67 std::vector<std::reference_wrapper<const MeshLib::Mesh>>
const& meshes,
68 std::filesystem::path
const& filepath,
unsigned long long const time_step,
69 double const initial_time,
70 std::set<std::string>
const& variable_output_names,
71 bool const use_compression,
unsigned int const n_files,
72 unsigned int const chunk_size_bytes)
85 auto const transform_ogs_mesh_data_to_xdmf_conforming_data =
86 [&n_files, &chunk_size_bytes](
auto const& mesh)
91 mesh, flattened_geometry_values.data(), n_files, chunk_size_bytes);
92 auto const [flattened_topology_values, parent_data_type] =
95 std::move(flattened_geometry_values),
96 std::move(flattened_topology_values), parent_data_type});
100 auto const transform_to_meta_data =
101 [&transform_ogs_mesh_data_to_xdmf_conforming_data, &n_files,
102 &chunk_size_bytes](
auto const& mesh)
106 std::unique_ptr<TransformedMeshData> xdmf_conforming_data =
107 transform_ogs_mesh_data_to_xdmf_conforming_data(mesh);
109 mesh, xdmf_conforming_data->flattened_geometry_values.data(),
110 n_files, chunk_size_bytes);
112 xdmf_conforming_data->flattened_topology_values,
113 xdmf_conforming_data->parent_data_type, n_files, chunk_size_bytes);
114 auto const attributes =
116 return XdmfHdfMesh{std::move(geometry), std::move(topology),
117 std::move(attributes), mesh.get().getName(),
118 std::move(xdmf_conforming_data)};
120 auto isVariableHdfAttribute =
124 auto const transform_metamesh_to_hdf =
125 [&isVariableHdfAttribute](
auto const& metamesh)
128 std::vector<HdfData> hdf_data_attributes = {metamesh.geometry.hdf,
129 metamesh.topology.hdf};
131 hdf_data_attributes.reserve(hdf_data_attributes.size() +
132 metamesh.attributes.size());
133 std::transform(metamesh.attributes.begin(), metamesh.attributes.end(),
134 std::back_inserter(hdf_data_attributes),
138 std::copy_if(hdf_data_attributes.begin(), hdf_data_attributes.end(),
139 back_inserter(constant_attributes),
140 std::not_fn(isVariableHdfAttribute));
142 std::copy_if(hdf_data_attributes.begin(), hdf_data_attributes.end(),
143 back_inserter(variable_attributes),
144 isVariableHdfAttribute);
147 .constant_attributes = std::move(constant_attributes),
148 .variable_attributes = std::move(variable_attributes),
149 .name = std::move(metamesh.name)};
153 std::vector<XdmfHdfMesh> xdmf_hdf_meshes;
154 xdmf_hdf_meshes.reserve(meshes.size());
155 std::transform(meshes.begin(), meshes.end(),
156 std::back_inserter(xdmf_hdf_meshes), transform_to_meta_data);
158 std::vector<MeshHdfData> hdf_meshes;
159 hdf_meshes.reserve(xdmf_hdf_meshes.size());
160 std::transform(xdmf_hdf_meshes.begin(), xdmf_hdf_meshes.end(),
161 std::back_inserter(hdf_meshes), transform_metamesh_to_hdf);
164 std::filesystem::path
const hdf_filepath =
165 filepath.parent_path() / (filepath.stem().
string() +
".h5");
168 _hdf_writer = std::make_unique<HdfWriter>(std::move(hdf_meshes), time_step,
169 hdf_filepath, use_compression,
170 is_file_manager, n_files);
174 if (!is_file_manager)
179 auto isVariableXdmfAttribute =
183 auto const transform_metamesh_to_xdmf =
184 [&isVariableXdmfAttribute, &filepath, &hdf_filepath,
187 std::string
const xdmf_name = metamesh.name;
188 std::filesystem::path
const xdmf_filepath =
189 filepath.parent_path() /
190 (filepath.stem().
string() +
"_" + xdmf_name +
".xdmf");
192 std::vector<XdmfData> xdmf_attributes;
193 std::transform(metamesh.attributes.begin(), metamesh.attributes.end(),
194 std::back_inserter(xdmf_attributes),
196 { return att.xdmf; });
198 for (std::size_t i = 0; i < metamesh.attributes.size(); ++i)
202 xdmf_attributes[i].index = i + 4;
205 std::vector<XdmfData> xdmf_variable_attributes;
206 std::copy_if(xdmf_attributes.begin(), xdmf_attributes.end(),
207 back_inserter(xdmf_variable_attributes),
208 isVariableXdmfAttribute);
209 std::vector<XdmfData> xdmf_constant_attributes;
210 std::copy_if(xdmf_attributes.begin(), xdmf_attributes.end(),
211 back_inserter(xdmf_constant_attributes),
212 std::not_fn(isVariableXdmfAttribute));
214 auto const xdmf_writer_fn =
215 write_xdmf(metamesh.geometry.xdmf, metamesh.topology.xdmf,
216 xdmf_constant_attributes, xdmf_variable_attributes,
217 hdf_filepath.filename().string(),
219 auto xdmf_writer = std::make_unique<XdmfWriter>(xdmf_filepath.string(),
221 xdmf_writer->addTimeStep(initial_time);
225 std::transform(xdmf_hdf_meshes.begin(), xdmf_hdf_meshes.end(),
227 transform_metamesh_to_xdmf);