v0.14.0
SeriesRecorder.hpp
Go to the documentation of this file.
1 /** \file SeriesRecorder.hpp
2  * \brief MoFEM interface
3  *
4  * Interface for recording and saving data series, for example in time or load
5  * stepping problems.
6  *
7  * \ingroup mofem_series
8  */
9 
10 #ifndef __SERIESRECORDER_HPP__
11 #define __SERIESRECORDER_HPP__
12 
13 #include "UnknownInterface.hpp"
14 
15 namespace MoFEM {
16 
17 /** Record (time) data series
18  * \ingroup mofem_series
19 
20  Is abstraction of Core interface.
21 
22  \bug fix names of this interface to follow naming convention
23 
24  */
26 
27  MoFEMErrorCode query_interface(boost::typeindex::type_index type_index,
28  UnknownInterface **iface) const;
29 
31  SeriesRecorder(const MoFEM::Core &core);
32 
33  /// destructor
35 
36  /**
37  * \brief get tags handlers used on meshsets
38 
39  */
40  MoFEMErrorCode getTags(int verb = -1);
41 
42  inline Tag get_th_SeriesName() { return th_SeriesName; }
43 
44  /**
45  * \brief clear multi-index container
46  * @return error code
47  */
49 
50  /**
51  * \brier initialize container form data on mesh
52  * @return error code
53  */
55 
56  /**
57  * \brief return pointer to meshset manager
58  */
60 
61  /**
62  * \brief return pointer to meshset manager
63  */
64  const SeriesRecorder *get_series_recorder_ptr() const { return this; }
65 
66  /**
67  * \ingroup mofem_series
68  * Add series recorder
69  *
70  * \param name of series
71  */
72  virtual MoFEMErrorCode add_series_recorder(const std::string &series_name);
73 
74  /**
75  * \ingroup mofem_series
76  * delete recorded series
77  *
78  * \param name of series
79  */
80  virtual MoFEMErrorCode delete_recorder_series(const std::string &series_name);
81 
82  /**
83  * \ingroup mofem_series
84  * initialize sries for recording
85  *
86  * \param series name
87  */
88  virtual MoFEMErrorCode
89  initialize_series_recorder(const std::string &serie_name);
90 
91  /**
92  * \ingroup mofem_series
93  * finalize series for recording, recorded data are not accessible until
94  * finalize
95  *
96  * \param series name
97  */
98  virtual MoFEMErrorCode
99  finalize_series_recorder(const std::string &serie_name);
100 
101  /**
102  * \ingroup mofem_series
103  * begin series recording
104  *
105  * \param series name
106  */
107  virtual MoFEMErrorCode record_begin(const std::string &serie_name);
108 
109  /**
110  * \ingroup mofem_series
111  * record problem
112  *
113  * \param series name
114  * \param problem pointer
115  * \param rc could be Row or Col
116  */
117  virtual MoFEMErrorCode record_problem(const std::string &serie_name,
118  const Problem *problemPtr,
119  RowColData rc);
120 
121  /**
122  * \ingroup mofem_series
123  * record problem
124  *
125  * \param series name
126  * \param problem name
127  * \param rc could be Row or Col
128  */
129  virtual MoFEMErrorCode record_problem(const std::string &serie_name,
130  const std::string &problem_name,
131  RowColData rc);
132 
133  /**
134  * \ingroup mofem_series
135  * record field
136  *
137  * \param field name
138  * \param bit ref level
139  * \param mask for bit ref level
140  */
141  virtual MoFEMErrorCode record_field(const std::string &serie_name,
142  const std::string &field_name,
143  const BitRefLevel &bit,
144  const BitRefLevel &mask);
145 
146  /**
147  * \ingroup mofem_series
148  * end series recording
149  *
150  * \param series name
151  */
152  virtual MoFEMErrorCode record_end(const std::string &serie_name,
153  double time = 0);
154 
155  /**
156  * \ingroup mofem_series
157  * load data from series into dofs database
158  *
159  * \param series name
160  * \param step number
161  */
162  virtual MoFEMErrorCode load_series_data(const std::string &serie_name,
163  const int step_number);
164 
165  /**
166  * \ingroup mofem_series
167  * print series
168  */
170 
171  /** \brief check if series is in database
172  * \ingroup mofem_series
173  *
174  * \param name field name
175  * \return true if field exist
176  *
177  */
178  virtual bool check_series(const std::string &name) const;
179 
180  virtual SeriesStep_multiIndex::index<SeriesName_mi_tag>::type::iterator
181  get_series_steps_byName_begin(const std::string &name);
182  virtual SeriesStep_multiIndex::index<SeriesName_mi_tag>::type::iterator
183  get_series_steps_byName_end(const std::string &name);
184 
185 protected:
186  Tag th_SeriesName; ///< Recorded series name
187 
188  Series_multiIndex sEries; ///< recorded series
189  SeriesStep_multiIndex seriesSteps; ///< recorded series steps
190 
191 /** \brief loop over recorded series step
192  * \ingroup mofem_series
193  *
194  * \param NAME series name
195  * \parma IT iterator variable
196  *
197  * Example: \code
198  for(_IT_SERIES_STEPS_BY_NAME_FOR_LOOP_(recorder_ptr,"TEST_SERIES1",sit)) {
199 
200  ierr = mField.load_series_data("TEST_SERIES1",sit->get_step_number());
201  CHKERRG(ierr);
202  * } \endcode
203  *
204  */
205 #define _IT_SERIES_STEPS_BY_NAME_FOR_LOOP_(RECORDER, NAME, IT) \
206  SeriesStep_multiIndex::index<SeriesName_mi_tag>::type::iterator IT = \
207  (RECORDER)->get_series_steps_byName_begin(NAME); \
208  IT != (RECORDER)->get_series_steps_byName_end(NAME); \
209  IT++
210 };
211 
212 } // namespace MoFEM
213 
214 #endif // __SERIESRECORDER_HPP__
215 
216 /**
217  * \defgroup mofem_series Recording and reading series
218  * Recorder for time steps and solution sequences
219  *
220  * \ingroup mofem
221  */
MoFEM::SeriesRecorder::clearMap
MoFEMErrorCode clearMap()
clear multi-index container
Definition: SeriesRecorder.cpp:40
MoFEM::CoreTmp< 0 >
Core (interface) class.
Definition: Core.hpp:82
MoFEM::SeriesRecorder::get_series_steps_byName_begin
virtual SeriesStep_multiIndex::index< SeriesName_mi_tag >::type::iterator get_series_steps_byName_begin(const std::string &name)
Definition: SeriesRecorder.cpp:329
MoFEM::SeriesRecorder::record_field
virtual MoFEMErrorCode record_field(const std::string &serie_name, const std::string &field_name, const BitRefLevel &bit, const BitRefLevel &mask)
Definition: SeriesRecorder.cpp:181
MoFEM::SeriesRecorder::check_series
virtual bool check_series(const std::string &name) const
check if series is in database
Definition: SeriesRecorder.cpp:301
MoFEM::SeriesRecorder::SeriesRecorder
SeriesRecorder(const MoFEM::Core &core)
Definition: SeriesRecorder.cpp:25
MoFEM::SeriesRecorder
Definition: SeriesRecorder.hpp:25
MoFEM::Exceptions::MoFEMErrorCode
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
Definition: Exceptions.hpp:56
MoFEM::SeriesRecorder::sEries
Series_multiIndex sEries
recorded series
Definition: SeriesRecorder.hpp:188
MoFEM::SeriesRecorder::get_series_recorder_ptr
SeriesRecorder * get_series_recorder_ptr()
return pointer to meshset manager
Definition: SeriesRecorder.hpp:59
MoFEM::SeriesRecorder::cOre
MoFEM::Core & cOre
Definition: SeriesRecorder.hpp:30
MoFEM::SeriesRecorder::seriesSteps
SeriesStep_multiIndex seriesSteps
recorded series steps
Definition: SeriesRecorder.hpp:189
MoFEM::SeriesRecorder::add_series_recorder
virtual MoFEMErrorCode add_series_recorder(const std::string &series_name)
Definition: SeriesRecorder.cpp:90
MoFEM::SeriesRecorder::th_SeriesName
Tag th_SeriesName
Recorded series name.
Definition: SeriesRecorder.hpp:186
MoFEM::SeriesRecorder::print_series_steps
virtual MoFEMErrorCode print_series_steps()
Definition: SeriesRecorder.cpp:286
MoFEM
implementation of Data Operators for Forces and Sources
Definition: Common.hpp:10
MoFEM::SeriesRecorder::record_begin
virtual MoFEMErrorCode record_begin(const std::string &serie_name)
Definition: SeriesRecorder.cpp:218
MoFEM::SeriesRecorder::query_interface
MoFEMErrorCode query_interface(boost::typeindex::type_index type_index, UnknownInterface **iface) const
Definition: SeriesRecorder.cpp:19
bit
auto bit
set bit
Definition: hanging_node_approx.cpp:75
RowColData
RowColData
RowColData.
Definition: definitions.h:136
MoFEM::SeriesRecorder::finalize_series_recorder
virtual MoFEMErrorCode finalize_series_recorder(const std::string &serie_name)
Definition: SeriesRecorder.cpp:264
MoFEM::SeriesStep_multiIndex
multi_index_container< FieldSeriesStep, indexed_by< ordered_unique< tag< Composite_SeriesID_And_Step_mi_tag >, composite_key< FieldSeriesStep, const_mem_fun< FieldSeriesStep::interface_type_FieldSeries, EntityID, &FieldSeriesStep::get_meshset_id >, member< FieldSeriesStep, int, &FieldSeriesStep::step_number > > >, ordered_unique< tag< Composite_SeriesName_And_Step_mi_tag >, composite_key< FieldSeriesStep, const_mem_fun< FieldSeriesStep::interface_type_FieldSeries, boost::string_ref, &FieldSeriesStep::getNameRef >, member< FieldSeriesStep, int, &FieldSeriesStep::step_number > > >, ordered_non_unique< tag< SeriesName_mi_tag >, const_mem_fun< FieldSeriesStep::interface_type_FieldSeries, boost::string_ref, &FieldSeriesStep::getNameRef > >, ordered_non_unique< tag< Composite_SeriesName_And_Time_mi_tag >, composite_key< FieldSeriesStep, const_mem_fun< FieldSeriesStep::interface_type_FieldSeries, boost::string_ref, &FieldSeriesStep::getNameRef >, const_mem_fun< FieldSeriesStep, double, &FieldSeriesStep::get_time > > > > > SeriesStep_multiIndex
Step multi index.
Definition: SeriesMultiIndices.hpp:179
MoFEM::SeriesRecorder::load_series_data
virtual MoFEMErrorCode load_series_data(const std::string &serie_name, const int step_number)
Definition: SeriesRecorder.cpp:309
UnknownInterface.hpp
MoFEM interface.
MoFEM::SeriesRecorder::get_series_steps_byName_end
virtual SeriesStep_multiIndex::index< SeriesName_mi_tag >::type::iterator get_series_steps_byName_end(const std::string &name)
Definition: SeriesRecorder.cpp:334
MoFEM::SeriesRecorder::get_th_SeriesName
Tag get_th_SeriesName()
Definition: SeriesRecorder.hpp:42
field_name
constexpr auto field_name
Definition: poisson_2d_homogeneous.cpp:13
MoFEM::SeriesRecorder::delete_recorder_series
virtual MoFEMErrorCode delete_recorder_series(const std::string &series_name)
Definition: SeriesRecorder.cpp:111
MoFEM::UnknownInterface
base class for all interface classes
Definition: UnknownInterface.hpp:34
MoFEM::SeriesRecorder::initialiseDatabaseFromMesh
MoFEMErrorCode initialiseDatabaseFromMesh(int verb=0)
Definition: SeriesRecorder.cpp:47
MoFEM::SeriesRecorder::~SeriesRecorder
~SeriesRecorder()
destructor
Definition: SeriesRecorder.hpp:34
MoFEM::SeriesRecorder::getTags
MoFEMErrorCode getTags(int verb=-1)
get tags handlers used on meshsets
Definition: SeriesRecorder.cpp:28
MoFEM::SeriesRecorder::get_series_recorder_ptr
const SeriesRecorder * get_series_recorder_ptr() const
return pointer to meshset manager
Definition: SeriesRecorder.hpp:64
MoFEM::SeriesRecorder::record_problem
virtual MoFEMErrorCode record_problem(const std::string &serie_name, const Problem *problemPtr, RowColData rc)
Definition: SeriesRecorder.cpp:141
MoFEM::Types::BitRefLevel
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
Definition: Types.hpp:40
MoFEM::Problem
keeps basic data about problem
Definition: ProblemsMultiIndices.hpp:54
MoFEM::SeriesRecorder::initialize_series_recorder
virtual MoFEMErrorCode initialize_series_recorder(const std::string &serie_name)
Definition: SeriesRecorder.cpp:246
MoFEM::SeriesRecorder::record_end
virtual MoFEMErrorCode record_end(const std::string &serie_name, double time=0)
Definition: SeriesRecorder.cpp:231
MoFEM::Series_multiIndex
multi_index_container< FieldSeries, indexed_by< ordered_unique< tag< SeriesID_mi_tag >, const_mem_fun< FieldSeries, EntityID, &FieldSeries::get_meshset_id > >, ordered_unique< tag< SeriesName_mi_tag >, const_mem_fun< FieldSeries, boost::string_ref, &FieldSeries::getNameRef > > > > Series_multiIndex
Series multi index.
Definition: SeriesMultiIndices.hpp:143