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 /**
460 * \brief Get pointer to parent entity tag.
461 *
462 * Each refined entity has his parent. Such information is stored on tags.
463 * This function get pinter to tag.
464 *
465 * @return Pointer to tag on entity
466 */
467 inline EntityHandle *getParentEntPtr() const { return entParentTagPtr; }
468
469 /**
470 * \brief Get pointer to bit ref level tag
471
472 * Every entity belongs to some refinement level or levels. Each level is
473 marked
474 * by bit set in BitRefLevel() (bitset) structure.
475 *
476 * See \ref mix_mesh_refinement for explanation.
477
478 * @return Return pointer to tag.
479 */
481 return static_cast<BitRefLevel *>(
482 get_tag_ptr(this->getBasicDataPtr()->moab,
483 this->getBasicDataPtr()->th_RefBitLevel, this->ent, NULL));
484 }
485
486 /** \brief Get patent entity
487 */
489 return (EntityType)((getParentEnt() & MB_TYPE_MASK) >> MB_ID_WIDTH);
490 }
491
492 /** \brief Get parent entity, i.e. entity form one refinement level up
493 */
494 inline EntityHandle getParentEnt() const { return *(getParentEntPtr()); }
495
496 /** \brief Get entity ref bit refinement signature
497 */
498 inline const BitRefLevel &getBitRefLevel() const {
499 return *getBitRefLevelPtr();
500 }
501
502 /** \brief Get entity ref bit refinement as ulong
503 */
504 inline unsigned long int getBitRefLevelULong() const {
505 return getBitRefLevel().to_ulong();
506 }
507
508 friend std::ostream &operator<<(std::ostream &os, const RefEntityTmp &e);
509
511 static boost::weak_ptr<BasicEntityData> basicDataPtr;
512
513private:
514 friend struct EntFiniteElement;
516
517 /**
518 * @brief Get the pointer to reference element
519 *
520 * @return const boost::shared_ptr<RefElement>
521 */
522 inline const boost::shared_ptr<RefElement> getRefElementPtr() const {
523 if (auto ptr = refElementPtr.lock())
524 return ptr;
525 else
526 return nullptr;
527 }
528
529 static boost::weak_ptr<RefElement> refElementPtr;
530 EntityHandle *entParentTagPtr; ///< Tag ptr to parent entity handle
531};
532
533template <> struct RefEntityTmp<-1> : public RefEntityTmp<0> {
534
535 RefEntityTmp(const boost::shared_ptr<BasicEntityData> &basic_data_ptr,
536 const EntityHandle ent)
537 : RefEntityTmp<0>(basic_data_ptr, ent), basicDataPtr(basic_data_ptr) {}
538
539 RefEntityTmp(const boost::shared_ptr<BasicEntityData> &basic_data_ptr,
540 const EntityHandle ent, EntityHandle *ent_parent_tag_ptr)
541 : RefEntityTmp<0>(basic_data_ptr, ent, ent_parent_tag_ptr),
542 basicDataPtr(basic_data_ptr) {}
543
544 virtual const boost::shared_ptr<BasicEntityData> getBasicDataPtr() const {
545 if (auto ptr = basicDataPtr.lock())
546 return ptr;
547 else
548 return nullptr;
549 }
550
551private:
552 mutable boost::weak_ptr<BasicEntityData> basicDataPtr;
553};
554
556
557/**
558 * \brief interface to RefEntity
559 * \ingroup ent_multi_indices
560 */
561template <typename T> struct interface_RefEntity {
562
563 interface_RefEntity(const boost::shared_ptr<T> &sptr) : sPtr(sptr) {}
564
566 : sPtr(interface.getRefEntityPtr()) {}
567
568 virtual ~interface_RefEntity() = default;
569
570 /**
571 * @copydoc MoFEM::RefEntityTmp<0>::getSideNumber
572 */
573 inline int getSideNumber() const { return this->sPtr->getSideNumber(); }
574
575 /**
576 * @copydoc MoFEM::RefEntityTmp<0>::getSideNumberPtr
577 */
578 inline boost::shared_ptr<SideNumber> getSideNumberPtr() const {
579 return this->sPtr->getSideNumberPtr();
580 }
581
582 /**
583 * @copydoc MoFEM::RefEntityTmp<0>::getBasicDataPtr
584 */
585 inline const boost::shared_ptr<BasicEntityData> getBasicDataPtr() const {
586 return this->sPtr->getBasicDataPtr();
587 }
588
589 /**
590 * @copydoc MoFEM::RefEntityTmp<0>::getEnt
591 */
592 inline EntityHandle getEnt() const { return this->sPtr->getEnt(); }
593
594 /**
595 * @copydoc MoFEM::RefEntityTmp<0>::getParentEntType
596 */
598 return this->sPtr->getParentEntType();
599 };
600
601 /**
602 * @copydoc MoFEM::RefEntityTmp<0>::getParentEnt
603 */
604 inline EntityHandle getParentEnt() const {
605 return this->sPtr->getParentEnt();
606 }
607
608 /**
609 * @copydoc MoFEM::RefEntityTmp<0>::getBitRefLevelPtr
610 */
612 return this->sPtr->getBitRefLevelPtr();
613 }
614
615 /**
616 * @copydoc MoFEM::RefEntityTmp<0>::getBitRefLevel
617 */
618 inline const BitRefLevel &getBitRefLevel() const {
619 return this->sPtr->getBitRefLevel();
620 }
621
622 /**
623 * @copydoc MoFEM::RefEntityTmp<0>::getBitRefLevelULong
624 */
625 inline unsigned long int getBitRefLevelULong() const {
626 return this->sPtr->getBitRefLevelULong();
627 }
628
629 /**
630 * @copydoc MoFEM::RefEntityTmp<0>::getEntType
631 */
632 inline EntityType getEntType() const { return this->sPtr->getEntType(); };
633
634 /**
635 * @copydoc MoFEM::RefEntityTmp<0>::getEntDimension
636 */
637 inline int getEntDimension() const { return this->sPtr->getEntDimension(); }
638
639 /**
640 * @copydoc MoFEM::RefEntityTmp<0>::getEntTypeName
641 */
642 inline const char *getEntTypeName() const {
643 return this->sPtr->getEntTypeName();
644 }
645
646 /**
647 * @copydoc MoFEM::RefEntityTmp<0>::getEntId
648 */
649 inline EntityID getEntId() const { return this->sPtr->getEntId(); };
650
651 /**
652 * @copydoc MoFEM::RefEntityTmp<0>::getOwnerEnt
653 */
654 inline EntityHandle getOwnerEnt() const { return this->sPtr->getOwnerEnt(); }
655
656 /**
657 * @copydoc MoFEM::RefEntityTmp<0>::getOwnerEnt
658 */
659 inline EntityHandle &getOwnerEnt() { return this->sPtr->getOwnerEnt(); }
660
661 /**
662 * @copydoc MoFEM::RefEntityTmp<0>::getOwnerProc
663 */
664 inline int getOwnerProc() const { return this->sPtr->getOwnerProc(); }
665
666 /**
667 * @copydoc MoFEM::RefEntityTmp<0>::getPartProc
668 */
669 inline int getPartProc() const { return this->sPtr->getPartProc(); }
670
671 /**
672 * @copydoc MoFEM::RefEntityTmp<0>::getPartProcPtr
673 */
674 inline int *getPartProcPtr() const { return this->sPtr->getPartProcPtr(); }
675
676 /**
677 * @copydoc MoFEM::RefEntityTmp<0>::getPartProc
678 */
679 inline unsigned char getPStatus() const { return this->sPtr->getPStatus(); }
680
681 /**
682 * @copydoc MoFEM::RefEntityTmp<0>::getSharingProcsPtr
683 */
684 inline int *getSharingProcsPtr() const {
685 return this->sPtr->getSharingProcsPtr();
686 }
687
688 /**
689 * @copydoc MoFEM::RefEntityTmp<0>::getSharingHandlersPtr
690 */
692 return this->sPtr->getSharingHandlersPtr();
693 }
694
695 /**
696 * @copydoc MoFEM::RefEntityTmp<0>::getRefEntityPtr
697 */
698 inline boost::shared_ptr<T> &getRefEntityPtr() const { return this->sPtr; }
699
700 mutable boost::shared_ptr<T> sPtr;
701};
702
703/**
704 * \typedef RefEntity_multiIndex
705 * type multiIndex container for RefEntity
706 * \ingroup ent_multi_indices
707 *
708 * \param hashed_unique Ent_mi_tag
709 * \param ordered_non_unique Ent_Ent_mi_tag
710 * \param ordered_non_unique Composite_EntType_And_ParentEntType_mi_tag
711 * \param ordered_non_unique Composite_ParentEnt_And_EntType_mi_tag
712 */
713using RefEntity_multiIndex = multi_index_container<
714 boost::shared_ptr<RefEntity>,
715 indexed_by<ordered_unique<
716
717 tag<Ent_mi_tag>,
718 const_mem_fun<RefEntity, EntityHandle, &RefEntity::getEnt>
719
720 >,
721
722 ordered_non_unique<
723
724 tag<Ent_Ent_mi_tag>, const_mem_fun<RefEntity, EntityHandle,
726
727 >,
728
729 ordered_non_unique<
730 tag<Composite_EntType_and_ParentEntType_mi_tag>,
731 composite_key<RefEntity,
732 const_mem_fun<RefEntity, EntityType,
734 const_mem_fun<RefEntity, EntityType,
736
737 >,
738
739 ordered_non_unique<
740 tag<Composite_ParentEnt_And_EntType_mi_tag>,
741 composite_key<RefEntity,
742 const_mem_fun<RefEntity, EntityType,
744 const_mem_fun<RefEntity, EntityHandle,
746
747 >>
748
749 >;
750
751/** \brief multi-index view of RefEntity by parent entity
752\ingroup ent_multi_indices
753*/
755 boost::shared_ptr<RefEntity>,
756 indexed_by<
757 hashed_non_unique<
758 const_mem_fun<RefEntity, EntityHandle, &RefEntity::getParentEnt>>,
759 hashed_unique<tag<Composite_EntType_and_ParentEntType_mi_tag>,
760 composite_key<boost::shared_ptr<RefEntity>,
761 const_mem_fun<RefEntity, EntityHandle,
763 const_mem_fun<RefEntity, EntityHandle,
765
766 >;
767
769 multi_index_container<
770 boost::shared_ptr<RefEntity>,
771 indexed_by<ordered_non_unique<const_mem_fun<RefEntity, EntityHandle,
773 hashed_unique<
774 tag<Composite_EntType_and_ParentEntType_mi_tag>,
775 composite_key<boost::shared_ptr<RefEntity>,
776 const_mem_fun<RefEntity, EntityHandle,
778 const_mem_fun<RefEntity, EntityHandle,
780
781 >;
782
784 boost::shared_ptr<RefEntity>,
785 indexed_by<
786 sequenced<>,
787 ordered_unique<tag<Ent_mi_tag>, const_mem_fun<RefEntity, EntityHandle,
789
790/** \brief change parent
791* \ingroup ent_multi_indices
792*
793* Use this function with care. Some other multi-indices can deponent on
794this.
795
796Known dependent multi-indices (verify if that list is full):
797- RefEntity_multiIndex
798- RefElement_multiIndex
799
800*/
804 inline void operator()(boost::shared_ptr<RefEntity> &e) {
805 rval = e->getBasicDataPtr()->moab.tag_set_data(
806 e->getBasicDataPtr()->th_RefParentHandle, &e->ent, 1, &pArent);
808 }
809};
810
811/** \brief ref mofem entity, left shift
812 * \ingroup ent_multi_indices
813 */
815 int shift;
818 const BitRefLevel _mask = BitRefLevel().set())
819 : shift(_shift), mask(_mask) {}
820 inline void operator()(boost::shared_ptr<RefEntity> &e) {
821 BitRefLevel bit = *(e->getBitRefLevelPtr());
822 (*e->getBitRefLevelPtr()) = ((bit & mask) << shift) | (bit & ~mask);
823 };
824};
825
826/** \brief ref mofem entity, right shift
827 * \ingroup ent_multi_indices
828 */
830 int shift;
833 const BitRefLevel _mask = BitRefLevel().set())
834 : shift(_shift), mask(_mask) {}
835 inline void operator()(boost::shared_ptr<RefEntity> &e) {
836 BitRefLevel bit = *(e->getBitRefLevelPtr());
837 *(e->getBitRefLevelPtr()) = ((bit & mask) >> shift) | (bit & ~mask);
838 };
839};
840} // namespace MoFEM
841
842#endif // __REF_ENTSMULTIINDICES_HPP__
843
844/**
845 * \defgroup ent_multi_indices Entities structures and multi-indices
846 * \ingroup mofem
847 **/
#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)
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)