Flow123d  DF_patch_fe_data_tables-ab62eed
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<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:
48 
49  DECLARE_EXCEPTION(ExcFieldNotScalar, << "Field '" << FieldCommon::EI_Field::qval
50  << "' is not scalar in spacedim 3.");
51 
52  /// Configuration of output of one field. Pair of OutputTimeSet and DiscreteSpaces.
54  OutputTimeSet output_set_; ///< Set of output times.
55  OutputTime::DiscreteSpaceFlags space_flags_; ///< Array of used DiscreteSpaces
56  };
57 
58  /**
59  * Input type of the configuration record.
60  */
62 
63  /// Default constructor
65 
66  /// Destructor
68 
69  /**
70  * Make Input::Type for the output record. Particular selection of output fields is created
71  * from the contents of *this FieldSet using provided equation name and additional description.
72  */
73  const Input::Type::Instance &make_output_type(const string &equation_name, const string &aditional_description = "");
74  /**
75  * Make Input::Type for the output record.
76  * This function enables creating output record for a field set record with additional keys provided in @p in_rec.
77  */
79  const string &equation_name,
80  const string &aditional_description = "");
81 
82  /**
83  * Setup the object. Set output stream for field and observe output, input record for configuration of the object and
84  * TimeGovernor. The time governor is used to get the equation time mark type, the initial and the end time of the equation.
85  */
86  void initialize(std::shared_ptr<OutputTime> stream, Mesh *mesh, Input::Record in_rec, const TimeGovernor & tg);
87 
88  /**
89  * Returns true if @param field is marked for output in the given time @param step.
90  */
91  bool is_field_output_time(const FieldCommon &field, TimeStep step) const;
92 
93  /**
94  * Performs output of the fields marked for output in the time @param step.
95  */
96  void output(TimeStep step);
97 
98  /// Selects the error control field out of output field set according to input record.
100 
101 private:
102  /**
103  * Creates output selection from the field set.
104  */
105  const Input::Type::Selection& create_output_field_selection(const string &equation_name,
106  const string &additional_description);
107 
108  /**
109  * Read from the input, set output times and time marks. Must be called after set_stream.
110  * TODO: add output_stream times. Optional or always?
111  */
112  void read_from_input(Input::Record in_rec, const TimeGovernor & tg);
113 
114  /**
115  * Add a time grid to the common_output_times.
116  */
117  void add_output_times(double begin, double step, double end);
118 
119 
120  /**
121  * Create the output mesh of \p stream_ OutputTime object. The field set passed in is used
122  * to select the field used for adaptivity of the output mesh.
123  */
124  void make_output_mesh(bool parallel);
125 
126  /// Initialize data of Field given by passed Input::Record
128 
129  /// output stream (may be shared by more equation)
130  std::shared_ptr<OutputTime> stream_;
131  /// The time mark type of the equation.
133  /// The fixed time mark type of the equation.
135  /// The time set used for the fields without explicit time set.
137 
138  /// Time sets of individual fields.
139  std::unordered_map<string, FieldOutputConfig> field_output_times_;
140 
141  /// Set of observed fields. The observe points are given within the observe stream.
142  std::unordered_set<string> observe_fields_;
143 
144  /**
145  * Set of interpolations which are used in performed fields.
146  *
147  * Allow determine type of output mesh.
148  */
149  std::set<OutputTime::DiscreteSpace> used_interpolations_;
150 
151  /**
152  * Cached pointer at computational mesh.
153  */
155 
156  /// Output mesh.
157  std::shared_ptr<OutputMeshBase> output_mesh_;
158 
159  /// Objects for distribution of dofs.
160  std::shared_ptr<DOFHandlerMultiDim> dh_;
161  std::shared_ptr<DOFHandlerMultiDim> dh_node_;
162 
163  /// general assembly objects, hold assembly objects of appropriate dimension
168 
169 };
170 
171 
172 #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.
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.
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.
GenericAssembly< AssemblyOutputNodeData > * output_node_data_assembly_
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)
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.
GenericAssembly< AssemblyOutputNodeData > * output_corner_data_assembly_
void make_output_mesh(bool parallel)
GenericAssembly< AssemblyOutputElemData > * output_elem_data_assembly_
general assembly objects, hold assembly objects of appropriate dimension
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.