9 #include "HDF5Interface.h"
10 #include "pugixml.hpp"
12 #include <dolfinx/common/utils.h>
13 #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);
56 get_hdf5_filename(
const std::filesystem::path& xdmf_filename);
59 std::vector<std::int64_t> get_dataset_shape(
const pugi::xml_node& dataset_node);
62 std::int64_t get_num_cells(
const pugi::xml_node& topology_node);
66 std::vector<double> get_point_data_values(
const fem::Function<double>& u);
67 std::vector<std::complex<double>>
68 get_point_data_values(
const fem::Function<std::complex<double>>& u);
71 std::vector<double> get_cell_data_values(
const fem::Function<double>& u);
72 std::vector<std::complex<double>>
73 get_cell_data_values(
const fem::Function<std::complex<double>>& u);
76 std::string vtk_cell_type_str(
mesh::CellType cell_type,
int num_nodes);
97 std::pair<xt::xtensor<std::int32_t, 2>, std::vector<std::int32_t>>
98 extract_local_entities(
const mesh::Mesh& mesh,
int entity_dim,
99 const xt::xtensor<std::int64_t, 2>& entities,
100 const xtl::span<const std::int32_t>& values);
103 template <
typename T>
104 void add_data_item(pugi::xml_node& xml_node,
const hid_t h5_id,
105 const std::string h5_path,
const T& x,
106 const std::int64_t offset,
107 const std::vector<std::int64_t> shape,
108 const std::string number_type,
const bool use_mpi_io)
112 pugi::xml_node data_item_node = xml_node.append_child(
"DataItem");
113 assert(data_item_node);
118 dims += std::to_string(d) +
" ";
120 data_item_node.append_attribute(
"Dimensions") = dims.c_str();
124 if (!number_type.empty())
125 data_item_node.append_attribute(
"NumberType") = number_type.c_str();
130 data_item_node.append_attribute(
"Format") =
"XML";
131 assert(shape.size() == 2);
132 data_item_node.append_child(pugi::node_pcdata)
137 data_item_node.append_attribute(
"Format") =
"HDF";
141 const std::filesystem::path filename = p.filename().c_str();
144 const std::string xdmf_path = filename.string() +
":" + h5_path;
145 data_item_node.append_child(pugi::node_pcdata).set_value(xdmf_path.c_str());
148 assert(!shape.empty());
149 std::int64_t num_items_total = 1;
151 num_items_total *= n;
154 std::int64_t local_shape0 = x.size();
155 for (std::size_t i = 1; i < shape.size(); ++i)
157 assert(local_shape0 % shape[i] == 0);
158 local_shape0 /= shape[i];
161 const std::array
local_range{offset, offset + local_shape0};
static std::filesystem::path get_filename(hid_t handle)
Get filename.
Definition: HDF5Interface.cpp:132
static void write_dataset(const hid_t handle, const std::string &dataset_path, const T *data, const std::array< std::int64_t, 2 > &range, const std::vector< std::int64_t > &global_size, bool use_mpi_io, bool use_chunking)
Write data to existing HDF file as defined by range blocks on each process.
constexpr std::array< std::int64_t, 2 > local_range(int rank, std::int64_t N, int size)
Return local range for given process, splitting [0, N - 1] into size() portions of almost equal size.
Definition: MPI.h:109
std::string container_to_string(const T &x, const int precision, const int linebreak)
Convert a container to string.
Definition: utils.h:62
CellType
Cell type identifier.
Definition: cell_types.h:22