cad-to-dagmc 0.5.1__py3-none-any.whl → 0.6.0__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.
- _version.py +2 -2
- cad_to_dagmc/core.py +142 -118
- {cad_to_dagmc-0.5.1.dist-info → cad_to_dagmc-0.6.0.dist-info}/METADATA +44 -20
- cad_to_dagmc-0.6.0.dist-info/RECORD +8 -0
- {cad_to_dagmc-0.5.1.dist-info → cad_to_dagmc-0.6.0.dist-info}/WHEEL +1 -1
- cad_to_dagmc-0.5.1.dist-info/RECORD +0 -8
- {cad_to_dagmc-0.5.1.dist-info → cad_to_dagmc-0.6.0.dist-info}/LICENSE +0 -0
- {cad_to_dagmc-0.5.1.dist-info → cad_to_dagmc-0.6.0.dist-info}/top_level.txt +0 -0
_version.py
CHANGED
cad_to_dagmc/core.py
CHANGED
|
@@ -1,31 +1,13 @@
|
|
|
1
1
|
import typing
|
|
2
|
-
from pathlib import Path
|
|
3
2
|
|
|
4
3
|
import cadquery as cq
|
|
5
4
|
import gmsh
|
|
6
5
|
import numpy as np
|
|
7
|
-
import OCP
|
|
8
|
-
import trimesh
|
|
9
6
|
from cadquery import importers
|
|
10
7
|
from pymoab import core, types
|
|
11
8
|
|
|
12
9
|
|
|
13
|
-
def
|
|
14
|
-
fixed_triangles = []
|
|
15
|
-
for triangles in triangles_in_each_volume:
|
|
16
|
-
fixed_triangles.append(fix_normal(vertices, triangles))
|
|
17
|
-
return fixed_triangles
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
def fix_normal(vertices: typing.Sequence, triangles: typing.Sequence):
|
|
21
|
-
mesh = trimesh.Trimesh(vertices=vertices, faces=triangles, process=False)
|
|
22
|
-
|
|
23
|
-
mesh.fix_normals()
|
|
24
|
-
|
|
25
|
-
return mesh.faces
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
def define_moab_core_and_tags() -> typing.Tuple[core.Core, dict]:
|
|
10
|
+
def _define_moab_core_and_tags() -> typing.Tuple[core.Core, dict]:
|
|
29
11
|
"""Creates a MOAB Core instance which can be built up by adding sets of
|
|
30
12
|
triangles to the instance
|
|
31
13
|
|
|
@@ -79,7 +61,7 @@ def define_moab_core_and_tags() -> typing.Tuple[core.Core, dict]:
|
|
|
79
61
|
return moab_core, tags
|
|
80
62
|
|
|
81
63
|
|
|
82
|
-
def
|
|
64
|
+
def _vertices_to_h5m(
|
|
83
65
|
vertices: typing.Union[
|
|
84
66
|
typing.Iterable[typing.Tuple[float, float, float]],
|
|
85
67
|
typing.Iterable["cadquery.occ_impl.geom.Vector"],
|
|
@@ -87,6 +69,7 @@ def vertices_to_h5m(
|
|
|
87
69
|
triangles_by_solid_by_face: typing.Iterable[typing.Iterable[typing.Tuple[int, int, int]]],
|
|
88
70
|
material_tags: typing.Iterable[str],
|
|
89
71
|
h5m_filename="dagmc.h5m",
|
|
72
|
+
implicit_complement_material_tag=None,
|
|
90
73
|
):
|
|
91
74
|
"""Converts vertices and triangle sets into a tagged h5m file compatible
|
|
92
75
|
with DAGMC enabled neutronics simulations
|
|
@@ -118,7 +101,7 @@ def vertices_to_h5m(
|
|
|
118
101
|
else:
|
|
119
102
|
face_ids_with_solid_ids[face_id] = [solid_id]
|
|
120
103
|
|
|
121
|
-
moab_core, tags =
|
|
104
|
+
moab_core, tags = _define_moab_core_and_tags()
|
|
122
105
|
|
|
123
106
|
volume_sets_by_solid_id = {}
|
|
124
107
|
for material_tag, (solid_id, triangles_on_each_face) in zip(
|
|
@@ -187,6 +170,17 @@ def vertices_to_h5m(
|
|
|
187
170
|
|
|
188
171
|
moab_core.add_entity(group_set, volume_set)
|
|
189
172
|
|
|
173
|
+
if implicit_complement_material_tag:
|
|
174
|
+
group_set = moab_core.create_meshset()
|
|
175
|
+
moab_core.tag_set_data(tags["category"], group_set, "Group")
|
|
176
|
+
moab_core.tag_set_data(
|
|
177
|
+
tags["name"], group_set, f"mat:{implicit_complement_material_tag}_comp"
|
|
178
|
+
)
|
|
179
|
+
moab_core.tag_set_data(tags["geom_dimension"], group_set, 4)
|
|
180
|
+
moab_core.add_entity(
|
|
181
|
+
group_set, volume_set
|
|
182
|
+
) # volume is arbitrary but should exist in moab core
|
|
183
|
+
|
|
190
184
|
all_sets = moab_core.get_entities_by_handle(0)
|
|
191
185
|
|
|
192
186
|
file_set = moab_core.create_meshset()
|
|
@@ -198,11 +192,12 @@ def vertices_to_h5m(
|
|
|
198
192
|
return h5m_filename
|
|
199
193
|
|
|
200
194
|
|
|
201
|
-
def
|
|
195
|
+
def _mesh_brep(
|
|
202
196
|
brep_object: str,
|
|
203
197
|
min_mesh_size: float = 1,
|
|
204
198
|
max_mesh_size: float = 10,
|
|
205
199
|
mesh_algorithm: int = 1,
|
|
200
|
+
dimensions: int = 2,
|
|
206
201
|
):
|
|
207
202
|
"""Creates a conformal surface meshes of the volumes in a Brep file using
|
|
208
203
|
Gmsh.
|
|
@@ -215,6 +210,8 @@ def mesh_brep(
|
|
|
215
210
|
into gmsh.option.setNumber("Mesh.MeshSizeMax", max_mesh_size)
|
|
216
211
|
mesh_algorithm: The Gmsh mesh algorithm number to use. Passed into
|
|
217
212
|
gmsh.option.setNumber("Mesh.Algorithm", mesh_algorithm)
|
|
213
|
+
dimensions: The number of dimensions, 2 for a surface mesh 3 for a
|
|
214
|
+
volume mesh. Passed to gmsh.model.mesh.generate()
|
|
218
215
|
|
|
219
216
|
Returns:
|
|
220
217
|
The resulting gmsh object and volumes
|
|
@@ -222,23 +219,20 @@ def mesh_brep(
|
|
|
222
219
|
|
|
223
220
|
gmsh.initialize()
|
|
224
221
|
gmsh.option.setNumber("General.Terminal", 1)
|
|
225
|
-
gmsh.model.add("
|
|
222
|
+
gmsh.model.add("made_with_cad_to_dagmc_package")
|
|
226
223
|
volumes = gmsh.model.occ.importShapesNativePointer(brep_object)
|
|
227
224
|
gmsh.model.occ.synchronize()
|
|
228
225
|
|
|
229
226
|
gmsh.option.setNumber("Mesh.Algorithm", mesh_algorithm)
|
|
230
227
|
gmsh.option.setNumber("Mesh.MeshSizeMin", min_mesh_size)
|
|
231
228
|
gmsh.option.setNumber("Mesh.MeshSizeMax", max_mesh_size)
|
|
232
|
-
gmsh.model.mesh.generate(
|
|
229
|
+
gmsh.model.mesh.generate(dimensions)
|
|
233
230
|
|
|
234
231
|
return gmsh, volumes
|
|
235
232
|
|
|
236
233
|
|
|
237
|
-
def
|
|
234
|
+
def _mesh_to_h5m_in_memory_method(
|
|
238
235
|
volumes,
|
|
239
|
-
material_tags: typing.Iterable[str],
|
|
240
|
-
h5m_filename: str = "dagmc.h5m",
|
|
241
|
-
msh_filename=None,
|
|
242
236
|
) -> str:
|
|
243
237
|
"""Converts gmsh volumes into a DAGMC h5m file.
|
|
244
238
|
|
|
@@ -249,17 +243,9 @@ def mesh_to_h5m_in_memory_method(
|
|
|
249
243
|
h5m_filename: the filename of the DAGMC h5m file to write
|
|
250
244
|
|
|
251
245
|
Returns:
|
|
252
|
-
|
|
246
|
+
vertices and triangles (grouped by solid then by face)
|
|
253
247
|
"""
|
|
254
248
|
|
|
255
|
-
if isinstance(material_tags, str):
|
|
256
|
-
msg = f"material_tags should be a list of strings, not a single string."
|
|
257
|
-
raise ValueError(msg)
|
|
258
|
-
|
|
259
|
-
if len(volumes) != len(material_tags):
|
|
260
|
-
msg = f"{len(volumes)} volumes found in Brep file is not equal to the number of material_tags {len(material_tags)} provided."
|
|
261
|
-
raise ValueError(msg)
|
|
262
|
-
|
|
263
249
|
n = 3 # number of verts in a triangles
|
|
264
250
|
triangles_by_solid_by_face = {}
|
|
265
251
|
for dim_and_vol in volumes:
|
|
@@ -299,28 +285,17 @@ def mesh_to_h5m_in_memory_method(
|
|
|
299
285
|
|
|
300
286
|
vertices = [all_coords[i : i + n].tolist() for i in range(0, len(all_coords), n)]
|
|
301
287
|
|
|
302
|
-
|
|
303
|
-
gmsh.write(msh_filename)
|
|
304
|
-
|
|
305
|
-
gmsh.finalize()
|
|
306
|
-
|
|
307
|
-
# checks and fixes triangle fix_normals within vertices_to_h5m
|
|
308
|
-
return vertices_to_h5m(
|
|
309
|
-
vertices=vertices,
|
|
310
|
-
triangles_by_solid_by_face=triangles_by_solid_by_face,
|
|
311
|
-
material_tags=material_tags,
|
|
312
|
-
h5m_filename=h5m_filename,
|
|
313
|
-
)
|
|
288
|
+
return vertices, triangles_by_solid_by_face
|
|
314
289
|
|
|
315
290
|
|
|
316
|
-
def
|
|
291
|
+
def _get_ids_from_assembly(assembly: cq.assembly.Assembly):
|
|
317
292
|
ids = []
|
|
318
293
|
for obj, name, loc, _ in assembly:
|
|
319
294
|
ids.append(name)
|
|
320
295
|
return ids
|
|
321
296
|
|
|
322
297
|
|
|
323
|
-
def
|
|
298
|
+
def _get_ids_from_imprinted_assembly(solid_id_dict):
|
|
324
299
|
ids = []
|
|
325
300
|
for id in list(solid_id_dict.values()):
|
|
326
301
|
ids.append(id[0])
|
|
@@ -335,56 +310,16 @@ def order_material_ids_by_brep_order(original_ids, scrambled_id, material_tags):
|
|
|
335
310
|
return material_tags_in_brep_order
|
|
336
311
|
|
|
337
312
|
|
|
338
|
-
def merge_surfaces(parts):
|
|
339
|
-
"""Merges surfaces in the geometry that are the same. More details on
|
|
340
|
-
the merging process in the DAGMC docs
|
|
341
|
-
https://svalinn.github.io/DAGMC/usersguide/cubit_basics.html"""
|
|
342
|
-
|
|
343
|
-
# solids = geometry.Solids()
|
|
344
|
-
|
|
345
|
-
bldr = OCP.BOPAlgo.BOPAlgo_Splitter()
|
|
346
|
-
|
|
347
|
-
if len(parts) == 1:
|
|
348
|
-
# merged_solid = cq.Compound(solids)
|
|
349
|
-
|
|
350
|
-
if isinstance(parts[0], (cq.occ_impl.shapes.Compound, cq.occ_impl.shapes.Solid)):
|
|
351
|
-
# stp file
|
|
352
|
-
return parts[0], parts[0].wrapped
|
|
353
|
-
else:
|
|
354
|
-
return parts[0], parts[0].toOCC()
|
|
355
|
-
|
|
356
|
-
# else:
|
|
357
|
-
for solid in parts:
|
|
358
|
-
# checks if solid is a compound as .val() is not needed for compounds
|
|
359
|
-
if isinstance(solid, (cq.occ_impl.shapes.Compound, cq.occ_impl.shapes.Solid)):
|
|
360
|
-
bldr.AddArgument(solid.wrapped)
|
|
361
|
-
else:
|
|
362
|
-
bldr.AddArgument(solid.val().wrapped)
|
|
363
|
-
|
|
364
|
-
bldr.SetNonDestructive(True)
|
|
365
|
-
|
|
366
|
-
bldr.Perform()
|
|
367
|
-
|
|
368
|
-
bldr.Images()
|
|
369
|
-
|
|
370
|
-
merged_solid = cq.Compound(bldr.Shape())
|
|
371
|
-
|
|
372
|
-
return merged_solid, merged_solid.wrapped
|
|
373
|
-
|
|
374
|
-
|
|
375
313
|
class CadToDagmc:
|
|
376
314
|
def __init__(self):
|
|
377
315
|
self.parts = []
|
|
378
|
-
self.material_tags = []
|
|
379
316
|
|
|
380
317
|
def add_stp_file(
|
|
381
318
|
self,
|
|
382
319
|
filename: str,
|
|
383
|
-
material_tags: typing.Iterable[str],
|
|
384
320
|
scale_factor: float = 1.0,
|
|
385
321
|
):
|
|
386
|
-
"""Loads the parts from stp file into the model
|
|
387
|
-
parts and their material tags.
|
|
322
|
+
"""Loads the parts from stp file into the model.
|
|
388
323
|
|
|
389
324
|
Args:
|
|
390
325
|
filename: the filename used to save the html graph.
|
|
@@ -399,28 +334,22 @@ class CadToDagmc:
|
|
|
399
334
|
"""
|
|
400
335
|
part = importers.importStep(str(filename)).val()
|
|
401
336
|
|
|
402
|
-
if scale_factor == 1:
|
|
337
|
+
if scale_factor == 1.0:
|
|
403
338
|
scaled_part = part
|
|
404
339
|
else:
|
|
405
340
|
scaled_part = part.scale(scale_factor)
|
|
406
|
-
self.add_cadquery_object(object=scaled_part
|
|
341
|
+
self.add_cadquery_object(object=scaled_part)
|
|
407
342
|
|
|
408
343
|
def add_cadquery_object(
|
|
409
344
|
self,
|
|
410
345
|
object: typing.Union[
|
|
411
346
|
cq.assembly.Assembly, cq.occ_impl.shapes.Compound, cq.occ_impl.shapes.Solid
|
|
412
347
|
],
|
|
413
|
-
material_tags: typing.Iterable[str],
|
|
414
348
|
):
|
|
415
|
-
"""Loads the parts from CadQuery object into the model
|
|
416
|
-
the parts and their material tags.
|
|
349
|
+
"""Loads the parts from CadQuery object into the model.
|
|
417
350
|
|
|
418
351
|
Args:
|
|
419
352
|
object: the cadquery object to convert
|
|
420
|
-
material_tags: the names of the DAGMC material tags to assign.
|
|
421
|
-
These will need to be in the same order as the volumes in the
|
|
422
|
-
STP file and match the material tags used in the neutronics
|
|
423
|
-
code (e.g. OpenMC).
|
|
424
353
|
"""
|
|
425
354
|
|
|
426
355
|
if isinstance(object, cq.assembly.Assembly):
|
|
@@ -432,48 +361,143 @@ class CadToDagmc:
|
|
|
432
361
|
iterable_solids = object.val().Solids()
|
|
433
362
|
self.parts = self.parts + iterable_solids
|
|
434
363
|
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
364
|
+
def export_unstructured_mesh_file(
|
|
365
|
+
self,
|
|
366
|
+
filename: str = "umesh.h5m",
|
|
367
|
+
min_mesh_size: float = 1,
|
|
368
|
+
max_mesh_size: float = 5,
|
|
369
|
+
mesh_algorithm: int = 1,
|
|
370
|
+
):
|
|
371
|
+
|
|
372
|
+
assembly = cq.Assembly()
|
|
373
|
+
for part in self.parts:
|
|
374
|
+
assembly.add(part)
|
|
438
375
|
|
|
439
|
-
|
|
440
|
-
self.material_tags.append(material_tag)
|
|
376
|
+
imprinted_assembly, _ = cq.occ_impl.assembly.imprint(assembly)
|
|
441
377
|
|
|
442
|
-
|
|
378
|
+
gmsh, volumes = _mesh_brep(
|
|
379
|
+
brep_object=imprinted_assembly.wrapped._address(),
|
|
380
|
+
min_mesh_size=min_mesh_size,
|
|
381
|
+
max_mesh_size=max_mesh_size,
|
|
382
|
+
mesh_algorithm=mesh_algorithm,
|
|
383
|
+
dimensions=3,
|
|
384
|
+
)
|
|
385
|
+
|
|
386
|
+
# gmesh writes out a vtk file that is converted by pymoab into a h5 file
|
|
387
|
+
gmsh.write(filename + ".vtk")
|
|
388
|
+
|
|
389
|
+
moab_core = core.Core()
|
|
390
|
+
moab_core.load_file(filename + ".vtk")
|
|
391
|
+
moab_core.write_file(filename)
|
|
392
|
+
|
|
393
|
+
gmsh.finalize()
|
|
394
|
+
|
|
395
|
+
def export_gmsh_mesh_file(
|
|
443
396
|
self,
|
|
444
|
-
filename: str = "
|
|
397
|
+
filename: str = "mesh.msh",
|
|
445
398
|
min_mesh_size: float = 1,
|
|
446
399
|
max_mesh_size: float = 5,
|
|
447
400
|
mesh_algorithm: int = 1,
|
|
448
|
-
|
|
401
|
+
dimensions: int = 2,
|
|
449
402
|
):
|
|
403
|
+
"""Saves a GMesh msh file of the geometry in either 2D surface mesh or
|
|
404
|
+
3D volume mesh.
|
|
405
|
+
|
|
406
|
+
Args:
|
|
407
|
+
filename
|
|
408
|
+
min_mesh_size: the minimum size of mesh elements to use.
|
|
409
|
+
max_mesh_size: the maximum size of mesh elements to use.
|
|
410
|
+
mesh_algorithm: the gmsh mesh algorithm to use.
|
|
411
|
+
dimensions: The number of dimensions, 2 for a surface mesh 3 for a
|
|
412
|
+
volume mesh. Passed to gmsh.model.mesh.generate()
|
|
413
|
+
"""
|
|
414
|
+
|
|
450
415
|
assembly = cq.Assembly()
|
|
451
416
|
for part in self.parts:
|
|
452
417
|
assembly.add(part)
|
|
453
418
|
|
|
454
|
-
imprinted_assembly,
|
|
419
|
+
imprinted_assembly, _ = cq.occ_impl.assembly.imprint(assembly)
|
|
455
420
|
|
|
456
|
-
gmsh, volumes =
|
|
421
|
+
gmsh, volumes = _mesh_brep(
|
|
457
422
|
brep_object=imprinted_assembly.wrapped._address(),
|
|
458
423
|
min_mesh_size=min_mesh_size,
|
|
459
424
|
max_mesh_size=max_mesh_size,
|
|
460
425
|
mesh_algorithm=mesh_algorithm,
|
|
426
|
+
dimensions=dimensions,
|
|
461
427
|
)
|
|
462
428
|
|
|
463
|
-
|
|
464
|
-
|
|
429
|
+
gmsh.write(filename)
|
|
430
|
+
|
|
431
|
+
gmsh.finalize()
|
|
432
|
+
|
|
433
|
+
def export_dagmc_h5m_file(
|
|
434
|
+
self,
|
|
435
|
+
material_tags: typing.Iterable[str],
|
|
436
|
+
filename: str = "dagmc.h5m",
|
|
437
|
+
min_mesh_size: float = 1,
|
|
438
|
+
max_mesh_size: float = 5,
|
|
439
|
+
mesh_algorithm: int = 1,
|
|
440
|
+
implicit_complement_material_tag: typing.Optional[str] = None,
|
|
441
|
+
):
|
|
442
|
+
"""Saves a DAGMC h5m file of the geometry
|
|
443
|
+
|
|
444
|
+
Args:
|
|
445
|
+
filename
|
|
446
|
+
min_mesh_size: the minimum size of mesh elements to use.
|
|
447
|
+
max_mesh_size: the maximum size of mesh elements to use.
|
|
448
|
+
mesh_algorithm: the gmsh mesh algorithm to use.
|
|
449
|
+
material_tags: the names of the DAGMC material tags to assign.
|
|
450
|
+
These will need to be in the same order as the volumes in the
|
|
451
|
+
geometry geometry added (STP file and CadQuery objects) and
|
|
452
|
+
match the material tags used in the neutronics code (e.g. OpenMC).
|
|
453
|
+
implicit_complement_material_tag: the name of the material tag to
|
|
454
|
+
use for the implicit complement (void space). Defaults to None
|
|
455
|
+
which is a vacuum.
|
|
456
|
+
"""
|
|
457
|
+
assembly = cq.Assembly()
|
|
458
|
+
for part in self.parts:
|
|
459
|
+
assembly.add(part)
|
|
460
|
+
|
|
461
|
+
imprinted_assembly, imprinted_solids_with_org_id = cq.occ_impl.assembly.imprint(assembly)
|
|
462
|
+
|
|
463
|
+
original_ids = _get_ids_from_assembly(assembly)
|
|
464
|
+
scrambled_ids = _get_ids_from_imprinted_assembly(imprinted_solids_with_org_id)
|
|
465
465
|
|
|
466
466
|
# both id lists should be the same length as each other and the same
|
|
467
467
|
# length as the self.material_tags
|
|
468
468
|
|
|
469
|
+
if len(original_ids) != len(material_tags):
|
|
470
|
+
msg = f"Number of volumes {len(original_ids)} is not equal to number of material tags {len(material_tags)}"
|
|
471
|
+
raise ValueError(msg)
|
|
472
|
+
|
|
469
473
|
material_tags_in_brep_order = order_material_ids_by_brep_order(
|
|
470
|
-
original_ids, scrambled_ids,
|
|
474
|
+
original_ids, scrambled_ids, material_tags
|
|
475
|
+
)
|
|
476
|
+
|
|
477
|
+
gmsh, volumes = _mesh_brep(
|
|
478
|
+
brep_object=imprinted_assembly.wrapped._address(), # in memory address
|
|
479
|
+
min_mesh_size=min_mesh_size,
|
|
480
|
+
max_mesh_size=max_mesh_size,
|
|
481
|
+
mesh_algorithm=mesh_algorithm,
|
|
471
482
|
)
|
|
472
483
|
|
|
473
|
-
|
|
474
|
-
|
|
484
|
+
if isinstance(material_tags_in_brep_order, str):
|
|
485
|
+
msg = f"material_tags should be a list of strings, not a single string."
|
|
486
|
+
raise ValueError(msg)
|
|
487
|
+
|
|
488
|
+
if len(volumes) != len(material_tags_in_brep_order):
|
|
489
|
+
msg = f"{len(volumes)} volumes found in Brep file is not equal to the number of material_tags {len(material_tags_in_brep_order)} provided."
|
|
490
|
+
raise ValueError(msg)
|
|
491
|
+
|
|
492
|
+
vertices, triangles_by_solid_by_face = _mesh_to_h5m_in_memory_method(volumes=volumes)
|
|
493
|
+
|
|
494
|
+
gmsh.finalize()
|
|
495
|
+
|
|
496
|
+
# checks and fixes triangle fix_normals within vertices_to_h5m
|
|
497
|
+
return _vertices_to_h5m(
|
|
498
|
+
vertices=vertices,
|
|
499
|
+
triangles_by_solid_by_face=triangles_by_solid_by_face,
|
|
475
500
|
material_tags=material_tags_in_brep_order,
|
|
476
501
|
h5m_filename=filename,
|
|
477
|
-
|
|
502
|
+
implicit_complement_material_tag=implicit_complement_material_tag,
|
|
478
503
|
)
|
|
479
|
-
return h5m_filename
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
|
-
Name:
|
|
3
|
-
Version: 0.
|
|
2
|
+
Name: cad_to_dagmc
|
|
3
|
+
Version: 0.6.0
|
|
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
|
|
@@ -16,11 +16,12 @@ Requires-Dist: trimesh
|
|
|
16
16
|
Requires-Dist: networkx
|
|
17
17
|
Provides-Extra: tests
|
|
18
18
|
Requires-Dist: pytest ; extra == 'tests'
|
|
19
|
+
Requires-Dist: vtk ; extra == 'tests'
|
|
19
20
|
|
|
20
21
|
|
|
21
22
|
[](https://www.python.org)
|
|
22
23
|
|
|
23
|
-
[](https://github.com/fusion-energy/cad_to_dagmc/actions/workflows/ci_with_install.yml) Testing package and running examples
|
|
24
25
|
|
|
25
26
|
[](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)
|
|
26
27
|
|
|
@@ -29,34 +30,41 @@ Requires-Dist: pytest ; extra == 'tests'
|
|
|
29
30
|
[](https://pypi.org/project/cad_to_dagmc/)
|
|
30
31
|
|
|
31
32
|
|
|
32
|
-
A minimal package that
|
|
33
|
+
A minimal package that converts CAD geometry to [DAGMC](https://github.com/svalinn/DAGMC/) h5m files
|
|
34
|
+
|
|
35
|
+
cad-to-dagmc can create:
|
|
36
|
+
- surface meshes / faceted geometry / triangular meshes
|
|
37
|
+
- unstructured mesh / tetrahedral meshes / volume meshes
|
|
38
|
+
|
|
39
|
+
cad-to-dagmc can convert:
|
|
40
|
+
- STEP files
|
|
41
|
+
- CadQuery objects (in memory)
|
|
42
|
+
|
|
43
|
+
cadto-dagmc aims to produce DAGMC compatible h5m files from CAD geometry is intended to convert [STEP](http://www.steptools.com/stds/step/) files or [CadQuery](https://cadquery.readthedocs.io) objects to a [DAGMC](https://github.com/svalinn/DAGMC/) compatible h5m file.
|
|
33
44
|
|
|
34
|
-
This particular method of producing DAGMC compatible h5m files from CAD geometry is intended to convert STP files or [CadQuery](https://cadquery.readthedocs.io) objects to a DAGMC compatible h5m file.
|
|
35
45
|
|
|
36
46
|
The resulting DAGMC geometry can then be used for simulations in [OpenMC](https://github.com/openmc-dev/openmc/) or [other supported codes](https://svalinn.github.io/DAGMC/).
|
|
37
47
|
|
|
38
48
|
This package is tested with [pytest tests](https://github.com/fusion-energy/cad_to_dagmc/tree/main/tests) and also the DAGMC geometry made with this package is compared to simulation carried out with native constructive solid geometry, see [Model Benchmark Zoo](https://github.com/fusion-energy/model_benchmark_zoo) for more details.
|
|
39
49
|
|
|
40
|
-
Also checkout these other
|
|
50
|
+
Also checkout these other software projects that also create DAGMC geometry [CAD-to-OpenMC](https://github.com/openmsr/CAD_to_OpenMC), [Stellarmesh](https://github.com/Thea-Energy/stellarmesh) and [Coreform Cubit](https://coreform.com/products/coreform-cubit/)
|
|
41
51
|
|
|
42
52
|
# Installation prerequisite
|
|
43
53
|
|
|
44
54
|
In principle, any Conda/Mamba distribution will work. A few Conda/Mamba options are:
|
|
45
|
-
- [
|
|
46
|
-
- [Miniforge](https://github.com/conda-forge/miniforge#miniforge-pypy3)
|
|
55
|
+
- [Miniforge](https://github.com/conda-forge/miniforge) (recommended as it includes mamba)
|
|
47
56
|
- [Anaconda](https://www.anaconda.com/download)
|
|
48
57
|
- [Miniconda](https://docs.conda.io/en/latest/miniconda.html)
|
|
49
58
|
|
|
50
59
|
|
|
51
60
|
# Install using Mamba and pip
|
|
52
61
|
|
|
53
|
-
This example assumes you have installed the
|
|
54
|
-
installed Mamba with ```conda install -c conda-forge mamba -y```
|
|
62
|
+
This example assumes you have installed the Miniforge option or separately have installed Mamba with ```conda install -c conda-forge mamba -y```
|
|
55
63
|
|
|
56
|
-
Create a new conda environment, I've chosen Python 3.
|
|
64
|
+
Create a new conda environment, I've chosen Python 3.10 here but newer versions are
|
|
57
65
|
also supported.
|
|
58
66
|
```bash
|
|
59
|
-
mamba create --name new_env python=3.
|
|
67
|
+
mamba create --name new_env python=3.10 -y
|
|
60
68
|
```
|
|
61
69
|
|
|
62
70
|
Activate the environment
|
|
@@ -66,7 +74,7 @@ mamba activate new_env
|
|
|
66
74
|
|
|
67
75
|
Install the dependencies
|
|
68
76
|
```bash
|
|
69
|
-
mamba install -
|
|
77
|
+
mamba install -y -c conda-forge gmsh python-gmsh moab>=5.3.0 ocp>=7.7.2.0 cadquery>=2.4.0
|
|
70
78
|
```
|
|
71
79
|
|
|
72
80
|
Then you can install the cad_to_dagmc package with ```pip```
|
|
@@ -74,11 +82,17 @@ Then you can install the cad_to_dagmc package with ```pip```
|
|
|
74
82
|
pip install cad_to_dagmc
|
|
75
83
|
```
|
|
76
84
|
|
|
77
|
-
You may also want to install OpenMC with DAGMC to make use of the h5m geometry files produced in simulations. However you could also use other supported particle transport codes such as MCNP, FLUKA and others [link to DAGMC documentation](https://svalinn.github.io/DAGMC/).
|
|
85
|
+
You may also want to install OpenMC with DAGMC to make use of the h5m geometry files produced in simulations. However you could also use other supported particle transport codes such as MCNP, FLUKA and others [link to DAGMC documentation](https://svalinn.github.io/DAGMC/).
|
|
86
|
+
|
|
87
|
+
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
|
|
78
88
|
```bash
|
|
79
|
-
mamba install -c conda-forge -y "openmc=0.
|
|
89
|
+
mamba install -c conda-forge -y "openmc=0.14.0=dagmc*nompi*"
|
|
80
90
|
```
|
|
81
91
|
|
|
92
|
+
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.
|
|
93
|
+
|
|
94
|
+
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.
|
|
95
|
+
|
|
82
96
|
|
|
83
97
|
# Install using Conda and pip
|
|
84
98
|
|
|
@@ -86,7 +100,7 @@ This example uses Conda to install some dependencies that are not available via
|
|
|
86
100
|
|
|
87
101
|
Create a new conda environment
|
|
88
102
|
```bash
|
|
89
|
-
conda create --name new_env python=3.
|
|
103
|
+
conda create --name new_env python=3.10 -y
|
|
90
104
|
```
|
|
91
105
|
|
|
92
106
|
Activate the environment
|
|
@@ -96,7 +110,7 @@ conda activate new_env
|
|
|
96
110
|
|
|
97
111
|
Install the dependencies
|
|
98
112
|
```bash
|
|
99
|
-
conda install -
|
|
113
|
+
conda install -y -c conda-forge gmsh python-gmsh moab>=5.3.0 ocp>=7.7.2.0 cadquery>=2.4.0
|
|
100
114
|
```
|
|
101
115
|
|
|
102
116
|
Then you can install the cad_to_dagmc package with ```pip```
|
|
@@ -104,11 +118,19 @@ Then you can install the cad_to_dagmc package with ```pip```
|
|
|
104
118
|
pip install cad_to_dagmc
|
|
105
119
|
```
|
|
106
120
|
|
|
107
|
-
|
|
121
|
+
# Usage - with OpenMC
|
|
122
|
+
|
|
123
|
+
You may also want to install OpenMC with DAGMC to make use of the h5m geometry files produced in simulations. However you could also use other supported particle transport codes such as MCNP, FLUKA and others supported by [DAGMC](https://svalinn.github.io/DAGMC/).
|
|
124
|
+
|
|
125
|
+
You can run ```mamba install -c conda-forge openmc``` however this may choose to install OpenMC without DAGMC included.
|
|
126
|
+
|
|
127
|
+
You can be more specific with conda/mamba commands to make sure the latest version of OpenMC which contains DAGMC is chosen by conda / mamba
|
|
108
128
|
```bash
|
|
109
|
-
|
|
129
|
+
mamba install -c conda-forge -y "openmc=0.14.0=dagmc*nompi*"
|
|
110
130
|
```
|
|
111
131
|
|
|
132
|
+
You could also [install OpenMC from source](https://docs.openmc.org/en/stable/quickinstall.html) which might be prefered as it can be tricky for the conda enviroment to get resolved.
|
|
133
|
+
|
|
112
134
|
|
|
113
135
|
|
|
114
136
|
# Usage - creation of DAGMC h5m files
|
|
@@ -117,4 +139,6 @@ For examples see the [examples folder](https://github.com/fusion-energy/cad_to_d
|
|
|
117
139
|
|
|
118
140
|
# Usage - simulation with transport code
|
|
119
141
|
|
|
120
|
-
For examples see the
|
|
142
|
+
For examples see the [examples folder](https://github.com/fusion-energy/cad_to_dagmc/tree/main/examples)
|
|
143
|
+
|
|
144
|
+
For more examples see the CAD tasks in the [neutronics-workshop](https://github.com/fusion-energy/neutronics-workshop) and [model benchmark zoo](https://github.com/fusion-energy/model_benchmark_zoo)
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
_version.py,sha256=2JKwcA-YQ0okV2N-gwTWy_n51igWrPcsKQFm0cnqsvw,411
|
|
2
|
+
cad_to_dagmc/__init__.py,sha256=fskHUTyCunSpnpJUvBfAYjx4uwDKXHTTiMP6GqnFRf0,494
|
|
3
|
+
cad_to_dagmc/core.py,sha256=eMwKgKOjje3gBZEqjNzy9O6NF8a02WxD-VhXB5AJg58,18108
|
|
4
|
+
cad_to_dagmc-0.6.0.dist-info/LICENSE,sha256=B8kznH_777JVNZ3HOKDc4Tj24F7wJ68ledaNYeL9sCw,1070
|
|
5
|
+
cad_to_dagmc-0.6.0.dist-info/METADATA,sha256=Zrz_-X2KkLAoKrucNIcvOr1070dmSxq10ytsfqU5oWA,6771
|
|
6
|
+
cad_to_dagmc-0.6.0.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
|
7
|
+
cad_to_dagmc-0.6.0.dist-info/top_level.txt,sha256=zTi8C64SEBsE5WOtPovnxhOzt-E6Oc5nC3RW6M_5aEA,22
|
|
8
|
+
cad_to_dagmc-0.6.0.dist-info/RECORD,,
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
_version.py,sha256=8W5N0WKS0YIWUpfry5TouisDYjsMUIZ7Vc0crGGGQQU,411
|
|
2
|
-
cad_to_dagmc/__init__.py,sha256=fskHUTyCunSpnpJUvBfAYjx4uwDKXHTTiMP6GqnFRf0,494
|
|
3
|
-
cad_to_dagmc/core.py,sha256=rLJT6RhmaqQ2NQm9Nyxj1pqSz5TC0pgET0CvpQFI3TM,16643
|
|
4
|
-
cad_to_dagmc-0.5.1.dist-info/LICENSE,sha256=B8kznH_777JVNZ3HOKDc4Tj24F7wJ68ledaNYeL9sCw,1070
|
|
5
|
-
cad_to_dagmc-0.5.1.dist-info/METADATA,sha256=4RxJjQNV7RKMmB_xprO8LJ_OyuLSMlklUtmqaQvtyvo,5583
|
|
6
|
-
cad_to_dagmc-0.5.1.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
|
|
7
|
-
cad_to_dagmc-0.5.1.dist-info/top_level.txt,sha256=zTi8C64SEBsE5WOtPovnxhOzt-E6Oc5nC3RW6M_5aEA,22
|
|
8
|
-
cad_to_dagmc-0.5.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|