v0.9.0
Public Member Functions | Public Attributes | Friends | List of all members
MoFEM::FieldSeries Struct Reference

Structure for recording (time) series. More...

#include <src/multi_indices/SeriesMultiIndices.hpp>

Collaboration diagram for MoFEM::FieldSeries:
[legend]

Public Member Functions

 FieldSeries (Interface &moab, const EntityHandle _meshset)
 
EntityHandle getMeshset () const
 get meshset More...
 
EntityID get_meshset_id () const
 
boost::string_ref getNameRef () const
 get string_ref of series More...
 
std::string getName () const
 get series name More...
 
MoFEMErrorCode get_nb_steps (Interface &moab, int &nb_setps) const
 
MoFEMErrorCode set_time (double time)
 
MoFEMErrorCode push_dofs (const EntityHandle ent, const ShortId uid, const FieldData val)
 
template<typename IT >
MoFEMErrorCode push_dofs (IT it, IT hi_it)
 
MoFEMErrorCode begin ()
 
MoFEMErrorCode end (double time=0)
 
MoFEMErrorCode read (Interface &moab)
 
MoFEMErrorCode save (Interface &moab) const
 
const FieldSeriesget_FieldSeries_ptr () const
 

Public Attributes

EntityHandle meshset
 
const void * tagName
 tag keeps name of the series More...
 
int tagNameSize
 number of bits necessary to keep field series More...
 
bool record_begin
 
bool record_end
 
Tag th_SeriesData
 
Tag th_SeriesDataUIDs
 
Tag th_SeriesDataHandles
 
Tag th_SeriesTime
 
std::vector< intia
 
std::vector< doubletime
 
std::vector< EntityHandlehandles
 
std::vector< ShortIduids
 
std::vector< FieldDatadata
 

Friends

std::ostream & operator<< (std::ostream &os, const FieldSeries &e)
 

Detailed Description

Structure for recording (time) series.

Bug:

Fix member functions names. Not follow naming convention.

Member functions not documented

Definition at line 36 of file SeriesMultiIndices.hpp.

Constructor & Destructor Documentation

◆ FieldSeries()

MoFEM::FieldSeries::FieldSeries ( Interface moab,
const EntityHandle  _meshset 
)

Definition at line 21 of file SeriesMultiIndices.cpp.

22  : meshset(_meshset), tagName(NULL), tagNameSize(0), record_begin(false),
23  record_end(false) {
24 
25  Tag th_SeriesName;
26  rval = moab.tag_get_handle("_SeriesName", th_SeriesName);
28  rval = moab.tag_get_by_ptr(th_SeriesName, &meshset, 1,
29  (const void **)&tagName, &tagNameSize);
31 
32  const int def_val_len = 0;
33 
34  // time
35  std::string Tag_SeriesTime = "_SeriesTime_" + getName();
36  double def_time = 0;
37  rval = moab.tag_get_handle(Tag_SeriesTime.c_str(), 1, MB_TYPE_DOUBLE,
38  th_SeriesTime, MB_TAG_CREAT | MB_TAG_SPARSE,
39  &def_time);
41 
42  // handles
43  std::string Tag_DataHandles_SeriesName = "_SeriesDataHandles_" + getName();
44  rval = moab.tag_get_handle(
45  Tag_DataHandles_SeriesName.c_str(), def_val_len, MB_TYPE_HANDLE,
46  th_SeriesDataHandles, MB_TAG_CREAT | MB_TAG_SPARSE | MB_TAG_VARLEN, NULL);
48 
49  // uids
50  std::string Tag_DataUIDs_SeriesName = "_SeriesDataUIDs_" + getName();
51  rval = moab.tag_get_handle(
52  Tag_DataUIDs_SeriesName.c_str(), def_val_len, MB_TYPE_OPAQUE,
54  MB_TAG_CREAT | MB_TAG_SPARSE | MB_TAG_BYTES | MB_TAG_VARLEN, NULL);
56 
57  // data
58  std::string Tag_Data_SeriesName = "_SeriesData_" + getName();
59  rval = moab.tag_get_handle(
60  Tag_Data_SeriesName.c_str(), def_val_len, MB_TYPE_OPAQUE, th_SeriesData,
61  MB_TAG_CREAT | MB_TAG_SPARSE | MB_TAG_BYTES | MB_TAG_VARLEN, NULL);
63 }
#define MOAB_THROW(a)
Check error code of MoAB function and throw MoFEM exception.
Definition: definitions.h:602
static MoFEMErrorCodeGeneric< moab::ErrorCode > rval
Definition: Exceptions.hpp:84
std::string getName() const
get series name
int tagNameSize
number of bits necessary to keep field series
const void * tagName
tag keeps name of the series

