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