v0.14.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< int > ia
 
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 23 of file SeriesMultiIndices.hpp.

Constructor & Destructor Documentation

◆ FieldSeries()

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

Definition at line 8 of file SeriesMultiIndices.cpp.

9  : meshset(_meshset), tagName(NULL), tagNameSize(0), record_begin(false),
10  record_end(false) {
11 
12  Tag th_SeriesName;
13  rval = moab.tag_get_handle("_SeriesName", th_SeriesName);
15  rval = moab.tag_get_by_ptr(th_SeriesName, &meshset, 1,
16  (const void **)&tagName, &tagNameSize);
18 
19  const int def_val_len = 0;
20 
21  // time
22  std::string Tag_SeriesTime = "_SeriesTime_" + getName();
23  double def_time = 0;
24  rval = moab.tag_get_handle(Tag_SeriesTime.c_str(), 1, MB_TYPE_DOUBLE,
25  th_SeriesTime, MB_TAG_CREAT | MB_TAG_SPARSE,
26  &def_time);
28 
29  // handles
30  std::string Tag_DataHandles_SeriesName = "_SeriesDataHandles_" + getName();
31  rval = moab.tag_get_handle(
32  Tag_DataHandles_SeriesName.c_str(), def_val_len, MB_TYPE_HANDLE,
33  th_SeriesDataHandles, MB_TAG_CREAT | MB_TAG_SPARSE | MB_TAG_VARLEN, NULL);
35 
36  // uids
37  std::string Tag_DataUIDs_SeriesName = "_SeriesDataUIDs_" + getName();
38  rval = moab.tag_get_handle(
39  Tag_DataUIDs_SeriesName.c_str(), def_val_len, MB_TYPE_OPAQUE,
41  MB_TAG_CREAT | MB_TAG_SPARSE | MB_TAG_BYTES | MB_TAG_VARLEN, NULL);
43 
44  // data
45  std::string Tag_Data_SeriesName = "_SeriesData_" + getName();
46  rval = moab.tag_get_handle(
47  Tag_Data_SeriesName.c_str(), def_val_len, MB_TYPE_OPAQUE, th_SeriesData,
48  MB_TAG_CREAT | MB_TAG_SPARSE | MB_TAG_BYTES | MB_TAG_VARLEN, NULL);
50 }

Member Function Documentation

◆ begin()

MoFEMErrorCode MoFEM::FieldSeries::begin ( )

Definition at line 72 of file SeriesMultiIndices.cpp.

72  {
74  if (record_begin) {
75  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
76  "recording already begin");
77  }
78  record_begin = true;
80 }

◆ end()

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

Definition at line 82 of file SeriesMultiIndices.cpp.

82  {
84  if (!record_begin) {
85  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
86  "recording not begin it can not be ended");
87  }
88  record_begin = false;
89  record_end = true;
90  ia.push_back(uids.size());
91  time.push_back(t);
93 }

◆ get_FieldSeries_ptr()

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

Definition at line 81 of file SeriesMultiIndices.hpp.

81  {
82  return const_cast<FieldSeries *>(this);
83  };

◆ get_meshset_id()

EntityID MoFEM::FieldSeries::get_meshset_id ( ) const
inline

Definition at line 36 of file SeriesMultiIndices.hpp.

36  {
37  return (EntityID)(meshset & MB_ID_MASK);
38  }

◆ get_nb_steps()

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

Definition at line 52 of file SeriesMultiIndices.cpp.

53  {
55  CHKERR moab.num_contained_meshsets(meshset, &nb_steps);
57 }

◆ getMeshset()

EntityHandle MoFEM::FieldSeries::getMeshset ( ) const
inline

get meshset

Definition at line 35 of file SeriesMultiIndices.hpp.

35 { return meshset; }

◆ getName()

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

get series name

Definition at line 44 of file SeriesMultiIndices.hpp.

44  {
45  return std::string((char *)tagName, tagNameSize);
46  }

◆ getNameRef()

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

get string_ref of series

Definition at line 40 of file SeriesMultiIndices.hpp.

40  {
41  return boost::string_ref((char *)tagName, tagNameSize);
42  }

◆ push_dofs() [1/2]

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

Definition at line 59 of file SeriesMultiIndices.cpp.

60  {
62  if (!record_begin) {
63  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
64  "you neet to set recording");
65  }
66  handles.push_back(ent);
67  uids.push_back(uid);
68  data.push_back(val);
70 }

◆ push_dofs() [2/2]

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

Definition at line 65 of file SeriesMultiIndices.hpp.

65  {
67 
68  for (; it != hi_it; it++) {
69  ierr = push_dofs((*it)->getEnt(), (*it)->getNonNonuniqueShortId(),
70  (*it)->getFieldData());
71  CHKERRG(ierr);
72  }
74  }

◆ read()

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

Definition at line 95 of file SeriesMultiIndices.cpp.

