OGS
OutputFormat.h
Go to the documentation of this file.
1
11#pragma once
12
13#include <iosfwd>
14#include <vector>
15
18
19namespace ProcessLib
20{
21class Process;
22
24{
25 OutputFormat(std::string const& directory, std::string prefix,
26 std::string suffix, bool const compression);
27 virtual ~OutputFormat() = default;
28
29 OutputFormat(OutputFormat const& other) = delete;
30 OutputFormat(OutputFormat&& other) = default;
32 OutputFormat& operator=(OutputFormat&& other) = default;
33
34 std::string directory;
35 std::string prefix;
36 std::string suffix;
39
40 virtual void outputMeshes(
41 const int timestep, const double t, const int iteration,
42 std::vector<std::reference_wrapper<const MeshLib::Mesh>> const& meshes,
43 std::set<std::string> const& output_variables) const = 0;
44 virtual std::string constructFilename(std::string const& mesh_name,
45 int const timestep,
46 double const t,
47 int const iteration) const = 0;
48};
49
50inline std::ostream& operator<<(std::ostream& os, OutputFormat const& of)
51{
52 os << "OutputFormat::directory:" << of.directory << std::endl;
53 os << "OutputFormat::prefix:" << of.prefix << std::endl;
54 os << "OutputFormat::suffix:" << of.suffix << std::endl;
55 os << "OutputFormat::compression:" << of.compression << std::endl;
56 return os;
57}
58
59struct OutputVTKFormat final : public OutputFormat
60{
61 OutputVTKFormat(std::string const& directory, std::string prefix,
62 std::string suffix, bool const compression,
63 int const data_mode)
64 : OutputFormat(directory, std::move(prefix), std::move(suffix),
67 {
68 }
69
70 void outputMeshes(
71 const int timestep, const double t, const int iteration,
72 std::vector<std::reference_wrapper<const MeshLib::Mesh>> const& meshes,
73 std::set<std::string> const& output_variables) const override;
74
80
82 mutable std::map<std::string, MeshLib::IO::PVDFile> mesh_name_to_pvd_file;
83
85 std::string const& mesh_name) const;
86
87 std::string constructFilename(std::string const& mesh_name,
88 int const timestep, double const t,
89 int const iteration) const override;
90
91 std::string constructPVDName(std::string const& mesh_name) const;
92};
93
95{
96 OutputXDMFHDF5Format(std::string const& directory, std::string prefix,
97 std::string suffix, bool const compression,
98 unsigned int const n_files,
99 unsigned int const chunk_size_bytes)
100 : OutputFormat(directory, std::move(prefix), std::move(suffix),
104 {
105 }
106
108 const int timestep, const double t, const int iteration,
109 std::vector<std::reference_wrapper<const MeshLib::Mesh>> const& meshes,
110 std::set<std::string> const& output_variables) const override
111 {
112 outputMeshXdmf(output_variables, meshes, timestep, t, iteration);
113 }
114
115 std::string constructFilename(std::string const& mesh_name,
116 int const timestep, double const t,
117 int const iteration) const override;
118
119 mutable std::unique_ptr<MeshLib::IO::XdmfHdfWriter> mesh_xdmf_hdf_writer;
121 unsigned int n_files;
123 unsigned int const chunk_size_bytes;
124
125 void outputMeshXdmf(
126 std::set<std::string> const& output_variables,
127 std::vector<std::reference_wrapper<const MeshLib::Mesh>> const& meshes,
128 int const timestep, double const t, int const iteration) const;
129};
130
131void outputMeshVtk(std::string const& file_name, MeshLib::Mesh const& mesh,
132 bool const compress_output, int const data_mode);
133} // namespace ProcessLib
XdmfWriter which create contiguous data for geometry and topology and writes this and all attributes ...
std::ostream & operator<<(std::ostream &os, Output const &output)
Definition Output.cpp:447
void outputMeshVtk(std::string const &file_name, MeshLib::Mesh const &mesh, bool const compress_output, int const data_mode)
virtual std::string constructFilename(std::string const &mesh_name, int const timestep, double const t, int const iteration) const =0
OutputFormat & operator=(OutputFormat &other)=delete
OutputFormat(OutputFormat &&other)=default
OutputFormat(std::string const &directory, std::string prefix, std::string suffix, bool const compression)
bool compression
Enables or disables zlib-compression of the output files.
OutputFormat(OutputFormat const &other)=delete
OutputFormat & operator=(OutputFormat &&other)=default
virtual void outputMeshes(const int timestep, const double t, const int iteration, std::vector< std::reference_wrapper< const MeshLib::Mesh > > const &meshes, std::set< std::string > const &output_variables) const =0
virtual ~OutputFormat()=default
OutputVTKFormat(std::string const &directory, std::string prefix, std::string suffix, bool const compression, int const data_mode)
std::map< std::string, MeshLib::IO::PVDFile > mesh_name_to_pvd_file
Holds the PVD files associated with the meshes.
void outputMeshes(const int timestep, const double t, const int iteration, std::vector< std::reference_wrapper< const MeshLib::Mesh > > const &meshes, std::set< std::string > const &output_variables) const override
std::string constructPVDName(std::string const &mesh_name) const
std::string constructFilename(std::string const &mesh_name, int const timestep, double const t, int const iteration) const override
MeshLib::IO::PVDFile & findOrCreatePVDFile(std::string const &mesh_name) const
void outputMeshXdmf(std::set< std::string > const &output_variables, std::vector< std::reference_wrapper< const MeshLib::Mesh > > const &meshes, int const timestep, double const t, int const iteration) const
std::string constructFilename(std::string const &mesh_name, int const timestep, double const t, int const iteration) const override
OutputXDMFHDF5Format(std::string const &directory, std::string prefix, std::string suffix, bool const compression, unsigned int const n_files, unsigned int const chunk_size_bytes)
unsigned int const chunk_size_bytes
Specifies the chunks size in bytes per hdf5 output file.
void outputMeshes(const int timestep, const double t, const int iteration, std::vector< std::reference_wrapper< const MeshLib::Mesh > > const &meshes, std::set< std::string > const &output_variables) const override
unsigned int n_files
Specifies the number of hdf5 output files.
std::unique_ptr< MeshLib::IO::XdmfHdfWriter > mesh_xdmf_hdf_writer