-
Notifications
You must be signed in to change notification settings - Fork 0
/
consistent_stl.py
36 lines (27 loc) · 1.05 KB
/
consistent_stl.py
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
import gmsh
import argparse
import math
parser = argparse.ArgumentParser(description="Input arguments")
parser.add_argument("input", metavar="input", type=str,
help="Path to mesh")
parser.add_argument("output", metavar="output", type=str,
help="Output path")
parser.add_argument("length", metavar="length", type=float,
help="Characteristic length mesh")
parser.add_argument("angle", metavar="angle", type=float,
help="""Angle at which new surface is defined in degrees.
If geometry is smooth, use 180, else use 45.""")
args = parser.parse_args()
gmsh.initialize()
gmsh.clear()
gmsh.option.setNumber("General.NumThreads", 4)
gmsh.merge(args.input)
angle = args.angle * math.pi / 180
gmsh.model.mesh.createTopology()
gmsh.model.mesh.classifySurfaces(angle, True, True)
gmsh.model.mesh.createGeometry()
gmsh.model.mesh.set_size(gmsh.model.getEntities(0), args.length)
gmsh.model.mesh.generate(2)
gmsh.model.mesh.optimize("Netgen")
gmsh.write(args.output)
gmsh.clear()