77 std::vector<std::reference_wrapper<const MeshLib::Mesh>>
const& meshes,
78 std::filesystem::path
const& filepath,
unsigned long long const time_step,
79 double const initial_time,
80 std::set<std::string>
const& output_variable_names,
81 std::set<std::string>
const& static_attribute_names,
82 bool const use_compression,
unsigned int const n_files,
83 unsigned int const chunk_size_bytes,
84 bool const store_static_data_separately)
97 auto const transform_ogs_mesh_data_to_xdmf_conforming_data =
98 [&n_files, &chunk_size_bytes](
auto const& mesh)
103 mesh, flattened_geometry_values.data(), n_files, chunk_size_bytes);
104 auto const [flattened_topology_values, parent_data_type] =
107 std::move(flattened_geometry_values),
108 std::move(flattened_topology_values), parent_data_type});
112 auto const transform_to_meta_data =
113 [&output_variable_names,
114 &transform_ogs_mesh_data_to_xdmf_conforming_data, &n_files,
115 &chunk_size_bytes](
auto const& mesh)
119 std::unique_ptr<TransformedMeshData> xdmf_conforming_data =
120 transform_ogs_mesh_data_to_xdmf_conforming_data(mesh);
122 mesh, xdmf_conforming_data->flattened_geometry_values.data(),
123 n_files, chunk_size_bytes);
125 xdmf_conforming_data->flattened_topology_values,
126 xdmf_conforming_data->parent_data_type, n_files, chunk_size_bytes);
128 n_files, chunk_size_bytes);
129 return XdmfHdfMesh{std::move(geometry), std::move(topology),
130 std::move(attributes), mesh.get().getName(),
131 std::move(xdmf_conforming_data)};
134 output_variable_names, static_attribute_names);
137 auto const transform_metamesh_to_hdf =
138 [&isVariableHdfAttribute](
auto const& metamesh)
141 std::vector<HdfData> hdf_data_attributes = {metamesh.geometry.hdf,
142 metamesh.topology.hdf};
144 hdf_data_attributes.reserve(hdf_data_attributes.size() +
145 metamesh.attributes.size());
146 std::transform(metamesh.attributes.begin(), metamesh.attributes.end(),
147 std::back_inserter(hdf_data_attributes),
151 std::copy_if(hdf_data_attributes.begin(), hdf_data_attributes.end(),
152 back_inserter(constant_attributes),
153 std::not_fn(isVariableHdfAttribute));
155 std::copy_if(hdf_data_attributes.begin(), hdf_data_attributes.end(),
156 back_inserter(variable_attributes),
157 isVariableHdfAttribute);
160 .constant_attributes = std::move(constant_attributes),
161 .variable_attributes = std::move(variable_attributes),
162 .name = std::move(metamesh.name)};
166 std::vector<XdmfHdfMesh> xdmf_hdf_meshes;
167 xdmf_hdf_meshes.reserve(meshes.size());
168 std::transform(meshes.begin(), meshes.end(),
169 std::back_inserter(xdmf_hdf_meshes), transform_to_meta_data);
171 std::vector<MeshHdfData> hdf_meshes;
172 hdf_meshes.reserve(xdmf_hdf_meshes.size());
173 std::transform(xdmf_hdf_meshes.begin(), xdmf_hdf_meshes.end(),
174 std::back_inserter(hdf_meshes), transform_metamesh_to_hdf);
177 std::filesystem::path
const hdf_filepath =
178 filepath.parent_path() / (filepath.stem().
string() +
".h5");
179 std::filesystem::path
const static_hdf_filepath =
180 filepath.parent_path() / (filepath.stem().
string() +
"_static.h5");
184 if (store_static_data_separately)
188 std::vector<MeshHdfData> static_hdf_meshes;
189 std::vector<MeshHdfData> dynamic_hdf_meshes;
190 for (
auto& m : hdf_meshes)
193 .constant_attributes = std::move(m.constant_attributes),
194 .variable_attributes = {},
197 .constant_attributes = {},
198 .variable_attributes = std::move(m.variable_attributes),
199 .name = std::move(m.name)});
203 std::move(static_hdf_meshes), time_step, initial_time,
204 static_hdf_filepath, use_compression, is_file_manager, n_files,
207 std::move(dynamic_hdf_meshes), time_step, initial_time,
208 hdf_filepath, use_compression, is_file_manager, n_files,
false);
215 std::move(hdf_meshes), time_step, initial_time, hdf_filepath,
216 use_compression, is_file_manager, n_files,
false);
221 if (!is_file_manager)
227 output_variable_names, static_attribute_names);
230 auto const transform_metamesh_to_xdmf =
231 [&isVariableXdmfAttribute, &filepath, &hdf_filepath,
232 &static_hdf_filepath, &initial_time,
233 store_static_data_separately](
XdmfHdfMesh& metamesh)
235 std::string
const xdmf_name = metamesh.name;
236 std::filesystem::path
const xdmf_filepath =
237 filepath.parent_path() /
238 (filepath.stem().
string() +
"_" + xdmf_name +
".xdmf");
240 std::vector<XdmfData> xdmf_attributes;
241 std::transform(metamesh.attributes.begin(), metamesh.attributes.end(),
242 std::back_inserter(xdmf_attributes),
244 { return att.xdmf; });
246 std::vector<XdmfData> xdmf_variable_attributes;
247 std::copy_if(xdmf_attributes.begin(), xdmf_attributes.end(),
248 back_inserter(xdmf_variable_attributes),
249 isVariableXdmfAttribute);
250 std::vector<XdmfData> xdmf_constant_attributes;
251 std::copy_if(xdmf_attributes.begin(), xdmf_attributes.end(),
252 back_inserter(xdmf_constant_attributes),
253 std::not_fn(isVariableXdmfAttribute));
257 auto const static_fn = store_static_data_separately
258 ? static_hdf_filepath.filename().string()
259 : hdf_filepath.filename().string();
260 auto const xdmf_writer_fn =
261 write_xdmf(metamesh.geometry.xdmf, metamesh.topology.xdmf,
262 xdmf_constant_attributes, xdmf_variable_attributes,
263 static_fn, hdf_filepath.filename().string(),
265 auto xdmf_writer = std::make_unique<XdmfWriter>(xdmf_filepath.string(),
267 xdmf_writer->addTimeStep(initial_time);
271 std::transform(xdmf_hdf_meshes.begin(), xdmf_hdf_meshes.end(),
273 transform_metamesh_to_xdmf);