From 6c6676cc14861abb84b732ac607d59df9c60b80e Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Mon, 28 Sep 2015 19:01:10 +0700 Subject: [PATCH] Have openmc-update-inputs change 'surfaces' to 'region' --- examples/xml/basic/geometry.xml | 4 ++-- examples/xml/reflective/geometry.xml | 8 ++++---- scripts/openmc-update-inputs | 27 ++++++++++++++++++--------- tests/test_cmfd_feed/geometry.xml | 4 ++-- tests/test_cmfd_nofeed/geometry.xml | 4 ++-- 5 files changed, 28 insertions(+), 19 deletions(-) diff --git a/examples/xml/basic/geometry.xml b/examples/xml/basic/geometry.xml index b7de2c1346..b30884f8ca 100644 --- a/examples/xml/basic/geometry.xml +++ b/examples/xml/basic/geometry.xml @@ -5,11 +5,11 @@ - + - + diff --git a/examples/xml/reflective/geometry.xml b/examples/xml/reflective/geometry.xml index 664ef0705f..51cdf1ecb0 100644 --- a/examples/xml/reflective/geometry.xml +++ b/examples/xml/reflective/geometry.xml @@ -5,15 +5,15 @@ 0 1 - 1 -2 3 -4 5 -6 + 1 -2 3 -4 5 -6 - + - + - + diff --git a/scripts/openmc-update-inputs b/scripts/openmc-update-inputs index f2e5308d02..1ff70d0505 100755 --- a/scripts/openmc-update-inputs +++ b/scripts/openmc-update-inputs @@ -1,14 +1,15 @@ #!/usr/bin/env python """Update OpenMC's input XML files to the latest format. -Usage information can be obtained by running 'update_inputs.py --help': +Usage information can be obtained by running 'openmc-update-inputs --help': -usage: update_lattices.py [-h] IN [IN ...] +usage: openmc-update-inputs [-h] IN [IN ...] -Update lattices in geometry.xml files to the latest format. This will remove -'outside' attributes/elements and replace them with 'outer' attributes. Note -that this script will not delete the given files; it will append '.original' -to the given files and write new ones. +Update geometry.xml files to the latest format. This will remove 'outside' +attributes/elements from lattices and replace them with 'outer' attributes. For +'cell' elements, any 'surfaces' attributes/elements will be renamed +'region'. Note that this script will not delete the given files; it will append +'.original' to the given files and write new ones. positional arguments: IN Input geometry.xml file(s). @@ -173,9 +174,6 @@ def update_geometry(geometry_root): root = geometry_root was_updated = False - # Ignore files that do not contain lattices. - if all([child.tag != 'lattice' for child in root]): return False - # Get a set of already-used universe and cell ids. uids = get_universe_ids(root) cids = get_cell_ids(root) @@ -233,6 +231,17 @@ def update_geometry(geometry_root): del lat.attrib['width'] was_updated = True + # Change 'surfaces' to 'region' in cell definitions + for cell in root.iter('cell'): + elem = cell.find('surfaces') + if elem is not None: + elem.tag = 'region' + was_updated = True + if 'surfaces' in cell.attrib: + cell.attrib['region'] = cell.attrib['surfaces'] + del cell.attrib['surfaces'] + was_updated = True + return was_updated diff --git a/tests/test_cmfd_feed/geometry.xml b/tests/test_cmfd_feed/geometry.xml index 57c4aa2285..73ea679c4c 100644 --- a/tests/test_cmfd_feed/geometry.xml +++ b/tests/test_cmfd_feed/geometry.xml @@ -4,7 +4,7 @@ 0 - -1 2 -3 4 -5 6 + -1 2 -3 4 -5 6 1 @@ -39,5 +39,5 @@ -1 reflective - + diff --git a/tests/test_cmfd_nofeed/geometry.xml b/tests/test_cmfd_nofeed/geometry.xml index 57c4aa2285..73ea679c4c 100644 --- a/tests/test_cmfd_nofeed/geometry.xml +++ b/tests/test_cmfd_nofeed/geometry.xml @@ -4,7 +4,7 @@ 0 - -1 2 -3 4 -5 6 + -1 2 -3 4 -5 6 1 @@ -39,5 +39,5 @@ -1 reflective - +