cad-to-dagmc 0.9.8__tar.gz → 0.9.9__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.
Files changed (66) hide show
  1. {cad_to_dagmc-0.9.8 → cad_to_dagmc-0.9.9}/.github/workflows/ci_with_conda_install.yml +1 -2
  2. {cad_to_dagmc-0.9.8 → cad_to_dagmc-0.9.9}/.github/workflows/ci_with_pip_install.yml +4 -2
  3. {cad_to_dagmc-0.9.8 → cad_to_dagmc-0.9.9}/PKG-INFO +1 -1
  4. cad_to_dagmc-0.9.9/examples/surface_mesh/cadquery_assembly_with_materials.py +20 -0
  5. {cad_to_dagmc-0.9.8 → cad_to_dagmc-0.9.9}/src/_version.py +3 -3
  6. {cad_to_dagmc-0.9.8 → cad_to_dagmc-0.9.9}/src/cad_to_dagmc/core.py +23 -5
  7. {cad_to_dagmc-0.9.8 → cad_to_dagmc-0.9.9}/src/cad_to_dagmc.egg-info/PKG-INFO +1 -1
  8. {cad_to_dagmc-0.9.8 → cad_to_dagmc-0.9.9}/src/cad_to_dagmc.egg-info/SOURCES.txt +2 -0
  9. cad_to_dagmc-0.9.9/tests/test_assembly_with_materials.py +52 -0
  10. {cad_to_dagmc-0.9.8 → cad_to_dagmc-0.9.9}/.github/workflows/black.yml +0 -0
  11. {cad_to_dagmc-0.9.8 → cad_to_dagmc-0.9.9}/.github/workflows/ci_with_benchmarks.yml +0 -0
  12. {cad_to_dagmc-0.9.8 → cad_to_dagmc-0.9.9}/.github/workflows/python-publish.yml +0 -0
  13. {cad_to_dagmc-0.9.8 → cad_to_dagmc-0.9.9}/.gitignore +0 -0
  14. {cad_to_dagmc-0.9.8 → cad_to_dagmc-0.9.9}/CITATION.cff +0 -0
  15. {cad_to_dagmc-0.9.8 → cad_to_dagmc-0.9.9}/LICENSE +0 -0
  16. {cad_to_dagmc-0.9.8 → cad_to_dagmc-0.9.9}/README.md +0 -0
  17. {cad_to_dagmc-0.9.8 → cad_to_dagmc-0.9.9}/examples/surface_and_unstructured_mesh/unstructured_mesh_with_conformal_surface_mesh.py +0 -0
  18. {cad_to_dagmc-0.9.8 → cad_to_dagmc-0.9.9}/examples/surface_mesh/cadquery_assembly.py +0 -0
  19. {cad_to_dagmc-0.9.8 → cad_to_dagmc-0.9.9}/examples/surface_mesh/cadquery_assembly_with_scaled_geometry.py +0 -0
  20. {cad_to_dagmc-0.9.8 → cad_to_dagmc-0.9.9}/examples/surface_mesh/cadquery_compound.py +0 -0
  21. {cad_to_dagmc-0.9.8 → cad_to_dagmc-0.9.9}/examples/surface_mesh/cadquery_object_and_stp_file.py +0 -0
  22. {cad_to_dagmc-0.9.8 → cad_to_dagmc-0.9.9}/examples/surface_mesh/cadquery_text.py +0 -0
  23. {cad_to_dagmc-0.9.8 → cad_to_dagmc-0.9.9}/examples/surface_mesh/curved_cadquery_object_to_dagmc_surface_mesh.py +0 -0
  24. {cad_to_dagmc-0.9.8 → cad_to_dagmc-0.9.9}/examples/surface_mesh/different_resolution_meshes.py +0 -0
  25. {cad_to_dagmc-0.9.8 → cad_to_dagmc-0.9.9}/examples/surface_mesh/from_gmsh_mesh_file.py +0 -0
  26. {cad_to_dagmc-0.9.8 → cad_to_dagmc-0.9.9}/examples/surface_mesh/from_gmsh_mesh_file_with_tags.py +0 -0
  27. {cad_to_dagmc-0.9.8 → cad_to_dagmc-0.9.9}/examples/surface_mesh/from_gmsh_object_with_tag.py +0 -0
  28. {cad_to_dagmc-0.9.8 → cad_to_dagmc-0.9.9}/examples/surface_mesh/multiple_cadquery_objects.py +0 -0
  29. {cad_to_dagmc-0.9.8 → cad_to_dagmc-0.9.9}/examples/surface_mesh/multiple_stp_files.py +0 -0
  30. {cad_to_dagmc-0.9.8 → cad_to_dagmc-0.9.9}/examples/surface_mesh/single_cadquery_object.py +0 -0
  31. {cad_to_dagmc-0.9.8 → cad_to_dagmc-0.9.9}/examples/surface_mesh/single_stp_file.py +0 -0
  32. {cad_to_dagmc-0.9.8 → cad_to_dagmc-0.9.9}/examples/surface_mesh/single_stp_file_multiple_volumes.py +0 -0
  33. {cad_to_dagmc-0.9.8 → cad_to_dagmc-0.9.9}/examples/surface_mesh/tagged_mesh.msh +0 -0
  34. {cad_to_dagmc-0.9.8 → cad_to_dagmc-0.9.9}/examples/unstrucutred_volume_mesh/curved_cadquery_object_to_dagmc_volume_mesh.py +0 -0
  35. {cad_to_dagmc-0.9.8 → cad_to_dagmc-0.9.9}/examples/unstrucutred_volume_mesh/different_resolution_meshes.py +0 -0
  36. {cad_to_dagmc-0.9.8 → cad_to_dagmc-0.9.9}/examples/unstrucutred_volume_mesh/simulate_unstrucutred_volume_mesh_with_openmc.py +0 -0
  37. {cad_to_dagmc-0.9.8 → cad_to_dagmc-0.9.9}/pyproject.toml +0 -0
  38. {cad_to_dagmc-0.9.8 → cad_to_dagmc-0.9.9}/setup.cfg +0 -0
  39. {cad_to_dagmc-0.9.8 → cad_to_dagmc-0.9.9}/src/cad_to_dagmc/__init__.py +0 -0
  40. {cad_to_dagmc-0.9.8 → cad_to_dagmc-0.9.9}/src/cad_to_dagmc/direct_mesh_plugin.py +0 -0
  41. {cad_to_dagmc-0.9.8 → cad_to_dagmc-0.9.9}/src/cad_to_dagmc.egg-info/dependency_links.txt +0 -0
  42. {cad_to_dagmc-0.9.8 → cad_to_dagmc-0.9.9}/src/cad_to_dagmc.egg-info/requires.txt +0 -0
  43. {cad_to_dagmc-0.9.8 → cad_to_dagmc-0.9.9}/src/cad_to_dagmc.egg-info/top_level.txt +0 -0
  44. {cad_to_dagmc-0.9.8 → cad_to_dagmc-0.9.9}/tests/ENDFB-7.1-NNDC_H1.h5 +0 -0
  45. {cad_to_dagmc-0.9.8 → cad_to_dagmc-0.9.9}/tests/ball_reactor.brep +0 -0
  46. {cad_to_dagmc-0.9.8 → cad_to_dagmc-0.9.9}/tests/curved_extrude.stp +0 -0
  47. {cad_to_dagmc-0.9.8 → cad_to_dagmc-0.9.9}/tests/extrude_rectangle.stp +0 -0
  48. {cad_to_dagmc-0.9.8 → cad_to_dagmc-0.9.9}/tests/multi_volume_cylinders.stp +0 -0
  49. {cad_to_dagmc-0.9.8 → cad_to_dagmc-0.9.9}/tests/one_cube.brep +0 -0
  50. {cad_to_dagmc-0.9.8 → cad_to_dagmc-0.9.9}/tests/single_cube.stp +0 -0
  51. {cad_to_dagmc-0.9.8 → cad_to_dagmc-0.9.9}/tests/single_volume_thin.stp +0 -0
  52. {cad_to_dagmc-0.9.8 → cad_to_dagmc-0.9.9}/tests/single_volume_thin.vtk +0 -0
  53. {cad_to_dagmc-0.9.8 → cad_to_dagmc-0.9.9}/tests/tagged_mesh.msh +0 -0
  54. {cad_to_dagmc-0.9.8 → cad_to_dagmc-0.9.9}/tests/test_brep_file.brep +0 -0
  55. {cad_to_dagmc-0.9.8 → cad_to_dagmc-0.9.9}/tests/test_file_creation.py +0 -0
  56. {cad_to_dagmc-0.9.8 → cad_to_dagmc-0.9.9}/tests/test_get_volumes.py +0 -0
  57. {cad_to_dagmc-0.9.8 → cad_to_dagmc-0.9.9}/tests/test_h5m_in_transport.py +0 -0
  58. {cad_to_dagmc-0.9.8 → cad_to_dagmc-0.9.9}/tests/test_kwarg_args.py +0 -0
  59. {cad_to_dagmc-0.9.8 → cad_to_dagmc-0.9.9}/tests/test_loading_from_file_vs_shape_object.py +0 -0
  60. {cad_to_dagmc-0.9.8 → cad_to_dagmc-0.9.9}/tests/test_mesh_to_dagmc.py +0 -0
  61. {cad_to_dagmc-0.9.8 → cad_to_dagmc-0.9.9}/tests/test_python_api.py +0 -0
  62. {cad_to_dagmc-0.9.8 → cad_to_dagmc-0.9.9}/tests/test_two_joined_cubes.brep +0 -0
  63. {cad_to_dagmc-0.9.8 → cad_to_dagmc-0.9.9}/tests/test_two_sep_cubes.brep +0 -0
  64. {cad_to_dagmc-0.9.8 → cad_to_dagmc-0.9.9}/tests/test_version.py +0 -0
  65. {cad_to_dagmc-0.9.8 → cad_to_dagmc-0.9.9}/tests/two_connected_cubes.stp +0 -0
  66. {cad_to_dagmc-0.9.8 → cad_to_dagmc-0.9.9}/tests/two_disconnected_cubes.stp +0 -0