Member Function Documentation

◆ begin()

MoFEMErrorCode MoFEM::FieldSeries::begin ( )

Definition at line 85 of file SeriesMultiIndices.cpp.

85  {
87  if (record_begin) {
88  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
89  "recording already begin");
90  }
91  record_begin = true;
93 }
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:477
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:407

◆ end()

MoFEMErrorCode MoFEM::FieldSeries::end ( double  time = 0)

Definition at line 95 of file SeriesMultiIndices.cpp.

95  {
97  if (!record_begin) {
98  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
99  "recording not begin it can not be ended");
100  }
101  record_begin = false;
102  record_end = true;
103  ia.push_back(uids.size());
104  time.push_back(t);
106 }
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:477
std::vector< double > time
std::vector< int > ia
std::vector< ShortId > uids
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:407

◆ get_FieldSeries_ptr()

const FieldSeries* MoFEM::FieldSeries::get_FieldSeries_ptr ( ) const

Definition at line 94 of file SeriesMultiIndices.hpp.

94  {
95  return const_cast<FieldSeries *>(this);
96  };

◆ get_meshset_id()

EntityID MoFEM::FieldSeries::get_meshset_id ( ) const

Definition at line 49 of file SeriesMultiIndices.hpp.

49  {
50  return (EntityID)(meshset & MB_ID_MASK);
51  }
#define MB_ID_MASK
Definition: definitions.h:296

◆ get_nb_steps()

MoFEMErrorCode MoFEM::FieldSeries::get_nb_steps ( Interface moab,
int nb_setps 
) const

Definition at line 65 of file SeriesMultiIndices.cpp.

66  {
68  CHKERR moab.num_contained_meshsets(meshset, &nb_steps);
70 }
#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
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:407

◆ getMeshset()

EntityHandle MoFEM::FieldSeries::getMeshset ( ) const

get meshset

Definition at line 48 of file SeriesMultiIndices.hpp.

48 { return meshset; }

◆ getName()

std::string MoFEM::FieldSeries::getName ( ) const

get series name

Definition at line 57 of file SeriesMultiIndices.hpp.

57  {
58  return std::string((char *)tagName, tagNameSize);
59  }
int tagNameSize
number of bits necessary to keep field series
const void * tagName
tag keeps name of the series

◆ getNameRef()

boost::string_ref MoFEM::FieldSeries::getNameRef ( ) const

get string_ref of series

Definition at line 53 of file SeriesMultiIndices.hpp.

53  {
54  return boost::string_ref((char *)tagName, tagNameSize);
55  }
int tagNameSize
number of bits necessary to keep field series
const void * tagName
tag keeps name of the series

◆ push_dofs() [1/2]

MoFEMErrorCode MoFEM::FieldSeries::push_dofs ( const EntityHandle  ent,
const ShortId  uid,
const FieldData  val 
)

Definition at line 72 of file SeriesMultiIndices.cpp.

73  {
75  if (!record_begin) {
76  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
77  "you neet to set recording");
78  }
79  handles.push_back(ent);
80  uids.push_back(uid);
81  data.push_back(val);
83 }
std::vector< FieldData > data
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:477
std::vector< EntityHandle > handles
std::vector< ShortId > uids
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:407

◆ push_dofs() [2/2]

template<typename IT >
MoFEMErrorCode MoFEM::FieldSeries::push_dofs ( IT  it,
IT  hi_it 
)

Definition at line 78 of file SeriesMultiIndices.hpp.

78  {
80 
81  for (; it != hi_it; it++) {
82  ierr = push_dofs((*it)->getEnt(), (*it)->getNonNonuniqueShortId(),
83  (*it)->getFieldData());
84  CHKERRG(ierr);
85  }
87  }
MoFEMErrorCode push_dofs(const EntityHandle ent, const ShortId uid, const FieldData val)
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:501
#define CHKERRG(n)
Check error code of MoFEM/MOAB/PETSc function.
Definition: definitions.h:544
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:508

