v0.14.0
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 type_from_handle(this->ent);
183 }
184
185 /**
186 * @brief Get the Ent Dimension
187 *
188 * @return int
189 */
190 inline int getEntDimension() const {
191 return dimension_from_handle(this->ent);
192 }
193
194 /**
195 * @brief Get the Ent Type Name
196 *
197 * @return const char*
198 */
199 inline const char *getEntTypeName() const {
200 return type_name_from_handle(this->ent);
201 }
202
203 /** \brief get entity id
204 */
205 inline EntityID getEntId() const { return id_from_handle(this->ent); }
206
207 static inline EntityHandle
209 boost::shared_ptr<BasicEntityData> basic_ent_data) {
210 auto *pcomm =
211 ParallelComm::get_pcomm(&basic_ent_data->moab, basic_ent_data->pcommID);
212
213 auto get_owner_ent = [&](auto tag) {
214 if (auto owner_ent_ptr = static_cast<EntityHandle *>(
215 MoFEM::get_tag_ptr(basic_ent_data->moab, tag, ent, NULL))) {
216 return owner_ent_ptr[0];
217 } else {
218 return ent;
219 }
220 };
221
222 if (auto pstat_ptr = static_cast<unsigned char *>(MoFEM::get_tag_ptr(
223 basic_ent_data->moab, pcomm->pstatus_tag(), ent, NULL))) {
224 if (!(*pstat_ptr & PSTATUS_NOT_OWNED)) {
225 return ent;
226 } else if (*pstat_ptr & PSTATUS_MULTISHARED) {
227 return get_owner_ent(pcomm->sharedhs_tag());
228 } else if (*pstat_ptr & PSTATUS_SHARED) {
229 return get_owner_ent(pcomm->sharedh_tag());
230 } else {
231 return ent;
232 }
233 } else {
234 return ent;
235 }
236 }
237
238 /** \brief Owner handle on this or other processors
239 */
240 inline EntityHandle getOwnerEnt() const {
241 return getOwnerEnt(this->ent, this->getBasicDataPtr());
242 }
243
244 static inline int
246 boost::shared_ptr<BasicEntityData> basic_ent_data) {
247 auto *pcomm =
248 ParallelComm::get_pcomm(&basic_ent_data->moab, basic_ent_data->pcommID);
249
250 auto get_owner_proc = [&](auto tag) {
251 if (auto owner_proc = static_cast<int *>(
252 MoFEM::get_tag_ptr(basic_ent_data->moab, tag, ent, NULL))) {
253 return owner_proc[0];
254 } else {
255 return 0;
256 }
257 };
258
259 if (auto pstat_ptr = static_cast<unsigned char *>(MoFEM::get_tag_ptr(
260 basic_ent_data->moab, pcomm->pstatus_tag(), ent, NULL))) {
261 if (!(*pstat_ptr & PSTATUS_NOT_OWNED)) {
262 return pcomm->rank();
263 } else if (*pstat_ptr & PSTATUS_MULTISHARED) {
264 return get_owner_proc(pcomm->sharedps_tag());
265 } else if (*pstat_ptr & PSTATUS_SHARED) {
266 return get_owner_proc(pcomm->sharedp_tag());
267 } else {
268 return 0;
269 }
270 } else {
271 return 0;
272 }
273 }
274
275 inline int getOwnerProc() const {
276 return getOwnerProc(this->ent, this->getBasicDataPtr());
277 }
278
279 static inline int
280 getPartProc(const EntityHandle ent, const Tag th,
281 const boost::shared_ptr<BasicEntityData> &basic_ptr) {
282 if (auto part_ptr = static_cast<int *>(
283 MoFEM::get_tag_ptr(basic_ptr->moab, th, ent, NULL))) {
284 return *part_ptr >= 0 ? *part_ptr : 0;
285 } else
286 return 0;
287 };
288
289 /** \brief Get processor
290 */
291 inline int getPartProc() const {
292 if (PetscUnlikely(getEntType() == MBENTITYSET)) {
293 return getPartProc(ent, this->getBasicDataPtr()->th_MeshsetPart,
294 this->getBasicDataPtr());
295 } else {
296 auto *pcomm = ParallelComm::get_pcomm(&this->getBasicDataPtr()->moab,
297 this->getBasicDataPtr()->pcommID);
298 return getPartProc(ent, pcomm->partition_tag(), this->getBasicDataPtr());
299 }
300 }
301
302 /**
303 * @brief Get pointer to partition tag
304 *
305 * @return int*
306 */
307 inline int *getPartProcPtr() const {
308 if (PetscUnlikely(getEntType() == MBENTITYSET)) {
309 return static_cast<int *>(MoFEM::get_tag_ptr(
310 this->getBasicDataPtr()->moab,
311 this->getBasicDataPtr()->th_MeshsetPart, ent, NULL));
312 } else {
313 auto *pcomm = ParallelComm::get_pcomm(&this->getBasicDataPtr()->moab,
314 this->getBasicDataPtr()->pcommID);
315 return static_cast<int *>(MoFEM::get_tag_ptr(
316 this->getBasicDataPtr()->moab, pcomm->partition_tag(), ent, NULL));
317 }
318 }
319
320 /** \brief get pstatus
321 * This tag stores various aspects of parallel status in bits; see also
322 * define following, to be used in bit mask operations. If an entity is
323 * not shared with any other processors, the pstatus is 0, otherwise it's >
324 * 0
325 *
326 * bit 0: !owned (0=owned, 1=not owned)
327 * bit 1: shared (0=not shared, 1=shared)
328 * bit 2: multishared (shared by > 2 procs; 0=not shared, 1=shared)
329 * bit 3: interface (0=not interface, 1=interface)
330 * bit 4: ghost (0=not ghost, 1=ghost)
331 *
332 */
333 inline unsigned char getPStatus() const {
334 auto *pcomm = ParallelComm::get_pcomm(&this->getBasicDataPtr()->moab,
335 this->getBasicDataPtr()->pcommID);
336 if (auto pstat_ptr = static_cast<unsigned char *>(MoFEM::get_tag_ptr(
337 this->getBasicDataPtr()->moab, pcomm->pstatus_tag(), ent, NULL))) {
338 return *pstat_ptr;
339 } else {
340 return 0;
341 }
342 }
343
344 /** \brief get shared processors
345
346 Returning list to shared processors. Lists end with -1. Returns NULL if not
347 sharing processors.
348
349 DO NOT MODIFY LIST.
350
351 \code
352 BasicEntity *ent_ptr = BasicEntity(moab,entity_handle);
353 for(int proc = 0; proc<MAX_SHARING_PROCS && -1 !=
354 ent_ptr->getSharingProcsPtr[proc]; proc++) {
355 if(ent_ptr->getSharingProcsPtr[proc] == -1) {
356 // End of the list
357 break;
358 }
359 int sharing_proc = ent_ptr->getSharingProcsPtr[proc];
360 EntityHandle sharing_ent = ent_ptr->getSharingHandlersPtr[proc];
361 if(!(ent_ptr->getPStatus()&PSTATUS_MULTISHARED)) {
362 break;
363 }
364 }
365 \endcode
366
367 */
368 int *getSharingProcsPtr() const {
369 auto &moab = this->getBasicDataPtr()->moab;
370 int *sharing_procs_ptr = NULL;
371 ParallelComm *pcomm =
372 ParallelComm::get_pcomm(&moab, this->getBasicDataPtr()->pcommID);
373 if (getPStatus() & PSTATUS_MULTISHARED) {
374 // entity is multi shared
375 rval = moab.tag_get_by_ptr(pcomm->sharedps_tag(), &this->ent, 1,
376 (const void **)&sharing_procs_ptr);
378 } else if (getPStatus() & PSTATUS_SHARED) {
379 // shared
380 rval = moab.tag_get_by_ptr(pcomm->sharedp_tag(), &this->ent, 1,
381 (const void **)&sharing_procs_ptr);
383 }
384 return sharing_procs_ptr;
385 }
386
387 /** \brief get sharid entity handlers
388
389 Returning list to shared entity handlers. Use it with getSharingProcsPtr()
390
391 DO NOT MODIFY LIST.
392
393 \code
394 BasicEntity *ent_ptr = BasicEntity(moab,entity_handle);
395 for(int proc = 0; proc<MAX_SHARING_PROCS && -1 !=
396 ent_ptr->getSharingProcsPtr[proc]; proc++) {
397 if(ent_ptr->getSharingProcsPtr[proc] == -1) {
398 // End of the list
399 break;
400 }
401 int sharing_proc = ent_ptr->getSharingProcsPtr[proc];
402 EntityHandle sharing_ent = ent_ptr->getSharingHandlersPtr[proc];
403 if(!(ent_ptr->getPStatus()&PSTATUS_MULTISHARED)) {
404 break;
405 }
406 }
407 \endcode
408
409 */
411 EntityHandle *sharing_handlers_ptr = NULL;
412 auto &moab = this->getBasicDataPtr()->moab;
413 ParallelComm *pcomm =
414 ParallelComm::get_pcomm(&moab, this->getBasicDataPtr()->pcommID);
415 if (getPStatus() & PSTATUS_MULTISHARED) {
416 // entity is multi shared
417 rval = moab.tag_get_by_ptr(pcomm->sharedhs_tag(), &this->ent, 1,
418 (const void **)&sharing_handlers_ptr);
420 } else if (getPStatus() & PSTATUS_SHARED) {
421 // shared
422 rval = moab.tag_get_by_ptr(pcomm->sharedh_tag(), &this->ent, 1,
423 (const void **)&sharing_handlers_ptr);
425 }
426 return sharing_handlers_ptr;
427 }
428
430 std::vector<EntityHandle> vec_patent_ent);
431
432 static MoFEMErrorCode
434 std::vector<BitRefLevel> &vec_bit_ref_level) {
436 Tag th_ref_bit_level;
437 CHKERR moab.tag_get_handle("_RefBitLevel", th_ref_bit_level);
438 vec_bit_ref_level.resize(ents.size());
439 CHKERR moab.tag_get_data(th_ref_bit_level, ents,
440 &*vec_bit_ref_level.begin());
442 }
443
444 static MoFEMErrorCode
446 std::vector<const BitRefLevel *> &vec_ptr_bit_ref_level) {
448 Tag th_ref_bit_level;
449 CHKERR moab.tag_get_handle("_RefBitLevel", th_ref_bit_level);
450 vec_ptr_bit_ref_level.resize(ents.size());
451 CHKERR moab.tag_get_by_ptr(
452 th_ref_bit_level, ents,
453 reinterpret_cast<const void **>(&*vec_ptr_bit_ref_level.begin()));
455 }
456
457 static MoFEMErrorCode
458 getBitRefLevel(Interface &moab, std::vector<EntityHandle> &ents,
459 std::vector<const BitRefLevel *> &vec_ptr_bit_ref_level) {
461 Tag th_ref_bit_level;
462 CHKERR moab.tag_get_handle("_RefBitLevel", th_ref_bit_level);
463 vec_ptr_bit_ref_level.resize(ents.size());
464 CHKERR moab.tag_get_by_ptr(
465 th_ref_bit_level, &*ents.begin(), ents.size(),
466 reinterpret_cast<const void **>(&*vec_ptr_bit_ref_level.begin()));
468 }
469
470 /**
471 * \brief Get pointer to parent entity tag.
472 *
473 * Each refined entity has his parent. Such information is stored on tags.
474 * This function get pinter to tag.
475 *
476 * @return Pointer to tag on entity
477 */
478 inline EntityHandle *getParentEntPtr() const { return entParentTagPtr; }
479
480 /**
481 * \brief Get pointer to bit ref level tag
482
483 * Every entity belongs to some refinement level or levels. Each level is
484 marked
485 * by bit set in BitRefLevel() (bitset) structure.
486 *
487 * See \ref mix_mesh_refinement for explanation.
488
489 * @return Return pointer to tag.
490 */
492 return static_cast<BitRefLevel *>(
493 get_tag_ptr(this->getBasicDataPtr()->moab,
494 this->getBasicDataPtr()->th_RefBitLevel, this->ent, NULL));
495 }
496
497 /** \brief Get patent entity
498 */
500 return (EntityType)((getParentEnt() & MB_TYPE_MASK) >> MB_ID_WIDTH);
501 }
502
503 /** \brief Get parent entity, i.e. entity form one refinement level up
504 */
505 inline EntityHandle getParentEnt() const { return *(getParentEntPtr()); }
506
507 /** \brief Get entity ref bit refinement signature
508 */
509 inline const BitRefLevel &getBitRefLevel() const {
510 return *getBitRefLevelPtr();
511 }
512
513 /** \brief Get entity ref bit refinement as ulong
514 */
515 inline unsigned long int getBitRefLevelULong() const {
516 return getBitRefLevel().to_ulong();
517 }
518
519 friend std::ostream &operator<<(std::ostream &os, const RefEntityTmp &e);
520
522 static boost::weak_ptr<BasicEntityData> basicDataPtr;
523
524private:
525 friend struct EntFiniteElement;
527
528 /**
529 * @brief Get the pointer to reference element
530 *
531 * @return const boost::shared_ptr<RefElement>
532 */
533 inline const boost::shared_ptr<RefElement> getRefElementPtr() const {
534 if (auto ptr = refElementPtr.lock())
535 return ptr;
536 else
537 return nullptr;
538 }
539
540 static boost::weak_ptr<RefElement> refElementPtr;
541 EntityHandle *entParentTagPtr; ///< Tag ptr to parent entity handle
542};
543
544template <> struct RefEntityTmp<-1> : public RefEntityTmp<0> {
545
546 RefEntityTmp(const boost::shared_ptr<BasicEntityData> &basic_data_ptr,
547 const EntityHandle ent)
548 : RefEntityTmp<0>(basic_data_ptr, ent), basicDataPtr(basic_data_ptr) {}
549
550 RefEntityTmp(const boost::shared_ptr<BasicEntityData> &basic_data_ptr,
551 const EntityHandle ent, EntityHandle *ent_parent_tag_ptr)
552 : RefEntityTmp<0>(basic_data_ptr, ent, ent_parent_tag_ptr),
553 basicDataPtr(basic_data_ptr) {}
554
555 virtual const boost::shared_ptr<BasicEntityData> getBasicDataPtr() const {
556 if (auto ptr = basicDataPtr.lock())
557 return ptr;
558 else
559 return nullptr;
560 }
561
562private:
563 mutable boost::weak_ptr<BasicEntityData> basicDataPtr;
564};
565
567
568/**
569 * \brief interface to RefEntity
570 * \ingroup ent_multi_indices
571 */
572template <typename T> struct interface_RefEntity {
573
574 interface_RefEntity(const boost::shared_ptr<T> &sptr) : sPtr(sptr) {}
575
577 : sPtr(interface.getRefEntityPtr()) {}
578
579 virtual ~interface_RefEntity() = default;
580
581 /**
582 * @copydoc MoFEM::RefEntityTmp<0>::getSideNumber
583 */
584 inline int getSideNumber() const { return this->sPtr->getSideNumber(); }
585
586 /**
587 * @copydoc MoFEM::RefEntityTmp<0>::getSideNumberPtr
588 */
589 inline boost::shared_ptr<SideNumber> getSideNumberPtr() const {
590 return this->sPtr->getSideNumberPtr();
591 }
592
593 /**
594 * @copydoc MoFEM::RefEntityTmp<0>::getBasicDataPtr
595 */
596 inline const boost::shared_ptr<BasicEntityData> getBasicDataPtr() const {
597 return this->sPtr->getBasicDataPtr();
598 }
599
600 /**
601 * @copydoc MoFEM::RefEntityTmp<0>::getEnt
602 */
603 inline EntityHandle getEnt() const { return this->sPtr->getEnt(); }
604
605 /**
606 * @copydoc MoFEM::RefEntityTmp<0>::getParentEntType
607 */
609 return this->sPtr->getParentEntType();
610 };
611
612 /**
613 * @copydoc MoFEM::RefEntityTmp<0>::getParentEnt
614 */
615 inline EntityHandle getParentEnt() const {
616 return this->sPtr->getParentEnt();
617 }
618
619 /**
620 * @copydoc MoFEM::RefEntityTmp<0>::getBitRefLevelPtr
621 */
623 return this->sPtr->getBitRefLevelPtr();
624 }
625
626 /**
627 * @copydoc MoFEM::RefEntityTmp<0>::getBitRefLevel
628 */
629 inline const BitRefLevel &getBitRefLevel() const {
630 return this->sPtr->getBitRefLevel();
631 }
632
633 /**
634 * @copydoc MoFEM::RefEntityTmp<0>::getBitRefLevelULong
635 */
636 inline unsigned long int getBitRefLevelULong() const {
637 return this->sPtr->getBitRefLevelULong();
638 }
639
640 /**
641 * @copydoc MoFEM::RefEntityTmp<0>::getEntType
642 */
643 inline EntityType getEntType() const { return this->sPtr->getEntType(); };
644
645 /**
646 * @copydoc MoFEM::RefEntityTmp<0>::getEntDimension
647 */
648 inline int getEntDimension() const { return this->sPtr->getEntDimension(); }
649
650 /**
651 * @copydoc MoFEM::RefEntityTmp<0>::getEntTypeName
652 */
653 inline const char *getEntTypeName() const {
654 return this->sPtr->getEntTypeName();
655 }
656
657 /**
658 * @copydoc MoFEM::RefEntityTmp<0>::getEntId
659 */
660 inline EntityID getEntId() const { return this->sPtr->getEntId(); };
661
662 /**
663 * @copydoc MoFEM::RefEntityTmp<0>::getOwnerEnt
664 */
665 inline EntityHandle getOwnerEnt() const { return this->sPtr->getOwnerEnt(); }
666
667 /**
668 * @copydoc MoFEM::RefEntityTmp<0>::getOwnerEnt
669 */
670 inline EntityHandle &getOwnerEnt() { return this->sPtr->getOwnerEnt(); }
671
672 /**
673 * @copydoc MoFEM::RefEntityTmp<0>::getOwnerProc
674 */
675 inline int getOwnerProc() const { return this->sPtr->getOwnerProc(); }
676
677 /**
678 * @copydoc MoFEM::RefEntityTmp<0>::getPartProc
679 */
680 inline int getPartProc() const { return this->sPtr->getPartProc(); }
681
682 /**
683 * @copydoc MoFEM::RefEntityTmp<0>::getPartProcPtr
684 */
685 inline int *getPartProcPtr() const { return this->sPtr->getPartProcPtr(); }
686
687 /**
688 * @copydoc MoFEM::RefEntityTmp<0>::getPartProc
689 */
690 inline unsigned char getPStatus() const { return this->sPtr->getPStatus(); }
691
692 /**
693 * @copydoc MoFEM::RefEntityTmp<0>::getSharingProcsPtr
694 */
695 inline int *getSharingProcsPtr() const {
696 return this->sPtr->getSharingProcsPtr();
697 }
698
699 /**
700 * @copydoc MoFEM::RefEntityTmp<0>::getSharingHandlersPtr
701 */
703 return this->sPtr->getSharingHandlersPtr();
704 }
705
706 /**
707 * @copydoc MoFEM::RefEntityTmp<0>::getRefEntityPtr
708 */
709 inline boost::shared_ptr<T> &getRefEntityPtr() const { return this->sPtr; }
710
711 mutable boost::shared_ptr<T> sPtr;
712};
713
714/**
715 * \typedef RefEntity_multiIndex
716 * type multiIndex container for RefEntity
717 * \ingroup ent_multi_indices
718 *
719 * \param hashed_unique Ent_mi_tag
720 * \param ordered_non_unique Ent_Ent_mi_tag
721 * \param ordered_non_unique Composite_EntType_And_ParentEntType_mi_tag
722 * \param ordered_non_unique Composite_ParentEnt_And_EntType_mi_tag
723 */
724using RefEntity_multiIndex = multi_index_container<
725 boost::shared_ptr<RefEntity>,
726 indexed_by<ordered_unique<
727
728 tag<Ent_mi_tag>,
729 const_mem_fun<RefEntity, EntityHandle, &RefEntity::getEnt>
730
731 >,
732
733 ordered_non_unique<
734
735 tag<Ent_Ent_mi_tag>, const_mem_fun<RefEntity, EntityHandle,
737
738 >,
739
740 ordered_non_unique<
741 tag<Composite_EntType_and_ParentEntType_mi_tag>,
742 composite_key<RefEntity,
743 const_mem_fun<RefEntity, EntityType,
745 const_mem_fun<RefEntity, EntityType,
747
748 >,
749
750 ordered_non_unique<
751 tag<Composite_ParentEnt_And_EntType_mi_tag>,
752 composite_key<RefEntity,
753 const_mem_fun<RefEntity, EntityType,
755 const_mem_fun<RefEntity, EntityHandle,
757
758 >>
759
760 >;
761
762/** \brief multi-index view of RefEntity by parent entity
763\ingroup ent_multi_indices
764*/
766 boost::shared_ptr<RefEntity>,
767 indexed_by<
768 hashed_non_unique<
769 const_mem_fun<RefEntity, EntityHandle, &RefEntity::getParentEnt>>,
770 hashed_unique<tag<Composite_EntType_and_ParentEntType_mi_tag>,
771 composite_key<boost::shared_ptr<RefEntity>,
772 const_mem_fun<RefEntity, EntityHandle,
774 const_mem_fun<RefEntity, EntityHandle,
776
777 >;
778
780 multi_index_container<
781 boost::shared_ptr<RefEntity>,
782 indexed_by<ordered_non_unique<const_mem_fun<RefEntity, EntityHandle,
784 hashed_unique<
785 tag<Composite_EntType_and_ParentEntType_mi_tag>,
786 composite_key<boost::shared_ptr<RefEntity>,
787 const_mem_fun<RefEntity, EntityHandle,
789 const_mem_fun<RefEntity, EntityHandle,
791
792 >;
793
795 boost::shared_ptr<RefEntity>,
796 indexed_by<
797 sequenced<>,
798 ordered_unique<tag<Ent_mi_tag>, const_mem_fun<RefEntity, EntityHandle,
800
801/** \brief change parent
802* \ingroup ent_multi_indices
803*
804* Use this function with care. Some other multi-indices can deponent on
805this.
806
807Known dependent multi-indices (verify if that list is full):
808- RefEntity_multiIndex
809- RefElement_multiIndex
810
811*/
815 inline void operator()(boost::shared_ptr<RefEntity> &e) {
816 rval = e->getBasicDataPtr()->moab.tag_set_data(
817 e->getBasicDataPtr()->th_RefParentHandle, &e->ent, 1, &pArent);
819 }
820};
821
822/** \brief ref mofem entity, left shift
823 * \ingroup ent_multi_indices
824 */
826 int shift;
829 const BitRefLevel _mask = BitRefLevel().set())
830 : shift(_shift), mask(_mask) {}
831 inline void operator()(boost::shared_ptr<RefEntity> &e) {
832 BitRefLevel bit = *(e->getBitRefLevelPtr());
833 (*e->getBitRefLevelPtr()) = ((bit & mask) << shift) | (bit & ~mask);
834 };
835};
836
837/** \brief ref mofem entity, right shift
838 * \ingroup ent_multi_indices
839 */
841 int shift;
844 const BitRefLevel _mask = BitRefLevel().set())
845 : shift(_shift), mask(_mask) {}
846 inline void operator()(boost::shared_ptr<RefEntity> &e) {
847 BitRefLevel bit = *(e->getBitRefLevelPtr());
848 *(e->getBitRefLevelPtr()) = ((bit & mask) >> shift) | (bit & ~mask);
849 };
850};
851} // namespace MoFEM
852
853#endif // __REF_ENTSMULTIINDICES_HPP__
854
855/**
856 * \defgroup ent_multi_indices Entities structures and multi-indices
857 * \ingroup mofem
858 **/
#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
auto type_from_handle(const EntityHandle h)
get type from entity handle
Definition: Templates.hpp:1918
EntityHandle get_id_for_max_type()
EntityHandle get_id_for_min_type()
auto id_from_handle(const EntityHandle h)
Definition: Templates.hpp:1910
RefEntityTmp< 0 > RefEntity
auto dimension_from_handle(const EntityHandle h)
get entity dimension form handle
Definition: Templates.hpp:1934
auto type_name_from_handle(const EntityHandle h)
get entity type name from handle
Definition: Templates.hpp:1942
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)