Skip to content

Commit cb95c78

Browse files
authored
Fix bug where the same mesh is written multiple times to settings.xml (#3418)
1 parent a7d1ceb commit cb95c78

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

openmc/settings.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1626,9 +1626,12 @@ def _create_weight_window_generators_subelement(self, root, mesh_memo=None):
16261626
if mesh_memo is not None and wwg.mesh.id in mesh_memo:
16271627
continue
16281628

1629-
root.append(wwg.mesh.to_xml_element())
1630-
if mesh_memo is not None:
1631-
mesh_memo.add(wwg.mesh.id)
1629+
# See if a <mesh> element already exists -- if not, add it
1630+
path = f"./mesh[@id='{wwg.mesh.id}']"
1631+
if root.find(path) is None:
1632+
root.append(wwg.mesh.to_xml_element())
1633+
if mesh_memo is not None:
1634+
mesh_memo.add(wwg.mesh.id)
16321635

16331636
def _create_weight_windows_file_element(self, root):
16341637
if self.weight_windows_file is not None:

0 commit comments

Comments
 (0)