v0.13.2
Loading...
Searching...
No Matches
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
23 return (static_cast<EntityHandle>(type) << MB_ID_WIDTH) |
24 (~static_cast<EntityHandle>(MB_TYPE_MASK));
25};
26
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 {
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
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 */
108 moab::Interface &moab;
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*/
141template <> struct RefEntityTmp<0> {
142
143 RefEntityTmp(const boost::shared_ptr<BasicEntityData> &basic_data_ptr,
144 const EntityHandle ent);
145
146 RefEntityTmp(const boost::shared_ptr<BasicEntityData> &basic_data_ptr,
147 const EntityHandle ent, EntityHandle *ent_parent_tag_ptr);
148
149 virtual ~RefEntityTmp() = default;
150
151 /**
152 * @brief Get pointer to basic data struture
153 *
154 * @return const boost::shared_ptr<BasicEntityData>
155 */
156 virtual const boost::shared_ptr<BasicEntityData> getBasicDataPtr() const {
157 if (auto ptr = basicDataPtr.lock())
158 return ptr;
159 else
160 return nullptr;
161 }
162
163 int getSideNumber() const;
164
165 /**
166 * @brief Get the Side number
167 *
168 * @return int
169 */
170 boost::shared_ptr<SideNumber> getSideNumberPtr() const;
171
172 /**
173 * @brief Get the entity handle
174 *
175 * @return EntityHandle
176 */
177 inline EntityHandle getEnt() const { return this->ent; }
178
179 /** \brief Get entity type
180 */
181 inline EntityType getEntType() const {
182 return (EntityType)((this->ent & MB_TYPE_MASK) >> MB_ID_WIDTH);
183 }
184
185 /**
186 * @brief Get the Ent Dimension
187 *
188 * @return int
189 */
190 inline int getEntDimension() const {
191 return moab::CN::Dimension(getEntType());
192 }
193
194 /**
195 * @brief Get the Ent Type Name
196 *
197 * @return const char*
198 */
199 inline const char *getEntTypeName() const {
200 return moab::CN::EntityTypeName(getEntType());
201 }
202
203 /** \brief get entity id
204 */
205 inline EntityID getEntId() const {
206 return (EntityID)(this->ent & MB_ID_MASK);
207 };
208
209 static inline EntityHandle
211 boost::shared_ptr<BasicEntityData> basic_ent_data) {
212 auto *pcomm =
213 ParallelComm::get_pcomm(&basic_ent_data->moab, basic_ent_data->pcommID);
214
215 auto get_owner_ent = [&](auto tag) {
216 if (auto owner_ent_ptr = static_cast<EntityHandle *>(
217 MoFEM::get_tag_ptr(basic_ent_data->moab, tag, ent, NULL))) {
218 return owner_ent_ptr[0];
219 } else {
220 return ent;
221 }
222 };
223
224 if (auto pstat_ptr = static_cast<unsigned char *>(MoFEM::get_tag_ptr(
225 basic_ent_data->moab, pcomm->pstatus_tag(), ent, NULL))) {
226 if (!(*pstat_ptr & PSTATUS_NOT_OWNED)) {
227 return ent;
228 } else if (*pstat_ptr & PSTATUS_MULTISHARED) {
229 return get_owner_ent(pcomm->sharedhs_tag());
230 } else if (*pstat_ptr & PSTATUS_SHARED) {
231 return get_owner_ent(pcomm->sharedh_tag());
232 } else {
233 return ent;
234 }
235 } else {
236 return ent;
237 }
238 }
239
240 /** \brief Owner handle on this or other processors
241 */
242 inline EntityHandle getOwnerEnt() const {
243 return getOwnerEnt(this->ent, this->getBasicDataPtr());
244 }
245
246 static inline int
248 boost::shared_ptr<BasicEntityData> basic_ent_data) {
249 auto *pcomm =
250 ParallelComm::get_pcomm(&basic_ent_data->moab, basic_ent_data->pcommID);
251
252 auto get_owner_proc = [&](auto tag) {
253 if (auto owner_proc = static_cast<int *>(
254 MoFEM::get_tag_ptr(basic_ent_data->moab, tag, ent, NULL))) {
255 return owner_proc[0];
256 } else {
257 return 0;
258 }
259 };
260
261 if (auto pstat_ptr = static_cast<unsigned char *>(MoFEM::get_tag_ptr(
262 basic_ent_data->moab, pcomm->pstatus_tag(), ent, NULL))) {
263 if (!(*pstat_ptr & PSTATUS_NOT_OWNED)) {
264 return pcomm->rank();
265 } else if (*pstat_ptr & PSTATUS_MULTISHARED) {
266 return get_owner_proc(pcomm->sharedps_tag());
267 } else if (*pstat_ptr & PSTATUS_SHARED) {
268 return get_owner_proc(pcomm->sharedp_tag());
269 } else {
270 return 0;
271 }
272 } else {
273 return 0;
274 }
275 }
276
277 inline int getOwnerProc() const {
278 return getOwnerProc(this->ent, this->getBasicDataPtr());
279 }
280
281 static inline int
282 getPartProc(const EntityHandle ent, const Tag th,
283 const boost::shared_ptr<BasicEntityData> &basic_ptr) {
284 if (auto part_ptr = static_cast<int *>(
285 MoFEM::get_tag_ptr(basic_ptr->moab, th, ent, NULL))) {
286 return *part_ptr >= 0 ? *part_ptr : 0;
287 } else
288 return 0;
289 };
290
291 /** \brief Get processor
292 */
293 inline int getPartProc() const {
294 if (PetscUnlikely(getEntType() == MBENTITYSET)) {
295 return getPartProc(ent, this->getBasicDataPtr()->th_MeshsetPart,
296 this->getBasicDataPtr());
297 } else {
298 auto *pcomm = ParallelComm::get_pcomm(&this->getBasicDataPtr()->moab,
299 this->getBasicDataPtr()->pcommID);
300 return getPartProc(ent, pcomm->partition_tag(), this->getBasicDataPtr());
301 }
302 }
303
304 /**
305 * @brief Get pointer to partition tag
306 *
307 * @return int*
308 */
309 inline int *getPartProcPtr() const {
310 if (PetscUnlikely(getEntType() == MBENTITYSET)) {
311 return static_cast<int *>(MoFEM::get_tag_ptr(
312 this->getBasicDataPtr()->moab,
313 this->getBasicDataPtr()->th_MeshsetPart, ent, NULL));
314 } else {
315 auto *pcomm = ParallelComm::get_pcomm(&this->getBasicDataPtr()->moab,
316 this->getBasicDataPtr()->pcommID);
317 return static_cast<int *>(MoFEM::get_tag_ptr(
318 this->getBasicDataPtr()->moab, pcomm->partition_tag(), ent, NULL));
319 }
320 }
321
322 /** \brief get pstatus
323 * This tag stores various aspects of parallel status in bits; see also
324 * define following, to be used in bit mask operations. If an entity is
325 * not shared with any other processors, the pstatus is 0, otherwise it's >
326 * 0
327 *
328 * bit 0: !owned (0=owned, 1=not owned)
329 * bit 1: shared (0=not shared, 1=shared)
330 * bit 2: multishared (shared by > 2 procs; 0=not shared, 1=shared)
331 * bit 3: interface (0=not interface, 1=interface)
332 * bit 4: ghost (0=not ghost, 1=ghost)
333 *
334 */
335 inline unsigned char getPStatus() const {
336 auto *pcomm = ParallelComm::get_pcomm(&this->getBasicDataPtr()->moab,
337 this->getBasicDataPtr()->pcommID);
338 if (auto pstat_ptr = static_cast<unsigned char *>(MoFEM::get_tag_ptr(
339 this->getBasicDataPtr()->moab, pcomm->pstatus_tag(), ent, NULL))) {
340 return *pstat_ptr;
341 } else {
342 return 0;
343 }
344 }
345
346 /** \brief get shared processors
347
348 Returning list to shared processors. Lists end with -1. Returns NULL if not
349 sharing processors.
350
351 DO NOT MODIFY LIST.
352
353 \code
354 BasicEntity *ent_ptr = BasicEntity(moab,entity_handle);
355 for(int proc = 0; proc<MAX_SHARING_PROCS && -1 !=
356 ent_ptr->getSharingProcsPtr[proc]; proc++) {
357 if(ent_ptr->getSharingProcsPtr[proc] == -1) {
358 // End of the list
359 break;
360 }
361 int sharing_proc = ent_ptr->getSharingProcsPtr[proc];
362 EntityHandle sharing_ent = ent_ptr->getSharingHandlersPtr[proc];
363 if(!(ent_ptr->getPStatus()&PSTATUS_MULTISHARED)) {
364 break;
365 }
366 }
367 \endcode
368
369 */
370 int *getSharingProcsPtr() const {
371 auto &moab = this->getBasicDataPtr()->moab;
372 int *sharing_procs_ptr = NULL;
373 ParallelComm *pcomm =
374 ParallelComm::get_pcomm(&moab, this->getBasicDataPtr()->pcommID);
375 if (getPStatus() & PSTATUS_MULTISHARED) {
376 // entity is multi shared
377 rval = moab.tag_get_by_ptr(pcomm->sharedps_tag(), &this->ent, 1,
378 (const void **)&sharing_procs_ptr);
380 } else if (getPStatus() & PSTATUS_SHARED) {
381 // shared
382 rval = moab.tag_get_by_ptr(pcomm->sharedp_tag(), &this->ent, 1,
383 (const void **)&sharing_procs_ptr);
385 }
386 return sharing_procs_ptr;
387 }
388
389 /** \brief get sharid entity handlers
390
391 Returning list to shared entity handlers. Use it with getSharingProcsPtr()
392
393 DO NOT MODIFY LIST.
394
395 \code
396 BasicEntity *ent_ptr = BasicEntity(moab,entity_handle);
397 for(int proc = 0; proc<MAX_SHARING_PROCS && -1 !=
398 ent_ptr->getSharingProcsPtr[proc]; proc++) {
399 if(ent_ptr->getSharingProcsPtr[proc] == -1) {
400 // End of the list
401 break;
402 }
403 int sharing_proc = ent_ptr->getSharingProcsPtr[proc];
404 EntityHandle sharing_ent = ent_ptr->getSharingHandlersPtr[proc];
405 if(!(ent_ptr->getPStatus()&PSTATUS_MULTISHARED)) {
406 break;
407 }
408 }
409 \endcode
410
411 */
413 EntityHandle *sharing_handlers_ptr = NULL;
414 auto &moab = this->getBasicDataPtr()->moab;
415 ParallelComm *pcomm =
416 ParallelComm::get_pcomm(&moab, this->getBasicDataPtr()->pcommID);
417 if (getPStatus() & PSTATUS_MULTISHARED) {
418 // entity is multi shared
419 rval = moab.tag_get_by_ptr(pcomm->sharedhs_tag(), &this->ent, 1,
420 (const void **)&sharing_handlers_ptr);
422 } else if (getPStatus() & PSTATUS_SHARED) {
423 // shared
424 rval = moab.tag_get_by_ptr(pcomm->sharedh_tag(), &this->ent, 1,
425 (const void **)&sharing_handlers_ptr);
427 }
428 return sharing_handlers_ptr;
429 }
430
432 std::vector<EntityHandle> vec_patent_ent);
433
434 static MoFEMErrorCode
436 std::vector<BitRefLevel> &vec_bit_ref_level) {
438 Tag th_ref_bit_level;
439 CHKERR moab.tag_get_handle("_RefBitLevel", th_ref_bit_level);
440 vec_bit_ref_level.resize(ents.size());
441 CHKERR moab.tag_get_data(th_ref_bit_level, ents,
442 &*vec_bit_ref_level.begin());
444 }
445
446 static MoFEMErrorCode
448 std::vector<const BitRefLevel *> &vec_ptr_bit_ref_level) {
450 Tag th_ref_bit_level;
451 CHKERR moab.tag_get_handle("_RefBitLevel", th_ref_bit_level);
452 vec_ptr_bit_ref_level.resize(ents.size());
453 CHKERR moab.tag_get_by_ptr(
454 th_ref_bit_level, ents,
455 reinterpret_cast<const void **>(&*vec_ptr_bit_ref_level.begin()));
457 }
458
459 static MoFEMErrorCode
460 getBitRefLevel(Interface &moab, std::vector<EntityHandle> &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.begin(), ents.size(),
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 */
480 inline EntityHandle *getParentEntPtr() const { return entParentTagPtr; }
481
482 /**
483 * \brief Get pointer to bit ref level tag
484
485 * Every entity belongs to some refinement level or levels. Each level is
486 marked
487 * by bit set in BitRefLevel() (bitset) structure.
488 *
489 * See \ref mix_mesh_refinement for explanation.
490
491 * @return Return pointer to tag.
492 */
494 return static_cast<BitRefLevel *>(
495 get_tag_ptr(this->getBasicDataPtr()->moab,
496 this->getBasicDataPtr()->th_RefBitLevel, this->ent, NULL));
497 }
498
499 /** \brief Get patent entity
500 */
502 return (EntityType)((getParentEnt() & MB_TYPE_MASK) >> MB_ID_WIDTH);
503 }
504
505 /** \brief Get parent entity, i.e. entity form one refinement level up
506 */
507 inline EntityHandle getParentEnt() const { return *(getParentEntPtr()); }
508
509 /** \brief Get entity ref bit refinement signature
510 */
511 inline const BitRefLevel &getBitRefLevel() const {
512 return *getBitRefLevelPtr();
513 }
514
515 /** \brief Get entity ref bit refinement as ulong
516 */
517 inline unsigned long int getBitRefLevelULong() const {
518 return getBitRefLevel().to_ulong();
519 }
520
521 friend std::ostream &operator<<(std::ostream &os, const RefEntityTmp &e);
522
524 static boost::weak_ptr<BasicEntityData> basicDataPtr;
525
526private:
527 friend struct EntFiniteElement;
529
530 /**
531 * @brief Get the pointer to reference element
532 *
533 * @return const boost::shared_ptr<RefElement>
534 */
535 inline const boost::shared_ptr<RefElement> getRefElementPtr() const {
536 if (auto ptr = refElementPtr.lock())
537 return ptr;
538 else
539 return nullptr;
540 }
541
542 static boost::weak_ptr<RefElement> refElementPtr;
543 EntityHandle *entParentTagPtr; ///< Tag ptr to parent entity handle
544};
545
546template <> struct RefEntityTmp<-1> : public RefEntityTmp<0> {
547
548 RefEntityTmp(const boost::shared_ptr<BasicEntityData> &basic_data_ptr,
549 const EntityHandle ent)
550 : RefEntityTmp<0>(basic_data_ptr, ent), basicDataPtr(basic_data_ptr) {}
551
552 RefEntityTmp(const boost::shared_ptr<BasicEntityData> &basic_data_ptr,
553 const EntityHandle ent, EntityHandle *ent_parent_tag_ptr)
554 : RefEntityTmp<0>(basic_data_ptr, ent, ent_parent_tag_ptr),
555 basicDataPtr(basic_data_ptr) {}
556
557 virtual const boost::shared_ptr<BasicEntityData> getBasicDataPtr() const {
558 if (auto ptr = basicDataPtr.lock())
559 return ptr;
560 else
561 return nullptr;
562 }
563
564private:
565 mutable boost::weak_ptr<BasicEntityData> basicDataPtr;
566};
567
569
570/**
571 * \brief interface to RefEntity
572 * \ingroup ent_multi_indices
573 */
574template <typename T> struct interface_RefEntity {
575
576 interface_RefEntity(const boost::shared_ptr<T> &sptr) : sPtr(sptr) {}
577
579 : sPtr(interface.getRefEntityPtr()) {}
580
581 virtual ~interface_RefEntity() = default;
582
583 /**
584 * @copydoc MoFEM::RefEntityTmp<0>::getSideNumber
585 */
586 inline int getSideNumber() const { return this->sPtr->getSideNumber(); }
587
588 /**
589 * @copydoc MoFEM::RefEntityTmp<0>::getSideNumberPtr
590 */
591 inline boost::shared_ptr<SideNumber> getSideNumberPtr() const {
592 return this->sPtr->getSideNumberPtr();
593 }
594
595 /**
596 * @copydoc MoFEM::RefEntityTmp<0>::getBasicDataPtr
597 */
598 inline const boost::shared_ptr<BasicEntityData> getBasicDataPtr() const {
599 return this->sPtr->getBasicDataPtr();
600 }
601
602 /**
603 * @copydoc MoFEM::RefEntityTmp<0>::getEnt
604 */
605 inline EntityHandle getEnt() const { return this->sPtr->getEnt(); }
606
607 /**
608 * @copydoc MoFEM::RefEntityTmp<0>::getParentEntType
609 */
611 return this->sPtr->getParentEntType();
612 };
613
614 /**
615 * @copydoc MoFEM::RefEntityTmp<0>::getParentEnt
616 */
617 inline EntityHandle getParentEnt() const {
618 return this->sPtr->getParentEnt();
619 }
620
621 /**
622 * @copydoc MoFEM::RefEntityTmp<0>::getBitRefLevelPtr
623 */
625 return this->sPtr->getBitRefLevelPtr();
626 }
627
628 /**
629 * @copydoc MoFEM::RefEntityTmp<0>::getBitRefLevel
630 */
631 inline const BitRefLevel &getBitRefLevel() const {
632 return this->sPtr->getBitRefLevel();
633 }
634
635 /**
636 * @copydoc MoFEM::RefEntityTmp<0>::getBitRefLevelULong
637 */
638 inline unsigned long int getBitRefLevelULong() const {
639 return this->sPtr->getBitRefLevelULong();
640 }
641
642 /**
643 * @copydoc MoFEM::RefEntityTmp<0>::getEntType
644 */
645 inline EntityType getEntType() const { return this->sPtr->getEntType(); };
646
647 /**
648 * @copydoc MoFEM::RefEntityTmp<0>::getEntDimension
649 */
650 inline int getEntDimension() const { return this->sPtr->getEntDimension(); }
651
652 /**
653 * @copydoc MoFEM::RefEntityTmp<0>::getEntTypeName
654 */
655 inline const char *getEntTypeName() const {
656 return this->sPtr->getEntTypeName();
657 }
658
659 /**
660 * @copydoc MoFEM::RefEntityTmp<0>::getEntId
661 */
662 inline EntityID getEntId() const { return this->sPtr->getEntId(); };
663
664 /**
665 * @copydoc MoFEM::RefEntityTmp<0>::getOwnerEnt
666 */
667 inline EntityHandle getOwnerEnt() const { return this->sPtr->getOwnerEnt(); }
668
669 /**
670 * @copydoc MoFEM::RefEntityTmp<0>::getOwnerEnt
671 */
672 inline EntityHandle &getOwnerEnt() { return this->sPtr->getOwnerEnt(); }
673
674 /**
675 * @copydoc MoFEM::RefEntityTmp<0>::getOwnerProc
676 */
677 inline int getOwnerProc() const { return this->sPtr->getOwnerProc(); }
678
679 /**
680 * @copydoc MoFEM::RefEntityTmp<0>::getPartProc
681 */
682 inline int getPartProc() const { return this->sPtr->getPartProc(); }
683
684 /**
685 * @copydoc MoFEM::RefEntityTmp<0>::getPartProcPtr
686 */
687 inline int *getPartProcPtr() const { return this->sPtr->getPartProcPtr(); }
688
689 /**
690 * @copydoc MoFEM::RefEntityTmp<0>::getPartProc
691 */
692 inline unsigned char getPStatus() const { return this->sPtr->getPStatus(); }
693
694 /**
695 * @copydoc MoFEM::RefEntityTmp<0>::getSharingProcsPtr
696 */
697 inline int *getSharingProcsPtr() const {
698 return this->sPtr->getSharingProcsPtr();
699 }
700
701 /**
702 * @copydoc MoFEM::RefEntityTmp<0>::getSharingHandlersPtr
703 */
705 return this->sPtr->getSharingHandlersPtr();
706 }
707
708 /**
709 * @copydoc MoFEM::RefEntityTmp<0>::getRefEntityPtr
710 */
711 inline boost::shared_ptr<T> &getRefEntityPtr() const { return this->sPtr; }
712
713 mutable boost::shared_ptr<T> sPtr;
714};
715
716/**
717 * \typedef RefEntity_multiIndex
718 * type multiIndex container for RefEntity
719 * \ingroup ent_multi_indices
720 *
721 * \param hashed_unique Ent_mi_tag
722 * \param ordered_non_unique Ent_Ent_mi_tag
723 * \param ordered_non_unique Composite_EntType_And_ParentEntType_mi_tag
724 * \param ordered_non_unique Composite_ParentEnt_And_EntType_mi_tag
725 */
726using RefEntity_multiIndex = multi_index_container<
727 boost::shared_ptr<RefEntity>,
728 indexed_by<ordered_unique<
729
730 tag<Ent_mi_tag>,
731 const_mem_fun<RefEntity, EntityHandle, &RefEntity::getEnt>
732
733 >,
734
735 ordered_non_unique<
736
737 tag<Ent_Ent_mi_tag>, const_mem_fun<RefEntity, EntityHandle,
739
740 >,
741
742 ordered_non_unique<
743 tag<Composite_EntType_and_ParentEntType_mi_tag>,
744 composite_key<RefEntity,
745 const_mem_fun<RefEntity, EntityType,
747 const_mem_fun<RefEntity, EntityType,
749
750 >,
751
752 ordered_non_unique<
753 tag<Composite_ParentEnt_And_EntType_mi_tag>,
754 composite_key<RefEntity,
755 const_mem_fun<RefEntity, EntityType,
757 const_mem_fun<RefEntity, EntityHandle,
759
760 >>
761
762 >;
763
764/** \brief multi-index view of RefEntity by parent entity
765\ingroup ent_multi_indices
766*/
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
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
807this.
808
809Known 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);
821 }
822};
823
824/** \brief ref mofem entity, left shift
825 * \ingroup ent_multi_indices
826 */
828 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 **/
#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
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: Common.hpp:10
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.
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
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)
static MoFEMErrorCode getBitRefLevel(Interface &moab, std::vector< EntityHandle > &ents, std::vector< const BitRefLevel * > &vec_ptr_bit_ref_level)
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
const char * getEntTypeName() const
interface_RefEntity(const interface_RefEntity< T > &interface)
EntityHandle * getSharingHandlersPtr() const
EntityHandle getParentEnt() const
EntityHandle getOwnerEnt() const
const boost::shared_ptr< BasicEntityData > getBasicDataPtr() const
boost::shared_ptr< SideNumber > getSideNumberPtr() const
boost::shared_ptr< T > & getRefEntityPtr() const
unsigned char getPStatus() const
BitRefLevel * getBitRefLevelPtr() const
unsigned long int getBitRefLevelULong() const
interface_RefEntity(const boost::shared_ptr< T > &sptr)