Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions assembly_mesh_plugin/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,12 @@ def assembly_to_gmsh(self, mesh_path="tagged_mesh.msh"):
gmsh.finalize()


def assembly_to_imprinted_gmsh(self, mesh_path="tagged_mesh.msh"):
def get_imprinted_gmsh(self):
"""
Exports an imprinted assembly to capture conformal meshes.
Allows the user to get a gmsh object from the assembly, with the assembly being imprinted.
"""

# Initialize gmsh and create a new model
gmsh.initialize()
gmsh.option.setNumber("General.Terminal", 0)
gmsh.model.add("assembly")
Expand All @@ -208,7 +209,6 @@ def assembly_to_imprinted_gmsh(self, mesh_path="tagged_mesh.msh"):
cq.occ_impl.assembly.imprint(self)
)

print(imprinted_solids_with_orginal_ids)
for solid, id in imprinted_solids_with_orginal_ids.items():
# Add the current solid to the mesh
# Work-around for a segfault with in-memory passing of OCCT objects
Expand Down Expand Up @@ -297,6 +297,17 @@ def assembly_to_imprinted_gmsh(self, mesh_path="tagged_mesh.msh"):

gmsh.model.occ.synchronize()

return gmsh


def assembly_to_imprinted_gmsh(self, mesh_path="tagged_mesh.msh"):
"""
Exports an imprinted assembly to capture conformal meshes.
"""

# Turn this assembly into a imprinted gmsh object
gmsh = get_imprinted_gmsh(self)

gmsh.model.mesh.field.setAsBackgroundMesh(2)

gmsh.model.mesh.generate(3)
Expand All @@ -310,3 +321,4 @@ def assembly_to_imprinted_gmsh(self, mesh_path="tagged_mesh.msh"):
cq.Assembly.saveToGmsh = assembly_to_gmsh # Alias name that works better on cq.Assembly
cq.Assembly.getTaggedGmsh = get_tagged_gmsh
cq.Assembly.assemblyToImprintedGmsh = assembly_to_imprinted_gmsh
cq.Assembly.getImprintedGmsh = get_imprinted_gmsh
16 changes: 16 additions & 0 deletions tests/smoke_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,22 @@ def test_nested_cubes():
assert len(surfaces) == 18


def test_imprinted_assembly_mesh():
"""
Tests to make sure that the imprinted assembly mesh works correctly with tagging.
"""

# Create the basic assembly
assy = generate_test_cross_section()

# Convert eh assembly to an imprinted GMSH mesh
gmsh = assy.getImprintedGmsh()

# Make sure we have the correct number of surfaces
surfaces = gmsh.model.getEntities(2)
assert len(surfaces) == 56


def test_basic_assembly():
"""
Tests to make sure that the most basic assembly works correctly with tagging.
Expand Down
Loading