@@ -74,6 +74,7 @@ jobs:
74
74
  python examples/surface_mesh/cadquery_object_and_stp_file.py
75
75
  python examples/surface_mesh/cadquery_text.py
76
76
  python examples/surface_mesh/curved_cadquery_object_to_dagmc_surface_mesh.py
77
+ python examples/surface_mesh/different_resolution_meshes.py
77
78
  python examples/surface_mesh/from_gmsh_mesh_file.py
78
79
  python examples/surface_mesh/from_gmsh_mesh_file_with_tags.py
79
80
  python examples/surface_mesh/from_gmsh_object_with_tag.py
@@ -85,6 +86,4 @@ jobs:
85
86
  python examples/unstrucutred_volume_mesh/curved_cadquery_object_to_dagmc_volume_mesh.py
86
87
  python examples/unstrucutred_volume_mesh/simulate_unstrucutred_volume_mesh_with_openmc.py
87
88
  python examples/unstrucutred_volume_mesh/different_resolution_meshes.py
88
- python examples/surface_mesh/different_resolution_meshes.py
89
- python examples/surface_mesh/cadquery_assembly_with_scaled_geometry.py
90
89
  python examples/surface_and_unstructured_mesh/unstructured_mesh_with_conformal_surface_mesh.py
@@ -40,17 +40,21 @@ jobs:
40
40
  sudo apt-get install -y libblas-dev liblapack-dev libgl1 libglx-mesa0 libgl1-mesa-dev libglu1-mesa-dev freeglut3-dev libosmesa6 libosmesa6-dev libgles2-mesa-dev libarchive-dev libpangocairo-1.0-0 libxcursor-dev libxft2 libxinerama-dev make cmake libeigen3-dev
