v0.9.1
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 107 of file SeriesRecorder.cpp.

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

◆ 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 315 of file SeriesRecorder.cpp.

315  {
316  Series_multiIndex::index<SeriesName_mi_tag>::type::iterator sit =
317  sEries.get<SeriesName_mi_tag>().find(name);
318  if (sit != sEries.get<SeriesName_mi_tag>().end())
319  return true;
320  return false;
321 }
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 128 of file SeriesRecorder.cpp.

128  {
129 
130  Interface &m_field = cOre;
131  moab::Interface &moab = m_field.get_moab();
133  SeriesStep_multiIndex::index<SeriesName_mi_tag>::type::iterator ssit, hi_ssit;
134  ssit = seriesSteps.get<SeriesName_mi_tag>().lower_bound(series_name);
135  hi_ssit = seriesSteps.get<SeriesName_mi_tag>().upper_bound(series_name);
136  seriesSteps.get<SeriesName_mi_tag>().erase(ssit, hi_ssit);
137  Series_multiIndex::index<SeriesName_mi_tag>::type::iterator sit;
138  sit = sEries.get<SeriesName_mi_tag>().find(series_name);
139  if (sit == sEries.get<SeriesName_mi_tag>().end()) {
140  SETERRQ1(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
141  "series recorder <%s> not exist and can be deleted",
142  series_name.c_str());
143  }
144  EntityHandle series_meshset = sit->getMeshset();
145  CHKERR moab.tag_delete(sit->th_SeriesTime);
146  CHKERR moab.tag_delete(sit->th_SeriesDataHandles);
147  CHKERR moab.tag_delete(sit->th_SeriesDataUIDs);
148  CHKERR moab.tag_delete(sit->th_SeriesData);
149  sEries.get<SeriesName_mi_tag>().erase(sit);
150  std::vector<EntityHandle> contained;
151  CHKERR moab.get_contained_meshsets(series_meshset, contained);
152  CHKERR moab.remove_entities(series_meshset, &contained[0], contained.size());
153  CHKERR moab.delete_entities(&contained[0], contained.size());
154  CHKERR moab.delete_entities(&series_meshset, 1);
156 }
virtual moab::Interface & get_moab()=0
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:483
#define CHKERR
Inline error check.
Definition: definitions.h:602
Series_multiIndex sEries
recorded series
DeprecatedCoreInterface Interface
Definition: Interface.hpp:1788
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:413

◆ 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 280 of file SeriesRecorder.cpp.

280  {
281 
282  Interface &m_field = cOre;
283  moab::Interface &moab = m_field.get_moab();
285  Series_multiIndex::index<SeriesName_mi_tag>::type::iterator sit =
286  sEries.get<SeriesName_mi_tag>().find(serie_name);
287  if (sit == sEries.get<SeriesName_mi_tag>().end()) {
288  SETERRQ1(PETSC_COMM_SELF, 1, "serie recorder <%s> not exist",
289  serie_name.c_str());
290  }
291  CHKERR sit->save(moab);
292  int nb_steps;
293  CHKERR sit->get_nb_steps(moab, nb_steps);
294  int ss = 0;
295  for (; ss < nb_steps; ss++) {
296  /*std::pair<SeriesStep_multiIndex::iterator,bool> p =*/seriesSteps.insert(
297  FieldSeriesStep(moab, &*sit, ss));
298  }
300 }
virtual moab::Interface & get_moab()=0
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:483
#define CHKERR
Inline error check.
Definition: definitions.h:602
Series_multiIndex sEries
recorded series
DeprecatedCoreInterface Interface
Definition: Interface.hpp:1788
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:413

◆ initialize_series_recorder()

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

initialize sries for recording

Parameters
seriesname

Definition at line 262 of file SeriesRecorder.cpp.

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

◆ 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 323 of file SeriesRecorder.cpp.

324  {
325 
326  Interface &m_field = cOre;
327  moab::Interface &moab = m_field.get_moab();
328  const DofEntity_multiIndex *dofs_ptr;
330  SeriesStep_multiIndex::index<
331  Composite_SeriesName_And_Step_mi_tag>::type::iterator sit;
332  sit = seriesSteps.get<Composite_SeriesName_And_Step_mi_tag>().find(
333  boost::make_tuple(serie_name, step_number));
334  if (sit == seriesSteps.get<Composite_SeriesName_And_Step_mi_tag>().end()) {
335  SETERRQ2(PETSC_COMM_SELF, 1, "series <%s> and step %d not found",
336  serie_name.c_str(), step_number);
337  }
338  CHKERR m_field.get_dofs(&dofs_ptr);
339  CHKERR sit->get(moab, *(const_cast<DofEntity_multiIndex *>(dofs_ptr)));
341 }
virtual moab::Interface & get_moab()=0
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:483
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:602
DeprecatedCoreInterface Interface
Definition: Interface.hpp:1788
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:413

◆ print_series_steps()

MoFEMErrorCode MoFEM::SeriesRecorder::print_series_steps ( )
virtual

print series

Definition at line 302 of file SeriesRecorder.cpp.

