Skip to content

Commit

Permalink
Merge pull request #43 from fusion-energy/allowing_msh_export
Browse files Browse the repository at this point in the history
Allowing msh export
  • Loading branch information
shimwell authored Jul 25, 2023
2 parents 1dd2e51 + 023d613 commit bf0243c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/cad_to_dagmc/brep_to_h5m.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/cad_to_dagmc/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions tests/test_h5m_creation.py → tests/test_file_creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"}


Expand Down

0 comments on commit bf0243c

Please sign in to comment.