v0.9.0
Files | Classes | Macros | Functions
Recording and reading series
Collaboration diagram for Recording and reading series:

Files

file  SeriesRecorder.hpp
 MoFEM interface.
 

Classes

struct  MoFEM::SeriesRecorder
 

Macros

#define _IT_SERIES_STEPS_BY_NAME_FOR_LOOP_(RECORDER, NAME, IT)
 loop over recorded series step More...
 

Functions

virtual MoFEMErrorCode MoFEM::SeriesRecorder::add_series_recorder (const std::string &series_name)
 
virtual MoFEMErrorCode MoFEM::SeriesRecorder::delete_recorder_series (const std::string &series_name)
 
virtual MoFEMErrorCode MoFEM::SeriesRecorder::initialize_series_recorder (const std::string &serie_name)
 
virtual MoFEMErrorCode MoFEM::SeriesRecorder::finalize_series_recorder (const std::string &serie_name)
 
virtual MoFEMErrorCode MoFEM::SeriesRecorder::record_begin (const std::string &serie_name)
 
virtual MoFEMErrorCode MoFEM::SeriesRecorder::record_problem (const std::string &serie_name, const Problem *problemPtr, RowColData rc)
 
virtual MoFEMErrorCode MoFEM::SeriesRecorder::record_problem (const std::string &serie_name, const std::string &problem_name, RowColData rc)
 
virtual MoFEMErrorCode MoFEM::SeriesRecorder::record_field (const std::string &serie_name, const std::string &field_name, const BitRefLevel &bit, const BitRefLevel &mask)
 
virtual MoFEMErrorCode MoFEM::SeriesRecorder::record_end (const std::string &serie_name, double time=0)
 
virtual MoFEMErrorCode MoFEM::SeriesRecorder::load_series_data (const std::string &serie_name, const int step_number)
 
virtual MoFEMErrorCode MoFEM::SeriesRecorder::print_series_steps ()
 
virtual bool MoFEM::SeriesRecorder::check_series (const std::string &name) const
 check if series is in database More...
 

Detailed Description

Recorder for time steps and solution sequences

Macro Definition Documentation

◆ _IT_SERIES_STEPS_BY_NAME_FOR_LOOP_

#define _IT_SERIES_STEPS_BY_NAME_FOR_LOOP_ (   RECORDER,
  NAME,
  IT 
)
Value:
SeriesStep_multiIndex::index<SeriesName_mi_tag>::type::iterator IT = \
(RECORDER)->get_series_steps_byName_begin(NAME); \
IT != (RECORDER)->get_series_steps_byName_end(NAME); \
IT++

loop over recorded series step

Parameters
NAMEseries name \parma IT iterator variable

Example:

for(_IT_SERIES_STEPS_BY_NAME_FOR_LOOP_(recorder_ptr,"TEST_SERIES1",sit)) {
ierr = mField.load_series_data("TEST_SERIES1",sit->get_step_number());
}
Examples
elasticity.cpp.

Definition at line 218 of file SeriesRecorder.hpp.

Function Documentation

◆ add_series_recorder()

MoFEMErrorCode MoFEM::SeriesRecorder::add_series_recorder ( const std::string &  series_name)
virtual

Add series recorder

Parameters
nameof series

Definition at line 103 of file SeriesRecorder.cpp.

103  {
104 
105  Interface &m_field = cOre;
106  moab::Interface &moab = m_field.get_moab();
108  EntityHandle meshset;
109  CHKERR moab.create_meshset(MESHSET_SET | MESHSET_TRACK_OWNER, meshset);
110  void const *tag_data[] = {series_name.c_str()};
111  int tag_sizes[1];
112  tag_sizes[0] = series_name.size();
113  CHKERR moab.tag_set_by_ptr(th_SeriesName, &meshset, 1, tag_data, tag_sizes);
114  std::pair<Series_multiIndex::iterator, bool> p =
115  sEries.insert(FieldSeries(moab, meshset));
116  if (!p.second) {
117  SETERRQ1(PETSC_COMM_SELF, 1, "series recorder <%s> is already there",
118  series_name.c_str());
119  }
121 }
moab::Interface & get_moab()
Definition: Core.hpp:266
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:477
Tag th_SeriesName
Recorded series name.
#define CHKERR
Inline error check.
Definition: definitions.h:596
Series_multiIndex sEries
recorded series
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:407

◆ check_series()

bool MoFEM::SeriesRecorder::check_series ( const std::string &  name) const
virtual

