v0.13.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());
}
#define CHKERRG(n)
Check error code of MoFEM/MOAB/PETSc function.
Definition: definitions.h:496
#define _IT_SERIES_STEPS_BY_NAME_FOR_LOOP_(RECORDER, NAME, IT)
loop over recorded series step
static MoFEMErrorCodeGeneric< PetscErrorCode > ierr
Definition: Exceptions.hpp:87
Examples
elasticity.cpp.

Definition at line 215 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);
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}
static Index< 'p', 3 > p
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:359
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:429
#define CHKERR
Inline error check.
Definition: definitions.h:548
DeprecatedCoreInterface Interface
Definition: Interface.hpp:1965
virtual moab::Interface & get_moab()=0
Series_multiIndex sEries
recorded series
Tag th_SeriesName
Recorded series name.

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

314 {
315 Series_multiIndex::index<SeriesName_mi_tag>::type::iterator sit =
316 sEries.get<SeriesName_mi_tag>().find(name);
317 if (sit != sEries.get<SeriesName_mi_tag>().end())
318 return true;
319 return false;
320}

◆ 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}
@ MOFEM_DATA_INCONSISTENCY
Definition: definitions.h:44
SeriesStep_multiIndex seriesSteps
recorded series steps

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

277 {
278
279 Interface &m_field = cOre;
280 moab::Interface &moab = m_field.get_moab();
282 Series_multiIndex::index<SeriesName_mi_tag>::type::iterator sit =
283 sEries.get<SeriesName_mi_tag>().find(serie_name);
284 if (sit == sEries.get<SeriesName_mi_tag>().end()) {
285 SETERRQ1(PETSC_COMM_SELF, 1, "serie recorder <%s> not exist",
286 serie_name.c_str());
287 }
288 CHKERR sit->save(moab);
289 int nb_steps;
290 CHKERR sit->get_nb_steps(moab, nb_steps);
291 int ss = 0;
292 for (; ss < nb_steps; ss++) {
293 /*std::pair<SeriesStep_multiIndex::iterator,bool> p =*/seriesSteps.insert(
294 FieldSeriesStep(moab, &*sit, ss));
295 }
297}

◆ initialize_series_recorder()

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

initialize sries for recording

Parameters
seriesname

Definition at line 259 of file SeriesRecorder.cpp.

259 {
260
261 Interface &m_field = cOre;
262 moab::Interface &moab = m_field.get_moab();
264 Series_multiIndex::index<SeriesName_mi_tag>::type::iterator sit =
265 sEries.get<SeriesName_mi_tag>().find(serie_name);
266 if (sit == sEries.get<SeriesName_mi_tag>().end()) {
267 SETERRQ1(PETSC_COMM_SELF, 1, "serie recorder <%s> not exist",
268 serie_name.c_str());
269 }
270 CHKERR const_cast<FieldSeries *>(&*sit)->read(moab);
271 const_cast<FieldSeries *>(&*sit)->record_begin = false;
272 const_cast<FieldSeries *>(&*sit)->record_end = false;
274}
virtual MoFEMErrorCode record_begin(const std::string &serie_name)
virtual MoFEMErrorCode record_end(const std::string &serie_name, double time=0)

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

323 {
324
325 Interface &m_field = cOre;
326 moab::Interface &moab = m_field.get_moab();
327 auto dofs_ptr = m_field.get_dofs();
330 Composite_SeriesName_And_Step_mi_tag>::type::iterator sit;
331 sit = seriesSteps.get<Composite_SeriesName_And_Step_mi_tag>().find(
332 boost::make_tuple(serie_name, step_number));
333 if (sit == seriesSteps.get<Composite_SeriesName_And_Step_mi_tag>().end()) {
334 SETERRQ2(PETSC_COMM_SELF, 1, "series <%s> and step %d not found",
335 serie_name.c_str(), step_number);
336 }
337 CHKERR sit->get(moab, *(const_cast<DofEntity_multiIndex *>(dofs_ptr)));
339}
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.

◆ print_series_steps()

MoFEMErrorCode MoFEM::SeriesRecorder::print_series_steps ( )
virtual

print series

Definition at line 299 of file SeriesRecorder.cpp.

