14#include <range/v3/algorithm/find.hpp>
29 using namespace std::string_view_literals;
30 constexpr std::array data_mode_lookup_table{
"Ascii"sv,
"Binary"sv,
32 auto res = ranges::find(begin(data_mode_lookup_table),
33 end(data_mode_lookup_table), data_mode);
34 if (res == data_mode_lookup_table.end())
37 "Unsupported vtk output file data mode '{:s}'. Expected Ascii, "
38 "Binary, or Appended.",
41 return static_cast<int>(std::distance(begin(data_mode_lookup_table), res));
46 std::vector<std::string> output_names;
47 for (
auto const& output : outputs)
49 auto output_mesh_names = output.getFileNamesForOutput();
50 output_names.insert(output_names.end(), output_mesh_names.begin(),
51 output_mesh_names.end());
53 std::sort(output_names.begin(), output_names.end());
54 auto const last = std::unique(output_names.begin(), output_names.end());
55 return last == output_names.end();
62 std::string
const& output_directory,
OutputType const output_type,
63 std::string prefix, std::string suffix, std::string
const& data_mode,
64 bool const compress_output,
unsigned int const number_of_files,
65 unsigned int const chunk_size_bytes)
70 return std::make_unique<OutputVTKFormat>(
71 output_directory, std::move(prefix), std::move(suffix),
72 compress_output, convertVtkDataMode(data_mode));
74 return std::make_unique<OutputXDMFHDF5Format>(
75 output_directory, std::move(prefix), std::move(suffix),
76 compress_output, number_of_files, chunk_size_bytes);
79 "No supported file type provided. Read '{}' from "
80 "<output><type> in prj file. Supported: VTK, XDMF.",
86 std::vector<std::unique_ptr<MeshLib::Mesh>>
const& meshes)
89 output_directory, oc.output_type, std::move(oc.prefix),
90 std::move(oc.suffix), oc.data_mode, oc.compress_output,
91 oc.number_of_files, oc.chunk_size_bytes);
94 std::move(oc.output_variables), std::move(oc.fixed_output_times),
95 std::move(oc.repeats_each_steps), oc.output_extrapolation_residuals};
97 return {std::move(output_format), oc.output_iteration_results,
98 std::move(output_data_specification),
99 std::move(oc.mesh_names_for_output), meshes};
104 std::string
const& output_directory,
105 std::vector<std::unique_ptr<MeshLib::Mesh>>& meshes)
107 std::vector<Output> outputs;
109 outputs.push_back(
createOutput(std::move(oc), output_directory, meshes));
115 std::string
const& output_directory,
116 std::vector<std::unique_ptr<MeshLib::Mesh>>& meshes)
118 DBUG(
"Parse outputs configuration:");
119 std::vector<Output> outputs;
120 for (
auto const& output_config :
128 if (areOutputNamesUnique(outputs))
135 "Output configuration paths are not unique. This will lead to "
136 "overwritten results or invalid / corrupted data within the "
void DBUG(fmt::format_string< Args... > fmt, Args &&... args)
Definition of the Mesh class.
Range< SubtreeIterator > getConfigSubtreeList(std::string const &root) const
constexpr auto to_underlying(E e) noexcept
Converts an enumeration to its underlying type.
OutputConfig createOutputConfig(const BaseLib::ConfigTree &config, std::vector< std::unique_ptr< MeshLib::Mesh > > &meshes)
Output createOutput(OutputConfig &&oc, std::string const &output_directory, std::vector< std::unique_ptr< MeshLib::Mesh > > const &meshes)
std::unique_ptr< OutputFormat > createOutputFormat(std::string const &output_directory, OutputType const output_type, std::string prefix, std::string suffix, std::string const &data_mode, bool const compress_output, unsigned int const number_of_files, unsigned int const chunk_size_bytes)
std::vector< Output > createOutputs(const BaseLib::ConfigTree &output_configs, std::string const &output_directory, std::vector< std::unique_ptr< MeshLib::Mesh > > &meshes)
bool areOutputNamesUnique(std::vector< ProcessLib::Output > const &outputs)
int convertVtkDataMode(std::string_view const &data_mode)
Holds information about which variables to write to output files.