cad-to-dagmc 0.7.3__tar.gz → 0.7.5__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.3 → cad_to_dagmc-0.7.5}/PKG-INFO +1 -1
- {cad_to_dagmc-0.7.3 → cad_to_dagmc-0.7.5}/examples/unstrucutred_volume_mesh/curved_cadquery_object_to_dagmc_volume_mesh.py +1 -1
- {cad_to_dagmc-0.7.3 → cad_to_dagmc-0.7.5}/examples/unstrucutred_volume_mesh/simulate_unstrucutred_volume_mesh_with_openmc.py +2 -2
- {cad_to_dagmc-0.7.3 → cad_to_dagmc-0.7.5}/src/_version.py +2 -2
- {cad_to_dagmc-0.7.3 → cad_to_dagmc-0.7.5}/src/cad_to_dagmc/core.py +77 -18
- {cad_to_dagmc-0.7.3 → cad_to_dagmc-0.7.5}/src/cad_to_dagmc.egg-info/PKG-INFO +1 -1
- {cad_to_dagmc-0.7.3 → cad_to_dagmc-0.7.5}/.github/workflows/black.yml +0 -0
- {cad_to_dagmc-0.7.3 → cad_to_dagmc-0.7.5}/.github/workflows/ci_with_benchmarks.yml +0 -0
- {cad_to_dagmc-0.7.3 → cad_to_dagmc-0.7.5}/.github/workflows/ci_with_conda_install.yml +0 -0
- {cad_to_dagmc-0.7.3 → cad_to_dagmc-0.7.5}/.github/workflows/ci_with_pip_install.yml +0 -0
- {cad_to_dagmc-0.7.3 → cad_to_dagmc-0.7.5}/.github/workflows/python-publish.yml +0 -0
- {cad_to_dagmc-0.7.3 → cad_to_dagmc-0.7.5}/.gitignore +0 -0
- {cad_to_dagmc-0.7.3 → cad_to_dagmc-0.7.5}/CITATION.cff +0 -0
- {cad_to_dagmc-0.7.3 → cad_to_dagmc-0.7.5}/LICENSE +0 -0
- {cad_to_dagmc-0.7.3 → cad_to_dagmc-0.7.5}/README.md +0 -0
- {cad_to_dagmc-0.7.3 → cad_to_dagmc-0.7.5}/examples/surface_mesh/cadquery_assembly.py +0 -0
- {cad_to_dagmc-0.7.3 → cad_to_dagmc-0.7.5}/examples/surface_mesh/cadquery_assembly_with_scaled_geometry.py +0 -0
- {cad_to_dagmc-0.7.3 → cad_to_dagmc-0.7.5}/examples/surface_mesh/cadquery_compound.py +0 -0
- {cad_to_dagmc-0.7.3 → cad_to_dagmc-0.7.5}/examples/surface_mesh/cadquery_object_and_stp_file.py +0 -0
- {cad_to_dagmc-0.7.3 → cad_to_dagmc-0.7.5}/examples/surface_mesh/cadquery_text.py +0 -0
- {cad_to_dagmc-0.7.3 → cad_to_dagmc-0.7.5}/examples/surface_mesh/curved_cadquery_object_to_dagmc_surface_mesh.py +0 -0
- {cad_to_dagmc-0.7.3 → cad_to_dagmc-0.7.5}/examples/surface_mesh/from_gmsh_mesh_file.py +0 -0
- {cad_to_dagmc-0.7.3 → cad_to_dagmc-0.7.5}/examples/surface_mesh/multiple_cadquery_objects.py +0 -0
- {cad_to_dagmc-0.7.3 → cad_to_dagmc-0.7.5}/examples/surface_mesh/multiple_stp_files.py +0 -0
- {cad_to_dagmc-0.7.3 → cad_to_dagmc-0.7.5}/examples/surface_mesh/single_cadquery_object.py +0 -0
- {cad_to_dagmc-0.7.3 → cad_to_dagmc-0.7.5}/examples/surface_mesh/single_stp_file.py +0 -0
- {cad_to_dagmc-0.7.3 → cad_to_dagmc-0.7.5}/examples/surface_mesh/single_stp_file_multiple_volumes.py +0 -0
- {cad_to_dagmc-0.7.3 → cad_to_dagmc-0.7.5}/pyproject.toml +0 -0
- {cad_to_dagmc-0.7.3 → cad_to_dagmc-0.7.5}/setup.cfg +0 -0
- {cad_to_dagmc-0.7.3 → cad_to_dagmc-0.7.5}/src/cad_to_dagmc/__init__.py +0 -0
- {cad_to_dagmc-0.7.3 → cad_to_dagmc-0.7.5}/src/cad_to_dagmc.egg-info/SOURCES.txt +0 -0
- {cad_to_dagmc-0.7.3 → cad_to_dagmc-0.7.5}/src/cad_to_dagmc.egg-info/dependency_links.txt +0 -0
- {cad_to_dagmc-0.7.3 → cad_to_dagmc-0.7.5}/src/cad_to_dagmc.egg-info/requires.txt +0 -0
- {cad_to_dagmc-0.7.3 → cad_to_dagmc-0.7.5}/src/cad_to_dagmc.egg-info/top_level.txt +0 -0
- {cad_to_dagmc-0.7.3 → cad_to_dagmc-0.7.5}/tests/ENDFB-7.1-NNDC_H1.h5 +0 -0
- {cad_to_dagmc-0.7.3 → cad_to_dagmc-0.7.5}/tests/ball_reactor.brep +0 -0
- {cad_to_dagmc-0.7.3 → cad_to_dagmc-0.7.5}/tests/curved_extrude.stp +0 -0
- {cad_to_dagmc-0.7.3 → cad_to_dagmc-0.7.5}/tests/extrude_rectangle.stp +0 -0
- {cad_to_dagmc-0.7.3 → cad_to_dagmc-0.7.5}/tests/multi_volume_cylinders.stp +0 -0
- {cad_to_dagmc-0.7.3 → cad_to_dagmc-0.7.5}/tests/one_cube.brep +0 -0
- {cad_to_dagmc-0.7.3 → cad_to_dagmc-0.7.5}/tests/single_cube.stp +0 -0
- {cad_to_dagmc-0.7.3 → cad_to_dagmc-0.7.5}/tests/single_volume_thin.stp +0 -0
- {cad_to_dagmc-0.7.3 → cad_to_dagmc-0.7.5}/tests/single_volume_thin.vtk +0 -0
- {cad_to_dagmc-0.7.3 → cad_to_dagmc-0.7.5}/tests/test_brep_file.brep +0 -0
- {cad_to_dagmc-0.7.3 → cad_to_dagmc-0.7.5}/tests/test_file_creation.py +0 -0
- {cad_to_dagmc-0.7.3 → cad_to_dagmc-0.7.5}/tests/test_h5m_in_transport.py +0 -0
- {cad_to_dagmc-0.7.3 → cad_to_dagmc-0.7.5}/tests/test_loading_from_file_vs_shape_object.py +0 -0
- {cad_to_dagmc-0.7.3 → cad_to_dagmc-0.7.5}/tests/test_python_api.py +0 -0
- {cad_to_dagmc-0.7.3 → cad_to_dagmc-0.7.5}/tests/test_two_joined_cubes.brep +0 -0
- {cad_to_dagmc-0.7.3 → cad_to_dagmc-0.7.5}/tests/test_two_sep_cubes.brep +0 -0
- {cad_to_dagmc-0.7.3 → cad_to_dagmc-0.7.5}/tests/test_version.py +0 -0
- {cad_to_dagmc-0.7.3 → cad_to_dagmc-0.7.5}/tests/two_connected_cubes.stp +0 -0
- {cad_to_dagmc-0.7.3 → cad_to_dagmc-0.7.5}/tests/two_disconnected_cubes.stp +0 -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
|
|
|
@@ -484,19 +485,62 @@ class CadToDagmc:
|
|
|
484
485
|
|
|
485
486
|
def export_unstructured_mesh_file(
|
|
486
487
|
self,
|
|
487
|
-
filename: str = "umesh.
|
|
488
|
+
filename: str = "umesh.vtk",
|
|
488
489
|
min_mesh_size: float = 1,
|
|
489
490
|
max_mesh_size: float = 5,
|
|
490
491
|
mesh_algorithm: int = 1,
|
|
491
492
|
method: str = "file",
|
|
492
493
|
scale_factor: float = 1.0,
|
|
494
|
+
imprint: bool = True,
|
|
493
495
|
):
|
|
496
|
+
"""
|
|
497
|
+
Exports an unstructured mesh file in VTK format for use with openmc.UnstructuredMesh.
|
|
498
|
+
Compatible with the MOAB unstructured mesh library. Example useage
|
|
499
|
+
openmc.UnstructuredMesh(filename="umesh.vtk", library="moab")
|
|
500
|
+
|
|
501
|
+
Parameters:
|
|
502
|
+
-----------
|
|
503
|
+
filename : str, optional
|
|
504
|
+
The name of the output file. Default is "umesh.vtk".
|
|
505
|
+
min_mesh_size: the minimum mesh element size to use in Gmsh. Passed
|
|
506
|
+
into gmsh.option.setNumber("Mesh.MeshSizeMin", min_mesh_size)
|
|
507
|
+
max_mesh_size: the maximum mesh element size to use in Gmsh. Passed
|
|
508
|
+
into gmsh.option.setNumber("Mesh.MeshSizeMax", max_mesh_size)
|
|
509
|
+
mesh_algorithm: The Gmsh mesh algorithm number to use. Passed into
|
|
510
|
+
gmsh.option.setNumber("Mesh.Algorithm", mesh_algorithm)
|
|
511
|
+
method: the method to use to import the geometry into gmsh. Options
|
|
512
|
+
are 'file' or 'in memory'. 'file' is the default and will write
|
|
513
|
+
the geometry to a temporary file before importing it into gmsh.
|
|
514
|
+
'in memory' will import the geometry directly into gmsh but
|
|
515
|
+
requires the version of OpenCASCADE used to build gmsh to be
|
|
516
|
+
the same as the version used by CadQuery. This is possible to
|
|
517
|
+
ensure when installing the package with Conda but harder when
|
|
518
|
+
installing from PyPI.
|
|
519
|
+
scale_factor: a scaling factor to apply to the geometry that can be
|
|
520
|
+
used to enlarge or shrink the geometry. Useful when converting
|
|
521
|
+
Useful when converting the geometry to cm for use in neutronics
|
|
522
|
+
imprint: whether to imprint the geometry or not. Defaults to True as this is
|
|
523
|
+
normally needed to ensure the geometry is meshed correctly. However if
|
|
524
|
+
you know your geometry does not need imprinting you can set this to False
|
|
525
|
+
and this can save time.
|
|
526
|
+
|
|
527
|
+
Returns:
|
|
528
|
+
--------
|
|
529
|
+
gmsh : gmsh
|
|
530
|
+
The gmsh object after finalizing the mesh.
|
|
531
|
+
"""
|
|
532
|
+
|
|
533
|
+
if Path(filename).suffix != ".vtk":
|
|
534
|
+
raise ValueError("Unstructured mesh filename must have a .vtk extension")
|
|
494
535
|
|
|
495
536
|
assembly = cq.Assembly()
|
|
496
537
|
for part in self.parts:
|
|
497
538
|
assembly.add(part)
|
|
498
539
|
|
|
499
|
-
|
|
540
|
+
if imprint:
|
|
541
|
+
imprinted_assembly, _ = cq.occ_impl.assembly.imprint(assembly)
|
|
542
|
+
else:
|
|
543
|
+
imprinted_assembly = assembly
|
|
500
544
|
|
|
501
545
|
gmsh = init_gmsh()
|
|
502
546
|
|
|
@@ -510,12 +554,9 @@ class CadToDagmc:
|
|
|
510
554
|
dimensions=3,
|
|
511
555
|
)
|
|
512
556
|
|
|
513
|
-
# gmesh writes out a vtk file that is
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
moab_core = core.Core()
|
|
517
|
-
moab_core.load_file(filename + ".vtk")
|
|
518
|
-
moab_core.write_file(filename)
|
|
557
|
+
# gmesh writes out a vtk file that is accepted by openmc.UnstructuredMesh
|
|
558
|
+
# The library argument must be set to "moab"
|
|
559
|
+
gmsh.write(filename)
|
|
519
560
|
|
|
520
561
|
gmsh.finalize()
|
|
521
562
|
|
|
@@ -530,6 +571,7 @@ class CadToDagmc:
|
|
|
530
571
|
dimensions: int = 2,
|
|
531
572
|
method: str = "file",
|
|
532
573
|
scale_factor: float = 1.0,
|
|
574
|
+
imprint: bool = True,
|
|
533
575
|
):
|
|
534
576
|
"""Saves a GMesh msh file of the geometry in either 2D surface mesh or
|
|
535
577
|
3D volume mesh.
|
|
@@ -552,13 +594,20 @@ class CadToDagmc:
|
|
|
552
594
|
scale_factor: a scaling factor to apply to the geometry that can be
|
|
553
595
|
used to enlarge or shrink the geometry. Useful when converting
|
|
554
596
|
Useful when converting the geometry to cm for use in neutronics
|
|
597
|
+
imprint: whether to imprint the geometry or not. Defaults to True as this is
|
|
598
|
+
normally needed to ensure the geometry is meshed correctly. However if
|
|
599
|
+
you know your geometry does not need imprinting you can set this to False
|
|
600
|
+
and this can save time.
|
|
555
601
|
"""
|
|
556
602
|
|
|
557
603
|
assembly = cq.Assembly()
|
|
558
604
|
for part in self.parts:
|
|
559
605
|
assembly.add(part)
|
|
560
606
|
|
|
561
|
-
|
|
607
|
+
if imprint:
|
|
608
|
+
imprinted_assembly, _ = cq.occ_impl.assembly.imprint(assembly)
|
|
609
|
+
else:
|
|
610
|
+
imprinted_assembly = assembly
|
|
562
611
|
|
|
563
612
|
gmsh = init_gmsh()
|
|
564
613
|
|
|
@@ -587,11 +636,11 @@ class CadToDagmc:
|
|
|
587
636
|
implicit_complement_material_tag: str | None = None,
|
|
588
637
|
method: str = "file",
|
|
589
638
|
scale_factor: float = 1.0,
|
|
639
|
+
imprint: bool = True,
|
|
590
640
|
) -> str:
|
|
591
641
|
"""Saves a DAGMC h5m file of the geometry
|
|
592
642
|
|
|
593
643
|
Args:
|
|
594
|
-
|
|
595
644
|
filename (str, optional): the filename to use for the saved DAGMC file. Defaults to "dagmc.h5m".
|
|
596
645
|
min_mesh_size (float, optional): the minimum size of mesh elements to use. Defaults to 1.
|
|
597
646
|
max_mesh_size (float, optional): the maximum size of mesh elements to use. Defaults to 5.
|
|
@@ -610,6 +659,10 @@ class CadToDagmc:
|
|
|
610
659
|
scale_factor: a scaling factor to apply to the geometry that can be
|
|
611
660
|
used to enlarge or shrink the geometry. Useful when converting
|
|
612
661
|
Useful when converting the geometry to cm for use in neutronics
|
|
662
|
+
imprint: whether to imprint the geometry or not. Defaults to True as this is
|
|
663
|
+
normally needed to ensure the geometry is meshed correctly. However if
|
|
664
|
+
you know your geometry does not need imprinting you can set this to False
|
|
665
|
+
and this can save time.
|
|
613
666
|
|
|
614
667
|
Returns:
|
|
615
668
|
str: the DAGMC filename saved
|
|
@@ -619,21 +672,27 @@ class CadToDagmc:
|
|
|
619
672
|
for part in self.parts:
|
|
620
673
|
assembly.add(part)
|
|
621
674
|
|
|
622
|
-
imprinted_assembly, imprinted_solids_with_org_id = cq.occ_impl.assembly.imprint(assembly)
|
|
623
|
-
|
|
624
675
|
original_ids = _get_ids_from_assembly(assembly)
|
|
625
|
-
scrambled_ids = _get_ids_from_imprinted_assembly(imprinted_solids_with_org_id)
|
|
626
676
|
|
|
627
677
|
# both id lists should be the same length as each other and the same
|
|
628
678
|
# length as the self.material_tags
|
|
629
|
-
|
|
630
679
|
if len(original_ids) != len(self.material_tags):
|
|
631
680
|
msg = f"Number of volumes {len(original_ids)} is not equal to number of material tags {len(self.material_tags)}"
|
|
632
681
|
raise ValueError(msg)
|
|
633
682
|
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
683
|
+
if imprint:
|
|
684
|
+
imprinted_assembly, imprinted_solids_with_org_id = cq.occ_impl.assembly.imprint(
|
|
685
|
+
assembly
|
|
686
|
+
)
|
|
687
|
+
|
|
688
|
+
scrambled_ids = _get_ids_from_imprinted_assembly(imprinted_solids_with_org_id)
|
|
689
|
+
|
|
690
|
+
material_tags_in_brep_order = order_material_ids_by_brep_order(
|
|
691
|
+
original_ids, scrambled_ids, self.material_tags
|
|
692
|
+
)
|
|
693
|
+
else:
|
|
694
|
+
material_tags_in_brep_order = self.material_tags
|
|
695
|
+
imprinted_assembly = assembly
|
|
637
696
|
|
|
638
697
|
_check_material_tags(material_tags_in_brep_order, self.parts)
|
|
639
698
|
|
|
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
|
{cad_to_dagmc-0.7.3 → cad_to_dagmc-0.7.5}/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.3 → cad_to_dagmc-0.7.5}/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.3 → cad_to_dagmc-0.7.5}/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
|