-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_mask.py
More file actions
46 lines (40 loc) · 1.33 KB
/
create_mask.py
File metadata and controls
46 lines (40 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import numpy as np
import qgis.core
import sys
import qmesh3
import argparse
def main():
parser = argparse.ArgumentParser(
prog="create_mask",
description="""Create a polygon from a simulation boundary shapefile"""
)
parser.add_argument(
'-v',
'--verbose',
action='store_true',
help="Verbose output: mainly progress reports.",
default=False
)
parser.add_argument(
'shapefile',
help='The shapefile used in qmesh when making your mesh'
)
parser.add_argument(
'output',
help='The output mask shapefile'
)
args = parser.parse_args()
verbose = args.verbose
shp_file = args.shapefile
output_mask = args.output
#Reading in the shapefile describing the domain boundaries, and creating a gmsh file.
boundaries = qmesh3.vector.shapefileTools.Shapes()
boundaries.fromFile(shp_file)
loopShapes = qmesh3.vector.shapefileTools.identifyLoops(boundaries,
isGlobal=False, defaultPhysID=1000,
fixOpenLoops=True)
polygonShapes = qmesh3.vector.shapefileTools.identifyPolygons(loopShapes, smallestMeshedArea=50000000,
meshedAreaPhysID = 1)
polygonShapes.writeFile(output_mask)
if __name__ == "__main__":
main()