v0.8.19
DofsMultiIndices.hpp
Go to the documentation of this file.
1 /** \file DofsMultiIndices.hpp
2  * \ingroup dof_multi_indices
3  * \brief Multi-Index contains, data structures for mofem dofs and other
4  * low-level functions
5  */
6 
7 /* MoFEM is free software: you can redistribute it and/or modify it under
8  * the terms of the GNU Lesser General Public License as published by the
9  * Free Software Foundation, either version 3 of the License, or (at your
10  * option) any later version.
11 
12  * MoFEM is distributed in the hope that it will be useful, but WITHOUT
13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
15  * License for more details.
16 
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with MoFEM. If not, see <http://www.gnu.org/licenses/>
19 */
20 
21 #ifndef __DOFSMULTIINDICES_HPP__
22 #define __DOFSMULTIINDICES_HPP__
23 
24 namespace MoFEM {
25 
26 /**
27  * \brief keeps information about DOF on the entity
28  * \ingroup dof_multi_indices
29  */
30 struct DofEntity : public interface_FieldEntity<FieldEntity> {
31 
35 
36  static inline UId getGlobalUniqueIdCalculate(const DofIdx dof,
37  const UId &ent_uid) {
38  // if(dof>=MAX_DOFS_ON_ENTITY) THROW_MESSAGE("dof >= MAX_DOFS_ON_ENTITY");
39  return static_cast<UId>(dof) | ent_uid;
40  }
41 
42  /**
43  * \brief Calculate UId for DOF
44  *
45  * UId is constructed such that all DOFs are ordered by processor, entity,
46  * field and dof index on entity, On entity dofs index is constructed such
47  * that coefficient number and dofs increase with dofs index on entity.
48  *
49  * @param dof dof index on entity
50  * @param ent_ptr pointer to field entity
51  * @return UId
52  */
53  static inline UId
55  const boost::shared_ptr<FieldEntity> &ent_ptr) {
56  return getGlobalUniqueIdCalculate(dof, ent_ptr->getGlobalUniqueId());
57  }
58 
59  static inline UId getGlobalUniqueIdCalculate_Low_Proc(const int owner_proc) {
62  }
63 
64  static inline UId getGlobalUniqueIdCalculate_Hi_Proc(const int owner_proc) {
68  }
69 
70  static inline ShortId
72  const boost::shared_ptr<FieldEntity> &ent_ptr) {
73  // if(sizeof(ShortId) < sizeof(char)+2) THROW_MESSAGE("sizeof(ShortId)<
74  // sizeof(char)+2")
75  return static_cast<ShortId>(dof) |
76  (static_cast<ShortId>(ent_ptr->getBitNumber()) << 9);
77  }
78 
79  bool active; ///< true if dof is active
80  UId globalUId; ///< global unique id for this dof
81 
82  DofEntity(const boost::shared_ptr<FieldEntity> &entity_ptr,
83  const ApproximationOrder dof_order,
84  const FieldCoefficientsNumber dof_rank, const DofIdx dof,
85  const bool is_active = false);
86 
87  /// @return get dof index on entity
88  inline DofIdx getEntDofIdx() const {
89  DofIdx dof;
90  memcpy(&dof, &globalUId, 2);
91  return DOF_UID_MASK & dof;
92  }
93 
94  /// @return get field data on dof
95  inline FieldData &getFieldData() const {
96  return const_cast<FieldData &>(
97  this->sPtr->getEntFieldData().data()[getEntDofIdx()]);
98  }
99 
100  /// @return get unique dof id
101  inline const UId &getGlobalUniqueId() const { return globalUId; }
102 
103  /// @return get entity unique dof id
104  inline const UId &getEntGlobalUniqueId() const {
105  return this->sPtr->getGlobalUniqueId();
106  }
107 
108  /** \brief get short uid it is unique in combination with entity handle
109  *
110  * EntityHandle are controlled by MOAB, which is unique in
111  * MOAB instance. However two MOAB instances, can have attached different
112  * EntityHandles to the same entity.
113  *
114  * Relation between MoAB EntityHandle can be handled by saving entity handle
115  * data into tag, see MB_TYPE_HANDLE. MOAB at time of file reading or
116  * creating new MOAB instance, substitute tag value by approbate entity
117  * handle.
118  *
119  * ShortId is created to handle problems related to saving data series, and
120  * reading those data using different MoAB instances.
121  *
122  */
125  }
126 
127  /// @return get dof entity handle
128  inline EntityHandle getEnt() const { return this->sPtr->getEnt(); }
129 
130  /// @return get dof approximation order
132  return getDofOrderMap()[getEntDofIdx()];
133  }
134 
135  /// @return get dof coefficient index
137  return getEntDofIdx() % getNbOfCoeffs();
138  }
139 
140  /// @return return true if dof us active
141  inline char getActive() const { return active ? 1 : 0; }
142 
143  friend std::ostream &operator<<(std::ostream &os, const DofEntity &e);
144 };
145 
146 /**
147  * \brief Interface to DofEntity
148  *
149  * In MoFEM DOFs classes (and Ent and Finite Element classes) are derived by
150  * interface, i.e. not class is derived but interface to it.
151  *
152  * \ingroup dof_multi_indices
153  */
154 template <typename T>
156 
157  interface_DofEntity(const boost::shared_ptr<T> &sptr)
158  : interface_FieldEntity<T>(sptr) {}
159 
160  /// @return return dof unique id
161  inline const UId &getGlobalUniqueId() const {
162  return this->sPtr->getGlobalUniqueId();
163  }
164 
165  /// @return return entity unique id
166  inline const UId &getEntGlobalUniqueId() const {
167  return this->sPtr->getEntGlobalUniqueId();
168  }
169 
170  /// @return return short id (used by data recorder)
172  return this->sPtr->getNonNonuniqueShortId();
173  }
174 
175  /// @return return index of dof on the entity
176  inline DofIdx getEntDofIdx() const { return this->sPtr->getEntDofIdx(); }
177 
178  /// @return return data on dof
179  inline FieldData &getFieldData() const { return this->sPtr->getFieldData(); }
180 
181  /// @return return entity handle
182  inline EntityHandle getEnt() const { return this->sPtr->getEnt(); }
183 
184  /// @return get dof approximation order
186  return this->sPtr->getDofOrder();
187  }
188 
189  /// @return get dof coefficient index
191  return this->sPtr->getDofCoeffIdx();
192  }
193 
194  /// @return return true if dof is active
195  inline char getActive() const { return this->sPtr->getActive(); }
196 
197  /// @return get pointer to dof data structure
198  inline boost::shared_ptr<DofEntity> &getDofEntityPtr() const {
199  return this->sPtr;
200  }
201 
202  /// @return get pioneer do dof's entity data structure
203  inline boost::shared_ptr<FieldEntity> &getFieldEntityPtr() const {
204  return this->sPtr->getFieldEntityPtr();
205  }
206 
207 };
208 
209 /**
210  * \brief keeps information about indexed dofs for the problem
211  * \ingroup dof_multi_indices
212  *
213  * FIXME: Is too many iterator, this has to be manage more efficiently, some
214  * iterators could be moved to multi_indices views.
215  *
216  */
217 struct NumeredDofEntity : public interface_DofEntity<DofEntity> {
218 
225  unsigned int pArt;
226 
227  /// @return MoFEM DoF index
228  inline DofIdx getDofIdx() const { return dofIdx; }
229 
230  /// @return PETSc global DoF index
231  inline DofIdx getPetscGlobalDofIdx() const { return petscGloablDofIdx; }
232 
233  /// @return PETSc local DoF index
234  inline DofIdx getPetscLocalDofIdx() const { return petscLocalDofIdx; }
235 
236  /// @return Owning partition (i.e. process/processor)
237  inline unsigned int getPart() const { return pArt; }
238 
239  /// @return True if local index is set
240  inline bool getHasLocalIndex() const {
241  return !std::signbit(petscLocalDofIdx);
242  }
243 
244  NumeredDofEntity(const boost::shared_ptr<DofEntity> &dof_entity_ptr,
245  const int dof_idx = -1, const int petsc_gloabl_dof_idx = -1,
246  const int petsc_local_dof_idx = -1, const int part = -1);
247  friend std::ostream &operator<<(std::ostream &os, const NumeredDofEntity &e);
248 };
249 
250 /**
251  * \brief interface to NumeredDofEntity
252  * \ingroup dof_multi_indices
253  */
254 template <typename T>
256 
257  interface_NumeredDofEntity(const boost::shared_ptr<T> &sptr)
258  : interface_DofEntity<T>(sptr){};
259 
260  /// @return get dof index on entity
261  inline DofIdx getDofIdx() const { return this->sPtr->getDofIdx(); }
262 
263  /// @return get petsc global index on entity
264  inline DofIdx getPetscGlobalDofIdx() const {
265  return this->sPtr->getPetscGlobalDofIdx();
266  }
267 
268  /// @return get pe
269  inline DofIdx getPetscLocalDofIdx() const {
270  return this->sPtr->getPetscLocalDofIdx();
271  }
272 
273  inline unsigned int getPart() const { return this->sPtr->getPart(); }
274 
275  inline bool getHasLocalIndex() const {
276  return this->sPtr->getHasLocalIndex();
277  }
278 
279  inline boost::shared_ptr<NumeredDofEntity> &getNumeredDofEntityPtr() const {
280  return this->sPtr;
281  };
282 };
283 
284 /**
285  * \brief keeps information about indexed dofs for the finite element
286  * \ingroup dof_multi_indices
287  */
288 struct FEDofEntity : public BaseFEEntity, interface_DofEntity<DofEntity> {
292  FEDofEntity(const boost::shared_ptr<SideNumber> &side_number_ptr,
293  const boost::shared_ptr<DofEntity> &dof_ptr);
294  FEDofEntity(const boost::tuple<const boost::shared_ptr<SideNumber> &,
295  const boost::shared_ptr<DofEntity> &> &t);
296  friend std::ostream &operator<<(std::ostream &os, const FEDofEntity &e);
297 };
298 
299 /**
300  * \brief keeps information about indexed dofs for the finite element
301  * \ingroup dof_multi_indices
302  */
304  interface_NumeredDofEntity<NumeredDofEntity> {
310  FENumeredDofEntity(const boost::shared_ptr<SideNumber> &side_number_ptr,
311  const boost::shared_ptr<NumeredDofEntity> &dof_ptr);
313  const boost::tuple<const boost::shared_ptr<SideNumber> &,
314  const boost::shared_ptr<NumeredDofEntity> &> &t);
315  friend std::ostream &operator<<(std::ostream &os,
316  const FENumeredDofEntity &e);
317 };
318 
319 /**
320  * @relates multi_index_container
321  * \brief MultiIndex container keeps DofEntity
322  * \ingroup dof_multi_indices
323  */
324 typedef multi_index_container<
325  boost::shared_ptr<DofEntity>,
326  indexed_by<
327  // unique
328  ordered_unique<tag<Unique_mi_tag>,
329  member<DofEntity, UId, &DofEntity::globalUId>>,
330  // non_unique
331  ordered_non_unique<
332  tag<Composite_Name_And_Ent_And_EntDofIdx_mi_tag>,
333  composite_key<
334  DofEntity,
335  const_mem_fun<DofEntity::interface_type_Field,
336  boost::string_ref, &DofEntity::getNameRef>,
337  const_mem_fun<DofEntity, EntityHandle, &DofEntity::getEnt>,
338  const_mem_fun<DofEntity, DofIdx, &DofEntity::getEntDofIdx>>>,
339  ordered_non_unique<tag<Unique_Ent_mi_tag>,
340  const_mem_fun<DofEntity, const UId &,
342  ordered_non_unique<
343  tag<FieldName_mi_tag>,
344  const_mem_fun<DofEntity::interface_type_Field, boost::string_ref,
346  ordered_non_unique<
347  tag<Ent_mi_tag>,
348  const_mem_fun<DofEntity, EntityHandle, &DofEntity::getEnt>>,
349  ordered_non_unique<
350  tag<Composite_Name_And_Ent_mi_tag>,
351  composite_key<
352  DofEntity,
353  const_mem_fun<DofEntity::interface_type_Field,
354  boost::string_ref, &DofEntity::getNameRef>,
355  const_mem_fun<DofEntity, EntityHandle, &DofEntity::getEnt>>>,
356  ordered_non_unique<
357  tag<Composite_Name_And_Type_mi_tag>,
358  composite_key<
359  DofEntity,
360  const_mem_fun<DofEntity::interface_type_Field,
361  boost::string_ref, &DofEntity::getNameRef>,
362  const_mem_fun<DofEntity::interface_type_RefEntity, EntityType,
365 
366 /** \brief Dof multi-index by field name
367  *
368  * \ingroup dof_multi_indices
369  */
370 typedef DofEntity_multiIndex::index<FieldName_mi_tag>::type
372 
373 /** \brief Dof multi-index by entity
374  *
375  * \ingroup dof_multi_indices
376  */
377 typedef DofEntity_multiIndex::index<Ent_mi_tag>::type DofEntityByEnt;
378 
379 /** \brief Dof multi-index by field name and entity
380  *
381  * \ingroup dof_multi_indices
382  */
383 typedef DofEntity_multiIndex::index<Composite_Name_And_Ent_mi_tag>::type
385 
386 /** \brief Dof multi-index by field name and entity type
387  *
388  * \ingroup dof_multi_indices
389  */
390 typedef DofEntity_multiIndex::index<Composite_Name_And_Type_mi_tag>::type
392 
393 /** \brief multi-index view on DofEntity by uid
394  \ingroup dof_multi_indices
395 */
396 typedef multi_index_container<
397  boost::shared_ptr<DofEntity>,
398  indexed_by<
399 
400  ordered_unique<const_mem_fun<DofEntity, const UId &,
402 
403  >>
405 
406 /** \brief vector view on DofEntity by uid
407  \ingroup dof_multi_indices
408 */
409 typedef std::vector<boost::weak_ptr<DofEntity>> DofEntity_vector_view;
410 
411 /** \brief multi-index view on DofEntity activity
412  \ingroup dof_multi_indices
413 */
414 typedef multi_index_container<
415  boost::shared_ptr<DofEntity>,
416  indexed_by<
417 
418  ordered_unique<const_mem_fun<DofEntity, const UId &,
420 
421  ordered_non_unique<
422  const_mem_fun<DofEntity, char, &DofEntity::getActive>>
423 
424  >>
426 
427 /**
428  * @relates multi_index_container
429  * \brief MultiIndex container keeps FEDofEntity
430  * \ingroup dof_multi_indices
431 
432  */
433 typedef multi_index_container<
434  boost::shared_ptr<FEDofEntity>,
435  indexed_by<
436 
437  ordered_unique<
438  tag<Unique_mi_tag>,
439  const_mem_fun<FEDofEntity::interface_type_DofEntity, const UId &,
441 
442  ordered_non_unique<tag<Ent_mi_tag>,
445 
446  ordered_non_unique<
447  tag<FieldName_mi_tag>,
448  const_mem_fun<FEDofEntity::interface_type_Field, boost::string_ref,
450 
451  ordered_non_unique<tag<EntType_mi_tag>,
453  EntityType, &FEDofEntity::getEntType>>,
454 
455  ordered_non_unique<
456  tag<Composite_Name_And_Type_mi_tag>,
457  composite_key<
458  FEDofEntity,
459  const_mem_fun<FEDofEntity::interface_type_Field,
460  boost::string_ref, &FEDofEntity::getNameRef>,
461  const_mem_fun<FEDofEntity::interface_type_RefEntity, EntityType,
463 
464  ordered_non_unique<
465  tag<Composite_Name_And_Ent_mi_tag>,
466  composite_key<
467  FEDofEntity,
468  const_mem_fun<FEDofEntity::interface_type_Field,
469  boost::string_ref, &FEDofEntity::getNameRef>,
472 
473  // This is only used by obsolete modules, should be removed with
474  // brother of Cephas, i.e. Pawel.
475  ordered_non_unique<
476  tag<Composite_Name_Type_And_Side_Number_mi_tag>,
477  composite_key<
478  FEDofEntity,
479  const_mem_fun<FEDofEntity::interface_type_Field,
480  boost::string_ref, &FEDofEntity::getNameRef>,
481  const_mem_fun<FEDofEntity::interface_type_RefEntity, EntityType,
485  boost::shared_ptr<SideNumber>,
487 
488  >>
490 
491 /** \brief Finite element DoF multi-index by field name
492  *
493  * \ingroup dof_multi_indices
494  */
495 typedef FEDofEntity_multiIndex::index<FieldName_mi_tag>::type
497 
498 /** \brief Dof entity multi-index by field name and entity
499  *
500  * \ingroup dof_multi_indices
501  */
502 typedef FEDofEntity_multiIndex::index<Composite_Name_And_Ent_mi_tag>::type
504 
505 /** \brief Dof entity multi-index by field name and entity type
506  *
507  * \ingroup dof_multi_indices
508  */
509 typedef FEDofEntity_multiIndex::index<Composite_Name_And_Type_mi_tag>::type
511 
512 /**
513  * @relates multi_index_container
514  * \brief MultiIndex container keeps FENumeredDofEntity
515 
516  * \ingroup dof_multi_indices
517  */
518 typedef multi_index_container<
519  boost::shared_ptr<FENumeredDofEntity>,
520  indexed_by<
521  ordered_unique<
522  tag<Unique_mi_tag>,
525  ordered_non_unique<
526  tag<Ent_mi_tag>,
529  ordered_non_unique<
530  tag<FieldName_mi_tag>,
532  boost::string_ref, &FENumeredDofEntity::getNameRef>>,
533  ordered_non_unique<
534  tag<PetscGlobalIdx_mi_tag>,
537  ordered_non_unique<
538  tag<Composite_Name_Type_And_Side_Number_mi_tag>,
539  composite_key<
542  boost::string_ref,
545  EntityType, &FENumeredDofEntity::getEntType>,
548  boost::shared_ptr<SideNumber>,
550  ordered_non_unique<
551  tag<Composite_Name_And_Type_mi_tag>,
552  composite_key<
555  boost::string_ref,
558  EntityType, &FENumeredDofEntity::getEntType>>>,
559  ordered_non_unique<
560  tag<Composite_Name_And_Ent_mi_tag>,
561  composite_key<
564  boost::string_ref,
569 
570 /** \brief Finite element numbered DoF multi-index by field name
571  *
572  * \ingroup dof_multi_indices
573  */
574 typedef FENumeredDofEntity_multiIndex::index<FieldName_mi_tag>::type
576 
577 /** \brief Dof entity multi-index by field name and entity
578  *
579  * \ingroup dof_multi_indices
580  */
581 typedef FENumeredDofEntity_multiIndex::index<
583 
584 /** \brief Dof entity multi-index by field name and entity type
585  *
586  * \ingroup dof_multi_indices
587  */
588 typedef FENumeredDofEntity_multiIndex::index<
590 
591 /** \brief Dof entity multi-index by UId
592  *
593  * \ingroup dof_multi_indices
594  */
595 typedef FENumeredDofEntity_multiIndex::index<Unique_mi_tag>::type
597 
598 /** \brief Numbered DoF multi-index by entity
599  *
600  * \ingroup dof_multi_indices
601  */
602 typedef FENumeredDofEntity_multiIndex::index<Ent_mi_tag>::type
604 
605 /**
606  * @relates multi_index_container
607  * \brief MultiIndex container keeps NumeredDofEntity
608  * \ingroup dof_multi_indices
609  */
610 typedef multi_index_container<
611  boost::shared_ptr<NumeredDofEntity>,
612 
613  // unique
614  indexed_by<
615  ordered_unique<
616  tag<Unique_mi_tag>,
619 
620  // non unique
621  ordered_non_unique<
622  tag<Unique_Ent_mi_tag>,
624  const UId &,
626 
627  ordered_non_unique<
628  tag<Part_mi_tag>,
629  member<NumeredDofEntity, unsigned int, &NumeredDofEntity::pArt>>,
630  ordered_non_unique<tag<Idx_mi_tag>, member<NumeredDofEntity, DofIdx,
632 
633  ordered_non_unique<
634  tag<FieldName_mi_tag>,
636  boost::string_ref, &NumeredDofEntity::getNameRef>>,
637 
638  ordered_non_unique<tag<PetscGlobalIdx_mi_tag>,
639  member<NumeredDofEntity, DofIdx,
641 
642  ordered_non_unique<tag<PetscLocalIdx_mi_tag>,
643  member<NumeredDofEntity, DofIdx,
645 
646  ordered_non_unique<
647  tag<Ent_mi_tag>,
650 
651  ordered_non_unique<
652  tag<Composite_Name_And_Ent_And_EntDofIdx_mi_tag>,
653  composite_key<
656  boost::string_ref, &NumeredDofEntity::getNameRef>,
661 
662  ordered_non_unique<
663  tag<Composite_Name_And_Part_mi_tag>,
664  composite_key<
667  boost::string_ref, &NumeredDofEntity::getNameRef>,
668  member<NumeredDofEntity, unsigned int,
670 
671  ordered_non_unique<
672  tag<Composite_Name_Ent_And_Part_mi_tag>,
673  composite_key<
676  boost::string_ref, &NumeredDofEntity::getNameRef>,
679  member<NumeredDofEntity, unsigned int,
681 
682  >>
684 
685 /** \brief Numbered DoF multi-index by field name
686  *
687  * \ingroup dof_multi_indices
688  */
689 typedef NumeredDofEntity_multiIndex::index<FieldName_mi_tag>::type
691 
692 /** \brief Numbered DoF multi-index by UId
693  *
694  * \ingroup dof_multi_indices
695  */
696 typedef NumeredDofEntity_multiIndex::index<Unique_mi_tag>::type
698 
699 /** \brief Numbered DoF multi-index by local index
700  *
701  * \ingroup dof_multi_indices
702  */
703 typedef NumeredDofEntity_multiIndex::index<PetscLocalIdx_mi_tag>::type
705 
706 /** \brief Numbered DoF multi-index by entity
707  *
708  * \ingroup dof_multi_indices
709  */
710 typedef NumeredDofEntity_multiIndex::index<Ent_mi_tag>::type
712 
713 /** \brief Numbered DoF multi-index by name entity and partition
714  *
715  * \ingroup dof_multi_indices
716  */
717 typedef NumeredDofEntity_multiIndex::index<
719 
720 typedef multi_index_container<
721  boost::shared_ptr<NumeredDofEntity>,
722  indexed_by<ordered_unique<
723  const_mem_fun<NumeredDofEntity::interface_type_DofEntity, const UId &,
726 
727 typedef multi_index_container<
728  boost::shared_ptr<NumeredDofEntity>,
729  indexed_by<hashed_unique<const_mem_fun<NumeredDofEntity, DofIdx,
732 
733 typedef multi_index_container<
734  boost::shared_ptr<NumeredDofEntity>,
735  indexed_by<ordered_non_unique<const_mem_fun<
738 
739 typedef multi_index_container<
740  boost::shared_ptr<NumeredDofEntity>,
741  indexed_by<ordered_non_unique<const_mem_fun<
745 
746 /**
747  * Activate or deactivate dofs (multi-index modifier)
748  * \ingroup dof_multi_indices
749  */
751  bool aCtive;
752  DofEntity_active_change(bool active);
753  void operator()(boost::shared_ptr<DofEntity> &dof);
754 };
755 
756 /**
757  * Change part and global pestc index (multi-index modifier)
758  * \ingroup dof_multi_indices
759  */
761  const unsigned int pArt;
764  const DofIdx petsc_gloabl_dof_idx)
765  : pArt(part), petscGloablDofIdx(petsc_gloabl_dof_idx){};
766  inline void operator()(boost::shared_ptr<NumeredDofEntity> &dof) const {
767  dof->pArt = pArt;
768  dof->petscGloablDofIdx = petscGloablDofIdx;
769  }
770 };
771 
773  const unsigned int pArt;
777  const unsigned int part, const DofIdx mofem_dof_idx,
778  const DofIdx petsc_gloabl_dof_idx)
779  : pArt(part), mofemDofIdx(mofem_dof_idx),
780  petscGloablDofIdx(petsc_gloabl_dof_idx){};
781  inline void operator()(boost::shared_ptr<NumeredDofEntity> &dof) const {
782  dof->pArt = pArt;
783  dof->petscGloablDofIdx = petscGloablDofIdx;
784  }
785 };
786 
788  const unsigned int pArt;
792  const DofIdx petsc_gloabl_dof_idx,
793  const DofIdx petsc_local_dof_idx)
794  : pArt(part), petscGloablDofIdx(petsc_gloabl_dof_idx),
795  petscLocalDofIdx(petsc_local_dof_idx){};
796  inline void operator()(boost::shared_ptr<NumeredDofEntity> &dof) const {
797  dof->pArt = pArt;
798  dof->petscGloablDofIdx = petscGloablDofIdx;
799  dof->petscLocalDofIdx = petscLocalDofIdx;
800  }
801 };
802 
803 /**
804  * Change part and local pestc index (multi-index modifier)
805  * \ingroup dof_multi_indices
806  */
809  NumeredDofEntity_local_idx_change(const DofIdx petsc_local_dof_idx)
810  : petscLocalDofIdx(petsc_local_dof_idx){};
811  inline void operator()(boost::shared_ptr<NumeredDofEntity> &dof) const {
812  dof->petscLocalDofIdx = petscLocalDofIdx;
813  }
814 };
815 
816 /**
817  * Change part and mofem index (multi-index modifier)
818  * \ingroup dof_multi_indices
819  */
823  : mofemIdx(mofem_idx){};
824  inline void operator()(boost::shared_ptr<NumeredDofEntity> &dof) const {
825  dof->dofIdx = mofemIdx;
826  }
827 };
828 
829 /**
830  * Change part and mofem/pestc global and local index (multi-index modifier)
831  * \ingroup dof_multi_indices
832  */
834  const unsigned int pArt;
839  const unsigned int part, const DofIdx mofem_idx,
840  const DofIdx petsc_gloabl_dof_idx, const DofIdx petsc_local_dof_idx)
841  : pArt(part), mofemIdx(mofem_idx),
842  petscGloablDofIdx(petsc_gloabl_dof_idx),
843  petscLocalDofIdx(petsc_local_dof_idx){};
844  inline void operator()(boost::shared_ptr<NumeredDofEntity> &dof) const {
845  dof->pArt = pArt;
846  dof->dofIdx = mofemIdx;
847  dof->petscGloablDofIdx = petscGloablDofIdx;
848  dof->petscLocalDofIdx = petscLocalDofIdx;
849  }
850 };
851 
852 /**
853  * Replace dofs shared_ptr
854  *
855  * DOFs on entities are stored by sequences. If DOFs to entities are added,
856  * whole entity sequence is change to preserve continuity in memory
857  *
858  * \ingroup dof_multi_indices
859  */
860 template <class T> struct Dof_shared_ptr_change {
861  boost::shared_ptr<T> &dofPtr;
862  Dof_shared_ptr_change(boost::shared_ptr<T> &dof_ptr) : dofPtr(dof_ptr){};
863  inline void operator()(boost::shared_ptr<T> &dof) { dof = dofPtr; }
864 };
865 
866 } // namespace MoFEM
867 #endif // __DOFSMULTIINDICES_HPP__
868 
869 /***************************************************************************/ /**
870  * \defgroup dof_multi_indices Dofs structures and multi-indices
871  * \ingroup mofem
872 ******************************************************************************/
void operator()(boost::shared_ptr< NumeredDofEntity > &dof) const
NumeredDofEntity_multiIndex::index< FieldName_mi_tag >::type NumeredDofEntityByFieldName
Numbered DoF multi-index by field name.
interface_RefEntity< NumeredDofEntity > interface_type_RefEntity
int FieldCoefficientsNumber
Number of field coefficients.
Definition: Common.hpp:132
interface_Field< NumeredDofEntity > interface_type_Field
void operator()(boost::shared_ptr< NumeredDofEntity > &dof) const
void operator()(boost::shared_ptr< NumeredDofEntity > &dof) const
Keeps basic information about entity on the finite element.
DofIdx getPetscLocalDofIdx() const
multi_index_container< boost::shared_ptr< DofEntity >, indexed_by< ordered_unique< const_mem_fun< DofEntity, const UId &, &DofEntity::getGlobalUniqueId > > > > DofEntity_multiIndex_uid_view
multi-index view on DofEntity by uid
boost::shared_ptr< FieldEntity > sPtr
keeps information about indexed dofs for the finite element
std::vector< ApproximationOrder > & getDofOrderMap() const
get hash-map relating dof index on entity with its order
multi_index_container< boost::shared_ptr< FENumeredDofEntity >, indexed_by< ordered_unique< tag< Unique_mi_tag >, const_mem_fun< FENumeredDofEntity::interface_type_DofEntity, const UId &, &FENumeredDofEntity::getGlobalUniqueId > >, ordered_non_unique< tag< Ent_mi_tag >, const_mem_fun< FENumeredDofEntity::interface_type_DofEntity, EntityHandle, &FENumeredDofEntity::getEnt > >, ordered_non_unique< tag< FieldName_mi_tag >, const_mem_fun< FENumeredDofEntity::interface_type_Field, boost::string_ref, &FENumeredDofEntity::getNameRef > >, ordered_non_unique< tag< PetscGlobalIdx_mi_tag >, const_mem_fun< FENumeredDofEntity::interface_type_NumeredDofEntity, DofIdx, &FENumeredDofEntity::getPetscGlobalDofIdx > >, ordered_non_unique< tag< Composite_Name_Type_And_Side_Number_mi_tag >, composite_key< FENumeredDofEntity, const_mem_fun< FENumeredDofEntity::interface_type_Field, boost::string_ref, &FENumeredDofEntity::getNameRef >, const_mem_fun< FENumeredDofEntity::interface_type_RefEntity, EntityType, &FENumeredDofEntity::getEntType >, KeyFromKey< member< SideNumber, char, &SideNumber::side_number >, member< FENumeredDofEntity::BaseFEEntity, boost::shared_ptr< SideNumber >, &FENumeredDofEntity::sideNumberPtr > > > >, ordered_non_unique< tag< Composite_Name_And_Type_mi_tag >, composite_key< FENumeredDofEntity, const_mem_fun< FENumeredDofEntity::interface_type_Field, boost::string_ref, &FENumeredDofEntity::getNameRef >, const_mem_fun< FENumeredDofEntity::interface_type_RefEntity, EntityType, &FENumeredDofEntity::getEntType > > >, ordered_non_unique< tag< Composite_Name_And_Ent_mi_tag >, composite_key< FENumeredDofEntity, const_mem_fun< FENumeredDofEntity::interface_type_Field, boost::string_ref, &FENumeredDofEntity::getNameRef >, const_mem_fun< FENumeredDofEntity::interface_type_DofEntity, EntityHandle, &FENumeredDofEntity::getEnt > > > > > FENumeredDofEntity_multiIndex
MultiIndex container keeps FENumeredDofEntity.
friend std::ostream & operator<<(std::ostream &os, const NumeredDofEntity &e)
DofIdx getEntDofIdx() const
DofIdx getPetscGlobalDofIdx() const
interface_Field< DofEntity > interface_type_Field
FENumeredDofEntity(const boost::shared_ptr< SideNumber > &side_number_ptr, const boost::shared_ptr< NumeredDofEntity > &dof_ptr)
interface_NumeredDofEntity(const boost::shared_ptr< T > &sptr)
DofEntity_multiIndex::index< Ent_mi_tag >::type DofEntityByEnt
Dof multi-index by entity.
NumeredDofEntity_multiIndex::index< Ent_mi_tag >::type NumeredDofEntityByEnt
Numbered DoF multi-index by entity.
boost::shared_ptr< DofEntity > & getDofEntityPtr() const
FENumeredDofEntity_multiIndex::index< FieldName_mi_tag >::type FENumeredDofEntityByFieldName
Finite element numbered DoF multi-index by field name.
DofEntity(const boost::shared_ptr< FieldEntity > &entity_ptr, const ApproximationOrder dof_order, const FieldCoefficientsNumber dof_rank, const DofIdx dof, const bool is_active=false)
ShortId getNonNonuniqueShortId() const
get short uid it is unique in combination with entity handle
boost::shared_ptr< NumeredDofEntity > & getNumeredDofEntityPtr() const
FieldCoefficientsNumber getDofCoeffIdx() const
FieldData & getFieldData() const
keeps information about DOF on the entity
static ShortId getNonNonuniqueShortId(const DofIdx dof, const boost::shared_ptr< FieldEntity > &ent_ptr)
DofEntity_multiIndex::index< Composite_Name_And_Type_mi_tag >::type DofEntityByNameAndType
Dof multi-index by field name and entity type.
std::vector< boost::weak_ptr< DofEntity > > DofEntity_vector_view
vector view on DofEntity by uid
boost::shared_ptr< SideNumber > sideNumberPtr
NumeredDofEntity_multiIndex::index< Composite_Name_Ent_And_Part_mi_tag >::type NumeredDofEntityByNameEntAndPart
Numbered DoF multi-index by name entity and partition.
multi_index_container< boost::shared_ptr< NumeredDofEntity >, indexed_by< hashed_unique< const_mem_fun< NumeredDofEntity, DofIdx, &NumeredDofEntity::getDofIdx > > > > NumeredDofEntity_multiIndex_idx_view_hashed
Interface to FieldEntityinterface to FieldEntity.
FENumeredDofEntity_multiIndex::index< Composite_Name_And_Ent_mi_tag >::type FENumeredDofEntityByNameAndEnt
Dof entity multi-index by field name and entity.
void operator()(boost::shared_ptr< NumeredDofEntity > &dof) const
const UId & getGlobalUniqueId() const
interface_DofEntity(const boost::shared_ptr< T > &sptr)
NumeredDofEntity_local_idx_change(const DofIdx petsc_local_dof_idx)
FieldCoefficientsNumber getNbOfCoeffs() const
const UId & getEntGlobalUniqueId() const
static UId getGlobalUniqueIdCalculate_Hi_Proc(const int owner_proc)
EntityHandle getEnt() const
NumeredDofEntity_multiIndex::index< PetscLocalIdx_mi_tag >::type NumeredDofEntityByLocalIdx
Numbered DoF multi-index by local index.
void operator()(boost::shared_ptr< T > &dof)
FENumeredDofEntity_multiIndex::index< Unique_mi_tag >::type FENumeredDofEntityByUId
Dof entity multi-index by UId.
interface to NumeredDofEntity
interface_NumeredDofEntity< NumeredDofEntity > interface_type_NumeredDofEntity
friend std::ostream & operator<<(std::ostream &os, const FEDofEntity &e)
FieldData & getFieldData() const
uint128_t UId
Unique Id.
Definition: Common.hpp:136
implementation of Data Operators for Forces and Sources
Definition: Common.hpp:21
multi_index_container< boost::shared_ptr< NumeredDofEntity >, indexed_by< ordered_unique< const_mem_fun< NumeredDofEntity::interface_type_DofEntity, const UId &, &NumeredDofEntity::getGlobalUniqueId > > > > NumeredDofEntity_multiIndex_uid_view_ordered
keeps information about indexed dofs for the finite element
FEDofEntity_multiIndex::index< FieldName_mi_tag >::type FEDofEntityByFieldName
Finite element DoF multi-index by field name.
interface_Field< FieldEntity > interface_type_Field
NumeredDofEntity_part_and_glob_idx_change(const unsigned int part, const DofIdx petsc_gloabl_dof_idx)
interface_FieldEntity< FieldEntity > interface_type_FieldEntity
char getActive() const
friend std::ostream & operator<<(std::ostream &os, const FENumeredDofEntity &e)
multi_index_container< boost::shared_ptr< DofEntity >, indexed_by< ordered_unique< const_mem_fun< DofEntity, const UId &, &DofEntity::getGlobalUniqueId > >, ordered_non_unique< const_mem_fun< DofEntity, char, &DofEntity::getActive > > > > DofEntity_multiIndex_active_view
multi-index view on DofEntity activity
static UId getGlobalUniqueIdCalculate_Hi_Proc(const int owner_proc)
multi_index_container< boost::shared_ptr< NumeredDofEntity >, indexed_by< ordered_non_unique< const_mem_fun< NumeredDofEntity, DofIdx, &NumeredDofEntity::getPetscLocalDofIdx > > > > NumeredDofEntity_multiIndex_petsc_local_dof_view_ordered_non_unique
EntityHandle getEnt() const
ShortId getNonNonuniqueShortId() const
unsigned int getPart() const
NumeredDofEntity_part_and_all_indices_change(const unsigned int part, const DofIdx mofem_idx, const DofIdx petsc_gloabl_dof_idx, const DofIdx petsc_local_dof_idx)
interface_FieldEntity< DofEntity > interface_type_FieldEntity
NumeredDofEntity_part_and_mofem_glob_idx_change(const unsigned int part, const DofIdx mofem_dof_idx, const DofIdx petsc_gloabl_dof_idx)
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.
DofEntity_multiIndex::index< FieldName_mi_tag >::type DofEntityByFieldName
Dof multi-index by field name.
boost::shared_ptr< FieldEntity > & getFieldEntityPtr() const
const UId & getEntGlobalUniqueId() const
Dof_shared_ptr_change(boost::shared_ptr< T > &dof_ptr)
NumeredDofEntity_mofem_index_change(const DofIdx mofem_idx)
FENumeredDofEntity_multiIndex::index< Composite_Name_And_Type_mi_tag >::type FENumeredDofEntityByNameAndType
Dof entity multi-index by field name and entity type.
static UId getGlobalUniqueIdCalculate_Low_Proc(const int owner_proc)
static UId getGlobalUniqueIdCalculate(const DofIdx dof, const UId &ent_uid)
const UId & getGlobalUniqueId() const
boost::shared_ptr< T > & dofPtr
FEDofEntity_multiIndex::index< Composite_Name_And_Ent_mi_tag >::type FEDofEntityByNameAndEnt
Dof entity multi-index by field name and entity.
boost::shared_ptr< FieldEntity > & getFieldEntityPtr() const
interface_DofEntity< NumeredDofEntity > interface_type_DofEntity
friend std::ostream & operator<<(std::ostream &os, const DofEntity &e)
bool active
true if dof is active
multi_index_container< boost::shared_ptr< NumeredDofEntity >, indexed_by< ordered_non_unique< const_mem_fun< NumeredDofEntity::interface_type_DofEntity, FieldCoefficientsNumber, &NumeredDofEntity::getDofCoeffIdx > > > > NumeredDofEntity_multiIndex_coeff_idx_ordered_non_unique
multi_index_container< boost::shared_ptr< FEDofEntity >, indexed_by< ordered_unique< tag< Unique_mi_tag >, const_mem_fun< FEDofEntity::interface_type_DofEntity, const UId &, &FEDofEntity::getGlobalUniqueId > >, ordered_non_unique< tag< Ent_mi_tag >, const_mem_fun< FEDofEntity::interface_type_DofEntity, EntityHandle, &FEDofEntity::getEnt > >, ordered_non_unique< tag< FieldName_mi_tag >, const_mem_fun< FEDofEntity::interface_type_Field, boost::string_ref, &FEDofEntity::getNameRef > >, ordered_non_unique< tag< EntType_mi_tag >, const_mem_fun< FEDofEntity::interface_type_RefEntity, EntityType, &FEDofEntity::getEntType > >, ordered_non_unique< tag< Composite_Name_And_Type_mi_tag >, composite_key< FEDofEntity, const_mem_fun< FEDofEntity::interface_type_Field, boost::string_ref, &FEDofEntity::getNameRef >, const_mem_fun< FEDofEntity::interface_type_RefEntity, EntityType, &FEDofEntity::getEntType > > >, ordered_non_unique< tag< Composite_Name_And_Ent_mi_tag >, composite_key< FEDofEntity, const_mem_fun< FEDofEntity::interface_type_Field, boost::string_ref, &FEDofEntity::getNameRef >, const_mem_fun< FEDofEntity::interface_type_DofEntity, EntityHandle, &FEDofEntity::getEnt > > >, ordered_non_unique< tag< Composite_Name_Type_And_Side_Number_mi_tag >, composite_key< FEDofEntity, const_mem_fun< FEDofEntity::interface_type_Field, boost::string_ref, &FEDofEntity::getNameRef >, const_mem_fun< FEDofEntity::interface_type_RefEntity, EntityType, &FEDofEntity::getEntType >, KeyFromKey< member< SideNumber, char, &SideNumber::side_number >, member< FEDofEntity::BaseFEEntity, boost::shared_ptr< SideNumber >, &FEDofEntity::sideNumberPtr > > > > > > FEDofEntity_multiIndex
MultiIndex container keeps FEDofEntity.
FENumeredDofEntity_multiIndex::index< Ent_mi_tag >::type FENumeredDofEntityByEnt
Numbered DoF multi-index by entity.
ApproximationOrder getDofOrder() const
ApproximationOrder getDofOrder() const
BaseFEEntity(const boost::shared_ptr< SideNumber > &side_number_ptr)
void operator()(boost::shared_ptr< DofEntity > &dof)
#define MAX_DOFS_ON_ENTITY
Maximal number of DOFs on entity.
Definition: definitions.h:296
interface_DofEntity< DofEntity > interface_type_DofEntity
keeps information about indexed dofs for the problemFIXME: Is too many iterator, this has to be manag...
interface_RefEntity< FieldEntity > interface_type_RefEntity
static UId getGlobalUniqueIdCalculate(const DofIdx dof, const boost::shared_ptr< FieldEntity > &ent_ptr)
Calculate UId for DOF.
interface_DofEntity< DofEntity > interface_type_DofEntity
Interface to DofEntity.
FieldCoefficientsNumber getDofCoeffIdx() const
FEDofEntity(const boost::shared_ptr< SideNumber > &side_number_ptr, const boost::shared_ptr< DofEntity > &dof_ptr)
FEDofEntity_multiIndex::index< Composite_Name_And_Type_mi_tag >::type FEDofEntityByNameAndType
Dof entity multi-index by field name and entity type.
int DofIdx
Index of DOF.
Definition: Common.hpp:126
NumeredDofEntity_multiIndex::index< Unique_mi_tag >::type NumeredDofEntityByUId
Numbered DoF multi-index by UId.
NumeredDofEntity(const boost::shared_ptr< DofEntity > &dof_entity_ptr, const int dof_idx=-1, const int petsc_gloabl_dof_idx=-1, const int petsc_local_dof_idx=-1, const int part=-1)
UId globalUId
global unique id for this dof
#define DOF_UID_MASK
Mask for DOF number on entity form UId.
Definition: definitions.h:297
void operator()(boost::shared_ptr< NumeredDofEntity > &dof) const
void operator()(boost::shared_ptr< NumeredDofEntity > &dof) const
DofEntity_multiIndex::index< Composite_Name_And_Ent_mi_tag >::type DofEntityByNameAndEnt
Dof multi-index by field name and entity.
NumeredDofEntity_part_and_indices_change(const unsigned int part, const DofIdx petsc_gloabl_dof_idx, const DofIdx petsc_local_dof_idx)
interface_RefEntity< DofEntity > interface_type_RefEntity
static UId getGlobalUniqueIdCalculate_Low_Proc(const int owner_proc)
multi_index_container< boost::shared_ptr< NumeredDofEntity >, indexed_by< ordered_unique< tag< Unique_mi_tag >, const_mem_fun< NumeredDofEntity::interface_type_DofEntity, const UId &, &NumeredDofEntity::getGlobalUniqueId > >, ordered_non_unique< tag< Unique_Ent_mi_tag >, const_mem_fun< NumeredDofEntity::interface_type_DofEntity, const UId &, &NumeredDofEntity::getEntGlobalUniqueId > >, ordered_non_unique< tag< Part_mi_tag >, member< NumeredDofEntity, unsigned int, &NumeredDofEntity::pArt > >, ordered_non_unique< tag< Idx_mi_tag >, member< NumeredDofEntity, DofIdx, &NumeredDofEntity::dofIdx > >, ordered_non_unique< tag< FieldName_mi_tag >, const_mem_fun< NumeredDofEntity::interface_type_Field, boost::string_ref, &NumeredDofEntity::getNameRef > >, ordered_non_unique< tag< PetscGlobalIdx_mi_tag >, member< NumeredDofEntity, DofIdx, &NumeredDofEntity::petscGloablDofIdx > >, ordered_non_unique< tag< PetscLocalIdx_mi_tag >, member< NumeredDofEntity, DofIdx, &NumeredDofEntity::petscLocalDofIdx > >, ordered_non_unique< tag< Ent_mi_tag >, const_mem_fun< NumeredDofEntity::interface_type_DofEntity, EntityHandle, &NumeredDofEntity::getEnt > >, ordered_non_unique< tag< Composite_Name_And_Ent_And_EntDofIdx_mi_tag >, composite_key< NumeredDofEntity, const_mem_fun< NumeredDofEntity::interface_type_Field, boost::string_ref, &NumeredDofEntity::getNameRef >, const_mem_fun< NumeredDofEntity::interface_type_DofEntity, EntityHandle, &NumeredDofEntity::getEnt >, const_mem_fun< NumeredDofEntity::interface_type_DofEntity, DofIdx, &NumeredDofEntity::getEntDofIdx > > >, ordered_non_unique< tag< Composite_Name_And_Part_mi_tag >, composite_key< NumeredDofEntity, const_mem_fun< NumeredDofEntity::interface_type_Field, boost::string_ref, &NumeredDofEntity::getNameRef >, member< NumeredDofEntity, unsigned int, &NumeredDofEntity::pArt > > >, ordered_non_unique< tag< Composite_Name_Ent_And_Part_mi_tag >, composite_key< NumeredDofEntity, const_mem_fun< NumeredDofEntity::interface_type_Field, boost::string_ref, &NumeredDofEntity::getNameRef >, const_mem_fun< NumeredDofEntity::interface_type_DofEntity, EntityHandle, &NumeredDofEntity::getEnt >, member< NumeredDofEntity, unsigned int, &NumeredDofEntity::pArt > > > > > NumeredDofEntity_multiIndex
MultiIndex container keeps NumeredDofEntity.
interface_Field< DofEntity > interface_type_Field