check if series is in database

Parameters
namefield name
Returns
true if field exist
Examples
elasticity.cpp.

Definition at line 317 of file SeriesRecorder.cpp.

317  {
318  Series_multiIndex::index<SeriesName_mi_tag>::type::iterator sit =
319  sEries.get<SeriesName_mi_tag>().find(name);
320  if (sit != sEries.get<SeriesName_mi_tag>().end())
321  return true;
322  return false;
323 }
Series_multiIndex sEries
recorded series

◆ delete_recorder_series()

MoFEMErrorCode MoFEM::SeriesRecorder::delete_recorder_series ( const std::string &  series_name)
virtual

delete recorded series

Parameters
nameof series

Definition at line 124 of file SeriesRecorder.cpp.

124  {
125 
126  Interface &m_field = cOre;
127  moab::Interface &moab = m_field.get_moab();
129  SeriesStep_multiIndex::index<SeriesName_mi_tag>::type::iterator ssit, hi_ssit;
130  ssit = seriesSteps.get<SeriesName_mi_tag>().lower_bound(series_name);
131  hi_ssit = seriesSteps.get<SeriesName_mi_tag>().upper_bound(series_name);
132  seriesSteps.get<SeriesName_mi_tag>().erase(ssit, hi_ssit);
133  Series_multiIndex::index<SeriesName_mi_tag>::type::iterator sit;
134  sit = sEries.get<SeriesName_mi_tag>().find(series_name);
135  if (sit == sEries.get<SeriesName_mi_tag>().end()) {
136  SETERRQ1(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
137  "series recorder <%s> not exist and can be deleted",
138  series_name.c_str());
139  }
140  EntityHandle series_meshset = sit->getMeshset();
141  CHKERR moab.tag_delete(sit->th_SeriesTime);
142  CHKERR moab.tag_delete(sit->th_SeriesDataHandles);
143  CHKERR moab.tag_delete(sit->th_SeriesDataUIDs);
144  CHKERR moab.tag_delete(sit->th_SeriesData);
145  sEries.get<SeriesName_mi_tag>().erase(sit);
146  std::vector<EntityHandle> contained;
147  CHKERR moab.get_contained_meshsets(series_meshset, contained);
148  CHKERR moab.remove_entities(series_meshset, &contained[0], contained.size());
149  CHKERR moab.delete_entities(&contained[0], contained.size());
150  CHKERR moab.delete_entities(&series_meshset, 1);
152 }
moab::Interface & get_moab()
Definition: Core.hpp:266
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:477
#define CHKERR
Inline error check.
Definition: definitions.h:596
Series_multiIndex sEries
recorded series
SeriesStep_multiIndex seriesSteps
recorded series steps
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:407

◆ finalize_series_recorder()

MoFEMErrorCode MoFEM::SeriesRecorder::finalize_series_recorder ( const std::string &  serie_name)
virtual

finalize series for recording, recorded data are not accessible until finalize

Parameters
seriesname

Definition at line 276 of file SeriesRecorder.cpp.

276  {
277 
278  Interface &m_field = cOre;
279  moab::Interface &moab = m_field.get_moab();
281  Series_multiIndex::index<SeriesName_mi_tag>::type::iterator sit =
282  sEries.get<SeriesName_mi_tag>().find(serie_name);
283  if (sit == sEries.get<SeriesName_mi_tag>().end()) {
284  SETERRQ1(PETSC_COMM_SELF, 1, "serie recorder <%s> not exist",
285  serie_name.c_str());
286  }
287  CHKERR sit->save(moab);
288  int nb_steps;
289  CHKERR sit->get_nb_steps(moab, nb_steps);
290  int ss = 0;
291  for (; ss < nb_steps; ss++) {
292  /*std::pair<SeriesStep_multiIndex::iterator,bool> p =*/seriesSteps.insert(
293  FieldSeriesStep(moab, &*sit, ss));
294  }
296 }
moab::Interface & get_moab()
Definition: Core.hpp:266
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:477
#define CHKERR
Inline error check.
Definition: definitions.h:596
Series_multiIndex sEries
recorded series
SeriesStep_multiIndex seriesSteps
recorded series steps
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:407

◆ initialize_series_recorder()

MoFEMErrorCode MoFEM::SeriesRecorder::initialize_series_recorder ( const std::string &  serie_name)
virtual

initialize sries for recording

Parameters
seriesname

Definition at line 258 of file SeriesRecorder.cpp.

