Flow123d  release_3.0.0-1025-gd4d7c13
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> // for shared_ptr
12 #include <string> // for string
13 #include <unordered_map> // for unordered_map
14 #include <unordered_set> // for unordered_set
15 #include "fields/field_common.hh" // for FieldCommon, FieldCommon::EI_Field
16 #include "fields/field_set.hh" // for FieldSet
17 #include "fields/field_values.hh" // for FieldValue, FieldValue<>::Scalar
18 #include "io/output_time_set.hh" // for OutputTimeSet
19 #include "io/output_mesh.hh"
20 #include "system/exceptions.hh" // for ExcStream, operator<<, DECLARE_EXC...
21 #include "tools/time_marks.hh" // for TimeMark, TimeMark::Type
22 
23 class OutputTime;
24 class TimeGovernor;
25 class TimeStep;
26 namespace Input {
27  class Record;
28  namespace Type {
29  class Instance;
30  class Record;
31  class Selection;
32  }
33 }
34 
35 
36 /**
37  * A class responsible for check for output times of individual fields
38  * and store their values into the connected output stream.
39  */
40 class EquationOutput : public FieldSet {
41 public:
42 
43  DECLARE_EXCEPTION(ExcFieldNotScalar, << "Field '" << FieldCommon::EI_Field::qval
44  << "' is not scalar in spacedim 3.");
45 
46  /**
47  * Input type of the configuration record.
48  */
49  static Input::Type::Record &get_input_type();
50 
51  /**
52  * Make Input::Type for the output record. Particular selection of output fields is created
53  * from the contents of *this FieldSet using provided equation name and additional description.
54  */
55  const Input::Type::Instance &make_output_type(const string &equation_name, const string &aditional_description = "");
56  /**
57  * Make Input::Type for the output record.
58  * This function enables creating output record for a field set record with additional keys provided in @p in_rec.
59  */
60  const Input::Type::Instance &make_output_type_from_record(Input::Type::Record &in_rec,
61  const string &equation_name,
62  const string &aditional_description = "");
63 
64  /**
65  * Setup the object. Set output stream for field and observe output, input record for configuration of the object and
66  * TimeGovernor. The time governor is used to get the equation time mark type, the initial and the end time of the equation.
67  */
68  void initialize(std::shared_ptr<OutputTime> stream, Mesh *mesh, Input::Record in_rec, const TimeGovernor & tg);
69 
70  /**
71  * Returns true if @param field is marked for output in the given time @param step.
72  */
73  bool is_field_output_time(const FieldCommon &field, TimeStep step) const;
74 
75  /**
76  * Performs output of the fields marked for output in the time @param step.
77  */
78  void output(TimeStep step);
79 
80  /// Selects the error control field out of output field set according to input record.
81  typename OutputMeshBase::ErrorControlFieldFunc select_error_control_field();
82 
83 private:
84  /**
85  * Creates output selection from the field set.
86  */
87  const Input::Type::Selection& create_output_field_selection(const string &equation_name,
88  const string &additional_description);
89 
90  /**
91  * Read from the input, set output times and time marks. Must be called after set_stream.
92  * TODO: add output_stream times. Optional or always?
93  */
94  void read_from_input(Input::Record in_rec, const TimeGovernor & tg);
95 
96  /**
97  * Add a time grid to the common_output_times.
98  */
99  void add_output_times(double begin, double step, double end);
100 
101 
102  /**
103  * Create the output mesh of \p stream_ OutputTime object. The field set passed in is used
104  * to select the field used for adaptivity of the output mesh.
105  */
106  void make_output_mesh(bool parallel);
107 
108  /// output stream (may be shared by more equation)
109  std::shared_ptr<OutputTime> stream_;
110  /// The time mark type of the equation.
112  /// The fixed time mark type of the equation.
114  /// The time set used for the fields without explicit time set.
116 
117  /// Time sets of individual fields.
118  std::unordered_map<string, OutputTimeSet> field_output_times_;
119 
120  /// Set of observed fields. The observe points are given within the observe stream.
121  std::unordered_set<string> observe_fields_;
122 
123  /**
124  * Set of interpolations which are used in performed fields.
125  *
126  * Allow determine type of output mesh.
127  */
128  std::set<OutputTime::DiscreteSpace> used_interpolations_;
129 
130  /**
131  * Cached pointer at computational mesh.
132  */
134 
135  /// Output mesh.
136  std::shared_ptr<OutputMeshBase> output_mesh_;
137 
138 };
139 
140 
141 #endif /* SRC_FIELDS_EQUATION_OUTPUT_HH_ */
Classes for auxiliary output mesh.
Common abstract parent of all Field<...> classes.
Definition: field_common.hh:73
Container for various descendants of FieldCommonBase.
Definition: field_set.hh:71
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
Abstract linear system class.
Definition: balance.hh:35
Definition: mesh.h:76
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).
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)
The class for outputting data during time.
Definition: output_time.hh:50
std::unordered_map< string, OutputTimeSet > field_output_times_
Time sets of individual fields.
DECLARE_EXCEPTION(ExcWrongDefaultJSON,<< "Consistency Error: Not valid JSON of Default value "<< EI_DefaultStr::qval<< " of type "<< EI_TypeName::qval<< ";\n"<< "During declaration of the key: "<< EI_KeyName::qval)
Record type proxy class.
Definition: type_record.hh:182
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..
Template for classes storing finite set of named values.
std::shared_ptr< OutputMeshBase > output_mesh_
Output mesh.
std::set< OutputTime::DiscreteSpace > used_interpolations_