Flow123d  release_2.2.0-914-gf1a3a4f
equation_output.hh
Go to the documentation of this file.
1 /*
2  * equation_output.hh
3  *
4  * Created on: Jul 8, 2016
5  * Author: jb
6  */
7 
8 #ifndef SRC_FIELDS_EQUATION_OUTPUT_HH_
9 #define SRC_FIELDS_EQUATION_OUTPUT_HH_
10 
11 #include <memory>
12 #include <unordered_map>
13 #include <unordered_set>
14 
15 #include "tools/time_marks.hh"
16 #include "fields/field_set.hh"
19 #include "io/output_time_set.hh"
20 #include "io/output_mesh.hh"
21 class TimeStep;
22 
23 
24 /**
25  * A class responsible for check for output times of individual fields
26  * and store their values into the connected output stream.
27  */
28 class EquationOutput : public FieldSet {
29 public:
30 
31  DECLARE_EXCEPTION(ExcFieldNotScalar, << "Field '" << FieldCommon::EI_Field::qval
32  << "' is not scalar in spacedim 3.");
33 
34  /**
35  * Make Input::Type for the output record. Particular selection of output fields is created
36  * from the contents of *this FeildSet using provided equation name and additional description.
37  */
38  const Input::Type::Instance &make_output_type(const string &equation_name, const string &aditional_description = "");
39 
40  /**
41  * Setup the object. Set output stream for field and observe output, input record for configuration of the object and
42  * TimeGovernor. The time governor is used to get the equation time mark type, the initial and the end time of the equation.
43  */
44  void initialize(std::shared_ptr<OutputTime> stream, Mesh *mesh, Input::Record in_rec, const TimeGovernor & tg);
45 
46  /**
47  * Returns true if @param field is marked for output in the given time @param step.
48  */
49  bool is_field_output_time(const FieldCommon &field, TimeStep step) const;
50 
51  /**
52  * Performs output of the fields marked for output in the time @param step.
53  */
54  void output(TimeStep step);
55 
56  /// Selects the error control field out of output field set according to input record.
58 
59 private:
60  /**
61  * Input type of the configuration record.
62  */
64 
65  /**
66  * Read from the input, set output times and time marks. Must be called after set_stream.
67  * TODO: add output_stream times. Optional or always?
68  */
69  void read_from_input(Input::Record in_rec, const TimeGovernor & tg);
70 
71  /**
72  * Add a time grid to the common_output_times.
73  */
74  void add_output_times(double begin, double step, double end);
75 
76 
77  /**
78  * Create the output mesh of \p stream_ OutputTime object. The field set passed in is used
79  * to select the field used for adaptivity of the output mesh.
80  */
81  void make_output_mesh(bool parallel);
82 
83  /// output stream (may be shared by more equation)
84  std::shared_ptr<OutputTime> stream_;
85  /// The time mark type of the equation.
87  /// The fixed time mark type of the equation.
89  /// The time set used for the fields without explicit time set.
91 
92  /// Time sets of individual fields.
93  std::unordered_map<string, OutputTimeSet> field_output_times_;
94 
95  /// Set of observed fields. The observe points are given within the observe stream.
96  std::unordered_set<string> observe_fields_;
97 
98  /**
99  * Set of interpolations which are used in performed fields.
100  *
101  * Allow determine type of output mesh.
102  */
103  std::set<OutputTime::DiscreteSpace> used_interpolations_;
104 
105  /**
106  * Cached pointer at computational mesh.
107  */
109 
110  /// Output mesh.
111  std::shared_ptr<OutputMeshBase> output_mesh_;
112 
113 };
114 
115 
116 #endif /* SRC_FIELDS_EQUATION_OUTPUT_HH_ */
Classes for auxiliary output mesh.
void add_output_times(double begin, double step, double end)
Common abstract parent of all Field<...> classes.
Definition: field_common.hh:60
Container for various descendants of FieldCommonBase.
Definition: field_set.hh:61
std::unordered_set< string > observe_fields_
Set of observed fields. The observe points are given within the observe stream.
std::function< void(const std::vector< Space< spacedim >::Point > &, const ElementAccessor< spacedim > &, std::vector< double > &)> ErrorControlFieldFunc
Definition: output_mesh.hh:74
void output(TimeStep step)
Definition: mesh.h:99
TimeMark::Type equation_fixed_type_
The fixed time mark type of the equation.
Helper class that stores data of generic types.
Definition: type_generic.hh:89
Basic time management functionality for unsteady (and steady) solvers (class Equation).
void make_output_mesh(bool parallel)
void read_from_input(Input::Record in_rec, const TimeGovernor &tg)
FieldCommon * field(const std::string &field_name) const
Definition: field_set.cc:140
Accessor to the data with type Type::Record.
Definition: accessors.hh:292
OutputMeshBase::ErrorControlFieldFunc select_error_control_field()
Selects the error control field out of output field set according to input record.
std::shared_ptr< OutputTime > stream_
output stream (may be shared by more equation)
std::unordered_map< string, OutputTimeSet > field_output_times_
Time sets of individual fields.
void initialize(std::shared_ptr< OutputTime > stream, Mesh *mesh, Input::Record in_rec, const TimeGovernor &tg)
static Input::Type::Record & get_input_type()
Record type proxy class.
Definition: type_record.hh:182
bool is_field_output_time(const FieldCommon &field, TimeStep step) const
const Input::Type::Instance & make_output_type(const string &equation_name, const string &aditional_description="")
DECLARE_EXCEPTION(ExcFieldNotScalar,<< "Field '"<< FieldCommon::EI_Field::qval<< "' is not scalar in spacedim 3.")
OutputTimeSet common_output_times_
The time set used for the fields without explicit time set.
TimeMark::Type equation_type_
The time mark type of the equation.
Representation of one time step..
std::shared_ptr< OutputMeshBase > output_mesh_
Output mesh.
std::set< OutputTime::DiscreteSpace > used_interpolations_