cad-to-dagmc 0.7.1__py3-none-any.whl → 0.7.3__py3-none-any.whl

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.

_version.py CHANGED
@@ -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.1'
16
- __version_tuple__ = version_tuple = (0, 7, 1)
15
+ __version__ = version = '0.7.3'
16
+ __version_tuple__ = version_tuple = (0, 7, 3)
cad_to_dagmc/core.py CHANGED
@@ -190,16 +190,27 @@ def _vertices_to_h5m(
190
190
  return h5m_filename
191
191
 
192
192
 
193
- def get_volumes(gmsh, assembly, method="file"):
193
+ def get_volumes(gmsh, assembly, method="file", scale_factor=1.0):
194
194
 
195
195
  if method == "in memory":
196
196
  volumes = gmsh.model.occ.importShapesNativePointer(assembly.wrapped._address())
197
- gmsh.model.occ.synchronize()
197
+
198
198
  elif method == "file":
199
- with tempfile.NamedTemporaryFile(suffix=".step") as temp_file:
200
- exporters.export(assembly, temp_file.name)
199
+ with tempfile.NamedTemporaryFile(suffix=".brep") as temp_file:
200
+ if isinstance(assembly, cq.Assembly):
201
+ assembly.toCompound().exportBrep(temp_file.name)
202
+ else:
203
+ assembly.exportBrep(temp_file.name)
201
204
  volumes = gmsh.model.occ.importShapes(temp_file.name)
202
- gmsh.model.occ.synchronize()
205
+
206
+ # updating the model to ensure the entities in the geometry are found
207
+ gmsh.model.occ.synchronize()
208
+
209
+ if scale_factor != 1.0:
210
+ dim_tags = gmsh.model.getEntities(3)
211
+ gmsh.model.occ.dilate(dim_tags, 0.0, 0.0, 0.0, scale_factor, scale_factor, scale_factor)
212
+ # update the model to ensure the scaling factor has been applied
213
+ gmsh.model.occ.synchronize()
203
214
 
204
215
  return gmsh, volumes
205
216
 
@@ -239,6 +250,7 @@ def _mesh_brep(
239
250
  gmsh.option.setNumber("Mesh.Algorithm", mesh_algorithm)
240
251
  gmsh.option.setNumber("Mesh.MeshSizeMin", min_mesh_size)
241
252
  gmsh.option.setNumber("Mesh.MeshSizeMax", max_mesh_size)
253
+ gmsh.option.setNumber("General.NumThreads", 0) # Use all available cores
242
254
  gmsh.model.mesh.generate(dimensions)
243
255
 
244
256
  return gmsh
@@ -477,6 +489,7 @@ class CadToDagmc:
477
489
  max_mesh_size: float = 5,
478
490
  mesh_algorithm: int = 1,
479
491
  method: str = "file",
492
+ scale_factor: float = 1.0,
480
493
  ):
481
494
 
482
495
  assembly = cq.Assembly()
@@ -487,7 +500,7 @@ class CadToDagmc:
487
500
 
488
501
  gmsh = init_gmsh()
489
502
 
490
- gmsh, _ = get_volumes(gmsh, imprinted_assembly, method=method)
503
+ gmsh, _ = get_volumes(gmsh, imprinted_assembly, method=method, scale_factor=scale_factor)
491
504
 
492
505
  gmsh = _mesh_brep(
493
506
  gmsh=gmsh,
@@ -516,6 +529,7 @@ class CadToDagmc:
516
529
  mesh_algorithm: int = 1,
517
530
  dimensions: int = 2,
518
531
  method: str = "file",
532
+ scale_factor: float = 1.0,
519
533
  ):
520
534
  """Saves a GMesh msh file of the geometry in either 2D surface mesh or
521
535
  3D volume mesh.
@@ -535,6 +549,9 @@ class CadToDagmc:
535
549
  the same as the version used by CadQuery. This is possible to
536
550
  ensure when installing the package with Conda but harder when
537
551
  installing from PyPI.
552
+ scale_factor: a scaling factor to apply to the geometry that can be
553
+ used to enlarge or shrink the geometry. Useful when converting
554
+ Useful when converting the geometry to cm for use in neutronics
538
555
  """
539
556
 
540
557
  assembly = cq.Assembly()
@@ -545,7 +562,7 @@ class CadToDagmc:
545
562
 
546
563
  gmsh = init_gmsh()
547
564
 
548
- gmsh, _ = get_volumes(gmsh, imprinted_assembly, method=method)
565
+ gmsh, _ = get_volumes(gmsh, imprinted_assembly, method=method, scale_factor=scale_factor)
549
566
 
550
567
  gmsh = _mesh_brep(
551
568
  gmsh=gmsh,
@@ -569,6 +586,7 @@ class CadToDagmc:
569
586
  mesh_algorithm: int = 1,
570
587
  implicit_complement_material_tag: str | None = None,
571
588
  method: str = "file",
589
+ scale_factor: float = 1.0,
572
590
  ) -> str:
573
591
  """Saves a DAGMC h5m file of the geometry
574
592
 
@@ -589,6 +607,10 @@ class CadToDagmc:
589
607
  the same as the version used by CadQuery. This is possible to
590
608
  ensure when installing the package with Conda but harder when
591
609
  installing from PyPI.
610
+ scale_factor: a scaling factor to apply to the geometry that can be
611
+ used to enlarge or shrink the geometry. Useful when converting
612
+ Useful when converting the geometry to cm for use in neutronics
613
+
592
614
  Returns:
593
615
  str: the DAGMC filename saved
594
616
  """
@@ -617,7 +639,9 @@ class CadToDagmc:
617
639
 
618
640
  gmsh = init_gmsh()
619
641
 
620
- gmsh, volumes = get_volumes(gmsh, imprinted_assembly, method=method)
642
+ gmsh, volumes = get_volumes(
643
+ gmsh, imprinted_assembly, method=method, scale_factor=scale_factor
644
+ )
621
645
 
622
646
  gmsh = _mesh_brep(
623
647
  gmsh=gmsh,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cad_to_dagmc
3
- Version: 0.7.1
3
+ Version: 0.7.3
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
@@ -15,7 +15,7 @@ License-File: LICENSE
15
15
  Requires-Dist: trimesh
16
16
  Requires-Dist: networkx
17
17
  Requires-Dist: cadquery >=2.4.0
18
- Requires-Dist: numpy <=1.23.5
18
+ Requires-Dist: numpy <=1.26.4
19
19
  Requires-Dist: gmsh
20
20
  Provides-Extra: tests
21
21
  Requires-Dist: pytest ; extra == 'tests'
@@ -24,7 +24,9 @@ Requires-Dist: vtk ; extra == 'tests'
24
24
 
25
25
  [![N|Python](https://www.python.org/static/community_logos/python-powered-w-100x40.png)](https://www.python.org)
26
26
 
27
- [![CI with install](https://github.com/fusion-energy/cad_to_dagmc/actions/workflows/ci_with_install.yml/badge.svg?branch=main)](https://github.com/fusion-energy/cad_to_dagmc/actions/workflows/ci_with_install.yml) Testing package and running examples
27
+ [![CI with Conda install](https://github.com/fusion-energy/cad_to_dagmc/actions/workflows/ci_with_conda_install.yml/badge.svg)](https://github.com/fusion-energy/cad_to_dagmc/actions/workflows/ci_with_conda_install.yml) Testing package and running examples with dependencies installed via Conda
28
+
29
+ [![CI with pip install](https://github.com/fusion-energy/cad_to_dagmc/actions/workflows/ci_with_pip_install.yml/badge.svg)](https://github.com/fusion-energy/cad_to_dagmc/actions/workflows/ci_with_pip_install.yml) Testing package and running examples with dependencies installed vua PIP
28
30
 
29
31
  [![CI with model benchmark zoo](https://github.com/fusion-energy/cad_to_dagmc/actions/workflows/ci_with_benchmarks.yml/badge.svg?branch=main)](https://github.com/fusion-energy/cad_to_dagmc/actions/workflows/ci_with_benchmarks.yml) Testing with [Model Benchmark Zoo](https://github.com/fusion-energy/model_benchmark_zoo)
30
32
 
@@ -0,0 +1,8 @@
1
+ _version.py,sha256=9Y_dpdWykJt40jFoLa3Q4GkYvOMvJ1Y09SkdBJZvTM4,411
2
+ cad_to_dagmc/__init__.py,sha256=fskHUTyCunSpnpJUvBfAYjx4uwDKXHTTiMP6GqnFRf0,494
3
+ cad_to_dagmc/core.py,sha256=_5q_nL_I95JlR1EOAGrG38jMN5SPPZYR86Icg-5At2s,24522
4
+ cad_to_dagmc-0.7.3.dist-info/LICENSE,sha256=B8kznH_777JVNZ3HOKDc4Tj24F7wJ68ledaNYeL9sCw,1070
5
+ cad_to_dagmc-0.7.3.dist-info/METADATA,sha256=L5xUGum0Sz5YlvxleYPlOpbLIRrMtuX5Gnas6diRRTM,7941
6
+ cad_to_dagmc-0.7.3.dist-info/WHEEL,sha256=R06PA3UVYHThwHvxuRWMqaGcr-PuniXahwjmQRFMEkY,91
7
+ cad_to_dagmc-0.7.3.dist-info/top_level.txt,sha256=zTi8C64SEBsE5WOtPovnxhOzt-E6Oc5nC3RW6M_5aEA,22
8
+ cad_to_dagmc-0.7.3.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.2.0)
2
+ Generator: setuptools (75.5.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,8 +0,0 @@
1
- _version.py,sha256=5-skCoU2Vu44uYeNEApDjjGE2Q26ndIh5lKJuVOeL88,411
2
- cad_to_dagmc/__init__.py,sha256=fskHUTyCunSpnpJUvBfAYjx4uwDKXHTTiMP6GqnFRf0,494
3
- cad_to_dagmc/core.py,sha256=aGBPoxZMWmoo-qf28AFkoSsdO59EtLtRJ_87QKUaFgU,23297
4
- cad_to_dagmc-0.7.1.dist-info/LICENSE,sha256=B8kznH_777JVNZ3HOKDc4Tj24F7wJ68ledaNYeL9sCw,1070
5
- cad_to_dagmc-0.7.1.dist-info/METADATA,sha256=9gUrCwcSrUx0wHrYoug9f9PJiiiCEwnH4BU-_-pyJ-s,7610
6
- cad_to_dagmc-0.7.1.dist-info/WHEEL,sha256=OVMc5UfuAQiSplgO0_WdW7vXVGAt9Hdd6qtN4HotdyA,91
7
- cad_to_dagmc-0.7.1.dist-info/top_level.txt,sha256=zTi8C64SEBsE5WOtPovnxhOzt-E6Oc5nC3RW6M_5aEA,22
8
- cad_to_dagmc-0.7.1.dist-info/RECORD,,