I´m trying to mesh a Volume with gmsh in Python and so far everything is fine, but my result in GMSH is with invisible surfaces. Because I want to build it later on as a structured grid it's quite annoying to click my way through
I can make the surfaces visible via
options -> mesh -> visibilty -> and then mark [2d element faces] and remove the mark on [3d element edges]
default is:
[2d element edges] and [3d element edges]
marked.
Is there a way for me to solve this in my code?
thank you all very much in advance and greetings
Michael
Here is my code:
import gmsh import math
def main():
gmsh.initialize()
# alias to facilitate code writing
factory = gmsh.model.geo
# default mesh size
lc = 1.
# Geometry
# points
p1 = factory.addPoint(0., 0., 0., lc)
p2 = factory.addPoint(10., 0., 0., lc)
p3 = factory.addPoint(0., 10., 0., lc)
p4 = factory.addPoint(4., 0., 0., lc)
p5 = factory.addPoint(0., 4., 0., lc)
p6 = factory.addPoint(4., 4., 0., lc)
angle = math.pi/4.
p7 = factory.addPoint(10*math.cos(angle), 10*math.sin(angle), 0., lc)
# lines
l1 = factory.addLine(p5, p6)
l2 = factory.addLine(p6, p4)
l3 = factory.addLine(p4, p1)
l4 = factory.addLine(p1, p5)
l5 = factory.addLine(p4, p2)
l6 = factory.addLine(p5, p3)
l7 = factory.addLine(p6, p7)
l8 = factory.addCircleArc(p2, p1, p7)
l9 = factory.addCircleArc(p7, p1, p3)
# curve loops
cl1 = factory.addCurveLoop([l3, l4, l1, l2])
cl2 = factory.addCurveLoop([l7, l9, -l6, l1])
cl3 = factory.addCurveLoop([l5, l8, -l7, l2])
# surfaces
s1 = factory.addPlaneSurface([cl1])
s2 = factory.addPlaneSurface([cl2])
s3 = factory.addPlaneSurface([cl3])
# extrusions
dx = 5.
num_els_z = 10
factory.extrude([(2, s1), (2, s2), (2, s3)], 0., 0., dx,
numElements=[num_els_z], recombine=True)
factory.synchronize()
# Meshing
meshFact = gmsh.model.mesh
# transfinite curves
n_nodes = 10
# "Progression" 1 is default
meshFact.setTransfiniteCurve(l1, numNodes=n_nodes)
meshFact.setTransfiniteCurve(l2, numNodes=n_nodes)
meshFact.setTransfiniteCurve(l3, numNodes=n_nodes)
meshFact.setTransfiniteCurve(l4, numNodes=n_nodes)
meshFact.setTransfiniteCurve(l5, numNodes=n_nodes)
meshFact.setTransfiniteCurve(l6, numNodes=n_nodes)
meshFact.setTransfiniteCurve(l7, numNodes=n_nodes)
meshFact.setTransfiniteCurve(l8, numNodes=n_nodes)
meshFact.setTransfiniteCurve(l9, numNodes=n_nodes)
# transfinite surfaces
meshFact.setTransfiniteSurface(s1)
meshFact.setTransfiniteSurface(s2)
meshFact.setTransfiniteSurface(s3)
# mesh
meshFact.generate(2)
meshFact.recombine()
meshFact.generate(3)
gmsh.fltk.run()
gmsh.finalize()
if __name__ == "__main__":
main()
This is my gmsh model as it is without any work on the visibility This is how I would like to get it straight out of the code