cad-to-dagmc 0.7.5__tar.gz → 0.7.6__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 (53) hide show
  1. {cad_to_dagmc-0.7.5 → cad_to_dagmc-0.7.6}/PKG-INFO +1 -1
  2. {cad_to_dagmc-0.7.5 → cad_to_dagmc-0.7.6}/src/_version.py +2 -2
  3. {cad_to_dagmc-0.7.5 → cad_to_dagmc-0.7.6}/src/cad_to_dagmc/core.py +39 -7
  4. {cad_to_dagmc-0.7.5 → cad_to_dagmc-0.7.6}/src/cad_to_dagmc.egg-info/PKG-INFO +1 -1
  5. {cad_to_dagmc-0.7.5 → cad_to_dagmc-0.7.6}/tests/test_python_api.py +82 -1
  6. {cad_to_dagmc-0.7.5 → cad_to_dagmc-0.7.6}/.github/workflows/black.yml +0 -0
  7. {cad_to_dagmc-0.7.5 → cad_to_dagmc-0.7.6}/.github/workflows/ci_with_benchmarks.yml +0 -0
  8. {cad_to_dagmc-0.7.5 → cad_to_dagmc-0.7.6}/.github/workflows/ci_with_conda_install.yml +0 -0
  9. {cad_to_dagmc-0.7.5 → cad_to_dagmc-0.7.6}/.github/workflows/ci_with_pip_install.yml +0 -0
  10. {cad_to_dagmc-0.7.5 → cad_to_dagmc-0.7.6}/.github/workflows/python-publish.yml +0 -0
  11. {cad_to_dagmc-0.7.5 → cad_to_dagmc-0.7.6}/.gitignore +0 -0
  12. {cad_to_dagmc-0.7.5 → cad_to_dagmc-0.7.6}/CITATION.cff +0 -0
  13. {cad_to_dagmc-0.7.5 → cad_to_dagmc-0.7.6}/LICENSE +0 -0
  14. {cad_to_dagmc-0.7.5 → cad_to_dagmc-0.7.6}/README.md +0 -0
  15. {cad_to_dagmc-0.7.5 → cad_to_dagmc-0.7.6}/examples/surface_mesh/cadquery_assembly.py +0 -0
  16. {cad_to_dagmc-0.7.5 → cad_to_dagmc-0.7.6}/examples/surface_mesh/cadquery_assembly_with_scaled_geometry.py +0 -0
  17. {cad_to_dagmc-0.7.5 → cad_to_dagmc-0.7.6}/examples/surface_mesh/cadquery_compound.py +0 -0
  18. {cad_to_dagmc-0.7.5 → cad_to_dagmc-0.7.6}/examples/surface_mesh/cadquery_object_and_stp_file.py +0 -0
  19. {cad_to_dagmc-0.7.5 → cad_to_dagmc-0.7.6}/examples/surface_mesh/cadquery_text.py +0 -0
  20. {cad_to_dagmc-0.7.5 → cad_to_dagmc-0.7.6}/examples/surface_mesh/curved_cadquery_object_to_dagmc_surface_mesh.py +0 -0
  21. {cad_to_dagmc-0.7.5 → cad_to_dagmc-0.7.6}/examples/surface_mesh/from_gmsh_mesh_file.py +0 -0
  22. {cad_to_dagmc-0.7.5 → cad_to_dagmc-0.7.6}/examples/surface_mesh/multiple_cadquery_objects.py +0 -0
  23. {cad_to_dagmc-0.7.5 → cad_to_dagmc-0.7.6}/examples/surface_mesh/multiple_stp_files.py +0 -0
  24. {cad_to_dagmc-0.7.5 → cad_to_dagmc-0.7.6}/examples/surface_mesh/single_cadquery_object.py +0 -0
  25. {cad_to_dagmc-0.7.5 → cad_to_dagmc-0.7.6}/examples/surface_mesh/single_stp_file.py +0 -0
  26. {cad_to_dagmc-0.7.5 → cad_to_dagmc-0.7.6}/examples/surface_mesh/single_stp_file_multiple_volumes.py +0 -0
  27. {cad_to_dagmc-0.7.5 → cad_to_dagmc-0.7.6}/examples/unstrucutred_volume_mesh/curved_cadquery_object_to_dagmc_volume_mesh.py +0 -0
  28. {cad_to_dagmc-0.7.5 → cad_to_dagmc-0.7.6}/examples/unstrucutred_volume_mesh/simulate_unstrucutred_volume_mesh_with_openmc.py +0 -0
  29. {cad_to_dagmc-0.7.5 → cad_to_dagmc-0.7.6}/pyproject.toml +0 -0
  30. {cad_to_dagmc-0.7.5 → cad_to_dagmc-0.7.6}/setup.cfg +0 -0
  31. {cad_to_dagmc-0.7.5 → cad_to_dagmc-0.7.6}/src/cad_to_dagmc/__init__.py +0 -0
  32. {cad_to_dagmc-0.7.5 → cad_to_dagmc-0.7.6}/src/cad_to_dagmc.egg-info/SOURCES.txt +0 -0
  33. {cad_to_dagmc-0.7.5 → cad_to_dagmc-0.7.6}/src/cad_to_dagmc.egg-info/dependency_links.txt +0 -0
  34. {cad_to_dagmc-0.7.5 → cad_to_dagmc-0.7.6}/src/cad_to_dagmc.egg-info/requires.txt +0 -0
  35. {cad_to_dagmc-0.7.5 → cad_to_dagmc-0.7.6}/src/cad_to_dagmc.egg-info/top_level.txt +0 -0
  36. {cad_to_dagmc-0.7.5 → cad_to_dagmc-0.7.6}/tests/ENDFB-7.1-NNDC_H1.h5 +0 -0
  37. {cad_to_dagmc-0.7.5 → cad_to_dagmc-0.7.6}/tests/ball_reactor.brep +0 -0
  38. {cad_to_dagmc-0.7.5 → cad_to_dagmc-0.7.6}/tests/curved_extrude.stp +0 -0
  39. {cad_to_dagmc-0.7.5 → cad_to_dagmc-0.7.6}/tests/extrude_rectangle.stp +0 -0
  40. {cad_to_dagmc-0.7.5 → cad_to_dagmc-0.7.6}/tests/multi_volume_cylinders.stp +0 -0
  41. {cad_to_dagmc-0.7.5 → cad_to_dagmc-0.7.6}/tests/one_cube.brep +0 -0
  42. {cad_to_dagmc-0.7.5 → cad_to_dagmc-0.7.6}/tests/single_cube.stp +0 -0
  43. {cad_to_dagmc-0.7.5 → cad_to_dagmc-0.7.6}/tests/single_volume_thin.stp +0 -0
  44. {cad_to_dagmc-0.7.5 → cad_to_dagmc-0.7.6}/tests/single_volume_thin.vtk +0 -0
  45. {cad_to_dagmc-0.7.5 → cad_to_dagmc-0.7.6}/tests/test_brep_file.brep +0 -0
  46. {cad_to_dagmc-0.7.5 → cad_to_dagmc-0.7.6}/tests/test_file_creation.py +0 -0
  47. {cad_to_dagmc-0.7.5 → cad_to_dagmc-0.7.6}/tests/test_h5m_in_transport.py +0 -0
  48. {cad_to_dagmc-0.7.5 → cad_to_dagmc-0.7.6}/tests/test_loading_from_file_vs_shape_object.py +0 -0
  49. {cad_to_dagmc-0.7.5 → cad_to_dagmc-0.7.6}/tests/test_two_joined_cubes.brep +0 -0
  50. {cad_to_dagmc-0.7.5 → cad_to_dagmc-0.7.6}/tests/test_two_sep_cubes.brep +0 -0
  51. {cad_to_dagmc-0.7.5 → cad_to_dagmc-0.7.6}/tests/test_version.py +0 -0
  52. {cad_to_dagmc-0.7.5 → cad_to_dagmc-0.7.6}/tests/two_connected_cubes.stp +0 -0
  53. {cad_to_dagmc-0.7.5 → cad_to_dagmc-0.7.6}/tests/two_disconnected_cubes.stp +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cad_to_dagmc