258  {
259 
260  Interface &m_field = cOre;
261  moab::Interface &moab = m_field.get_moab();
263  Series_multiIndex::index<SeriesName_mi_tag>::type::iterator sit =
264  sEries.get<SeriesName_mi_tag>().find(serie_name);
265  if (sit == sEries.get<SeriesName_mi_tag>().end()) {
266  SETERRQ1(PETSC_COMM_SELF, 1, "serie recorder <%s> not exist",
267  serie_name.c_str());
268  }
269  CHKERR const_cast<FieldSeries *>(&*sit)->read(moab);
270  const_cast<FieldSeries *>(&*sit)->record_begin = false;
271  const_cast<FieldSeries *>(&*sit)->record_end = false;
273 }
moab::Interface & get_moab()
Definition: Core.hpp:266
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:477
#define CHKERR
Inline error check.
Definition: definitions.h:596
Series_multiIndex sEries
recorded series
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:407

◆ load_series_data()

MoFEMErrorCode MoFEM::SeriesRecorder::load_series_data ( const std::string &  serie_name,
const int  step_number 
)
virtual

load data from series into dofs database

Parameters
seriesname
stepnumber
Examples
elasticity.cpp.

Definition at line 325 of file SeriesRecorder.cpp.

326  {
327 
328  Interface &m_field = cOre;
329  moab::Interface &moab = m_field.get_moab();
330  const DofEntity_multiIndex *dofs_ptr;
332  SeriesStep_multiIndex::index<
333  Composite_SeriesName_And_Step_mi_tag>::type::iterator sit;
334  sit = seriesSteps.get<Composite_SeriesName_And_Step_mi_tag>().find(
335  boost::make_tuple(serie_name, step_number));
336  if (sit == seriesSteps.get<Composite_SeriesName_And_Step_mi_tag>().end()) {
337  SETERRQ2(PETSC_COMM_SELF, 1, "series <%s> and step %d not found",
338  serie_name.c_str(), step_number);
339  }
340  CHKERR m_field.get_dofs(&dofs_ptr);
341  CHKERR sit->get(moab, *(const_cast<DofEntity_multiIndex *>(dofs_ptr)));
343 }
moab::Interface & get_moab()
Definition: Core.hpp:266
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:477
multi_index_container< boost::shared_ptr< DofEntity >, indexed_by< ordered_unique< tag< Unique_mi_tag >, member< DofEntity, UId, &DofEntity::globalUId > >, ordered_non_unique< tag< Composite_Name_And_Ent_And_EntDofIdx_mi_tag >, composite_key< DofEntity, const_mem_fun< DofEntity::interface_type_Field, boost::string_ref, &DofEntity::getNameRef >, const_mem_fun< DofEntity, EntityHandle, &DofEntity::getEnt >, const_mem_fun< DofEntity, DofIdx, &DofEntity::getEntDofIdx > > >, ordered_non_unique< tag< Unique_Ent_mi_tag >, const_mem_fun< DofEntity, const UId &, &DofEntity::getEntGlobalUniqueId > >, ordered_non_unique< tag< FieldName_mi_tag >, const_mem_fun< DofEntity::interface_type_Field, boost::string_ref, &DofEntity::getNameRef > >, ordered_non_unique< tag< Ent_mi_tag >, const_mem_fun< DofEntity, EntityHandle, &DofEntity::getEnt > >, ordered_non_unique< tag< Composite_Name_And_Ent_mi_tag >, composite_key< DofEntity, const_mem_fun< DofEntity::interface_type_Field, boost::string_ref, &DofEntity::getNameRef >, const_mem_fun< DofEntity, EntityHandle, &DofEntity::getEnt > > >, ordered_non_unique< tag< Composite_Name_And_Type_mi_tag >, composite_key< DofEntity, const_mem_fun< DofEntity::interface_type_Field, boost::string_ref, &DofEntity::getNameRef >, const_mem_fun< DofEntity::interface_type_RefEntity, EntityType, &DofEntity::getEntType > > > > > DofEntity_multiIndex
MultiIndex container keeps DofEntity.
#define CHKERR
Inline error check.
Definition: definitions.h:596
SeriesStep_multiIndex seriesSteps
recorded series steps
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:407

◆ print_series_steps()

MoFEMErrorCode MoFEM::SeriesRecorder::print_series_steps ( )
virtual

print series

Definition at line 298 of file SeriesRecorder.cpp.

