68 const pugi::xml_node array = xml_node.child(
"array");
72 "read array from XML file",
73 "Unable to find <array> tag in XML file");
77 const std::size_t size = array.attribute(
"size").as_uint();
78 const std::string type = array.attribute(
"type").value();
82 "read array from XML file",
83 "XML I/O of Array objects only supported when the value type is 'double'");
89 for (pugi::xml_node_iterator it = array.begin(); it != array.end(); ++it)
91 const std::size_t index = it->attribute(
"index").as_uint();
92 const double value = it->attribute(
"value").as_double();
93 dolfin_assert(index < size);
94 indices[index] = index;
101 pugi::xml_node xml_node)
104 pugi::xml_node array_node = xml_node.append_child(
"array");
107 const std::size_t size = x.size();
108 array_node.append_attribute(
"type") = type.c_str();
109 array_node.append_attribute(
"size") = (
unsigned int) size;
112 for (std::size_t i = 0; i < size; ++i)
114 pugi::xml_node element_node = array_node.append_child(
"element");
115 element_node.append_attribute(
"index") = (
unsigned int) i;
118 element_node.append_attribute(
"value")
119 = boost::str(boost::format(
"%.15e") % x[i]).c_str();
static void write(const std::vector< T > &x, const std::string type, pugi::xml_node xml_node)
Write the XML file.
Definition XMLArray.h:100