13#include <spdlog/fmt/bundled/ranges.h>
29 std::string
const& mesh_name)
31 if (material_ids.empty())
35 return mesh_name +
"_" + fmt::format(
"{}", fmt::join(material_ids,
"_"));
40 std::vector<std::unique_ptr<MeshLib::Mesh>>& meshes)
42 auto const mesh_name = output_mesh_config.
getValue<std::string>();
45 auto material_id_string =
50 if (!material_id_string)
55 auto const material_ids_for_output =
60 mesh, material_ids_for_output,
62 auto const* bulk_mesh =
65 bulk_mesh, subdomain_mesh.get()));
68 mesh, material_ids_for_output,
72 return meshes.back()->
getName();
79 std::vector<std::unique_ptr<MeshLib::Mesh>>& meshes)
87 const std::map<std::string, OutputType> outputType_to_enum = {
89 auto type = outputType_to_enum.at(output_type);
93 catch (std::out_of_range&)
96 "No supported file type provided. Read `{:s}' from <output><type> \
97 in prj File. Supported: VTK, XDMF.",
110 "_ts_{:timestep}_t_{:time}");
125 return hdf->getConfigParameter<
unsigned int>(
"number_of_files");
134 return hdf->getConfigParameter<
unsigned int>(
"chunk_size_bytes");
156 "fixed_output_times_from_file",
"no_file");
158 if (filename !=
"no_file")
173 for (
auto pair : timesteps->getConfigSubtreeList(
"pair"))
176 auto repeat = pair.getConfigParameter<
unsigned>(
"repeat");
178 auto each_steps = pair.getConfigParameter<
unsigned>(
"each_steps");
180 assert(repeat != 0 && each_steps != 0);
181 repeats_each_steps.emplace_back(repeat, each_steps);
184 if (repeats_each_steps.empty())
187 "You have not given any pair (<repeat/>, <each_steps/>) that "
188 "defines at which timesteps output shall be written. "
197 repeats_each_steps.emplace_back(1, 1);
206 out_vars.getConfigParameterList<std::string>(
"variable"))
208 if (output_variables.find(out_var) != output_variables.cend())
210 OGS_FATAL(
"output variable `{:s}' specified more than once.",
214 DBUG(
"adding output variable `{:s}'", out_var);
215 output_variables.insert(out_var);
227 if (output_config.
prefix.find(
"{:meshname}") == std::string::npos)
230 "There are multiple meshes defined in the output section of "
231 "the project file, but the prefix doesn't contain "
232 "'{{:meshname}}'. Thus the names for the files, the simulation "
233 "results should be written to, would not be distinguishable "
234 "for different meshes.");
237 for (
auto mesh_config : meshes_config->getConfigParameterList(
"mesh"))
239 mesh_names_for_output.push_back(
241 INFO(
"Configure mesh '{:s}' for output.",
242 mesh_names_for_output.back());
246 if (
auto const geometrical_sets_config =
251 auto geometrical_set_config :
253 geometrical_sets_config->getConfigSubtreeList(
"geometrical_set"))
255 auto const geometrical_set_name =
257 geometrical_set_config.getConfigParameter<std::string>(
"name",
259 auto const geometry_name =
261 geometrical_set_config.getConfigParameter<std::string>(
263 mesh_names_for_output.push_back(geometrical_set_name +
"_" +
272 return output_config;
std::string createMeshOutputName(std::vector< int > const &material_ids, std::string const &mesh_name)
std::string parseOutputMeshConfig(BaseLib::ConfigTree const &output_mesh_config, std::vector< std::unique_ptr< MeshLib::Mesh > > &meshes)
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
void DBUG(fmt::format_string< Args... > fmt, Args &&... args)
Definition of the Mesh class.
Definition of mesh class for partitioned mesh (by node) for parallel computing within the framework o...
std::optional< ConfigTree > getConfigSubtreeOptional(std::string const &root) const
T getConfigParameter(std::string const ¶m) const
ConfigTree getConfigSubtree(std::string const &root) const
std::optional< T > getConfigAttributeOptional(std::string const &attr) const
const std::string getName() const
Get name of the mesh.
std::vector< double > readDoublesFromBinaryFile(const std::string &filename)
void makeVectorUnique(std::vector< T > &v)
std::vector< int > splitMaterialIdString(std::string const &material_id_string)
Mesh & findMeshByName(std::vector< std::unique_ptr< Mesh > > const &meshes, std::string_view const name)
std::unique_ptr< MeshLib::Mesh > createMaterialIDsBasedSubMesh(MeshLib::Mesh const &mesh, std::vector< int > const &material_ids, std::string const &name_for_created_mesh)
std::unique_ptr< NodePartitionedMesh > transformMeshToNodePartitionedMesh(NodePartitionedMesh const *const bulk_mesh, Mesh const *const subdomain_mesh)
OutputConfig createOutputConfig(const BaseLib::ConfigTree &config, std::vector< std::unique_ptr< MeshLib::Mesh > > &meshes)
std::vector< PairRepeatEachSteps > repeats_each_steps
bool output_extrapolation_residuals
std::vector< double > fixed_output_times
unsigned int number_of_files
bool output_iteration_results
unsigned int chunk_size_bytes
std::set< std::string > output_variables
std::vector< std::string > mesh_names_for_output