cad-to-dagmc 0.9.4__tar.gz → 0.9.7__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 (64) hide show
  1. {cad_to_dagmc-0.9.4 → cad_to_dagmc-0.9.7}/.github/workflows/ci_with_pip_install.yml +12 -9
  2. {cad_to_dagmc-0.9.4 → cad_to_dagmc-0.9.7}/PKG-INFO +5 -5
  3. {cad_to_dagmc-0.9.4 → cad_to_dagmc-0.9.7}/README.md +4 -4
  4. {cad_to_dagmc-0.9.4 → cad_to_dagmc-0.9.7}/src/_version.py +3 -3
  5. {cad_to_dagmc-0.9.4 → cad_to_dagmc-0.9.7}/src/cad_to_dagmc/core.py +56 -3
  6. {cad_to_dagmc-0.9.4 → cad_to_dagmc-0.9.7}/src/cad_to_dagmc/direct_mesh_plugin.py +2 -0
  7. {cad_to_dagmc-0.9.4 → cad_to_dagmc-0.9.7}/src/cad_to_dagmc.egg-info/PKG-INFO +5 -5
  8. {cad_to_dagmc-0.9.4 → cad_to_dagmc-0.9.7}/tests/test_file_creation.py +3 -1
  9. {cad_to_dagmc-0.9.4 → cad_to_dagmc-0.9.7}/tests/test_get_volumes.py +20 -4
  10. {cad_to_dagmc-0.9.4 → cad_to_dagmc-0.9.7}/tests/test_h5m_in_transport.py +3 -1
  11. {cad_to_dagmc-0.9.4 → cad_to_dagmc-0.9.7}/tests/test_kwarg_args.py +118 -1
  12. {cad_to_dagmc-0.9.4 → cad_to_dagmc-0.9.7}/tests/test_python_api.py +3 -1
  13. {cad_to_dagmc-0.9.4 → cad_to_dagmc-0.9.7}/.github/workflows/black.yml +0 -0
  14. {cad_to_dagmc-0.9.4 → cad_to_dagmc-0.9.7}/.github/workflows/ci_with_benchmarks.yml +0 -0
  15. {cad_to_dagmc-0.9.4 → cad_to_dagmc-0.9.7}/.github/workflows/ci_with_conda_install.yml +0 -0
  16. {cad_to_dagmc-0.9.4 → cad_to_dagmc-0.9.7}/.github/workflows/python-publish.yml +0 -0
  17. {cad_to_dagmc-0.9.4 → cad_to_dagmc-0.9.7}/.gitignore +0 -0
  18. {cad_to_dagmc-0.9.4 → cad_to_dagmc-0.9.7}/CITATION.cff +0 -0
  19. {cad_to_dagmc-0.9.4 → cad_to_dagmc-0.9.7}/LICENSE +0 -0
  20. {cad_to_dagmc-0.9.4 → cad_to_dagmc-0.9.7}/examples/surface_and_unstructured_mesh/unstructured_mesh_with_conformal_surface_mesh.py +0 -0
  21. {cad_to_dagmc-0.9.4 → cad_to_dagmc-0.9.7}/examples/surface_mesh/cadquery_assembly.py +0 -0
  22. {cad_to_dagmc-0.9.4 → cad_to_dagmc-0.9.7}/examples/surface_mesh/cadquery_assembly_with_scaled_geometry.py +0 -0
  23. {cad_to_dagmc-0.9.4 → cad_to_dagmc-0.9.7}/examples/surface_mesh/cadquery_compound.py +0 -0
  24. {cad_to_dagmc-0.9.4 → cad_to_dagmc-0.9.7}/examples/surface_mesh/cadquery_object_and_stp_file.py +0 -0
  25. {cad_to_dagmc-0.9.4 → cad_to_dagmc-0.9.7}/examples/surface_mesh/cadquery_text.py +0 -0
  26. {cad_to_dagmc-0.9.4 → cad_to_dagmc-0.9.7}/examples/surface_mesh/curved_cadquery_object_to_dagmc_surface_mesh.py +0 -0
  27. {cad_to_dagmc-0.9.4 → cad_to_dagmc-0.9.7}/examples/surface_mesh/different_resolution_meshes.py +0 -0
  28. {cad_to_dagmc-0.9.4 → cad_to_dagmc-0.9.7}/examples/surface_mesh/from_gmsh_mesh_file.py +0 -0
  29. {cad_to_dagmc-0.9.4 → cad_to_dagmc-0.9.7}/examples/surface_mesh/from_gmsh_mesh_file_with_tags.py +0 -0
  30. {cad_to_dagmc-0.9.4 → cad_to_dagmc-0.9.7}/examples/surface_mesh/from_gmsh_object_with_tag.py +0 -0
  31. {cad_to_dagmc-0.9.4 → cad_to_dagmc-0.9.7}/examples/surface_mesh/multiple_cadquery_objects.py +0 -0
  32. {cad_to_dagmc-0.9.4 → cad_to_dagmc-0.9.7}/examples/surface_mesh/multiple_stp_files.py +0 -0
  33. {cad_to_dagmc-0.9.4 → cad_to_dagmc-0.9.7}/examples/surface_mesh/single_cadquery_object.py +0 -0
  34. {cad_to_dagmc-0.9.4 → cad_to_dagmc-0.9.7}/examples/surface_mesh/single_stp_file.py +0 -0
  35. {cad_to_dagmc-0.9.4 → cad_to_dagmc-0.9.7}/examples/surface_mesh/single_stp_file_multiple_volumes.py +0 -0
  36. {cad_to_dagmc-0.9.4 → cad_to_dagmc-0.9.7}/examples/surface_mesh/tagged_mesh.msh +0 -0
  37. {cad_to_dagmc-0.9.4 → cad_to_dagmc-0.9.7}/examples/unstrucutred_volume_mesh/curved_cadquery_object_to_dagmc_volume_mesh.py +0 -0
  38. {cad_to_dagmc-0.9.4 → cad_to_dagmc-0.9.7}/examples/unstrucutred_volume_mesh/different_resolution_meshes.py +0 -0
  39. {cad_to_dagmc-0.9.4 → cad_to_dagmc-0.9.7}/examples/unstrucutred_volume_mesh/simulate_unstrucutred_volume_mesh_with_openmc.py +0 -0
  40. {cad_to_dagmc-0.9.4 → cad_to_dagmc-0.9.7}/pyproject.toml +0 -0
  41. {cad_to_dagmc-0.9.4 → cad_to_dagmc-0.9.7}/setup.cfg +0 -0
  42. {cad_to_dagmc-0.9.4 → cad_to_dagmc-0.9.7}/src/cad_to_dagmc/__init__.py +0 -0
  43. {cad_to_dagmc-0.9.4 → cad_to_dagmc-0.9.7}/src/cad_to_dagmc.egg-info/SOURCES.txt +0 -0
  44. {cad_to_dagmc-0.9.4 → cad_to_dagmc-0.9.7}/src/cad_to_dagmc.egg-info/dependency_links.txt +0 -0
  45. {cad_to_dagmc-0.9.4 → cad_to_dagmc-0.9.7}/src/cad_to_dagmc.egg-info/requires.txt +0 -0
  46. {cad_to_dagmc-0.9.4 → cad_to_dagmc-0.9.7}/src/cad_to_dagmc.egg-info/top_level.txt +0 -0
  47. {cad_to_dagmc-0.9.4 → cad_to_dagmc-0.9.7}/tests/ENDFB-7.1-NNDC_H1.h5 +0 -0
  48. {cad_to_dagmc-0.9.4 → cad_to_dagmc-0.9.7}/tests/ball_reactor.brep +0 -0
  49. {cad_to_dagmc-0.9.4 → cad_to_dagmc-0.9.7}/tests/curved_extrude.stp +0 -0
  50. {cad_to_dagmc-0.9.4 → cad_to_dagmc-0.9.7}/tests/extrude_rectangle.stp +0 -0
  51. {cad_to_dagmc-0.9.4 → cad_to_dagmc-0.9.7}/tests/multi_volume_cylinders.stp +0 -0
  52. {cad_to_dagmc-0.9.4 → cad_to_dagmc-0.9.7}/tests/one_cube.brep +0 -0
  53. {cad_to_dagmc-0.9.4 → cad_to_dagmc-0.9.7}/tests/single_cube.stp +0 -0
  54. {cad_to_dagmc-0.9.4 → cad_to_dagmc-0.9.7}/tests/single_volume_thin.stp +0 -0
  55. {cad_to_dagmc-0.9.4 → cad_to_dagmc-0.9.7}/tests/single_volume_thin.vtk +0 -0
  56. {cad_to_dagmc-0.9.4 → cad_to_dagmc-0.9.7}/tests/tagged_mesh.msh +0 -0
  57. {cad_to_dagmc-0.9.4 → cad_to_dagmc-0.9.7}/tests/test_brep_file.brep +0 -0
  58. {cad_to_dagmc-0.9.4 → cad_to_dagmc-0.9.7}/tests/test_loading_from_file_vs_shape_object.py +0 -0
  59. {cad_to_dagmc-0.9.4 → cad_to_dagmc-0.9.7}/tests/test_mesh_to_dagmc.py +0 -0
  60. {cad_to_dagmc-0.9.4 → cad_to_dagmc-0.9.7}/tests/test_two_joined_cubes.brep +0 -0
  61. {cad_to_dagmc-0.9.4 → cad_to_dagmc-0.9.7}/tests/test_two_sep_cubes.brep +0 -0
  62. {cad_to_dagmc-0.9.4 → cad_to_dagmc-0.9.7}/tests/test_version.py +0 -0
  63. {cad_to_dagmc-0.9.4 → cad_to_dagmc-0.9.7}/tests/two_connected_cubes.stp +0 -0
  64. {cad_to_dagmc-0.9.4 → cad_to_dagmc-0.9.7}/tests/two_disconnected_cubes.stp +0 -0
