cad-to-dagmc 0.8.2__py3-none-any.whl → 0.9.0__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 +9 -4
- cad_to_dagmc/core.py +109 -48
- {cad_to_dagmc-0.8.2.dist-info → cad_to_dagmc-0.9.0.dist-info}/METADATA +9 -4
- cad_to_dagmc-0.9.0.dist-info/RECORD +8 -0
- {cad_to_dagmc-0.8.2.dist-info → cad_to_dagmc-0.9.0.dist-info}/WHEEL +1 -1
- cad_to_dagmc-0.8.2.dist-info/RECORD +0 -8
- {cad_to_dagmc-0.8.2.dist-info → cad_to_dagmc-0.9.0.dist-info/licenses}/LICENSE +0 -0
- {cad_to_dagmc-0.8.2.dist-info → cad_to_dagmc-0.9.0.dist-info}/top_level.txt +0 -0
_version.py
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
# file generated by
|
|
1
|
+
# file generated by setuptools-scm
|
|
2
2
|
# don't change, don't track in version control
|
|
3
|
+
|
|
4
|
+
__all__ = ["__version__", "__version_tuple__", "version", "version_tuple"]
|
|
5
|
+
|
|
3
6
|
TYPE_CHECKING = False
|
|
4
7
|
if TYPE_CHECKING:
|
|
5
|
-
from typing import Tuple
|
|
8
|
+
from typing import Tuple
|
|
9
|
+
from typing import Union
|
|
10
|
+
|
|
6
11
|
VERSION_TUPLE = Tuple[Union[int, str], ...]
|
|
7
12
|
else:
|
|
8
13
|
VERSION_TUPLE = object
|
|
@@ -12,5 +17,5 @@ __version__: str
|
|
|
12
17
|
__version_tuple__: VERSION_TUPLE
|
|
13
18
|
version_tuple: VERSION_TUPLE
|
|
14
19
|
|
|
15
|
-
__version__ = version = '0.
|
|
16
|
-
__version_tuple__ = version_tuple = (0,
|
|
20
|
+
__version__ = version = '0.9.0'
|
|
21
|
+
__version_tuple__ = version_tuple = (0, 9, 0)
|
cad_to_dagmc/core.py
CHANGED
|
@@ -6,6 +6,7 @@ from cadquery import importers
|
|
|
6
6
|
from pymoab import core, types
|
|
7
7
|
import tempfile
|
|
8
8
|
import warnings
|
|
9
|
+
from cad_to_dagmc import __version__
|
|
9
10
|
|
|
10
11
|
|
|
11
12
|
def define_moab_core_and_tags() -> tuple[core.Core, dict]:
|
|
@@ -229,7 +230,7 @@ def get_volumes(gmsh, assembly, method="file", scale_factor=1.0):
|
|
|
229
230
|
def init_gmsh():
|
|
230
231
|
gmsh.initialize()
|
|
231
232
|
gmsh.option.setNumber("General.Terminal", 1)
|
|
232
|
-
gmsh.model.add("
|
|
233
|
+
gmsh.model.add(f"made_with_cad_to_dagmc_package_{__version__}")
|
|
233
234
|
return gmsh
|
|
234
235
|
|
|
235
236
|
|
|
@@ -318,7 +319,9 @@ def mesh_to_vertices_and_triangles(
|
|
|
318
319
|
for dim_and_vol in dims_and_vol_ids:
|
|
319
320
|
# removes all groups so that the following getEntitiesForPhysicalGroup
|
|
320
321
|
# command only finds surfaces for the volume
|
|
321
|
-
gmsh.model.
|
|
322
|
+
face_groups = gmsh.model.getPhysicalGroups(2)
|
|
323
|
+
if face_groups: # Only remove if 2D groups exist
|
|
324
|
+
gmsh.model.removePhysicalGroups(face_groups)
|
|
322
325
|
|
|
323
326
|
vol_id = dim_and_vol[1]
|
|
324
327
|
entities_in_volume = gmsh.model.getAdjacencies(3, vol_id)
|
|
@@ -399,64 +402,122 @@ def order_material_ids_by_brep_order(original_ids, scrambled_id, material_tags):
|
|
|
399
402
|
return material_tags_in_brep_order
|
|
400
403
|
|
|
401
404
|
|
|
402
|
-
|
|
403
|
-
|
|
405
|
+
def export_gmsh_object_to_dagmc_h5m_file(
|
|
406
|
+
material_tags: list[str] | None = None,
|
|
407
|
+
implicit_complement_material_tag: str | None = None,
|
|
408
|
+
filename: str = "dagmc.h5m",
|
|
409
|
+
) -> str:
|
|
410
|
+
"""
|
|
411
|
+
Exports a GMSH object to a DAGMC-compatible h5m file. Note gmsh should
|
|
412
|
+
be initialized by the user prior and the gmsh model should be meshed before
|
|
413
|
+
calling this. Also users should ensure that the gmsh model is finalized.
|
|
404
414
|
|
|
405
|
-
|
|
406
|
-
|
|
415
|
+
Args:
|
|
416
|
+
material_tags: A list of material tags corresponding to the volumes in the GMSH object.
|
|
417
|
+
implicit_complement_material_tag: The material tag for the implicit complement (void space).
|
|
418
|
+
filename: The name of the output h5m file. Defaults to "dagmc.h5m".
|
|
407
419
|
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
# TODO test for exports result in files
|
|
420
|
+
Returns:
|
|
421
|
+
str: The filename of the generated DAGMC h5m file.
|
|
411
422
|
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
implicit_complement_material_tag: str | None = None,
|
|
416
|
-
filename: str = "dagmc.h5m",
|
|
417
|
-
):
|
|
418
|
-
"""Saves a DAGMC h5m file of the geometry
|
|
423
|
+
Raises:
|
|
424
|
+
ValueError: If the number of material tags does not match the number of volumes in the GMSH object.
|
|
425
|
+
"""
|
|
419
426
|
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
material tags to assign. These will need to be in the same
|
|
423
|
-
order as the volumes in the GMESH mesh and match the
|
|
424
|
-
material tags used in the neutronics code (e.g. OpenMC).
|
|
425
|
-
implicit_complement_material_tag (str | None, optional):
|
|
426
|
-
the name of the material tag to use for the implicit
|
|
427
|
-
complement (void space). Defaults to None which is a vacuum.
|
|
428
|
-
filename (str, optional): _description_. Defaults to "dagmc.h5m".
|
|
427
|
+
if material_tags is None:
|
|
428
|
+
material_tags = _get_material_tags_from_gmsh()
|
|
429
429
|
|
|
430
|
-
|
|
431
|
-
ValueError: _description_
|
|
430
|
+
dims_and_vol_ids = gmsh.model.getEntities(3)
|
|
432
431
|
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
432
|
+
if len(dims_and_vol_ids) != len(material_tags):
|
|
433
|
+
msg = f"Number of volumes {len(dims_and_vol_ids)} is not equal to number of material tags {len(material_tags)}"
|
|
434
|
+
raise ValueError(msg)
|
|
436
435
|
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
436
|
+
vertices, triangles_by_solid_by_face = mesh_to_vertices_and_triangles(
|
|
437
|
+
dims_and_vol_ids=dims_and_vol_ids
|
|
438
|
+
)
|
|
440
439
|
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
440
|
+
h5m_filename = vertices_to_h5m(
|
|
441
|
+
vertices=vertices,
|
|
442
|
+
triangles_by_solid_by_face=triangles_by_solid_by_face,
|
|
443
|
+
material_tags=material_tags,
|
|
444
|
+
h5m_filename=filename,
|
|
445
|
+
implicit_complement_material_tag=implicit_complement_material_tag,
|
|
446
|
+
)
|
|
444
447
|
|
|
445
|
-
|
|
446
|
-
dims_and_vol_ids=dims_and_vol_ids
|
|
447
|
-
)
|
|
448
|
+
return h5m_filename
|
|
448
449
|
|
|
449
|
-
gmsh.finalize()
|
|
450
450
|
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
451
|
+
def _get_material_tags_from_gmsh() -> list[str]:
|
|
452
|
+
"""Gets the Physical groups of 3D groups from the GMSH object and returns
|
|
453
|
+
their names."""
|
|
454
|
+
|
|
455
|
+
# Get all 3D physical groups (volumes)
|
|
456
|
+
volume_groups = gmsh.model.getPhysicalGroups(3)
|
|
457
|
+
|
|
458
|
+
material_tags = []
|
|
459
|
+
# Get the name for each physical group
|
|
460
|
+
for dim, tag in volume_groups:
|
|
461
|
+
name = gmsh.model.getPhysicalName(dim, tag)
|
|
462
|
+
material_tags.append(name)
|
|
463
|
+
print(f"Material tag: {name}")
|
|
464
|
+
print(f"Material tags: {material_tags}")
|
|
465
|
+
return material_tags
|
|
466
|
+
|
|
467
|
+
|
|
468
|
+
def export_gmsh_file_to_dagmc_h5m_file(
|
|
469
|
+
gmsh_filename: str,
|
|
470
|
+
material_tags: list[str] | None = None,
|
|
471
|
+
implicit_complement_material_tag: str | None = None,
|
|
472
|
+
dagmc_filename: str = "dagmc.h5m",
|
|
473
|
+
) -> str:
|
|
474
|
+
"""Saves a DAGMC h5m file of the geometry GMsh file. This function
|
|
475
|
+
initializes and finalizes Gmsh.
|
|
476
|
+
|
|
477
|
+
Args:
|
|
478
|
+
material_tags (list[str]): the names of the DAGMC
|
|
479
|
+
material tags to assign. These will need to be in the same
|
|
480
|
+
order as the volumes in the GMESH mesh and match the
|
|
481
|
+
material tags used in the neutronics code (e.g. OpenMC).
|
|
482
|
+
implicit_complement_material_tag (str | None, optional):
|
|
483
|
+
the name of the material tag to use for the implicit
|
|
484
|
+
complement (void space). Defaults to None which is a vacuum.
|
|
485
|
+
dagmc_filename (str, optional): _description_. Defaults to "dagmc.h5m".
|
|
486
|
+
|
|
487
|
+
Returns:
|
|
488
|
+
str: The filename of the generated DAGMC h5m file.
|
|
489
|
+
|
|
490
|
+
Raises:
|
|
491
|
+
ValueError: If the number of material tags does not match the number of volumes in the GMSH object.
|
|
492
|
+
"""
|
|
493
|
+
|
|
494
|
+
gmsh.initialize()
|
|
495
|
+
gmsh.open(gmsh_filename)
|
|
496
|
+
|
|
497
|
+
if material_tags is None:
|
|
498
|
+
material_tags = _get_material_tags_from_gmsh()
|
|
499
|
+
|
|
500
|
+
dims_and_vol_ids = gmsh.model.getEntities(3)
|
|
501
|
+
|
|
502
|
+
if len(dims_and_vol_ids) != len(material_tags):
|
|
503
|
+
msg = f"Number of volumes {len(dims_and_vol_ids)} is not equal to number of material tags {len(material_tags)}"
|
|
504
|
+
raise ValueError(msg)
|
|
458
505
|
|
|
459
|
-
|
|
506
|
+
vertices, triangles_by_solid_by_face = mesh_to_vertices_and_triangles(
|
|
507
|
+
dims_and_vol_ids=dims_and_vol_ids
|
|
508
|
+
)
|
|
509
|
+
|
|
510
|
+
gmsh.finalize()
|
|
511
|
+
|
|
512
|
+
h5m_filename = vertices_to_h5m(
|
|
513
|
+
vertices=vertices,
|
|
514
|
+
triangles_by_solid_by_face=triangles_by_solid_by_face,
|
|
515
|
+
material_tags=material_tags,
|
|
516
|
+
h5m_filename=dagmc_filename,
|
|
517
|
+
implicit_complement_material_tag=implicit_complement_material_tag,
|
|
518
|
+
)
|
|
519
|
+
|
|
520
|
+
return h5m_filename
|
|
460
521
|
|
|
461
522
|
|
|
462
523
|
class CadToDagmc:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: cad_to_dagmc
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.9.0
|
|
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
|
|
@@ -20,6 +20,8 @@ Requires-Dist: gmsh
|
|
|
20
20
|
Provides-Extra: tests
|
|
21
21
|
Requires-Dist: pytest; extra == "tests"
|
|
22
22
|
Requires-Dist: vtk; extra == "tests"
|
|
23
|
+
Requires-Dist: assembly-mesh-plugin; extra == "tests"
|
|
24
|
+
Dynamic: license-file
|
|
23
25
|
|
|
24
26
|
|
|
25
27
|
[](https://www.python.org)
|
|
@@ -43,10 +45,13 @@ cad-to-dagmc can create DAGMC compatible:
|
|
|
43
45
|
|
|
44
46
|
cad-to-dagmc can convert the following in to DAGMC compatible meshes:
|
|
45
47
|
- STEP files
|
|
46
|
-
- CadQuery objects (
|
|
47
|
-
- Gmsh meshes
|
|
48
|
+
- CadQuery objects (optionally use names as material tags)
|
|
49
|
+
- Gmsh meshes (optionally use physical groups as material tags)
|
|
48
50
|
|
|
49
51
|
Cad-to-dagmc offers a wide range of features including.
|
|
52
|
+
- Compatibly with [assembly-mesh-plugin](https://github.com/CadQuery/assembly-mesh-plugin) (see examples)
|
|
53
|
+
- Access to the Gmsh mesh to allow user to define full set of mesh parameters
|
|
54
|
+
- Option to use Gmsh physical groups as material tags
|
|
50
55
|
- Geometry scaling with ```scale_factor``` argument
|
|
51
56
|
- Model wide mesh size parameters with ```min_mesh_size``` and ```max_mesh_size``` arguments
|
|
52
57
|
- Volume specific mesh sizing parameters with the ```set_size``` argument
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
_version.py,sha256=fqtOm8q4HIqAgc-mXbjsKoz34kMK1y3t9LDhc4497WE,511
|
|
2
|
+
cad_to_dagmc/__init__.py,sha256=fskHUTyCunSpnpJUvBfAYjx4uwDKXHTTiMP6GqnFRf0,494
|
|
3
|
+
cad_to_dagmc/core.py,sha256=C3NEy5z4bjbg0SQjodGcZSOVqMAc8g5e0zLoF2gs0Og,34140
|
|
4
|
+
cad_to_dagmc-0.9.0.dist-info/licenses/LICENSE,sha256=B8kznH_777JVNZ3HOKDc4Tj24F7wJ68ledaNYeL9sCw,1070
|
|
5
|
+
cad_to_dagmc-0.9.0.dist-info/METADATA,sha256=J3Q4BXSU_ApF86K8sjDXA_hYT_k5GRRAKXaYc-ksbuw,9092
|
|
6
|
+
cad_to_dagmc-0.9.0.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
|
7
|
+
cad_to_dagmc-0.9.0.dist-info/top_level.txt,sha256=zTi8C64SEBsE5WOtPovnxhOzt-E6Oc5nC3RW6M_5aEA,22
|
|
8
|
+
cad_to_dagmc-0.9.0.dist-info/RECORD,,
|
|
@@ -1,8 +0,0 @@
|
|
|
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,,
|
|
File without changes
|
|
File without changes
|