95  {
97 
98  if (record_begin) {
99  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
100  "all series data will be lost");
101  }
102  if (record_end) {
103  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
104  "all series data will be lost");
105  }
106 
107  std::vector<EntityHandle> contained;
108  CHKERR moab.get_contained_meshsets(meshset, contained);
109  ia.resize(0);
110  time.resize(0);
111  handles.resize(0);
112  uids.resize(0);
113  data.resize(0);
114  ia.push_back(0);
115 
116  for (unsigned int mm = 0; mm < contained.size(); mm++) {
117  // time
118  {
119  double t;
120  CHKERR moab.tag_set_data(th_SeriesTime, &meshset, 1, &t);
121  time.push_back(t);
122  }
123  // handles
124  {
125  const EntityHandle *tag_data;
126  int tag_size;
127  CHKERR moab.tag_get_by_ptr(th_SeriesDataHandles, &meshset, 1,
128  (const void **)&tag_data, &tag_size);
129  handles.insert(handles.end(), tag_data, &tag_data[tag_size]);
130  }
131  // uids
132  {
133  const ShortId *tag_data;
134  int tag_size;
135  CHKERR moab.tag_get_by_ptr(th_SeriesDataUIDs, &meshset, 1,
136  (const void **)&tag_data, &tag_size);
137  int nb = tag_size / sizeof(ShortId);
138  uids.insert(uids.end(), tag_data, &tag_data[nb]);
139  }
140  if (handles.size() != uids.size()) {
141  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY, "data inconsistency");
142  }
143  // data
144  {
145  const FieldData *tag_data;
146  int tag_size;
147  CHKERR moab.tag_get_by_ptr(th_SeriesData, &meshset, 1,
148  (const void **)&tag_data, &tag_size);
149  int nb = tag_size / sizeof(FieldData);
150  data.insert(data.end(), tag_data, &tag_data[nb]);
151  }
152  if (data.size() != uids.size()) {
153  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY, "data inconsistency");
154  }
155  ia.push_back(data.size());
156  }
157 
159 }

◆ save()

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

Definition at line 161 of file SeriesMultiIndices.cpp.

161  {
163 
164  if (record_begin) {
165  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY, "switch off recording");
166  }
167  if (!record_end) {
168  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY, "finish recording");
169  }
170 
171  std::vector<EntityHandle> contained;
172  CHKERR moab.get_contained_meshsets(meshset, contained);
173  unsigned int nb_contained = contained.size();
174  if (nb_contained < ia.size() - 1) {
175  contained.resize(ia.size());
176  }
177  for (unsigned int mm = ia.size() - 1; mm < nb_contained; mm++) {
178  CHKERR moab.remove_entities(meshset, &contained[mm], 1);
179  CHKERR moab.delete_entities(&contained[mm], 1);
180  }
181  for (unsigned int mm = nb_contained; mm < ia.size() - 1; mm++) {
182  EntityHandle new_meshset;
183  CHKERR moab.create_meshset(MESHSET_SET, new_meshset);
184  CHKERR moab.add_entities(meshset, &new_meshset, 1);
185  }
186  contained.resize(0);
187  CHKERR moab.get_contained_meshsets(meshset, contained);
188  if (contained.size() != ia.size() - 1) {
189  SETERRQ2(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
190  "data inconsistency nb_contained != ia.size()-1 %d!=%d",
191  contained.size(), ia.size() - 1);
192  }
193 
194  // time
195  for (unsigned int ii = 1; ii < ia.size(); ii++) {
196  CHKERR moab.tag_set_data(th_SeriesTime, &contained[ii - 1], 1,
197  &time[ii - 1]);
198  }
199 
200  // handles
201  for (unsigned int ii = 1; ii < ia.size(); ii++) {
202  void const *tag_data[] = {&handles[ia[ii - 1]]};
203  int tag_sizes[] = {(ia[ii] - ia[ii - 1])};
204  CHKERR moab.tag_set_by_ptr(th_SeriesDataHandles, &contained[ii - 1], 1,
205  tag_data, tag_sizes);
206  }
207  // uids
208  for (unsigned int ii = 1; ii < ia.size(); ii++) {
209  void const *tag_data[] = {&uids[ia[ii - 1]]};
210  int tag_sizes[] = {(ia[ii] - ia[ii - 1]) * (int)sizeof(ShortId)};
211  CHKERR moab.tag_set_by_ptr(th_SeriesDataUIDs, &contained[ii - 1], 1,
212  tag_data, tag_sizes);
213  }
214 
215  // data
216  for (unsigned int ii = 1; ii < ia.size(); ii++) {
217  void const *tag_data[] = {&data[ia[ii - 1]]};
218  int tag_sizes[] = {(ia[ii] - ia[ii - 1]) * (int)sizeof(FieldData)};
219  CHKERR moab.tag_set_by_ptr(th_SeriesData, &contained[ii - 1], 1, tag_data,
220  tag_sizes);
221  }
222 
224 }

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

323  {
324  os << "name " << e.getName() << " meshset " << e.getMeshset();
325  return os;
326 }

Member Data Documentation

◆ data

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

Definition at line 59 of file SeriesMultiIndices.hpp.

◆ handles

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

