OGS
ProcessLib/Output/Output.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) OpenGeoSys Community (opengeosys.org)
2// SPDX-License-Identifier: BSD-3-Clause
3
4#pragma once
5
6#include <iosfwd>
7#include <map>
8#include <utility>
9#include <vector>
10
13#include "OutputFormat.h"
14
15namespace NumLib
16{
17struct Time;
18}
19
20namespace ProcessLib
21{
22class Process;
23
29class Output
30{
31public:
32 Output(std::unique_ptr<OutputFormat>&& output_format,
33 bool const output_nonlinear_iteration_results,
34 OutputDataSpecification&& output_data_specification,
35 std::vector<std::string>&& mesh_names_for_output,
36 std::vector<std::unique_ptr<MeshLib::Mesh>> const& meshes);
37
38 Output(Output const& other) = delete;
39 Output(Output&& other) = default;
40 Output& operator=(Output const& src) = delete;
41 Output& operator=(Output&& src) = default;
42 ~Output() = default;
43
45 void addProcess(ProcessLib::Process const& process);
46
50 std::string const& property_name,
51 MeshLib::MeshItemType const mesh_item_type);
52
55 void doOutput(Process const& process, const int process_id,
56 int const timestep, const NumLib::Time& t,
57 int const iteration, bool const converged,
58 std::vector<GlobalVector*> const& xs) const;
59
63 void doOutputLastTimestep(Process const& process, const int process_id,
64 int const timestep, const NumLib::Time& t,
65 int const iteration, bool const converged,
66 std::vector<GlobalVector*> const& xs) const;
67
71 void doOutputAlways(Process const& process, const int process_id,
72 int const timestep, const NumLib::Time& t,
73 int const iteration, bool const converged,
74 std::vector<GlobalVector*> const& xs) const;
75
78 void doOutputNonlinearIteration(Process const& process,
79 const int process_id, int const timestep,
80 const NumLib::Time& t, const int iteration,
81 bool const converged,
82 std::vector<GlobalVector*> const& xs) const;
83
85 bool isOutputStep(int const timestep, NumLib::Time const& t) const;
86
87 std::vector<double> const& getFixedOutputTimes() const
88 {
89 return _output_data_specification.fixed_output_times;
90 }
91
92 std::vector<std::string> getFileNamesForOutput() const;
93
94 friend std::ostream& operator<<(std::ostream& os, Output const& output);
95
96private:
100 bool isOutputProcess(int const process_id, Process const& process) const;
101
102 void outputMeshes(
103 int const timestep, const double t, int const iteration,
104 bool const converged,
105 std::vector<std::reference_wrapper<const MeshLib::Mesh>> const& meshes)
106 const;
107
109 std::string const& submesh_output_name, Process const& process,
110 const int process_id, NumLib::Time const& t,
111 std::vector<GlobalVector*> const& xs) const;
112
113 std::unique_ptr<OutputFormat> _output_format;
114
116
118 std::vector<std::reference_wrapper<Process const>> _output_processes;
119 std::vector<std::string> _mesh_names_for_output;
120 // The reference wrapper enables the compiler to generate a move constructor
121 // and move assignment operator
122 // - another possibility would be to transform the
123 // std::vector<std::unique_ptr<MeshLib::Mesh>> to
124 // std::vector<MeshLib::Mesh*>
125 // - this issue could also be solved by (globally) storing the meshes into a
126 // std::vector<std::shared_ptr<MeshLib::Mesh>>
127 std::reference_wrapper<std::vector<std::unique_ptr<MeshLib::Mesh>> const>
129
130 std::set<std::pair<std::string, MeshLib::MeshItemType>>
132};
133
135 std::vector<Output> const& outputs);
136
137} // 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.