9 #include "HDF5Interface.h"
10 #include "pugixml.hpp"
13 #include <dolfinx/common/utils.h>
14 #include <dolfinx/mesh/cell_types.h>
18 #include <xtl/xspan.hpp>
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<double> get_point_data_values(
const fem::Function<double>& u);
66 std::vector<std::complex<double>>
67 get_point_data_values(
const fem::Function<std::complex<double>>& u);
70 std::vector<double> get_cell_data_values(
const fem::Function<double>& u);
71 std::vector<std::complex<double>>
72 get_cell_data_values(
const fem::Function<std::complex<double>>& u);
75 std::string vtk_cell_type_str(
mesh::CellType cell_type,
int num_nodes);
96 std::pair<xt::xtensor<std::int32_t, 2>, std::vector<std::int32_t>>
97 extract_local_entities(
const mesh::Mesh& mesh,
int entity_dim,
98 const xt::xtensor<std::int64_t, 2>& entities,
99 const xtl::span<const std::int32_t>& values);
102 template <
typename T>
103 void add_data_item(pugi::xml_node& xml_node,
const hid_t h5_id,
104 const std::string h5_path,
const T& x,
105 const std::int64_t offset,
106 const std::vector<std::int64_t> shape,
107 const std::string number_type,
const bool use_mpi_io)
111 pugi::xml_node data_item_node = xml_node.append_child(
"DataItem");
112 assert(data_item_node);
117 dims += std::to_string(d) +
" ";
119 data_item_node.append_attribute(
"Dimensions") = dims.c_str();
123 if (!number_type.empty())
124 data_item_node.append_attribute(
"NumberType") = number_type.c_str();
129 data_item_node.append_attribute(
"Format") =
"XML";
130 assert(shape.size() == 2);
131 data_item_node.append_child(pugi::node_pcdata)
136 data_item_node.append_attribute(
"Format") =
"HDF";
143 const std::string xdmf_path = filename +
":" + h5_path;
144 data_item_node.append_child(pugi::node_pcdata).set_value(xdmf_path.c_str());
147 assert(!shape.empty());
148 std::int64_t num_items_total = 1;
150 num_items_total *= n;
153 std::int64_t local_shape0 = x.size();
154 for (std::size_t i = 1; i < shape.size(); ++i)
156 assert(local_shape0 % shape[i] == 0);
157 local_shape0 /= shape[i];
160 const std::array local_range{offset, offset + local_shape0};