◆ read()

MoFEMErrorCode MoFEM::FieldSeries::read ( Interface moab)

Definition at line 108 of file SeriesMultiIndices.cpp.

108  {
110 
111  if (record_begin) {
112  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
113  "all series data will be lost");
114  }
115  if (record_end) {
116  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
117  "all series data will be lost");
118  }
119 
120  std::vector<EntityHandle> contained;
121  CHKERR moab.get_contained_meshsets(meshset, contained);
122  ia.resize(0);
123  time.resize(0);
124  handles.resize(0);
125  uids.resize(0);
126  data.resize(0);
127  ia.push_back(0);
128 
129  for (unsigned int mm = 0; mm < contained.size(); mm++) {
130  // time
131  {
132  double t;
133  CHKERR moab.tag_set_data(th_SeriesTime, &meshset, 1, &t);
134  time.push_back(t);
135  }
136  // handles
137  {
138  const EntityHandle *tag_data;
139  int tag_size;
140  CHKERR moab.tag_get_by_ptr(th_SeriesDataHandles, &meshset, 1,
141  (const void **)&tag_data, &tag_size);
142  handles.insert(handles.end(), tag_data, &tag_data[tag_size]);
143  }
144  // uids
145  {
146  const ShortId *tag_data;
147  int tag_size;
148  CHKERR moab.tag_get_by_ptr(th_SeriesDataUIDs, &meshset, 1,
149  (const void **)&tag_data, &tag_size);
150  int nb = tag_size / sizeof(ShortId);
151  uids.insert(uids.end(), tag_data, &tag_data[nb]);
152  }
153  if (handles.size() != uids.size()) {
154  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY, "data inconsistency");
155  }
156  // data
157  {
158  const FieldData *tag_data;
159  int tag_size;
160  CHKERR moab.tag_get_by_ptr(th_SeriesData, &meshset, 1,
161  (const void **)&tag_data, &tag_size);
162  int nb = tag_size / sizeof(FieldData);
163  data.insert(data.end(), tag_data, &tag_data[nb]);
164  }
165  if (data.size() != uids.size()) {
166  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY, "data inconsistency");
167  }
168  ia.push_back(data.size());
169  }
170 
172 }
std::vector< FieldData > data
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:477
std::vector< double > time
std::vector< int > ia
std::vector< EntityHandle > handles
std::vector< ShortId > uids
#define CHKERR
Inline error check.
Definition: definitions.h:596
double FieldData
Field data type.
Definition: Types.hpp:36
int ShortId
Unique Id in the field.
Definition: Types.hpp:42
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:407

◆ save()

MoFEMErrorCode MoFEM::FieldSeries::save ( Interface moab) const

Definition at line 174 of file SeriesMultiIndices.cpp.

