cad-to-dagmc 0.8.0__tar.gz → 0.8.1__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.
- {cad_to_dagmc-0.8.0 → cad_to_dagmc-0.8.1}/PKG-INFO +1 -1
- {cad_to_dagmc-0.8.0 → cad_to_dagmc-0.8.1}/src/_version.py +2 -2
- {cad_to_dagmc-0.8.0 → cad_to_dagmc-0.8.1}/src/cad_to_dagmc/core.py +13 -3
- {cad_to_dagmc-0.8.0 → cad_to_dagmc-0.8.1}/src/cad_to_dagmc.egg-info/PKG-INFO +1 -1
- {cad_to_dagmc-0.8.0 → cad_to_dagmc-0.8.1}/tests/test_python_api.py +120 -6
- {cad_to_dagmc-0.8.0 → cad_to_dagmc-0.8.1}/.github/workflows/black.yml +0 -0
- {cad_to_dagmc-0.8.0 → cad_to_dagmc-0.8.1}/.github/workflows/ci_with_benchmarks.yml +0 -0
- {cad_to_dagmc-0.8.0 → cad_to_dagmc-0.8.1}/.github/workflows/ci_with_conda_install.yml +0 -0
- {cad_to_dagmc-0.8.0 → cad_to_dagmc-0.8.1}/.github/workflows/ci_with_pip_install.yml +0 -0
- {cad_to_dagmc-0.8.0 → cad_to_dagmc-0.8.1}/.github/workflows/python-publish.yml +0 -0
- {cad_to_dagmc-0.8.0 → cad_to_dagmc-0.8.1}/.gitignore +0 -0
- {cad_to_dagmc-0.8.0 → cad_to_dagmc-0.8.1}/CITATION.cff +0 -0
- {cad_to_dagmc-0.8.0 → cad_to_dagmc-0.8.1}/LICENSE +0 -0
- {cad_to_dagmc-0.8.0 → cad_to_dagmc-0.8.1}/README.md +0 -0
- {cad_to_dagmc-0.8.0 → cad_to_dagmc-0.8.1}/examples/surface_mesh/cadquery_assembly.py +0 -0
- {cad_to_dagmc-0.8.0 → cad_to_dagmc-0.8.1}/examples/surface_mesh/cadquery_assembly_with_scaled_geometry.py +0 -0
- {cad_to_dagmc-0.8.0 → cad_to_dagmc-0.8.1}/examples/surface_mesh/cadquery_compound.py +0 -0
- {cad_to_dagmc-0.8.0 → cad_to_dagmc-0.8.1}/examples/surface_mesh/cadquery_object_and_stp_file.py +0 -0
- {cad_to_dagmc-0.8.0 → cad_to_dagmc-0.8.1}/examples/surface_mesh/cadquery_text.py +0 -0
- {cad_to_dagmc-0.8.0 → cad_to_dagmc-0.8.1}/examples/surface_mesh/curved_cadquery_object_to_dagmc_surface_mesh.py +0 -0
- {cad_to_dagmc-0.8.0 → cad_to_dagmc-0.8.1}/examples/surface_mesh/different_resolution_meshes.py +0 -0
- {cad_to_dagmc-0.8.0 → cad_to_dagmc-0.8.1}/examples/surface_mesh/from_gmsh_mesh_file.py +0 -0
- {cad_to_dagmc-0.8.0 → cad_to_dagmc-0.8.1}/examples/surface_mesh/multiple_cadquery_objects.py +0 -0
- {cad_to_dagmc-0.8.0 → cad_to_dagmc-0.8.1}/examples/surface_mesh/multiple_stp_files.py +0 -0
- {cad_to_dagmc-0.8.0 → cad_to_dagmc-0.8.1}/examples/surface_mesh/single_cadquery_object.py +0 -0
- {cad_to_dagmc-0.8.0 → cad_to_dagmc-0.8.1}/examples/surface_mesh/single_stp_file.py +0 -0
- {cad_to_dagmc-0.8.0 → cad_to_dagmc-0.8.1}/examples/surface_mesh/single_stp_file_multiple_volumes.py +0 -0
- {cad_to_dagmc-0.8.0 → cad_to_dagmc-0.8.1}/examples/unstrucutred_volume_mesh/curved_cadquery_object_to_dagmc_volume_mesh.py +0 -0
- {cad_to_dagmc-0.8.0 → cad_to_dagmc-0.8.1}/examples/unstrucutred_volume_mesh/different_resolution_meshes.py +0 -0
- {cad_to_dagmc-0.8.0 → cad_to_dagmc-0.8.1}/examples/unstrucutred_volume_mesh/simulate_unstrucutred_volume_mesh_with_openmc.py +0 -0
- {cad_to_dagmc-0.8.0 → cad_to_dagmc-0.8.1}/pyproject.toml +0 -0
- {cad_to_dagmc-0.8.0 → cad_to_dagmc-0.8.1}/setup.cfg +0 -0
- {cad_to_dagmc-0.8.0 → cad_to_dagmc-0.8.1}/src/cad_to_dagmc/__init__.py +0 -0
- {cad_to_dagmc-0.8.0 → cad_to_dagmc-0.8.1}/src/cad_to_dagmc.egg-info/SOURCES.txt +0 -0
- {cad_to_dagmc-0.8.0 → cad_to_dagmc-0.8.1}/src/cad_to_dagmc.egg-info/dependency_links.txt +0 -0
- {cad_to_dagmc-0.8.0 → cad_to_dagmc-0.8.1}/src/cad_to_dagmc.egg-info/requires.txt +0 -0
- {cad_to_dagmc-0.8.0 → cad_to_dagmc-0.8.1}/src/cad_to_dagmc.egg-info/top_level.txt +0 -0
- {cad_to_dagmc-0.8.0 → cad_to_dagmc-0.8.1}/tests/ENDFB-7.1-NNDC_H1.h5 +0 -0
- {cad_to_dagmc-0.8.0 → cad_to_dagmc-0.8.1}/tests/ball_reactor.brep +0 -0
- {cad_to_dagmc-0.8.0 → cad_to_dagmc-0.8.1}/tests/curved_extrude.stp +0 -0
- {cad_to_dagmc-0.8.0 → cad_to_dagmc-0.8.1}/tests/extrude_rectangle.stp +0 -0
- {cad_to_dagmc-0.8.0 → cad_to_dagmc-0.8.1}/tests/multi_volume_cylinders.stp +0 -0
- {cad_to_dagmc-0.8.0 → cad_to_dagmc-0.8.1}/tests/one_cube.brep +0 -0
- {cad_to_dagmc-0.8.0 → cad_to_dagmc-0.8.1}/tests/single_cube.stp +0 -0
- {cad_to_dagmc-0.8.0 → cad_to_dagmc-0.8.1}/tests/single_volume_thin.stp +0 -0
- {cad_to_dagmc-0.8.0 → cad_to_dagmc-0.8.1}/tests/single_volume_thin.vtk +0 -0
- {cad_to_dagmc-0.8.0 → cad_to_dagmc-0.8.1}/tests/test_brep_file.brep +0 -0
- {cad_to_dagmc-0.8.0 → cad_to_dagmc-0.8.1}/tests/test_file_creation.py +0 -0
- {cad_to_dagmc-0.8.0 → cad_to_dagmc-0.8.1}/tests/test_h5m_in_transport.py +0 -0
- {cad_to_dagmc-0.8.0 → cad_to_dagmc-0.8.1}/tests/test_loading_from_file_vs_shape_object.py +0 -0
- {cad_to_dagmc-0.8.0 → cad_to_dagmc-0.8.1}/tests/test_two_joined_cubes.brep +0 -0
- {cad_to_dagmc-0.8.0 → cad_to_dagmc-0.8.1}/tests/test_two_sep_cubes.brep +0 -0
- {cad_to_dagmc-0.8.0 → cad_to_dagmc-0.8.1}/tests/test_version.py +0 -0
- {cad_to_dagmc-0.8.0 → cad_to_dagmc-0.8.1}/tests/two_connected_cubes.stp +0 -0
- {cad_to_dagmc-0.8.0 → cad_to_dagmc-0.8.1}/tests/two_disconnected_cubes.stp +0 -0
|
@@ -503,6 +503,7 @@ class CadToDagmc:
|
|
|
503
503
|
cq.assembly.Assembly | cq.occ_impl.shapes.Compound | cq.occ_impl.shapes.Solid
|
|
504
504
|
),
|
|
505
505
|
material_tags: list[str] | None,
|
|
506
|
+
scale_factor: float = 1.0,
|
|
506
507
|
) -> int:
|
|
507
508
|
"""Loads the parts from CadQuery object into the model.
|
|
508
509
|
|
|
@@ -514,6 +515,10 @@ class CadToDagmc:
|
|
|
514
515
|
same order as the volumes in the geometry added (STP file and
|
|
515
516
|
CadQuery objects) and match the material tags used in the
|
|
516
517
|
neutronics code (e.g. OpenMC).
|
|
518
|
+
scale_factor: a scaling factor to apply to the geometry that can be
|
|
519
|
+
used to increase the size or decrease the size of the geometry.
|
|
520
|
+
Useful when converting the geometry to cm for use in neutronics
|
|
521
|
+
simulations.
|
|
517
522
|
|
|
518
523
|
Returns:
|
|
519
524
|
int: number of volumes in the stp file.
|
|
@@ -527,12 +532,17 @@ class CadToDagmc:
|
|
|
527
532
|
else:
|
|
528
533
|
iterable_solids = cadquery_object.val().Solids()
|
|
529
534
|
|
|
530
|
-
|
|
535
|
+
if scale_factor == 1.0:
|
|
536
|
+
scaled_iterable_solids = iterable_solids
|
|
537
|
+
else:
|
|
538
|
+
scaled_iterable_solids = [part.scale(scale_factor) for part in iterable_solids]
|
|
539
|
+
|
|
540
|
+
_check_material_tags(material_tags, scaled_iterable_solids)
|
|
531
541
|
if material_tags:
|
|
532
542
|
self.material_tags = self.material_tags + material_tags
|
|
533
|
-
self.parts = self.parts +
|
|
543
|
+
self.parts = self.parts + scaled_iterable_solids
|
|
534
544
|
|
|
535
|
-
return len(
|
|
545
|
+
return len(scaled_iterable_solids)
|
|
536
546
|
|
|
537
547
|
def export_unstructured_mesh_file(
|
|
538
548
|
self,
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import os
|
|
2
|
-
from pathlib import Path
|
|
3
|
-
import pytest
|
|
4
|
-
import cadquery as cq
|
|
5
|
-
from cad_to_dagmc import CadToDagmc
|
|
6
2
|
import warnings
|
|
7
|
-
from cad_to_dagmc.core import _check_material_tags
|
|
8
|
-
|
|
9
3
|
from pathlib import Path
|
|
10
4
|
|
|
5
|
+
import cadquery as cq
|
|
6
|
+
import gmsh
|
|
11
7
|
import pymoab as mb
|
|
8
|
+
import pytest
|
|
12
9
|
from pymoab import core, types
|
|
13
10
|
|
|
11
|
+
from cad_to_dagmc import CadToDagmc
|
|
12
|
+
from cad_to_dagmc.core import _check_material_tags
|
|
13
|
+
|
|
14
14
|
|
|
15
15
|
def get_volumes_and_materials_from_h5m(filename: str) -> dict:
|
|
16
16
|
"""Reads in a DAGMC h5m file and uses PyMoab to find the volume ids with
|
|
@@ -219,3 +219,117 @@ def test_check_material_tags_too_long():
|
|
|
219
219
|
assert issubclass(w[-1].category, UserWarning)
|
|
220
220
|
assert "Material tag" in str(w[-1].message)
|
|
221
221
|
assert "a" * 29 in str(w[-1].message)
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
@pytest.mark.parametrize(
|
|
225
|
+
"scale_factor, expected_width",
|
|
226
|
+
[
|
|
227
|
+
(1, 10.0),
|
|
228
|
+
(2, 20.0),
|
|
229
|
+
(10, 100.0),
|
|
230
|
+
],
|
|
231
|
+
)
|
|
232
|
+
def test_scaling_factor_when_adding_stp(scale_factor, expected_width):
|
|
233
|
+
|
|
234
|
+
c2d = CadToDagmc()
|
|
235
|
+
c2d.add_stp_file("tests/single_cube.stp", scale_factor=scale_factor)
|
|
236
|
+
c2d.export_gmsh_mesh_file(f"st_test_scaling_factor_{scale_factor}.msh")
|
|
237
|
+
|
|
238
|
+
gmsh.initialize()
|
|
239
|
+
gmsh.open(f"st_test_scaling_factor_{scale_factor}.msh")
|
|
240
|
+
_, node_coords, _ = gmsh.model.mesh.getNodes()
|
|
241
|
+
|
|
242
|
+
# Reshape the node coordinates into a 2D array
|
|
243
|
+
node_coords = node_coords.reshape(-1, 3)
|
|
244
|
+
|
|
245
|
+
# Calculate the bounding box
|
|
246
|
+
min_coords = node_coords.min(axis=0)
|
|
247
|
+
max_coords = node_coords.max(axis=0)
|
|
248
|
+
|
|
249
|
+
width_x = max_coords[0] - min_coords[0]
|
|
250
|
+
width_y = max_coords[1] - min_coords[1]
|
|
251
|
+
width_z = max_coords[2] - min_coords[2]
|
|
252
|
+
|
|
253
|
+
gmsh.finalize()
|
|
254
|
+
|
|
255
|
+
assert width_x == expected_width
|
|
256
|
+
assert width_y == expected_width
|
|
257
|
+
assert width_z == expected_width
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
@pytest.mark.parametrize(
|
|
261
|
+
"scale_factor, expected_width",
|
|
262
|
+
[
|
|
263
|
+
(1, 10.0),
|
|
264
|
+
(2, 20.0),
|
|
265
|
+
(10, 100.0),
|
|
266
|
+
],
|
|
267
|
+
)
|
|
268
|
+
def test_scaling_factor_when_adding_cq_object(scale_factor, expected_width):
|
|
269
|
+
|
|
270
|
+
box = cq.Workplane("XY").box(10, 10, 10)
|
|
271
|
+
c2d = CadToDagmc()
|
|
272
|
+
c2d.add_cadquery_object(box, scale_factor=scale_factor, material_tags=["mat1"])
|
|
273
|
+
c2d.export_gmsh_mesh_file(f"cq_test_scaling_factor_{scale_factor}.msh")
|
|
274
|
+
|
|
275
|
+
gmsh.initialize()
|
|
276
|
+
gmsh.open(f"cq_test_scaling_factor_{scale_factor}.msh")
|
|
277
|
+
_, node_coords, _ = gmsh.model.mesh.getNodes()
|
|
278
|
+
|
|
279
|
+
# Reshape the node coordinates into a 2D array
|
|
280
|
+
node_coords = node_coords.reshape(-1, 3)
|
|
281
|
+
|
|
282
|
+
# Calculate the bounding box
|
|
283
|
+
min_coords = node_coords.min(axis=0)
|
|
284
|
+
max_coords = node_coords.max(axis=0)
|
|
285
|
+
|
|
286
|
+
width_x = max_coords[0] - min_coords[0]
|
|
287
|
+
width_y = max_coords[1] - min_coords[1]
|
|
288
|
+
width_z = max_coords[2] - min_coords[2]
|
|
289
|
+
|
|
290
|
+
gmsh.finalize()
|
|
291
|
+
|
|
292
|
+
assert width_x == expected_width
|
|
293
|
+
assert width_y == expected_width
|
|
294
|
+
assert width_z == expected_width
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
@pytest.mark.parametrize(
|
|
298
|
+
"scale_factor, expected_x_width, expected_y_width, expected_z_width",
|
|
299
|
+
[
|
|
300
|
+
(1, 20.0, 10.0, 10.0),
|
|
301
|
+
(2, 40.0, 20.0, 20.0),
|
|
302
|
+
(10, 200.0, 100.0, 100.0),
|
|
303
|
+
],
|
|
304
|
+
)
|
|
305
|
+
def test_two_box_scaling_factor_when_adding_cq_object(
|
|
306
|
+
scale_factor, expected_x_width, expected_y_width, expected_z_width
|
|
307
|
+
):
|
|
308
|
+
|
|
309
|
+
box = cq.Workplane("XY").box(10, 10, 10)
|
|
310
|
+
box2 = cq.Workplane("XY").moveTo(10, 0).box(10, 10, 10)
|
|
311
|
+
c2d = CadToDagmc()
|
|
312
|
+
c2d.add_cadquery_object(box, scale_factor=scale_factor, material_tags=["mat1"])
|
|
313
|
+
c2d.add_cadquery_object(box2, scale_factor=scale_factor, material_tags=["mat1"])
|
|
314
|
+
c2d.export_gmsh_mesh_file(f"cq_test_2_box_scaling_factor_{scale_factor}.msh")
|
|
315
|
+
|
|
316
|
+
gmsh.initialize()
|
|
317
|
+
gmsh.open(f"cq_test_2_box_scaling_factor_{scale_factor}.msh")
|
|
318
|
+
_, node_coords, _ = gmsh.model.mesh.getNodes()
|
|
319
|
+
|
|
320
|
+
# Reshape the node coordinates into a numpy 2D array
|
|
321
|
+
node_coords = node_coords.reshape(-1, 3)
|
|
322
|
+
|
|
323
|
+
# Calculate the bounding box
|
|
324
|
+
min_coords = node_coords.min(axis=0)
|
|
325
|
+
max_coords = node_coords.max(axis=0)
|
|
326
|
+
|
|
327
|
+
width_x = max_coords[0] - min_coords[0]
|
|
328
|
+
width_y = max_coords[1] - min_coords[1]
|
|
329
|
+
width_z = max_coords[2] - min_coords[2]
|
|
330
|
+
|
|
331
|
+
gmsh.finalize()
|
|
332
|
+
|
|
333
|
+
assert width_x == expected_x_width
|
|
334
|
+
assert width_y == expected_y_width
|
|
335
|
+
assert width_z == expected_z_width
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{cad_to_dagmc-0.8.0 → cad_to_dagmc-0.8.1}/examples/surface_mesh/cadquery_object_and_stp_file.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{cad_to_dagmc-0.8.0 → cad_to_dagmc-0.8.1}/examples/surface_mesh/different_resolution_meshes.py
RENAMED
|
File without changes
|
|
File without changes
|
{cad_to_dagmc-0.8.0 → cad_to_dagmc-0.8.1}/examples/surface_mesh/multiple_cadquery_objects.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{cad_to_dagmc-0.8.0 → cad_to_dagmc-0.8.1}/examples/surface_mesh/single_stp_file_multiple_volumes.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|