Definition at line 57 of file SeriesMultiIndices.hpp.

◆ ia

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

Definition at line 55 of file SeriesMultiIndices.hpp.

◆ meshset

EntityHandle MoFEM::FieldSeries::meshset

Definition at line 25 of file SeriesMultiIndices.hpp.

◆ record_begin

bool MoFEM::FieldSeries::record_begin

Definition at line 29 of file SeriesMultiIndices.hpp.

◆ record_end

bool MoFEM::FieldSeries::record_end

Definition at line 30 of file SeriesMultiIndices.hpp.

◆ tagName

const void* MoFEM::FieldSeries::tagName

tag keeps name of the series

Definition at line 26 of file SeriesMultiIndices.hpp.

◆ tagNameSize

int MoFEM::FieldSeries::tagNameSize

number of bits necessary to keep field series

Definition at line 27 of file SeriesMultiIndices.hpp.

◆ th_SeriesData

Tag MoFEM::FieldSeries::th_SeriesData

Definition at line 48 of file SeriesMultiIndices.hpp.

◆ th_SeriesDataHandles

Tag MoFEM::FieldSeries::th_SeriesDataHandles

Definition at line 50 of file SeriesMultiIndices.hpp.

◆ th_SeriesDataUIDs

Tag MoFEM::FieldSeries::th_SeriesDataUIDs

Definition at line 49 of file SeriesMultiIndices.hpp.

◆ th_SeriesTime

Tag MoFEM::FieldSeries::th_SeriesTime

Definition at line 51 of file SeriesMultiIndices.hpp.

◆ time

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

Definition at line 56 of file SeriesMultiIndices.hpp.

◆ uids

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

Definition at line 58 of file SeriesMultiIndices.hpp.


The documentation for this struct was generated from the following files:
MoFEMFunctionReturnHot
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:460
EntityHandle
MoFEM::FieldSeries::uids
std::vector< ShortId > uids
Definition: SeriesMultiIndices.hpp:58
MoFEM::FieldSeries::push_dofs
MoFEMErrorCode push_dofs(const EntityHandle ent, const ShortId uid, const FieldData val)
Definition: SeriesMultiIndices.cpp:59
MoFEM::FieldSeries::meshset
EntityHandle meshset
Definition: SeriesMultiIndices.hpp:25
MoFEM::FieldSeries::tagNameSize
int tagNameSize
number of bits necessary to keep field series
Definition: SeriesMultiIndices.hpp:27
MoFEM::FieldSeries::th_SeriesData
Tag th_SeriesData
Definition: SeriesMultiIndices.hpp:48
MoFEM::FieldSeries::getName
std::string getName() const
get series name
Definition: SeriesMultiIndices.hpp:44
MOAB_THROW
#define MOAB_THROW(err)
Check error code of MoAB function and throw MoFEM exception.
Definition: definitions.h:554
MoFEM::FieldSeries::ia
std::vector< int > ia
Definition: SeriesMultiIndices.hpp:55
MoFEM::FieldSeries::th_SeriesDataHandles
Tag th_SeriesDataHandles
Definition: SeriesMultiIndices.hpp:50
MoFEM::FieldSeries::th_SeriesTime
Tag th_SeriesTime
Definition: SeriesMultiIndices.hpp:51
MoFEM::Exceptions::rval
static MoFEMErrorCodeGeneric< moab::ErrorCode > rval
Definition: Exceptions.hpp:74
CHKERR
#define CHKERR
Inline error check.
Definition: definitions.h:548
MoFEM::FieldSeries::time
std::vector< double > time
Definition: SeriesMultiIndices.hpp:56
MoFEM::FieldSeries::data
std::vector< FieldData > data
Definition: SeriesMultiIndices.hpp:59
MoFEM::Types::ShortId
int ShortId
Unique Id in the field.
Definition: Types.hpp:32
MoFEM::FieldSeries::FieldSeries
FieldSeries(Interface &moab, const EntityHandle _meshset)
Definition: SeriesMultiIndices.cpp:8
MoFEM::FieldSeries::handles
std::vector< EntityHandle > handles
Definition: SeriesMultiIndices.hpp:57
t
constexpr double t
plate stiffness
Definition: plate.cpp:58
MoFEM::FieldSeries::record_begin
bool record_begin
Definition: SeriesMultiIndices.hpp:29
MoFEM::FieldSeries::tagName
const void * tagName
tag keeps name of the series
Definition: SeriesMultiIndices.hpp:26
MoFEM::FieldSeries::th_SeriesDataUIDs
Tag th_SeriesDataUIDs
Definition: SeriesMultiIndices.hpp:49
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::FieldSeries::record_end
bool record_end
Definition: SeriesMultiIndices.hpp:30
MoFEMFunctionBeginHot
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:453
MB_ID_MASK
#define MB_ID_MASK
Definition: definitions.h:247
MoFEMFunctionReturn
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:429
CHKERRG
#define CHKERRG(n)
Check error code of MoFEM/MOAB/PETSc function.
Definition: definitions.h:496
MoFEMFunctionBegin
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:359