cad-to-dagmc 0.9.1__tar.gz → 0.9.2__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.

Files changed (62) hide show
  1. {cad_to_dagmc-0.9.1 → cad_to_dagmc-0.9.2}/.github/workflows/ci_with_conda_install.yml +1 -0
  2. {cad_to_dagmc-0.9.1 → cad_to_dagmc-0.9.2}/.github/workflows/ci_with_pip_install.yml +2 -1
  3. {cad_to_dagmc-0.9.1 → cad_to_dagmc-0.9.2}/PKG-INFO +3 -2
  4. {cad_to_dagmc-0.9.1 → cad_to_dagmc-0.9.2}/README.md +2 -1
  5. {cad_to_dagmc-0.9.1 → cad_to_dagmc-0.9.2}/examples/surface_and_unstructured_mesh/unstructured_mesh_with_conformal_surface_mesh.py +13 -16
  6. {cad_to_dagmc-0.9.1 → cad_to_dagmc-0.9.2}/src/_version.py +2 -2
  7. {cad_to_dagmc-0.9.1 → cad_to_dagmc-0.9.2}/src/cad_to_dagmc/core.py +33 -8
  8. {cad_to_dagmc-0.9.1 → cad_to_dagmc-0.9.2}/src/cad_to_dagmc.egg-info/PKG-INFO +3 -2
  9. {cad_to_dagmc-0.9.1 → cad_to_dagmc-0.9.2}/tests/test_python_api.py +33 -0
  10. {cad_to_dagmc-0.9.1 → cad_to_dagmc-0.9.2}/.github/workflows/black.yml +0 -0
  11. {cad_to_dagmc-0.9.1 → cad_to_dagmc-0.9.2}/.github/workflows/ci_with_benchmarks.yml +0 -0
  12. {cad_to_dagmc-0.9.1 → cad_to_dagmc-0.9.2}/.github/workflows/python-publish.yml +0 -0
  13. {cad_to_dagmc-0.9.1 → cad_to_dagmc-0.9.2}/.gitignore +0 -0
  14. {cad_to_dagmc-0.9.1 → cad_to_dagmc-0.9.2}/CITATION.cff +0 -0
  15. {cad_to_dagmc-0.9.1 → cad_to_dagmc-0.9.2}/LICENSE +0 -0
  16. {cad_to_dagmc-0.9.1 → cad_to_dagmc-0.9.2}/examples/surface_mesh/cadquery_assembly.py +0 -0
  17. {cad_to_dagmc-0.9.1 → cad_to_dagmc-0.9.2}/examples/surface_mesh/cadquery_assembly_with_scaled_geometry.py +0 -0
  18. {cad_to_dagmc-0.9.1 → cad_to_dagmc-0.9.2}/examples/surface_mesh/cadquery_compound.py +0 -0
  19. {cad_to_dagmc-0.9.1 → cad_to_dagmc-0.9.2}/examples/surface_mesh/cadquery_object_and_stp_file.py +0 -0
  20. {cad_to_dagmc-0.9.1 → cad_to_dagmc-0.9.2}/examples/surface_mesh/cadquery_text.py +0 -0
  21. {cad_to_dagmc-0.9.1 → cad_to_dagmc-0.9.2}/examples/surface_mesh/curved_cadquery_object_to_dagmc_surface_mesh.py +0 -0
  22. {cad_to_dagmc-0.9.1 → cad_to_dagmc-0.9.2}/examples/surface_mesh/different_resolution_meshes.py +0 -0
  23. {cad_to_dagmc-0.9.1 → cad_to_dagmc-0.9.2}/examples/surface_mesh/from_gmsh_mesh_file.py +0 -0
  24. {cad_to_dagmc-0.9.1 → cad_to_dagmc-0.9.2}/examples/surface_mesh/from_gmsh_mesh_file_with_tags.py +0 -0
  25. {cad_to_dagmc-0.9.1 → cad_to_dagmc-0.9.2}/examples/surface_mesh/from_gmsh_object_with_tag.py +0 -0
  26. {cad_to_dagmc-0.9.1 → cad_to_dagmc-0.9.2}/examples/surface_mesh/multiple_cadquery_objects.py +0 -0
  27. {cad_to_dagmc-0.9.1 → cad_to_dagmc-0.9.2}/examples/surface_mesh/multiple_stp_files.py +0 -0
  28. {cad_to_dagmc-0.9.1 → cad_to_dagmc-0.9.2}/examples/surface_mesh/single_cadquery_object.py +0 -0
  29. {cad_to_dagmc-0.9.1 → cad_to_dagmc-0.9.2}/examples/surface_mesh/single_stp_file.py +0 -0
  30. {cad_to_dagmc-0.9.1 → cad_to_dagmc-0.9.2}/examples/surface_mesh/single_stp_file_multiple_volumes.py +0 -0
  31. {cad_to_dagmc-0.9.1 → cad_to_dagmc-0.9.2}/examples/surface_mesh/tagged_mesh.msh +0 -0
  32. {cad_to_dagmc-0.9.1 → cad_to_dagmc-0.9.2}/examples/unstrucutred_volume_mesh/curved_cadquery_object_to_dagmc_volume_mesh.py +0 -0
  33. {cad_to_dagmc-0.9.1 → cad_to_dagmc-0.9.2}/examples/unstrucutred_volume_mesh/different_resolution_meshes.py +0 -0
  34. {cad_to_dagmc-0.9.1 → cad_to_dagmc-0.9.2}/examples/unstrucutred_volume_mesh/simulate_unstrucutred_volume_mesh_with_openmc.py +0 -0
  35. {cad_to_dagmc-0.9.1 → cad_to_dagmc-0.9.2}/pyproject.toml +0 -0
  36. {cad_to_dagmc-0.9.1 → cad_to_dagmc-0.9.2}/setup.cfg +0 -0
  37. {cad_to_dagmc-0.9.1 → cad_to_dagmc-0.9.2}/src/cad_to_dagmc/__init__.py +0 -0
  38. {cad_to_dagmc-0.9.1 → cad_to_dagmc-0.9.2}/src/cad_to_dagmc.egg-info/SOURCES.txt +0 -0
  39. {cad_to_dagmc-0.9.1 → cad_to_dagmc-0.9.2}/src/cad_to_dagmc.egg-info/dependency_links.txt +0 -0
  40. {cad_to_dagmc-0.9.1 → cad_to_dagmc-0.9.2}/src/cad_to_dagmc.egg-info/requires.txt +0 -0
  41. {cad_to_dagmc-0.9.1 → cad_to_dagmc-0.9.2}/src/cad_to_dagmc.egg-info/top_level.txt +0 -0
  42. {cad_to_dagmc-0.9.1 → cad_to_dagmc-0.9.2}/tests/ENDFB-7.1-NNDC_H1.h5 +0 -0
  43. {cad_to_dagmc-0.9.1 → cad_to_dagmc-0.9.2}/tests/ball_reactor.brep +0 -0
  44. {cad_to_dagmc-0.9.1 → cad_to_dagmc-0.9.2}/tests/curved_extrude.stp +0 -0
  45. {cad_to_dagmc-0.9.1 → cad_to_dagmc-0.9.2}/tests/extrude_rectangle.stp +0 -0
  46. {cad_to_dagmc-0.9.1 → cad_to_dagmc-0.9.2}/tests/multi_volume_cylinders.stp +0 -0
  47. {cad_to_dagmc-0.9.1 → cad_to_dagmc-0.9.2}/tests/one_cube.brep +0 -0
  48. {cad_to_dagmc-0.9.1 → cad_to_dagmc-0.9.2}/tests/single_cube.stp +0 -0
  49. {cad_to_dagmc-0.9.1 → cad_to_dagmc-0.9.2}/tests/single_volume_thin.stp +0 -0
  50. {cad_to_dagmc-0.9.1 → cad_to_dagmc-0.9.2}/tests/single_volume_thin.vtk +0 -0
  51. {cad_to_dagmc-0.9.1 → cad_to_dagmc-0.9.2}/tests/tagged_mesh.msh +0 -0
  52. {cad_to_dagmc-0.9.1 → cad_to_dagmc-0.9.2}/tests/test_brep_file.brep +0 -0
  53. {cad_to_dagmc-0.9.1 → cad_to_dagmc-0.9.2}/tests/test_file_creation.py +0 -0
  54. {cad_to_dagmc-0.9.1 → cad_to_dagmc-0.9.2}/tests/test_get_volumes.py +0 -0
  55. {cad_to_dagmc-0.9.1 → cad_to_dagmc-0.9.2}/tests/test_h5m_in_transport.py +0 -0
  56. {cad_to_dagmc-0.9.1 → cad_to_dagmc-0.9.2}/tests/test_loading_from_file_vs_shape_object.py +0 -0
  57. {cad_to_dagmc-0.9.1 → cad_to_dagmc-0.9.2}/tests/test_mesh_to_dagmc.py +0 -0
  58. {cad_to_dagmc-0.9.1 → cad_to_dagmc-0.9.2}/tests/test_two_joined_cubes.brep +0 -0
  59. {cad_to_dagmc-0.9.1 → cad_to_dagmc-0.9.2}/tests/test_two_sep_cubes.brep +0 -0
  60. {cad_to_dagmc-0.9.1 → cad_to_dagmc-0.9.2}/tests/test_version.py +0 -0
  61. {cad_to_dagmc-0.9.1 → cad_to_dagmc-0.9.2}/tests/two_connected_cubes.stp +0 -0
  62. {cad_to_dagmc-0.9.1 → cad_to_dagmc-0.9.2}/tests/two_disconnected_cubes.stp +0 -0
