v0.10.0
RefEntsMultiIndices.hpp
Go to the documentation of this file.
1 /** \file RefEntsMultiIndices.hpp
2  * \brief Multi-index contains, for mofem entities data structures and other
3  * low-level functions
4  */
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 __REF_ENTSMULTIINDICES_HPP__
22 #define __REF_ENTSMULTIINDICES_HPP__
23 
24 namespace MoFEM {
25 
26 template <EntityType TYPE> inline EntityHandle get_id_for_max_type() {
27  return (static_cast<EntityHandle>(TYPE) << MB_ID_WIDTH) |
28  (~static_cast<EntityHandle>(MB_TYPE_MASK));
29 };
30 
31 template <EntityType TYPE> inline EntityHandle get_id_for_min_type() {
32  return (static_cast<EntityHandle>(TYPE) << MB_ID_WIDTH);
33 };
34 
35 inline EntityHandle get_id_for_max_type(const EntityType type) {
36  return (static_cast<EntityHandle>(type) << MB_ID_WIDTH) |
37  (~static_cast<EntityHandle>(MB_TYPE_MASK));
38 };
39 
40 inline EntityHandle get_id_for_min_type(const EntityType type) {
41  return (static_cast<EntityHandle>(type) << MB_ID_WIDTH);
42 };
43 
44 /**
45  * @brief Get the tag ptr object
46  *
47  * @param moab
48  * @param th
49  * @param ent
50  * @param tag_size
51  * @return void*
52  */
53 inline void *get_tag_ptr(moab::Interface &moab, Tag th, EntityHandle ent,
54  int *tag_size) {
55  void *ret_val;
56  rval = moab.tag_get_by_ptr(th, &ent, 1, (const void **)&ret_val, tag_size);
57  if (rval != MB_SUCCESS) {
58  if (tag_size)
59  *tag_size = 0;
60  return NULL;
61  } else {
62  return ret_val;
63  }
64 }
65 
66 /**
67  * \brief keeps information about side number for the finite element
68  * \ingroup ent_multi_indices
69  */
70 struct __attribute__((__packed__)) SideNumber {
71  EntityHandle ent;
72  char side_number;
73  char sense;
74  char offset;
75  char brother_side_number;
76 
77  inline EntityType getEntType() const {
78  return static_cast<EntityType>((ent & MB_TYPE_MASK) >> MB_ID_WIDTH);
79  }
80 
81  inline int getEntDimension() const {
82  return moab::CN::Dimension(getEntType());
83  }
84 
85  inline const char *getEntTypeName() const {
86  return moab::CN::EntityTypeName(getEntType());
87  }
88 
89  SideNumber(EntityHandle ent, int side_number, int sense, int offset)
90  : ent(ent), side_number(side_number), sense(sense), offset(offset),
91  brother_side_number(-1) {}
92 };
93 
94 /**
95  * @relates multi_index_container
96  * \brief SideNumber_multiIndex for SideNumber
97  * \ingroup ent_multi_indices
98  *
99  */
100 typedef multi_index_container<
101  boost::shared_ptr<SideNumber>,
102  indexed_by<
103  ordered_unique<member<SideNumber, EntityHandle, &SideNumber::ent>>,
104  ordered_non_unique<
105 
106  composite_key<
107  SideNumber,
108  const_mem_fun<SideNumber, EntityType, &SideNumber::getEntType>,
109  member<SideNumber, char, &SideNumber::side_number>
110 
111  >>
112 
113  >>
115 
116 /**
117  * \brief PipelineManager data. like access to moab interface and basic tag
118  * handlers.
119  */
122  int pcommID;
126  BasicEntityData(const moab::Interface &mfield,
127  const int pcomm_id = MYPCOMM_INDEX);
128  virtual ~BasicEntityData() = default;
129 };
130 
131 template <int N> struct RefEntityTmp : public RefEntityTmp<N - 1> {
132 
133  using RefEntityTmp<N - 1>::RefEntityTmp;
134 
135  virtual const boost::shared_ptr<BasicEntityData> getBasicDataPtr() const {
136  if (auto ptr = basicDataPtr.lock())
137  return ptr;
138  else
139  return nullptr;
140  }
141 
142  static boost::weak_ptr<BasicEntityData> basicDataPtr;
143 };
144 
145 template <int N> boost::weak_ptr<BasicEntityData> RefEntityTmp<N>::basicDataPtr;
146 
147 struct RefElement;
148 
149 /**
150 * \brief Struct keeps handle to refined handle.
151 * \ingroup ent_multi_indices
152 
153 \todo th_RefType "_RefType" is set as two integers, need to be fixed, it is
154 waste of space.
155 
156 */
157 template <> struct RefEntityTmp<0> {
158 
159  RefEntityTmp(const boost::shared_ptr<BasicEntityData> &basic_data_ptr,
160  const EntityHandle ent);
161 
162  virtual ~RefEntityTmp() = default;
163 
164  /**
165  * @brief Get pointer to basic data struture
166  *
167  * @return const boost::shared_ptr<BasicEntityData>
168  */
169  virtual const boost::shared_ptr<BasicEntityData> getBasicDataPtr() const {
170  if (auto ptr = basicDataPtr.lock())
171  return ptr;
172  else
173  return nullptr;
174  }
175 
176  int getSideNumber() const;
177 
178  /**
179  * @brief Get the Side number
180  *
181  * @return int
182  */
183  boost::shared_ptr<SideNumber> getSideNumberPtr() const;
184 
185  /**
186  * @brief Get the entity handle
187  *
188  * @return EntityHandle
189  */
190  inline EntityHandle getEnt() const { return this->ent; }
191 
192  /** \brief Get entity type
193  */
194  inline EntityType getEntType() const {
195  return (EntityType)((this->ent & MB_TYPE_MASK) >> MB_ID_WIDTH);
196  }
197 
198  /**
199  * @brief Get the Ent Dimension
200  *
201  * @return int
202  */
203  inline int getEntDimension() const {
204  return moab::CN::Dimension(getEntType());
205  }
206 
207  /**
208  * @brief Get the Ent Type Name
209  *
210  * @return const char*
211  */
212  inline const char *getEntTypeName() const {
213  return moab::CN::EntityTypeName(getEntType());
214  }
215 
216  /** \brief get entity id
217  */
218  inline EntityID getEntId() const {
219  return (EntityID)(this->ent & MB_ID_MASK);
220  };
221 
222  static inline EntityHandle
224  boost::shared_ptr<BasicEntityData> basic_ent_data) {
225  auto *pcomm =
226  ParallelComm::get_pcomm(&basic_ent_data->moab, basic_ent_data->pcommID);
227 
228  auto get_owner_ent = [&](auto tag) {
229  if (auto owner_ent_ptr = static_cast<EntityHandle *>(
230  MoFEM::get_tag_ptr(basic_ent_data->moab, tag, ent, NULL))) {
231  return owner_ent_ptr[0];
232  } else {
233  return ent;
234  }
235  };
236 
237  if (auto pstat_ptr = static_cast<unsigned char *>(MoFEM::get_tag_ptr(
238  basic_ent_data->moab, pcomm->pstatus_tag(), ent, NULL))) {
239  if (!(*pstat_ptr & PSTATUS_NOT_OWNED)) {
240  return ent;
241  } else if (*pstat_ptr & PSTATUS_MULTISHARED) {
242  return get_owner_ent(pcomm->sharedhs_tag());
243  } else if (*pstat_ptr & PSTATUS_SHARED) {
244  return get_owner_ent(pcomm->sharedh_tag());
245  } else {
246  return ent;
247  }
248  } else {
249  return ent;
250  }
251  }
252 
253  /** \brief Owner handle on this or other processors
254  */
255  inline EntityHandle getOwnerEnt() const {
256  return getOwnerEnt(this->ent, this->getBasicDataPtr());
257  }
258 
259  static inline int
261  boost::shared_ptr<BasicEntityData> basic_ent_data) {
262  auto *pcomm =
263  ParallelComm::get_pcomm(&basic_ent_data->moab, basic_ent_data->pcommID);
264 
265  auto get_owner_proc = [&](auto tag) {
266  if (auto owner_proc = static_cast<int *>(
267  MoFEM::get_tag_ptr(basic_ent_data->moab, tag, ent, NULL))) {
268  return owner_proc[0];
269  } else {
270  return 0;
271  }
272  };
273 
274  if (auto pstat_ptr = static_cast<unsigned char *>(MoFEM::get_tag_ptr(
275  basic_ent_data->moab, pcomm->pstatus_tag(), ent, NULL))) {
276  if (!(*pstat_ptr & PSTATUS_NOT_OWNED)) {
277  return pcomm->rank();
278  } else if (*pstat_ptr & PSTATUS_MULTISHARED) {
279  return get_owner_proc(pcomm->sharedps_tag());
280  } else if (*pstat_ptr & PSTATUS_SHARED) {
281  return get_owner_proc(pcomm->sharedp_tag());
282  } else {
283  return 0;
284  }
285  } else {
286  return 0;
287  }
288  }
289 
290  inline int getOwnerProc() const {
291  return getOwnerProc(this->ent, this->getBasicDataPtr());
292  }
293 
294  static inline int
295  getPartProc(const EntityHandle ent, const Tag th,
296  const boost::shared_ptr<BasicEntityData> &basic_ptr) {
297  if (auto part_ptr = static_cast<int *>(
298  MoFEM::get_tag_ptr(basic_ptr->moab, th, ent, NULL))) {
299  return *part_ptr >= 0 ? *part_ptr : 0;
300  } else
301  return 0;
302  };
303 
304  /** \brief Get processor
305  */
306  inline int getPartProc() const {
307  if (PetscUnlikely(getEntType() == MBENTITYSET)) {
308  return getPartProc(ent, this->getBasicDataPtr()->th_MeshsetPart,
309  this->getBasicDataPtr());
310  } else {
311  auto *pcomm = ParallelComm::get_pcomm(&this->getBasicDataPtr()->moab,
312  this->getBasicDataPtr()->pcommID);
313  return getPartProc(ent, pcomm->partition_tag(), this->getBasicDataPtr());
314  }
315  }
316 
317  /**
318  * @brief Get pointer to partition tag
319  *
320  * @return int*
321  */
322  inline int *getPartProcPtr() const {
323  if (PetscUnlikely(getEntType() == MBENTITYSET)) {
324  return static_cast<int *>(MoFEM::get_tag_ptr(
325  this->getBasicDataPtr()->moab,
326  this->getBasicDataPtr()->th_MeshsetPart, ent, NULL));
327  } else {
328  auto *pcomm = ParallelComm::get_pcomm(&this->getBasicDataPtr()->moab,
329  this->getBasicDataPtr()->pcommID);
330  return static_cast<int *>(MoFEM::get_tag_ptr(
331  this->getBasicDataPtr()->moab, pcomm->partition_tag(), ent, NULL));
332  }
333  }
334 
335  /** \brief get pstatus
336  * This tag stores various aspects of parallel status in bits; see also
337  * define following, to be used in bit mask operations. If an entity is
338  * not shared with any other processors, the pstatus is 0, otherwise it's >
339  * 0
340  *
341  * bit 0: !owned (0=owned, 1=not owned)
342  * bit 1: shared (0=not shared, 1=shared)
343  * bit 2: multishared (shared by > 2 procs; 0=not shared, 1=shared)
344  * bit 3: interface (0=not interface, 1=interface)
345  * bit 4: ghost (0=not ghost, 1=ghost)
346  *
347  */
348  inline unsigned char getPStatus() const {
349  auto *pcomm = ParallelComm::get_pcomm(&this->getBasicDataPtr()->moab,
350  this->getBasicDataPtr()->pcommID);
351  if (auto pstat_ptr = static_cast<unsigned char *>(MoFEM::get_tag_ptr(
352  this->getBasicDataPtr()->moab, pcomm->pstatus_tag(), ent, NULL))) {
353  return *pstat_ptr;
354  } else {
355  return 0;
356  }
357  }
358 
359  /** \brief get shared processors
360 
361  Returning list to shared processors. Lists end with -1. Returns NULL if not
362  sharing processors.
363 
364  DO NOT MODIFY LIST.
365 
366  \code
367  BasicEntity *ent_ptr = BasicEntity(moab,entity_handle);
368  for(int proc = 0; proc<MAX_SHARING_PROCS && -1 !=
369  ent_ptr->getSharingProcsPtr[proc]; proc++) {
370  if(ent_ptr->getSharingProcsPtr[proc] == -1) {
371  // End of the list
372  break;
373  }
374  int sharing_proc = ent_ptr->getSharingProcsPtr[proc];
375  EntityHandle sharing_ent = ent_ptr->getSharingHandlersPtr[proc];
376  if(!(ent_ptr->getPStatus()&PSTATUS_MULTISHARED)) {
377  break;
378  }
379  }
380  \endcode
381 
382  */
383  int *getSharingProcsPtr() const {
384  auto &moab = this->getBasicDataPtr()->moab;
385  int *sharing_procs_ptr = NULL;
386  ParallelComm *pcomm =
387  ParallelComm::get_pcomm(&moab, this->getBasicDataPtr()->pcommID);
388  if (getPStatus() & PSTATUS_MULTISHARED) {
389  // entity is multi shared
390  rval = moab.tag_get_by_ptr(pcomm->sharedps_tag(), &this->ent, 1,
391  (const void **)&sharing_procs_ptr);
392  MOAB_THROW(rval);
393  } else if (getPStatus() & PSTATUS_SHARED) {
394  // shared
395  rval = moab.tag_get_by_ptr(pcomm->sharedp_tag(), &this->ent, 1,
396  (const void **)&sharing_procs_ptr);
397  MOAB_THROW(rval);
398  }
399  return sharing_procs_ptr;
400  }
401 
402  /** \brief get sharid entity handlers
403 
404  Returning list to shared entity handlers. Use it with getSharingProcsPtr()
405 
406  DO NOT MODIFY LIST.
407 
408  \code
409  BasicEntity *ent_ptr = BasicEntity(moab,entity_handle);
410  for(int proc = 0; proc<MAX_SHARING_PROCS && -1 !=
411  ent_ptr->getSharingProcsPtr[proc]; proc++) {
412  if(ent_ptr->getSharingProcsPtr[proc] == -1) {
413  // End of the list
414  break;
415  }
416  int sharing_proc = ent_ptr->getSharingProcsPtr[proc];
417  EntityHandle sharing_ent = ent_ptr->getSharingHandlersPtr[proc];
418  if(!(ent_ptr->getPStatus()&PSTATUS_MULTISHARED)) {
419  break;
420  }
421  }
422  \endcode
423 
424  */
426  EntityHandle *sharing_handlers_ptr = NULL;
427  auto &moab = this->getBasicDataPtr()->moab;
428  ParallelComm *pcomm =
429  ParallelComm::get_pcomm(&moab, this->getBasicDataPtr()->pcommID);
430  if (getPStatus() & PSTATUS_MULTISHARED) {
431  // entity is multi shared
432  rval = moab.tag_get_by_ptr(pcomm->sharedhs_tag(), &this->ent, 1,
433  (const void **)&sharing_handlers_ptr);
434  MOAB_THROW(rval);
435  } else if (getPStatus() & PSTATUS_SHARED) {
436  // shared
437  rval = moab.tag_get_by_ptr(pcomm->sharedh_tag(), &this->ent, 1,
438  (const void **)&sharing_handlers_ptr);
439  MOAB_THROW(rval);
440  }
441  return sharing_handlers_ptr;
442  }
443 
444  static MoFEMErrorCode getParentEnt(Interface &moab, Range ents,
445  std::vector<EntityHandle> vec_patent_ent);
446 
447  static MoFEMErrorCode
448  getBitRefLevel(Interface &moab, Range ents,
449  std::vector<BitRefLevel> &vec_bit_ref_level) {
451  Tag th_ref_bit_level;
452  CHKERR moab.tag_get_handle("_RefBitLevel", th_ref_bit_level);
453  vec_bit_ref_level.resize(ents.size());
454  CHKERR moab.tag_get_data(th_ref_bit_level, ents,
455  &*vec_bit_ref_level.begin());
457  }
458 
459  static MoFEMErrorCode
460  getBitRefLevel(Interface &moab, Range ents,
461  std::vector<const BitRefLevel *> &vec_ptr_bit_ref_level) {
463  Tag th_ref_bit_level;
464  CHKERR moab.tag_get_handle("_RefBitLevel", th_ref_bit_level);
465  vec_ptr_bit_ref_level.resize(ents.size());
466  CHKERR moab.tag_get_by_ptr(
467  th_ref_bit_level, ents,
468  reinterpret_cast<const void **>(&*vec_ptr_bit_ref_level.begin()));
470  }
471 
472  /**
473  * \brief Get pointer to parent entity tag.
474  *
475  * Each refined entity has his parent. Such information is stored on tags.
476  * This function get pinter to tag.
477  *
478  * @return Pointer to tag on entity
479  */
481  return static_cast<EntityHandle *>(get_tag_ptr(
482  this->getBasicDataPtr()->moab,
483  this->getBasicDataPtr()->th_RefParentHandle, this->ent, NULL));
484  }
485 
486  /**
487  * \brief Get pointer to bit ref level tag
488 
489  * Every entity belongs to some refinement level or levels. Each level is
490  marked
491  * by bit set in BitRefLevel() (bitset) structure.
492  *
493  * See \ref mix_mesh_refinement for explanation.
494 
495  * @return Return pointer to tag.
496  */
498  return static_cast<BitRefLevel *>(
499  get_tag_ptr(this->getBasicDataPtr()->moab,
500  this->getBasicDataPtr()->th_RefBitLevel, this->ent, NULL));
501  }
502 
503  /** \brief Get patent entity
504  */
505  inline EntityType getParentEntType() const {
506  EntityHandle *tag_parent_ent = getParentEntPtr();
507  if (*tag_parent_ent == 0)
508  return MBMAXTYPE;
509  return (EntityType)((*tag_parent_ent & MB_TYPE_MASK) >> MB_ID_WIDTH);
510  }
511 
512  /** \brief Get parent entity, i.e. entity form one refinement level up
513  */
514  inline EntityHandle getParentEnt() const { return *(getParentEntPtr()); }
515 
516  /** \brief Get entity ref bit refinement signature
517  */
518  inline const BitRefLevel &getBitRefLevel() const {
519  return *getBitRefLevelPtr();
520  }
521 
522  /** \brief Get entity ref bit refinement as ulong
523  */
524  inline unsigned long int getBitRefLevelULong() const {
525  return getBitRefLevel().to_ulong();
526  }
527 
528  friend std::ostream &operator<<(std::ostream &os, const RefEntityTmp &e);
529 
531  static boost::weak_ptr<BasicEntityData> basicDataPtr;
532 
533 private:
534  friend struct EntFiniteElement;
535  friend struct NumeredEntFiniteElement;
536 
537  /**
538  * @brief Get the pointer to reference element
539  *
540  * @return const boost::shared_ptr<RefElement>
541  */
542  inline const boost::shared_ptr<RefElement> getRefElementPtr() const {
543  if (auto ptr = refElementPtr.lock())
544  return ptr;
545  else
546  return nullptr;
547  }
548 
549  static boost::weak_ptr<RefElement> refElementPtr;
550 };
551 
552 template <> struct RefEntityTmp<-1> : public RefEntityTmp<0> {
553 
554  RefEntityTmp(const boost::shared_ptr<BasicEntityData> &basic_data_ptr,
555  const EntityHandle ent)
556  : RefEntityTmp<0>(basic_data_ptr, ent), basicDataPtr(basic_data_ptr) {}
557 
558  virtual const boost::shared_ptr<BasicEntityData> getBasicDataPtr() const {
559  if (auto ptr = basicDataPtr.lock())
560  return ptr;
561  else
562  return nullptr;
563  }
564 
565 private:
566  mutable boost::weak_ptr<BasicEntityData> basicDataPtr;
567 };
568 
570 
571 /**
572  * \brief interface to RefEntity
573  * \ingroup ent_multi_indices
574  */
575 template <typename T> struct interface_RefEntity {
576 
577  interface_RefEntity(const boost::shared_ptr<T> &sptr) : sPtr(sptr) {}
578 
580  : sPtr(interface.getRefEntityPtr()) {}
581 
582  virtual ~interface_RefEntity() = default;
583 
584  /**
585  * @copydoc MoFEM::RefEntityTmp<0>::getSideNumber
586  */
587  inline int getSideNumber() const { return this->sPtr->getSideNumber(); }
588 
589  /**
590  * @copydoc MoFEM::RefEntityTmp<0>::getSideNumberPtr
591  */
592  inline boost::shared_ptr<SideNumber> getSideNumberPtr() const {
593  return this->sPtr->getSideNumberPtr();
594  }
595 
596  /**
597  * @copydoc MoFEM::RefEntityTmp<0>::getBasicDataPtr
598  */
599  inline const boost::shared_ptr<BasicEntityData> getBasicDataPtr() const {
600  return this->sPtr->getBasicDataPtr();
601  }
602 
603  /**
604  * @copydoc MoFEM::RefEntityTmp<0>::getEnt
605  */
606  inline EntityHandle getEnt() const { return this->sPtr->getEnt(); }
607 
608  /**
609  * @copydoc MoFEM::RefEntityTmp<0>::getParentEntType
610  */
611  inline EntityType getParentEntType() const {
612  return this->sPtr->getParentEntType();
613  };
614 
615  /**
616  * @copydoc MoFEM::RefEntityTmp<0>::getParentEnt
617  */
618  inline EntityHandle getParentEnt() const {
619  return this->sPtr->getParentEnt();
620  }
621 
622  /**
623  * @copydoc MoFEM::RefEntityTmp<0>::getBitRefLevelPtr
624  */
625  inline BitRefLevel *getBitRefLevelPtr() const {
626  return this->sPtr->getBitRefLevelPtr();
627  }
628 
629  /**
630  * @copydoc MoFEM::RefEntityTmp<0>::getBitRefLevel
631  */
632  inline const BitRefLevel &getBitRefLevel() const {
633  return this->sPtr->getBitRefLevel();
634  }
635 
636  /**
637  * @copydoc MoFEM::RefEntityTmp<0>::getBitRefLevelULong
638  */
639  inline unsigned long int getBitRefLevelULong() const {
640  return this->sPtr->getBitRefLevelULong();
641  }
642 
643  /**
644  * @copydoc MoFEM::RefEntityTmp<0>::getEntType
645  */
646  inline EntityType getEntType() const { return this->sPtr->getEntType(); };
647 
648  /**
649  * @copydoc MoFEM::RefEntityTmp<0>::getEntDimension
650  */
651  inline int getEntDimension() const { return this->sPtr->getEntDimension(); }
652 
653  /**
654  * @copydoc MoFEM::RefEntityTmp<0>::getEntTypeName
655  */
656  inline const char *getEntTypeName() const {
657  return this->sPtr->getEntTypeName();
658  }
659 
660  /**
661  * @copydoc MoFEM::RefEntityTmp<0>::getEntId
662  */
663  inline EntityID getEntId() const { return this->sPtr->getEntId(); };
664 
665  /**
666  * @copydoc MoFEM::RefEntityTmp<0>::getOwnerEnt
667  */
668  inline EntityHandle getOwnerEnt() const { return this->sPtr->getOwnerEnt(); }
669 
670  /**
671  * @copydoc MoFEM::RefEntityTmp<0>::getOwnerEnt
672  */
673  inline EntityHandle &getOwnerEnt() { return this->sPtr->getOwnerEnt(); }
674 
675  /**
676  * @copydoc MoFEM::RefEntityTmp<0>::getOwnerProc
677  */
678  inline int getOwnerProc() const { return this->sPtr->getOwnerProc(); }
679 
680  /**
681  * @copydoc MoFEM::RefEntityTmp<0>::getPartProc
682  */
683  inline int getPartProc() const { return this->sPtr->getPartProc(); }
684 
685  /**
686  * @copydoc MoFEM::RefEntityTmp<0>::getPartProcPtr
687  */
688  inline int *getPartProcPtr() const { return this->sPtr->getPartProcPtr(); }
689 
690  /**
691  * @copydoc MoFEM::RefEntityTmp<0>::getPartProc
692  */
693  inline unsigned char getPStatus() const { return this->sPtr->getPStatus(); }
694 
695  /**
696  * @copydoc MoFEM::RefEntityTmp<0>::getSharingProcsPtr
697  */
698  inline int *getSharingProcsPtr() const {
699  return this->sPtr->getSharingProcsPtr();
700  }
701 
702  /**
703  * @copydoc MoFEM::RefEntityTmp<0>::getSharingHandlersPtr
704  */
706  return this->sPtr->getSharingHandlersPtr();
707  }
708 
709  /**
710  * @copydoc MoFEM::RefEntityTmp<0>::getRefEntityPtr
711  */
712  inline boost::shared_ptr<T> &getRefEntityPtr() const { return this->sPtr; }
713 
714  mutable boost::shared_ptr<T> sPtr;
715 };
716 
717 /**
718  * \typedef RefEntity_multiIndex
719  * type multiIndex container for RefEntity
720  * \ingroup ent_multi_indices
721  *
722  * \param hashed_unique Ent_mi_tag
723  * \param ordered_non_unique Meshset_mi_tag
724  * \param ordered_non_unique Ent_Ent_mi_tag
725  * \param ordered_non_unique Composite_EntType_And_ParentEntType_mi_tag
726  * \param ordered_non_unique Composite_ParentEnt_And_EntType_mi_tag
727  */
728 using RefEntity_multiIndex = multi_index_container<
729  boost::shared_ptr<RefEntity>,
730  indexed_by<ordered_unique<
731 
732  tag<Ent_mi_tag>,
733  const_mem_fun<RefEntity, EntityHandle, &RefEntity::getEnt>
734 
735  >,
736 
737  ordered_non_unique<
738 
739  tag<Ent_Ent_mi_tag>, const_mem_fun<RefEntity, EntityHandle,
741 
742  >,
743 
744  ordered_non_unique<
745  tag<Composite_EntType_and_ParentEntType_mi_tag>,
746  composite_key<RefEntity,
747  const_mem_fun<RefEntity, EntityType,
749  const_mem_fun<RefEntity, EntityType,
751 
752  >,
753 
754  ordered_non_unique<
755  tag<Composite_ParentEnt_And_EntType_mi_tag>,
756  composite_key<RefEntity,
757  const_mem_fun<RefEntity, EntityType,
759  const_mem_fun<RefEntity, EntityHandle,
761 
762  >;
763 
764 /** \brief multi-index view of RefEntity by parent entity
765 \ingroup ent_multi_indices
766 */
767 using RefEntity_multiIndex_view_by_hashed_parent_entity = multi_index_container<
768  boost::shared_ptr<RefEntity>,
769  indexed_by<
770  hashed_non_unique<
771  const_mem_fun<RefEntity, EntityHandle, &RefEntity::getParentEnt>>,
772  hashed_unique<tag<Composite_EntType_and_ParentEntType_mi_tag>,
773  composite_key<boost::shared_ptr<RefEntity>,
774  const_mem_fun<RefEntity, EntityHandle,
776  const_mem_fun<RefEntity, EntityHandle,
778 
779  >;
780 
782  multi_index_container<
783  boost::shared_ptr<RefEntity>,
784  indexed_by<ordered_non_unique<const_mem_fun<RefEntity, EntityHandle,
786  hashed_unique<
787  tag<Composite_EntType_and_ParentEntType_mi_tag>,
788  composite_key<boost::shared_ptr<RefEntity>,
789  const_mem_fun<RefEntity, EntityHandle,
791  const_mem_fun<RefEntity, EntityHandle,
793 
794  >;
795 
796 using RefEntity_multiIndex_view_sequence_ordered_view = multi_index_container<
797  boost::shared_ptr<RefEntity>,
798  indexed_by<
799  sequenced<>,
800  ordered_unique<tag<Ent_mi_tag>, const_mem_fun<RefEntity, EntityHandle,
802 
803 /** \brief change parent
804 * \ingroup ent_multi_indices
805 *
806 * Use this function with care. Some other multi-indices can deponent on
807 this.
808 
809 Known dependent multi-indices (verify if that list is full):
810 - RefEntity_multiIndex
811 - RefElement_multiIndex
812 
813 */
817  inline void operator()(boost::shared_ptr<RefEntity> &e) {
818  rval = e->getBasicDataPtr()->moab.tag_set_data(
819  e->getBasicDataPtr()->th_RefParentHandle, &e->ent, 1, &pArent);
820  MOAB_THROW(rval);
821  }
822 };
823 
824 /** \brief ref mofem entity, left shift
825  * \ingroup ent_multi_indices
826  */
828  int shift;
830  RefEntity_change_left_shift(const int _shift,
831  const BitRefLevel _mask = BitRefLevel().set())
832  : shift(_shift), mask(_mask) {}
833  inline void operator()(boost::shared_ptr<RefEntity> &e) {
834  BitRefLevel bit = *(e->getBitRefLevelPtr());
835  (*e->getBitRefLevelPtr()) = ((bit & mask) << shift) | (bit & ~mask);
836  };
837 };
838 
839 /** \brief ref mofem entity, right shift
840  * \ingroup ent_multi_indices
841  */
843  int shift;
846  const BitRefLevel _mask = BitRefLevel().set())
847  : shift(_shift), mask(_mask) {}
848  inline void operator()(boost::shared_ptr<RefEntity> &e) {
849  BitRefLevel bit = *(e->getBitRefLevelPtr());
850  *(e->getBitRefLevelPtr()) = ((bit & mask) >> shift) | (bit & ~mask);
851  };
852 };
853 } // namespace MoFEM
854 
855 #endif // __REF_ENTSMULTIINDICES_HPP__
856 
857 /**
858  * \defgroup ent_multi_indices Entities structures and multi-indices
859  * \ingroup mofem
860  **/
interface_RefEntity(const interface_RefEntity< T > &interface)
EntityHandle get_id_for_max_type()
EntityHandle get_id_for_min_type()
RefEntity_change_left_shift(const int _shift, const BitRefLevel _mask=BitRefLevel().set())
Deprecated interface functions.
static MoFEMErrorCode getBitRefLevel(Interface &moab, Range ents, std::vector< BitRefLevel > &vec_bit_ref_level)
int * getPartProcPtr() const
Get pointer to partition tag.
virtual const boost::shared_ptr< BasicEntityData > getBasicDataPtr() const
Get pointer to basic data struture.
change parentUse this function with care. Some other multi-indices can deponent on this.
int getEntDimension() const
Get the Ent Dimension.
static int getPartProc(const EntityHandle ent, const Tag th, const boost::shared_ptr< BasicEntityData > &basic_ptr)
multi_index_container< boost::shared_ptr< RefEntity >, indexed_by< ordered_non_unique< const_mem_fun< RefEntity, EntityHandle, &RefEntity::getParentEnt > >, hashed_unique< tag< Composite_EntType_and_ParentEntType_mi_tag >, composite_key< boost::shared_ptr< RefEntity >, const_mem_fun< RefEntity, EntityHandle, &RefEntity::getEnt >, const_mem_fun< RefEntity, EntityHandle, &RefEntity::getParentEnt > >> > > RefEntity_multiIndex_view_by_ordered_parent_entity
multi_index_container< boost::shared_ptr< SideNumber >, indexed_by< ordered_unique< member< SideNumber, EntityHandle, &SideNumber::ent > >, ordered_non_unique< composite_key< SideNumber, const_mem_fun< SideNumber, EntityType, &SideNumber::getEntType >, member< SideNumber, char, &SideNumber::side_number > > > > > SideNumber_multiIndex
SideNumber_multiIndex for SideNumber.
EntityType getEntType() const
Get entity type.
static MoFEMErrorCode getBitRefLevel(Interface &moab, Range ents, std::vector< const BitRefLevel * > &vec_ptr_bit_ref_level)
static boost::weak_ptr< BasicEntityData > basicDataPtr
const boost::shared_ptr< BasicEntityData > getBasicDataPtr() const
Get pointer to basic data struture.
RefEntityTmp< 0 > RefEntity
RefEntity_change_right_shift(const int _shift, const BitRefLevel _mask=BitRefLevel().set())
EntityHandle * getParentEntPtr() const
Get pointer to parent entity tag.
Struct keeps handle to refined handle.
Partitioned (Indexed) Finite Element in Problem.
RefEntityTmp(const boost::shared_ptr< BasicEntityData > &basic_data_ptr, const EntityHandle ent)
unsigned char getPStatus() const
get pstatus This tag stores various aspects of parallel status in bits; see also define following,...
EntityID getEntId() const
get entity id
#define MB_TYPE_MASK
Definition: definitions.h:297
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:485
boost::weak_ptr< BasicEntityData > basicDataPtr
EntityHandle getParentEnt() const
Get parent entity, i.e. entity form one refinement level up.
int * getSharingProcsPtr() const
get shared processors
EntityHandle * getSharingHandlersPtr() const
get sharid entity handlers
const boost::shared_ptr< RefElement > getRefElementPtr() const
Get the pointer to reference element.
#define MOAB_THROW(a)
Check error code of MoAB function and throw MoFEM exception.
Definition: definitions.h:610
implementation of Data Operators for Forces and Sources
Definition: Common.hpp:21
PipelineManager data. like access to moab interface and basic tag handlers.
keeps data about abstract refined finite element
EntityHandle getOwnerEnt() const
Owner handle on this or other processors.
EntityHandle getOwnerEnt() const
const BitRefLevel & getBitRefLevel() const
static MoFEMErrorCodeGeneric< moab::ErrorCode > rval
Definition: Exceptions.hpp:85
std::ostream & operator<<(std::ostream &os, const DataForcesAndSourcesCore::EntData &e)
EntityHandle getParentEnt() const
boost::shared_ptr< T > & getRefEntityPtr() const
EntityType getParentEntType() const
Get patent entity.
int * getPartProcPtr() const
Get pointer to partition tag.
struct __attribute__((__packed__)) SideNumber
keeps information about side number for the finite element
const char * getEntTypeName() const
Get the Ent Type Name.
unsigned long int getBitRefLevelULong() const
Get entity ref bit refinement as ulong.
EntityHandle getEnt() const
Get the entity handle.
EntityHandle * getSharingHandlersPtr() const
get sharid entity handlers
virtual ~BasicEntityData()=default
interface_RefEntity(const boost::shared_ptr< T > &sptr)
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
Definition: Exceptions.hpp:67
BasicEntityData(const moab::Interface &mfield, const int pcomm_id=MYPCOMM_INDEX)
static int getOwnerProc(const EntityHandle ent, boost::shared_ptr< BasicEntityData > basic_ent_data)
#define MB_ID_MASK
Definition: definitions.h:303
const BitRefLevel & getBitRefLevel() const
Get entity ref bit refinement signature.
multi_index_container< boost::shared_ptr< RefEntity >, indexed_by< sequenced<>, ordered_unique< tag< Ent_mi_tag >, const_mem_fun< RefEntity, EntityHandle, &RefEntity::getEnt > >> > RefEntity_multiIndex_view_sequence_ordered_view
EntityType getEntType() const
Get entity type.
interface to RefEntity
BitRefLevel * getBitRefLevelPtr() const
Get pointer to bit ref level tag.
static boost::weak_ptr< RefElement > refElementPtr
unsigned long int getBitRefLevelULong() const
Get entity ref bit refinement as ulong.
Finite element data for entity.
#define CHKERR
Inline error check.
Definition: definitions.h:604
int getPartProc() const
Get processor.
BitRefLevel * getBitRefLevelPtr() const
Get pointer to bit ref level tag.
unsigned char getPStatus() const
EntityType getParentEntType() const
Get patent entity.
#define MYPCOMM_INDEX
default communicator number PCOMM
Definition: definitions.h:292
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
Definition: Types.hpp:51
const char * getEntTypeName() const
Get the Ent Type Name.
multi_index_container< boost::shared_ptr< RefEntity >, indexed_by< ordered_unique< tag< Ent_mi_tag >, const_mem_fun< RefEntity, EntityHandle, &RefEntity::getEnt > >, ordered_non_unique< tag< Ent_Ent_mi_tag >, const_mem_fun< RefEntity, EntityHandle, &RefEntity::getParentEnt > >, ordered_non_unique< tag< Composite_EntType_and_ParentEntType_mi_tag >, composite_key< RefEntity, const_mem_fun< RefEntity, EntityType, &RefEntity::getEntType >, const_mem_fun< RefEntity, EntityType, &RefEntity::getParentEntType > > >, ordered_non_unique< tag< Composite_ParentEnt_And_EntType_mi_tag >, composite_key< RefEntity, const_mem_fun< RefEntity, EntityType, &RefEntity::getEntType >, const_mem_fun< RefEntity, EntityHandle, &RefEntity::getParentEnt > >> > > RefEntity_multiIndex
EntityHandle getEnt() const
Get the entity handle.
void * get_tag_ptr(moab::Interface &moab, Tag th, EntityHandle ent, int *tag_size)
Get the tag ptr object.
boost::shared_ptr< SideNumber > getSideNumberPtr() const
Get the Side number.
void operator()(boost::shared_ptr< RefEntity > &e)
DeprecatedCoreInterface Interface
Definition: Interface.hpp:1943
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:415
void operator()(boost::shared_ptr< RefEntity > &e)
void operator()(boost::shared_ptr< RefEntity > &e)
RefEntity_change_parent(EntityHandle parent)
static EntityHandle getOwnerEnt(const EntityHandle ent, boost::shared_ptr< BasicEntityData > basic_ent_data)
int getEntDimension() const
Get the Ent Dimension.
virtual const boost::shared_ptr< BasicEntityData > getBasicDataPtr() const
#define MB_ID_WIDTH
Definition: definitions.h:296
const int N
Definition: speed_test.cpp:3
static boost::weak_ptr< BasicEntityData > basicDataPtr
virtual const boost::shared_ptr< BasicEntityData > getBasicDataPtr() const
Get pointer to basic data struture.
int * getSharingProcsPtr() const
get shared processors
EntityID getEntId() const
get entity id
virtual ~interface_RefEntity()=default
multi_index_container< boost::shared_ptr< RefEntity >, indexed_by< hashed_non_unique< const_mem_fun< RefEntity, EntityHandle, &RefEntity::getParentEnt > >, hashed_unique< tag< Composite_EntType_and_ParentEntType_mi_tag >, composite_key< boost::shared_ptr< RefEntity >, const_mem_fun< RefEntity, EntityHandle, &RefEntity::getEnt >, const_mem_fun< RefEntity, EntityHandle, &RefEntity::getParentEnt > >> > > RefEntity_multiIndex_view_by_hashed_parent_entity
multi-index view of RefEntity by parent entity