mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 14:15:42 -04:00
Writing all output under a single root node
This commit is contained in:
parent
ad746cb3e1
commit
a09a61e77b
2 changed files with 10 additions and 3 deletions
|
|
@ -1449,16 +1449,19 @@ class Materials(cv.CheckedList):
|
|||
for material in self:
|
||||
material.make_isotropic_in_lab()
|
||||
|
||||
def _write_xml(self, file):
|
||||
def _write_xml(self, file, header=True):
|
||||
"""Writes XML content of the materials to an open file handle.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
file : IOTextWrapper
|
||||
Open file handle to write content into.
|
||||
header : bool
|
||||
Whether or not to write the XML header
|
||||
"""
|
||||
# Write the header and the opening tag for the root element.
|
||||
file.write("<?xml version='1.0' encoding='utf-8'?>\n")
|
||||
if header:
|
||||
file.write("<?xml version='1.0' encoding='utf-8'?>\n")
|
||||
file.write('<materials>\n')
|
||||
|
||||
# Write the <cross_sections> element.
|
||||
|
|
|
|||
|
|
@ -444,9 +444,12 @@ class Model:
|
|||
|
||||
with open(d, 'w', encoding='utf-8',
|
||||
errors='xmlcharrefreplace') as fh:
|
||||
# write the XML header
|
||||
fh.write("<?xml version='1.0' encoding='utf-8'?>\n")
|
||||
fh.write("<model>\n")
|
||||
# Write the materials collection to the open XML file first.
|
||||
# This will write the XML header also
|
||||
materials._write_xml(fh)
|
||||
materials._write_xml(fh, False)
|
||||
# Write remaining elements as a tree
|
||||
ET.ElementTree(geometry_element).write(fh, encoding='unicode')
|
||||
ET.ElementTree(settings_element).write(fh, encoding='unicode')
|
||||
|
|
@ -457,6 +460,7 @@ class Model:
|
|||
if self.plots:
|
||||
plots_element = self.plots.to_xml_element()
|
||||
ET.ElementTree(plots_element).write(fh, encoding='unicode')
|
||||
fh.write("</model>\n")
|
||||
|
||||
def import_properties(self, filename):
|
||||
"""Import physical properties
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue