mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 22:26:08 -04:00
Adding checks to geometry.plot to avoid material name overlaps (#3458)
Co-authored-by: Patrick Shriwise <pshriwise@gmail.com>
This commit is contained in:
parent
3e32aed2da
commit
3d16d4b100
2 changed files with 31 additions and 10 deletions
|
|
@ -758,13 +758,27 @@ class Geometry:
|
|||
model.geometry = self
|
||||
model.materials = self.get_all_materials().values()
|
||||
|
||||
# Add placeholder materials for DAGMCUniverses
|
||||
universes = self.get_all_universes()
|
||||
for universe in universes.values():
|
||||
if isinstance(universe, openmc.DAGMCUniverse):
|
||||
for name in universe.material_names:
|
||||
mat_dag = openmc.Material(name=name)
|
||||
mat_dag.add_nuclide('H1', 1.0)
|
||||
model.materials.append(mat_dag)
|
||||
# collect all the material names from the geometry
|
||||
all_material_names = {m.name for m in model.materials if m.name is not None}
|
||||
|
||||
# makes a placeholder material for each material name if it isn't
|
||||
# already present on the model. These materials are otherwise missing
|
||||
# from the geometry and are needed for plotting.
|
||||
for universe in model.geometry.get_all_universes().values():
|
||||
if not isinstance(universe, openmc.DAGMCUniverse):
|
||||
continue
|
||||
for name in universe.material_names:
|
||||
# if this name is already present in the model, skip it
|
||||
# (this can happen if the same material name is used in multiple
|
||||
# universes)
|
||||
if name in all_material_names:
|
||||
continue
|
||||
# if the material name is not present on the model,
|
||||
# create a placeholder material with the same name
|
||||
# and add it to the model
|
||||
mat_dag = openmc.Material(name=name)
|
||||
mat_dag.add_nuclide('H1', 1.0)
|
||||
model.materials.append(mat_dag)
|
||||
all_material_names.add(name)
|
||||
|
||||
return model.plot(*args, **kwargs)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue