cad-to-dagmc 0.7.7__tar.gz → 0.8.1__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.1}/.github/workflows/ci_with_conda_install.yml +3 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.1}/.github/workflows/ci_with_pip_install.yml +2 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.1}/PKG-INFO +20 -16
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.1}/README.md +19 -15
- cad_to_dagmc-0.8.1/examples/surface_mesh/different_resolution_meshes.py +44 -0
- cad_to_dagmc-0.8.1/examples/unstrucutred_volume_mesh/different_resolution_meshes.py +44 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.1}/src/_version.py +2 -2
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.1}/src/cad_to_dagmc/core.py +69 -11
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.1}/src/cad_to_dagmc.egg-info/PKG-INFO +20 -16
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.1}/src/cad_to_dagmc.egg-info/SOURCES.txt +2 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.1}/tests/test_python_api.py +120 -6
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.1}/.github/workflows/black.yml +0 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.1}/.github/workflows/ci_with_benchmarks.yml +0 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.1}/.github/workflows/python-publish.yml +0 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.1}/.gitignore +0 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.1}/CITATION.cff +0 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.1}/LICENSE +0 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.1}/examples/surface_mesh/cadquery_assembly.py +0 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.1}/examples/surface_mesh/cadquery_assembly_with_scaled_geometry.py +0 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.1}/examples/surface_mesh/cadquery_compound.py +0 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.1}/examples/surface_mesh/cadquery_object_and_stp_file.py +0 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.1}/examples/surface_mesh/cadquery_text.py +0 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.1}/examples/surface_mesh/curved_cadquery_object_to_dagmc_surface_mesh.py +0 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.1}/examples/surface_mesh/from_gmsh_mesh_file.py +0 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.1}/examples/surface_mesh/multiple_cadquery_objects.py +0 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.1}/examples/surface_mesh/multiple_stp_files.py +0 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.1}/examples/surface_mesh/single_cadquery_object.py +0 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.1}/examples/surface_mesh/single_stp_file.py +0 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.1}/examples/surface_mesh/single_stp_file_multiple_volumes.py +0 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.1}/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.1}/examples/unstrucutred_volume_mesh/simulate_unstrucutred_volume_mesh_with_openmc.py +0 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.1}/pyproject.toml +0 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.1}/setup.cfg +0 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.1}/src/cad_to_dagmc/__init__.py +0 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.1}/src/cad_to_dagmc.egg-info/dependency_links.txt +0 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.1}/src/cad_to_dagmc.egg-info/requires.txt +0 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.1}/src/cad_to_dagmc.egg-info/top_level.txt +0 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.1}/tests/ENDFB-7.1-NNDC_H1.h5 +0 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.1}/tests/ball_reactor.brep +0 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.1}/tests/curved_extrude.stp +0 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.1}/tests/extrude_rectangle.stp +0 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.1}/tests/multi_volume_cylinders.stp +0 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.1}/tests/one_cube.brep +0 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.1}/tests/single_cube.stp +0 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.1}/tests/single_volume_thin.stp +0 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.1}/tests/single_volume_thin.vtk +0 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.1}/tests/test_brep_file.brep +0 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.1}/tests/test_file_creation.py +0 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.1}/tests/test_h5m_in_transport.py +0 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.1}/tests/test_loading_from_file_vs_shape_object.py +0 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.1}/tests/test_two_joined_cubes.brep +0 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.1}/tests/test_two_sep_cubes.brep +0 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.1}/tests/test_version.py +0 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.1}/tests/two_connected_cubes.stp +0 -0
- {cad_to_dagmc-0.7.7 → cad_to_dagmc-0.8.1}/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.1
|
|
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
|
|
@@ -468,6 +503,7 @@ class CadToDagmc:
|
|
|
468
503
|
cq.assembly.Assembly | cq.occ_impl.shapes.Compound | cq.occ_impl.shapes.Solid
|
|
469
504
|
),
|
|
470
505
|
material_tags: list[str] | None,
|
|
506
|
+
scale_factor: float = 1.0,
|
|
471
507
|
) -> int:
|
|
472
508
|
"""Loads the parts from CadQuery object into the model.
|
|
473
509
|
|
|
@@ -479,6 +515,10 @@ class CadToDagmc:
|
|
|
479
515
|
same order as the volumes in the geometry added (STP file and
|
|
480
516
|
CadQuery objects) and match the material tags used in the
|
|
481
517
|
neutronics code (e.g. OpenMC).
|
|
518
|
+
scale_factor: a scaling factor to apply to the geometry that can be
|
|
519
|
+
used to increase the size or decrease the size of the geometry.
|
|
520
|
+
Useful when converting the geometry to cm for use in neutronics
|
|
521
|
+
simulations.
|
|
482
522
|
|
|
483
523
|
Returns:
|
|
484
524
|
int: number of volumes in the stp file.
|
|
@@ -492,12 +532,17 @@ class CadToDagmc:
|
|
|
492
532
|
else:
|
|
493
533
|
iterable_solids = cadquery_object.val().Solids()
|
|
494
534
|
|
|
495
|
-
|
|
535
|
+
if scale_factor == 1.0:
|
|
536
|
+
scaled_iterable_solids = iterable_solids
|
|
537
|
+
else:
|
|
538
|
+
scaled_iterable_solids = [part.scale(scale_factor) for part in iterable_solids]
|
|
539
|
+
|
|
540
|
+
_check_material_tags(material_tags, scaled_iterable_solids)
|
|
496
541
|
if material_tags:
|
|
497
542
|
self.material_tags = self.material_tags + material_tags
|
|
498
|
-
self.parts = self.parts +
|
|
543
|
+
self.parts = self.parts + scaled_iterable_solids
|
|
499
544
|
|
|
500
|
-
return len(
|
|
545
|
+
return len(scaled_iterable_solids)
|
|
501
546
|
|
|
502
547
|
def export_unstructured_mesh_file(
|
|
503
548
|
self,
|
|
@@ -508,6 +553,7 @@ class CadToDagmc:
|
|
|
508
553
|
method: str = "file",
|
|
509
554
|
scale_factor: float = 1.0,
|
|
510
555
|
imprint: bool = True,
|
|
556
|
+
set_size: dict[int, float] | None = None,
|
|
511
557
|
):
|
|
512
558
|
"""
|
|
513
559
|
Exports an unstructured mesh file in VTK format for use with openmc.UnstructuredMesh.
|
|
@@ -539,6 +585,9 @@ class CadToDagmc:
|
|
|
539
585
|
normally needed to ensure the geometry is meshed correctly. However if
|
|
540
586
|
you know your geometry does not need imprinting you can set this to False
|
|
541
587
|
and this can save time.
|
|
588
|
+
set_size: a dictionary of volume ids (int) and target mesh sizes
|
|
589
|
+
(floats) to set for each volume, passed to gmsh.model.mesh.setSize.
|
|
590
|
+
|
|
542
591
|
|
|
543
592
|
Returns:
|
|
544
593
|
--------
|
|
@@ -570,6 +619,7 @@ class CadToDagmc:
|
|
|
570
619
|
max_mesh_size=max_mesh_size,
|
|
571
620
|
mesh_algorithm=mesh_algorithm,
|
|
572
621
|
dimensions=3,
|
|
622
|
+
set_size=set_size,
|
|
573
623
|
)
|
|
574
624
|
|
|
575
625
|
# makes the folder if it does not exist
|
|
@@ -589,13 +639,14 @@ class CadToDagmc:
|
|
|
589
639
|
def export_gmsh_mesh_file(
|
|
590
640
|
self,
|
|
591
641
|
filename: str = "mesh.msh",
|
|
592
|
-
min_mesh_size: float =
|
|
593
|
-
max_mesh_size: float =
|
|
642
|
+
min_mesh_size: float | None = None,
|
|
643
|
+
max_mesh_size: float | None = None,
|
|
594
644
|
mesh_algorithm: int = 1,
|
|
595
645
|
dimensions: int = 2,
|
|
596
646
|
method: str = "file",
|
|
597
647
|
scale_factor: float = 1.0,
|
|
598
648
|
imprint: bool = True,
|
|
649
|
+
set_size: dict[int, float] | None = None,
|
|
599
650
|
):
|
|
600
651
|
"""Saves a GMesh msh file of the geometry in either 2D surface mesh or
|
|
601
652
|
3D volume mesh.
|
|
@@ -622,6 +673,8 @@ class CadToDagmc:
|
|
|
622
673
|
normally needed to ensure the geometry is meshed correctly. However if
|
|
623
674
|
you know your geometry does not need imprinting you can set this to False
|
|
624
675
|
and this can save time.
|
|
676
|
+
set_size: a dictionary of volume ids (int) and target mesh sizes
|
|
677
|
+
(floats) to set for each volume, passed to gmsh.model.mesh.setSize.
|
|
625
678
|
"""
|
|
626
679
|
|
|
627
680
|
assembly = cq.Assembly()
|
|
@@ -643,6 +696,7 @@ class CadToDagmc:
|
|
|
643
696
|
max_mesh_size=max_mesh_size,
|
|
644
697
|
mesh_algorithm=mesh_algorithm,
|
|
645
698
|
dimensions=dimensions,
|
|
699
|
+
set_size=set_size,
|
|
646
700
|
)
|
|
647
701
|
|
|
648
702
|
# makes the folder if it does not exist
|
|
@@ -662,13 +716,14 @@ class CadToDagmc:
|
|
|
662
716
|
def export_dagmc_h5m_file(
|
|
663
717
|
self,
|
|
664
718
|
filename: str = "dagmc.h5m",
|
|
665
|
-
min_mesh_size: float =
|
|
666
|
-
max_mesh_size: float =
|
|
719
|
+
min_mesh_size: float | None = None,
|
|
720
|
+
max_mesh_size: float | None = None,
|
|
667
721
|
mesh_algorithm: int = 1,
|
|
668
722
|
implicit_complement_material_tag: str | None = None,
|
|
669
723
|
method: str = "file",
|
|
670
724
|
scale_factor: float = 1.0,
|
|
671
725
|
imprint: bool = True,
|
|
726
|
+
set_size: dict[int, float] | None = None,
|
|
672
727
|
) -> str:
|
|
673
728
|
"""Saves a DAGMC h5m file of the geometry
|
|
674
729
|
|
|
@@ -695,6 +750,8 @@ class CadToDagmc:
|
|
|
695
750
|
normally needed to ensure the geometry is meshed correctly. However if
|
|
696
751
|
you know your geometry does not need imprinting you can set this to False
|
|
697
752
|
and this can save time.
|
|
753
|
+
set_size: a dictionary of volume ids (int) and target mesh sizes
|
|
754
|
+
(floats) to set for each volume, passed to gmsh.model.mesh.setSize.
|
|
698
755
|
|
|
699
756
|
Returns:
|
|
700
757
|
str: the DAGMC filename saved
|
|
@@ -739,6 +796,7 @@ class CadToDagmc:
|
|
|
739
796
|
min_mesh_size=min_mesh_size,
|
|
740
797
|
max_mesh_size=max_mesh_size,
|
|
741
798
|
mesh_algorithm=mesh_algorithm,
|
|
799
|
+
set_size=set_size,
|
|
742
800
|
)
|
|
743
801
|
|
|
744
802
|
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.1
|
|
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
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import os
|
|
2
|
-
from pathlib import Path
|
|
3
|
-
import pytest
|
|
4
|
-
import cadquery as cq
|
|
5
|
-
from cad_to_dagmc import CadToDagmc
|
|
6
2
|
import warnings
|
|
7
|
-
from cad_to_dagmc.core import _check_material_tags
|
|
8
|
-
|
|
9
3
|
from pathlib import Path
|
|
10
4
|
|
|
5
|
+
import cadquery as cq
|
|
6
|
+
import gmsh
|
|
11
7
|
import pymoab as mb
|
|
8
|
+
import pytest
|
|
12
9
|
from pymoab import core, types
|
|
13
10
|
|
|
11
|
+
from cad_to_dagmc import CadToDagmc
|
|
12
|
+
from cad_to_dagmc.core import _check_material_tags
|
|
13
|
+
|
|
14
14
|
|
|
15
15
|
def get_volumes_and_materials_from_h5m(filename: str) -> dict:
|
|
16
16
|
"""Reads in a DAGMC h5m file and uses PyMoab to find the volume ids with
|
|
@@ -219,3 +219,117 @@ def test_check_material_tags_too_long():
|
|
|
219
219
|
assert issubclass(w[-1].category, UserWarning)
|
|
220
220
|
assert "Material tag" in str(w[-1].message)
|
|
221
221
|
assert "a" * 29 in str(w[-1].message)
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
@pytest.mark.parametrize(
|
|
225
|
+
"scale_factor, expected_width",
|
|
226
|
+
[
|
|
227
|
+
(1, 10.0),
|
|
228
|
+
(2, 20.0),
|
|
229
|
+
(10, 100.0),
|
|
230
|
+
],
|
|
231
|
+
)
|
|
232
|
+
def test_scaling_factor_when_adding_stp(scale_factor, expected_width):
|
|
233
|
+
|
|
234
|
+
c2d = CadToDagmc()
|
|
235
|
+
c2d.add_stp_file("tests/single_cube.stp", scale_factor=scale_factor)
|
|
236
|
+
c2d.export_gmsh_mesh_file(f"st_test_scaling_factor_{scale_factor}.msh")
|
|
237
|
+
|
|
238
|
+
gmsh.initialize()
|
|
239
|
+
gmsh.open(f"st_test_scaling_factor_{scale_factor}.msh")
|
|
240
|
+
_, node_coords, _ = gmsh.model.mesh.getNodes()
|
|
241
|
+
|
|
242
|
+
# Reshape the node coordinates into a 2D array
|
|
243
|
+
node_coords = node_coords.reshape(-1, 3)
|
|
244
|
+
|
|
245
|
+
# Calculate the bounding box
|
|
246
|
+
min_coords = node_coords.min(axis=0)
|
|
247
|
+
max_coords = node_coords.max(axis=0)
|
|
248
|
+
|
|
249
|
+
width_x = max_coords[0] - min_coords[0]
|
|
250
|
+
width_y = max_coords[1] - min_coords[1]
|
|
251
|
+
width_z = max_coords[2] - min_coords[2]
|
|
252
|
+
|
|
253
|
+
gmsh.finalize()
|
|
254
|
+
|
|
255
|
+
assert width_x == expected_width
|
|
256
|
+
assert width_y == expected_width
|
|
257
|
+
assert width_z == expected_width
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
@pytest.mark.parametrize(
|
|
261
|
+
"scale_factor, expected_width",
|
|
262
|
+
[
|
|
263
|
+
(1, 10.0),
|
|
264
|
+
(2, 20.0),
|
|
265
|
+
(10, 100.0),
|
|
266
|
+
],
|
|
267
|
+
)
|
|
268
|
+
def test_scaling_factor_when_adding_cq_object(scale_factor, expected_width):
|
|
269
|
+
|
|
270
|
+
box = cq.Workplane("XY").box(10, 10, 10)
|
|
271
|
+
c2d = CadToDagmc()
|
|
272
|
+
c2d.add_cadquery_object(box, scale_factor=scale_factor, material_tags=["mat1"])
|
|
273
|
+
c2d.export_gmsh_mesh_file(f"cq_test_scaling_factor_{scale_factor}.msh")
|
|
274
|
+
|
|
275
|
+
gmsh.initialize()
|
|
276
|
+
gmsh.open(f"cq_test_scaling_factor_{scale_factor}.msh")
|
|
277
|
+
_, node_coords, _ = gmsh.model.mesh.getNodes()
|
|
278
|
+
|
|
279
|
+
# Reshape the node coordinates into a 2D array
|
|
280
|
+
node_coords = node_coords.reshape(-1, 3)
|
|
281
|
+
|
|
282
|
+
# Calculate the bounding box
|
|
283
|
+
min_coords = node_coords.min(axis=0)
|
|
284
|
+
max_coords = node_coords.max(axis=0)
|
|
285
|
+
|
|
286
|
+
width_x = max_coords[0] - min_coords[0]
|
|
287
|
+
width_y = max_coords[1] - min_coords[1]
|
|
288
|
+
width_z = max_coords[2] - min_coords[2]
|
|
289
|
+
|
|
290
|
+
gmsh.finalize()
|
|
291
|
+
|
|
292
|
+
assert width_x == expected_width
|
|
293
|
+
assert width_y == expected_width
|
|
294
|
+
assert width_z == expected_width
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
@pytest.mark.parametrize(
|
|
298
|
+
"scale_factor, expected_x_width, expected_y_width, expected_z_width",
|
|
299
|
+
[
|
|
300
|
+
(1, 20.0, 10.0, 10.0),
|
|
301
|
+
(2, 40.0, 20.0, 20.0),
|
|
302
|
+
(10, 200.0, 100.0, 100.0),
|
|
303
|
+
],
|
|
304
|
+
)
|
|
305
|
+
def test_two_box_scaling_factor_when_adding_cq_object(
|
|
306
|
+
scale_factor, expected_x_width, expected_y_width, expected_z_width
|
|
307
|
+
):
|
|
308
|
+
|
|
309
|
+
box = cq.Workplane("XY").box(10, 10, 10)
|
|
310
|
+
box2 = cq.Workplane("XY").moveTo(10, 0).box(10, 10, 10)
|
|
311
|
+
c2d = CadToDagmc()
|
|
312
|
+
c2d.add_cadquery_object(box, scale_factor=scale_factor, material_tags=["mat1"])
|
|
313
|
+
c2d.add_cadquery_object(box2, scale_factor=scale_factor, material_tags=["mat1"])
|
|
314
|
+
c2d.export_gmsh_mesh_file(f"cq_test_2_box_scaling_factor_{scale_factor}.msh")
|
|
315
|
+
|
|
316
|
+
gmsh.initialize()
|
|
317
|
+
gmsh.open(f"cq_test_2_box_scaling_factor_{scale_factor}.msh")
|
|
318
|
+
_, node_coords, _ = gmsh.model.mesh.getNodes()
|
|
319
|
+
|
|
320
|
+
# Reshape the node coordinates into a numpy 2D array
|
|
321
|
+
node_coords = node_coords.reshape(-1, 3)
|
|
322
|
+
|
|
323
|
+
# Calculate the bounding box
|
|
324
|
+
min_coords = node_coords.min(axis=0)
|
|
325
|
+
max_coords = node_coords.max(axis=0)
|
|
326
|
+
|
|
327
|
+
width_x = max_coords[0] - min_coords[0]
|
|
328
|
+
width_y = max_coords[1] - min_coords[1]
|
|
329
|
+
width_z = max_coords[2] - min_coords[2]
|
|
330
|
+
|
|
331
|
+
gmsh.finalize()
|
|
332
|
+
|
|
333
|
+
assert width_x == expected_x_width
|
|
334
|
+
assert width_y == expected_y_width
|
|
335
|
+
assert width_z == expected_z_width
|
|
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.1}/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.1}/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.1}/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
|