@@ -21,22 +21,25 @@ on:
21
21
  jobs:
22
22
  testing:
23
23
  runs-on: ubuntu-latest
24
- container:
25
- image: openmc/openmc:develop-dagmc
24
+ strategy:
25
+ matrix:
26
+ python-version: [3.12]
26
27
  steps:
28
+ - name: Set up Python ${{ matrix.python-version }}
29
+ uses: actions/setup-python@v5
30
+ with:
31
+ python-version: ${{ matrix.python-version }}
27
32
  - name: Checkout repository
28
33
  uses: actions/checkout@v4
29
34
 
30
35
  - name: install non pypi dependencies
31
36
  shell: bash
32
37
  run: |
33
- apt-get --allow-releaseinfo-change update
34
- apt-get update -y
35
- apt-get upgrade -y
36
- 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
37
- apt install python3
38
- apt install python3-pip
39
- python -m pip install --extra-index-url https://shimwell.github.io/wheels moab
38
+ sudo apt-get update -y
39
+ sudo apt-get upgrade -y
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
+ # Python3 and pip are pre-installed on GitHub Actions runners
42
+ python -m pip install --extra-index-url https://shimwell.github.io/wheels moab openmc
40
43
  python -c "import pymoab"
41
44
  python -m pip install .[tests]
