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