v0.9.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  * MoFEM is free software: you can redistribute it and/or modify it under
7  * the terms of the GNU Lesser General Public License as published by the
8  * Free Software Foundation, either version 3 of the License, or (at your
9  * option) any later version.
10  *
11  * MoFEM is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14  * License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with MoFEM. If not, see <http://www.gnu.org/licenses/>
18 */
19 
20 #ifndef __SERIESMULTIINDICES_HPP__
21 #define __SERIESMULTIINDICES_HPP__
22 
23 namespace MoFEM {
24 
25 struct FieldSeriesStep;
26 
27 /**
28  * \brief Structure for recording (time) series
29  *
30  * \ingroup series_multi_indices
31  *
32  * \bug Fix member functions names. Not follow naming convention.
33  * \bug Member functions not documented
34  *
35  */
36 struct FieldSeries {
37 
39  const void *tagName; ///< tag keeps name of the series
40  int tagNameSize; ///< number of bits necessary to keep field series
41 
43  bool record_end;
44 
45  FieldSeries(Interface &moab, const EntityHandle _meshset);
46 
47  /// get meshset
48  inline EntityHandle getMeshset() const { return meshset; }
49  inline EntityID get_meshset_id() const {
50  return (EntityID)(meshset & MB_ID_MASK);
51  }
52  /// get string_ref of series
53  inline boost::string_ref getNameRef() const {
54  return boost::string_ref((char *)tagName, tagNameSize);
55  }
56  /// get series name
57  inline std::string getName() const {
58  return std::string((char *)tagName, tagNameSize);
59  }
60 
65 
66  MoFEMErrorCode get_nb_steps(Interface &moab, int &nb_setps) const;
67 
68  std::vector<int> ia;
69  std::vector<double> time;
70  std::vector<EntityHandle> handles;
71  std::vector<ShortId> uids;
72  std::vector<FieldData> data;
73 
75  MoFEMErrorCode push_dofs(const EntityHandle ent, const ShortId uid,
76  const FieldData val);
77 
78  template <typename IT> MoFEMErrorCode push_dofs(IT it, IT hi_it) {
80 
81  for (; it != hi_it; it++) {
82  ierr = push_dofs((*it)->getEnt(), (*it)->getNonNonuniqueShortId(),
83  (*it)->getFieldData());
84  CHKERRG(ierr);
85  }
87  }
88 
90  MoFEMErrorCode end(double time = 0);
92  MoFEMErrorCode save(Interface &moab) const;
93 
94  inline const FieldSeries *get_FieldSeries_ptr() const {
95  return const_cast<FieldSeries *>(this);
96  };
97 
98  friend std::ostream &operator<<(std::ostream &os, const FieldSeries &e);
99 };
100 
101 template <typename T> struct interface_FieldSeries {
102  const T *ptr;
103  interface_FieldSeries(const T *_ptr) : ptr(_ptr) {}
104 
105  /// get meshset
106  inline EntityHandle getMeshset() const { return ptr->getMeshset(); }
107  inline EntityID get_meshset_id() const { return ptr->get_meshset_id(); }
108  /// get string_ref of series
109  inline boost::string_ref getNameRef() const { return ptr->getNameRef(); }
110  /// get series name
111  inline std::string getName() const { return ptr->getName(); }
112 
113  inline const FieldSeries *get_FieldSeries_ptr() const {
114  return ptr->get_FieldSeries_ptr();
115  };
116 };
117 
118 /**
119  * \brief Structure for keeping time and step
120  *
121  * \ingroup series_multi_indices
122  *
123  * \bug Fix member functions names. Not follow namining convention.
124  */
125 struct FieldSeriesStep : public interface_FieldSeries<FieldSeries> {
126 
128 
130  FieldSeriesStep(Interface &moab, const FieldSeries *_FieldSeries_ptr,
131  const int _step_number);
132 
133  inline int get_step_number() const { return step_number; };
134  MoFEMErrorCode get(Interface &moab, DofEntity_multiIndex &dofsField) const;
135 
136  double time;
138  inline double get_time() const { return time; }
139 
140  friend std::ostream &operator<<(std::ostream &os, const FieldSeriesStep &e);
141 };
142 
143 /**
144  * \brief Series multi index
145  *
146  * \ingroup series_multi_indices
147  */
148 typedef multi_index_container<
149  FieldSeries,
150  indexed_by<ordered_unique<tag<SeriesID_mi_tag>,
151  const_mem_fun<FieldSeries, EntityID,
153  ordered_unique<tag<SeriesName_mi_tag>,
154  const_mem_fun<FieldSeries, boost::string_ref,
157 
158 /**
159  * \brief Step multi index
160  *
161  * \ingroup series_multi_indices
162  */
163 typedef multi_index_container<
165  indexed_by<
166  ordered_unique<
167  tag<Composite_SeriesID_And_Step_mi_tag>,
168  composite_key<
172  member<FieldSeriesStep, int, &FieldSeriesStep::step_number>>>,
173  ordered_unique<
174  tag<Composite_SeriesName_And_Step_mi_tag>,
175  composite_key<
178  boost::string_ref, &FieldSeriesStep::getNameRef>,
179  member<FieldSeriesStep, int, &FieldSeriesStep::step_number>>>,
180  ordered_non_unique<
181  tag<SeriesName_mi_tag>,
183  boost::string_ref, &FieldSeriesStep::getNameRef>>,
184  ordered_non_unique<
185  tag<Composite_SeriesName_And_Time_mi_tag>,
186  composite_key<
189  boost::string_ref, &FieldSeriesStep::getNameRef>,
190  const_mem_fun<FieldSeriesStep, double,
193 
194 } // namespace MoFEM
195 
196 /***************************************************************************/ /**
197 * \defgroup series_multi_indices Series structures and multi-indices
198 * \brief Interface used to record fields and play them back (for example response of structure subjected to earthquake)
199 *
200 * The idea of this interface is taken from Opensees
201 * <http://opensees.berkeley.edu>, tailored and generalised for MoFEM code. In
202 * principle, one can record tape in for a sequence of points (for example steps
203 * in time) and play it back. One can create several tapes and record all fields
204 * or some of them.
205 *
206 * User do not use multi-indices data structures directly, recording and playing
207 * data is by MoFEM::SeriesRecorder interface, more in module \ref mofem_series
208 *
209 * \ingroup mofem
210 ******************************************************************************/
211 
212 #endif // __SERIESMULTIINDICES_HPP__
Structure for recording (time) series.
std::string getName() const
get series name
MoFEMErrorCode get_time_init(Interface &moab)
const FieldSeries * get_FieldSeries_ptr() const
std::vector< FieldData > data
const FieldSeries * get_FieldSeries_ptr() const
EntityID get_meshset_id() const
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
MoFEMErrorCode save(Interface &moab) const
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.
#define CHKERRG(n)
Check error code of MoFEM/MOAB/PETSc function.
Definition: definitions.h:544
MoFEMErrorCode push_dofs(IT it, IT hi_it)
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:508
std::vector< double > time
boost::string_ref getNameRef() const
get string_ref of series
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.
std::vector< int > ia
implementation of Data Operators for Forces and Sources
Definition: Common.hpp:21
EntityHandle getMeshset() const
get meshset
MoFEMErrorCode set_time(double time)
FieldSeriesStep(Interface &moab, const FieldSeries *_FieldSeries_ptr, const int _step_number)
friend std::ostream & operator<<(std::ostream &os, const FieldSeriesStep &e)
std::string getName() const
get series name
multi_index_container< boost::shared_ptr< DofEntity >, indexed_by< ordered_unique< tag< Unique_mi_tag >, member< DofEntity, UId, &DofEntity::globalUId > >, ordered_non_unique< tag< Composite_Name_And_Ent_And_EntDofIdx_mi_tag >, composite_key< DofEntity, const_mem_fun< DofEntity::interface_type_Field, boost::string_ref, &DofEntity::getNameRef >, const_mem_fun< DofEntity, EntityHandle, &DofEntity::getEnt >, const_mem_fun< DofEntity, DofIdx, &DofEntity::getEntDofIdx > > >, ordered_non_unique< tag< Unique_Ent_mi_tag >, const_mem_fun< DofEntity, const UId &, &DofEntity::getEntGlobalUniqueId > >, ordered_non_unique< tag< FieldName_mi_tag >, const_mem_fun< DofEntity::interface_type_Field, boost::string_ref, &DofEntity::getNameRef > >, ordered_non_unique< tag< Ent_mi_tag >, const_mem_fun< DofEntity, EntityHandle, &DofEntity::getEnt > >, ordered_non_unique< tag< Composite_Name_And_Ent_mi_tag >, composite_key< DofEntity, const_mem_fun< DofEntity::interface_type_Field, boost::string_ref, &DofEntity::getNameRef >, const_mem_fun< DofEntity, EntityHandle, &DofEntity::getEnt > > >, ordered_non_unique< tag< Composite_Name_And_Type_mi_tag >, composite_key< DofEntity, const_mem_fun< DofEntity::interface_type_Field, boost::string_ref, &DofEntity::getNameRef >, const_mem_fun< DofEntity::interface_type_RefEntity, EntityType, &DofEntity::getEntType > > > > > DofEntity_multiIndex
MultiIndex container keeps DofEntity.
friend std::ostream & operator<<(std::ostream &os, const FieldSeries &e)
boost::string_ref getNameRef() const
get string_ref of series
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
Definition: Exceptions.hpp:66
#define MB_ID_MASK
Definition: definitions.h:296
std::vector< EntityHandle > handles
MoFEMErrorCode begin()
std::vector< ShortId > uids
MoFEMErrorCode read(Interface &moab)
interface_FieldSeries< FieldSeries > interface_type_FieldSeries
int tagNameSize
number of bits necessary to keep field series
FieldSeries(Interface &moab, const EntityHandle _meshset)
Structure for keeping time and step.
MoFEMErrorCode get_nb_steps(Interface &moab, int &nb_setps) const
const void * tagName
tag keeps name of the series
MoFEMErrorCode end(double time=0)
MoFEMErrorCode get(Interface &moab, DofEntity_multiIndex &dofsField) const
EntityHandle getMeshset() const
get meshset