12#include <dolfinx/common/log.h>
13#include <dolfinx/mesh/MeshTags.h>
35template <std::
floating_po
int T>
37template <std::
floating_po
int T>
49template <std::
floating_po
int U>
50void add_mesh(MPI_Comm comm, pugi::xml_node& xml_node, hid_t h5_id,
63template <std::
floating_po
int U>
65 std::string_view path_prefix,
68 std::span<const std::int32_t> entities);
71template <std::
floating_po
int U>
73 std::string_view path_prefix,
82std::pair<std::variant<std::vector<float>, std::vector<double>>,
83 std::array<std::size_t, 2>>
92std::pair<std::vector<std::int64_t>, std::array<std::size_t, 2>>
96template <
typename T, std::
floating_po
int U>
99 hid_t h5_id, std::string_view name)
101 logger().info(
"XDMF: add meshtags ({})", name);
103 const int dim = meshtags.
dim();
104 std::shared_ptr<const common::IndexMap> entity_map
105 = meshtags.
topology()->index_map(dim);
108 throw std::runtime_error(
"Missing entities. Did you forget to call "
109 "dolfinx::mesh::Topology::create_entities?");
111 const std::int32_t num_local_entities = entity_map->size_local();
114 auto it = std::ranges::lower_bound(meshtags.
indices(), num_local_entities);
115 const int num_active_entities
116 = std::ranges::distance(meshtags.
indices().begin(), it);
118 const std::string path_prefix = std::format(
"/MeshTags/{}", name);
121 std::span<const std::int32_t>(meshtags.
indices().data(),
122 num_active_entities));
125 pugi::xml_node attribute_node = xml_node.append_child(
"Attribute");
126 assert(attribute_node);
127 attribute_node.append_attribute(
"Name") = std::string(name).c_str();
128 attribute_node.append_attribute(
"AttributeType") =
"Scalar";
129 attribute_node.append_attribute(
"Center") =
"Cell";
131 std::int64_t global_num_values = 0;
132 const std::int64_t local_num_values = num_active_entities;
133 MPI_Allreduce(&local_num_values, &global_num_values, 1, MPI_INT64_T, MPI_SUM,
135 const std::int64_t num_local = num_active_entities;
136 std::int64_t offset = 0;
137 MPI_Exscan(&num_local, &offset, 1, MPI_INT64_T, MPI_SUM, comm);
139 xdmf_utils::add_data_item(
140 attribute_node, h5_id, std::format(
"{}/Values", path_prefix),
141 std::span<const T>(meshtags.
values().data(), num_active_entities), offset,
142 {global_num_values, 1},
"", use_mpi_io);
Geometry stores the geometry imposed on a mesh.
Definition Geometry.h:39
A Mesh consists of a set of connected and numbered mesh topological entities, and geometry data.
Definition Mesh.h:25
Topology stores the topology of a mesh, consisting of mesh entities and connectivity (incidence relat...
Definition Topology.h:49
int size(MPI_Comm comm)
Definition MPI.cpp:81
Geometry data structures and algorithms.
Definition BoundingBoxTree.h:26
Low-level methods for reading XDMF files.
Definition xdmf_mesh.h:44
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:305
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:264
void add_geometry_data(MPI_Comm comm, pugi::xml_node &xml_node, hid_t h5_id, std::string_view path_prefix, const mesh::Geometry< U > &geometry)
Add Geometry xml node.
Definition xdmf_mesh.cpp:169
void add_topology_data(MPI_Comm comm, pugi::xml_node &xml_node, hid_t h5_id, std::string_view 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:27
void add_mesh(MPI_Comm comm, pugi::xml_node &xml_node, hid_t h5_id, const mesh::Mesh< U > &mesh, std::string_view path_prefix)
Definition xdmf_mesh.cpp:224
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, std::string_view name)
Add mesh tags to XDMF file.
Definition xdmf_mesh.h:97
Mesh data structures and algorithms on meshes.
Definition DofMap.h:32
Top-level namespace.
Definition defines.h:12
auto logger() -> spdlog::logger &
Dolfinx's logger.
Definition log.cpp:24