Skip to content

Commit b921c4d

Browse files
Merge branch 'main' into schnellerhase/clang-tidy-2.0
2 parents da76875 + 1952d7f commit b921c4d

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

cpp/dolfinx/io/xdmf_function.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "xdmf_function.h"
88
#include "xdmf_mesh.h"
99
#include "xdmf_utils.h"
10+
#include <algorithm>
1011
#include <basix/mdspan.hpp>
1112
#include <boost/lexical_cast.hpp>
1213
#include <dolfinx/common/IndexMap.h>
@@ -167,13 +168,12 @@ void xdmf_function::add_function(MPI_Comm comm, const fem::Function<T, U>& u,
167168
std::vector<std::string> components = {""};
168169
if constexpr (!std::is_scalar_v<T>)
169170
components = {"real_", "imag_"};
171+
170172
std::string t_str = boost::lexical_cast<std::string>(t);
171173
std::replace(t_str.begin(), t_str.end(), '.', '_');
172174
for (const auto& component : components)
173175
{
174176
std::string attr_name = component + u.name;
175-
std::string dataset_name
176-
= "/Function/" + attr_name.append("/").append(t_str);
177177

178178
// Add attribute node
179179
pugi::xml_node attr_node = xml_node.append_child("Attribute");
@@ -205,7 +205,8 @@ void xdmf_function::add_function(MPI_Comm comm, const fem::Function<T, U>& u,
205205
u = std::span<const T>(data_values);
206206

207207
// -- Real case, add data item
208-
xdmf_utils::add_data_item(attr_node, h5_id, dataset_name, u, offset,
208+
std::string h5_path = std::format("/Function/{}/{}", attr_name, t_str);
209+
xdmf_utils::add_data_item(attr_node, h5_id, h5_path, u, offset,
209210
{num_values, num_components}, "", use_mpi_io);
210211
}
211212
}

0 commit comments

Comments
 (0)