55import gmsh
66
77
8- def assembly_to_gmsh (self , mesh_path = "tagged_mesh.msh" ):
8+ def get_tagged_gmesh (self ):
99 """
10- Pack the assembly into a gmsh object, respecting assembly part names and face tags when creating
11- the physical groups .
10+ Allows the user to get a gmsh object from the assembly , respecting assembly part names and face
11+ tags, but have more control over how it is meshed .
1212 """
13-
1413 gmsh .initialize ()
1514 gmsh .option .setNumber ("General.Terminal" , 0 )
1615 gmsh .model .add ("coil_assembly" )
@@ -126,6 +125,18 @@ def assembly_to_gmsh(self, mesh_path="tagged_mesh.msh"):
126125
127126 gmsh .model .occ .synchronize ()
128127
128+ return gmsh
129+
130+
131+ def assembly_to_gmsh (self , mesh_path = "tagged_mesh.msh" ):
132+ """
133+ Pack the assembly into a gmsh object, respecting assembly part names and face tags when creating
134+ the physical groups.
135+ """
136+
137+ # Turn this assembly with potentially tagged faces into a gmsh object
138+ gmsh = get_tagged_gmesh (self )
139+
129140 gmsh .model .mesh .field .setAsBackgroundMesh (2 )
130141
131142 gmsh .model .mesh .generate (3 )
@@ -136,3 +147,5 @@ def assembly_to_gmsh(self, mesh_path="tagged_mesh.msh"):
136147
137148# Patch the new assembly functions into CadQuery's importers package
138149cq .Assembly .assemblyToGmsh = assembly_to_gmsh
150+ cq .Assembly .saveToGmsh = assembly_to_gmsh # Alias name that works better on cq.Assembly
151+ cq .Assembly .getTaggedGmesh = get_tagged_gmesh
0 commit comments