cad-to-dagmc 0.5.1__py3-none-any.whl → 0.6.1__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.6.1.dist-info/METADATA +180 -0
- cad_to_dagmc-0.6.1.dist-info/RECORD +8 -0
- {cad_to_dagmc-0.5.1.dist-info → cad_to_dagmc-0.6.1.dist-info}/WHEEL +1 -1
- cad_to_dagmc-0.5.1.dist-info/METADATA +0 -120
- cad_to_dagmc-0.5.1.dist-info/RECORD +0 -8
- {cad_to_dagmc-0.5.1.dist-info → cad_to_dagmc-0.6.1.dist-info}/LICENSE +0 -0
- {cad_to_dagmc-0.5.1.dist-info → cad_to_dagmc-0.6.1.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
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: cad_to_dagmc
|
|
3
|
+
Version: 0.6.1
|
|
4
|
+
Summary: Converts CAD files to a DAGMC h5m file
|
|
5
|
+
Author-email: Jonathan Shimwell <mail@jshimwell.com>
|
|
6
|
+
Project-URL: Homepage, https://github.com/fusion-energy/cad_to_dagmc
|
|
7
|
+
Project-URL: Bug Tracker, https://github.com/fusion-energy/cad_to_dagmc/issues
|
|
8
|
+
Keywords: dagmc,geometry,plot,slice
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Requires-Python: >=3.8
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
License-File: LICENSE
|
|
15
|
+
Requires-Dist: trimesh
|
|
16
|
+
Requires-Dist: networkx
|
|
17
|
+
Requires-Dist: cadquery-ocp >=7.7.2
|
|
18
|
+
Requires-Dist: cadquery >=2.4.0
|
|
19
|
+
Provides-Extra: tests
|
|
20
|
+
Requires-Dist: pytest ; extra == 'tests'
|
|
21
|
+
Requires-Dist: vtk ; extra == 'tests'
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
[](https://www.python.org)
|
|
25
|
+
|
|
26
|
+
[](https://github.com/fusion-energy/cad_to_dagmc/actions/workflows/ci_with_install.yml) Testing package and running examples
|
|
27
|
+
|
|
28
|
+
[](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)
|
|
29
|
+
|
|
30
|
+
[](https://github.com/fusion-energy/cad_to_dagmc/actions/workflows/python-publish.yml)
|
|
31
|
+
|
|
32
|
+
[](https://pypi.org/project/cad_to_dagmc/)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
A minimal package that converts CAD geometry to [DAGMC](https://github.com/svalinn/DAGMC/) h5m files
|
|
36
|
+
|
|
37
|
+
cad-to-dagmc can create:
|
|
38
|
+
- surface meshes / faceted geometry / triangular meshes
|
|
39
|
+
- unstructured mesh / tetrahedral meshes / volume meshes
|
|
40
|
+
|
|
41
|
+
cad-to-dagmc can convert:
|
|
42
|
+
- STEP files
|
|
43
|
+
- CadQuery objects (in memory)
|
|
44
|
+
|
|
45
|
+
cad-to-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.
|
|
46
|
+
|
|
47
|
+
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/).
|
|
48
|
+
|
|
49
|
+
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.
|
|
50
|
+
|
|
51
|
+
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/)
|
|
52
|
+
|
|
53
|
+
# Installation options
|
|
54
|
+
|
|
55
|
+
- Install using Mamba and pip
|
|
56
|
+
- Install using Conda and pip
|
|
57
|
+
- Install using pip and source compilations
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
## Install using Mamba and pip
|
|
61
|
+
|
|
62
|
+
In principle, installing any Conda/Mamba distribution will work. A few Conda/Mamba options are:
|
|
63
|
+
- [Miniforge](https://github.com/conda-forge/miniforge) (recommended as it includes mamba)
|
|
64
|
+
- [Anaconda](https://www.anaconda.com/download)
|
|
65
|
+
- [Miniconda](https://docs.conda.io/en/latest/miniconda.html)
|
|
66
|
+
|
|
67
|
+
This example assumes you have installed the Miniforge option or separately have installed Mamba with ```conda install -c conda-forge mamba -y```
|
|
68
|
+
|
|
69
|
+
Create a new conda environment, I've chosen Python 3.10 here but newer versions are
|
|
70
|
+
also supported.
|
|
71
|
+
```bash
|
|
72
|
+
mamba create --name new_env python=3.10 -y
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Activate the environment
|
|
76
|
+
```bash
|
|
77
|
+
mamba activate new_env
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Install the dependencies
|
|
81
|
+
```bash
|
|
82
|
+
mamba install -y -c conda-forge "moab>=5.3.0" gmsh python-gmsh
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Then you can install the cad_to_dagmc package with ```pip```
|
|
86
|
+
```bash
|
|
87
|
+
pip install cad_to_dagmc
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
## Install using Conda and pip
|
|
92
|
+
|
|
93
|
+
In principle, installing any Conda/Mamba distribution will work. A few Conda/Mamba options are:
|
|
94
|
+
- [Miniforge](https://github.com/conda-forge/miniforge) (recommended as it includes mamba)
|
|
95
|
+
- [Anaconda](https://www.anaconda.com/download)
|
|
96
|
+
- [Miniconda](https://docs.conda.io/en/latest/miniconda.html)
|
|
97
|
+
|
|
98
|
+
This example uses Conda to install some dependencies that are not available via PyPi.
|
|
99
|
+
|
|
100
|
+
Create a new conda environment
|
|
101
|
+
```bash
|
|
102
|
+
conda create --name new_env python=3.10 -y
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Activate the environment
|
|
106
|
+
```bash
|
|
107
|
+
conda activate new_env
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Install the dependencies
|
|
111
|
+
```bash
|
|
112
|
+
conda install -y -c conda-forge "moab>=5.3.0" gmsh python-gmsh
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
Then you can install the cad_to_dagmc package with ```pip```
|
|
116
|
+
```bash
|
|
117
|
+
pip install cad_to_dagmc
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## Install using pip and source compilations
|
|
121
|
+
|
|
122
|
+
It should possible to avoid the use of conda and installing using pip and compiling from source.
|
|
123
|
+
|
|
124
|
+
First compile MOAB (and install Pymoab) from source
|
|
125
|
+
|
|
126
|
+
Then install gmsh from source (installing from pip appears to cause conflicts with the open cascade used in ocp and cadquery)
|
|
127
|
+
|
|
128
|
+
Then you can install the cad_to_dagmc package with ```pip```
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
pip install cad_to_dagmc
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
## Install with transport code (e.g OpenMC)
|
|
135
|
+
|
|
136
|
+
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/).
|
|
137
|
+
|
|
138
|
+
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
|
|
139
|
+
```bash
|
|
140
|
+
mamba install -c conda-forge -y "openmc=0.14.0=dagmc*nompi*"
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
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.
|
|
144
|
+
|
|
145
|
+
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.
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
# Known incompatibilities
|
|
150
|
+
|
|
151
|
+
The package requires newer versions of Linux. For example the package does not work on Ubuntu 18.04 or older.
|
|
152
|
+
|
|
153
|
+
The package requires newer versions of pip. It is recommended to ensure that your version of pip is up to date. This can be done with ```python -m pip install --upgrade pip```
|
|
154
|
+
|
|
155
|
+
Installing one of the package dependancies (gmsh) with pip appears to result in occational errors when passing cad objects between cadquery / ocp and gmsh. The conda install gmsh appears to work fine.
|
|
156
|
+
|
|
157
|
+
# Usage - with OpenMC
|
|
158
|
+
|
|
159
|
+
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/).
|
|
160
|
+
|
|
161
|
+
You can run ```mamba install -c conda-forge openmc``` however this may choose to install OpenMC without DAGMC included.
|
|
162
|
+
|
|
163
|
+
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
|
|
164
|
+
```bash
|
|
165
|
+
mamba install -c conda-forge -y "openmc=0.14.0=dagmc*nompi*"
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
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.
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
# Usage - creation of DAGMC h5m files
|
|
173
|
+
|
|
174
|
+
For examples see the [examples folder](https://github.com/fusion-energy/cad_to_dagmc/tree/main/examples)
|
|
175
|
+
|
|
176
|
+
# Usage - simulation with transport code
|
|
177
|
+
|
|
178
|
+
For examples see the [examples folder](https://github.com/fusion-energy/cad_to_dagmc/tree/main/examples)
|
|
179
|
+
|
|
180
|
+
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=lgiCYGSijhLK71WmuudWf_AyhNAutwQWx2V8bV6a5VQ,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.1.dist-info/LICENSE,sha256=B8kznH_777JVNZ3HOKDc4Tj24F7wJ68ledaNYeL9sCw,1070
|
|
5
|
+
cad_to_dagmc-0.6.1.dist-info/METADATA,sha256=Fw_uOmqvNJCm1-XPMr1vy4fWgxWW4ZPmqSgCJouGmr4,8183
|
|
6
|
+
cad_to_dagmc-0.6.1.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
|
7
|
+
cad_to_dagmc-0.6.1.dist-info/top_level.txt,sha256=zTi8C64SEBsE5WOtPovnxhOzt-E6Oc5nC3RW6M_5aEA,22
|
|
8
|
+
cad_to_dagmc-0.6.1.dist-info/RECORD,,
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: cad-to-dagmc
|
|
3
|
-
Version: 0.5.1
|
|
4
|
-
Summary: Converts CAD files to a DAGMC h5m file
|
|
5
|
-
Author-email: Jonathan Shimwell <mail@jshimwell.com>
|
|
6
|
-
Project-URL: Homepage, https://github.com/fusion-energy/cad_to_dagmc
|
|
7
|
-
Project-URL: Bug Tracker, https://github.com/fusion-energy/cad_to_dagmc/issues
|
|
8
|
-
Keywords: dagmc,geometry,plot,slice
|
|
9
|
-
Classifier: Programming Language :: Python :: 3
|
|
10
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
-
Classifier: Operating System :: OS Independent
|
|
12
|
-
Requires-Python: >=3.8
|
|
13
|
-
Description-Content-Type: text/markdown
|
|
14
|
-
License-File: LICENSE
|
|
15
|
-
Requires-Dist: trimesh
|
|
16
|
-
Requires-Dist: networkx
|
|
17
|
-
Provides-Extra: tests
|
|
18
|
-
Requires-Dist: pytest ; extra == 'tests'
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
[](https://www.python.org)
|
|
22
|
-
|
|
23
|
-
[](https://github.com/fusion-energy/cad_to_dagmc/actions/workflows/ci_with_benchmarks.yml) Testing package and running examples
|
|
24
|
-
|
|
25
|
-
[](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
|
-
[](https://github.com/fusion-energy/cad_to_dagmc/actions/workflows/python-publish.yml)
|
|
28
|
-
|
|
29
|
-
[](https://pypi.org/project/cad_to_dagmc/)
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
A minimal package that uses CadQuery functionality to convert CAD geometry to [DAGMC](https://github.com/svalinn/DAGMC/) h5m files
|
|
33
|
-
|
|
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
|
-
|
|
36
|
-
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
|
-
|
|
38
|
-
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
|
-
|
|
40
|
-
Also checkout these other packages that also create DAGMC geometry [CAD-to-OpenMC](https://github.com/openmsr/CAD_to_OpenMC), [Stellarmesh](https://github.com/Thea-Energy/stellarmesh)
|
|
41
|
-
|
|
42
|
-
# Installation prerequisite
|
|
43
|
-
|
|
44
|
-
In principle, any Conda/Mamba distribution will work. A few Conda/Mamba options are:
|
|
45
|
-
- [Mambaforge](https://github.com/conda-forge/miniforge#mambaforge)
|
|
46
|
-
- [Miniforge](https://github.com/conda-forge/miniforge#miniforge-pypy3)
|
|
47
|
-
- [Anaconda](https://www.anaconda.com/download)
|
|
48
|
-
- [Miniconda](https://docs.conda.io/en/latest/miniconda.html)
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
# Install using Mamba and pip
|
|
52
|
-
|
|
53
|
-
This example assumes you have installed the MambaForge option or separately
|
|
54
|
-
installed Mamba with ```conda install -c conda-forge mamba -y```
|
|
55
|
-
|
|
56
|
-
Create a new conda environment, I've chosen Python 3.9 here but new versions are
|
|
57
|
-
also supported.
|
|
58
|
-
```bash
|
|
59
|
-
mamba create --name new_env python=3.9 -y
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
Activate the environment
|
|
63
|
-
```bash
|
|
64
|
-
mamba activate new_env
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
Install the dependencies
|
|
68
|
-
```bash
|
|
69
|
-
mamba install -c cadquery -c conda-forge moab gmsh python-gmsh cadquery=master -y
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
Then you can install the cad_to_dagmc package with ```pip```
|
|
73
|
-
```bash
|
|
74
|
-
pip install cad_to_dagmc
|
|
75
|
-
```
|
|
76
|
-
|
|
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/).You can run ```conda 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
|
-
```bash
|
|
79
|
-
mamba install -c conda-forge -y "openmc=0.13.3=dagmc*nompi*"
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
# Install using Conda and pip
|
|
84
|
-
|
|
85
|
-
This example uses Conda to install some dependencies that are not available via PyPi.
|
|
86
|
-
|
|
87
|
-
Create a new conda environment
|
|
88
|
-
```bash
|
|
89
|
-
conda create --name new_env python=3.9 -y
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
Activate the environment
|
|
93
|
-
```bash
|
|
94
|
-
conda activate new_env
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
Install the dependencies
|
|
98
|
-
```bash
|
|
99
|
-
conda install -c cadquery -c conda-forge moab gmsh python-gmsh cadquery=master -y
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
Then you can install the cad_to_dagmc package with ```pip```
|
|
103
|
-
```bash
|
|
104
|
-
pip install cad_to_dagmc
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
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/).You can run ```conda 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
|
|
108
|
-
```bash
|
|
109
|
-
conda install -c conda-forge -y "openmc=0.13.3=dagmc*nompi*"
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
# Usage - creation of DAGMC h5m files
|
|
115
|
-
|
|
116
|
-
For examples see the [examples folder](https://github.com/fusion-energy/cad_to_dagmc/tree/main/examples)
|
|
117
|
-
|
|
118
|
-
# Usage - simulation with transport code
|
|
119
|
-
|
|
120
|
-
For examples see the CAD tasks in the [neutronics-workshop](https://github.com/fusion-energy/neutronics-workshop)
|
|
@@ -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
|