cad-to-dagmc 0.7.7__tar.gz → 0.8.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of cad-to-dagmc might be problematic. Click here for more details.
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.0}/.github/workflows/ci_with_conda_install.yml +3 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.0}/.github/workflows/ci_with_pip_install.yml +2 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.0}/PKG-INFO +20 -16
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.0}/README.md +19 -15
- cad_to_dagmc-0.8.0/examples/surface_mesh/different_resolution_meshes.py +44 -0
- cad_to_dagmc-0.8.0/examples/unstrucutred_volume_mesh/different_resolution_meshes.py +44 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.0}/src/_version.py +2 -2
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.0}/src/cad_to_dagmc/core.py +56 -8
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.0}/src/cad_to_dagmc.egg-info/PKG-INFO +20 -16
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.0}/src/cad_to_dagmc.egg-info/SOURCES.txt +2 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.0}/.github/workflows/black.yml +0 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.0}/.github/workflows/ci_with_benchmarks.yml +0 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.0}/.github/workflows/python-publish.yml +0 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.0}/.gitignore +0 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.0}/CITATION.cff +0 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.0}/LICENSE +0 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.0}/examples/surface_mesh/cadquery_assembly.py +0 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.0}/examples/surface_mesh/cadquery_assembly_with_scaled_geometry.py +0 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.0}/examples/surface_mesh/cadquery_compound.py +0 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.0}/examples/surface_mesh/cadquery_object_and_stp_file.py +0 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.0}/examples/surface_mesh/cadquery_text.py +0 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.0}/examples/surface_mesh/curved_cadquery_object_to_dagmc_surface_mesh.py +0 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.0}/examples/surface_mesh/from_gmsh_mesh_file.py +0 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.0}/examples/surface_mesh/multiple_cadquery_objects.py +0 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.0}/examples/surface_mesh/multiple_stp_files.py +0 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.0}/examples/surface_mesh/single_cadquery_object.py +0 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.0}/examples/surface_mesh/single_stp_file.py +0 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.0}/examples/surface_mesh/single_stp_file_multiple_volumes.py +0 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.0}/examples/unstrucutred_volume_mesh/curved_cadquery_object_to_dagmc_volume_mesh.py +0 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.0}/examples/unstrucutred_volume_mesh/simulate_unstrucutred_volume_mesh_with_openmc.py +0 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.0}/pyproject.toml +0 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.0}/setup.cfg +0 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.0}/src/cad_to_dagmc/__init__.py +0 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.0}/src/cad_to_dagmc.egg-info/dependency_links.txt +0 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.0}/src/cad_to_dagmc.egg-info/requires.txt +0 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.0}/src/cad_to_dagmc.egg-info/top_level.txt +0 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.0}/tests/ENDFB-7.1-NNDC_H1.h5 +0 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.0}/tests/ball_reactor.brep +0 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.0}/tests/curved_extrude.stp +0 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.0}/tests/extrude_rectangle.stp +0 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.0}/tests/multi_volume_cylinders.stp +0 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.0}/tests/one_cube.brep +0 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.0}/tests/single_cube.stp +0 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.0}/tests/single_volume_thin.stp +0 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.0}/tests/single_volume_thin.vtk +0 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.0}/tests/test_brep_file.brep +0 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.0}/tests/test_file_creation.py +0 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.0}/tests/test_h5m_in_transport.py +0 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.0}/tests/test_loading_from_file_vs_shape_object.py +0 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.0}/tests/test_python_api.py +0 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.0}/tests/test_two_joined_cubes.brep +0 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.0}/tests/test_two_sep_cubes.brep +0 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.0}/tests/test_version.py +0 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.0}/tests/two_connected_cubes.stp +0 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.0}/tests/two_disconnected_cubes.stp +0 -0
|
@@ -72,3 +72,6 @@ jobs:
|
|
|
72
72
|
python examples/surface_mesh/single_stp_file.py
|
|
73
73
|
python examples/unstrucutred_volume_mesh/curved_cadquery_object_to_dagmc_volume_mesh.py
|
|
74
74
|
python examples/unstrucutred_volume_mesh/simulate_unstrucutred_volume_mesh_with_openmc.py
|
|
75
|
+
python examples/unstrucutred_volume_mesh/different_resolution_meshes.py
|
|
76
|
+
python examples/surface_mesh/different_resolution_meshes.py
|
|
77
|
+
python examples/surface_mesh/cadquery_assembly_with_scaled_geometry.py
|
|
@@ -58,4 +58,6 @@ jobs:
|
|
|
58
58
|
python examples/surface_mesh/from_gmsh_mesh_file.py
|
|
59
59
|
python examples/unstrucutred_volume_mesh/curved_cadquery_object_to_dagmc_volume_mesh.py
|
|
60
60
|
python examples/unstrucutred_volume_mesh/simulate_unstrucutred_volume_mesh_with_openmc.py
|
|
61
|
+
python examples/unstrucutred_volume_mesh/different_resolution_meshes.py
|
|
62
|
+
python examples/surface_mesh/different_resolution_meshes.py
|
|
61
63
|
python examples/surface_mesh/cadquery_assembly_with_scaled_geometry.py
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: cad_to_dagmc
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.8.0
|
|
4
4
|
Summary: Converts CAD files to a DAGMC h5m file
|
|
5
5
|
Author-email: Jonathan Shimwell <mail@jshimwell.com>
|
|
6
6
|
Project-URL: Homepage, https://github.com/fusion-energy/cad_to_dagmc
|
|
@@ -35,7 +35,7 @@ Requires-Dist: vtk; extra == "tests"
|
|
|
35
35
|
[](https://pypi.org/project/cad_to_dagmc/)
|
|
36
36
|
|
|
37
37
|
|
|
38
|
-
A minimal package that converts CAD geometry to [DAGMC](https://github.com/svalinn/DAGMC/)
|
|
38
|
+
A minimal package that converts CAD geometry to [DAGMC](https://github.com/svalinn/DAGMC/) (h5m) files, [unstructured mesh](https://docs.openmc.org/en/latest/pythonapi/generated/openmc.UnstructuredMesh.html) files (vtk) and Gmsh (msh) files ready for use in neutronics simulations.
|
|
39
39
|
|
|
40
40
|
cad-to-dagmc can create DAGMC compatible:
|
|
41
41
|
- surface meshes / faceted geometry / triangular meshes
|
|
@@ -43,23 +43,23 @@ cad-to-dagmc can create DAGMC compatible:
|
|
|
43
43
|
|
|
44
44
|
cad-to-dagmc can convert the following in to DAGMC compatible meshes:
|
|
45
45
|
- STEP files
|
|
46
|
-
- CadQuery objects
|
|
46
|
+
- CadQuery objects (in memory)
|
|
47
47
|
- Gmsh meshes
|
|
48
48
|
|
|
49
|
-
|
|
50
|
-
-
|
|
51
|
-
-
|
|
52
|
-
-
|
|
53
|
-
-
|
|
54
|
-
-
|
|
49
|
+
Cad-to-dagmc offers a wide range of features including.
|
|
50
|
+
- Geometry scaling with ```scale_factor``` argument
|
|
51
|
+
- Model wide mesh size parameters with ```min_mesh_size``` and ```max_mesh_size``` arguments
|
|
52
|
+
- Volume specific mesh sizing parameters with the ```set_size``` argument
|
|
53
|
+
- Parallel meshing to quickly mesh the geometry using multiple CPU cores
|
|
54
|
+
- Imprint and merging of CAD geometry, or disable with the ```imprint``` argument
|
|
55
|
+
- Add geometry from multiple sources ([STEP](http://www.steptools.com/stds/step/) files, [CadQuery](https://cadquery.readthedocs.io) objects and [Gmsh](https://gmsh.info/) meshes)
|
|
56
|
+
- Ability to tag the DAGMC implicit complement material using the ```implicit_complement_material_tag``` argument
|
|
57
|
+
- Selected different Gmesh mesh algorithms (defaults to 1) using the ```mesh_algorithm``` argument
|
|
58
|
+
- Pass CadQuery objects in memory for fast transfer of geometry using the ```method``` argument
|
|
59
|
+
- Easy to install with [pip](https://pypi.org/project/cad-to-dagmc/) and [Conda/Mamba](https://anaconda.org/conda-forge/cad_to_dagmc)
|
|
60
|
+
- Well tested both with [CI unit tests](https://github.com/fusion-energy/cad_to_dagmc/tree/main/tests), integration tests and the CSG [Model Benchmark Zoo](https://github.com/fusion-energy/model_benchmark_zoo).
|
|
61
|
+
- Compatible with [Paramak](https://github.com/fusion-energy/paramak) geometry for fusion simulations.
|
|
55
62
|
|
|
56
|
-
cad-to-dagmc aims to produce DAGMC compatible h5m and vtk files from CAD geometry is intended to convert [STEP](http://www.steptools.com/stds/step/) files, [CadQuery](https://cadquery.readthedocs.io) or [Gmsh]([https://cadquery.readthedocs.io](https://gmsh.info/)) meshes objects to a [DAGMC](https://github.com/svalinn/DAGMC/) compatible h5m file or a DAGMC compatible Unstruuctre vtk file.
|
|
57
|
-
|
|
58
|
-
The resulting DAGMC geometry can then be used for simulations in [OpenMC](https://github.com/openmc-dev/openmc/) or [other supported codes](https://svalinn.github.io/DAGMC/).
|
|
59
|
-
|
|
60
|
-
This package is tested with [pytest tests](https://github.com/fusion-energy/cad_to_dagmc/tree/main/tests) and also the DAGMC geometry made with this package is compared to simulation carried out with native constructive solid geometry, see [Model Benchmark Zoo](https://github.com/fusion-energy/model_benchmark_zoo) for more details.
|
|
61
|
-
|
|
62
|
-
Also checkout these other software projects that also create DAGMC geometry [CAD-to-OpenMC](https://github.com/openmsr/CAD_to_OpenMC), [Stellarmesh](https://github.com/Thea-Energy/stellarmesh) and [Coreform Cubit](https://coreform.com/products/coreform-cubit/)
|
|
63
63
|
|
|
64
64
|
# Installation options
|
|
65
65
|
|
|
@@ -176,3 +176,7 @@ Installing one of the package dependancies (Gmsh) with pip appears to result in
|
|
|
176
176
|
For examples showing creation of DAGMC h5m files, vtk files and usage within OpenMC transport code see the [examples folder](https://github.com/fusion-energy/cad_to_dagmc/tree/main/examples)
|
|
177
177
|
|
|
178
178
|
For more examples see the CAD tasks in the [neutronics-workshop](https://github.com/fusion-energy/neutronics-workshop) and [model benchmark zoo](https://github.com/fusion-energy/model_benchmark_zoo)
|
|
179
|
+
|
|
180
|
+
# Related software
|
|
181
|
+
|
|
182
|
+
Also checkout these other software projects that also create DAGMC geometry [CAD-to-OpenMC](https://github.com/openmsr/CAD_to_OpenMC), [Stellarmesh](https://github.com/Thea-Energy/stellarmesh) and [Coreform Cubit](https://coreform.com/products/coreform-cubit/).
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
[](https://pypi.org/project/cad_to_dagmc/)
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
A minimal package that converts CAD geometry to [DAGMC](https://github.com/svalinn/DAGMC/)
|
|
15
|
+
A minimal package that converts CAD geometry to [DAGMC](https://github.com/svalinn/DAGMC/) (h5m) files, [unstructured mesh](https://docs.openmc.org/en/latest/pythonapi/generated/openmc.UnstructuredMesh.html) files (vtk) and Gmsh (msh) files ready for use in neutronics simulations.
|
|
16
16
|
|
|
17
17
|
cad-to-dagmc can create DAGMC compatible:
|
|
18
18
|
- surface meshes / faceted geometry / triangular meshes
|
|
@@ -20,23 +20,23 @@ cad-to-dagmc can create DAGMC compatible:
|
|
|
20
20
|
|
|
21
21
|
cad-to-dagmc can convert the following in to DAGMC compatible meshes:
|
|
22
22
|
- STEP files
|
|
23
|
-
- CadQuery objects
|
|
23
|
+
- CadQuery objects (in memory)
|
|
24
24
|
- Gmsh meshes
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
-
|
|
28
|
-
-
|
|
29
|
-
-
|
|
30
|
-
-
|
|
31
|
-
-
|
|
26
|
+
Cad-to-dagmc offers a wide range of features including.
|
|
27
|
+
- Geometry scaling with ```scale_factor``` argument
|
|
28
|
+
- Model wide mesh size parameters with ```min_mesh_size``` and ```max_mesh_size``` arguments
|
|
29
|
+
- Volume specific mesh sizing parameters with the ```set_size``` argument
|
|
30
|
+
- Parallel meshing to quickly mesh the geometry using multiple CPU cores
|
|
31
|
+
- Imprint and merging of CAD geometry, or disable with the ```imprint``` argument
|
|
32
|
+
- Add geometry from multiple sources ([STEP](http://www.steptools.com/stds/step/) files, [CadQuery](https://cadquery.readthedocs.io) objects and [Gmsh](https://gmsh.info/) meshes)
|
|
33
|
+
- Ability to tag the DAGMC implicit complement material using the ```implicit_complement_material_tag``` argument
|
|
34
|
+
- Selected different Gmesh mesh algorithms (defaults to 1) using the ```mesh_algorithm``` argument
|
|
35
|
+
- Pass CadQuery objects in memory for fast transfer of geometry using the ```method``` argument
|
|
36
|
+
- Easy to install with [pip](https://pypi.org/project/cad-to-dagmc/) and [Conda/Mamba](https://anaconda.org/conda-forge/cad_to_dagmc)
|
|
37
|
+
- Well tested both with [CI unit tests](https://github.com/fusion-energy/cad_to_dagmc/tree/main/tests), integration tests and the CSG [Model Benchmark Zoo](https://github.com/fusion-energy/model_benchmark_zoo).
|
|
38
|
+
- Compatible with [Paramak](https://github.com/fusion-energy/paramak) geometry for fusion simulations.
|
|
32
39
|
|
|
33
|
-
cad-to-dagmc aims to produce DAGMC compatible h5m and vtk files from CAD geometry is intended to convert [STEP](http://www.steptools.com/stds/step/) files, [CadQuery](https://cadquery.readthedocs.io) or [Gmsh]([https://cadquery.readthedocs.io](https://gmsh.info/)) meshes objects to a [DAGMC](https://github.com/svalinn/DAGMC/) compatible h5m file or a DAGMC compatible Unstruuctre vtk file.
|
|
34
|
-
|
|
35
|
-
The resulting DAGMC geometry can then be used for simulations in [OpenMC](https://github.com/openmc-dev/openmc/) or [other supported codes](https://svalinn.github.io/DAGMC/).
|
|
36
|
-
|
|
37
|
-
This package is tested with [pytest tests](https://github.com/fusion-energy/cad_to_dagmc/tree/main/tests) and also the DAGMC geometry made with this package is compared to simulation carried out with native constructive solid geometry, see [Model Benchmark Zoo](https://github.com/fusion-energy/model_benchmark_zoo) for more details.
|
|
38
|
-
|
|
39
|
-
Also checkout these other software projects that also create DAGMC geometry [CAD-to-OpenMC](https://github.com/openmsr/CAD_to_OpenMC), [Stellarmesh](https://github.com/Thea-Energy/stellarmesh) and [Coreform Cubit](https://coreform.com/products/coreform-cubit/)
|
|
40
40
|
|
|
41
41
|
# Installation options
|
|
42
42
|
|
|
@@ -153,3 +153,7 @@ Installing one of the package dependancies (Gmsh) with pip appears to result in
|
|
|
153
153
|
For examples showing creation of DAGMC h5m files, vtk files and usage within OpenMC transport code see the [examples folder](https://github.com/fusion-energy/cad_to_dagmc/tree/main/examples)
|
|
154
154
|
|
|
155
155
|
For more examples see the CAD tasks in the [neutronics-workshop](https://github.com/fusion-energy/neutronics-workshop) and [model benchmark zoo](https://github.com/fusion-energy/model_benchmark_zoo)
|
|
156
|
+
|
|
157
|
+
# Related software
|
|
158
|
+
|
|
159
|
+
Also checkout these other software projects that also create DAGMC geometry [CAD-to-OpenMC](https://github.com/openmsr/CAD_to_OpenMC), [Stellarmesh](https://github.com/Thea-Energy/stellarmesh) and [Coreform Cubit](https://coreform.com/products/coreform-cubit/).
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# This example makes 3 CAD boxes
|
|
2
|
+
# Meshes the 3 volumes with different resolutions
|
|
3
|
+
# exports the mesh to a DAGMC h5m file and GMsh msh file
|
|
4
|
+
import cadquery as cq
|
|
5
|
+
from cad_to_dagmc import CadToDagmc
|
|
6
|
+
|
|
7
|
+
box_set_size_course_mesh = cq.Workplane().box(1, 1, 2)
|
|
8
|
+
box_set_size_fine_mesh = cq.Workplane().moveTo(1, 0.5).box(1, 1, 1.5)
|
|
9
|
+
box_set_global_mesh = cq.Workplane().moveTo(2, 1).box(1, 1, 1)
|
|
10
|
+
|
|
11
|
+
assembly = cq.Assembly()
|
|
12
|
+
assembly.add(box_set_size_course_mesh, color=cq.Color(0, 0, 1))
|
|
13
|
+
assembly.add(box_set_size_fine_mesh, color=cq.Color(0, 1, 0))
|
|
14
|
+
assembly.add(box_set_global_mesh, color=cq.Color(1, 0, 0))
|
|
15
|
+
|
|
16
|
+
assembly.export("different_resolution_meshes.step")
|
|
17
|
+
|
|
18
|
+
# uncomment to see the assembly in a pop up vtk viewer
|
|
19
|
+
# from cadquery import vis
|
|
20
|
+
# vis.show(assembly)
|
|
21
|
+
|
|
22
|
+
model = CadToDagmc()
|
|
23
|
+
model.add_cadquery_object(assembly, material_tags=["mat1", "mat2", "mat3"])
|
|
24
|
+
|
|
25
|
+
model.export_dagmc_h5m_file(
|
|
26
|
+
filename="different_resolution_meshes.h5m",
|
|
27
|
+
min_mesh_size=0.01,
|
|
28
|
+
max_mesh_size=10,
|
|
29
|
+
set_size={
|
|
30
|
+
1: 0.9,
|
|
31
|
+
2: 0.1,
|
|
32
|
+
}, # not volume 3 is not specified in the set_size so it uses only the min max mesh sizes
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
model.export_gmsh_mesh_file(
|
|
36
|
+
filename="different_resolution_meshes.msh",
|
|
37
|
+
dimensions=2,
|
|
38
|
+
min_mesh_size=0.01,
|
|
39
|
+
max_mesh_size=10,
|
|
40
|
+
set_size={
|
|
41
|
+
1: 0.9,
|
|
42
|
+
2: 0.1,
|
|
43
|
+
}, # not volume 3 is not specified in the set_size so it uses only the min max mesh sizes
|
|
44
|
+
)
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# This example makes 3 CAD boxes
|
|
2
|
+
# Meshes the 3 volumes with different resolutions
|
|
3
|
+
# exports the mesh to a DAGMC unstructured VTK file and Gmsh msh file
|
|
4
|
+
import cadquery as cq
|
|
5
|
+
from cad_to_dagmc import CadToDagmc
|
|
6
|
+
|
|
7
|
+
box_set_size_course_mesh = cq.Workplane().box(1, 1, 2)
|
|
8
|
+
box_set_size_fine_mesh = cq.Workplane().moveTo(1, 0.5).box(1, 1, 1.5)
|
|
9
|
+
box_set_global_mesh = cq.Workplane().moveTo(2, 1).box(1, 1, 1)
|
|
10
|
+
|
|
11
|
+
assembly = cq.Assembly()
|
|
12
|
+
assembly.add(box_set_size_course_mesh, color=cq.Color(0, 0, 1))
|
|
13
|
+
assembly.add(box_set_size_fine_mesh, color=cq.Color(0, 1, 0))
|
|
14
|
+
assembly.add(box_set_global_mesh, color=cq.Color(1, 0, 0))
|
|
15
|
+
|
|
16
|
+
assembly.export("different_resolution_meshes.step")
|
|
17
|
+
|
|
18
|
+
# uncomment to see the assembly in a pop up vtk viewer
|
|
19
|
+
# from cadquery import vis
|
|
20
|
+
# vis.show(assembly)
|
|
21
|
+
|
|
22
|
+
model = CadToDagmc()
|
|
23
|
+
model.add_cadquery_object(assembly, material_tags=["mat1", "mat2", "mat3"])
|
|
24
|
+
|
|
25
|
+
model.export_gmsh_mesh_file(
|
|
26
|
+
filename="different_resolution_meshes.msh",
|
|
27
|
+
dimensions=3,
|
|
28
|
+
min_mesh_size=0.01,
|
|
29
|
+
max_mesh_size=10,
|
|
30
|
+
set_size={
|
|
31
|
+
1: 0.9,
|
|
32
|
+
2: 0.1,
|
|
33
|
+
}, # not volume 3 is not specified in the set_size so it uses only the min max mesh sizes
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
model.export_unstructured_mesh_file(
|
|
37
|
+
filename="different_resolution_meshes.vtk",
|
|
38
|
+
min_mesh_size=0.01,
|
|
39
|
+
max_mesh_size=10,
|
|
40
|
+
set_size={
|
|
41
|
+
1: 0.9,
|
|
42
|
+
2: 0.1,
|
|
43
|
+
}, # not volume 3 is not specified in the set_size so it uses only the min max mesh sizes
|
|
44
|
+
)
|
|
@@ -235,10 +235,11 @@ def init_gmsh():
|
|
|
235
235
|
|
|
236
236
|
def _mesh_brep(
|
|
237
237
|
gmsh,
|
|
238
|
-
min_mesh_size: float =
|
|
239
|
-
max_mesh_size: float =
|
|
238
|
+
min_mesh_size: float | None = None,
|
|
239
|
+
max_mesh_size: float | None = None,
|
|
240
240
|
mesh_algorithm: int = 1,
|
|
241
241
|
dimensions: int = 2,
|
|
242
|
+
set_size: dict[int, float] | None = None,
|
|
242
243
|
):
|
|
243
244
|
"""Creates a conformal surface meshes of the volumes in a Brep file using Gmsh.
|
|
244
245
|
|
|
@@ -252,15 +253,49 @@ def _mesh_brep(
|
|
|
252
253
|
gmsh.option.setNumber("Mesh.Algorithm", mesh_algorithm)
|
|
253
254
|
dimensions: The number of dimensions, 2 for a surface mesh 3 for a
|
|
254
255
|
volume mesh. Passed to gmsh.model.mesh.generate()
|
|
256
|
+
set_size: a dictionary of volume ids (int) and target mesh sizes
|
|
257
|
+
(floats) to set for each volume, passed to gmsh.model.mesh.setSize.
|
|
255
258
|
|
|
256
259
|
Returns:
|
|
257
260
|
The resulting gmsh object and volumes
|
|
258
261
|
"""
|
|
262
|
+
if min_mesh_size and max_mesh_size:
|
|
263
|
+
if min_mesh_size > max_mesh_size:
|
|
264
|
+
raise ValueError(
|
|
265
|
+
f"min_mesh_size must be less than or equal to max_mesh_size. Currently min_mesh_size is set to {min_mesh_size} and max_mesh_size is set to {max_mesh_size}"
|
|
266
|
+
)
|
|
267
|
+
|
|
268
|
+
if min_mesh_size:
|
|
269
|
+
gmsh.option.setNumber("Mesh.MeshSizeMin", min_mesh_size)
|
|
270
|
+
|
|
271
|
+
if max_mesh_size:
|
|
272
|
+
gmsh.option.setNumber("Mesh.MeshSizeMax", max_mesh_size)
|
|
259
273
|
|
|
260
274
|
gmsh.option.setNumber("Mesh.Algorithm", mesh_algorithm)
|
|
261
|
-
gmsh.option.setNumber("Mesh.MeshSizeMin", min_mesh_size)
|
|
262
|
-
gmsh.option.setNumber("Mesh.MeshSizeMax", max_mesh_size)
|
|
263
275
|
gmsh.option.setNumber("General.NumThreads", 0) # Use all available cores
|
|
276
|
+
|
|
277
|
+
if set_size:
|
|
278
|
+
volumes = gmsh.model.getEntities(3)
|
|
279
|
+
available_volumes = [volume[1] for volume in volumes]
|
|
280
|
+
print("volumes", volumes)
|
|
281
|
+
for volume_id, size in set_size.items():
|
|
282
|
+
if volume_id in available_volumes:
|
|
283
|
+
size = set_size[volume_id]
|
|
284
|
+
if isinstance(size, dict):
|
|
285
|
+
# TODO face specific mesh sizes
|
|
286
|
+
pass
|
|
287
|
+
else:
|
|
288
|
+
boundaries = gmsh.model.getBoundary(
|
|
289
|
+
[(3, volume_id)], recursive=True
|
|
290
|
+
) # dim must be set to 3
|
|
291
|
+
print("boundaries", boundaries)
|
|
292
|
+
gmsh.model.mesh.setSize(boundaries, size)
|
|
293
|
+
print(f"Set size of {size} for volume {volume_id}")
|
|
294
|
+
else:
|
|
295
|
+
raise ValueError(
|
|
296
|
+
f"volume ID of {volume_id} set in set_sizes but not found in available volumes {volumes}"
|
|
297
|
+
)
|
|
298
|
+
|
|
264
299
|
gmsh.model.mesh.generate(dimensions)
|
|
265
300
|
|
|
266
301
|
return gmsh
|
|
@@ -508,6 +543,7 @@ class CadToDagmc:
|
|
|
508
543
|
method: str = "file",
|
|
509
544
|
scale_factor: float = 1.0,
|
|
510
545
|
imprint: bool = True,
|
|
546
|
+
set_size: dict[int, float] | None = None,
|
|
511
547
|
):
|
|
512
548
|
"""
|
|
513
549
|
Exports an unstructured mesh file in VTK format for use with openmc.UnstructuredMesh.
|
|
@@ -539,6 +575,9 @@ class CadToDagmc:
|
|
|
539
575
|
normally needed to ensure the geometry is meshed correctly. However if
|
|
540
576
|
you know your geometry does not need imprinting you can set this to False
|
|
541
577
|
and this can save time.
|
|
578
|
+
set_size: a dictionary of volume ids (int) and target mesh sizes
|
|
579
|
+
(floats) to set for each volume, passed to gmsh.model.mesh.setSize.
|
|
580
|
+
|
|
542
581
|
|
|
543
582
|
Returns:
|
|
544
583
|
--------
|
|
@@ -570,6 +609,7 @@ class CadToDagmc:
|
|
|
570
609
|
max_mesh_size=max_mesh_size,
|
|
571
610
|
mesh_algorithm=mesh_algorithm,
|
|
572
611
|
dimensions=3,
|
|
612
|
+
set_size=set_size,
|
|
573
613
|
)
|
|
574
614
|
|
|
575
615
|
# makes the folder if it does not exist
|
|
@@ -589,13 +629,14 @@ class CadToDagmc:
|
|
|
589
629
|
def export_gmsh_mesh_file(
|
|
590
630
|
self,
|
|
591
631
|
filename: str = "mesh.msh",
|
|
592
|
-
min_mesh_size: float =
|
|
593
|
-
max_mesh_size: float =
|
|
632
|
+
min_mesh_size: float | None = None,
|
|
633
|
+
max_mesh_size: float | None = None,
|
|
594
634
|
mesh_algorithm: int = 1,
|
|
595
635
|
dimensions: int = 2,
|
|
596
636
|
method: str = "file",
|
|
597
637
|
scale_factor: float = 1.0,
|
|
598
638
|
imprint: bool = True,
|
|
639
|
+
set_size: dict[int, float] | None = None,
|
|
599
640
|
):
|
|
600
641
|
"""Saves a GMesh msh file of the geometry in either 2D surface mesh or
|
|
601
642
|
3D volume mesh.
|
|
@@ -622,6 +663,8 @@ class CadToDagmc:
|
|
|
622
663
|
normally needed to ensure the geometry is meshed correctly. However if
|
|
623
664
|
you know your geometry does not need imprinting you can set this to False
|
|
624
665
|
and this can save time.
|
|
666
|
+
set_size: a dictionary of volume ids (int) and target mesh sizes
|
|
667
|
+
(floats) to set for each volume, passed to gmsh.model.mesh.setSize.
|
|
625
668
|
"""
|
|
626
669
|
|
|
627
670
|
assembly = cq.Assembly()
|
|
@@ -643,6 +686,7 @@ class CadToDagmc:
|
|
|
643
686
|
max_mesh_size=max_mesh_size,
|
|
644
687
|
mesh_algorithm=mesh_algorithm,
|
|
645
688
|
dimensions=dimensions,
|
|
689
|
+
set_size=set_size,
|
|
646
690
|
)
|
|
647
691
|
|
|
648
692
|
# makes the folder if it does not exist
|
|
@@ -662,13 +706,14 @@ class CadToDagmc:
|
|
|
662
706
|
def export_dagmc_h5m_file(
|
|
663
707
|
self,
|
|
664
708
|
filename: str = "dagmc.h5m",
|
|
665
|
-
min_mesh_size: float =
|
|
666
|
-
max_mesh_size: float =
|
|
709
|
+
min_mesh_size: float | None = None,
|
|
710
|
+
max_mesh_size: float | None = None,
|
|
667
711
|
mesh_algorithm: int = 1,
|
|
668
712
|
implicit_complement_material_tag: str | None = None,
|
|
669
713
|
method: str = "file",
|
|
670
714
|
scale_factor: float = 1.0,
|
|
671
715
|
imprint: bool = True,
|
|
716
|
+
set_size: dict[int, float] | None = None,
|
|
672
717
|
) -> str:
|
|
673
718
|
"""Saves a DAGMC h5m file of the geometry
|
|
674
719
|
|
|
@@ -695,6 +740,8 @@ class CadToDagmc:
|
|
|
695
740
|
normally needed to ensure the geometry is meshed correctly. However if
|
|
696
741
|
you know your geometry does not need imprinting you can set this to False
|
|
697
742
|
and this can save time.
|
|
743
|
+
set_size: a dictionary of volume ids (int) and target mesh sizes
|
|
744
|
+
(floats) to set for each volume, passed to gmsh.model.mesh.setSize.
|
|
698
745
|
|
|
699
746
|
Returns:
|
|
700
747
|
str: the DAGMC filename saved
|
|
@@ -739,6 +786,7 @@ class CadToDagmc:
|
|
|
739
786
|
min_mesh_size=min_mesh_size,
|
|
740
787
|
max_mesh_size=max_mesh_size,
|
|
741
788
|
mesh_algorithm=mesh_algorithm,
|
|
789
|
+
set_size=set_size,
|
|
742
790
|
)
|
|
743
791
|
|
|
744
792
|
dims_and_vol_ids = volumes
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: cad_to_dagmc
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.8.0
|
|
4
4
|
Summary: Converts CAD files to a DAGMC h5m file
|
|
5
5
|
Author-email: Jonathan Shimwell <mail@jshimwell.com>
|
|
6
6
|
Project-URL: Homepage, https://github.com/fusion-energy/cad_to_dagmc
|
|
@@ -35,7 +35,7 @@ Requires-Dist: vtk; extra == "tests"
|
|
|
35
35
|
[](https://pypi.org/project/cad_to_dagmc/)
|
|
36
36
|
|
|
37
37
|
|
|
38
|
-
A minimal package that converts CAD geometry to [DAGMC](https://github.com/svalinn/DAGMC/)
|
|
38
|
+
A minimal package that converts CAD geometry to [DAGMC](https://github.com/svalinn/DAGMC/) (h5m) files, [unstructured mesh](https://docs.openmc.org/en/latest/pythonapi/generated/openmc.UnstructuredMesh.html) files (vtk) and Gmsh (msh) files ready for use in neutronics simulations.
|
|
39
39
|
|
|
40
40
|
cad-to-dagmc can create DAGMC compatible:
|
|
41
41
|
- surface meshes / faceted geometry / triangular meshes
|
|
@@ -43,23 +43,23 @@ cad-to-dagmc can create DAGMC compatible:
|
|
|
43
43
|
|
|
44
44
|
cad-to-dagmc can convert the following in to DAGMC compatible meshes:
|
|
45
45
|
- STEP files
|
|
46
|
-
- CadQuery objects
|
|
46
|
+
- CadQuery objects (in memory)
|
|
47
47
|
- Gmsh meshes
|
|
48
48
|
|
|
49
|
-
|
|
50
|
-
-
|
|
51
|
-
-
|
|
52
|
-
-
|
|
53
|
-
-
|
|
54
|
-
-
|
|
49
|
+
Cad-to-dagmc offers a wide range of features including.
|
|
50
|
+
- Geometry scaling with ```scale_factor``` argument
|
|
51
|
+
- Model wide mesh size parameters with ```min_mesh_size``` and ```max_mesh_size``` arguments
|
|
52
|
+
- Volume specific mesh sizing parameters with the ```set_size``` argument
|
|
53
|
+
- Parallel meshing to quickly mesh the geometry using multiple CPU cores
|
|
54
|
+
- Imprint and merging of CAD geometry, or disable with the ```imprint``` argument
|
|
55
|
+
- Add geometry from multiple sources ([STEP](http://www.steptools.com/stds/step/) files, [CadQuery](https://cadquery.readthedocs.io) objects and [Gmsh](https://gmsh.info/) meshes)
|
|
56
|
+
- Ability to tag the DAGMC implicit complement material using the ```implicit_complement_material_tag``` argument
|
|
57
|
+
- Selected different Gmesh mesh algorithms (defaults to 1) using the ```mesh_algorithm``` argument
|
|
58
|
+
- Pass CadQuery objects in memory for fast transfer of geometry using the ```method``` argument
|
|
59
|
+
- Easy to install with [pip](https://pypi.org/project/cad-to-dagmc/) and [Conda/Mamba](https://anaconda.org/conda-forge/cad_to_dagmc)
|
|
60
|
+
- Well tested both with [CI unit tests](https://github.com/fusion-energy/cad_to_dagmc/tree/main/tests), integration tests and the CSG [Model Benchmark Zoo](https://github.com/fusion-energy/model_benchmark_zoo).
|
|
61
|
+
- Compatible with [Paramak](https://github.com/fusion-energy/paramak) geometry for fusion simulations.
|
|
55
62
|
|
|
56
|
-
cad-to-dagmc aims to produce DAGMC compatible h5m and vtk files from CAD geometry is intended to convert [STEP](http://www.steptools.com/stds/step/) files, [CadQuery](https://cadquery.readthedocs.io) or [Gmsh]([https://cadquery.readthedocs.io](https://gmsh.info/)) meshes objects to a [DAGMC](https://github.com/svalinn/DAGMC/) compatible h5m file or a DAGMC compatible Unstruuctre vtk file.
|
|
57
|
-
|
|
58
|
-
The resulting DAGMC geometry can then be used for simulations in [OpenMC](https://github.com/openmc-dev/openmc/) or [other supported codes](https://svalinn.github.io/DAGMC/).
|
|
59
|
-
|
|
60
|
-
This package is tested with [pytest tests](https://github.com/fusion-energy/cad_to_dagmc/tree/main/tests) and also the DAGMC geometry made with this package is compared to simulation carried out with native constructive solid geometry, see [Model Benchmark Zoo](https://github.com/fusion-energy/model_benchmark_zoo) for more details.
|
|
61
|
-
|
|
62
|
-
Also checkout these other software projects that also create DAGMC geometry [CAD-to-OpenMC](https://github.com/openmsr/CAD_to_OpenMC), [Stellarmesh](https://github.com/Thea-Energy/stellarmesh) and [Coreform Cubit](https://coreform.com/products/coreform-cubit/)
|
|
63
63
|
|
|
64
64
|
# Installation options
|
|
65
65
|
|
|
@@ -176,3 +176,7 @@ Installing one of the package dependancies (Gmsh) with pip appears to result in
|
|
|
176
176
|
For examples showing creation of DAGMC h5m files, vtk files and usage within OpenMC transport code see the [examples folder](https://github.com/fusion-energy/cad_to_dagmc/tree/main/examples)
|
|
177
177
|
|
|
178
178
|
For more examples see the CAD tasks in the [neutronics-workshop](https://github.com/fusion-energy/neutronics-workshop) and [model benchmark zoo](https://github.com/fusion-energy/model_benchmark_zoo)
|
|
179
|
+
|
|
180
|
+
# Related software
|
|
181
|
+
|
|
182
|
+
Also checkout these other software projects that also create DAGMC geometry [CAD-to-OpenMC](https://github.com/openmsr/CAD_to_OpenMC), [Stellarmesh](https://github.com/Thea-Energy/stellarmesh) and [Coreform Cubit](https://coreform.com/products/coreform-cubit/).
|
|
@@ -14,6 +14,7 @@ examples/surface_mesh/cadquery_compound.py
|
|
|
14
14
|
examples/surface_mesh/cadquery_object_and_stp_file.py
|
|
15
15
|
examples/surface_mesh/cadquery_text.py
|
|
16
16
|
examples/surface_mesh/curved_cadquery_object_to_dagmc_surface_mesh.py
|
|
17
|
+
examples/surface_mesh/different_resolution_meshes.py
|
|
17
18
|
examples/surface_mesh/from_gmsh_mesh_file.py
|
|
18
19
|
examples/surface_mesh/multiple_cadquery_objects.py
|
|
19
20
|
examples/surface_mesh/multiple_stp_files.py
|
|
@@ -21,6 +22,7 @@ examples/surface_mesh/single_cadquery_object.py
|
|
|
21
22
|
examples/surface_mesh/single_stp_file.py
|
|
22
23
|
examples/surface_mesh/single_stp_file_multiple_volumes.py
|
|
23
24
|
examples/unstrucutred_volume_mesh/curved_cadquery_object_to_dagmc_volume_mesh.py
|
|
25
|
+
examples/unstrucutred_volume_mesh/different_resolution_meshes.py
|
|
24
26
|
examples/unstrucutred_volume_mesh/simulate_unstrucutred_volume_mesh_with_openmc.py
|
|
25
27
|
src/_version.py
|
|
26
28
|
src/cad_to_dagmc/__init__.py
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.0}/examples/surface_mesh/cadquery_object_and_stp_file.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.0}/examples/surface_mesh/multiple_cadquery_objects.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.0}/examples/surface_mesh/single_stp_file_multiple_volumes.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|