Flow123d  release_2.2.0-37-g336ee74
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 class TimeStep;
21 
22 
23 /**
24  * A class responsible for check for output times of individual fields
25  * and store their values into the connected output stream.
26  */
27 class EquationOutput : public FieldSet {
28 public:
29 
30  DECLARE_EXCEPTION(ExcFieldNotScalar, << "Field '" << FieldCommon::EI_Field::qval
31  << "' is not scalar in spacedim 3.");
32 
33  /**
34  * Make Input::Type for the output record. Particular selection of output fields is created
35  * from the contents of *this FeildSet using provided equation name and additional description.
36  */
37  const Input::Type::Instance &make_output_type(const string &equation_name, const string &aditional_description = "");
38 
39  /**
40  * Setup the object. Set output stream for field and observe output, input record for configuration of the object and
41  * TimeGovernor. The time governor is used to get the equation time mark type, the initial and the end time of the equation.
42  */
43  void initialize(std::shared_ptr<OutputTime> stream, Input::Record in_rec, const TimeGovernor & tg);
44 
45  /**
46  * Returns true if @param field is marked for output in the given time @param step.
47  */
48  bool is_field_output_time(const FieldCommon &field, TimeStep step) const;
49 
50  /**
51  * Performs output of the fields marked for output in the time @param step.
52  */
53  void output(TimeStep step);
54 
55  /// Selects the error control field out of output field set according to input record.
56  void select_error_control_field(std::string error_control_field_name);
57 
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();
82 
83 
84  /// output stream (may be shared by more equation)
85  std::shared_ptr<OutputTime> stream_;
86  /// The time mark type of the equation.
88  /// The fixed time mark type of the equation.
90  /// The time set used for the fields without explicit time set.
92 
93  /// Time sets of individual fields.
94  std::unordered_map<string, OutputTimeSet> field_output_times_;
95 
96  /// Set of observed fields. The observe points are given within the observe stream.
97  std::unordered_set<string> observe_fields_;
98 
99  /// Refinement error control field.
101 };
102 
103 
104 #endif /* SRC_FIELDS_EQUATION_OUTPUT_HH_ */
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.
void output(TimeStep step)
Class template representing a field with values dependent on: point, element, and region...
Definition: field.hh:62
void initialize(std::shared_ptr< OutputTime > stream, Input::Record in_rec, const TimeGovernor &tg)
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).
Field< 3, FieldValue< 3 >::Scalar > * error_control_field_
Refinement error control field.
void read_from_input(Input::Record in_rec, const TimeGovernor &tg)
FieldCommon * field(const std::string &field_name) const
Definition: field_set.cc:132
Accessor to the data with type Type::Record.
Definition: accessors.hh:292
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 select_error_control_field(std::string error_control_field_name)
Selects the error control field out of output field set according to input record.
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..