3
- Version: 0.7.5
3
+ Version: 0.7.6
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
@@ -12,5 +12,5 @@ __version__: str
12
12
  __version_tuple__: VERSION_TUPLE
13
13
  version_tuple: VERSION_TUPLE
14
14
 
15
- __version__ = version = '0.7.5'
16
- __version_tuple__ = version_tuple = (0, 7, 5)
15
+ __version__ = version = '0.7.6'
16
+ __version_tuple__ = version_tuple = (0, 7, 6)
@@ -5,6 +5,7 @@ import numpy as np
5
5
  from cadquery import importers
6
6
  from pymoab import core, types
7
7
  import tempfile
8
+ import warnings
8
9
 
9
10
 
10
11
  def _define_moab_core_and_tags() -> tuple[core.Core, dict]:
@@ -76,6 +77,7 @@ def _vertices_to_h5m(
76
77
  triangles:
77
78
  material_tags:
78
79
  h5m_filename:
80
+ implicit_complement_material_tag:
79
81
  """
80
82
 
81
83
  if len(material_tags) != len(triangles_by_solid_by_face):
@@ -184,7 +186,15 @@ def _vertices_to_h5m(
184
186
 
185
187
  moab_core.add_entities(file_set, all_sets)
186
188
 
187
- moab_core.write_file(h5m_filename)
189
+ # makes the folder if it does not exist
190
+ if Path(h5m_filename).parent:
191
+ Path(h5m_filename).parent.mkdir(parents=True, exist_ok=True)
192
+
193
+ # moab_core.write_file only accepts strings
194
+ if isinstance(h5m_filename, Path):
195
+ moab_core.write_file(str(h5m_filename))
196
+ else:
197
+ moab_core.write_file(h5m_filename)
188
198
 
189
199
  print(f"written DAGMC file {h5m_filename}")
190
200
 
@@ -230,8 +240,7 @@ def _mesh_brep(
230
240
  mesh_algorithm: int = 1,
231
241
  dimensions: int = 2,
232
242
  ):
233
- """Creates a conformal surface meshes of the volumes in a Brep file using
234
- Gmsh.
243
+ """Creates a conformal surface meshes of the volumes in a Brep file using Gmsh.
235
244
 
236
245
  Args:
237
246
  occ_shape: the occ_shape of the Brep file to convert
@@ -339,6 +348,12 @@ def _check_material_tags(material_tags, iterable_solids):
339
348
  if not isinstance(material_tag, str):
340
349
  msg = f"material_tags should be an iterable of strings."
341
350
  raise ValueError(msg)
351
+ if len(material_tag) > 28:
352
+ msg = (
353
+ f"Material tag {material_tag} is too long. DAGMC will truncate this material tag "
354
+ f"to 28 characters. The resulting tag in the h5m file will be {material_tag[:28]}"
355
+ )
356
+ warnings.warn(msg)
342
357
 
343
358
 
344
359
  def order_material_ids_by_brep_order(original_ids, scrambled_id, material_tags):
@@ -357,6 +372,7 @@ class MeshToDagmc:
357
372
 
358
373
  # TODO add export_unstructured_mesh_file
359
374
  # TODO add add_gmsh_msh_file
375
+ # TODO test for exports result in files
360
376
 
361
377
  def export_dagmc_h5m_file(
362
378
  self,
@@ -530,6 +546,8 @@ class CadToDagmc:
530
546
  The gmsh object after finalizing the mesh.
531
547
  """
532
548
 
549
+ # gmesh writes out a vtk file that is accepted by openmc.UnstructuredMesh
550
+ # The library argument must be set to "moab"
533
551
  if Path(filename).suffix != ".vtk":
534
552
  raise ValueError("Unstructured mesh filename must have a .vtk extension")
535
553
 
@@ -554,9 +572,15 @@ class CadToDagmc:
554
572
  dimensions=3,
555
573
  )