298  {
299  //
300  Interface &m_field = cOre;
302  std::ostringstream ss;
303  Series_multiIndex::index<SeriesName_mi_tag>::type::iterator sit =
304  sEries.get<SeriesName_mi_tag>().begin();
305  for (; sit != sEries.get<SeriesName_mi_tag>().end(); sit++) {
306  ss << "series " << *sit << std::endl;
307  }
308  SeriesStep_multiIndex::index<SeriesName_mi_tag>::type::iterator ssit =
309  seriesSteps.get<SeriesName_mi_tag>().begin();
310  for (; ssit != seriesSteps.get<SeriesName_mi_tag>().end(); ssit++) {
311  ss << "serises steps " << *ssit << std::endl;
312  }
313  PetscPrintf(m_field.get_comm(), ss.str().c_str());
315 }
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:477
Series_multiIndex sEries
recorded series
SeriesStep_multiIndex seriesSteps
recorded series steps
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:407

◆ record_begin()

MoFEMErrorCode MoFEM::SeriesRecorder::record_begin ( const std::string &  serie_name)
virtual

begin series recording

Parameters
seriesname

Definition at line 230 of file SeriesRecorder.cpp.

230  {
231 
233  Series_multiIndex::index<SeriesName_mi_tag>::type::iterator sit =
234  sEries.get<SeriesName_mi_tag>().find(serie_name);
235  if (sit == sEries.get<SeriesName_mi_tag>().end()) {
236  SETERRQ1(PETSC_COMM_SELF, 1, "serie recorder <%s> not exist",
237  serie_name.c_str());
238  }
239  CHKERR const_cast<FieldSeries *>(&*sit)->begin();
241 }
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:477
#define CHKERR
Inline error check.
Definition: definitions.h:596
Series_multiIndex sEries
recorded series
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:407

◆ record_end()

MoFEMErrorCode MoFEM::SeriesRecorder::record_end ( const std::string &  serie_name,
double  time = 0 
)
virtual

end series recording

Parameters
seriesname

Definition at line 243 of file SeriesRecorder.cpp.

244  {
245 
247  Series_multiIndex::index<SeriesName_mi_tag>::type::iterator sit =
248  sEries.get<SeriesName_mi_tag>().find(serie_name);
249  if (sit == sEries.get<SeriesName_mi_tag>().end()) {
250  SETERRQ1(PETSC_COMM_SELF, 1, "serie recorder <%s> not exist",
251  serie_name.c_str());
252  }
253  CHKERR const_cast<FieldSeries *>(&*sit)->end(time);
255 }
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:477
#define CHKERR
Inline error check.
Definition: definitions.h:596
Series_multiIndex sEries
recorded series
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:407

◆ record_field()

MoFEMErrorCode MoFEM::SeriesRecorder::record_field ( const std::string &  serie_name,
const std::string &  field_name,
const BitRefLevel bit,
const BitRefLevel mask 
)
virtual

record field

Parameters
fieldname
bitref level
maskfor bit ref level

Definition at line 194 of file SeriesRecorder.cpp.

