Flow123d  JS_before_hm-1713-g943b6bc16
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  /// Configuration of output of one field. Pair of OutputTimeSet and DiscreteSpaces.
48  OutputTimeSet output_set_; ///< Set of output times.
49  OutputTime::DiscreteSpaceFlags space_flags_; ///< Array of used DiscreteSpaces
50  };
51 
52  /**
53  * Input type of the configuration record.
54  */
56 
57  /**
58  * Make Input::Type for the output record. Particular selection of output fields is created
59  * from the contents of *this FieldSet using provided equation name and additional description.
60  */
61  const Input::Type::Instance &make_output_type(const string &equation_name, const string &aditional_description = "");
62  /**
63  * Make Input::Type for the output record.
64  * This function enables creating output record for a field set record with additional keys provided in @p in_rec.
65  */
67  const string &equation_name,
68  const string &aditional_description = "");
69 
70  /**
71  * Setup the object. Set output stream for field and observe output, input record for configuration of the object and
72  * TimeGovernor. The time governor is used to get the equation time mark type, the initial and the end time of the equation.
73  */
74  void initialize(std::shared_ptr<OutputTime> stream, Mesh *mesh, Input::Record in_rec, const TimeGovernor & tg);
75 
76  /**
77  * Returns true if @param field is marked for output in the given time @param step.
78  */
79  bool is_field_output_time(const FieldCommon &field, TimeStep step) const;
80 
81  /**
82  * Performs output of the fields marked for output in the time @param step.
83  */
84  void output(TimeStep step);
85 
86  /// Selects the error control field out of output field set according to input record.
88 
89 private:
90  /**
91  * Creates output selection from the field set.
92  */
93  const Input::Type::Selection& create_output_field_selection(const string &equation_name,
94  const string &additional_description);
95 
96  /**
97  * Read from the input, set output times and time marks. Must be called after set_stream.
98  * TODO: add output_stream times. Optional or always?
99  */
100  void read_from_input(Input::Record in_rec, const TimeGovernor & tg);
101 
102  /**
103  * Add a time grid to the common_output_times.
104  */
105  void add_output_times(double begin, double step, double end);
106 
107 
108  /**
109  * Create the output mesh of \p stream_ OutputTime object. The field set passed in is used
110  * to select the field used for adaptivity of the output mesh.
111  */
112  void make_output_mesh(bool parallel);
113 
114  /// output stream (may be shared by more equation)
115  std::shared_ptr<OutputTime> stream_;
116  /// The time mark type of the equation.
118  /// The fixed time mark type of the equation.
120  /// The time set used for the fields without explicit time set.
122 
123  /// Time sets of individual fields.
124  std::unordered_map<string, FieldOutputConfig> field_output_times_;
125 
126  /// Set of observed fields. The observe points are given within the observe stream.
127  std::unordered_set<string> observe_fields_;
128 
129  /**
130  * Set of interpolations which are used in performed fields.
131  *
132  * Allow determine type of output mesh.
133  */
134  std::set<OutputTime::DiscreteSpace> used_interpolations_;
135 
136  /**
137  * Cached pointer at computational mesh.
138  */
140 
141  /// Output mesh.
142  std::shared_ptr<OutputMeshBase> output_mesh_;
143 
144 };
145 
146 
147 #endif /* SRC_FIELDS_EQUATION_OUTPUT_HH_ */
FieldSet::mesh
const Mesh * mesh() const
Returns pointer to mesh.
Definition: field_set.hh:370
EquationOutput::initialize
void initialize(std::shared_ptr< OutputTime > stream, Mesh *mesh, Input::Record in_rec, const TimeGovernor &tg)
Definition: equation_output.cc:109
Input
Abstract linear system class.
Definition: balance.hh:40
EquationOutput::select_error_control_field
OutputMeshBase::ErrorControlFieldFunc select_error_control_field()
Selects the error control field out of output field set according to input record.
Definition: equation_output.cc:283
EquationOutput::create_output_field_selection
const Input::Type::Selection & create_output_field_selection(const string &equation_name, const string &additional_description)
Definition: equation_output.cc:66
field_set.hh
EquationOutput::is_field_output_time
bool is_field_output_time(const FieldCommon &field, TimeStep step) const
Definition: equation_output.cc:187
exceptions.hh
EquationOutput::make_output_type
const Input::Type::Instance & make_output_type(const string &equation_name, const string &aditional_description="")
Definition: equation_output.cc:92
OutputMeshBase::ErrorControlFieldFunc
std::function< void(const Armor::array &, const ElementAccessor< spacedim > &, std::vector< double > &)> ErrorControlFieldFunc
Definition: output_mesh.hh:77
OutputTime::DiscreteSpaceFlags
std::array< bool, 4 > DiscreteSpaceFlags
Definition: output_time.hh:122
EquationOutput::FieldOutputConfig::output_set_
OutputTimeSet output_set_
Set of output times.
Definition: equation_output.hh:48
EquationOutput::mesh_
Mesh * mesh_
Definition: equation_output.hh:139
EquationOutput::DECLARE_EXCEPTION
DECLARE_EXCEPTION(ExcFieldNotScalar,<< "Field '"<< FieldCommon::EI_Field::qval<< "' is not scalar in spacedim 3.")
EquationOutput::read_from_input
void read_from_input(Input::Record in_rec, const TimeGovernor &tg)
Definition: equation_output.cc:120
Input::Record
Accessor to the data with type Type::Record.
Definition: accessors.hh:291
EquationOutput
Definition: equation_output.hh:40
TimeStep
Representation of one time step..
Definition: time_governor.hh:123
TimeGovernor
Basic time management functionality for unsteady (and steady) solvers (class Equation).
Definition: time_governor.hh:310
EquationOutput::add_output_times
void add_output_times(double begin, double step, double end)
Definition: equation_output.cc:228
field_values.hh
TimeMark::Type
Definition: time_marks.hh:60
EquationOutput::field_output_times_
std::unordered_map< string, FieldOutputConfig > field_output_times_
Time sets of individual fields.
Definition: equation_output.hh:124
FieldCommon
Common abstract parent of all Field<...> classes.
Definition: field_common.hh:74
OutputTime
The class for outputting data during time.
Definition: output_time.hh:51
EquationOutput::equation_type_
TimeMark::Type equation_type_
The time mark type of the equation.
Definition: equation_output.hh:117
EquationOutput::get_input_type
static Input::Type::Record & get_input_type()
Definition: equation_output.cc:22
Input::Type::Instance
Helper class that stores data of generic types.
Definition: type_generic.hh:89
FieldSet
Container for various descendants of FieldCommonBase.
Definition: field_set.hh:159
output_time_set.hh
Input::Type::Selection
Template for classes storing finite set of named values.
Definition: type_selection.hh:65
Input::Type::Record
Record type proxy class.
Definition: type_record.hh:182
EquationOutput::output
void output(TimeStep step)
Definition: equation_output.cc:199
EquationOutput::observe_fields_
std::unordered_set< string > observe_fields_
Set of observed fields. The observe points are given within the observe stream.
Definition: equation_output.hh:127
Mesh
Definition: mesh.h:77
EquationOutput::make_output_type_from_record
const Input::Type::Instance & make_output_type_from_record(Input::Type::Record &in_rec, const string &equation_name, const string &aditional_description="")
Definition: equation_output.cc:97
output_mesh.hh
Classes for auxiliary output mesh.
EquationOutput::FieldOutputConfig
Configuration of output of one field. Pair of OutputTimeSet and DiscreteSpaces.
Definition: equation_output.hh:47
EquationOutput::FieldOutputConfig::space_flags_
OutputTime::DiscreteSpaceFlags space_flags_
Array of used DiscreteSpaces.
Definition: equation_output.hh:49
EquationOutput::make_output_mesh
void make_output_mesh(bool parallel)
Definition: equation_output.cc:234
EquationOutput::used_interpolations_
std::set< OutputTime::DiscreteSpace > used_interpolations_
Definition: equation_output.hh:134
EquationOutput::common_output_times_
OutputTimeSet common_output_times_
The time set used for the fields without explicit time set.
Definition: equation_output.hh:121
time_marks.hh
OutputTimeSet
Definition: output_time_set.hh:28
EquationOutput::stream_
std::shared_ptr< OutputTime > stream_
output stream (may be shared by more equation)
Definition: equation_output.hh:115
EquationOutput::equation_fixed_type_
TimeMark::Type equation_fixed_type_
The fixed time mark type of the equation.
Definition: equation_output.hh:119
EquationOutput::output_mesh_
std::shared_ptr< OutputMeshBase > output_mesh_
Output mesh.
Definition: equation_output.hh:142
field_common.hh
FieldSet::field
FieldCommon * field(const std::string &field_name) const
Definition: field_set.cc:147