Skip to content

Commit

Permalink
adds support for meshing in-vessel components
Browse files Browse the repository at this point in the history
  • Loading branch information
tokamaster committed Nov 20, 2024
1 parent 69fb5b6 commit 6cfe305
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
27 changes: 27 additions & 0 deletions parastell/invessel_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,33 @@ def export_cad_to_dagmc(self, dagmc_filename="dagmc", export_dir=""):

model.export_dagmc_h5m_file(filename=str(export_path))

def export_invessel_component_mesh(
self, components, mesh_size=5, import_dir="", export_dir=""
):
"""Creates a tetrahedral mesh of an in-vessel component volume
via Coreform Cubit and exports it as H5M file.
Arguments:
components (array of strings): array containing the name
of the in-vessel components to be meshed.
mesh_size (int): controls the size of the mesh. Takes values
between 1 (finer) and 10 (coarser) (optional, defaults to 5).
import_dir (str): directory containing the STEP file of
the in-vessel component (optional, defaults to empty string).
export_dir (str): directory to which to export the h5m
output file (optional, defaults to empty string).
"""
for component in components:
vol_id = cubit_io.import_step_cubit(component, import_dir)
cubit.cmd(f"volume {vol_id} scheme tetmesh")
cubit.cmd(f"volume {vol_id} size auto factor {mesh_size}")
cubit.cmd(f"mesh volume {vol_id}")
cubit_io.export_mesh_cubit(
filename=component,
export_dir=export_dir,
delete_upon_export=False,
)


class Surface(object):
"""An object representing a surface formed by lofting across a set of
Expand Down
21 changes: 21 additions & 0 deletions parastell/parastell.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,27 @@ def export_invessel_build(
dagmc_filename=dagmc_filename, export_dir=export_dir
)

def export_invessel_component_mesh(
self, components, mesh_size=5, import_dir="", export_dir=""
):
"""Creates a tetrahedral mesh of an in-vessel component volume
via Coreform Cubit and exports it as H5M file.
Arguments:
components (array of strings): array containing the name
of the in-vessel components to be meshed.
mesh_size (int): controls the size of the mesh. Takes values
between 1 (finer) and 10 (coarser) (optional, defaults to 5).
import_dir (str): directory containing the STEP file of
the in-vessel component (optional, defaults to empty string).
export_dir (str): directory to which to export the h5m
output file (optional, defaults to empty string).
"""
self._logger.info("Exporting in-vessel components mesh...")
self.invessel_build.export_invessel_component_mesh(
components, mesh_size, import_dir, export_dir
)

def construct_magnets(
self, coils_file, width, thickness, toroidal_extent, **kwargs
):
Expand Down
3 changes: 3 additions & 0 deletions tests/test_invessel_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,12 @@ def test_ivb_exports(invessel_build):
invessel_build.generate_components()
invessel_build.export_step()
invessel_build.export_cad_to_dagmc()
invessel_build.export_invessel_component_mesh()

assert Path("chamber.step").exists()
assert Path("component.step").exists()
assert Path("dagmc.h5m").exists()
assert Path("chamber.h5m").exists()
assert Path("component.h5m").exists()

remove_files()

0 comments on commit 6cfe305

Please sign in to comment.