cad-to-dagmc 0.7.2__tar.gz → 0.7.4__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.
- {cad_to_dagmc-0.7.2 → cad_to_dagmc-0.7.4}/.github/workflows/ci_with_conda_install.yml +1 -0
- {cad_to_dagmc-0.7.2 → cad_to_dagmc-0.7.4}/.github/workflows/ci_with_pip_install.yml +1 -0
- {cad_to_dagmc-0.7.2 → cad_to_dagmc-0.7.4}/PKG-INFO +1 -1
- {cad_to_dagmc-0.7.2 → cad_to_dagmc-0.7.4}/examples/surface_mesh/cadquery_assembly.py +1 -1
- cad_to_dagmc-0.7.4/examples/surface_mesh/cadquery_assembly_with_scaled_geometry.py +14 -0
- {cad_to_dagmc-0.7.2 → cad_to_dagmc-0.7.4}/examples/unstrucutred_volume_mesh/curved_cadquery_object_to_dagmc_volume_mesh.py +1 -1
- {cad_to_dagmc-0.7.2 → cad_to_dagmc-0.7.4}/examples/unstrucutred_volume_mesh/simulate_unstrucutred_volume_mesh_with_openmc.py +2 -2
- {cad_to_dagmc-0.7.2 → cad_to_dagmc-0.7.4}/src/_version.py +2 -2
- {cad_to_dagmc-0.7.2 → cad_to_dagmc-0.7.4}/src/cad_to_dagmc/core.py +73 -16
- {cad_to_dagmc-0.7.2 → cad_to_dagmc-0.7.4}/src/cad_to_dagmc.egg-info/PKG-INFO +1 -1
- {cad_to_dagmc-0.7.2 → cad_to_dagmc-0.7.4}/src/cad_to_dagmc.egg-info/SOURCES.txt +1 -0
- {cad_to_dagmc-0.7.2 → cad_to_dagmc-0.7.4}/.github/workflows/black.yml +0 -0
- {cad_to_dagmc-0.7.2 → cad_to_dagmc-0.7.4}/.github/workflows/ci_with_benchmarks.yml +0 -0
- {cad_to_dagmc-0.7.2 → cad_to_dagmc-0.7.4}/.github/workflows/python-publish.yml +0 -0
- {cad_to_dagmc-0.7.2 → cad_to_dagmc-0.7.4}/.gitignore +0 -0
- {cad_to_dagmc-0.7.2 → cad_to_dagmc-0.7.4}/CITATION.cff +0 -0
- {cad_to_dagmc-0.7.2 → cad_to_dagmc-0.7.4}/LICENSE +0 -0
- {cad_to_dagmc-0.7.2 → cad_to_dagmc-0.7.4}/README.md +0 -0
- {cad_to_dagmc-0.7.2 → cad_to_dagmc-0.7.4}/examples/surface_mesh/cadquery_compound.py +0 -0
- {cad_to_dagmc-0.7.2 → cad_to_dagmc-0.7.4}/examples/surface_mesh/cadquery_object_and_stp_file.py +0 -0
- {cad_to_dagmc-0.7.2 → cad_to_dagmc-0.7.4}/examples/surface_mesh/cadquery_text.py +0 -0
- {cad_to_dagmc-0.7.2 → cad_to_dagmc-0.7.4}/examples/surface_mesh/curved_cadquery_object_to_dagmc_surface_mesh.py +0 -0
- {cad_to_dagmc-0.7.2 → cad_to_dagmc-0.7.4}/examples/surface_mesh/from_gmsh_mesh_file.py +0 -0
- {cad_to_dagmc-0.7.2 → cad_to_dagmc-0.7.4}/examples/surface_mesh/multiple_cadquery_objects.py +0 -0
- {cad_to_dagmc-0.7.2 → cad_to_dagmc-0.7.4}/examples/surface_mesh/multiple_stp_files.py +0 -0
- {cad_to_dagmc-0.7.2 → cad_to_dagmc-0.7.4}/examples/surface_mesh/single_cadquery_object.py +0 -0
- {cad_to_dagmc-0.7.2 → cad_to_dagmc-0.7.4}/examples/surface_mesh/single_stp_file.py +0 -0
- {cad_to_dagmc-0.7.2 → cad_to_dagmc-0.7.4}/examples/surface_mesh/single_stp_file_multiple_volumes.py +0 -0
- {cad_to_dagmc-0.7.2 → cad_to_dagmc-0.7.4}/pyproject.toml +0 -0
- {cad_to_dagmc-0.7.2 → cad_to_dagmc-0.7.4}/setup.cfg +0 -0
- {cad_to_dagmc-0.7.2 → cad_to_dagmc-0.7.4}/src/cad_to_dagmc/__init__.py +0 -0
- {cad_to_dagmc-0.7.2 → cad_to_dagmc-0.7.4}/src/cad_to_dagmc.egg-info/dependency_links.txt +0 -0
- {cad_to_dagmc-0.7.2 → cad_to_dagmc-0.7.4}/src/cad_to_dagmc.egg-info/requires.txt +0 -0
- {cad_to_dagmc-0.7.2 → cad_to_dagmc-0.7.4}/src/cad_to_dagmc.egg-info/top_level.txt +0 -0
- {cad_to_dagmc-0.7.2 → cad_to_dagmc-0.7.4}/tests/ENDFB-7.1-NNDC_H1.h5 +0 -0
- {cad_to_dagmc-0.7.2 → cad_to_dagmc-0.7.4}/tests/ball_reactor.brep +0 -0
- {cad_to_dagmc-0.7.2 → cad_to_dagmc-0.7.4}/tests/curved_extrude.stp +0 -0
- {cad_to_dagmc-0.7.2 → cad_to_dagmc-0.7.4}/tests/extrude_rectangle.stp +0 -0
- {cad_to_dagmc-0.7.2 → cad_to_dagmc-0.7.4}/tests/multi_volume_cylinders.stp +0 -0
- {cad_to_dagmc-0.7.2 → cad_to_dagmc-0.7.4}/tests/one_cube.brep +0 -0
- {cad_to_dagmc-0.7.2 → cad_to_dagmc-0.7.4}/tests/single_cube.stp +0 -0
- {cad_to_dagmc-0.7.2 → cad_to_dagmc-0.7.4}/tests/single_volume_thin.stp +0 -0
- {cad_to_dagmc-0.7.2 → cad_to_dagmc-0.7.4}/tests/single_volume_thin.vtk +0 -0
- {cad_to_dagmc-0.7.2 → cad_to_dagmc-0.7.4}/tests/test_brep_file.brep +0 -0
- {cad_to_dagmc-0.7.2 → cad_to_dagmc-0.7.4}/tests/test_file_creation.py +0 -0
- {cad_to_dagmc-0.7.2 → cad_to_dagmc-0.7.4}/tests/test_h5m_in_transport.py +0 -0
- {cad_to_dagmc-0.7.2 → cad_to_dagmc-0.7.4}/tests/test_loading_from_file_vs_shape_object.py +0 -0
- {cad_to_dagmc-0.7.2 → cad_to_dagmc-0.7.4}/tests/test_python_api.py +0 -0
- {cad_to_dagmc-0.7.2 → cad_to_dagmc-0.7.4}/tests/test_two_joined_cubes.brep +0 -0
- {cad_to_dagmc-0.7.2 → cad_to_dagmc-0.7.4}/tests/test_two_sep_cubes.brep +0 -0
- {cad_to_dagmc-0.7.2 → cad_to_dagmc-0.7.4}/tests/test_version.py +0 -0
- {cad_to_dagmc-0.7.2 → cad_to_dagmc-0.7.4}/tests/two_connected_cubes.stp +0 -0
- {cad_to_dagmc-0.7.2 → cad_to_dagmc-0.7.4}/tests/two_disconnected_cubes.stp +0 -0
|
@@ -62,3 +62,4 @@ jobs:
|
|
|
62
62
|
python examples/surface_mesh/from_gmsh_mesh_file.py
|
|
63
63
|
python examples/unstrucutred_volume_mesh/curved_cadquery_object_to_dagmc_volume_mesh.py
|
|
64
64
|
python examples/unstrucutred_volume_mesh/simulate_unstrucutred_volume_mesh_with_openmc.py
|
|
65
|
+
python examples/surface_mesh/cadquery_assembly_with_scaled_geometry.py
|
|
@@ -58,3 +58,4 @@ 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/surface_mesh/cadquery_assembly_with_scaled_geometry.py
|
|
@@ -10,4 +10,4 @@ assembly.add(result2)
|
|
|
10
10
|
|
|
11
11
|
my_model = CadToDagmc()
|
|
12
12
|
my_model.add_cadquery_object(cadquery_object=assembly, material_tags=["mat1", "mat2"])
|
|
13
|
-
my_model.export_dagmc_h5m_file(min_mesh_size=0.5, max_mesh_size=1.
|
|
13
|
+
my_model.export_dagmc_h5m_file(min_mesh_size=0.5, max_mesh_size=1.0e6)
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import cadquery as cq
|
|
2
|
+
from cad_to_dagmc import CadToDagmc
|
|
3
|
+
|
|
4
|
+
result = cq.Workplane().sphere(5)
|
|
5
|
+
result2 = cq.Workplane().moveTo(10, 0).sphere(2)
|
|
6
|
+
|
|
7
|
+
assembly = cq.Assembly()
|
|
8
|
+
assembly.add(result)
|
|
9
|
+
assembly.add(result2)
|
|
10
|
+
|
|
11
|
+
my_model = CadToDagmc()
|
|
12
|
+
my_model.add_cadquery_object(cadquery_object=assembly, material_tags=["mat1", "mat2"])
|
|
13
|
+
# scales geometry to makie it 10 times bigger
|
|
14
|
+
my_model.export_dagmc_h5m_file(min_mesh_size=0.5, max_mesh_size=1.0e6, scale_factor=10.0)
|
|
@@ -59,4 +59,4 @@ my_model = CadToDagmc()
|
|
|
59
59
|
my_model.add_cadquery_object(result, material_tags=["mat1"])
|
|
60
60
|
my_model.add_cadquery_object(result2, material_tags=["mat2"])
|
|
61
61
|
|
|
62
|
-
my_model.export_unstructured_mesh_file(filename="umesh.
|
|
62
|
+
my_model.export_unstructured_mesh_file(filename="umesh.vtk", max_mesh_size=1, min_mesh_size=0.1)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# script assumes that "umesh.
|
|
1
|
+
# script assumes that "umesh.vtk" has been created by
|
|
2
2
|
# curved_cadquery_object_to_dagmc_volume_mesh.py has been
|
|
3
3
|
|
|
4
4
|
import openmc
|
|
@@ -14,7 +14,7 @@ with open("cross_sections.xml", "w") as file:
|
|
|
14
14
|
)
|
|
15
15
|
openmc.config["cross_sections"] = "cross_sections.xml"
|
|
16
16
|
|
|
17
|
-
umesh = openmc.UnstructuredMesh("umesh.
|
|
17
|
+
umesh = openmc.UnstructuredMesh("umesh.vtk", library="moab")
|
|
18
18
|
mesh_filter = openmc.MeshFilter(umesh)
|
|
19
19
|
tally = openmc.Tally(name="unstrucutred_mesh_tally")
|
|
20
20
|
tally.filters = [mesh_filter]
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
from pathlib import Path
|
|
1
2
|
import cadquery as cq
|
|
2
3
|
import gmsh
|
|
3
4
|
import numpy as np
|
|
4
|
-
from cadquery import importers
|
|
5
|
+
from cadquery import importers
|
|
5
6
|
from pymoab import core, types
|
|
6
7
|
import tempfile
|
|
7
8
|
|
|
@@ -190,16 +191,27 @@ def _vertices_to_h5m(
|
|
|
190
191
|
return h5m_filename
|
|
191
192
|
|
|
192
193
|
|
|
193
|
-
def get_volumes(gmsh, assembly, method="file"):
|
|
194
|
+
def get_volumes(gmsh, assembly, method="file", scale_factor=1.0):
|
|
194
195
|
|
|
195
196
|
if method == "in memory":
|
|
196
197
|
volumes = gmsh.model.occ.importShapesNativePointer(assembly.wrapped._address())
|
|
197
|
-
|
|
198
|
+
|
|
198
199
|
elif method == "file":
|
|
199
|
-
with tempfile.NamedTemporaryFile(suffix=".
|
|
200
|
-
|
|
200
|
+
with tempfile.NamedTemporaryFile(suffix=".brep") as temp_file:
|
|
201
|
+
if isinstance(assembly, cq.Assembly):
|
|
202
|
+
assembly.toCompound().exportBrep(temp_file.name)
|
|
203
|
+
else:
|
|
204
|
+
assembly.exportBrep(temp_file.name)
|
|
201
205
|
volumes = gmsh.model.occ.importShapes(temp_file.name)
|
|
202
|
-
|
|
206
|
+
|
|
207
|
+
# updating the model to ensure the entities in the geometry are found
|
|
208
|
+
gmsh.model.occ.synchronize()
|
|
209
|
+
|
|
210
|
+
if scale_factor != 1.0:
|
|
211
|
+
dim_tags = gmsh.model.getEntities(3)
|
|
212
|
+
gmsh.model.occ.dilate(dim_tags, 0.0, 0.0, 0.0, scale_factor, scale_factor, scale_factor)
|
|
213
|
+
# update the model to ensure the scaling factor has been applied
|
|
214
|
+
gmsh.model.occ.synchronize()
|
|
203
215
|
|
|
204
216
|
return gmsh, volumes
|
|
205
217
|
|
|
@@ -239,6 +251,7 @@ def _mesh_brep(
|
|
|
239
251
|
gmsh.option.setNumber("Mesh.Algorithm", mesh_algorithm)
|
|
240
252
|
gmsh.option.setNumber("Mesh.MeshSizeMin", min_mesh_size)
|
|
241
253
|
gmsh.option.setNumber("Mesh.MeshSizeMax", max_mesh_size)
|
|
254
|
+
gmsh.option.setNumber("General.NumThreads", 0) # Use all available cores
|
|
242
255
|
gmsh.model.mesh.generate(dimensions)
|
|
243
256
|
|
|
244
257
|
return gmsh
|
|
@@ -472,12 +485,48 @@ class CadToDagmc:
|
|
|
472
485
|
|
|
473
486
|
def export_unstructured_mesh_file(
|
|
474
487
|
self,
|
|
475
|
-
filename: str = "umesh.
|
|
488
|
+
filename: str = "umesh.vtk",
|
|
476
489
|
min_mesh_size: float = 1,
|
|
477
490
|
max_mesh_size: float = 5,
|
|
478
491
|
mesh_algorithm: int = 1,
|
|
479
492
|
method: str = "file",
|
|
493
|
+
scale_factor: float = 1.0,
|
|
480
494
|
):
|
|
495
|
+
"""
|
|
496
|
+
Exports an unstructured mesh file in VTK format for use with openmc.UnstructuredMesh.
|
|
497
|
+
Compatible with the MOAB unstructured mesh library. Example useage
|
|
498
|
+
openmc.UnstructuredMesh(filename="umesh.vtk", library="moab")
|
|
499
|
+
|
|
500
|
+
Parameters:
|
|
501
|
+
-----------
|
|
502
|
+
filename : str, optional
|
|
503
|
+
The name of the output file. Default is "umesh.vtk".
|
|
504
|
+
min_mesh_size: the minimum mesh element size to use in Gmsh. Passed
|
|
505
|
+
into gmsh.option.setNumber("Mesh.MeshSizeMin", min_mesh_size)
|
|
506
|
+
max_mesh_size: the maximum mesh element size to use in Gmsh. Passed
|
|
507
|
+
into gmsh.option.setNumber("Mesh.MeshSizeMax", max_mesh_size)
|
|
508
|
+
mesh_algorithm: The Gmsh mesh algorithm number to use. Passed into
|
|
509
|
+
gmsh.option.setNumber("Mesh.Algorithm", mesh_algorithm)
|
|
510
|
+
method: the method to use to import the geometry into gmsh. Options
|
|
511
|
+
are 'file' or 'in memory'. 'file' is the default and will write
|
|
512
|
+
the geometry to a temporary file before importing it into gmsh.
|
|
513
|
+
'in memory' will import the geometry directly into gmsh but
|
|
514
|
+
requires the version of OpenCASCADE used to build gmsh to be
|
|
515
|
+
the same as the version used by CadQuery. This is possible to
|
|
516
|
+
ensure when installing the package with Conda but harder when
|
|
517
|
+
installing from PyPI.
|
|
518
|
+
scale_factor: a scaling factor to apply to the geometry that can be
|
|
519
|
+
used to enlarge or shrink the geometry. Useful when converting
|
|
520
|
+
Useful when converting the geometry to cm for use in neutronics
|
|
521
|
+
|
|
522
|
+
Returns:
|
|
523
|
+
--------
|
|
524
|
+
gmsh : gmsh
|
|
525
|
+
The gmsh object after finalizing the mesh.
|
|
526
|
+
"""
|
|
527
|
+
|
|
528
|
+
if Path(filename).suffix != ".vtk":
|
|
529
|
+
raise ValueError("Unstructured mesh filename must have a .vtk extension")
|
|
481
530
|
|
|
482
531
|
assembly = cq.Assembly()
|
|
483
532
|
for part in self.parts:
|
|
@@ -487,7 +536,7 @@ class CadToDagmc:
|
|
|
487
536
|
|
|
488
537
|
gmsh = init_gmsh()
|
|
489
538
|
|
|
490
|
-
gmsh, _ = get_volumes(gmsh, imprinted_assembly, method=method)
|
|
539
|
+
gmsh, _ = get_volumes(gmsh, imprinted_assembly, method=method, scale_factor=scale_factor)
|
|
491
540
|
|
|
492
541
|
gmsh = _mesh_brep(
|
|
493
542
|
gmsh=gmsh,
|
|
@@ -497,12 +546,9 @@ class CadToDagmc:
|
|
|
497
546
|
dimensions=3,
|
|
498
547
|
)
|
|
499
548
|
|
|
500
|
-
# gmesh writes out a vtk file that is
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
moab_core = core.Core()
|
|
504
|
-
moab_core.load_file(filename + ".vtk")
|
|
505
|
-
moab_core.write_file(filename)
|
|
549
|
+
# gmesh writes out a vtk file that is accepted by openmc.UnstructuredMesh
|
|
550
|
+
# The library argument must be set to "moab"
|
|
551
|
+
gmsh.write(filename)
|
|
506
552
|
|
|
507
553
|
gmsh.finalize()
|
|
508
554
|
|
|
@@ -516,6 +562,7 @@ class CadToDagmc:
|
|
|
516
562
|
mesh_algorithm: int = 1,
|
|
517
563
|
dimensions: int = 2,
|
|
518
564
|
method: str = "file",
|
|
565
|
+
scale_factor: float = 1.0,
|
|
519
566
|
):
|
|
520
567
|
"""Saves a GMesh msh file of the geometry in either 2D surface mesh or
|
|
521
568
|
3D volume mesh.
|
|
@@ -535,6 +582,9 @@ class CadToDagmc:
|
|
|
535
582
|
the same as the version used by CadQuery. This is possible to
|
|
536
583
|
ensure when installing the package with Conda but harder when
|
|
537
584
|
installing from PyPI.
|
|
585
|
+
scale_factor: a scaling factor to apply to the geometry that can be
|
|
586
|
+
used to enlarge or shrink the geometry. Useful when converting
|
|
587
|
+
Useful when converting the geometry to cm for use in neutronics
|
|
538
588
|
"""
|
|
539
589
|
|
|
540
590
|
assembly = cq.Assembly()
|
|
@@ -545,7 +595,7 @@ class CadToDagmc:
|
|
|
545
595
|
|
|
546
596
|
gmsh = init_gmsh()
|
|
547
597
|
|
|
548
|
-
gmsh, _ = get_volumes(gmsh, imprinted_assembly, method=method)
|
|
598
|
+
gmsh, _ = get_volumes(gmsh, imprinted_assembly, method=method, scale_factor=scale_factor)
|
|
549
599
|
|
|
550
600
|
gmsh = _mesh_brep(
|
|
551
601
|
gmsh=gmsh,
|
|
@@ -569,6 +619,7 @@ class CadToDagmc:
|
|
|
569
619
|
mesh_algorithm: int = 1,
|
|
570
620
|
implicit_complement_material_tag: str | None = None,
|
|
571
621
|
method: str = "file",
|
|
622
|
+
scale_factor: float = 1.0,
|
|
572
623
|
) -> str:
|
|
573
624
|
"""Saves a DAGMC h5m file of the geometry
|
|
574
625
|
|
|
@@ -589,6 +640,10 @@ class CadToDagmc:
|
|
|
589
640
|
the same as the version used by CadQuery. This is possible to
|
|
590
641
|
ensure when installing the package with Conda but harder when
|
|
591
642
|
installing from PyPI.
|
|
643
|
+
scale_factor: a scaling factor to apply to the geometry that can be
|
|
644
|
+
used to enlarge or shrink the geometry. Useful when converting
|
|
645
|
+
Useful when converting the geometry to cm for use in neutronics
|
|
646
|
+
|
|
592
647
|
Returns:
|
|
593
648
|
str: the DAGMC filename saved
|
|
594
649
|
"""
|
|
@@ -617,7 +672,9 @@ class CadToDagmc:
|
|
|
617
672
|
|
|
618
673
|
gmsh = init_gmsh()
|
|
619
674
|
|
|
620
|
-
gmsh, volumes = get_volumes(
|
|
675
|
+
gmsh, volumes = get_volumes(
|
|
676
|
+
gmsh, imprinted_assembly, method=method, scale_factor=scale_factor
|
|
677
|
+
)
|
|
621
678
|
|
|
622
679
|
gmsh = _mesh_brep(
|
|
623
680
|
gmsh=gmsh,
|
|
@@ -9,6 +9,7 @@ pyproject.toml
|
|
|
9
9
|
.github/workflows/ci_with_pip_install.yml
|
|
10
10
|
.github/workflows/python-publish.yml
|
|
11
11
|
examples/surface_mesh/cadquery_assembly.py
|
|
12
|
+
examples/surface_mesh/cadquery_assembly_with_scaled_geometry.py
|
|
12
13
|
examples/surface_mesh/cadquery_compound.py
|
|
13
14
|
examples/surface_mesh/cadquery_object_and_stp_file.py
|
|
14
15
|
examples/surface_mesh/cadquery_text.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
|
{cad_to_dagmc-0.7.2 → cad_to_dagmc-0.7.4}/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.2 → cad_to_dagmc-0.7.4}/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.2 → cad_to_dagmc-0.7.4}/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
|