27 std::string
const& output_directory,
28 std::vector<std::unique_ptr<MeshLib::Mesh>>
const& meshes)
30 DBUG(
"Parse output configuration:");
31 OutputType const output_type = [](
auto output_type)
35 const std::map<std::string, OutputType> outputType_to_enum = {
37 auto type = outputType_to_enum.at(output_type);
41 catch (std::out_of_range&)
44 "No supported file type provided. Read `{:s}' from <output><type> \
45 in prj File. Supported: VTK, XDMF.",
58 "_ts_{:timestep}_t_{:time}");
60 auto const compress_output =
68 auto number_of_files = [&hdf]() ->
unsigned int
73 return hdf->getConfigParameter<
unsigned int>(
"number_of_files");
81 auto const data_mode =
86 std::vector<Output::PairRepeatEachSteps> repeats_each_steps;
92 for (
auto pair : timesteps->getConfigSubtreeList(
"pair"))
95 auto repeat = pair.getConfigParameter<
unsigned>(
"repeat");
97 auto each_steps = pair.getConfigParameter<
unsigned>(
"each_steps");
99 assert(repeat != 0 && each_steps != 0);
100 repeats_each_steps.emplace_back(repeat, each_steps);
103 if (repeats_each_steps.empty())
106 "You have not given any pair (<repeat/>, <each_steps/>) that "
107 "defines at which timesteps output shall be written. "
113 repeats_each_steps.emplace_back(1, 1);
119 std::set<std::string> output_variables;
122 out_vars.getConfigParameterList<std::string>(
"variable"))
124 if (output_variables.find(out_var) != output_variables.cend())
126 OGS_FATAL(
"output variable `{:s}' specified more than once.",
130 DBUG(
"adding output variable `{:s}'", out_var);
131 output_variables.insert(out_var);
136 "output_extrapolation_residuals",
false);
141 std::vector<std::string> mesh_names_for_output;
145 if (prefix.find(
"{:meshname}") == std::string::npos)
148 "There are multiple meshes defined in the output section of "
149 "the project file, but the prefix doesn't contain "
150 "'{{:meshname}}'. Thus the names for the files, the simulation "
151 "results should be written to, would not be distinguishable "
152 "for different meshes.");
155 for (
auto mesh_config : meshes_config->getConfigParameterList(
"mesh"))
157 mesh_names_for_output.push_back(
158 mesh_config.getValue<std::string>());
159 INFO(
"Configure mesh '{:s}' for output.",
160 mesh_names_for_output.back());
164 std::vector<double> fixed_output_times =
171 bool const output_iteration_results =
175 return std::make_unique<Output>(
176 output_directory, output_type, prefix, suffix, compress_output,
177 number_of_files, data_mode, output_iteration_results,
178 std::move(repeats_each_steps), std::move(fixed_output_times),
179 std::move(output_data_specification), std::move(mesh_names_for_output),
void INFO(char const *fmt, Args const &... args)
void DBUG(char const *fmt, Args const &... args)
Definition of the Mesh class.
std::optional< ConfigTree > getConfigSubtreeOptional(std::string const &root) const
T getConfigParameter(std::string const ¶m) const
ConfigTree getConfigSubtree(std::string const &root) const
void makeVectorUnique(std::vector< T > &v)
std::unique_ptr< Output > createOutput(const BaseLib::ConfigTree &config, std::string const &output_directory, std::vector< std::unique_ptr< MeshLib::Mesh >> const &meshes)
Holds information about which variables to write to output files.