197  {
198 
199  Interface &m_field = cOre;
200  const DofEntity_multiIndex *dofs_ptr;
202  CHKERR m_field.get_dofs(&dofs_ptr);
203  Series_multiIndex::index<SeriesName_mi_tag>::type::iterator sit =
204  sEries.get<SeriesName_mi_tag>().find(serie_name);
205  if (sit == sEries.get<SeriesName_mi_tag>().end()) {
206  SETERRQ1(PETSC_COMM_SELF, 1, "serie recorder <%s> not exist",
207  serie_name.c_str());
208  }
209  DofEntityByFieldName::iterator dit =
210  dofs_ptr->get<FieldName_mi_tag>().lower_bound(field_name);
211  if (dit == dofs_ptr->get<FieldName_mi_tag>().end()) {
212  SETERRQ1(PETSC_COMM_SELF, 1, "field <%s> not exist", field_name.c_str());
213  }
214  DofEntityByFieldName::iterator hi_dit =
215  dofs_ptr->get<FieldName_mi_tag>().upper_bound(field_name);
216  for (; dit != hi_dit; dit++) {
217  const BitRefLevel &dof_bit = (*dit)->getBitRefLevel();
218  if ((dof_bit & mask) != dof_bit)
219  continue;
220  if ((dof_bit & bit).any()) {
221  EntityHandle ent = (*dit)->getEnt();
222  ShortId uid = (*dit)->getNonNonuniqueShortId();
223  FieldData val = (*dit)->getFieldData();
224  CHKERR const_cast<FieldSeries *>(&*sit)->push_dofs(ent, uid, val);
225  }
226  }
228 }
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:477
multi_index_container< boost::shared_ptr< DofEntity >, indexed_by< ordered_unique< tag< Unique_mi_tag >, member< DofEntity, UId, &DofEntity::globalUId > >, ordered_non_unique< tag< Composite_Name_And_Ent_And_EntDofIdx_mi_tag >, composite_key< DofEntity, const_mem_fun< DofEntity::interface_type_Field, boost::string_ref, &DofEntity::getNameRef >, const_mem_fun< DofEntity, EntityHandle, &DofEntity::getEnt >, const_mem_fun< DofEntity, DofIdx, &DofEntity::getEntDofIdx > > >, ordered_non_unique< tag< Unique_Ent_mi_tag >, const_mem_fun< DofEntity, const UId &, &DofEntity::getEntGlobalUniqueId > >, ordered_non_unique< tag< FieldName_mi_tag >, const_mem_fun< DofEntity::interface_type_Field, boost::string_ref, &DofEntity::getNameRef > >, ordered_non_unique< tag< Ent_mi_tag >, const_mem_fun< DofEntity, EntityHandle, &DofEntity::getEnt > >, ordered_non_unique< tag< Composite_Name_And_Ent_mi_tag >, composite_key< DofEntity, const_mem_fun< DofEntity::interface_type_Field, boost::string_ref, &DofEntity::getNameRef >, const_mem_fun< DofEntity, EntityHandle, &DofEntity::getEnt > > >, ordered_non_unique< tag< Composite_Name_And_Type_mi_tag >, composite_key< DofEntity, const_mem_fun< DofEntity::interface_type_Field, boost::string_ref, &DofEntity::getNameRef >, const_mem_fun< DofEntity::interface_type_RefEntity, EntityType, &DofEntity::getEntType > > > > > DofEntity_multiIndex
MultiIndex container keeps DofEntity.
#define CHKERR
Inline error check.
Definition: definitions.h:596
double FieldData
Field data type.
Definition: Types.hpp:36
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
Definition: Types.hpp:51
int ShortId
Unique Id in the field.
Definition: Types.hpp:42
Series_multiIndex sEries
recorded series
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:407

◆ record_problem() [1/2]

MoFEMErrorCode MoFEM::SeriesRecorder::record_problem ( const std::string &  serie_name,
const Problem problemPtr,
RowColData  rc 
)
virtual

record problem

Parameters
seriesname
problempointer
rccould be Row or Col

Definition at line 154 of file SeriesRecorder.cpp.

156  {
158 
159  Series_multiIndex::index<SeriesName_mi_tag>::type::iterator sit =
160  sEries.get<SeriesName_mi_tag>().find(serie_name);
161  if (sit == sEries.get<SeriesName_mi_tag>().end()) {
162  SETERRQ1(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
163  "series recorder <%s> not exist", serie_name.c_str());
164  }
165  switch (rc) {
166  case ROW:
167  CHKERR const_cast<FieldSeries *>(&*sit)->push_dofs(
168  problemPtr->numeredDofsRows->begin(),
169  problemPtr->numeredDofsRows->end());
170  break;
171  case COL:
172  CHKERR const_cast<FieldSeries *>(&*sit)->push_dofs(
173  problemPtr->numeredDofsCols->begin(),
174  problemPtr->numeredDofsCols->end());
175  break;
176  default:
177  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY, "data inconsistency");
178  }
180 }
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:477
#define CHKERR
Inline error check.
Definition: definitions.h:596
Series_multiIndex sEries
recorded series
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:407

◆ record_problem() [2/2]

MoFEMErrorCode MoFEM::SeriesRecorder::record_problem ( const std::string &  serie_name,
const std::string &  problem_name,
RowColData  rc 
)
virtual

record problem

Parameters
seriesname
problemname
rccould be Row or Col

Definition at line 182 of file SeriesRecorder.cpp.

184  {
185 
186  Interface &m_field = cOre;
188  const Problem *problem_ptr;
189  CHKERR m_field.get_problem(problem_name, &problem_ptr);
190  CHKERR record_problem(serie_name, problem_ptr, rc);
192 }
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:477
virtual MoFEMErrorCode record_problem(const std::string &serie_name, const Problem *problemPtr, RowColData rc)
#define CHKERR
Inline error check.
Definition: definitions.h:596
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:407