41
41
  # Python3 and pip are pre-installed on GitHub Actions runners
42
42
  python -m pip install --extra-index-url https://shimwell.github.io/wheels moab openmc
43
+ # install the latest cadquery master branch as it has PR https://github.com/CadQuery/cadquery/pull/1923 merged in
44
+ python -m pip install git+https://github.com/CadQuery/cadquery
43
45
  python -c "import pymoab"
44
46
  python -m pip install .[tests]
45
47
  python -m pip install git+https://github.com/svalinn/pydagmc
46
48
  python -c "import cad_to_dagmc"
47
49
  pytest -v tests
48
50
  python examples/surface_mesh/cadquery_assembly.py
51
+ python examples/surface_mesh/cadquery_assembly_with_materials.py
49
52
  python examples/surface_mesh/cadquery_assembly_with_scaled_geometry.py
50
53
  python examples/surface_mesh/cadquery_compound.py
51
54
  python examples/surface_mesh/cadquery_object_and_stp_file.py
52
55
  python examples/surface_mesh/cadquery_text.py
53
56
  python examples/surface_mesh/curved_cadquery_object_to_dagmc_surface_mesh.py
57
+ python examples/surface_mesh/different_resolution_meshes.py
54
58
  python examples/surface_mesh/from_gmsh_mesh_file.py
