9 #include "HDF5Interface.h"
10 #include "pugixml.hpp"
12 #include <boost/filesystem.hpp>
13 #include <dolfinx/common/utils.h>
14 #include <dolfinx/mesh/cell_types.h>
33 namespace io::xdmf_utils
38 std::pair<std::string, int> get_cell_type(
const pugi::xml_node& topology_node);
42 std::array<std::string, 2> get_hdf5_paths(
const pugi::xml_node& dataitem_node);
44 std::string get_hdf5_filename(std::string xdmf_filename);
47 std::vector<std::int64_t> get_dataset_shape(
const pugi::xml_node& dataset_node);
50 std::int64_t get_num_cells(
const pugi::xml_node& topology_node);
54 std::vector<PetscScalar> get_point_data_values(
const function::Function& u);
57 std::vector<PetscScalar> get_cell_data_values(
const function::Function& u);
60 std::string vtk_cell_type_str(
mesh::CellType cell_type,
int num_nodes);
64 void add_data_item(pugi::xml_node& xml_node,
const hid_t h5_id,
65 const std::string h5_path,
const T& x,
66 const std::int64_t offset,
67 const std::vector<std::int64_t> shape,
68 const std::string number_type,
const bool use_mpi_io)
72 pugi::xml_node data_item_node = xml_node.append_child(
"DataItem");
73 assert(data_item_node);
78 dims += std::to_string(d) +
" ";
80 data_item_node.append_attribute(
"Dimensions") = dims.c_str();
84 if (!number_type.empty())
85 data_item_node.append_attribute(
"NumberType") = number_type.c_str();
90 data_item_node.append_attribute(
"Format") =
"XML";
91 assert(shape.size() == 2);
92 data_item_node.append_child(pugi::node_pcdata)
97 data_item_node.append_attribute(
"Format") =
"HDF";
101 const boost::filesystem::path p(hdf5_filename);
104 const std::string xdmf_path = p.filename().string() +
":" + h5_path;
105 data_item_node.append_child(pugi::node_pcdata).set_value(xdmf_path.c_str());
108 assert(!shape.empty());
109 std::int64_t num_items_total = 1;
111 num_items_total *= n;
114 std::int64_t local_shape0 = x.size();
115 for (std::size_t i = 1; i < shape.size(); ++i)
117 assert(local_shape0 % shape[i] == 0);
118 local_shape0 /= shape[i];
121 const std::array<std::int64_t, 2> local_range
122 = {{offset, offset + local_shape0}};