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>
36 class CoordinateElement;
44 namespace io::xdmf_utils
49 std::pair<std::string, int> get_cell_type(
const pugi::xml_node& topology_node);
53 std::array<std::string, 2> get_hdf5_paths(
const pugi::xml_node& dataitem_node);
55 std::string get_hdf5_filename(std::string xdmf_filename);
58 std::vector<std::int64_t> get_dataset_shape(
const pugi::xml_node& dataset_node);
61 std::int64_t get_num_cells(
const pugi::xml_node& topology_node);
65 std::vector<PetscScalar>
66 get_point_data_values(
const function::Function<PetscScalar>& u);
69 std::vector<PetscScalar>
70 get_cell_data_values(
const function::Function<PetscScalar>& u);
73 std::string vtk_cell_type_str(
mesh::CellType cell_type,
int num_nodes);
82 Eigen::Array<std::int32_t, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>,
83 std::vector<std::int32_t>>
84 extract_local_entities(
85 const mesh::Mesh& mesh,
const int entity_dim,
86 const Eigen::Array<std::int64_t, Eigen::Dynamic, Eigen::Dynamic,
87 Eigen::RowMajor>& entities,
88 const std::vector<std::int32_t>& values);
92 void add_data_item(pugi::xml_node& xml_node,
const hid_t h5_id,
93 const std::string h5_path,
const T& x,
94 const std::int64_t offset,
95 const std::vector<std::int64_t> shape,
96 const std::string number_type,
const bool use_mpi_io)
100 pugi::xml_node data_item_node = xml_node.append_child(
"DataItem");
101 assert(data_item_node);
106 dims += std::to_string(d) +
" ";
108 data_item_node.append_attribute(
"Dimensions") = dims.c_str();
112 if (!number_type.empty())
113 data_item_node.append_attribute(
"NumberType") = number_type.c_str();
118 data_item_node.append_attribute(
"Format") =
"XML";
119 assert(shape.size() == 2);
120 data_item_node.append_child(pugi::node_pcdata)
125 data_item_node.append_attribute(
"Format") =
"HDF";
129 const boost::filesystem::path p(hdf5_filename);
132 const std::string xdmf_path = p.filename().string() +
":" + h5_path;
133 data_item_node.append_child(pugi::node_pcdata).set_value(xdmf_path.c_str());
136 assert(!shape.empty());
137 std::int64_t num_items_total = 1;
139 num_items_total *= n;
142 std::int64_t local_shape0 = x.size();
143 for (std::size_t i = 1; i < shape.size(); ++i)
145 assert(local_shape0 % shape[i] == 0);
146 local_shape0 /= shape[i];
149 const std::array local_range{offset, offset + local_shape0};