42
45
  python -m pip install git+https://github.com/svalinn/pydagmc
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cad_to_dagmc
3
- Version: 0.9.4
3
+ Version: 0.9.7
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
@@ -50,7 +50,7 @@ cad-to-dagmc can convert the following in to DAGMC compatible meshes:
50
50
 
51
51
  Cad-to-dagmc offers a wide range of features including.
52
52
  - Geometry scaling with ```scale_factor``` argument
53
- - Ddirect surface meshing of CadQuery geometry with ```tolerance``` and ```angular_tolerance``` arguments (avoids using Gmsh)
53
+ - Direct surface meshing of CadQuery geometry with ```tolerance``` and ```angular_tolerance``` arguments (avoids using Gmsh)
54
54
  - Model wide mesh Gmsh size parameters with ```min_mesh_size``` and ```max_mesh_size``` arguments
55
55
  - Volume specific mesh sizing parameters with the ```set_size``` argument
56
56
  - Unstructured mesh that share the same coordinates as the surface mesh.
@@ -73,7 +73,7 @@ Cad-to-dagmc offers a wide range of features including.
73
73
 
74
74
  - Install using Mamba
75
75
  - Install using Conda
76
- - Install using pip and source compilations
76
+ - Install using pip
77
77
 
78
78
  ## Install using Mamba
79
79
 
@@ -151,10 +151,10 @@ You may also want to install OpenMC with DAGMC to make use of the h5m geometry f
151
151
 
152
152
  To install OpenMC you can run ```mamba install -c conda-forge openmc``` however this more specific command makes sure the latest version of OpenMC which contains DAGMC is chosen by conda / mamba
153
153
  ```bash
154
- mamba install -c conda-forge -y "openmc=0.15.0=dagmc*nompi*"
154
+ mamba install -c conda-forge -y "openmc=0.15.2=dagmc*nompi*"
155
155
  ```