174  {
176 
177  if (record_begin) {
178  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY, "switch off recording");
179  }
180  if (!record_end) {
181  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY, "finish recording");
182  }
183 
184  std::vector<EntityHandle> contained;
185  CHKERR moab.get_contained_meshsets(meshset, contained);
186  unsigned int nb_contained = contained.size();
187  if (nb_contained < ia.size() - 1) {
188  contained.resize(ia.size());
189  }
190  for (unsigned int mm = ia.size() - 1; mm < nb_contained; mm++) {
191  CHKERR moab.remove_entities(meshset, &contained[mm], 1);
192  CHKERR moab.delete_entities(&contained[mm], 1);
193  }
194  for (unsigned int mm = nb_contained; mm < ia.size() - 1; mm++) {
195  EntityHandle new_meshset;
196  CHKERR moab.create_meshset(MESHSET_SET | MESHSET_TRACK_OWNER, new_meshset);
197  CHKERR moab.add_entities(meshset, &new_meshset, 1);
198  }
199  contained.resize(0);
200  CHKERR moab.get_contained_meshsets(meshset, contained);
201  if (contained.size() != ia.size() - 1) {
202  SETERRQ2(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
203  "data inconsistency nb_contained != ia.size()-1 %d!=%d",
204  contained.size(), ia.size() - 1);
205  }
206 
207  // time
208  for (unsigned int ii = 1; ii < ia.size(); ii++) {
209  CHKERR moab.tag_set_data(th_SeriesTime, &contained[ii - 1], 1,
210  &time[ii - 1]);
211  }
212 
213  // handles
214  for (unsigned int ii = 1; ii < ia.size(); ii++) {
215  void const *tag_data[] = {&handles[ia[ii - 1]]};
216  int tag_sizes[] = {(ia[ii] - ia[ii - 1])};
217  CHKERR moab.tag_set_by_ptr(th_SeriesDataHandles, &contained[ii - 1], 1,
218  tag_data, tag_sizes);
219  }
220  // uids
221  for (unsigned int ii = 1; ii < ia.size(); ii++) {
222  void const *tag_data[] = {&uids[ia[ii - 1]]};
223  int tag_sizes[] = {(ia[ii] - ia[ii - 1]) * (int)sizeof(ShortId)};
224  CHKERR moab.tag_set_by_ptr(th_SeriesDataUIDs, &contained[ii - 1], 1,
225  tag_data, tag_sizes);
226  }
227 
228  // data
229  for (unsigned int ii = 1; ii < ia.size(); ii++) {
230  void const *tag_data[] = {&data[ia[ii - 1]]};
231  int tag_sizes[] = {(ia[ii] - ia[ii - 1]) * (int)sizeof(FieldData)};
232  CHKERR moab.tag_set_by_ptr(th_SeriesData, &contained[ii - 1], 1, tag_data,
233  tag_sizes);
234  }
235 
237 }
std::vector< FieldData > data
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:477
std::vector< double > time
std::vector< int > ia
std::vector< EntityHandle > handles
std::vector< ShortId > uids
#define CHKERR
Inline error check.
Definition: definitions.h:596
double FieldData
Field data type.
Definition: Types.hpp:36
int ShortId
Unique Id in the field.
Definition: Types.hpp:42
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:407

◆ set_time()

MoFEMErrorCode MoFEM::FieldSeries::set_time ( double  time)

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  os,
const FieldSeries e 
)
friend

Definition at line 336 of file SeriesMultiIndices.cpp.

336  {
337  os << "name " << e.getName() << " meshset " << e.getMeshset();
338  return os;
339 }

Member Data Documentation

◆ data

std::vector<FieldData> MoFEM::FieldSeries::data

Definition at line 72 of file SeriesMultiIndices.hpp.

◆ handles

std::vector<EntityHandle> MoFEM::FieldSeries::handles

Definition at line 70 of file SeriesMultiIndices.hpp.

◆ ia

std::vector<int> MoFEM::FieldSeries::ia

Definition at line 68 of file SeriesMultiIndices.hpp.

◆ meshset

EntityHandle MoFEM::FieldSeries::meshset

Definition at line 38 of file SeriesMultiIndices.hpp.

◆ record_begin

bool MoFEM::FieldSeries::record_begin

Definition at line 42 of file SeriesMultiIndices.hpp.

◆ record_end

bool MoFEM::FieldSeries::record_end

Definition at line 43 of file SeriesMultiIndices.hpp.

◆ tagName

const void* MoFEM::FieldSeries::tagName

tag keeps name of the series

Definition at line 39 of file SeriesMultiIndices.hpp.

◆ tagNameSize

int MoFEM::FieldSeries::tagNameSize

number of bits necessary to keep field series

Definition at line 40 of file SeriesMultiIndices.hpp.

◆ th_SeriesData

Tag MoFEM::FieldSeries::th_SeriesData

Definition at line 61 of file SeriesMultiIndices.hpp.

◆ th_SeriesDataHandles

Tag MoFEM::FieldSeries::th_SeriesDataHandles

Definition at line 63 of file SeriesMultiIndices.hpp.

◆ th_SeriesDataUIDs

Tag MoFEM::FieldSeries::th_SeriesDataUIDs

Definition at line 62 of file SeriesMultiIndices.hpp.

◆ th_SeriesTime

Tag MoFEM::FieldSeries::th_SeriesTime

Definition at line 64 of file SeriesMultiIndices.hpp.

◆ time

std::vector<double> MoFEM::FieldSeries::time

Definition at line 69 of file SeriesMultiIndices.hpp.

◆ uids

std::vector<ShortId> MoFEM::FieldSeries::uids

Definition at line 71 of file SeriesMultiIndices.hpp.


The documentation for this struct was generated from the following files: