v0.14.0
SeriesMultiIndices.hpp
Go to the documentation of this file.
1 /** \file SeriesMultiIndices.hpp
2  * \brief Multindex containers, for mofem fields data structures and other
3  low-level functions
4  *
5  */
6 
7 #ifndef __SERIESMULTIINDICES_HPP__
8 #define __SERIESMULTIINDICES_HPP__
9 
10 namespace MoFEM {
11 
12 struct FieldSeriesStep;
13 
14 /**
15  * \brief Structure for recording (time) series
16  *
17  * \ingroup series_multi_indices
18  *
19  * \bug Fix member functions names. Not follow naming convention.
20  * \bug Member functions not documented
21  *
22  */
23 struct FieldSeries {
24 
26  const void *tagName; ///< tag keeps name of the series
27  int tagNameSize; ///< number of bits necessary to keep field series
28 
30  bool record_end;
31 
32  FieldSeries(Interface &moab, const EntityHandle _meshset);
33 
34  /// get meshset
35  inline EntityHandle getMeshset() const { return meshset; }
36  inline EntityID get_meshset_id() const {
37  return (EntityID)(meshset & MB_ID_MASK);
38  }
39  /// get string_ref of series
40  inline boost::string_ref getNameRef() const {
41  return boost::string_ref((char *)tagName, tagNameSize);
42  }
43  /// get series name
44  inline std::string getName() const {
45  return std::string((char *)tagName, tagNameSize);
46  }
47 
52 
53  MoFEMErrorCode get_nb_steps(Interface &moab, int &nb_setps) const;
54 
55  std::vector<int> ia;
56  std::vector<double> time;
57  std::vector<EntityHandle> handles;
58  std::vector<ShortId> uids;
59  std::vector<FieldData> data;
60 
62  MoFEMErrorCode push_dofs(const EntityHandle ent, const ShortId uid,
63  const FieldData val);
64 
65  template <typename IT> MoFEMErrorCode push_dofs(IT it, IT hi_it) {
67 
68  for (; it != hi_it; it++) {
69  ierr = push_dofs((*it)->getEnt(), (*it)->getNonNonuniqueShortId(),
70  (*it)->getFieldData());
71  CHKERRG(ierr);
72  }
74  }
75 
77  MoFEMErrorCode end(double time = 0);
79  MoFEMErrorCode save(Interface &moab) const;
80 
81  inline const FieldSeries *get_FieldSeries_ptr() const {
82  return const_cast<FieldSeries *>(this);
83  };
84 
85  friend std::ostream &operator<<(std::ostream &os, const FieldSeries &e);
86 };
87 
88 template <typename T> struct interface_FieldSeries {
89  const T *ptr;
90  interface_FieldSeries(const T *_ptr) : ptr(_ptr) {}
91 
92  /// get meshset
93  inline EntityHandle getMeshset() const { return ptr->getMeshset(); }
94  inline EntityID get_meshset_id() const { return ptr->get_meshset_id(); }
95  /// get string_ref of series
96  inline boost::string_ref getNameRef() const { return ptr->getNameRef(); }
97  /// get series name
98  inline std::string getName() const { return ptr->getName(); }
99 
100  inline const FieldSeries *get_FieldSeries_ptr() const {
101  return ptr->get_FieldSeries_ptr();
102  };
103 };
104 
105 /**
106  * \brief Structure for keeping time and step
107  *
108  * \ingroup series_multi_indices
109  *
110  * \bug Fix member functions names. Not follow namining convention.
111  */
112 struct FieldSeriesStep : public interface_FieldSeries<FieldSeries> {
113 
115 
117  FieldSeriesStep(Interface &moab, const FieldSeries *_FieldSeries_ptr,
118  const int _step_number);
119 
120  inline int get_step_number() const { return step_number; };
121  MoFEMErrorCode get(Interface &moab, DofEntity_multiIndex &dofsField) const;
122 
123  double time;
125  inline double get_time() const { return time; }
126 
127  friend std::ostream &operator<<(std::ostream &os, const FieldSeriesStep &e);
128 };
129 
130 /**
131  * \brief Series multi index
132  *
133  * \ingroup series_multi_indices
134  */
135 typedef multi_index_container<
136  FieldSeries,
137  indexed_by<ordered_unique<tag<SeriesID_mi_tag>,
138  const_mem_fun<FieldSeries, EntityID,
140  ordered_unique<tag<SeriesName_mi_tag>,
141  const_mem_fun<FieldSeries, boost::string_ref,
144 
145 /**
146  * \brief Step multi index
147  *
148  * \ingroup series_multi_indices
149  */
150 typedef multi_index_container<
152  indexed_by<
153  ordered_unique<
154  tag<Composite_SeriesID_And_Step_mi_tag>,
155  composite_key<
159  member<FieldSeriesStep, int, &FieldSeriesStep::step_number>>>,
160  ordered_unique<
161  tag<Composite_SeriesName_And_Step_mi_tag>,
162  composite_key<
165  boost::string_ref, &FieldSeriesStep::getNameRef>,
166  member<FieldSeriesStep, int, &FieldSeriesStep::step_number>>>,
167  ordered_non_unique<
168  tag<SeriesName_mi_tag>,
170  boost::string_ref, &FieldSeriesStep::getNameRef>>,
171  ordered_non_unique<
172  tag<Composite_SeriesName_And_Time_mi_tag>,
173  composite_key<
176  boost::string_ref, &FieldSeriesStep::getNameRef>,
177  const_mem_fun<FieldSeriesStep, double,
180 
181 } // namespace MoFEM
182 
183 /***************************************************************************/ /**
184 * \defgroup series_multi_indices Series structures and multi-indices
185 * \brief Interface used to record fields and play them back (for example response of structure subjected to earthquake)
186 *
187 * The idea of this interface is taken from Opensees
188 * <http://opensees.berkeley.edu>, tailored and generalised for MoFEM code. In
189 * principle, one can record tape in for a sequence of points (for example steps
190 * in time) and play it back. One can create several tapes and record all fields
191 * or some of them.
192 *
193 * User do not use multi-indices data structures directly, recording and playing
194 * data is by MoFEM::SeriesRecorder interface, more in module \ref mofem_series
195 *
196 * \ingroup mofem
197 ******************************************************************************/
198 
199 #endif // __SERIESMULTIINDICES_HPP__
MoFEMFunctionReturnHot
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:447
MoFEM::FieldSeries::getMeshset
EntityHandle getMeshset() const
get meshset
Definition: SeriesMultiIndices.hpp:35
MoFEM::interface_FieldSeries::ptr
const T * ptr
Definition: SeriesMultiIndices.hpp:89
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::FieldSeriesStep::time
double time
Definition: SeriesMultiIndices.hpp:123
MoFEM::interface_FieldSeries::getNameRef
boost::string_ref getNameRef() const
get string_ref of series
Definition: SeriesMultiIndices.hpp:96
MoFEM::Exceptions::MoFEMErrorCode
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
Definition: Exceptions.hpp:56
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::set_time
MoFEMErrorCode set_time(double time)
MoFEM::FieldSeries::getName
std::string getName() const
get series name
Definition: SeriesMultiIndices.hpp:44
MoFEM::FieldSeries::ia
std::vector< int > ia
Definition: SeriesMultiIndices.hpp:55
MoFEM::FieldSeriesStep::get_time
double get_time() const
Definition: SeriesMultiIndices.hpp:125
MoFEM::interface_FieldSeries::getName
std::string getName() const
get series name
Definition: SeriesMultiIndices.hpp:98
MoFEM::FieldSeries::get_meshset_id
EntityID get_meshset_id() const
Definition: SeriesMultiIndices.hpp:36
MoFEM::interface_FieldSeries::get_meshset_id
EntityID get_meshset_id() const
Definition: SeriesMultiIndices.hpp:94
MoFEM::DeprecatedCoreInterface
Deprecated interface functions.
Definition: DeprecatedCoreInterface.hpp:16
MoFEM::FieldSeries::end
MoFEMErrorCode end(double time=0)
Definition: SeriesMultiIndices.cpp:82
MoFEM::FieldSeries::th_SeriesDataHandles
Tag th_SeriesDataHandles
Definition: SeriesMultiIndices.hpp:50
MoFEM::FieldSeries::th_SeriesTime
Tag th_SeriesTime
Definition: SeriesMultiIndices.hpp:51
MoFEM::FieldSeries::time
std::vector< double > time
Definition: SeriesMultiIndices.hpp:56
MoFEM::FieldSeries::getNameRef
boost::string_ref getNameRef() const
get string_ref of series
Definition: SeriesMultiIndices.hpp:40
MoFEM::FieldSeries::data
std::vector< FieldData > data
Definition: SeriesMultiIndices.hpp:59
MoFEM
implementation of Data Operators for Forces and Sources
Definition: Common.hpp:10
MoFEM::Types::ShortId
int ShortId
Unique Id in the field.
Definition: Types.hpp:32
MoFEM::FieldSeries::save
MoFEMErrorCode save(Interface &moab) const
Definition: SeriesMultiIndices.cpp:161
MoFEM::FieldSeriesStep::step_number
int step_number
Definition: SeriesMultiIndices.hpp:116
double
MoFEM::FieldSeries::operator<<
friend std::ostream & operator<<(std::ostream &os, const FieldSeries &e)
Definition: SeriesMultiIndices.cpp:323
MoFEM::FieldSeries::FieldSeries
FieldSeries(Interface &moab, const EntityHandle _meshset)
Definition: SeriesMultiIndices.cpp:8
MoFEM::SeriesStep_multiIndex
multi_index_container< FieldSeriesStep, indexed_by< ordered_unique< tag< Composite_SeriesID_And_Step_mi_tag >, composite_key< FieldSeriesStep, const_mem_fun< FieldSeriesStep::interface_type_FieldSeries, EntityID, &FieldSeriesStep::get_meshset_id >, member< FieldSeriesStep, int, &FieldSeriesStep::step_number > > >, ordered_unique< tag< Composite_SeriesName_And_Step_mi_tag >, composite_key< FieldSeriesStep, const_mem_fun< FieldSeriesStep::interface_type_FieldSeries, boost::string_ref, &FieldSeriesStep::getNameRef >, member< FieldSeriesStep, int, &FieldSeriesStep::step_number > > >, ordered_non_unique< tag< SeriesName_mi_tag >, const_mem_fun< FieldSeriesStep::interface_type_FieldSeries, boost::string_ref, &FieldSeriesStep::getNameRef > >, ordered_non_unique< tag< Composite_SeriesName_And_Time_mi_tag >, composite_key< FieldSeriesStep, const_mem_fun< FieldSeriesStep::interface_type_FieldSeries, boost::string_ref, &FieldSeriesStep::getNameRef >, const_mem_fun< FieldSeriesStep, double, &FieldSeriesStep::get_time > > > > > SeriesStep_multiIndex
Step multi index.
Definition: SeriesMultiIndices.hpp:179
MoFEM::FieldSeries::get_nb_steps
MoFEMErrorCode get_nb_steps(Interface &moab, int &nb_setps) const
Definition: SeriesMultiIndices.cpp:52
MoFEM::FieldSeriesStep::get
MoFEMErrorCode get(Interface &moab, DofEntity_multiIndex &dofsField) const
Definition: SeriesMultiIndices.cpp:236
MoFEM::FieldSeries
Structure for recording (time) series.
Definition: SeriesMultiIndices.hpp:23
MoFEM::interface_FieldSeries::get_FieldSeries_ptr
const FieldSeries * get_FieldSeries_ptr() const
Definition: SeriesMultiIndices.hpp:100
MoFEM::FieldSeries::handles
std::vector< EntityHandle > handles
Definition: SeriesMultiIndices.hpp:57
IT
constexpr IntegrationType IT
Definition: plastic.cpp:47
MoFEM::FieldSeries::record_begin
bool record_begin
Definition: SeriesMultiIndices.hpp:29
MoFEM::FieldSeriesStep
Structure for keeping time and step.
Definition: SeriesMultiIndices.hpp:112
MoFEM::FieldSeries::tagName
const void * tagName
tag keeps name of the series
Definition: SeriesMultiIndices.hpp:26
MoFEM::FieldSeriesStep::get_step_number
int get_step_number() const
Definition: SeriesMultiIndices.hpp:120
MoFEM::FieldSeries::th_SeriesDataUIDs
Tag th_SeriesDataUIDs
Definition: SeriesMultiIndices.hpp:49
MoFEM::FieldSeries::begin
MoFEMErrorCode begin()
Definition: SeriesMultiIndices.cpp:72
MoFEM::FieldSeries::read
MoFEMErrorCode read(Interface &moab)
Definition: SeriesMultiIndices.cpp:95
MoFEM::Exceptions::ierr
static MoFEMErrorCodeGeneric< PetscErrorCode > ierr
Definition: Exceptions.hpp:76
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:440
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
MoFEM::FieldSeriesStep::get_time_init
MoFEMErrorCode get_time_init(Interface &moab)
Definition: SeriesMultiIndices.cpp:307
MB_ID_MASK
#define MB_ID_MASK
Definition: definitions.h:234
MoFEM::FieldSeries::push_dofs
MoFEMErrorCode push_dofs(IT it, IT hi_it)
Definition: SeriesMultiIndices.hpp:65
MoFEM::interface_FieldSeries::getMeshset
EntityHandle getMeshset() const
get meshset
Definition: SeriesMultiIndices.hpp:93
MoFEM::FieldSeriesStep::interface_type_FieldSeries
interface_FieldSeries< FieldSeries > interface_type_FieldSeries
Definition: SeriesMultiIndices.hpp:114
MoFEM::FieldSeries::get_FieldSeries_ptr
const FieldSeries * get_FieldSeries_ptr() const
Definition: SeriesMultiIndices.hpp:81
MoFEM::interface_FieldSeries::interface_FieldSeries
interface_FieldSeries(const T *_ptr)
Definition: SeriesMultiIndices.hpp:90
CHKERRG
#define CHKERRG(n)
Check error code of MoFEM/MOAB/PETSc function.
Definition: definitions.h:483
MoFEM::FieldSeriesStep::operator<<
friend std::ostream & operator<<(std::ostream &os, const FieldSeriesStep &e)
Definition: SeriesMultiIndices.cpp:328
MoFEM::interface_FieldSeries
Definition: SeriesMultiIndices.hpp:88
MoFEM::Series_multiIndex
multi_index_container< FieldSeries, indexed_by< ordered_unique< tag< SeriesID_mi_tag >, const_mem_fun< FieldSeries, EntityID, &FieldSeries::get_meshset_id > >, ordered_unique< tag< SeriesName_mi_tag >, const_mem_fun< FieldSeries, boost::string_ref, &FieldSeries::getNameRef > > > > Series_multiIndex
Series multi index.
Definition: SeriesMultiIndices.hpp:143
MoFEM::FieldSeriesStep::FieldSeriesStep
FieldSeriesStep(Interface &moab, const FieldSeries *_FieldSeries_ptr, const int _step_number)
Definition: SeriesMultiIndices.cpp:226