v0.13.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 /*
11  * MoFEM is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14  * License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with MoFEM. If not, see <http://www.gnu.org/licenses/>
18  */
19 
20 #ifndef __SERIESRECORDER_HPP__
21 #define __SERIESRECORDER_HPP__
22 
23 #include "UnknownInterface.hpp"
24 
25 namespace MoFEM {
26 
27 /** Record (time) data series
28  * \ingroup mofem_series
29 
30  Is abstraction of Core interface.
31 
32  \bug fix names of this interface to follow naming convention
33 
34  */
36 
37  MoFEMErrorCode query_interface(boost::typeindex::type_index type_index,
38  UnknownInterface **iface) const;
39 
41  SeriesRecorder(const MoFEM::Core &core);
42 
43  /// destructor
45 
46  /**
47  * \brief get tags handlers used on meshsets
48 
49  */
50  MoFEMErrorCode getTags(int verb = -1);
51 
52  inline Tag get_th_SeriesName() { return th_SeriesName; }
53 
54  /**
55  * \brief clear multi-index container
56  * @return error code
57  */
59 
60  /**
61  * \brier initialize container form data on mesh
62  * @return error code
63  */
65 
66  /**
67  * \brief return pointer to meshset manager
68  */
70 
71  /**
72  * \brief return pointer to meshset manager
73  */
74  const SeriesRecorder *get_series_recorder_ptr() const { return this; }
75 
76  /**
77  * \ingroup mofem_series
78  * Add series recorder
79  *
80  * \param name of series
81  */
82  virtual MoFEMErrorCode add_series_recorder(const std::string &series_name);
83 
84  /**
85  * \ingroup mofem_series
86  * delete recorded series
87  *
88  * \param name of series
89  */
90  virtual MoFEMErrorCode delete_recorder_series(const std::string &series_name);
91 
92  /**
93  * \ingroup mofem_series
94  * initialize sries for recording
95  *
96  * \param series name
97  */
98  virtual MoFEMErrorCode
99  initialize_series_recorder(const std::string &serie_name);
100 
101  /**
102  * \ingroup mofem_series
103  * finalize series for recording, recorded data are not accessible until
104  * finalize
105  *
106  * \param series name
107  */
108  virtual MoFEMErrorCode
109  finalize_series_recorder(const std::string &serie_name);
110 
111  /**
112  * \ingroup mofem_series
113  * begin series recording
114  *
115  * \param series name
116  */
117  virtual MoFEMErrorCode record_begin(const std::string &serie_name);
118 
119  /**
120  * \ingroup mofem_series
121  * record problem
122  *
123  * \param series name
124  * \param problem pointer
125  * \param rc could be Row or Col
126  */
127  virtual MoFEMErrorCode record_problem(const std::string &serie_name,
128  const Problem *problemPtr,
129  RowColData rc);
130 
131  /**
132  * \ingroup mofem_series
133  * record problem
134  *
135  * \param series name
136  * \param problem name
137  * \param rc could be Row or Col
138  */
139  virtual MoFEMErrorCode record_problem(const std::string &serie_name,
140  const std::string &problem_name,
141  RowColData rc);
142 
143  /**
144  * \ingroup mofem_series
145  * record field
146  *
147  * \param field name
148  * \param bit ref level
149  * \param mask for bit ref level
150  */
151  virtual MoFEMErrorCode record_field(const std::string &serie_name,
152  const std::string &field_name,
153  const BitRefLevel &bit,
154  const BitRefLevel &mask);
155 
156  /**
157  * \ingroup mofem_series
158  * end series recording
159  *
160  * \param series name
161  */
162  virtual MoFEMErrorCode record_end(const std::string &serie_name,
163  double time = 0);
164 
165  /**
166  * \ingroup mofem_series
167  * load data from series into dofs database
168  *
169  * \param series name
170  * \param step number
171  */
172  virtual MoFEMErrorCode load_series_data(const std::string &serie_name,
173  const int step_number);
174 
175  /**
176  * \ingroup mofem_series
177  * print series
178  */
180 
181  /** \brief check if series is in database
182  * \ingroup mofem_series
183  *
184  * \param name field name
185  * \return true if field exist
186  *
187  */
188  virtual bool check_series(const std::string &name) const;
189 
190  virtual SeriesStep_multiIndex::index<SeriesName_mi_tag>::type::iterator
191  get_series_steps_byName_begin(const std::string &name);
192  virtual SeriesStep_multiIndex::index<SeriesName_mi_tag>::type::iterator
193  get_series_steps_byName_end(const std::string &name);
194 
195 protected:
196  Tag th_SeriesName; ///< Recorded series name
197 
198  Series_multiIndex sEries; ///< recorded series
199  SeriesStep_multiIndex seriesSteps; ///< recorded series steps
200 
201 /** \brief loop over recorded series step
202  * \ingroup mofem_series
203  *
204  * \param NAME series name
205  * \parma IT iterator variable
206  *
207  * Example: \code
208  for(_IT_SERIES_STEPS_BY_NAME_FOR_LOOP_(recorder_ptr,"TEST_SERIES1",sit)) {
209 
210  ierr = mField.load_series_data("TEST_SERIES1",sit->get_step_number());
211  CHKERRG(ierr);
212  * } \endcode
213  *
214  */
215 #define _IT_SERIES_STEPS_BY_NAME_FOR_LOOP_(RECORDER, NAME, IT) \
216  SeriesStep_multiIndex::index<SeriesName_mi_tag>::type::iterator IT = \
217  (RECORDER)->get_series_steps_byName_begin(NAME); \
218  IT != (RECORDER)->get_series_steps_byName_end(NAME); \
219  IT++
220 };
221 
222 } // namespace MoFEM
223 
224 #endif // __SERIESRECORDER_HPP__
225 
226 /**
227  * \defgroup mofem_series Recording and reading series
228  * Recorder for time steps and solution sequences
229  *
230  * \ingroup mofem
231  */
MoFEM interface.
RowColData
RowColData.
Definition: definitions.h:136
virtual MoFEMErrorCode load_series_data(const std::string &serie_name, const int step_number)
virtual MoFEMErrorCode print_series_steps()
virtual MoFEMErrorCode finalize_series_recorder(const std::string &serie_name)
virtual bool check_series(const std::string &name) const
check if series is in database
virtual MoFEMErrorCode record_problem(const std::string &serie_name, const Problem *problemPtr, RowColData rc)
virtual MoFEMErrorCode record_field(const std::string &serie_name, const std::string &field_name, const BitRefLevel &bit, const BitRefLevel &mask)
virtual MoFEMErrorCode initialize_series_recorder(const std::string &serie_name)
virtual MoFEMErrorCode add_series_recorder(const std::string &series_name)
virtual MoFEMErrorCode record_begin(const std::string &serie_name)
virtual MoFEMErrorCode record_end(const std::string &serie_name, double time=0)
virtual MoFEMErrorCode delete_recorder_series(const std::string &series_name)
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.
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.
auto bit
set bit
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
Definition: Exceptions.hpp:67
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
Definition: Types.hpp:51
implementation of Data Operators for Forces and Sources
Definition: Common.hpp:21
Core (interface) class.
Definition: Core.hpp:92
keeps basic data about problem
virtual SeriesStep_multiIndex::index< SeriesName_mi_tag >::type::iterator get_series_steps_byName_begin(const std::string &name)
Series_multiIndex sEries
recorded series
SeriesRecorder * get_series_recorder_ptr()
return pointer to meshset manager
MoFEMErrorCode clearMap()
clear multi-index container
SeriesStep_multiIndex seriesSteps
recorded series steps
MoFEMErrorCode query_interface(boost::typeindex::type_index type_index, UnknownInterface **iface) const
SeriesRecorder(const MoFEM::Core &core)
Tag th_SeriesName
Recorded series name.
MoFEMErrorCode getTags(int verb=-1)
get tags handlers used on meshsets
virtual SeriesStep_multiIndex::index< SeriesName_mi_tag >::type::iterator get_series_steps_byName_end(const std::string &name)
const SeriesRecorder * get_series_recorder_ptr() const
return pointer to meshset manager
MoFEMErrorCode initialiseDatabaseFromMesh(int verb=0)
base class for all interface classes