v0.14.0
Files | Macros | Functions
Recording and reading series

Recorder for time steps and solution sequences. More...

Collaboration diagram for Recording and reading series:

Files

file  SeriesRecorder.hpp
 MoFEM interface.
 

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 205 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 90 of file SeriesRecorder.cpp.

90  {
91 
92  Interface &m_field = cOre;
93  moab::Interface &moab = m_field.get_moab();
95  EntityHandle meshset;
96  CHKERR moab.create_meshset(MESHSET_SET, meshset);
97  void const *tag_data[] = {series_name.c_str()};
98  int tag_sizes[1];
99  tag_sizes[0] = series_name.size();
100  CHKERR moab.tag_set_by_ptr(th_SeriesName, &meshset, 1, tag_data, tag_sizes);
101  std::pair<Series_multiIndex::iterator, bool> p =
102  sEries.insert(FieldSeries(moab, meshset));
103  if (!p.second) {
104  SETERRQ1(PETSC_COMM_SELF, 1, "series recorder <%s> is already there",
105  series_name.c_str());
106  }
108 }

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

301  {
302  Series_multiIndex::index<SeriesName_mi_tag>::type::iterator sit =
303  sEries.get<SeriesName_mi_tag>().find(name);
304  if (sit != sEries.get<SeriesName_mi_tag>().end())
305  return true;
306  return false;
307 }

◆ delete_recorder_series()

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

delete recorded series

Parameters
nameof series

Definition at line 111 of file SeriesRecorder.cpp.

111  {
112 
113  Interface &m_field = cOre;
114  moab::Interface &moab = m_field.get_moab();
116  SeriesStep_multiIndex::index<SeriesName_mi_tag>::type::iterator ssit, hi_ssit;
117  ssit = seriesSteps.get<SeriesName_mi_tag>().lower_bound(series_name);
118  hi_ssit = seriesSteps.get<SeriesName_mi_tag>().upper_bound(series_name);
119  seriesSteps.get<SeriesName_mi_tag>().erase(ssit, hi_ssit);
120  Series_multiIndex::index<SeriesName_mi_tag>::type::iterator sit;
121  sit = sEries.get<SeriesName_mi_tag>().find(series_name);
122  if (sit == sEries.get<SeriesName_mi_tag>().end()) {
123  SETERRQ1(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
124  "series recorder <%s> not exist and can be deleted",
125  series_name.c_str());
126  }
127  EntityHandle series_meshset = sit->getMeshset();
128  CHKERR moab.tag_delete(sit->th_SeriesTime);
129  CHKERR moab.tag_delete(sit->th_SeriesDataHandles);
130  CHKERR moab.tag_delete(sit->th_SeriesDataUIDs);
131  CHKERR moab.tag_delete(sit->th_SeriesData);
132  sEries.get<SeriesName_mi_tag>().erase(sit);
133  std::vector<EntityHandle> contained;
134  CHKERR moab.get_contained_meshsets(series_meshset, contained);
135  CHKERR moab.remove_entities(series_meshset, &contained[0], contained.size());
136  CHKERR moab.delete_entities(&contained[0], contained.size());
137  CHKERR moab.delete_entities(&series_meshset, 1);
139 }

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

264  {
265 
266  Interface &m_field = cOre;
267  moab::Interface &moab = m_field.get_moab();
269  Series_multiIndex::index<SeriesName_mi_tag>::type::iterator sit =
270  sEries.get<SeriesName_mi_tag>().find(serie_name);
271  if (sit == sEries.get<SeriesName_mi_tag>().end()) {
272  SETERRQ1(PETSC_COMM_SELF, 1, "serie recorder <%s> not exist",
273  serie_name.c_str());
274  }
275  CHKERR sit->save(moab);
276  int nb_steps;
277  CHKERR sit->get_nb_steps(moab, nb_steps);
278  int ss = 0;
279  for (; ss < nb_steps; ss++) {
280  /*std::pair<SeriesStep_multiIndex::iterator,bool> p =*/seriesSteps.insert(
281  FieldSeriesStep(moab, &*sit, ss));
282  }
284 }

◆ initialize_series_recorder()

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

initialize sries for recording

Parameters
seriesname

Definition at line 246 of file SeriesRecorder.cpp.

246  {
247 
248  Interface &m_field = cOre;
249  moab::Interface &moab = m_field.get_moab();
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)->read(moab);
258  const_cast<FieldSeries *>(&*sit)->record_begin = false;
259  const_cast<FieldSeries *>(&*sit)->record_end = false;
261 }

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