302  {
304 
305  for (auto &sit : sEries.get<SeriesName_mi_tag>())
306  MOFEM_LOG("SYNC", LogManager::SeverityLevel::inform) << "series " << sit;
307 
308  for (auto &ssit : seriesSteps.get<SeriesName_mi_tag>())
309  MOFEM_LOG("SYNC", LogManager::SeverityLevel::inform)
310  << "series steps " << ssit;
311 
313 }
#define SeriesRecorderFunctionBegin
#define MOFEM_LOG(channel, severity)
Log.
Definition: LogManager.hpp:290
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:483
Series_multiIndex sEries
recorded series
SeriesStep_multiIndex seriesSteps
recorded series steps

◆ record_begin()

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

begin series recording

Parameters
seriesname

Definition at line 234 of file SeriesRecorder.cpp.

234  {
235 
237  Series_multiIndex::index<SeriesName_mi_tag>::type::iterator sit =
238  sEries.get<SeriesName_mi_tag>().find(serie_name);
239  if (sit == sEries.get<SeriesName_mi_tag>().end()) {
240  SETERRQ1(PETSC_COMM_SELF, 1, "serie recorder <%s> not exist",
241  serie_name.c_str());
242  }
243  CHKERR const_cast<FieldSeries *>(&*sit)->begin();
245 }
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:483
#define CHKERR
Inline error check.
Definition: definitions.h:602
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:413

◆ record_end()

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

end series recording

Parameters
seriesname

Definition at line 247 of file SeriesRecorder.cpp.

248  {
249 
251  Series_multiIndex::index<SeriesName_mi_tag>::type::iterator sit =
252  sEries.get<SeriesName_mi_tag>().find(serie_name);
253  if (sit == sEries.get<SeriesName_mi_tag>().end()) {
254  SETERRQ1(PETSC_COMM_SELF, 1, "serie recorder <%s> not exist",
255  serie_name.c_str());
256  }
257  CHKERR const_cast<FieldSeries *>(&*sit)->end(time);
259 }
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:483
#define CHKERR
Inline error check.
Definition: definitions.h:602
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:413

◆ 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 198 of file SeriesRecorder.cpp.

201  {
202 
203  Interface &m_field = cOre;
204  const DofEntity_multiIndex *dofs_ptr;
206  CHKERR m_field.get_dofs(&dofs_ptr);
207  Series_multiIndex::index<SeriesName_mi_tag>::type::iterator sit =
208  sEries.get<SeriesName_mi_tag>().find(serie_name);
209  if (sit == sEries.get<SeriesName_mi_tag>().end()) {
210  SETERRQ1(PETSC_COMM_SELF, 1, "serie recorder <%s> not exist",
211  serie_name.c_str());
212  }
213  DofEntityByFieldName::iterator dit =
214  dofs_ptr->get<FieldName_mi_tag>().lower_bound(field_name);
215  if (dit == dofs_ptr->get<FieldName_mi_tag>().end()) {
216  SETERRQ1(PETSC_COMM_SELF, 1, "field <%s> not exist", field_name.c_str());
217  }
218  DofEntityByFieldName::iterator hi_dit =
219  dofs_ptr->get<FieldName_mi_tag>().upper_bound(field_name);
220  for (; dit != hi_dit; dit++) {
221  const BitRefLevel &dof_bit = (*dit)->getBitRefLevel();
222  if ((dof_bit & mask) != dof_bit)
223  continue;
224  if ((dof_bit & bit).any()) {
225  EntityHandle ent = (*dit)->getEnt();
226  ShortId uid = (*dit)->getNonNonuniqueShortId();
227  FieldData val = (*dit)->getFieldData();
228  CHKERR const_cast<FieldSeries *>(&*sit)->push_dofs(ent, uid, val);
229  }
230  }
232 }
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:483
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:602
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:50
int ShortId
Unique Id in the field.
Definition: Types.hpp:42
Series_multiIndex sEries
recorded series
DeprecatedCoreInterface Interface
Definition: Interface.hpp:1788
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:413

◆ 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 158 of file SeriesRecorder.cpp.

160  {
162 
163  Series_multiIndex::index<SeriesName_mi_tag>::type::iterator sit =
164  sEries.get<SeriesName_mi_tag>().find(serie_name);
165  if (sit == sEries.get<SeriesName_mi_tag>().end()) {
166  SETERRQ1(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
167  "series recorder <%s> not exist", serie_name.c_str());
168  }
169  switch (rc) {
170  case ROW:
171  CHKERR const_cast<FieldSeries *>(&*sit)->push_dofs(
172  problemPtr->numeredDofsRows->begin(),
173  problemPtr->numeredDofsRows->end());
174  break;
175  case COL:
176  CHKERR const_cast<FieldSeries *>(&*sit)->push_dofs(
177  problemPtr->numeredDofsCols->begin(),
178  problemPtr->numeredDofsCols->end());
179  break;
180  default:
181  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY, "data inconsistency");
182  }
184 }
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:483
#define CHKERR
Inline error check.
Definition: definitions.h:602
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:413

◆ 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 186 of file SeriesRecorder.cpp.

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