12#include <dolfinx/mesh/MeshTags.h>
32template <std::
floating_po
int T>
34template <std::
floating_po
int T>
47template <std::
floating_po
int U>
48void add_mesh(MPI_Comm comm, pugi::xml_node& xml_node, hid_t h5_id,
61template <std::
floating_po
int U>
65 std::span<const std::int32_t> entities);
68template <std::
floating_po
int U>
70 std::string path_prefix,
79std::pair<std::variant<std::vector<float>, std::vector<double>>,
80 std::array<std::size_t, 2>>
89std::pair<std::vector<std::int64_t>, std::array<std::size_t, 2>>
93template <
typename T, std::
floating_po
int U>
96 hid_t h5_id,
const std::string& name)
98 spdlog::info(
"XDMF: add meshtags ({})", name.c_str());
100 const int dim = meshtags.
dim();
101 std::shared_ptr<const common::IndexMap> entity_map
102 = meshtags.
topology()->index_map(dim);
105 throw std::runtime_error(
"Missing entities. Did you forget to call "
106 "dolfinx::mesh::Topology::create_entities?");
108 const std::int32_t num_local_entities = entity_map->size_local();
111 auto it = std::ranges::lower_bound(meshtags.
indices(), num_local_entities);
112 const int num_active_entities = std::distance(meshtags.
indices().begin(), it);
114 const std::string path_prefix =
"/MeshTags/" + name;
117 std::span<const std::int32_t>(meshtags.
indices().data(),
118 num_active_entities));
121 pugi::xml_node attribute_node = xml_node.append_child(
"Attribute");
122 assert(attribute_node);
123 attribute_node.append_attribute(
"Name") = name.c_str();
124 attribute_node.append_attribute(
"AttributeType") =
"Scalar";
125 attribute_node.append_attribute(
"Center") =
"Cell";
127 std::int64_t global_num_values = 0;
128 const std::int64_t local_num_values = num_active_entities;
129 MPI_Allreduce(&local_num_values, &global_num_values, 1, MPI_INT64_T, MPI_SUM,
131 const std::int64_t num_local = num_active_entities;
132 std::int64_t offset = 0;
133 MPI_Exscan(&num_local, &offset, 1, MPI_INT64_T, MPI_SUM, comm);
135 xdmf_utils::add_data_item(
136 attribute_node, h5_id, path_prefix + std::string(
"/Values"),
137 std::span<const T>(meshtags.
values().data(), num_active_entities), offset,
138 {global_num_values, 1},
"", use_mpi_io);
Geometry stores the geometry imposed on a mesh.
Definition Geometry.h:34
A Mesh consists of a set of connected and numbered mesh topological entities, and geometry data.
Definition Mesh.h:23
Topology stores the topology of a mesh, consisting of mesh entities and connectivity (incidence relat...
Definition Topology.h:46
int size(MPI_Comm comm)
Definition MPI.cpp:72
Geometry data structures and algorithms.
Definition BoundingBoxTree.h:22
Low-level methods for reading XDMF files.
Definition xdmf_mesh.h:41
std::pair< std::vector< std::int64_t >, std::array< std::size_t, 2 > > read_topology_data(MPI_Comm comm, hid_t h5_id, const pugi::xml_node &node)
Read topology (cell connectivity) data.
Definition xdmf_mesh.cpp:292
std::pair< std::variant< std::vector< float >, std::vector< double > >, std::array< std::size_t, 2 > > read_geometry_data(MPI_Comm comm, hid_t h5_id, const pugi::xml_node &node)
Read geometry (coordinate) data.
Definition xdmf_mesh.cpp:252
void add_meshtags(MPI_Comm comm, const mesh::MeshTags< T > &meshtags, const mesh::Geometry< U > &geometry, pugi::xml_node &xml_node, hid_t h5_id, const std::string &name)
Add mesh tags to XDMF file.
Definition xdmf_mesh.h:94
void add_geometry_data(MPI_Comm comm, pugi::xml_node &xml_node, hid_t h5_id, std::string path_prefix, const mesh::Geometry< U > &geometry)
Add Geometry xml node.
Definition xdmf_mesh.cpp:158
void add_mesh(MPI_Comm comm, pugi::xml_node &xml_node, hid_t h5_id, const mesh::Mesh< U > &mesh, const std::string &path_prefix)
Definition xdmf_mesh.cpp:212
void add_topology_data(MPI_Comm comm, pugi::xml_node &xml_node, hid_t h5_id, std::string path_prefix, const mesh::Topology &topology, const mesh::Geometry< U > &geometry, int cell_dim, std::span< const std::int32_t > entities)
Definition xdmf_mesh.cpp:23
Mesh data structures and algorithms on meshes.
Definition DofMap.h:32
Top-level namespace.
Definition defines.h:12