cad-to-dagmc 0.9.2__py3-none-any.whl → 0.9.3__py3-none-any.whl
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.
- _version.py +16 -3
- cad_to_dagmc/core.py +160 -62
- {cad_to_dagmc-0.9.2.dist-info → cad_to_dagmc-0.9.3.dist-info}/METADATA +1 -1
- cad_to_dagmc-0.9.3.dist-info/RECORD +8 -0
- {cad_to_dagmc-0.9.2.dist-info → cad_to_dagmc-0.9.3.dist-info}/WHEEL +1 -1
- cad_to_dagmc-0.9.2.dist-info/RECORD +0 -8
- {cad_to_dagmc-0.9.2.dist-info → cad_to_dagmc-0.9.3.dist-info}/licenses/LICENSE +0 -0
- {cad_to_dagmc-0.9.2.dist-info → cad_to_dagmc-0.9.3.dist-info}/top_level.txt +0 -0
_version.py
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
# file generated by setuptools-scm
|
|
2
2
|
# don't change, don't track in version control
|
|
3
3
|
|
|
4
|
-
__all__ = [
|
|
4
|
+
__all__ = [
|
|
5
|
+
"__version__",
|
|
6
|
+
"__version_tuple__",
|
|
7
|
+
"version",
|
|
8
|
+
"version_tuple",
|
|
9
|
+
"__commit_id__",
|
|
10
|
+
"commit_id",
|
|
11
|
+
]
|
|
5
12
|
|
|
6
13
|
TYPE_CHECKING = False
|
|
7
14
|
if TYPE_CHECKING:
|
|
@@ -9,13 +16,19 @@ if TYPE_CHECKING:
|
|
|
9
16
|
from typing import Union
|
|
10
17
|
|
|
11
18
|
VERSION_TUPLE = Tuple[Union[int, str], ...]
|
|
19
|
+
COMMIT_ID = Union[str, None]
|
|
12
20
|
else:
|
|
13
21
|
VERSION_TUPLE = object
|
|
22
|
+
COMMIT_ID = object
|
|
14
23
|
|
|
15
24
|
version: str
|
|
16
25
|
__version__: str
|
|
17
26
|
__version_tuple__: VERSION_TUPLE
|
|
18
27
|
version_tuple: VERSION_TUPLE
|
|
28
|
+
commit_id: COMMIT_ID
|
|
29
|
+
__commit_id__: COMMIT_ID
|
|
19
30
|
|
|
20
|
-
__version__ = version = '0.9.
|
|
21
|
-
__version_tuple__ = version_tuple = (0, 9,
|
|
31
|
+
__version__ = version = '0.9.3'
|
|
32
|
+
__version_tuple__ = version_tuple = (0, 9, 3)
|
|
33
|
+
|
|
34
|
+
__commit_id__ = commit_id = None
|
cad_to_dagmc/core.py
CHANGED
|
@@ -811,53 +811,112 @@ class CadToDagmc:
|
|
|
811
811
|
def export_dagmc_h5m_file(
|
|
812
812
|
self,
|
|
813
813
|
filename: str = "dagmc.h5m",
|
|
814
|
-
|
|
815
|
-
max_mesh_size: float | None = None,
|
|
816
|
-
mesh_algorithm: int = 1,
|
|
814
|
+
meshing_backend: str = "cadquery",
|
|
817
815
|
implicit_complement_material_tag: str | None = None,
|
|
818
|
-
method: str = "file",
|
|
819
816
|
scale_factor: float = 1.0,
|
|
820
817
|
imprint: bool = True,
|
|
821
|
-
|
|
822
|
-
unstructured_volumes: Iterable[int] | None = None,
|
|
823
|
-
umesh_filename: str = "umesh.vtk",
|
|
818
|
+
**kwargs,
|
|
824
819
|
) -> str:
|
|
825
820
|
"""Saves a DAGMC h5m file of the geometry
|
|
826
821
|
|
|
827
822
|
Args:
|
|
828
|
-
filename
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
set_size: a dictionary of volume ids (int) and target mesh sizes
|
|
851
|
-
(floats) to set for each volume, passed to gmsh.model.mesh.setSize.
|
|
852
|
-
unstructured_volumes: a list of volume ids to be saved in as an
|
|
853
|
-
unstructured mesh file.
|
|
854
|
-
umesh_filename: the filename to use for the optional unstructured
|
|
855
|
-
mesh file. Only used if unstructured_volumes is not empty.
|
|
823
|
+
filename: the filename to use for the saved DAGMC file.
|
|
824
|
+
meshing_backend: determines whether gmsh or cadquery's direct mesh method
|
|
825
|
+
is used for meshing. Options are 'gmsh' or 'cadquery'.
|
|
826
|
+
implicit_complement_material_tag: the name of the material tag to use
|
|
827
|
+
for the implicit complement (void space).
|
|
828
|
+
scale_factor: a scaling factor to apply to the geometry.
|
|
829
|
+
imprint: whether to imprint the geometry or not.
|
|
830
|
+
|
|
831
|
+
**kwargs: Backend-specific parameters:
|
|
832
|
+
|
|
833
|
+
For GMSH backend:
|
|
834
|
+
- min_mesh_size (float): minimum mesh element size
|
|
835
|
+
- max_mesh_size (float): maximum mesh element size
|
|
836
|
+
- mesh_algorithm (int): GMSH mesh algorithm (default: 1)
|
|
837
|
+
- method (str): import method 'file' or 'in memory' (default: 'file')
|
|
838
|
+
- set_size (dict[int, float]): volume ids and target mesh sizes
|
|
839
|
+
- unstructured_volumes (Iterable[int]): volume ids for unstructured mesh
|
|
840
|
+
- umesh_filename (str): filename for unstructured mesh (default: 'umesh.vtk')
|
|
841
|
+
|
|
842
|
+
For CadQuery backend:
|
|
843
|
+
- tolerance (float): meshing tolerance (default: 0.1)
|
|
844
|
+
- angular_tolerance (float): angular tolerance (default: 0.1)
|
|
856
845
|
|
|
857
846
|
Returns:
|
|
858
|
-
str: the
|
|
847
|
+
str: the filename(s) for the files created.
|
|
848
|
+
|
|
849
|
+
Raises:
|
|
850
|
+
ValueError: If invalid parameter combinations are used.
|
|
859
851
|
"""
|
|
860
852
|
|
|
853
|
+
# Validate meshing backend
|
|
854
|
+
if meshing_backend not in ["gmsh", "cadquery"]:
|
|
855
|
+
raise ValueError(
|
|
856
|
+
f'meshing_backend "{meshing_backend}" not supported. '
|
|
857
|
+
'Available options are "gmsh" or "cadquery"'
|
|
858
|
+
)
|
|
859
|
+
|
|
860
|
+
# Initialize variables to avoid unbound errors
|
|
861
|
+
tolerance = 0.1
|
|
862
|
+
angular_tolerance = 0.1
|
|
863
|
+
min_mesh_size = None
|
|
864
|
+
max_mesh_size = None
|
|
865
|
+
mesh_algorithm = 1
|
|
866
|
+
method = "file"
|
|
867
|
+
set_size = None
|
|
868
|
+
unstructured_volumes = None
|
|
869
|
+
umesh_filename = "umesh.vtk"
|
|
870
|
+
|
|
871
|
+
# Extract backend-specific parameters with defaults
|
|
872
|
+
if meshing_backend == "cadquery":
|
|
873
|
+
# CadQuery parameters
|
|
874
|
+
tolerance = kwargs.get("tolerance", 0.1)
|
|
875
|
+
angular_tolerance = kwargs.get("angular_tolerance", 0.1)
|
|
876
|
+
|
|
877
|
+
# Check for invalid parameters
|
|
878
|
+
unstructured_volumes = kwargs.get("unstructured_volumes")
|
|
879
|
+
if unstructured_volumes is not None:
|
|
880
|
+
raise ValueError(
|
|
881
|
+
"CadQuery backend cannot be used for volume meshing. "
|
|
882
|
+
"unstructured_volumes must be None when using 'cadquery' backend."
|
|
883
|
+
)
|
|
884
|
+
|
|
885
|
+
# Warn about unused GMSH parameters
|
|
886
|
+
gmsh_params = [
|
|
887
|
+
"min_mesh_size",
|
|
888
|
+
"max_mesh_size",
|
|
889
|
+
"mesh_algorithm",
|
|
890
|
+
"set_size",
|
|
891
|
+
"umesh_filename",
|
|
892
|
+
"method",
|
|
893
|
+
]
|
|
894
|
+
unused_params = [param for param in gmsh_params if param in kwargs]
|
|
895
|
+
if unused_params:
|
|
896
|
+
warnings.warn(
|
|
897
|
+
f"The following parameters are ignored when using CadQuery backend: "
|
|
898
|
+
f"{', '.join(unused_params)}"
|
|
899
|
+
)
|
|
900
|
+
|
|
901
|
+
elif meshing_backend == "gmsh":
|
|
902
|
+
# GMSH parameters
|
|
903
|
+
min_mesh_size = kwargs.get("min_mesh_size")
|
|
904
|
+
max_mesh_size = kwargs.get("max_mesh_size")
|
|
905
|
+
mesh_algorithm = kwargs.get("mesh_algorithm", 1)
|
|
906
|
+
method = kwargs.get("method", "file")
|
|
907
|
+
set_size = kwargs.get("set_size")
|
|
908
|
+
unstructured_volumes = kwargs.get("unstructured_volumes")
|
|
909
|
+
umesh_filename = kwargs.get("umesh_filename", "umesh.vtk")
|
|
910
|
+
|
|
911
|
+
# Warn about unused CadQuery parameters
|
|
912
|
+
cq_params = ["tolerance", "angular_tolerance"]
|
|
913
|
+
unused_params = [param for param in cq_params if param in kwargs]
|
|
914
|
+
if unused_params:
|
|
915
|
+
warnings.warn(
|
|
916
|
+
f"The following parameters are ignored when using GMSH backend: "
|
|
917
|
+
f"{', '.join(unused_params)}"
|
|
918
|
+
)
|
|
919
|
+
|
|
861
920
|
assembly = cq.Assembly()
|
|
862
921
|
for part in self.parts:
|
|
863
922
|
assembly.add(part)
|
|
@@ -870,41 +929,80 @@ class CadToDagmc:
|
|
|
870
929
|
msg = f"Number of volumes {len(original_ids)} is not equal to number of material tags {len(self.material_tags)}"
|
|
871
930
|
raise ValueError(msg)
|
|
872
931
|
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
932
|
+
# Use the CadQuery direct mesh plugin
|
|
933
|
+
if meshing_backend == "cadquery":
|
|
934
|
+
import cadquery_direct_mesh_plugin
|
|
935
|
+
|
|
936
|
+
# Mesh the assembly using CadQuery's direct-mesh plugin
|
|
937
|
+
cq_mesh = assembly.toMesh(
|
|
938
|
+
imprint,
|
|
939
|
+
tolerance=tolerance,
|
|
940
|
+
angular_tolerance=angular_tolerance,
|
|
941
|
+
scale_factor=scale_factor,
|
|
876
942
|
)
|
|
877
943
|
|
|
878
|
-
|
|
944
|
+
# Fix the material tag order for imprinted assemblies
|
|
945
|
+
if cq_mesh["imprinted_assembly"] is not None:
|
|
946
|
+
imprinted_solids_with_org_id = cq_mesh["imprinted_solids_with_orginal_ids"]
|
|
879
947
|
|
|
880
|
-
|
|
881
|
-
original_ids, scrambled_ids, self.material_tags
|
|
882
|
-
)
|
|
883
|
-
else:
|
|
884
|
-
material_tags_in_brep_order = self.material_tags
|
|
885
|
-
imprinted_assembly = assembly
|
|
948
|
+
scrambled_ids = get_ids_from_imprinted_assembly(imprinted_solids_with_org_id)
|
|
886
949
|
|
|
887
|
-
|
|
950
|
+
material_tags_in_brep_order = order_material_ids_by_brep_order(
|
|
951
|
+
original_ids, scrambled_ids, self.material_tags
|
|
952
|
+
)
|
|
953
|
+
else:
|
|
954
|
+
material_tags_in_brep_order = self.material_tags
|
|
955
|
+
|
|
956
|
+
check_material_tags(material_tags_in_brep_order, self.parts)
|
|
957
|
+
|
|
958
|
+
# Extract the mesh information to allow export to h5m from the direct-mesh result
|
|
959
|
+
vertices = cq_mesh["vertices"]
|
|
960
|
+
triangles_by_solid_by_face = cq_mesh["solid_face_triangle_vertex_map"]
|
|
961
|
+
# Use gmsh
|
|
962
|
+
elif meshing_backend == "gmsh":
|
|
963
|
+
# If assembly is not to be imprinted, pass through the assembly as-is
|
|
964
|
+
if imprint:
|
|
965
|
+
imprinted_assembly, imprinted_solids_with_org_id = cq.occ_impl.assembly.imprint(
|
|
966
|
+
assembly
|
|
967
|
+
)
|
|
888
968
|
|
|
889
|
-
|
|
969
|
+
scrambled_ids = get_ids_from_imprinted_assembly(imprinted_solids_with_org_id)
|
|
890
970
|
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
971
|
+
material_tags_in_brep_order = order_material_ids_by_brep_order(
|
|
972
|
+
original_ids, scrambled_ids, self.material_tags
|
|
973
|
+
)
|
|
894
974
|
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
max_mesh_size=max_mesh_size,
|
|
899
|
-
mesh_algorithm=mesh_algorithm,
|
|
900
|
-
set_size=set_size,
|
|
901
|
-
)
|
|
975
|
+
else:
|
|
976
|
+
material_tags_in_brep_order = self.material_tags
|
|
977
|
+
imprinted_assembly = assembly
|
|
902
978
|
|
|
903
|
-
|
|
979
|
+
check_material_tags(material_tags_in_brep_order, self.parts)
|
|
904
980
|
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
981
|
+
# Start generating the mesh
|
|
982
|
+
gmsh = init_gmsh()
|
|
983
|
+
|
|
984
|
+
gmsh, volumes = get_volumes(
|
|
985
|
+
gmsh, imprinted_assembly, method=method, scale_factor=scale_factor
|
|
986
|
+
)
|
|
987
|
+
|
|
988
|
+
gmsh = set_sizes_for_mesh(
|
|
989
|
+
gmsh=gmsh,
|
|
990
|
+
min_mesh_size=min_mesh_size,
|
|
991
|
+
max_mesh_size=max_mesh_size,
|
|
992
|
+
mesh_algorithm=mesh_algorithm,
|
|
993
|
+
set_size=set_size,
|
|
994
|
+
)
|
|
995
|
+
|
|
996
|
+
gmsh.model.mesh.generate(2)
|
|
997
|
+
|
|
998
|
+
vertices, triangles_by_solid_by_face = mesh_to_vertices_and_triangles(
|
|
999
|
+
dims_and_vol_ids=volumes
|
|
1000
|
+
)
|
|
1001
|
+
|
|
1002
|
+
else:
|
|
1003
|
+
raise ValueError(
|
|
1004
|
+
f'meshing_backend {meshing_backend} not supported. Available options are "cadquery" or "gmsh"'
|
|
1005
|
+
)
|
|
908
1006
|
|
|
909
1007
|
dagmc_filename = vertices_to_h5m(
|
|
910
1008
|
vertices=vertices,
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
_version.py,sha256=IVkGBvcxJApDB_GrSj1qL5BDxEvWBYmqcR3emEmrC0I,704
|
|
2
|
+
cad_to_dagmc/__init__.py,sha256=fskHUTyCunSpnpJUvBfAYjx4uwDKXHTTiMP6GqnFRf0,494
|
|
3
|
+
cad_to_dagmc/core.py,sha256=2OzaYEMcWr508PuyciESTJPvOKRAbEwfOOL6d4VKEzM,40333
|
|
4
|
+
cad_to_dagmc-0.9.3.dist-info/licenses/LICENSE,sha256=B8kznH_777JVNZ3HOKDc4Tj24F7wJ68ledaNYeL9sCw,1070
|
|
5
|
+
cad_to_dagmc-0.9.3.dist-info/METADATA,sha256=OmHxTGWZTity6KYaUwMwB9wppyBxxcry_ikCWOvSfPU,8990
|
|
6
|
+
cad_to_dagmc-0.9.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
7
|
+
cad_to_dagmc-0.9.3.dist-info/top_level.txt,sha256=zTi8C64SEBsE5WOtPovnxhOzt-E6Oc5nC3RW6M_5aEA,22
|
|
8
|
+
cad_to_dagmc-0.9.3.dist-info/RECORD,,
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
_version.py,sha256=eeYYTSIkrgfRwSQ7LKo_py3xs3DvzgfWiAtK4K1JM4A,511
|
|
2
|
-
cad_to_dagmc/__init__.py,sha256=fskHUTyCunSpnpJUvBfAYjx4uwDKXHTTiMP6GqnFRf0,494
|
|
3
|
-
cad_to_dagmc/core.py,sha256=dGj5LRRzboQ8CL8VS5dkvIkGLyj5MJWcbkTPtrFk0QQ,36947
|
|
4
|
-
cad_to_dagmc-0.9.2.dist-info/licenses/LICENSE,sha256=B8kznH_777JVNZ3HOKDc4Tj24F7wJ68ledaNYeL9sCw,1070
|
|
5
|
-
cad_to_dagmc-0.9.2.dist-info/METADATA,sha256=8vLnV93ycmV216LiNj38YI4z445pWtdpBKpcESFLLH0,8990
|
|
6
|
-
cad_to_dagmc-0.9.2.dist-info/WHEEL,sha256=0CuiUZ_p9E4cD6NyLD6UG80LBXYyiSYZOKDm5lp32xk,91
|
|
7
|
-
cad_to_dagmc-0.9.2.dist-info/top_level.txt,sha256=zTi8C64SEBsE5WOtPovnxhOzt-E6Oc5nC3RW6M_5aEA,22
|
|
8
|
-
cad_to_dagmc-0.9.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|