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