diff --git a/src/cad_to_dagmc/brep_to_h5m.py b/src/cad_to_dagmc/brep_to_h5m.py index 685c849..6f046ce 100644 --- a/src/cad_to_dagmc/brep_to_h5m.py +++ b/src/cad_to_dagmc/brep_to_h5m.py @@ -45,6 +45,7 @@ def mesh_to_h5m_in_memory_method( volumes, material_tags: typing.Iterable[str], h5m_filename: str = "dagmc.h5m", + msh_filename=None, ) -> str: """Converts gmsh volumes into a DAGMC h5m file. @@ -106,7 +107,8 @@ def mesh_to_h5m_in_memory_method( GroupedCoords = [ all_coords[i : i + n].tolist() for i in range(0, len(all_coords), n) ] - + if msh_filename is not None: + gmsh.write(msh_filename) gmsh.finalize() # checks and fixes triangle fix_normals within vertices_to_h5m diff --git a/src/cad_to_dagmc/core.py b/src/cad_to_dagmc/core.py index b82574b..9521821 100644 --- a/src/cad_to_dagmc/core.py +++ b/src/cad_to_dagmc/core.py @@ -95,6 +95,7 @@ def export_dagmc_h5m_file( min_mesh_size: float = 1, max_mesh_size: float = 10, mesh_algorithm: int = 1, + msh_filename: str = None, ): assembly = cq.Assembly() for part in self.parts: @@ -128,6 +129,7 @@ def export_dagmc_h5m_file( volumes=volumes, material_tags=material_tags_in_brep_order, h5m_filename=filename, + msh_filename=msh_filename, ) return h5m_filename diff --git a/tests/test_h5m_creation.py b/tests/test_file_creation.py similarity index 97% rename from tests/test_h5m_creation.py rename to tests/test_file_creation.py index 2a38232..dcfe43f 100644 --- a/tests/test_h5m_creation.py +++ b/tests/test_file_creation.py @@ -51,8 +51,8 @@ def test_h5m_with_single_volume_list(): my_model = CadToDagmc() my_model.add_stp_file(filename="tests/single_cube.stp", material_tags=["mat1"]) - my_model.export_dagmc_h5m_file(filename=h5m_file) - + my_model.export_dagmc_h5m_file(filename=h5m_file, msh_filename="test.msh") + assert Path("test.msh").is_file() assert get_volumes_and_materials_from_h5m(h5m_file) == {1: "mat:mat1"}