310  {
311 
312  Interface &m_field = cOre;
313  moab::Interface &moab = m_field.get_moab();
314  auto dofs_ptr = m_field.get_dofs();
316  SeriesStep_multiIndex::index<
317  Composite_SeriesName_And_Step_mi_tag>::type::iterator sit;
318  sit = seriesSteps.get<Composite_SeriesName_And_Step_mi_tag>().find(
319  boost::make_tuple(serie_name, step_number));
320  if (sit == seriesSteps.get<Composite_SeriesName_And_Step_mi_tag>().end()) {
321  SETERRQ2(PETSC_COMM_SELF, 1, "series <%s> and step %d not found",
322  serie_name.c_str(), step_number);
323  }
324  CHKERR sit->get(moab, *(const_cast<DofEntity_multiIndex *>(dofs_ptr)));
326 }

◆ print_series_steps()

MoFEMErrorCode MoFEM::SeriesRecorder::print_series_steps ( )
virtual

print series

Definition at line 286 of file SeriesRecorder.cpp.

286  {
288 
289  for (auto &sit : sEries.get<SeriesName_mi_tag>())
290  MOFEM_LOG("SYNC", Sev::inform) << "series " << sit;
291 
292  for (auto &ssit : seriesSteps.get<SeriesName_mi_tag>())
293  MOFEM_LOG("SYNC", Sev::inform) << "series steps " << ssit;
294 
295  MOFEM_LOG_CHANNEL("WORLD");
296  MOFEM_LOG_CHANNEL("SYNC");
297  MOFEM_LOG_CHANNEL("SELF");
299 }

◆ record_begin()

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

begin series recording

Parameters
seriesname

Definition at line 218 of file SeriesRecorder.cpp.

218  {
219 
221  Series_multiIndex::index<SeriesName_mi_tag>::type::iterator sit =
222  sEries.get<SeriesName_mi_tag>().find(serie_name);
223  if (sit == sEries.get<SeriesName_mi_tag>().end()) {
224  SETERRQ1(PETSC_COMM_SELF, 1, "serie recorder <%s> not exist",
225  serie_name.c_str());
226  }
227  CHKERR const_cast<FieldSeries *>(&*sit)->begin();
229 }

◆ record_end()

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

end series recording

Parameters
seriesname

Definition at line 231 of file SeriesRecorder.cpp.

232  {
233 
235  Series_multiIndex::index<SeriesName_mi_tag>::type::iterator sit =
236  sEries.get<SeriesName_mi_tag>().find(serie_name);
237  if (sit == sEries.get<SeriesName_mi_tag>().end()) {
238  SETERRQ1(PETSC_COMM_SELF, 1, "serie recorder <%s> not exist",
239  serie_name.c_str());
240  }
241  CHKERR const_cast<FieldSeries *>(&*sit)->end(time);
243 }

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

184  {
185  Interface &m_field = cOre;
186  auto dofs_ptr = m_field.get_dofs();
188  Series_multiIndex::index<SeriesName_mi_tag>::type::iterator sit =
189  sEries.get<SeriesName_mi_tag>().find(serie_name);
190  if (sit == sEries.get<SeriesName_mi_tag>().end()) {
191  SETERRQ1(PETSC_COMM_SELF, MOFEM_NOT_FOUND, "serie recorder <%s> not exist",
192  serie_name.c_str());
193  }
194 
195  const auto bit_number = m_field.get_field_bit_number(field_name);
196 
197  auto dit = dofs_ptr->get<Unique_mi_tag>().lower_bound(
198  FieldEntity::getLoBitNumberUId(bit_number));
199  if (dit == dofs_ptr->get<Unique_mi_tag>().end())
200  SETERRQ1(PETSC_COMM_SELF, MOFEM_NOT_FOUND, "field <%s> not exist", field_name.c_str());
201  auto hi_dit = dofs_ptr->get<Unique_mi_tag>().upper_bound(
202  FieldEntity::getHiBitNumberUId(bit_number));
203 
204  for (; dit != hi_dit; dit++) {
205  const BitRefLevel &dof_bit = (*dit)->getBitRefLevel();
206  if ((dof_bit & mask) != dof_bit)
207  continue;
208  if ((dof_bit & bit).any()) {
209  EntityHandle ent = (*dit)->getEnt();
210  ShortId uid = (*dit)->getNonNonuniqueShortId();
211  FieldData val = (*dit)->getFieldData();
212  CHKERR const_cast<FieldSeries *>(&*sit)->push_dofs(ent, uid, val);
213  }
214  }
216 }

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

143  {
145 
146  Series_multiIndex::index<SeriesName_mi_tag>::type::iterator sit =
147  sEries.get<SeriesName_mi_tag>().find(serie_name);
148  if (sit == sEries.get<SeriesName_mi_tag>().end()) {
149  SETERRQ1(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
150  "series recorder <%s> not exist", serie_name.c_str());
151  }
152  switch (rc) {
153  case ROW:
154  CHKERR const_cast<FieldSeries *>(&*sit)->push_dofs(
155  problemPtr->numeredRowDofsPtr->begin(),
156  problemPtr->numeredRowDofsPtr->end());
157  break;
158  case COL:
159  CHKERR const_cast<FieldSeries *>(&*sit)->push_dofs(
160  problemPtr->numeredColDofsPtr->begin(),
161  problemPtr->numeredColDofsPtr->end());
162  break;
163  default:
164  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY, "data inconsistency");
165  }
167 }

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