@@ -87,3 +87,4 @@ jobs:
87
87
  python examples/unstrucutred_volume_mesh/different_resolution_meshes.py
88
88
  python examples/surface_mesh/different_resolution_meshes.py
89
89
  python examples/surface_mesh/cadquery_assembly_with_scaled_geometry.py
90
+ python examples/surface_and_unstructured_mesh/unstructured_mesh_with_conformal_surface_mesh.py
@@ -63,4 +63,5 @@ jobs:
63
63
  python examples/unstrucutred_volume_mesh/simulate_unstrucutred_volume_mesh_with_openmc.py
64
64
  python examples/unstrucutred_volume_mesh/different_resolution_meshes.py
65
65
  python examples/surface_mesh/different_resolution_meshes.py
66
- python examples/surface_mesh/cadquery_assembly_with_scaled_geometry.py
66
+ python examples/surface_mesh/cadquery_assembly_with_scaled_geometry.py
67
+ 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.1
3
+ Version: 0.9.2
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
@@ -55,7 +55,8 @@ Cad-to-dagmc offers a wide range of features including.
55
55
  - Geometry scaling with ```scale_factor``` argument
56
56
  - Model wide mesh size parameters with ```min_mesh_size``` and ```max_mesh_size``` arguments
57
57
  - Volume specific mesh sizing parameters with the ```set_size``` argument
