v0.14.0
Loading...
Searching...
No Matches
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
10namespace MoFEM {
11
12struct 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 */
24
26 const void *tagName; ///< tag keeps name of the series
27 int tagNameSize; ///< number of bits necessary to keep field series
28
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());
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
88template <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 */
112struct 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 */
135typedef 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 */
150typedef 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__
#define MB_ID_MASK
Definition: definitions.h:234
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:447
#define CHKERRG(n)
Check error code of MoFEM/MOAB/PETSc function.
Definition: definitions.h:483
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:440
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.
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.
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.
const double T
static MoFEMErrorCodeGeneric< PetscErrorCode > ierr
Definition: Exceptions.hpp:76
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
Definition: Exceptions.hpp:56
int ShortId
Unique Id in the field.
Definition: Types.hpp:32
implementation of Data Operators for Forces and Sources
Definition: Common.hpp:10
constexpr IntegrationType IT
Definition: plastic.cpp:47
Deprecated interface functions.
Structure for recording (time) series.
MoFEMErrorCode set_time(double time)
std::vector< ShortId > uids
MoFEMErrorCode end(double time=0)
std::string getName() const
get series name
MoFEMErrorCode push_dofs(const EntityHandle ent, const ShortId uid, const FieldData val)
std::vector< FieldData > data
MoFEMErrorCode get_nb_steps(Interface &moab, int &nb_setps) const
boost::string_ref getNameRef() const
get string_ref of series
const void * tagName
tag keeps name of the series
EntityHandle getMeshset() const
get meshset
EntityID get_meshset_id() const
const FieldSeries * get_FieldSeries_ptr() const
MoFEMErrorCode read(Interface &moab)
std::vector< int > ia
std::vector< EntityHandle > handles
std::vector< double > time
MoFEMErrorCode save(Interface &moab) const
MoFEMErrorCode begin()
MoFEMErrorCode push_dofs(IT it, IT hi_it)
friend std::ostream & operator<<(std::ostream &os, const FieldSeries &e)
int tagNameSize
number of bits necessary to keep field series
Structure for keeping time and step.
friend std::ostream & operator<<(std::ostream &os, const FieldSeriesStep &e)
interface_FieldSeries< FieldSeries > interface_type_FieldSeries
MoFEMErrorCode get(Interface &moab, DofEntity_multiIndex &dofsField) const
MoFEMErrorCode get_time_init(Interface &moab)
boost::string_ref getNameRef() const
get string_ref of series
std::string getName() const
get series name
const FieldSeries * get_FieldSeries_ptr() const
EntityHandle getMeshset() const
get meshset