Loading [MathJax]/extensions/MathZoom.js
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 bool const converged,
43 std::vector<std::reference_wrapper<const MeshLib::Mesh>> const& meshes,
44 std::set<std::string> const& output_variables) const = 0;
45 virtual std::string constructFilename(std::string const& mesh_name,
46 int const timestep, double const t,
47 int const iteration,
48 bool const converged) const = 0;
49};
50
51inline std::ostream& operator<<(std::ostream& os, OutputFormat const& of)
52{
53 os << "OutputFormat::directory:" << of.directory << std::endl;
54 os << "OutputFormat::prefix:" << of.prefix << std::endl;
55 os << "OutputFormat::suffix:" << of.suffix << std::endl;
56 os << "OutputFormat::compression:" << of.compression << std::endl;
57 return os;
58}
59
60struct OutputVTKFormat final : public OutputFormat
61{
62 OutputVTKFormat(std::string const& directory, std::string prefix,
63 std::string suffix, bool const compression,
64 int const data_mode)
65 : OutputFormat(directory, std::move(prefix), std::move(suffix),
68 {
69 }
70
71 void outputMeshes(
72 const int timestep, const double t, const int iteration,
73 bool const converged,
74 std::vector<std::reference_wrapper<const MeshLib::Mesh>> const& meshes,
75 std::set<std::string> const& output_variables) const override;
76
82
84 mutable std::map<std::string, MeshLib::IO::PVDFile> mesh_name_to_pvd_file;
85
87 std::string const& mesh_name) const;
88
89 std::string constructFilename(std::string const& mesh_name,
90 int const timestep, double const t,
91 int const iteration,
92 bool const converged) const override;
93
94 std::string constructPVDName(std::string const& mesh_name) const;
95};
96
98{
99 OutputXDMFHDF5Format(std::string const& directory, std::string prefix,
100 std::string suffix, bool const compression,
101 unsigned int const n_files,
102 unsigned int const chunk_size_bytes)
103 : OutputFormat(directory, std::move(prefix), std::move(suffix),
107 {
108 }
109
111 const int timestep, const double t, const int iteration,
112 bool const converged,
113 std::vector<std::reference_wrapper<const MeshLib::Mesh>> const& meshes,
114 std::set<std::string> const& output_variables) const override
115 {
116 outputMeshXdmf(output_variables, meshes, timestep, t, iteration,
117 converged);
118 }
119
120 std::string constructFilename(std::string const& mesh_name,
121 int const timestep, double const t,
122 int const iteration,
123 bool const converged) const override;
124
125 mutable std::unique_ptr<MeshLib::IO::XdmfHdfWriter> mesh_xdmf_hdf_writer;
127 unsigned int n_files;
129 unsigned int const chunk_size_bytes;
130
131 void outputMeshXdmf(
132 std::set<std::string> const& output_variables,
133 std::vector<std::reference_wrapper<const MeshLib::Mesh>> const& meshes,
134 int const timestep, double const t, int const iteration,
135 bool const converged) const;
136};
137
138void outputMeshVtk(std::string const& file_name, MeshLib::Mesh const& mesh,
139 bool const compress_output, int const data_mode);
140} // 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:455
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, bool const converged) 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)
virtual void outputMeshes(const int timestep, const double t, const int iteration, bool const converged, std::vector< std::reference_wrapper< const MeshLib::Mesh > > const &meshes, std::set< std::string > const &output_variables) const =0
bool compression
Enables or disables zlib-compression of the output files.
OutputFormat(OutputFormat const &other)=delete
OutputFormat & operator=(OutputFormat &&other)=default
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.
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, bool const converged) const override
MeshLib::IO::PVDFile & findOrCreatePVDFile(std::string const &mesh_name) const
void outputMeshes(const int timestep, const double t, const int iteration, bool const converged, std::vector< std::reference_wrapper< const MeshLib::Mesh > > const &meshes, std::set< std::string > const &output_variables) const override
std::string constructFilename(std::string const &mesh_name, int const timestep, double const t, int const iteration, bool const converged) const override
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, bool const converged) const
void outputMeshes(const int timestep, const double t, const int iteration, bool const converged, std::vector< std::reference_wrapper< const MeshLib::Mesh > > const &meshes, std::set< std::string > const &output_variables) 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.
unsigned int n_files
Specifies the number of hdf5 output files.
std::unique_ptr< MeshLib::IO::XdmfHdfWriter > mesh_xdmf_hdf_writer