Adjust the read_meshes function to search only for mesh elements directly below the element passed in

This commit is contained in:
Patrick Shriwise 2023-02-03 22:51:51 -06:00
parent fc67b38ba4
commit 283e3ee6aa
2 changed files with 15 additions and 5 deletions

View file

@ -1940,12 +1940,22 @@ class UnstructuredMesh(MeshBase):
return cls(filename, library, mesh_id, '', length_multiplier)
def read_meshes(tree):
"""Reads all mesh nodes under an XML tree
def read_meshes(elem):
"""Reads all mesh nodes under a a given XML node
Parameters
----------
elem : xml.etree.ElementTree.Element
XML element
Returns
-------
OrderedDict
An ordered dictionary with mesh IDs as keys and openmc.MeshBase
instanaces as values
"""
out = OrderedDict()
root = tree.getroot()
for mesh_elem in root.iter('mesh'):
for mesh_elem in elem.findall('mesh'):
mesh = MeshBase.from_xml_element(mesh_elem)
out[mesh.id] = mesh

View file

@ -1762,5 +1762,5 @@ class Settings:
"""
tree = ET.parse(path)
root = tree.getroot()
meshes = read_meshes(tree)
meshes = read_meshes(root)
return cls.from_xml_element(root, meshes)