556
574
 
557
- # gmesh writes out a vtk file that is accepted by openmc.UnstructuredMesh
558
- # The library argument must be set to "moab"
559
- gmsh.write(filename)
575
+ # makes the folder if it does not exist
576
+ if Path(filename).parent:
577
+ Path(filename).parent.mkdir(parents=True, exist_ok=True)
578
+
579
+ # gmsh.write only accepts strings
580
+ if isinstance(filename, Path):
581
+ gmsh.write(str(filename))
582
+ else:
583
+ gmsh.write(filename)
560
584
 
561
585
  gmsh.finalize()
562
586
 
@@ -621,7 +645,15 @@ class CadToDagmc:
621
645
  dimensions=dimensions,
622
646
  )
623
647
 
624
- gmsh.write(filename)
648
+ # makes the folder if it does not exist
649
+ if Path(filename).parent:
650
+ Path(filename).parent.mkdir(parents=True, exist_ok=True)
651
+
652
+ # gmsh.write only accepts strings
653
+ if isinstance(filename, Path):
654
+ gmsh.write(str(filename))
655
+ else:
656
+ gmsh.write(filename)
625
657
 
626
658
  print(f"written GMSH mesh file {filename}")
627
659
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cad_to_dagmc
3
- Version: 0.7.5
3
+ Version: 0.7.6
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
@@ -1,8 +1,10 @@
1
1
  import os
