From 3a5b218728e09fe802d031d96c0350f3414ce671 Mon Sep 17 00:00:00 2001 From: Rayan HADDAD <103775910+rayanhaddad169@users.noreply.github.com> Date: Fri, 4 Oct 2024 01:13:18 +0200 Subject: [PATCH] adapt the openmc-update-inputs script for surfaces (#3131) Co-authored-by: r.haddad --- scripts/openmc-update-inputs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/scripts/openmc-update-inputs b/scripts/openmc-update-inputs index 2d49c0626e..5ee1f1ca0b 100755 --- a/scripts/openmc-update-inputs +++ b/scripts/openmc-update-inputs @@ -1,7 +1,5 @@ #!/usr/bin/env python3 -"""Update OpenMC's input XML files to the latest format. - -""" +"""Update OpenMC's input XML files to the latest format.""" import argparse from itertools import chain @@ -201,6 +199,16 @@ def update_geometry(geometry_root): was_updated = True + for surface in root.findall('surface'): + for attribute in ['type', 'coeffs', 'boundary']: + if surface.find(attribute) is not None: + value = surface.find(attribute).text + surface.attrib[attribute] = value + + child_element = surface.find(attribute) + surface.remove(child_element) + was_updated = True + # Remove 'type' from lattice definitions. for lat in root.iter('lattice'): elem = lat.find('type') @@ -296,4 +304,4 @@ if __name__ == '__main__': move(fname, fname + '.original') # Write a new geometry file. - tree.write(fname, xml_declaration=True) + tree.write(fname, xml_declaration=True) \ No newline at end of file