cad-to-dagmc 0.8.0__py3-none-any.whl → 0.8.2__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.
Potentially problematic release.
This version of cad-to-dagmc might be problematic. Click here for more details.
- _version.py +2 -2
- cad_to_dagmc/core.py +28 -18
- {cad_to_dagmc-0.8.0.dist-info → cad_to_dagmc-0.8.2.dist-info}/METADATA +1 -1
- cad_to_dagmc-0.8.2.dist-info/RECORD +8 -0
- cad_to_dagmc-0.8.0.dist-info/RECORD +0 -8
- {cad_to_dagmc-0.8.0.dist-info → cad_to_dagmc-0.8.2.dist-info}/LICENSE +0 -0
- {cad_to_dagmc-0.8.0.dist-info → cad_to_dagmc-0.8.2.dist-info}/WHEEL +0 -0
- {cad_to_dagmc-0.8.0.dist-info → cad_to_dagmc-0.8.2.dist-info}/top_level.txt +0 -0
_version.py
CHANGED
cad_to_dagmc/core.py
CHANGED
|
@@ -8,7 +8,7 @@ import tempfile
|
|
|
8
8
|
import warnings
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
def
|
|
11
|
+
def define_moab_core_and_tags() -> tuple[core.Core, dict]:
|
|
12
12
|
"""Creates a MOAB Core instance which can be built up by adding sets of
|
|
13
13
|
triangles to the instance
|
|
14
14
|
|
|
@@ -62,7 +62,7 @@ def _define_moab_core_and_tags() -> tuple[core.Core, dict]:
|
|
|
62
62
|
return moab_core, tags
|
|
63
63
|
|
|
64
64
|
|
|
65
|
-
def
|
|
65
|
+
def vertices_to_h5m(
|
|
66
66
|
vertices: list[tuple[float, float, float]] | list["cadquery.occ_impl.geom.Vector"],
|
|
67
67
|
triangles_by_solid_by_face: list[list[tuple[int, int, int]]],
|
|
68
68
|
material_tags: list[str],
|
|
@@ -100,7 +100,7 @@ def _vertices_to_h5m(
|
|
|
100
100
|
else:
|
|
101
101
|
face_ids_with_solid_ids[face_id] = [solid_id]
|
|
102
102
|
|
|
103
|
-
moab_core, tags =
|
|
103
|
+
moab_core, tags = define_moab_core_and_tags()
|
|
104
104
|
|
|
105
105
|
volume_sets_by_solid_id = {}
|
|
106
106
|
for material_tag, (solid_id, triangles_on_each_face) in zip(
|
|
@@ -233,7 +233,7 @@ def init_gmsh():
|
|
|
233
233
|
return gmsh
|
|
234
234
|
|
|
235
235
|
|
|
236
|
-
def
|
|
236
|
+
def mesh_brep(
|
|
237
237
|
gmsh,
|
|
238
238
|
min_mesh_size: float | None = None,
|
|
239
239
|
max_mesh_size: float | None = None,
|
|
@@ -355,21 +355,21 @@ def mesh_to_vertices_and_triangles(
|
|
|
355
355
|
return vertices, triangles_by_solid_by_face
|
|
356
356
|
|
|
357
357
|
|
|
358
|
-
def
|
|
358
|
+
def get_ids_from_assembly(assembly: cq.assembly.Assembly):
|
|
359
359
|
ids = []
|
|
360
360
|
for obj, name, loc, _ in assembly:
|
|
361
361
|
ids.append(name)
|
|
362
362
|
return ids
|
|
363
363
|
|
|
364
364
|
|
|
365
|
-
def
|
|
365
|
+
def get_ids_from_imprinted_assembly(solid_id_dict):
|
|
366
366
|
ids = []
|
|
367
367
|
for id in list(solid_id_dict.values()):
|
|
368
368
|
ids.append(id[0])
|
|
369
369
|
return ids
|
|
370
370
|
|
|
371
371
|
|
|
372
|
-
def
|
|
372
|
+
def check_material_tags(material_tags, iterable_solids):
|
|
373
373
|
if material_tags:
|
|
374
374
|
if len(material_tags) != len(iterable_solids):
|
|
375
375
|
msg = (
|
|
@@ -448,7 +448,7 @@ class MeshToDagmc:
|
|
|
448
448
|
|
|
449
449
|
gmsh.finalize()
|
|
450
450
|
|
|
451
|
-
h5m_filename =
|
|
451
|
+
h5m_filename = vertices_to_h5m(
|
|
452
452
|
vertices=vertices,
|
|
453
453
|
triangles_by_solid_by_face=triangles_by_solid_by_face,
|
|
454
454
|
material_tags=material_tags,
|
|
@@ -503,6 +503,7 @@ class CadToDagmc:
|
|
|
503
503
|
cq.assembly.Assembly | cq.occ_impl.shapes.Compound | cq.occ_impl.shapes.Solid
|
|
504
504
|
),
|
|
505
505
|
material_tags: list[str] | None,
|
|
506
|
+
scale_factor: float = 1.0,
|
|
506
507
|
) -> int:
|
|
507
508
|
"""Loads the parts from CadQuery object into the model.
|
|
508
509
|
|
|
@@ -514,6 +515,10 @@ class CadToDagmc:
|
|
|
514
515
|
same order as the volumes in the geometry added (STP file and
|
|
515
516
|
CadQuery objects) and match the material tags used in the
|
|
516
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.
|
|
517
522
|
|
|
518
523
|
Returns:
|
|
519
524
|
int: number of volumes in the stp file.
|
|
@@ -527,12 +532,17 @@ class CadToDagmc:
|
|
|
527
532
|
else:
|
|
528
533
|
iterable_solids = cadquery_object.val().Solids()
|
|
529
534
|
|
|
530
|
-
|
|
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)
|
|
531
541
|
if material_tags:
|
|
532
542
|
self.material_tags = self.material_tags + material_tags
|
|
533
|
-
self.parts = self.parts +
|
|
543
|
+
self.parts = self.parts + scaled_iterable_solids
|
|
534
544
|
|
|
535
|
-
return len(
|
|
545
|
+
return len(scaled_iterable_solids)
|
|
536
546
|
|
|
537
547
|
def export_unstructured_mesh_file(
|
|
538
548
|
self,
|
|
@@ -603,7 +613,7 @@ class CadToDagmc:
|
|
|
603
613
|
|
|
604
614
|
gmsh, _ = get_volumes(gmsh, imprinted_assembly, method=method, scale_factor=scale_factor)
|
|
605
615
|
|
|
606
|
-
gmsh =
|
|
616
|
+
gmsh = mesh_brep(
|
|
607
617
|
gmsh=gmsh,
|
|
608
618
|
min_mesh_size=min_mesh_size,
|
|
609
619
|
max_mesh_size=max_mesh_size,
|
|
@@ -680,7 +690,7 @@ class CadToDagmc:
|
|
|
680
690
|
|
|
681
691
|
gmsh, _ = get_volumes(gmsh, imprinted_assembly, method=method, scale_factor=scale_factor)
|
|
682
692
|
|
|
683
|
-
gmsh =
|
|
693
|
+
gmsh = mesh_brep(
|
|
684
694
|
gmsh=gmsh,
|
|
685
695
|
min_mesh_size=min_mesh_size,
|
|
686
696
|
max_mesh_size=max_mesh_size,
|
|
@@ -751,7 +761,7 @@ class CadToDagmc:
|
|
|
751
761
|
for part in self.parts:
|
|
752
762
|
assembly.add(part)
|
|
753
763
|
|
|
754
|
-
original_ids =
|
|
764
|
+
original_ids = get_ids_from_assembly(assembly)
|
|
755
765
|
|
|
756
766
|
# both id lists should be the same length as each other and the same
|
|
757
767
|
# length as the self.material_tags
|
|
@@ -764,7 +774,7 @@ class CadToDagmc:
|
|
|
764
774
|
assembly
|
|
765
775
|
)
|
|
766
776
|
|
|
767
|
-
scrambled_ids =
|
|
777
|
+
scrambled_ids = get_ids_from_imprinted_assembly(imprinted_solids_with_org_id)
|
|
768
778
|
|
|
769
779
|
material_tags_in_brep_order = order_material_ids_by_brep_order(
|
|
770
780
|
original_ids, scrambled_ids, self.material_tags
|
|
@@ -773,7 +783,7 @@ class CadToDagmc:
|
|
|
773
783
|
material_tags_in_brep_order = self.material_tags
|
|
774
784
|
imprinted_assembly = assembly
|
|
775
785
|
|
|
776
|
-
|
|
786
|
+
check_material_tags(material_tags_in_brep_order, self.parts)
|
|
777
787
|
|
|
778
788
|
gmsh = init_gmsh()
|
|
779
789
|
|
|
@@ -781,7 +791,7 @@ class CadToDagmc:
|
|
|
781
791
|
gmsh, imprinted_assembly, method=method, scale_factor=scale_factor
|
|
782
792
|
)
|
|
783
793
|
|
|
784
|
-
gmsh =
|
|
794
|
+
gmsh = mesh_brep(
|
|
785
795
|
gmsh=gmsh,
|
|
786
796
|
min_mesh_size=min_mesh_size,
|
|
787
797
|
max_mesh_size=max_mesh_size,
|
|
@@ -798,7 +808,7 @@ class CadToDagmc:
|
|
|
798
808
|
gmsh.finalize()
|
|
799
809
|
|
|
800
810
|
# checks and fixes triangle fix_normals within vertices_to_h5m
|
|
801
|
-
return
|
|
811
|
+
return vertices_to_h5m(
|
|
802
812
|
vertices=vertices,
|
|
803
813
|
triangles_by_solid_by_face=triangles_by_solid_by_face,
|
|
804
814
|
material_tags=material_tags_in_brep_order,
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
_version.py,sha256=t6tJJG56wlBKsg_0M1Q4l1ir09jgXRw1tolMbDalW9g,411
|
|
2
|
+
cad_to_dagmc/__init__.py,sha256=fskHUTyCunSpnpJUvBfAYjx4uwDKXHTTiMP6GqnFRf0,494
|
|
3
|
+
cad_to_dagmc/core.py,sha256=dW8p0TuQKJHPR6dqOulc7mTkB9zB2q_odkNSg8mU-Ew,31867
|
|
4
|
+
cad_to_dagmc-0.8.2.dist-info/LICENSE,sha256=B8kznH_777JVNZ3HOKDc4Tj24F7wJ68ledaNYeL9sCw,1070
|
|
5
|
+
cad_to_dagmc-0.8.2.dist-info/METADATA,sha256=aRZgmsBIcMbAB80vBJmuCWUkN6Ejab7X0IPBXsc52lU,8700
|
|
6
|
+
cad_to_dagmc-0.8.2.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
|
7
|
+
cad_to_dagmc-0.8.2.dist-info/top_level.txt,sha256=zTi8C64SEBsE5WOtPovnxhOzt-E6Oc5nC3RW6M_5aEA,22
|
|
8
|
+
cad_to_dagmc-0.8.2.dist-info/RECORD,,
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
_version.py,sha256=vspFLRfYI6gAAN7kyihey2lhPos0jxqKaNDWFlKPlmU,411
|
|
2
|
-
cad_to_dagmc/__init__.py,sha256=fskHUTyCunSpnpJUvBfAYjx4uwDKXHTTiMP6GqnFRf0,494
|
|
3
|
-
cad_to_dagmc/core.py,sha256=w8Bu3MyjhQtW4KYRXktib7aPbjTy8jfSdpSgzw57gIc,31366
|
|
4
|
-
cad_to_dagmc-0.8.0.dist-info/LICENSE,sha256=B8kznH_777JVNZ3HOKDc4Tj24F7wJ68ledaNYeL9sCw,1070
|
|
5
|
-
cad_to_dagmc-0.8.0.dist-info/METADATA,sha256=GvclO4Hs5U2TwJLenoQZVAsQ0GSNOjOQ1IUhqS0rNWA,8700
|
|
6
|
-
cad_to_dagmc-0.8.0.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
|
7
|
-
cad_to_dagmc-0.8.0.dist-info/top_level.txt,sha256=zTi8C64SEBsE5WOtPovnxhOzt-E6Oc5nC3RW6M_5aEA,22
|
|
8
|
-
cad_to_dagmc-0.8.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|