2
2
  from pathlib import Path
3
+ import pytest
3
4
  import cadquery as cq
4
5
  from cad_to_dagmc import CadToDagmc
5
-
6
+ import warnings
7
+ from cad_to_dagmc.core import _check_material_tags
6
8
 
7
9
  from pathlib import Path
8
10
 
@@ -138,3 +140,82 @@ def test_add_stp_file_returned_volumes():
138
140
  c2d = CadToDagmc()
139
141
  vols = c2d.add_stp_file("tests/two_disconnected_cubes.stp")
140
142
  assert vols == 2
143
+
144
+
145
+ @pytest.mark.parametrize(
146
+ "filename",
147
+ [
148
+ "test_dagmc1.h5m",
149
+ "out_folder1/test_dagmc2.h5m",
150
+ Path("test_dagmc3.h5m"),
151
+ Path("out_folder2/test_dagmc4.h5m"),
152
+ ],
153
+ )
154
+ def test_export_dagmc_h5m_file_handel_paths_folders_strings(filename):
155
+ """Checks that a h5m file is created"""
156
+
157
+ box = cq.Workplane().box(1, 1, 1)
158
+ c2d = CadToDagmc()
159
+ c2d.add_cadquery_object(box, material_tags=["mat1"])
160
+
161
+ c2d.export_dagmc_h5m_file(filename=filename)
162
+
163
+ assert Path(filename).is_file()
164
+
165
+ os.system(f"rm -rf {filename}")
166
+
167
+
168
+ @pytest.mark.parametrize(
169
+ "filename",
170
+ [
171
+ "test_dagmc1.vtk",
172
+ "out_folder3/test_dagmc2.vtk",
173
+ Path("test_dagmc3.vtk"),
174
+ Path("out_folder4/test_dagmc4.vtk"),
175
+ ],
176
+ )
177
+ def test_export_unstructured_mesh_file_handel_paths_folders_strings(filename):
178
+ """Checks that a vtk file is created"""
179
+
180
+ box = cq.Workplane().box(1, 1, 1)
181
+ c2d = CadToDagmc()
182
+ c2d.add_cadquery_object(box, material_tags=["mat1"])
183
+
184
+ c2d.export_unstructured_mesh_file(filename=filename)
185
+
186
+ assert Path(filename).is_file()
187
+
188
+ os.system(f"rm -rf {filename}")
189
+
190
+
191
+ @pytest.mark.parametrize(
192
+ "filename",
193
+ [
194
+ "test_dagmc1.msh",
195
+ "out_folder5/test_dagmc2.msh",
196
+ Path("test_dagmc3.msh"),
197
+ Path("out_folder6/test_dagmc4.msh"),
198
+ ],
199
+ )
200
+ def test_export_gmsh_mesh_file_handel_paths_folders_strings(filename):
201
+ """Checks that a vtk file is created"""
202
+
203
+ box = cq.Workplane().box(1, 1, 1)
204
+ c2d = CadToDagmc()
205
+ c2d.add_cadquery_object(box, material_tags=["mat1"])
206
+
207
+ c2d.export_gmsh_mesh_file(filename=filename)
208
+
209
+ assert Path(filename).is_file()
210
+
211
+ os.system(f"rm -rf {filename}")
212
+
213
+
214
+ def test_check_material_tags_too_long():
215
+ with warnings.catch_warnings(record=True) as w:
216
+ warnings.simplefilter("always")
217
+ _check_material_tags(["a" * 29], [1])
218
+ assert len(w) == 1
219
+ assert issubclass(w[-1].category, UserWarning)
220
+ assert "Material tag" in str(w[-1].message)
221
+ assert "a" * 29 in str(w[-1].message)
File without changes
File without changes
File without changes
File without changes
File without changes