171  {
172 
173  Interface &m_field = cOre;
175  const Problem *problem_ptr;
176  CHKERR m_field.get_problem(problem_name, &problem_ptr);
177  CHKERR record_problem(serie_name, problem_ptr, rc);
179 }
MOFEM_LOG_CHANNEL
#define MOFEM_LOG_CHANNEL(channel)
Set and reset channel.
Definition: LogManager.hpp:284
EntityHandle
MoFEM::SeriesRecorder::sEries
Series_multiIndex sEries
recorded series
Definition: SeriesRecorder.hpp:188
MoFEM::SeriesRecorder::cOre
MoFEM::Core & cOre
Definition: SeriesRecorder.hpp:30
MoFEM::SeriesRecorder::seriesSteps
SeriesStep_multiIndex seriesSteps
recorded series steps
Definition: SeriesRecorder.hpp:189
ROW
@ ROW
Definition: definitions.h:123
MoFEM::Interface
DeprecatedCoreInterface Interface
Definition: Interface.hpp:1975
MoFEM::SeriesRecorder::th_SeriesName
Tag th_SeriesName
Recorded series name.
Definition: SeriesRecorder.hpp:186
CHKERR
#define CHKERR
Inline error check.
Definition: definitions.h:535
MoFEM::CoreInterface::get_moab
virtual moab::Interface & get_moab()=0
MoFEM::SeriesRecorder::record_begin
virtual MoFEMErrorCode record_begin(const std::string &serie_name)
Definition: SeriesRecorder.cpp:218
MoFEM::Types::ShortId
int ShortId
Unique Id in the field.
Definition: Types.hpp:32
bit
auto bit
set bit
Definition: hanging_node_approx.cpp:75
MoFEM::FieldEntity::getLoBitNumberUId
static UId getLoBitNumberUId(const FieldBitNumber bit_number)
Definition: FieldEntsMultiIndices.hpp:222
COL
@ COL
Definition: definitions.h:123
_IT_SERIES_STEPS_BY_NAME_FOR_LOOP_
#define _IT_SERIES_STEPS_BY_NAME_FOR_LOOP_(RECORDER, NAME, IT)
loop over recorded series step
Definition: SeriesRecorder.hpp:205
SeriesRecorderFunctionBegin
#define SeriesRecorderFunctionBegin
Definition: SeriesRecorder.cpp:6
MOFEM_NOT_FOUND
@ MOFEM_NOT_FOUND
Definition: definitions.h:33
IT
constexpr IntegrationType IT
Definition: plastic.cpp:47
field_name
constexpr auto field_name
Definition: poisson_2d_homogeneous.cpp:13
MoFEM::CoreTmp< 0 >::get_dofs
MoFEMErrorCode get_dofs(const DofEntity_multiIndex **dofs_ptr) const
Get dofs multi index.
Definition: Core.cpp:824
MOFEM_LOG
#define MOFEM_LOG(channel, severity)
Log.
Definition: LogManager.hpp:308
MoFEM::Exceptions::ierr
static MoFEMErrorCodeGeneric< PetscErrorCode > ierr
Definition: Exceptions.hpp:76
MoFEM::Types::FieldData
double FieldData
Field data type.
Definition: Types.hpp:25
MOFEM_DATA_INCONSISTENCY
@ MOFEM_DATA_INCONSISTENCY
Definition: definitions.h:31
MoFEM::FieldEntity::getHiBitNumberUId
static UId getHiBitNumberUId(const FieldBitNumber bit_number)
Definition: FieldEntsMultiIndices.hpp:228
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
DofEntity_multiIndex
multi_index_container< boost::shared_ptr< DofEntity >, indexed_by< ordered_unique< tag< Unique_mi_tag >, const_mem_fun< DofEntity, UId, &DofEntity::getLocalUniqueId > >, ordered_non_unique< tag< Ent_mi_tag >, const_mem_fun< DofEntity, EntityHandle, &DofEntity::getEnt > > > > DofEntity_multiIndex
MultiIndex container keeps DofEntity.
Definition: DofsMultiIndices.hpp:317
MoFEMFunctionReturn
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:416
CHKERRG
#define CHKERRG(n)
Check error code of MoFEM/MOAB/PETSc function.
Definition: definitions.h:483
MoFEMFunctionBegin
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:346
MoFEM::SeriesRecorder::record_end
virtual MoFEMErrorCode record_end(const std::string &serie_name, double time=0)
Definition: SeriesRecorder.cpp:231