v0.8.4
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 namining convention.

Member functions not doucmented

Definition at line 35 of file SeriesMultiIndices.hpp.

Constructor & Destructor Documentation

◆ FieldSeries()

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

Definition at line 36 of file SeriesMultiIndices.cpp.

36  :
37  meshset(_meshset),tagName(NULL),tagNameSize(0),
38  record_begin(false),record_end(false) {
39  ErrorCode rval;
40 
41  Tag th_SeriesName;
42  rval = moab.tag_get_handle("_SeriesName",th_SeriesName); MOAB_THROW(rval);
43  rval = moab.tag_get_by_ptr(th_SeriesName,&meshset,1,(const void **)&tagName,&tagNameSize); MOAB_THROW(rval);
44 
45  const int def_val_len = 0;
46 
47  //time
48  std::string Tag_SeriesTime = "_SeriesTime_"+getName();
49  double def_time = 0;
50  rval = moab.tag_get_handle(Tag_SeriesTime.c_str(),1,MB_TYPE_DOUBLE,
51  th_SeriesTime,MB_TAG_CREAT|MB_TAG_SPARSE,&def_time); MOAB_THROW(rval);
52 
53  //handles
54  std::string Tag_DataHandles_SeriesName = "_SeriesDataHandles_"+getName();
55  rval = moab.tag_get_handle(Tag_DataHandles_SeriesName.c_str(),def_val_len,MB_TYPE_HANDLE,
56  th_SeriesDataHandles,MB_TAG_CREAT|MB_TAG_SPARSE|MB_TAG_VARLEN,NULL); MOAB_THROW(rval);
57 
58  //uids
59  std::string Tag_DataUIDs_SeriesName = "_SeriesDataUIDs_"+getName();
60  rval = moab.tag_get_handle(Tag_DataUIDs_SeriesName.c_str(),def_val_len,MB_TYPE_OPAQUE,
61  th_SeriesDataUIDs,MB_TAG_CREAT|MB_TAG_SPARSE|MB_TAG_BYTES|MB_TAG_VARLEN,NULL); MOAB_THROW(rval);
62 
63  //data
64  std::string Tag_Data_SeriesName = "_SeriesData_"+getName();
65  rval = moab.tag_get_handle(Tag_Data_SeriesName.c_str(),def_val_len,MB_TYPE_OPAQUE,
66  th_SeriesData,MB_TAG_CREAT|MB_TAG_SPARSE|MB_TAG_BYTES|MB_TAG_VARLEN,NULL); MOAB_THROW(rval);
67 
68 }
#define MOAB_THROW(a)
Check error code of MoAB function and throw MoFEM exception.
Definition: definitions.h:623
static MoFEMErrorCodeGeneric< moab::ErrorCode > rval
Definition: Common.hpp:78
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 88 of file SeriesMultiIndices.cpp.

88  {
90  if(record_begin) {
91  SETERRQ(PETSC_COMM_SELF,MOFEM_DATA_INCONSISTENCY,"recording already begin");
92  }
93  record_begin = true;
95 }
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:522
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return() ...
Definition: definitions.h:528

◆ end()

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

Definition at line 97 of file SeriesMultiIndices.cpp.

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

◆ get_FieldSeries_ptr()

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

Definition at line 85 of file SeriesMultiIndices.hpp.

85 { return const_cast<FieldSeries*>(this); };
FieldSeries(Interface &moab, const EntityHandle _meshset)

◆ get_meshset_id()

EntityID MoFEM::FieldSeries::get_meshset_id ( ) const

Definition at line 48 of file SeriesMultiIndices.hpp.

48 { return (EntityID)(meshset&MB_ID_MASK); }
#define MB_ID_MASK
Definition: definitions.h:334

◆ get_nb_steps()

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

Definition at line 70 of file SeriesMultiIndices.cpp.

70  {
72  ErrorCode rval;
73  rval = moab.num_contained_meshsets(meshset,&nb_steps); CHKERRQ_MOAB(rval);
75 }
#define CHKERRQ_MOAB(a)
check error code of MoAB function
Definition: definitions.h:536
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:522
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return() ...
Definition: definitions.h:528
static MoFEMErrorCodeGeneric< moab::ErrorCode > rval
Definition: Common.hpp:78

◆ getMeshset()

EntityHandle MoFEM::FieldSeries::getMeshset ( ) const

get meshset

Definition at line 47 of file SeriesMultiIndices.hpp.

47 { return meshset; }

◆ getName()

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

get series name

Definition at line 52 of file SeriesMultiIndices.hpp.

52 { return std::string((char *)tagName,tagNameSize); }
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 50 of file SeriesMultiIndices.hpp.

50 { return boost::string_ref((char *)tagName,tagNameSize); }
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 77 of file SeriesMultiIndices.cpp.

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

◆ push_dofs() [2/2]

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

Definition at line 71 of file SeriesMultiIndices.hpp.

71  {
73 
74  for(;it!=hi_it;it++) {
75  ierr = push_dofs((*it)->getEnt(),(*it)->getNonNonuniqueShortId(),(*it)->getFieldData()); CHKERRG(ierr);
76  }
78  }
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:522
#define CHKERRG(n)
Check error code of MoFEM/MOAB/PETSc function.
Definition: definitions.h:565
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return() ...
Definition: definitions.h:528
static MoFEMErrorCodeGeneric< PetscErrorCode > ierr
Definition: Common.hpp:80

