OGS
Output.h
Go to the documentation of this file.
1
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,
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,
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,
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 std::vector<GlobalVector*> const& xs) const;
89
91 bool isOutputStep(int const timestep, NumLib::Time const& t) const;
92
93 std::vector<double> const& getFixedOutputTimes() const
94 {
96 }
97
98 std::vector<std::string> getFileNamesForOutput() const;
99
100 friend std::ostream& operator<<(std::ostream& os, Output const& output);
101
102private:
106 bool isOutputProcess(int const process_id, Process const& process) const;
107
108 void outputMeshes(
109 int const timestep, const double t, int const iteration,
110 std::vector<std::reference_wrapper<const MeshLib::Mesh>> const& meshes)
111 const;
112
114 std::string const& submesh_output_name, Process const& process,
115 const int process_id, NumLib::Time const& t,
116 std::vector<GlobalVector*> const& xs) const;
117
118 std::unique_ptr<OutputFormat> _output_format;
119
121
123 std::vector<std::reference_wrapper<Process const>> _output_processes;
124 std::vector<std::string> _mesh_names_for_output;
125 // The reference wrapper enables the compiler to generate a move constructor
126 // and move assignment operator
127 // - another possibility would be to transform the
128 // std::vector<std::unique_ptr<MeshLib::Mesh>> to
129 // std::vector<MeshLib::Mesh*>
130 // - this issue could also be solved by (globally) storing the meshes into a
131 // std::vector<std::shared_ptr<MeshLib::Mesh>>
132 std::reference_wrapper<std::vector<std::unique_ptr<MeshLib::Mesh>> const>
134
135 std::set<std::pair<std::string, MeshLib::MeshItemType>>
137};
138
140 std::vector<Output> const& outputs);
141
142} // namespace ProcessLib
std::set< std::pair< std::string, MeshLib::MeshItemType > > _do_not_project_from_bulk_mesh_to_submeshes
Definition Output.h:136
std::reference_wrapper< std::vector< std::unique_ptr< MeshLib::Mesh > > const > _meshes
Definition Output.h:133
std::vector< std::string > _mesh_names_for_output
Definition Output.h:124
void doOutputAlways(Process const &process, const int process_id, int const timestep, const NumLib::Time &t, int const iteration, std::vector< GlobalVector * > const &xs) const
Definition Output.cpp:289
Output & operator=(Output &&src)=default
friend std::ostream & operator<<(std::ostream &os, Output const &output)
Definition Output.cpp:447
Output(Output &&other)=default
Output(Output const &other)=delete
void doNotProjectFromBulkMeshToSubmeshes(std::string const &property_name, MeshLib::MeshItemType const mesh_item_type)
Definition Output.cpp:169
OutputDataSpecification _output_data_specification
Definition Output.h:122
std::vector< std::reference_wrapper< Process const > > _output_processes
Definition Output.h:123
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
Definition Output.cpp:215
void doOutputLastTimestep(Process const &process, const int process_id, int const timestep, const NumLib::Time &t, int const iteration, std::vector< GlobalVector * > const &xs) const
Definition Output.cpp:355
void doOutputNonlinearIteration(Process const &process, const int process_id, int const timestep, const NumLib::Time &t, const int iteration, std::vector< GlobalVector * > const &xs) const
Definition Output.cpp:372
void doOutput(Process const &process, const int process_id, int const timestep, const NumLib::Time &t, int const iteration, std::vector< GlobalVector * > const &xs) const
Definition Output.cpp:336
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)
Definition Output.cpp:147
bool isOutputProcess(int const process_id, Process const &process) const
Definition Output.cpp:135
std::unique_ptr< OutputFormat > _output_format
Definition Output.h:118
void outputMeshes(int const timestep, const double t, int const iteration, std::vector< std::reference_wrapper< const MeshLib::Mesh > > const &meshes) const
Definition Output.cpp:177
void addProcess(ProcessLib::Process const &process)
TODO doc. Opens a PVD file for each process.
Definition Output.cpp:160
bool _output_nonlinear_iteration_results
Definition Output.h:120
std::vector< std::string > getFileNamesForOutput() const
Definition Output.cpp:423
bool isOutputStep(int const timestep, NumLib::Time const &t) const
Tells if output will be written at the specified timestep/time.
Definition Output.cpp:418
std::vector< double > const & getFixedOutputTimes() const
Definition Output.h:93
MeshItemType
Definition Location.h:21
std::vector< double > calculateUniqueFixedTimesForAllOutputs(std::vector< Output > const &outputs)
Definition Output.cpp:433
Holds information about which variables to write to output files.
std::vector< double > fixed_output_times
Given times that steps have to reach.