Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allowing msh export #43

Merged
merged 4 commits into from
Jul 25, 2023
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
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