OGS
ProcessLib/Output/Output.h
Go to the documentation of this file.
1
10
11#pragma once
12
13#include <iosfwd>
14#include <map>
15#include <utility>
16#include <vector>
17
20#include "OutputFormat.h"
21
22namespace NumLib
23{
24struct Time;
25}
26
27namespace ProcessLib
28{
29class Process;
30
36class Output
37{
38public:
39 Output(std::unique_ptr<OutputFormat>&& output_format,
40 bool const output_nonlinear_iteration_results,
41 OutputDataSpecification&& output_data_specification,
42 std::vector<std::string>&& mesh_names_for_output,
43 std::vector<std::unique_ptr<MeshLib::Mesh>> const& meshes);
44
45 Output(Output const& other) = delete;
46 Output(Output&& other) = default;
47 Output& operator=(Output const& src) = delete;
48 Output& operator=(Output&& src) = default;
49 ~Output() = default;
50
52 void addProcess(ProcessLib::Process const& process);
53
57 std::string const& property_name,
58 MeshLib::MeshItemType const mesh_item_type);
59
62 void doOutput(Process const& process, const int process_id,
63 int const timestep, const NumLib::Time& t,
64 int const iteration, bool const converged,
65 std::vector<GlobalVector*> const& xs) const;
66
70 void doOutputLastTimestep(Process const& process, const int process_id,
71 int const timestep, const NumLib::Time& t,
72 int const iteration, bool const converged,
73 std::vector<GlobalVector*> const& xs) const;
74
78 void doOutputAlways(Process const& process, const int process_id,
79 int const timestep, const NumLib::Time& t,
80 int const iteration, bool const converged,
81 std::vector<GlobalVector*> const& xs) const;
82
85 void doOutputNonlinearIteration(Process const& process,
86 const int process_id, int const timestep,
87 const NumLib::Time& t, const int iteration,
88 bool const converged,
89 std::vector<GlobalVector*> const& xs) const;
90
92 bool isOutputStep(int const timestep, NumLib::Time const& t) const;
93
94 std::vector<double> const& getFixedOutputTimes() const
95 {
96 return _output_data_specification.fixed_output_times;
97 }
98
99 std::vector<std::string> getFileNamesForOutput() const;
100
101 friend std::ostream& operator<<(std::ostream& os, Output const& output);
102
103private:
107 bool isOutputProcess(int const process_id, Process const& process) const;
108
109 void outputMeshes(
110 int const timestep, const double t, int const iteration,
111 bool const converged,
112 std::vector<std::reference_wrapper<const MeshLib::Mesh>> const& meshes)
113 const;
114
116 std::string const& submesh_output_name, Process const& process,
117 const int process_id, NumLib::Time const& t,
118 std::vector<GlobalVector*> const& xs) const;
119
120 std::unique_ptr<OutputFormat> _output_format;
121
123
125 std::vector<std::reference_wrapper<Process const>> _output_processes;
126 std::vector<std::string> _mesh_names_for_output;
127 // The reference wrapper enables the compiler to generate a move constructor
128 // and move assignment operator
129 // - another possibility would be to transform the
130 // std::vector<std::unique_ptr<MeshLib::Mesh>> to
131 // std::vector<MeshLib::Mesh*>
132 // - this issue could also be solved by (globally) storing the meshes into a
133 // std::vector<std::shared_ptr<MeshLib::Mesh>>
134 std::reference_wrapper<std::vector<std::unique_ptr<MeshLib::Mesh>> const>
136
137 std::set<std::pair<std::string, MeshLib::MeshItemType>>
139};
140
142 std::vector<Output> const& outputs);
143
144} // namespace ProcessLib
std::set< std::pair< std::string, MeshLib::MeshItemType > > _do_not_project_from_bulk_mesh_to_submeshes
std::reference_wrapper< std::vector< std::unique_ptr< MeshLib::Mesh > > const > _meshes
void doOutputAlways(Process const &process, const int process_id, int const timestep, const NumLib::Time &t, int const iteration, bool const converged, std::vector< GlobalVector * > const &xs) const
void doOutput(Process const &process, const int process_id, int const timestep, const NumLib::Time &t, int const iteration, bool const converged, std::vector< GlobalVector * > const &xs) const
void doOutputNonlinearIteration(Process const &process, const int process_id, int const timestep, const NumLib::Time &t, const int iteration, bool const converged, std::vector< GlobalVector * > const &xs) const
std::vector< std::string > _mesh_names_for_output
void doOutputLastTimestep(Process const &process, const int process_id, int const timestep, const NumLib::Time &t, int const iteration, bool const converged, std::vector< GlobalVector * > const &xs) const
void outputMeshes(int const timestep, const double t, int const iteration, bool const converged, std::vector< std::reference_wrapper< const MeshLib::Mesh > > const &meshes) const
Output & operator=(Output &&src)=default
friend std::ostream & operator<<(std::ostream &os, Output const &output)
Output(Output &&other)=default
Output(Output const &other)=delete
void doNotProjectFromBulkMeshToSubmeshes(std::string const &property_name, MeshLib::MeshItemType const mesh_item_type)
OutputDataSpecification _output_data_specification
std::vector< std::reference_wrapper< Process const > > _output_processes
MeshLib::Mesh const & prepareSubmesh(std::string const &submesh_output_name, Process const &process, const int process_id, NumLib::Time const &t, std::vector< GlobalVector * > const &xs) const
Output & operator=(Output const &src)=delete
Output(std::unique_ptr< OutputFormat > &&output_format, bool const output_nonlinear_iteration_results, OutputDataSpecification &&output_data_specification, std::vector< std::string > &&mesh_names_for_output, std::vector< std::unique_ptr< MeshLib::Mesh > > const &meshes)
bool isOutputProcess(int const process_id, Process const &process) const
std::unique_ptr< OutputFormat > _output_format
void addProcess(ProcessLib::Process const &process)
TODO doc. Opens a PVD file for each process.
std::vector< std::string > getFileNamesForOutput() const
bool isOutputStep(int const timestep, NumLib::Time const &t) const
Tells if output will be written at the specified timestep/time.
std::vector< double > const & getFixedOutputTimes() const
std::vector< double > calculateUniqueFixedTimesForAllOutputs(std::vector< Output > const &outputs)
Holds information about which variables to write to output files.