299 {
301
302 for (auto &sit : sEries.get<SeriesName_mi_tag>())
303 MOFEM_LOG("SYNC", Sev::inform) << "series " << sit;
304
305 for (auto &ssit : seriesSteps.get<SeriesName_mi_tag>())
306 MOFEM_LOG("SYNC", Sev::inform) << "series steps " << ssit;
307
308 MOFEM_LOG_CHANNEL("WORLD");
309 MOFEM_LOG_CHANNEL("SYNC");
310 MOFEM_LOG_CHANNEL("SELF");
312}
#define SeriesRecorderFunctionBegin
#define MOFEM_LOG(channel, severity)
Log.
Definition: LogManager.hpp:311
#define MOFEM_LOG_CHANNEL(channel)
Set and reset channel.
Definition: LogManager.hpp:287

◆ record_begin()

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

begin series recording

Parameters
seriesname

Definition at line 231 of file SeriesRecorder.cpp.

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

◆ record_end()

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

end series recording

Parameters
seriesname

Definition at line 244 of file SeriesRecorder.cpp.

245 {
246
248 Series_multiIndex::index<SeriesName_mi_tag>::type::iterator sit =
249 sEries.get<SeriesName_mi_tag>().find(serie_name);
250 if (sit == sEries.get<SeriesName_mi_tag>().end()) {
251 SETERRQ1(PETSC_COMM_SELF, 1, "serie recorder <%s> not exist",
252 serie_name.c_str());
253 }
254 CHKERR const_cast<FieldSeries *>(&*sit)->end(time);
256}

◆ 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 Interface &m_field = cOre;
199 auto dofs_ptr = m_field.get_dofs();
201 Series_multiIndex::index<SeriesName_mi_tag>::type::iterator sit =
202 sEries.get<SeriesName_mi_tag>().find(serie_name);
203 if (sit == sEries.get<SeriesName_mi_tag>().end()) {
204 SETERRQ1(PETSC_COMM_SELF, MOFEM_NOT_FOUND, "serie recorder <%s> not exist",
205 serie_name.c_str());
206 }
207
208 const auto bit_number = m_field.get_field_bit_number(field_name);
209
210 auto dit = dofs_ptr->get<Unique_mi_tag>().lower_bound(
212 if (dit == dofs_ptr->get<Unique_mi_tag>().end())
213 SETERRQ1(PETSC_COMM_SELF, MOFEM_NOT_FOUND, "field <%s> not exist", field_name.c_str());
214 auto hi_dit = dofs_ptr->get<Unique_mi_tag>().upper_bound(
216
217 for (; dit != hi_dit; dit++) {
218 const BitRefLevel &dof_bit = (*dit)->getBitRefLevel();
219 if ((dof_bit & mask) != dof_bit)
220 continue;
221 if ((dof_bit & bit).any()) {
222 EntityHandle ent = (*dit)->getEnt();
223 ShortId uid = (*dit)->getNonNonuniqueShortId();
224 FieldData val = (*dit)->getFieldData();
225 CHKERR const_cast<FieldSeries *>(&*sit)->push_dofs(ent, uid, val);
226 }
227 }
229}
@ MOFEM_NOT_FOUND
Definition: definitions.h:46
auto bit
set bit
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:43
constexpr auto field_name
MoFEMErrorCode get_dofs(const DofEntity_multiIndex **dofs_ptr) const
Get dofs multi index.
Definition: Core.cpp:808
static UId getHiBitNumberUId(const FieldBitNumber bit_number)
static UId getLoBitNumberUId(const FieldBitNumber bit_number)

◆ 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->numeredRowDofsPtr->begin(),
169 problemPtr->numeredRowDofsPtr->end());
170 break;
171 case COL:
172 CHKERR const_cast<FieldSeries *>(&*sit)->push_dofs(
173 problemPtr->numeredColDofsPtr->begin(),
174 problemPtr->numeredColDofsPtr->end());
175 break;
176 default:
177 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY, "data inconsistency");
178 }
180}
@ COL
Definition: definitions.h:136
@ ROW
Definition: definitions.h:136

◆ 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}
virtual MoFEMErrorCode record_problem(const std::string &serie_name, const Problem *problemPtr, RowColData rc)