v0.9.0
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->getEntFieldDataPtr())[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<Composite_Name_Type_And_Side_Number_mi_tag>,
535  composite_key<
538  boost::string_ref,
541  EntityType, &FENumeredDofEntity::getEntType>,
544  boost::shared_ptr<SideNumber>,
546  ordered_non_unique<
547  tag<Composite_Name_And_Type_mi_tag>,
548  composite_key<
551  boost::string_ref,
554  EntityType, &FENumeredDofEntity::getEntType>>>,
555  ordered_non_unique<
556  tag<Composite_Name_And_Ent_mi_tag>,
557  composite_key<
560  boost::string_ref,
565 
566 /** \brief Finite element numbered DoF multi-index by field name
567  *
568  * \ingroup dof_multi_indices
569  */
570 typedef FENumeredDofEntity_multiIndex::index<FieldName_mi_tag>::type
572 
573 /** \brief Dof entity multi-index by field name and entity
574  *
575  * \ingroup dof_multi_indices
576  */
577 typedef FENumeredDofEntity_multiIndex::index<
579 
580 /** \brief Dof entity multi-index by field name and entity type
581  *
582  * \ingroup dof_multi_indices
583  */
584 typedef FENumeredDofEntity_multiIndex::index<
586 
587 /** \brief Dof entity multi-index by UId
588  *
589  * \ingroup dof_multi_indices
590  */
591 typedef FENumeredDofEntity_multiIndex::index<Unique_mi_tag>::type
593 
594 /** \brief Numbered DoF multi-index by entity
595  *
596  * \ingroup dof_multi_indices
597  */
598 typedef FENumeredDofEntity_multiIndex::index<Ent_mi_tag>::type
600 
601 /**
602  * @relates multi_index_container
603  * \brief MultiIndex container keeps NumeredDofEntity
604  * \ingroup dof_multi_indices
605  */
606 typedef multi_index_container<
607  boost::shared_ptr<NumeredDofEntity>,
608 
609  // unique
610  indexed_by<
611  ordered_unique<
612  tag<Unique_mi_tag>,
615 
616  // non unique
617  ordered_non_unique<
618  tag<Unique_Ent_mi_tag>,
620  const UId &,
622 
623  ordered_non_unique<
624  tag<Part_mi_tag>,
625  member<NumeredDofEntity, unsigned int, &NumeredDofEntity::pArt>>,
626  ordered_non_unique<tag<Idx_mi_tag>, member<NumeredDofEntity, DofIdx,
628 
629  ordered_non_unique<
630  tag<FieldName_mi_tag>,
632  boost::string_ref, &NumeredDofEntity::getNameRef>>,
633 
634  ordered_non_unique<tag<PetscGlobalIdx_mi_tag>,
635  member<NumeredDofEntity, DofIdx,
637 
638  ordered_non_unique<tag<PetscLocalIdx_mi_tag>,
639  member<NumeredDofEntity, DofIdx,
641 
642  ordered_non_unique<
643  tag<Ent_mi_tag>,
646 
647  ordered_non_unique<
648  tag<Composite_Name_And_Ent_And_EntDofIdx_mi_tag>,
649  composite_key<
652  boost::string_ref, &NumeredDofEntity::getNameRef>,
657 
658  ordered_non_unique<
659  tag<Composite_Name_And_Part_mi_tag>,
660  composite_key<
663  boost::string_ref, &NumeredDofEntity::getNameRef>,
664  member<NumeredDofEntity, unsigned int,
666 
667  ordered_non_unique<
668  tag<Composite_Name_Ent_And_Part_mi_tag>,
669  composite_key<
672  boost::string_ref, &NumeredDofEntity::getNameRef>,
675  member<NumeredDofEntity, unsigned int,
677 
678  >>
680 
681 /** \brief Numbered DoF multi-index by field name
682  *
683  * \ingroup dof_multi_indices
684  */
685 typedef NumeredDofEntity_multiIndex::index<FieldName_mi_tag>::type
687 
688 /** \brief Numbered DoF multi-index by UId
689  *
690  * \ingroup dof_multi_indices
691  */
692 typedef NumeredDofEntity_multiIndex::index<Unique_mi_tag>::type
694 
695 /** \brief Numbered DoF multi-index by local index
696  *
697  * \ingroup dof_multi_indices
698  */
699 typedef NumeredDofEntity_multiIndex::index<PetscLocalIdx_mi_tag>::type
701 
702 /** \brief Numbered DoF multi-index by entity
703  *
704  * \ingroup dof_multi_indices
705  */
706 typedef NumeredDofEntity_multiIndex::index<Ent_mi_tag>::type
708 
709 /** \brief Numbered DoF multi-index by name entity and partition
710  *
711  * \ingroup dof_multi_indices
712  */
713 typedef NumeredDofEntity_multiIndex::index<
715 
716 typedef multi_index_container<
717  boost::shared_ptr<NumeredDofEntity>,
718  indexed_by<ordered_unique<
719  const_mem_fun<NumeredDofEntity::interface_type_DofEntity, const UId &,
722 
723 typedef multi_index_container<
724  boost::shared_ptr<NumeredDofEntity>,
725  indexed_by<hashed_unique<const_mem_fun<NumeredDofEntity, DofIdx,
728 
729 typedef multi_index_container<
730  boost::shared_ptr<NumeredDofEntity>,
731  indexed_by<ordered_non_unique<const_mem_fun<
734 
735 typedef multi_index_container<
736  boost::shared_ptr<NumeredDofEntity>,
737  indexed_by<ordered_non_unique<const_mem_fun<
741 
742 /**
743  * Activate or deactivate dofs (multi-index modifier)
744  * \ingroup dof_multi_indices
745  */
747  bool aCtive;
748  DofEntity_active_change(bool active);
749  void operator()(boost::shared_ptr<DofEntity> &dof);
750 };
751 
752 /**
753  * Change part and global pestc index (multi-index modifier)
754  * \ingroup dof_multi_indices
755  */
757  const unsigned int pArt;
760  const DofIdx petsc_gloabl_dof_idx)
761  : pArt(part), petscGloablDofIdx(petsc_gloabl_dof_idx){};
762  inline void operator()(boost::shared_ptr<NumeredDofEntity> &dof) const {
763  dof->pArt = pArt;
764  dof->petscGloablDofIdx = petscGloablDofIdx;
765  }
766 };
767 
769  const unsigned int pArt;
773  const unsigned int part, const DofIdx mofem_dof_idx,
774  const DofIdx petsc_gloabl_dof_idx)
775  : pArt(part), mofemDofIdx(mofem_dof_idx),
776  petscGloablDofIdx(petsc_gloabl_dof_idx){};
777  inline void operator()(boost::shared_ptr<NumeredDofEntity> &dof) const {
778  dof->pArt = pArt;
779  dof->petscGloablDofIdx = petscGloablDofIdx;
780  }
781 };
782 
784  const unsigned int pArt;
788  const DofIdx petsc_gloabl_dof_idx,
789  const DofIdx petsc_local_dof_idx)
790  : pArt(part), petscGloablDofIdx(petsc_gloabl_dof_idx),
791  petscLocalDofIdx(petsc_local_dof_idx){};
792  inline void operator()(boost::shared_ptr<NumeredDofEntity> &dof) const {
793  dof->pArt = pArt;
794  dof->petscGloablDofIdx = petscGloablDofIdx;
795  dof->petscLocalDofIdx = petscLocalDofIdx;
796  }
797 };
798 
799 /**
800  * Change part and local pestc index (multi-index modifier)
801  * \ingroup dof_multi_indices
802  */
805  NumeredDofEntity_local_idx_change(const DofIdx petsc_local_dof_idx)
806  : petscLocalDofIdx(petsc_local_dof_idx){};
807  inline void operator()(boost::shared_ptr<NumeredDofEntity> &dof) const {
808  dof->petscLocalDofIdx = petscLocalDofIdx;
809  }
810 };
811 
812 /**
813  * Change part and mofem index (multi-index modifier)
814  * \ingroup dof_multi_indices
815  */
819  : mofemIdx(mofem_idx){};
820  inline void operator()(boost::shared_ptr<NumeredDofEntity> &dof) const {
821  dof->dofIdx = mofemIdx;
822  }
823 };
824 
825 /**
826  * Change part and mofem/pestc global and local index (multi-index modifier)
827  * \ingroup dof_multi_indices
828  */
830  const unsigned int pArt;
835  const unsigned int part, const DofIdx mofem_idx,
836  const DofIdx petsc_gloabl_dof_idx, const DofIdx petsc_local_dof_idx)
837  : pArt(part), mofemIdx(mofem_idx),
838  petscGloablDofIdx(petsc_gloabl_dof_idx),
839  petscLocalDofIdx(petsc_local_dof_idx){};
840  inline void operator()(boost::shared_ptr<NumeredDofEntity> &dof) const {
841  dof->pArt = pArt;
842  dof->dofIdx = mofemIdx;
843  dof->petscGloablDofIdx = petscGloablDofIdx;
844  dof->petscLocalDofIdx = petscLocalDofIdx;
845  }
846 };
847 
848 /**
849  * Replace dofs shared_ptr
850  *
851  * DOFs on entities are stored by sequences. If DOFs to entities are added,
852  * whole entity sequence is change to preserve continuity in memory
853  *
854  * \ingroup dof_multi_indices
855  */
856 template <class T> struct Dof_shared_ptr_change {
857  boost::shared_ptr<T> &dofPtr;
858  Dof_shared_ptr_change(boost::shared_ptr<T> &dof_ptr) : dofPtr(dof_ptr){};
859  inline void operator()(boost::shared_ptr<T> &dof) { dof = dofPtr; }
860 };
861 
862 } // namespace MoFEM
863 #endif // __DOFSMULTIINDICES_HPP__
864 
865 /***************************************************************************/ /**
866  * \defgroup dof_multi_indices Dofs structures and multi-indices
867  * \ingroup mofem
868 ******************************************************************************/
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
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
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
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< 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.
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
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:298
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
int FieldCoefficientsNumber
Number of field coefficients.
Definition: Types.hpp:38
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)
int DofIdx
Index of DOF.
Definition: Types.hpp:29
std::array< int, MAX_DOFS_ON_ENTITY > & getDofOrderMap() const
get hash-map relating dof index on entity with its order
FEDofEntity_multiIndex::index< Composite_Name_And_Type_mi_tag >::type FEDofEntityByNameAndType
Dof entity multi-index by field name and entity type.
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:299
void operator()(boost::shared_ptr< NumeredDofEntity > &dof) const
uint128_t UId
Unique Id.
Definition: Types.hpp:41
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