55
59
  python examples/surface_mesh/from_gmsh_mesh_file_with_tags.py
56
60
  python examples/surface_mesh/from_gmsh_object_with_tag.py
@@ -62,6 +66,4 @@ jobs:
62
66
  python examples/unstrucutred_volume_mesh/curved_cadquery_object_to_dagmc_volume_mesh.py
63
67
  python examples/unstrucutred_volume_mesh/simulate_unstrucutred_volume_mesh_with_openmc.py
64
68
  python examples/unstrucutred_volume_mesh/different_resolution_meshes.py
65
- python examples/surface_mesh/different_resolution_meshes.py
66
- python examples/surface_mesh/cadquery_assembly_with_scaled_geometry.py
67
69
  python examples/surface_and_unstructured_mesh/unstructured_mesh_with_conformal_surface_mesh.py
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cad_to_dagmc
3
- Version: 0.9.8
3
+ Version: 0.9.9
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
@@ -0,0 +1,20 @@
1
+ # This example makes a CadQuery assembly and assigns materials to the parts
2
+ # These part materials are then used when exporting to a DAGMC H5M file
3
+ # This avoids needing to specify material tags separately when adding the CadQuery object
4
+
5
+
6
+ import cadquery as cq
7
+ from cad_to_dagmc import CadToDagmc
8
+
9
+ result = cq.Workplane().sphere(5)
10
+ result2 = cq.Workplane().moveTo(10, 0).sphere(2)
11
+
12
+ assembly = cq.Assembly()
13
+ assembly.add(result, name="result", material=cq.Material("mat1")) # note material assigned here
14
+ assembly.add(result2, name="result2", material=cq.Material("mat2")) # note material assigned here
15
+
16
+ my_model = CadToDagmc()
17
+ my_model.add_cadquery_object(
18
+ cadquery_object=assembly
19
+ ) # note that material tags are not needed here
20
+ my_model.export_dagmc_h5m_file(min_mesh_size=0.5, max_mesh_size=1.0e6)
@@ -28,7 +28,7 @@ version_tuple: VERSION_TUPLE
28
28
  commit_id: COMMIT_ID
29
29
  __commit_id__: COMMIT_ID
30
30
 
31
- __version__ = version = '0.9.8'
32
- __version_tuple__ = version_tuple = (0, 9, 8)
31
+ __version__ = version = '0.9.9'
32
+ __version_tuple__ = version_tuple = (0, 9, 9)
33
33
 
34
- __commit_id__ = commit_id = 'g00e5e76df'
34
+ __commit_id__ = commit_id = 'g72b88f255'
@@ -590,7 +590,7 @@ class CadToDagmc:
590
590
  cadquery_object: (
591
591
  cq.assembly.Assembly | cq.occ_impl.shapes.Compound | cq.occ_impl.shapes.Solid
592
592
  ),
593
- material_tags: list[str] | None,
593
+ material_tags: list[str] | None = None,
594
594
  scale_factor: float = 1.0,
595
595
  ) -> int:
596
596
  """Loads the parts from CadQuery object into the model.
@@ -613,18 +613,36 @@ class CadToDagmc:
613
613
  """
614
614
 
615
615
  if isinstance(cadquery_object, cq.assembly.Assembly):
616
- cadquery_object = cadquery_object.toCompound()
616
+ # look for materials in each part of the assembly
617
+ if material_tags is None:
618
+ material_tags = []
619
+ for child in cadquery_object.children:
620
+ if child.material is not None and child.material.name is not None:
621
+ material_tags.append(child.material.name)
622
+ else:
623
+ raise ValueError(
624
+ f"Not all parts in the assembly have material tags assigned. "
625
+ f"Missing material tag for child: {child}. "
626
+ "Please assign material tags to all parts or provide material_tags argument when adding the assembly."
627
+ )
628
+
629
+ cadquery_compound = cadquery_object.toCompound()
630
+ else:
631
+ cadquery_compound = cadquery_object
617
632
 