58
- - Volume mesh selected volumes in the geometry (helps ensure conformal volume and surface mesh).
58
+ - Unstructured mesh that share the same coordinates as the surface mesh.
59
+ - Volume mesh allows selecting individual volumes in the geometry.
59
60
  - Parallel meshing to quickly mesh the geometry using multiple CPU cores
60
61
  - Imprint and merging of CAD geometry, or disable with the ```imprint``` argument
61
62
  - Add geometry from multiple sources ([STEP](http://www.steptools.com/stds/step/) files, [CadQuery](https://cadquery.readthedocs.io) objects and [Gmsh](https://gmsh.info/) meshes)
@@ -30,7 +30,8 @@ Cad-to-dagmc offers a wide range of features including.
30
30
  - Geometry scaling with ```scale_factor``` argument
31
31
  - Model wide mesh size parameters with ```min_mesh_size``` and ```max_mesh_size``` arguments
32
32
  - Volume specific mesh sizing parameters with the ```set_size``` argument
33
- - Volume mesh selected volumes in the geometry (helps ensure conformal volume and surface mesh).
33
+ - Unstructured mesh that share the same coordinates as the surface mesh.
34
+ - Volume mesh allows selecting individual volumes in the geometry.
34
35
  - Parallel meshing to quickly mesh the geometry using multiple CPU cores
35
36
  - Imprint and merging of CAD geometry, or disable with the ```imprint``` argument
36
37
  - Add geometry from multiple sources ([STEP](http://www.steptools.com/stds/step/) files, [CadQuery](https://cadquery.readthedocs.io) objects and [Gmsh](https://gmsh.info/) meshes)
@@ -5,9 +5,10 @@
5
5
  # mesh as the same mesh parameters were used in both the surface and volume mesh.
6
6
  # Additionally only volume 2 is volume meshed, while all three volumes are surface meshed
7
7
 
8
-
9
8
  import cadquery as cq
10
9
  from cad_to_dagmc import CadToDagmc
10
+ import openmc
11
+
11
12
 
12
13
  box_cutter = cq.Workplane("XY").moveTo(0, 5).box(20, 10, 20)
13
14
  inner_sphere = cq.Workplane("XY").sphere(6).cut(box_cutter)
@@ -23,20 +24,17 @@ assembly.add(outer_sphere, name="outer_sphere")
23
24
  model = CadToDagmc()
24
25
  model.add_cadquery_object(assembly, material_tags=["mat1", "mat2", "mat3"])
25
26
 
26
-
27
- h5m_file = model.export_dagmc_h5m_file(
28
- filename="different_resolution_meshes.h5m",
29
- set_size={1: 0.9, 2: 0.1, 3: 0.9},
27
+ dagmc_filename, umesh_filename = model.export_dagmc_h5m_file(
28
+ filename="surface_mesh_conformal.h5m",
29
+ set_size={
30
+ 1: 0.9,
31
+ 2: 0.1,
32
+ 3: 0.9,
33
+ },
34
+ unstructured_volumes=[2],
35
+ umesh_filename="volume_mesh_conformal.vtk", #
30
36
  )
31
37
 
32
- vtk_file = model.export_unstructured_mesh_file(
33
- filename="umesh.vtk",
34
- set_size={1: 0.9, 2: 0.1, 3: 0.9},
35
- volumes=[2], # only mesh volume 2 out of the three volumes
36
- )
37
-
38
-
39
- import openmc
40
38
 
41
39
  with open("cross_sections.xml", "w") as file:
42
40
  file.write(
@@ -49,7 +47,7 @@ with open("cross_sections.xml", "w") as file:
49
47
  )
50
48
  openmc.config["cross_sections"] = "cross_sections.xml"
51
49
 
52
- umesh = openmc.UnstructuredMesh(vtk_file, library="moab")
50
+ umesh = openmc.UnstructuredMesh(umesh_filename, library="moab")
53
51
  mesh_filter = openmc.MeshFilter(umesh)
54
52
  tally = openmc.Tally(name="unstructured_mesh_tally")
55
53
  tally.filters = [mesh_filter]
@@ -68,11 +66,10 @@ mat3.add_nuclide("H1", 1, percent_type="ao")
68
66
  mat3.set_density("g/cm3", 0.003)
69
67
  my_materials = openmc.Materials([mat1, mat2, mat3])
70
68
 
71
- dag_univ = openmc.DAGMCUniverse(filename=h5m_file)
69
+ dag_univ = openmc.DAGMCUniverse(filename=dagmc_filename)
72
70
  bound_dag_univ = dag_univ.bounded_universe()
73
71
  my_geometry = openmc.Geometry(root=bound_dag_univ)
74
72
 
75
-
76
73
  my_settings = openmc.Settings()
77
74
  my_settings.batches = 10
78
75
  my_settings.particles = 5000
@@ -17,5 +17,5 @@ __version__: str
17
17
  __version_tuple__: VERSION_TUPLE
18
18
  version_tuple: VERSION_TUPLE
19
19
 
20
- __version__ = version = '0.9.1'
21
- __version_tuple__ = version_tuple = (0, 9, 1)
20
+ __version__ = version = '0.9.2'
21
+ __version_tuple__ = version_tuple = (0, 9, 2)
@@ -7,6 +7,7 @@ from cadquery import importers
7
7
  from pymoab import core, types
8
8
  import tempfile
9
9
  import warnings
10
+ from typing import Iterable
10
11
  from cad_to_dagmc import __version__
11
12
 
12
13
 
@@ -818,6 +819,8 @@ class CadToDagmc:
818
819
  scale_factor: float = 1.0,
819
820
  imprint: bool = True,
820
821
  set_size: dict[int, float] | None = None,
822
+ unstructured_volumes: Iterable[int] | None = None,
823
+ umesh_filename: str = "umesh.vtk",
821
824
  ) -> str:
822
825
  """Saves a DAGMC h5m file of the geometry
823
826
 
@@ -846,9 +849,13 @@ class CadToDagmc:
846
849
  and this can save time.
847
850
  set_size: a dictionary of volume ids (int) and target mesh sizes
848
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.
849
856
 
850
857
  Returns:
851
- str: the DAGMC filename saved
858
+ str: the filenames(s) for the files created.
852
859
  """
853
860
 
854
861
  assembly = cq.Assembly()
@@ -895,19 +902,37 @@ class CadToDagmc:
895
902
 
896
903
  gmsh.model.mesh.generate(2)
897
904
 
898
- dims_and_vol_ids = volumes
899
-
900
905
  vertices, triangles_by_solid_by_face = mesh_to_vertices_and_triangles(
901
- dims_and_vol_ids=dims_and_vol_ids
906
+ dims_and_vol_ids=volumes
902
907
  )
903
908
 
904
- gmsh.finalize()
905
-
906
- # checks and fixes triangle fix_normals within vertices_to_h5m
907
- return vertices_to_h5m(
909
+ dagmc_filename = vertices_to_h5m(
908
910
  vertices=vertices,
909
911
  triangles_by_solid_by_face=triangles_by_solid_by_face,
910
912
  material_tags=material_tags_in_brep_order,
911
913
  h5m_filename=filename,
912
914
  implicit_complement_material_tag=implicit_complement_material_tag,
913
915
  )
916
+
917
+ if unstructured_volumes:
918
+ # remove all the unused occ volumes, this prevents them being meshed
919
+ for volume_dim, volume_id in volumes:
920
+ if volume_id not in unstructured_volumes:
921
+ gmsh.model.occ.remove([(volume_dim, volume_id)], recursive=True)
922
+ gmsh.option.setNumber("Mesh.SaveAll", 1)
923
+ gmsh.model.occ.synchronize()
924
+
925
+ # removes all the 2D groups so that 2D faces are not included in the vtk file
926
+ all_2d_groups = gmsh.model.getPhysicalGroups(2)
927
+ for entry in all_2d_groups:
928
+ gmsh.model.removePhysicalGroups([entry])
929
+
930
+ gmsh.model.mesh.generate(3)
931
+ gmsh.option.setNumber("Mesh.SaveElementTagType", 3) # Save only volume elements
932
+ gmsh.write(umesh_filename)
933
+
934
+ gmsh.finalize()
935
+
936
+ return dagmc_filename, umesh_filename
937
+ else:
938
+ return dagmc_filename
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cad_to_dagmc
3
- Version: 0.9.1
3
+ Version: 0.9.2
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
@@ -55,7 +55,8 @@ Cad-to-dagmc offers a wide range of features including.
55
55
  - Geometry scaling with ```scale_factor``` argument
56
56
  - Model wide mesh size parameters with ```min_mesh_size``` and ```max_mesh_size``` arguments
57
57
  - Volume specific mesh sizing parameters with the ```set_size``` argument
58
- - Volume mesh selected volumes in the geometry (helps ensure conformal volume and surface mesh).
58
+ - Unstructured mesh that share the same coordinates as the surface mesh.
59
+ - Volume mesh allows selecting individual volumes in the geometry.
59
60
  - Parallel meshing to quickly mesh the geometry using multiple CPU cores
60
61
  - Imprint and merging of CAD geometry, or disable with the ```imprint``` argument
61
62
  - Add geometry from multiple sources ([STEP](http://www.steptools.com/stds/step/) files, [CadQuery](https://cadquery.readthedocs.io) objects and [Gmsh](https://gmsh.info/) meshes)
@@ -335,6 +335,39 @@ def test_two_box_scaling_factor_when_adding_cq_object(
335
335
  assert width_z == expected_z_width
336
336
 
337
337
 
338
+ def test_unstructured_mesh_export_with_surface_mesh():
339
+
340
+ box_set_size_course_mesh = cq.Workplane().box(1, 1, 2)
341
+ box_set_size_fine_mesh = cq.Workplane().moveTo(1, 0.5).box(1, 1, 1.5)
342
+ box_set_global_mesh = cq.Workplane().moveTo(2, 1).box(1, 1, 1)
343
+
344
+ assembly = cq.Assembly()
345
+ assembly.add(box_set_size_course_mesh, color=cq.Color(0, 0, 1))
346
+ assembly.add(box_set_size_fine_mesh, color=cq.Color(0, 1, 0))
347
+ assembly.add(box_set_global_mesh, color=cq.Color(1, 0, 0))
348
+
349
+ model = CadToDagmc()
350
+ model.add_cadquery_object(assembly, material_tags=["mat1", "mat2", "mat3"])
351
+
352
+ dag_filename, umesh_filename = model.export_dagmc_h5m_file(
353
+ filename="conformal-surface-mesh2.h5m",
354
+ min_mesh_size=0.01,
355
+ max_mesh_size=10,
356
+ set_size={
357
+ 1: 0.5,
358
+ 2: 0.4,
359
+ 3: 0.4,
360
+ },
361
+ unstructured_volumes=[2],
362
+ umesh_filename="conformal-volume-mesh2.vtk",
363
+ )
364
+ assert Path("conformal-surface-mesh2.h5m").is_file()
365
+ assert Path("conformal-volume-mesh2.vtk").is_file()
366
+ assert Path(dag_filename).is_file()
367
+ assert Path(umesh_filename).is_file()
368
+ # TODO check the volume mesh outer surface is the same as the surface mesh volume 2 surface
369
+
370
+
338
371
  def test_unstructured_mesh_with_volumes():
339
372
 
340
373
  box_cutter = cq.Workplane("XY").moveTo(0, 5).box(20, 10, 20)
File without changes
File without changes
File without changes
File without changes