mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 13:45:36 -04:00
Adding a from_xml method to the DAGUniverse class. Ensuring DAGMC universes are read into geometries from XML files.
This commit is contained in:
parent
9c849f4058
commit
e2826fa57b
2 changed files with 22 additions and 0 deletions
|
|
@ -198,6 +198,11 @@ class Geometry:
|
|||
if c.fill_type in ('universe', 'lattice'):
|
||||
child_of[c.fill].append(c)
|
||||
|
||||
# Add any DAGMC universes
|
||||
for elem in root.findall('dagmc_universe'):
|
||||
dag_univ = openmc.DAGMCUniverse.from_xml(elem)
|
||||
universes[dag_univ.id] = dag_univ
|
||||
|
||||
# Determine which universe is the root by finding one which is not a
|
||||
# child of any other object
|
||||
for u in universes.values():
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import numpy as np
|
|||
|
||||
import openmc
|
||||
import openmc.checkvalue as cv
|
||||
from ._xml import get_text
|
||||
from .mixin import IDManagerMixin
|
||||
from .plots import _SVG_COLORS
|
||||
|
||||
|
|
@ -729,3 +730,19 @@ class DAGMCUniverse(UniverseBase):
|
|||
dagmc_element.set('auto_mat_ids', 'true')
|
||||
dagmc_element.set('filename', self.filename)
|
||||
xml_element.append(dagmc_element)
|
||||
|
||||
@classmethod
|
||||
def from_xml(cls, elem):
|
||||
id = int(get_text(elem, 'id'))
|
||||
fname = get_text(elem, 'filename')
|
||||
|
||||
out = cls(fname, universe_id=id)
|
||||
|
||||
name = get_text(elem, 'name')
|
||||
if name is not None:
|
||||
out.name = name
|
||||
|
||||
out.auto_geom_ids = bool(elem.get('auto_geom_ids'))
|
||||
out.auto_mat_ids = bool(elem.get('auto_mat_ids'))
|
||||
|
||||
return out
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue