Flow123d  3.9.0-454df51df
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 class DOFHandlerMultiDim;
27 namespace Input {
28  class Record;
29  namespace Type {
30  class Instance;
31  class Record;
32  class Selection;
33  }
34 }
35 template<unsigned int dim> class AssemblyOutputElemData;
36 template<unsigned int dim> class AssemblyOutputNodeData;
37 template< template<IntDim...> class DimAssembly> class GenericAssembly;
38 
39 
40 /**
41  * A class responsible for check for output times of individual fields
42  * and store their values into the connected output stream.
43  */
44 class EquationOutput : public FieldSet {
45 public:
46 
47  DECLARE_EXCEPTION(ExcFieldNotScalar, << "Field '" << FieldCommon::EI_Field::qval
48  << "' is not scalar in spacedim 3.");
49 
50  /// Configuration of output of one field. Pair of OutputTimeSet and DiscreteSpaces.
52  OutputTimeSet output_set_; ///< Set of output times.
53  OutputTime::DiscreteSpaceFlags space_flags_; ///< Array of used DiscreteSpaces
54  };
55 
56  /**
57  * Input type of the configuration record.
58  */
60 
61  /// Default constructor
63 
64  /// Destructor
66 
67  /**
68  * Make Input::Type for the output record. Particular selection of output fields is created
69  * from the contents of *this FieldSet using provided equation name and additional description.
70  */
71  const Input::Type::Instance &make_output_type(const string &equation_name, const string &aditional_description = "");
72  /**
73  * Make Input::Type for the output record.
74  * This function enables creating output record for a field set record with additional keys provided in @p in_rec.
75  */
77  const string &equation_name,
78  const string &aditional_description = "");
79 
80  /**
81  * Setup the object. Set output stream for field and observe output, input record for configuration of the object and
82  * TimeGovernor. The time governor is used to get the equation time mark type, the initial and the end time of the equation.
83  */
84  void initialize(std::shared_ptr<OutputTime> stream, Mesh *mesh, Input::Record in_rec, const TimeGovernor & tg);
85 
86  /**
87  * Returns true if @param field is marked for output in the given time @param step.
88  */
89  bool is_field_output_time(const FieldCommon &field, TimeStep step) const;
90 
91  /**
92  * Performs output of the fields marked for output in the time @param step.
93  */
94  void output(TimeStep step);
95 
96  /// Selects the error control field out of output field set according to input record.
98 
99 private:
100  /**
101  * Creates output selection from the field set.
102  */
103  const Input::Type::Selection& create_output_field_selection(const string &equation_name,
104  const string &additional_description);
105 
106  /**
107  * Read from the input, set output times and time marks. Must be called after set_stream.
108  * TODO: add output_stream times. Optional or always?
109  */
110  void read_from_input(Input::Record in_rec, const TimeGovernor & tg);
111 
112  /**
113  * Add a time grid to the common_output_times.
114  */
115  void add_output_times(double begin, double step, double end);
116 
117 
118  /**
119  * Create the output mesh of \p stream_ OutputTime object. The field set passed in is used
120  * to select the field used for adaptivity of the output mesh.
121  */
122  void make_output_mesh(bool parallel);
123 
124  /// Initialize data of Field given by passed Input::Record
126 
127  /// output stream (may be shared by more equation)
128  std::shared_ptr<OutputTime> stream_;
129  /// The time mark type of the equation.
131  /// The fixed time mark type of the equation.
133  /// The time set used for the fields without explicit time set.
135 
136  /// Time sets of individual fields.
137  std::unordered_map<string, FieldOutputConfig> field_output_times_;
138 
139  /// Set of observed fields. The observe points are given within the observe stream.
140  std::unordered_set<string> observe_fields_;
141 
142  /**
143  * Set of interpolations which are used in performed fields.
144  *
145  * Allow determine type of output mesh.
146  */
147  std::set<OutputTime::DiscreteSpace> used_interpolations_;
148 
149  /**
150  * Cached pointer at computational mesh.
151  */
153 
154  /// Output mesh.
155  std::shared_ptr<OutputMeshBase> output_mesh_;
156 
157  /// Objects for distribution of dofs.
158  std::shared_ptr<DOFHandlerMultiDim> dh_;
159  std::shared_ptr<DOFHandlerMultiDim> dh_node_;
160 
161  /// general assembly objects, hold assembly objects of appropriate dimension
165 
166 };
167 
168 
169 #endif /* SRC_FIELDS_EQUATION_OUTPUT_HH_ */
EquationOutput::EquationOutput
EquationOutput()
Default constructor.
Definition: equation_output.cc:70
FieldSet::mesh
const Mesh * mesh() const
Returns pointer to mesh.
Definition: field_set.hh:382
AssemblyOutputNodeData
Definition: assembly_output.hh:142
EquationOutput::initialize
void initialize(std::shared_ptr< OutputTime > stream, Mesh *mesh, Input::Record in_rec, const TimeGovernor &tg)
Definition: equation_output.cc:126
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:386
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:83
field_set.hh
EquationOutput::is_field_output_time
bool is_field_output_time(const FieldCommon &field, TimeStep step) const
Definition: equation_output.cc:232
EquationOutput::dh_node_
std::shared_ptr< DOFHandlerMultiDim > dh_node_
Definition: equation_output.hh:159
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:109
OutputMeshBase::ErrorControlFieldFunc
std::function< void(const Armor::array &, const ElementAccessor< spacedim > &, std::vector< double > &)> ErrorControlFieldFunc
Definition: output_mesh.hh:77
EquationOutput::output_node_data_assembly_
GenericAssembly< AssemblyOutputNodeData > * output_node_data_assembly_
Definition: equation_output.hh:163
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:52
Input::Iterator
Definition: accessors.hh:143
EquationOutput::output_corner_data_assembly_
GenericAssembly< AssemblyOutputNodeData > * output_corner_data_assembly_
Definition: equation_output.hh:164
EquationOutput::mesh_
Mesh * mesh_
Definition: equation_output.hh:152
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:155
Input::Record
Accessor to the data with type Type::Record.
Definition: accessors.hh:291
DOFHandlerMultiDim
Provides the numbering of the finite element degrees of freedom on the computational mesh.
Definition: dofhandler.hh:151
EquationOutput
Definition: equation_output.hh:44
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:317
EquationOutput::add_output_times
void add_output_times(double begin, double step, double end)
Definition: equation_output.cc:331
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:137
FieldCommon
Common abstract parent of all Field<...> classes.
Definition: field_common.hh:76
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:130
EquationOutput::get_input_type
static Input::Type::Record & get_input_type()
Definition: equation_output.cc:26
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
Definition: balance.hh:41
Input::Type::Record
Record type proxy class.
Definition: type_record.hh:182
EquationOutput::output
void output(TimeStep step)
Definition: equation_output.cc:245
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:140
Mesh
Definition: mesh.h:361
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:114
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:51
EquationOutput::FieldOutputConfig::space_flags_
OutputTime::DiscreteSpaceFlags space_flags_
Array of used DiscreteSpaces.
Definition: equation_output.hh:53
EquationOutput::make_output_mesh
void make_output_mesh(bool parallel)
Definition: equation_output.cc:337
EquationOutput::dh_
std::shared_ptr< DOFHandlerMultiDim > dh_
Objects for distribution of dofs.
Definition: equation_output.hh:158
AssemblyOutputElemData
Definition: assembly_output.hh:100
EquationOutput::used_interpolations_
std::set< OutputTime::DiscreteSpace > used_interpolations_
Definition: equation_output.hh:147
EquationOutput::common_output_times_
OutputTimeSet common_output_times_
The time set used for the fields without explicit time set.
Definition: equation_output.hh:134
time_marks.hh
EquationOutput::output_elem_data_assembly_
GenericAssembly< AssemblyOutputElemData > * output_elem_data_assembly_
general assembly objects, hold assembly objects of appropriate dimension
Definition: equation_output.hh:162
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:128
EquationOutput::equation_fixed_type_
TimeMark::Type equation_fixed_type_
The fixed time mark type of the equation.
Definition: equation_output.hh:132
EquationOutput::~EquationOutput
~EquationOutput()
Destructor.
Definition: equation_output.cc:75
EquationOutput::init_field_item
void init_field_item(Input::Iterator< Input::Record > it, const TimeGovernor &tg)
Initialize data of Field given by passed Input::Record.
Definition: equation_output.cc:193
GenericAssembly
Generic class of assemblation.
Definition: generic_assembly.hh:160
EquationOutput::output_mesh_
std::shared_ptr< OutputMeshBase > output_mesh_
Output mesh.
Definition: equation_output.hh:155
field_common.hh
FieldSet::field
FieldCommon * field(const std::string &field_name) const
Definition: field_set.cc:168
IntDim
unsigned int IntDim
A dimension index type.
Definition: mixed.hh:19