618
- if isinstance(cadquery_object, (cq.occ_impl.shapes.Compound, cq.occ_impl.shapes.Solid)):
619
- iterable_solids = cadquery_object.Solids()
633
+ if isinstance(cadquery_compound, (cq.occ_impl.shapes.Compound, cq.occ_impl.shapes.Solid)):
634
+ iterable_solids = cadquery_compound.Solids()
620
635
  else:
621
- iterable_solids = cadquery_object.val().Solids()
636
+ iterable_solids = cadquery_compound.val().Solids()
622
637
 
623
638
  if scale_factor == 1.0:
624
639
  scaled_iterable_solids = iterable_solids
625
640
  else:
626
641
  scaled_iterable_solids = [part.scale(scale_factor) for part in iterable_solids]
627
642
 
643
+ # look for materials in the
644
+ # if material_tags is None:
645
+
628
646
  check_material_tags(material_tags, scaled_iterable_solids)
629
647
  if material_tags:
630
648
  self.material_tags = self.material_tags + material_tags
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cad_to_dagmc
3
- Version: 0.9.8
3
+ Version: 0.9.9
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
@@ -10,6 +10,7 @@ pyproject.toml
10
10
  .github/workflows/python-publish.yml
11
11
  examples/surface_and_unstructured_mesh/unstructured_mesh_with_conformal_surface_mesh.py
12
12
  examples/surface_mesh/cadquery_assembly.py
13
+ examples/surface_mesh/cadquery_assembly_with_materials.py
13
14
  examples/surface_mesh/cadquery_assembly_with_scaled_geometry.py
14
15
  examples/surface_mesh/cadquery_compound.py
15
16
  examples/surface_mesh/cadquery_object_and_stp_file.py
@@ -47,6 +48,7 @@ tests/single_cube.stp
47
48
  tests/single_volume_thin.stp
48
49
  tests/single_volume_thin.vtk
49
50
  tests/tagged_mesh.msh
51
+ tests/test_assembly_with_materials.py
50
52
  tests/test_brep_file.brep
51
53
  tests/test_file_creation.py
52
54
  tests/test_get_volumes.py
@@ -0,0 +1,52 @@
1
+ import tempfile
2
+ import cadquery as cq
3
+ from cad_to_dagmc import CadToDagmc
4
+ from pathlib import Path
5
+ import pytest
6
+ from test_python_api import get_volumes_and_materials_from_h5m
7
+
8
+
9
+ def test_cadquery_assembly_with_materials():
10
+
11
+ with tempfile.TemporaryDirectory() as tmpdir:
12
+
13
+ result = cq.Workplane().sphere(5)
14
+ result2 = cq.Workplane().moveTo(10, 0).sphere(2)
15
+
16
+ assembly = cq.Assembly()
17
+ assembly.add(
18
+ result, name="result", material=cq.Material("diamond")
19
+ ) # note material assigned here
20
+ assembly.add(
21
+ result2, name="result2", material=cq.Material("gold")
22
+ ) # note material assigned here
23
+
24
+ my_model = CadToDagmc()
25
+ my_model.add_cadquery_object(
26
+ cadquery_object=assembly
27
+ ) # note that material tags are not needed here
28
+ test_h5m_filename = my_model.export_dagmc_h5m_file(min_mesh_size=0.5, max_mesh_size=1.0e6)
29
+
30
+ assert Path(test_h5m_filename).is_file()
31
+
32
+ assert get_volumes_and_materials_from_h5m(test_h5m_filename) == {
33
+ 1: "mat:diamond",
34
+ 2: "mat:gold",
35
+ }
36
+
37
+
38
+ def test_assembly_missing_material_tag_raises():
39
+ # Create two parts, only one with a material
40
+ result = cq.Workplane().sphere(5)
41
+ result2 = cq.Workplane().moveTo(10, 0).sphere(2)
42
+
43
+ assembly = cq.Assembly()
44
+ assembly.add(result, name="result", material=cq.Material("diamond"))
45
+ assembly.add(result2, name="result2") # No material assigned
46
+
47
+ my_model = CadToDagmc()
48
+ # Should raise ValueError when adding the assembly
49
+ with pytest.raises(ValueError) as excinfo:
50
+ my_model.add_cadquery_object(cadquery_object=assembly)
51
+ # Check error message is informative
52
+ assert "material tags" in str(excinfo.value)
File without changes
File without changes
File without changes
File without changes
File without changes