Flow123d  master-c754b67
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_ */
EquationOutput::EquationOutput
EquationOutput()
Default constructor.
Definition: equation_output.cc:82
FieldSet::mesh
const Mesh * mesh() const
Returns pointer to mesh.
Definition: field_set.hh:393
EquationOutput::observe_output_assembly_
GenericAssemblyObserve< AssemblyObserveOutput > * observe_output_assembly_
Definition: equation_output.hh:167
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:140
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:410
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:97
field_set.hh
EquationOutput::is_field_output_time
bool is_field_output_time(const FieldCommon &field, TimeStep step) const
Definition: equation_output.cc:248
EquationOutput::dh_node_
std::shared_ptr< DOFHandlerMultiDim > dh_node_
Definition: equation_output.hh:161
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:123
OutputMeshBase::ErrorControlFieldFunc
std::function< void(const Armor::array &, const ElementAccessor< spacedim > &, std::vector< double > &)> ErrorControlFieldFunc
Definition: output_mesh.hh:77
AssemblyObserveOutput
Definition: assembly_observe.hh:112
EquationOutput::output_node_data_assembly_
GenericAssembly< AssemblyOutputNodeData > * output_node_data_assembly_
Definition: equation_output.hh:165
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:54
Input::Iterator
Definition: accessors.hh:143
EquationOutput::output_corner_data_assembly_
GenericAssembly< AssemblyOutputNodeData > * output_corner_data_assembly_
Definition: equation_output.hh:166
EquationOutput::mesh_
Mesh * mesh_
Definition: equation_output.hh:154
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:170
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:46
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:355
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:139
FieldCommon
Common abstract parent of all Field<...> classes.
Definition: field_common.hh:77
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:132
EquationOutput::get_input_type
static Input::Type::Record & get_input_type()
Definition: equation_output.cc:28
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:261
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:142
Mesh
Definition: mesh.h:362
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:128
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:53
EquationOutput::FieldOutputConfig::space_flags_
OutputTime::DiscreteSpaceFlags space_flags_
Array of used DiscreteSpaces.
Definition: equation_output.hh:55
EquationOutput::make_output_mesh
void make_output_mesh(bool parallel)
Definition: equation_output.cc:361
EquationOutput::dh_
std::shared_ptr< DOFHandlerMultiDim > dh_
Objects for distribution of dofs.
Definition: equation_output.hh:160
AssemblyOutputElemData
Definition: assembly_output.hh:100
EquationOutput::used_interpolations_
std::set< OutputTime::DiscreteSpace > used_interpolations_
Definition: equation_output.hh:149
EquationOutput::common_output_times_
OutputTimeSet common_output_times_
The time set used for the fields without explicit time set.
Definition: equation_output.hh:136
GenericAssemblyObserve
Generic class of observe output assemblation.
Definition: assembly_observe.hh:40
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:164
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:130
EquationOutput::equation_fixed_type_
TimeMark::Type equation_fixed_type_
The fixed time mark type of the equation.
Definition: equation_output.hh:134
EquationOutput::~EquationOutput
~EquationOutput()
Destructor.
Definition: equation_output.cc:88
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:208
GenericAssembly
Generic class of assemblation.
Definition: generic_assembly.hh:165
EquationOutput::output_mesh_
std::shared_ptr< OutputMeshBase > output_mesh_
Output mesh.
Definition: equation_output.hh:157
field_common.hh
FieldSet::field
FieldCommon * field(const std::string &field_name) const
Definition: field_set.cc:173
IntDim
unsigned int IntDim
A dimension index type.
Definition: mixed.hh:19