xdmf: handle point data
@@ -305,7 +305,6 @@ def write(filename,
field_data=None,
pretty_xml=True
):
- # if len(cells) > 1:
# from .legacy_writer import write as w
# w('xdmf3', filename, points, cells, point_data, cell_data, field_data)
# exit(1)
@@ -367,6 +366,20 @@ def write(filename,
])
data_item.text += numpy_to_xml_string(d, '%d')
+ # point data
+ for name, data in point_data.items():
+ att = ET.SubElement(
+ grid, 'Attribute',
+ Name=name, Type='None', Center='Node'
+ )
+ dt, prec = numpy_to_xdmf_dtype[data.dtype]
+ dim = ' '.join([str(s) for s in data.shape])
+ data_item = ET.SubElement(
+ att, 'DataItem',
+ DataType=dt, Dimensions=dim, Format='XML', Precision=prec
+ )
+ data_item.text = numpy_to_xml_string(data, '%.15e')
+
ET.register_namespace('xi', 'http://www.w3.org/2001/XInclude')
write_xml(filename, xdmf_file, pretty_xml, indent=2)
