diff --git a/openmc/geometry.py b/openmc/geometry.py index 36cff94e30..13113338a5 100644 --- a/openmc/geometry.py +++ b/openmc/geometry.py @@ -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(): diff --git a/openmc/universe.py b/openmc/universe.py index 402609e2cb..6f27148ea9 100644 --- a/openmc/universe.py +++ b/openmc/universe.py @@ -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