156
156
 
157
- It might not be possible to install OpenMC and cad-to-dagmc in the same conda/mamba python environment so you may have to create a new conda/mamba environment and install OpenMC there.
157
+ You could also install using this [wheel repo](https://github.com/shimwell/wheels)
158
158
 
159
159
  Another option would be to [install OpenMC from source](https://docs.openmc.org/en/stable/quickinstall.html) which would also need compiling with MOAB and DAGMC options.
160
160
 
@@ -25,7 +25,7 @@ cad-to-dagmc can convert the following in to DAGMC compatible meshes:
25
25
 
26
26
  Cad-to-dagmc offers a wide range of features including.
27
27
  - Geometry scaling with ```scale_factor``` argument
28
- - Ddirect surface meshing of CadQuery geometry with ```tolerance``` and ```angular_tolerance``` arguments (avoids using Gmsh)
28
+ - Direct surface meshing of CadQuery geometry with ```tolerance``` and ```angular_tolerance``` arguments (avoids using Gmsh)
29
29
  - Model wide mesh Gmsh size parameters with ```min_mesh_size``` and ```max_mesh_size``` arguments
30
30
  - Volume specific mesh sizing parameters with the ```set_size``` argument
31
31
  - Unstructured mesh that share the same coordinates as the surface mesh.
@@ -48,7 +48,7 @@ Cad-to-dagmc offers a wide range of features including.
48
48
 
49
49
  - Install using Mamba
50
50
  - Install using Conda
51
- - Install using pip and source compilations
51
+ - Install using pip
52
52
 
53
53
  ## Install using Mamba
54
54
 
@@ -126,10 +126,10 @@ You may also want to install OpenMC with DAGMC to make use of the h5m geometry f
126
126
 
127
127
  To install OpenMC you can run ```mamba install -c conda-forge openmc``` however this more specific command makes sure the latest version of OpenMC which contains DAGMC is chosen by conda / mamba
128
128
  ```bash
129
- mamba install -c conda-forge -y "openmc=0.15.0=dagmc*nompi*"
129
+ mamba install -c conda-forge -y "openmc=0.15.2=dagmc*nompi*"
130
130
  ```
131
131
 
132
- It might not be possible to install OpenMC and cad-to-dagmc in the same conda/mamba python environment so you may have to create a new conda/mamba environment and install OpenMC there.
132
+ You could also install using this [wheel repo](https://github.com/shimwell/wheels)
133
133
 
134
134
  Another option would be to [install OpenMC from source](https://docs.openmc.org/en/stable/quickinstall.html) which would also need compiling with MOAB and DAGMC options.
135
135
 
@@ -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.4'
32
- __version_tuple__ = version_tuple = (0, 9, 4)
31
+ __version__ = version = '0.9.7'
32
+ __version_tuple__ = version_tuple = (0, 9, 7)
33
33
 
34
- __commit_id__ = commit_id = 'g725750322'
34
+ __commit_id__ = commit_id = 'g7b0ab5bff'
@@ -687,6 +687,7 @@ class CadToDagmc:
687
687
  assembly.add(part)
688
688
 
689
689
  if imprint:
690
+ print("Imprinting assembly for unstructured mesh generation")
690
691
  imprinted_assembly, _ = cq.occ_impl.assembly.imprint(assembly)
691
692
  else:
692
693
  imprinted_assembly = assembly
@@ -777,6 +778,7 @@ class CadToDagmc:
777
778
  assembly.add(part)
778
779
 
779
780
  if imprint:
781
+ print("Imprinting assembly for mesh generation")
780
782
  imprinted_assembly, _ = cq.occ_impl.assembly.imprint(assembly)
781
783
  else:
782
784
  imprinted_assembly = assembly
@@ -812,7 +814,6 @@ class CadToDagmc:
812
814
  def export_dagmc_h5m_file(
813
815
  self,
814
816
  filename: str = "dagmc.h5m",
815
- meshing_backend: str = "cadquery",
816
817
  implicit_complement_material_tag: str | None = None,
817
818
  scale_factor: float = 1.0,
818
819
  imprint: bool = True,
@@ -822,8 +823,6 @@ class CadToDagmc:
822
823
 
823
824
  Args:
824
825
  filename: the filename to use for the saved DAGMC file.
825
- meshing_backend: determines whether gmsh or cadquery's direct mesh method
826
- is used for meshing. Options are 'gmsh' or 'cadquery'.
827
826
  implicit_complement_material_tag: the name of the material tag to use
828
827
  for the implicit complement (void space).
829
828
  scale_factor: a scaling factor to apply to the geometry.
@@ -831,6 +830,11 @@ class CadToDagmc:
831
830
 
832
831
  **kwargs: Backend-specific parameters:
833
832
 
833
+ Backend selection:
834
+ - meshing_backend (str, optional): explicitly specify 'gmsh' or 'cadquery'.
835
+ If not provided, backend is auto-selected based on other arguments.
836
+ Defaults to 'cadquery' if no backend-specific arguments are given.
837
+
834
838
  For GMSH backend:
835
839
  - min_mesh_size (float): minimum mesh element size
836
840
  - max_mesh_size (float): maximum mesh element size
@@ -851,6 +855,52 @@ class CadToDagmc:
851
855
  ValueError: If invalid parameter combinations are used.
852
856
  """
853
857
 
858
+ # Define all acceptable kwargs
859
+ cadquery_keys = {"tolerance", "angular_tolerance"}
860
+ gmsh_keys = {
861
+ "min_mesh_size",
862
+ "max_mesh_size",
863
+ "mesh_algorithm",
864
+ "set_size",
865
+ "umesh_filename",
866
+ "method",
867
+ "unstructured_volumes",
868
+ }
869
+ all_acceptable_keys = cadquery_keys | gmsh_keys | {"meshing_backend"}
870
+
871
+ # Check for invalid kwargs
872
+ invalid_keys = set(kwargs.keys()) - all_acceptable_keys
873
+ if invalid_keys:
874
+ raise ValueError(
875
+ f"Invalid keyword arguments: {sorted(invalid_keys)}\n"
876
+ f"Acceptable arguments are: {sorted(all_acceptable_keys)}"
877
+ )
878
+
879
+ # Handle meshing_backend - either from kwargs or auto-detect
880
+ meshing_backend = kwargs.pop("meshing_backend", None)
881
+
882
+ if meshing_backend is None:
883
+ # Auto-select meshing_backend based on kwargs
884
+ has_cadquery = any(key in kwargs for key in cadquery_keys)
885
+ has_gmsh = any(key in kwargs for key in gmsh_keys)
886
+ if has_cadquery and not has_gmsh:
887
+ meshing_backend = "cadquery"
888
+ elif has_gmsh and not has_cadquery:
889
+ meshing_backend = "gmsh"
890
+ elif has_cadquery and has_gmsh:
891
+ provided_cadquery = [key for key in cadquery_keys if key in kwargs]
892
+ provided_gmsh = [key for key in gmsh_keys if key in kwargs]
893
+ raise ValueError(
894
+ "Ambiguous backend: both CadQuery and GMSH-specific arguments provided.\n"
895
+ f"CadQuery-specific arguments: {sorted(cadquery_keys)}\n"
896
+ f"GMSH-specific arguments: {sorted(gmsh_keys)}\n"
897
+ f"Provided CadQuery arguments: {provided_cadquery}\n"
898
+ f"Provided GMSH arguments: {provided_gmsh}\n"
899
+ "Please provide only one backend's arguments."
900
+ )
901
+ else:
902
+ meshing_backend = "cadquery" # default
903
+
854
904
  # Validate meshing backend
855
905
  if meshing_backend not in ["gmsh", "cadquery"]:
856
906
  raise ValueError(
@@ -858,6 +908,8 @@ class CadToDagmc:
858
908
  'Available options are "gmsh" or "cadquery"'
859
909
  )
860
910
 
911
+ print(f"Using meshing backend: {meshing_backend}")
912
+
861
913
  # Initialize variables to avoid unbound errors
862
914
  tolerance = 0.1
863
915
  angular_tolerance = 0.1
@@ -963,6 +1015,7 @@ class CadToDagmc:
963
1015
  elif meshing_backend == "gmsh":
964
1016
  # If assembly is not to be imprinted, pass through the assembly as-is
965
1017
  if imprint:
1018
+ print("Imprinting assembly for mesh generation")
966
1019
  imprinted_assembly, imprinted_solids_with_org_id = cq.occ_impl.assembly.imprint(
967
1020
  assembly
968
1021
  )
@@ -291,6 +291,7 @@ def to_mesh(
291
291
  # Imprinted assemblies end up being compounds, whereas you have to step through each of the
292
292
  # parts in an assembly and extract the solids.
293
293
  if imprint:
294
+ print("Imprinting assembly for mesh generation")
294
295
  # Imprint the assembly and process it as a compound
295
296
  (
296
297
  imprinted_assembly,
@@ -329,6 +330,7 @@ def to_mesh(
329
330
 
330
331
  # Step through all of the collected solids and their respective faces to get the vertices
331
332
  for solid in solids:
333
+ print(f"Meshing solid {solid_idx} of {len(solids)}")
332
334
  # Reset this each time so that we get the correct number of faces per solid
333
335
  face_triangles = {}
334
336
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cad_to_dagmc
3
- Version: 0.9.4
3
+ Version: 0.9.7
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
@@ -50,7 +50,7 @@ cad-to-dagmc can convert the following in to DAGMC compatible meshes:
50
50
 
51
51
  Cad-to-dagmc offers a wide range of features including.
52
52
  - Geometry scaling with ```scale_factor``` argument
53
- - Ddirect surface meshing of CadQuery geometry with ```tolerance``` and ```angular_tolerance``` arguments (avoids using Gmsh)
53
+ - Direct surface meshing of CadQuery geometry with ```tolerance``` and ```angular_tolerance``` arguments (avoids using Gmsh)
54
54
  - Model wide mesh Gmsh size parameters with ```min_mesh_size``` and ```max_mesh_size``` arguments
55
55
  - Volume specific mesh sizing parameters with the ```set_size``` argument
56
56
  - Unstructured mesh that share the same coordinates as the surface mesh.
@@ -73,7 +73,7 @@ Cad-to-dagmc offers a wide range of features including.
73
73
 
74
74
  - Install using Mamba
75
75
  - Install using Conda
76
- - Install using pip and source compilations
76
+ - Install using pip
77
77
 
78
78
  ## Install using Mamba
79
79
 
@@ -151,10 +151,10 @@ You may also want to install OpenMC with DAGMC to make use of the h5m geometry f
151
151
 
152
152
  To install OpenMC you can run ```mamba install -c conda-forge openmc``` however this more specific command makes sure the latest version of OpenMC which contains DAGMC is chosen by conda / mamba
153
153
  ```bash
154
- mamba install -c conda-forge -y "openmc=0.15.0=dagmc*nompi*"
154
+ mamba install -c conda-forge -y "openmc=0.15.2=dagmc*nompi*"
155
155
  ```
156
156
 
157
- It might not be possible to install OpenMC and cad-to-dagmc in the same conda/mamba python environment so you may have to create a new conda/mamba environment and install OpenMC there.
157
+ You could also install using this [wheel repo](https://github.com/shimwell/wheels)
158
158
 
159
159
  Another option would be to [install OpenMC from source](https://docs.openmc.org/en/stable/quickinstall.html) which would also need compiling with MOAB and DAGMC options.
160
160
 
@@ -133,7 +133,9 @@ def test_h5m_with_multi_volume_touching(meshing_backend):
133
133
  assert get_volumes_and_materials_from_h5m(h5m_file) == tags_dict
134
134
 
135
135
  cad_to_dagmc.export_gmsh_file_to_dagmc_h5m_file(
136
- dagmc_filename=h5m_file, material_tags=mat_tags, gmsh_filename=h5m_file + ".msh"
136
+ dagmc_filename=h5m_file,
137
+ material_tags=mat_tags,
138
+ gmsh_filename=h5m_file + ".msh",
137
139
  )
138
140
  assert get_volumes_and_materials_from_h5m(h5m_file) == tags_dict
139
141
 
@@ -9,8 +9,14 @@ import cad_to_dagmc
9
9
  "scale_factor, expected_bbox",
10
10
  [
11
11
  (1.0, (-5.0000001, -5.0000001, -5.0000001, 5.0000001, 5.0000001, 5.0000001)),
12
- (2.0, (-10.0000001, -10.0000001, -10.0000001, 10.0000001, 10.0000001, 10.0000001)),
13
- (10.0, (-50.0000001, -50.0000001, -50.0000001, 50.0000001, 50.0000001, 50.0000001)),
12
+ (
13
+ 2.0,
14
+ (-10.0000001, -10.0000001, -10.0000001, 10.0000001, 10.0000001, 10.0000001),
15
+ ),
16
+ (
17
+ 10.0,
18
+ (-50.0000001, -50.0000001, -50.0000001, 50.0000001, 50.0000001, 50.0000001),
19
+ ),
14
20
  ],
15
21
  )
16
22
  def test_get_volumes(scale_factor, expected_bbox):
@@ -35,8 +41,18 @@ def test_get_volumes(scale_factor, expected_bbox):
35
41
  @pytest.mark.parametrize(
36
42
  "scale_factor, expected_bbox_lower_left, expected_bbox_upper_right, meshing_backend",
37
43
  [
38
- (1.0, (-5.0000001, -5.0000001, -5.0000001), (5.0000001, 5.0000001, 5.0000001), "cadquery"),
39
- (1.0, (-5.0000001, -5.0000001, -5.0000001), (5.0000001, 5.0000001, 5.0000001), "gmsh"),
44
+ (
45
+ 1.0,
46
+ (-5.0000001, -5.0000001, -5.0000001),
47
+ (5.0000001, 5.0000001, 5.0000001),
48
+ "cadquery",
49
+ ),
50
+ (
51
+ 1.0,
52
+ (-5.0000001, -5.0000001, -5.0000001),
53
+ (5.0000001, 5.0000001, 5.0000001),
54
+ "gmsh",
55
+ ),
40
56
  (
41
57
  2.0,
42
58
  (-10.0000001, -10.0000001, -10.0000001),
@@ -288,7 +288,9 @@ def test_umesh_with_volumes(meshing_backend):
288
288
  model.add_cadquery_object(assembly, material_tags=mat_tags)
289
289
 
290
290
  h5m_file = model.export_dagmc_h5m_file(
291
- filename="dagmc.h5m", set_size={1: 0.9, 2: 0.1, 3: 0.9}, meshing_backend=meshing_backend
291
+ filename="dagmc.h5m",
292
+ set_size={1: 0.9, 2: 0.1, 3: 0.9},
293
+ meshing_backend=meshing_backend,
292
294
  )
293
295
 
294
296
  vtk_file = model.export_unstructured_mesh_file(
@@ -54,7 +54,9 @@ class TestKwargsExportDagmcH5mFile:
54
54
 
55
55
  with pytest.raises(ValueError, match="CadQuery backend cannot be used for volume meshing"):
56
56
  self.my_model.export_dagmc_h5m_file(
57
- filename=str(output_file), meshing_backend="cadquery", unstructured_volumes=[1]
57
+ filename=str(output_file),
58
+ meshing_backend="cadquery",
59
+ unstructured_volumes=[1],
58
60
  )
59
61
 
60
62
  def test_invalid_meshing_backend_raises_error(self, tmp_path):
@@ -187,6 +189,121 @@ class TestKwargsExportDagmcH5mFile:
187
189
  assert output_file_gmsh.exists()
188
190
 
189
191
 
192
+ class TestKwargsValidation:
193
+ """Test kwargs validation for export_dagmc_h5m_file method"""
194
+
195
+ def setup_method(self):
196
+ """Setup method to create a simple geometry for testing"""
197
+ self.my_model = CadToDagmc()
198
+
199
+ # Create a simple box
200
+ box = cq.Workplane("XY").box(10, 10, 10)
201
+ self.my_model.add_cadquery_object(box, material_tags=["steel"])
202
+
203
+ def test_invalid_kwargs_raises_error(self, tmp_path):
204
+ """Test that invalid kwargs raise ValueError with helpful message"""
205
+ output_file = tmp_path / "test_invalid_kwargs.h5m"
206
+
207
+ with pytest.raises(ValueError) as excinfo:
208
+ self.my_model.export_dagmc_h5m_file(
209
+ filename=str(output_file),
210
+ invalid_param=123,
211
+ another_invalid=True,
212
+ )
213
+
214
+ error_message = str(excinfo.value)
215
+ assert "Invalid keyword arguments:" in error_message
216
+ assert "another_invalid" in error_message
217
+ assert "invalid_param" in error_message
218
+ assert "Acceptable arguments are:" in error_message
219
+
220
+ def test_mixed_valid_invalid_kwargs_raises_error(self, tmp_path):
221
+ """Test that mix of valid and invalid kwargs raises error"""
222
+ output_file = tmp_path / "test_mixed_kwargs.h5m"
223
+
224
+ with pytest.raises(ValueError) as excinfo:
225
+ self.my_model.export_dagmc_h5m_file(
226
+ filename=str(output_file),
227
+ tolerance=0.1, # valid
228
+ bad_param=456, # invalid
229
+ min_mesh_size=0.5, # valid
230
+ )
231
+
232
+ error_message = str(excinfo.value)
233
+ assert "Invalid keyword arguments:" in error_message
234
+ assert "bad_param" in error_message
235
+ assert "tolerance" in error_message # valid param should be in error
236
+ assert "min_mesh_size" in error_message # valid param should be in error
237
+
238
+ def test_all_valid_cadquery_kwargs_accepted(self, tmp_path):
239
+ """Test that all valid CadQuery kwargs are accepted"""
240
+ output_file = tmp_path / "test_valid_cq_kwargs.h5m"
241
+
242
+ # Should not raise any error
243
+ result = self.my_model.export_dagmc_h5m_file(
244
+ filename=str(output_file),
245
+ meshing_backend="cadquery",
246
+ tolerance=0.1,
247
+ angular_tolerance=0.2,
248
+ )
249
+
250
+ assert result == str(output_file)
251
+ assert output_file.exists()
252
+
253
+ def test_all_valid_gmsh_kwargs_accepted(self, tmp_path):
254
+ """Test that all valid GMSH kwargs are accepted"""
255
+ output_file = tmp_path / "test_valid_gmsh_kwargs.h5m"
256
+
257
+ # Should not raise any error
258
+ result = self.my_model.export_dagmc_h5m_file(
259
+ filename=str(output_file),
260
+ meshing_backend="gmsh",
261
+ min_mesh_size=0.1,
262
+ max_mesh_size=1.0,
263
+ mesh_algorithm=1,
264
+ set_size={1: 0.5},
265
+ umesh_filename="test.vtk",
266
+ method="file",
267
+ # unstructured_volumes would be tested separately
268
+ )
269
+
270
+ assert result == str(output_file)
271
+ assert output_file.exists()
272
+
273
+ def test_typo_in_kwarg_name_raises_helpful_error(self, tmp_path):
274
+ """Test that typos in parameter names give helpful error messages"""
275
+ output_file = tmp_path / "test_typo.h5m"
276
+
277
+ # Common typo: "tolerance" -> "tollerance"
278
+ with pytest.raises(ValueError) as excinfo:
279
+ self.my_model.export_dagmc_h5m_file(
280
+ filename=str(output_file),
281
+ tollerance=0.1, # typo
282
+ )
283
+
284
+ error_message = str(excinfo.value)
285
+ assert "Invalid keyword arguments:" in error_message
286
+ assert "tollerance" in error_message
287
+ assert "tolerance" in error_message # should show the correct options
288
+
289
+ def test_case_sensitivity_in_kwargs(self, tmp_path):
290
+ """Test that kwargs are case sensitive"""
291
+ output_file = tmp_path / "test_case_sensitive.h5m"
292
+
293
+ # Wrong case should raise error
294
+ with pytest.raises(ValueError) as excinfo:
295
+ self.my_model.export_dagmc_h5m_file(
296
+ filename=str(output_file),
297
+ Tolerance=0.1, # wrong case
298
+ MESHING_BACKEND="cadquery", # wrong case
299
+ )
300
+
301
+ error_message = str(excinfo.value)
302
+ assert "Invalid keyword arguments:" in error_message
303
+ assert "Tolerance" in error_message
304
+ assert "MESHING_BACKEND" in error_message
305
+
306
+
190
307
  class TestKwargsWithMultipleVolumes:
191
308
  """Test kwargs functionality with multiple volumes"""
192
309
 
@@ -400,7 +400,9 @@ def test_unstructured_mesh_with_volumes(meshing_backend):
400
400
  model.add_cadquery_object(assembly, material_tags=["mat1", "mat2", "mat3"])
401
401
 
402
402
  filename = model.export_dagmc_h5m_file(
403
- filename="dagmc.h5m", set_size={1: 0.9, 2: 0.1, 3: 0.9}, meshing_backend=meshing_backend
403
+ filename="dagmc.h5m",
404
+ set_size={1: 0.9, 2: 0.1, 3: 0.9},
405
+ meshing_backend=meshing_backend,
404
406
  )
405
407
  assert Path(filename).is_file()
406
408
 
File without changes
File without changes
File without changes
File without changes