Skip to content

Commit 4011b7a

Browse files
yrrepypaulromano
andauthored
Optional separation of mesh-material-volume calc from get_homogenized_materials (#3581)
Co-authored-by: Paul Romano <[email protected]>
1 parent 781dbf9 commit 4011b7a

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

openmc/mesh.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ def get_homogenized_materials(
287287
model: openmc.Model,
288288
n_samples: int | tuple[int, int, int] = 10_000,
289289
include_void: bool = True,
290+
material_volumes: MeshMaterialVolumes | None = None,
290291
**kwargs
291292
) -> list[openmc.Material]:
292293
"""Generate homogenized materials over each element in a mesh.
@@ -305,16 +306,23 @@ def get_homogenized_materials(
305306
the x, y, and z dimensions.
306307
include_void : bool, optional
307308
Whether homogenization should include voids.
309+
material_volumes : MeshMaterialVolumes, optional
310+
Previously computed mesh material volumes to use for homogenization.
311+
If not provided, they will be computed by calling
312+
:meth:`material_volumes`.
308313
**kwargs
309-
Keyword-arguments passed to :meth:`MeshBase.material_volumes`.
314+
Keyword-arguments passed to :meth:`material_volumes`.
310315
311316
Returns
312317
-------
313318
list of openmc.Material
314319
Homogenized material in each mesh element
315320
316321
"""
317-
vols = self.material_volumes(model, n_samples, **kwargs)
322+
if material_volumes is None:
323+
vols = self.material_volumes(model, n_samples, **kwargs)
324+
else:
325+
vols = material_volumes
318326
mat_volume_by_element = [vols.by_element(i) for i in range(vols.num_elements)]
319327

320328
# Create homogenized material for each element
@@ -424,7 +432,6 @@ def material_volumes(
424432

425433
# Restore original tallies
426434
model.tallies = original_tallies
427-
428435
return volumes
429436

430437

0 commit comments

Comments
 (0)