66 std::vector<std::reference_wrapper<const MeshLib::Mesh>>
const& meshes,
67 std::filesystem::path
const& filepath,
unsigned long long const time_step,
68 double const initial_time,
69 std::set<std::string>
const& variable_output_names,
70 bool const use_compression,
unsigned int const n_files,
71 unsigned int const chunk_size_bytes)
84 auto const transform_ogs_mesh_data_to_xdmf_conforming_data =
85 [&n_files, &chunk_size_bytes](
auto const& mesh)
90 mesh, flattened_geometry_values.data(), n_files, chunk_size_bytes);
91 auto const flattened_topology_values =
93 return std::make_unique<TransformedMeshData>(
95 std::move(flattened_topology_values)});
99 auto const transform_to_meta_data =
100 [&transform_ogs_mesh_data_to_xdmf_conforming_data, &n_files,
101 &chunk_size_bytes](
auto const& mesh)
105 std::unique_ptr<TransformedMeshData> xdmf_conforming_data =
106 transform_ogs_mesh_data_to_xdmf_conforming_data(mesh);
108 mesh, xdmf_conforming_data->flattened_geometry_values.data(),
109 n_files, chunk_size_bytes);
110 auto const topology =
112 n_files, chunk_size_bytes);
113 auto const attributes =
115 return XdmfHdfMesh{std::move(geometry), std::move(topology),
116 std::move(attributes), mesh.get().getName(),
117 std::move(xdmf_conforming_data)};
119 auto isVariableHdfAttribute =
120 isVariableAttribute<HdfData>(variable_output_names);
123 auto const transform_metamesh_to_hdf =
124 [&isVariableHdfAttribute](
auto const& metamesh)
127 std::vector<HdfData> hdf_data_attributes = {metamesh.geometry.hdf,
128 metamesh.topology.hdf};
130 hdf_data_attributes.reserve(hdf_data_attributes.size() +
131 metamesh.attributes.size());
132 std::transform(metamesh.attributes.begin(), metamesh.attributes.end(),
133 std::back_inserter(hdf_data_attributes),
137 std::copy_if(hdf_data_attributes.begin(), hdf_data_attributes.end(),
138 back_inserter(constant_attributes),
139 std::not_fn(isVariableHdfAttribute));
141 std::copy_if(hdf_data_attributes.begin(), hdf_data_attributes.end(),
142 back_inserter(variable_attributes),
143 isVariableHdfAttribute);
147 .variable_attributes = std::move(variable_attributes),
148 .name = std::move(metamesh.name)};
152 std::vector<XdmfHdfMesh> xdmf_hdf_meshes;
153 xdmf_hdf_meshes.reserve(meshes.size());
154 std::transform(meshes.begin(), meshes.end(),
155 std::back_inserter(xdmf_hdf_meshes), transform_to_meta_data);
157 std::vector<MeshHdfData> hdf_meshes;
158 hdf_meshes.reserve(xdmf_hdf_meshes.size());
159 std::transform(xdmf_hdf_meshes.begin(), xdmf_hdf_meshes.end(),
160 std::back_inserter(hdf_meshes), transform_metamesh_to_hdf);
163 std::filesystem::path
const hdf_filepath =
164 filepath.parent_path() / (filepath.stem().string() +
".h5");
167 _hdf_writer = std::make_unique<HdfWriter>(std::move(hdf_meshes), time_step,
168 hdf_filepath, use_compression,
169 is_file_manager, n_files);
173 if (!is_file_manager)
178 auto isVariableXdmfAttribute =
179 isVariableAttribute<XdmfData>(variable_output_names);
182 auto const transform_metamesh_to_xdmf =
183 [&isVariableXdmfAttribute, &filepath, &hdf_filepath,
186 std::string
const xdmf_name = metamesh.name;
187 std::filesystem::path
const xdmf_filepath =
188 filepath.parent_path() /
189 (filepath.stem().string() +
"_" + xdmf_name +
".xdmf");
191 std::vector<XdmfData> xdmf_attributes;
192 std::transform(metamesh.attributes.begin(), metamesh.attributes.end(),
193 std::back_inserter(xdmf_attributes),
195 { return att.xdmf; });
197 for (std::size_t i = 0; i < metamesh.attributes.size(); ++i)
201 xdmf_attributes[i].index = i + 4;
204 std::vector<XdmfData> xdmf_variable_attributes;
205 std::copy_if(xdmf_attributes.begin(), xdmf_attributes.end(),
206 back_inserter(xdmf_variable_attributes),
207 isVariableXdmfAttribute);
208 std::vector<XdmfData> xdmf_constant_attributes;
209 std::copy_if(xdmf_attributes.begin(), xdmf_attributes.end(),
210 back_inserter(xdmf_constant_attributes),
211 std::not_fn(isVariableXdmfAttribute));
213 auto const xdmf_writer_fn =
214 write_xdmf(metamesh.geometry.xdmf, metamesh.topology.xdmf,
215 xdmf_constant_attributes, xdmf_variable_attributes,
216 hdf_filepath.filename().string(),
218 auto xdmf_writer = std::make_unique<XdmfWriter>(xdmf_filepath.string(),
220 xdmf_writer->addTimeStep(initial_time);
224 std::transform(xdmf_hdf_meshes.begin(), xdmf_hdf_meshes.end(),
226 transform_metamesh_to_xdmf);