◆ read()

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

Definition at line 109 of file SeriesMultiIndices.cpp.

109  {
111  ErrorCode rval;
112 
113  if(record_begin) {
114  SETERRQ(PETSC_COMM_SELF,MOFEM_DATA_INCONSISTENCY,"all series data will be lost");
115  }
116  if(record_end) {
117  SETERRQ(PETSC_COMM_SELF,MOFEM_DATA_INCONSISTENCY,"all series data will be lost");
118  }
119 
120  std::vector<EntityHandle> contained;
121  rval = moab.get_contained_meshsets(meshset,contained); CHKERRQ_MOAB(rval);
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  rval = moab.tag_set_data(th_SeriesTime,&meshset,1,&t); CHKERRQ_MOAB(rval);
134  time.push_back(t);
135  }
136  //handles
137  {
138  const EntityHandle* tag_data;
139  int tag_size;
140  rval = moab.tag_get_by_ptr(th_SeriesDataHandles,&meshset,1,(const void **)&tag_data,&tag_size); CHKERRQ_MOAB(rval);
141  handles.insert(handles.end(),tag_data,&tag_data[tag_size]);
142  }
143  //uids
144  {
145  const ShortId* tag_data;
146  int tag_size;
147  rval = moab.tag_get_by_ptr(th_SeriesDataUIDs,&meshset,1,(const void **)&tag_data,&tag_size); CHKERRQ_MOAB(rval);
148  int nb = tag_size/sizeof(ShortId);
149  uids.insert(uids.end(),tag_data,&tag_data[nb]);
150  }
151  if(handles.size() != uids.size()) {
152  SETERRQ(PETSC_COMM_SELF,MOFEM_DATA_INCONSISTENCY,"data inconsistency");
153  }
154  //data
155  {
156  const FieldData* tag_data;
157  int tag_size;
158  rval = moab.tag_get_by_ptr(th_SeriesData,&meshset,1,(const void **)&tag_data,&tag_size); CHKERRQ_MOAB(rval);
159  int nb = tag_size/sizeof(FieldData);
160  data.insert(data.end(),tag_data,&tag_data[nb]);
161  }
162  if(data.size() != uids.size()) {
163  SETERRQ(PETSC_COMM_SELF,MOFEM_DATA_INCONSISTENCY,"data inconsistency");
164  }
165  ia.push_back(data.size());
166  }
167 
169 }
#define CHKERRQ_MOAB(a)
check error code of MoAB function
Definition: definitions.h:536
int ShortId
Unique Id in the field.
Definition: Common.hpp:137
std::vector< FieldData > data
double FieldData
Field data type.
Definition: Common.hpp:130
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:522
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return() ...
Definition: definitions.h:528
std::vector< double > time
std::vector< int > ia
static MoFEMErrorCodeGeneric< moab::ErrorCode > rval
Definition: Common.hpp:78
std::vector< EntityHandle > handles
std::vector< ShortId > uids

◆ save()

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

Definition at line 171 of file SeriesMultiIndices.cpp.

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

◆ 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 302 of file SeriesMultiIndices.cpp.

302  {
303  os << "name " << e.getName() << " meshset " << e.getMeshset();
304  return os;
305 }

Member Data Documentation

◆ data

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

Definition at line 65 of file SeriesMultiIndices.hpp.

◆ handles

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

Definition at line 63 of file SeriesMultiIndices.hpp.

◆ ia

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

Definition at line 61 of file SeriesMultiIndices.hpp.

◆ meshset

EntityHandle MoFEM::FieldSeries::meshset

Definition at line 37 of file SeriesMultiIndices.hpp.

◆ record_begin

bool MoFEM::FieldSeries::record_begin

Definition at line 41 of file SeriesMultiIndices.hpp.

◆ record_end

bool MoFEM::FieldSeries::record_end

Definition at line 42 of file SeriesMultiIndices.hpp.

◆ tagName

const void* MoFEM::FieldSeries::tagName

tag keeps name of the series

Definition at line 38 of file SeriesMultiIndices.hpp.

◆ tagNameSize

int MoFEM::FieldSeries::tagNameSize

number of bits necessary to keep field series

Definition at line 39 of file SeriesMultiIndices.hpp.

◆ th_SeriesData

Tag MoFEM::FieldSeries::th_SeriesData

Definition at line 54 of file SeriesMultiIndices.hpp.

◆ th_SeriesDataHandles

Tag MoFEM::FieldSeries::th_SeriesDataHandles

Definition at line 56 of file SeriesMultiIndices.hpp.

◆ th_SeriesDataUIDs

Tag MoFEM::FieldSeries::th_SeriesDataUIDs

Definition at line 55 of file SeriesMultiIndices.hpp.

◆ th_SeriesTime

Tag MoFEM::FieldSeries::th_SeriesTime

Definition at line 57 of file SeriesMultiIndices.hpp.

◆ time

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

Definition at line 62 of file SeriesMultiIndices.hpp.

◆ uids

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

Definition at line 64 of file SeriesMultiIndices.hpp.


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