From 945d1f015e52a16737a765c9337013cf5fa6397d Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@uliege.be> Date: Tue, 6 Oct 2020 16:34:33 +0200 Subject: [PATCH] plugin crack example in 3d --- demos/api/crack3d.py | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 demos/api/crack3d.py diff --git a/demos/api/crack3d.py b/demos/api/crack3d.py new file mode 100644 index 0000000000..beedf32dd8 --- /dev/null +++ b/demos/api/crack3d.py @@ -0,0 +1,44 @@ +import gmsh +import sys + +gmsh.initialize(sys.argv) + +gmsh.option.setNumber("General.Terminal", 1) + +# create 2 adjacent boxes + a smaller surface on the interface +v1 = gmsh.model.occ.addBox(0, 0, 0, 1, 1, 1) +v2 = gmsh.model.occ.addBox(0, 0, -1, 1, 1, 1) +s1 = gmsh.model.occ.addRectangle(0.25, 0.25, 0, 0.5, 0.5) + +# fragment the model to make the geometry conformal +out, out_map = gmsh.model.occ.fragment([(2, s1)], [(3, v1), (3, v2)]) + +# out_map contains the corresondence between the input and output entities after +# fragmentation: out_map[0] will thus contain the entities (as (dim, tag) pairs) +# replacing the surface s1 + +# synchronize with the topological model +gmsh.model.occ.synchronize() + +# define a physical group on the small surface (the "Crack" uses physical groups +# as input) +phys = gmsh.model.addPhysicalGroup(2, [out_map[0][0][1]]) + +# generate conformal mesh +gmsh.model.mesh.generate(3) + +# "crack" the mesh by duplicating the elements and nodes on the small surface +gmsh.plugin.setNumber("Crack", "Dimension", 2) +gmsh.plugin.setNumber("Crack", "PhysicalGroup", phys) +gmsh.plugin.run("Crack") + +# save all the elements in the mesh (even those that do not belong to any +# physical group): +gmsh.option.setNumber("Mesh.SaveAll", 1) +gmsh.write("crack.msh") + +# show the result +if '-nopopup' not in sys.argv: + gmsh.fltk.run() + +gmsh.finalize() -- GitLab