v0.15.0
Loading...
Searching...
No Matches
FEMultiIndices.hpp
Go to the documentation of this file.
1/** \file FEMultiIndices.hpp
2 * \brief Multi-index contains, data structures for mofem finite elements and
3 * other low-level functions
4 *
5 * \todo Add proc into feUId to reduce number of keys is multi-index
6 */
7
8#ifndef __FEMMULTIINDICES_HPP__
9 #define __FEMMULTIINDICES_HPP__
10
11namespace MoFEM {
12
13struct EntFiniteElement;
14
15/** \brief user adjacency function
16 * \ingroup fe_multi_indices
17 */
18using ElementAdjacencyFunct = boost::function<MoFEMErrorCode(
19 Interface &moab, const Field &field, const EntFiniteElement &fe,
20 std::vector<EntityHandle> &adjacency)>;
21
22/**
23 * \brief Finite element definition
24 * \ingroup fe_multi_indices
25 */
27
28 EntityHandle meshset; ///< meshset stores FE ents
29 BitFEId *tagId; ///< ptr to tag storing FE id
30 void *tagName; ///< ptr to tag storing FE name
31 int tagNameSize; ///< numer of characters in FE name
32 BitFieldId *tag_BitFieldId_col_data; ///< tag stores col id_id for fields
33 BitFieldId *tag_BitFieldId_row_data; ///< tag stores row id_id for fields
34 BitFieldId *tag_BitFieldId_data; ///< tag stores data id_id for fields
36
37 FiniteElement(Interface &moab, const EntityHandle _meshset);
38
39 /**
40 * @brief Get the tag storing meshset with adjacent entities to finite element
41 *
42 * @param moab
43 * @param field_name
44 * @return Tag
45 */
46 static Tag getNoFieldTag(moab::Interface &moab, const Field &field);
47
48 /**
49 * @brief Set the No Field meshset to finite element entities storing no field
50 * adjacencies to it
51 *
52 * @param moab
53 * @param fe_ents
54 * @param field_name
55 * @param meshset
56 * @return MoFEMErrorCode
57 */
58 static MoFEMErrorCode setNoFieldTagField(moab::Interface &moab, Range &fe_ents,
59 const Field &field,
61
62 /** @brief Set the No Field meshset to finite element entities storing no
63 * field adjacencies to it
64 *
65 * @param moab
66 * @param fe_ents
67 * @param field_name
68 * @param meshset
69 * @return MoFEMErrorCode
70 */
71 static MoFEMErrorCode setNoFieldTagField(moab::Interface &moab,
72 std::vector<EntityHandle> &fe_ents,
73 const Field &field,
75
76 /** \brief Get the No Field adjacency meshset from finite element entity
77 *
78 * @param moab
79 * @param fe_ent
80 * @param field_name
81 * @return EntityHandle
82 */
83 static EntityHandle getNoFieldAdjacencyMeshset(moab::Interface &moab,
84 EntityHandle fe_ent,
85 const Field &field);
86
87 /**
88 * @brief Get finite element uid
89 *
90 * @return const UId&
91 */
92 inline const UId &getFEUId() const { return feUId; }
93
94 /**
95 * \brief Get finite element id
96 * @return Finite element Id
97 */
98 inline BitFEId getId() const { return *tagId; }
99
100 /**
101 * \brief Get meshset containing element entities
102 * @return Meshset
103 */
104 inline EntityHandle getMeshset() const { return meshset; }
105
106 /**
107 * \brief Get finite element name
108 * @return string_ref
109 */
110 inline boost::string_ref getNameRef() const {
111 return boost::string_ref((char *)tagName, tagNameSize);
112 }
113
114 /**
115 * \brief Get finite element name
116 * @return string
117 */
118 inline std::string getName() const {
119 return std::string((char *)tagName, tagNameSize);
120 }
121
122 /**
123 * \brief Get field ids on columns
124 * @return Bit field ids
125 */
128 }
129
130 /**
131 * \brief Get field ids on rows
132 * @return Bit field ids
133 */
136 }
137
138 /**
139 * \brief Get field ids on data
140 * @return Bit field ids
141 */
143 return *((BitFieldId *)tag_BitFieldId_data);
144 }
145
146 /**
147 * \brief Get bit identifying this element
148 *
149 * Each element like field is identified by bit set. Each element has unique
150 * bit set, this function returns number of that bit.
151 *
152 * @return Bit number
153 */
154 inline unsigned int getBitNumber() const {
155 return ffsl(((BitFieldId *)tagId)->to_ulong());
156 }
157
158 /**
159 * \brief Table of functions retrieving adjacencies for finite element
160 * User can alter and change default behavior
161 */
162 std::array<ElementAdjacencyFunct, MBMAXTYPE> elementAdjacencyTable;
163
164 /**
165 * \brief print finite element
166 */
167 friend std::ostream &operator<<(std::ostream &os, const FiniteElement &e);
168
169private:
170 static constexpr int ent_shift = 64; // EntityHandle size
171};
172
173/** \brief default adjacency map
174 * \ingroup fe_multi_indices
175 */
177
178 static MoFEMErrorCode defaultVertex(Interface &moab, const Field &field,
179 const EntFiniteElement &fe,
180 std::vector<EntityHandle> &adjacency);
181 static MoFEMErrorCode defaultEdge(Interface &moab, const Field &field,
182 const EntFiniteElement &fe,
183 std::vector<EntityHandle> &adjacency);
184 static MoFEMErrorCode defaultFace(Interface &moab, const Field &field,
185 const EntFiniteElement &fe,
186 std::vector<EntityHandle> &adjacency);
187 static MoFEMErrorCode defaultVolume(Interface &moab, const Field &field,
188 const EntFiniteElement &fe,
189 std::vector<EntityHandle> &adjacency);
190 static MoFEMErrorCode defaultPrism(Interface &moab, const Field &field,
191 const EntFiniteElement &fe,
192 std::vector<EntityHandle> &adjacency);
193 static MoFEMErrorCode defaultMeshset(Interface &moab, const Field &field,
194 const EntFiniteElement &fe,
195 std::vector<EntityHandle> &adjacency);
196
197 using DefEntTypeMap = std::array<bool, MBMAXTYPE>;
198
199 static constexpr DefEntTypeMap defVertexTypeMap = {
200 // clang-format off
201 true, // MBVERTEX
202 false, // MBEDGE
203 false, // MBTRI
204 false, // MBQUAD
205 false, // MBPOLYGON
206 false, // MBTET
207 false, // MBPYRAMID
208 false, // MBPRISM
209 false, // MBKNIFE
210 false, // MBHEX
211 false, // MBPOLYHEDRON
212 false // MBENTITYSET
213 // clang-format on
214 };
215
216 static constexpr DefEntTypeMap defEdgeTypeMap = {
217 // clang-format off
218 true, // MBVERTEX
219 true, // MBEDGE
220 false, // MBTRI
221 false, // MBQUAD
222 false, // MBPOLYGON
223 false, // MBTET
224 false, // MBPYRAMID
225 false, // MBPRISM
226 false, // MBKNIFE
227 false, // MBHEX
228 false, // MBPOLYHEDRON
229 false // MBENTITYSET
230 // clang-format on
231 };
232
233 static constexpr DefEntTypeMap defTriTypeMap = {
234 // clang-format off
235 true, // MBVERTEX
236 true, // MBEDGE
237 true, // MBTRI
238 false, // MBQUAD
239 false, // MBPOLYGON
240 false, // MBTET
241 false, // MBPYRAMID
242 false, // MBPRISM
243 false, // MBKNIFE
244 false, // MBHEX
245 false, // MBPOLYHEDRON
246 false // MBENTITYSET
247 // clang-format on
248 };
249
250 static constexpr DefEntTypeMap defQuadTypeMap = {
251 // clang-format off
252 true, // MBVERTEX
253 true, // MBEDGE
254 false, // MBTRI
255 true, // MBQUAD
256 false, // MBPOLYGON
257 false, // MBTET
258 false, // MBPYRAMID
259 false, // MBPRISM
260 false, // MBKNIFE
261 false, // MBHEX
262 false, // MBPOLYHEDRON
263 false // MBENTITYSET
264 // clang-format on
265 };
266
267 static constexpr DefEntTypeMap defTetTypeMap = {
268 // clang-format off
269 true, // MBVERTEX
270 true, // MBEDGE
271 true, // MBTRI
272 false, // MBQUAD
273 false, // MBPOLYGON
274 true, // MBTET
275 false, // MBPYRAMID
276 false, // MBPRISM
277 false, // MBKNIFE
278 false, // MBHEX
279 false, // MBPOLYHEDRON
280 false // MBENTITYSET
281 // clang-format on
282 };
283
284 static constexpr DefEntTypeMap defHexTypeMap = {
285 // clang-format off
286 true, // MBVERTEX
287 true, // MBEDGE
288 false, // MBTRI
289 true, // MBQUAD
290 false, // MBPOLYGON
291 false, // MBTET
292 false, // MBPYRAMID
293 false, // MBPRISM
294 false, // MBKNIFE
295 true, // MBHEX
296 false, // MBPOLYHEDRON
297 false // MBENTITYSET
298 // clang-format on
299 };
300
301 static constexpr DefEntTypeMap defPrismTypeMap = {
302 // clang-format off
303 true, // MBVERTEX
304 true, // MBEDGE
305 true, // MBTRI
306 true, // MBQUAD
307 false, // MBPOLYGON
308 false, // MBTET
309 false, // MBPYRAMID
310 true, // MBPRISM
311 false, // MBKNIFE
312 false, // MBHEX
313 false, // MBPOLYHEDRON
314 false // MBENTITYSET
315 // clang-format on
316 };
317
318 static constexpr DefEntTypeMap defMeshsetTypeMap = {
319 // clang-format off
320 true, // MBVERTEX
321 true, // MBEDGE
322 true, // MBTRI
323 true, // MBQUAD
324 true, // MBPOLYGON
325 true, // MBTET
326 true, // MBPYRAMID
327 true, // MBPRISM
328 true, // MBKNIFE
329 true, // MBHEX
330 true, // MBPOLYHEDRON
331 true // MBENTITYSET
332 // clang-format on
333 };
334
335 static constexpr std::array<const DefEntTypeMap *, MBMAXTYPE> defTypeMap = {
336 // clang-format off
337 &defVertexTypeMap, // MBVERTEX
338 &defEdgeTypeMap, // MBEDGE
339 &defTriTypeMap, // MBTRI
340 &defQuadTypeMap, // MBQUAD
341 nullptr, // MBPOLYGON
342 &defTetTypeMap, // MBTET
343 nullptr, // MBPYRAMID
344 &defPrismTypeMap, // MBPRISM
345 nullptr, // MBKNIFE
346 &defHexTypeMap, // MBHEX
347 nullptr, // MBPOLYHEDRON
348 &defMeshsetTypeMap // MBENTITYSET
349 // clang-format on
350 };
351
352 static inline bool getDefTypeMap(const EntityType fe_type,
353 const EntityType ent_type) {
354 if (auto ptr = defTypeMap[fe_type])
355 return (*ptr)[ent_type];
356 THROW_MESSAGE("DefTypeMap is not defined by this element. This is propably "
357 "new implementation, and has to be implemented");
358 return false;
359 }
360};
361
362/**
363 * \brief Inetface for FE
364 * \ingroup fe_multi_indices
365 */
366template <typename FE, typename REFENT>
368
369 interface_FiniteElementImpl(const boost::shared_ptr<FE> fe_ptr,
370 const boost::shared_ptr<REFENT> ref_ents_ptr)
371 : interface_RefElement<REFENT>(ref_ents_ptr) {};
372 virtual ~interface_FiniteElementImpl() = default;
373};
374
375template <typename FE, typename REFENT>
377 interface_FiniteElement(const boost::shared_ptr<FE> fe_ptr,
378 const boost::shared_ptr<REFENT> ref_ents_ptr)
379 : interface_RefElement<REFENT>(ref_ents_ptr),
380 sFiniteElementPtr(fe_ptr) {};
381
382 virtual ~interface_FiniteElement() = default;
383
384 /**
385 * @copydoc MoFEM::FiniteElement::getFEUId
386 */
387 inline const UId &getFEUId() const {
388 return getFiniteElementPtr()->getFEUId();
389 }
390
391 /**
392 * @copydoc MoFEM::FiniteElement::getId
393 */
394 inline BitFEId getId() const { return getFiniteElementPtr()->getId(); }
395
396 /**
397 * @copydoc MoFEM::FiniteElement::getMeshset
398 */
399 inline EntityHandle getMeshset() const {
400 return getFiniteElementPtr()->getMeshset();
401 }
402
403 /**
404 * @copydoc MoFEM::FiniteElement::getNameRef
405 */
406 inline boost::string_ref getNameRef() const {
407 return getFiniteElementPtr()->getNameRef();
408 }
409
410 /**
411 * @copydoc MoFEM::FiniteElement::getName
412 */
413 inline std::string getName() const {
414 return getFiniteElementPtr()->getName();
415 }
416
417 /**
418 * @copydoc MoFEM::FiniteElement::getBitFieldIdCol
419 */
421 return getFiniteElementPtr()->getBitFieldIdCol();
422 }
423
424 /**
425 * @copydoc MoFEM::FiniteElement::getBitFieldIdRow
426 */
428 return getFiniteElementPtr()->getBitFieldIdRow();
429 }
430
431 /**
432 * @copydoc MoFEM::FiniteElement::getBitFieldIdData
433 */
435 return getFiniteElementPtr()->getBitFieldIdData();
436 }
437
438 /**
439 * @copydoc MoFEM::FiniteElement::getBitNumber
440 */
441 inline unsigned int getBitNumber() const {
442 return getFiniteElementPtr()->getBitNumber();
443 }
444
445 inline boost::shared_ptr<FE> &getFiniteElementPtr() const {
446 return sFiniteElementPtr;
447 }
448
449private:
450 mutable boost::shared_ptr<FE> sFiniteElementPtr;
451};
452
453template <typename T>
455 : public interface_FiniteElementImpl<T, T> {
456
457 interface_FiniteElement(const boost::shared_ptr<T> fe_ptr,
458 const boost::shared_ptr<T> ref_ents_ptr)
459 : interface_FiniteElementImpl<T, T>(fe_ptr, ref_ents_ptr) {}
460
461 /**
462 * @copydoc MoFEM::FiniteElement::getFEUId
463 */
464 inline const UId &getFEUId() const {
465 return getFiniteElementPtr()->getFEUId();
466 }
467
468 /**
469 * @copydoc MoFEM::FiniteElement::getId
470 */
471 inline BitFEId getId() const { return getFiniteElementPtr()->getId(); }
472
473 /**
474 * @copydoc MoFEM::FiniteElement::getMeshset
475 */
476 inline EntityHandle getMeshset() const {
477 return getFiniteElementPtr()->getMeshset();
478 }
479
480 /**
481 * @copydoc MoFEM::FiniteElement::getNameRef
482 */
483 inline boost::string_ref getNameRef() const {
484 return getFiniteElementPtr()->getNameRef();
485 }
486
487 /**
488 * @copydoc MoFEM::FiniteElement::getName
489 */
490 inline std::string getName() const {
491 return getFiniteElementPtr()->getName();
492 }
493
494 /**
495 * @copydoc MoFEM::FiniteElement::getBitFieldIdCol
496 */
498 return getFiniteElementPtr()->getBitFieldIdCol();
499 }
500
501 /**
502 * @copydoc MoFEM::FiniteElement::getBitFieldIdRow
503 */
505 return getFiniteElementPtr()->getBitFieldIdRow();
506 }
507
508 /**
509 * @copydoc MoFEM::FiniteElement::getBitFieldIdData
510 */
512 return getFiniteElementPtr()->getBitFieldIdData();
513 }
514
515 /**
516 * @copydoc MoFEM::FiniteElement::getBitNumber
517 */
518 inline unsigned int getBitNumber() const {
519 return getFiniteElementPtr()->getBitNumber();
520 }
521
522 inline boost::shared_ptr<FiniteElement> &getFiniteElementPtr() const {
523 return boost::static_pointer_cast<T>(this->getRefElement())
524 ->getFiniteElementPtr();
525 };
526};
527
529 std::array<DofEntity_multiIndex::iterator, 2> loHi;
530};
531
533 std::array<NumeredDofEntity_multiIndex::iterator, 2> loHi;
534};
535
536using CacheTuple = std::tuple<
537
538 std::vector<EntityCacheDofs>, std::vector<EntityCacheNumeredDofs>,
539 std::vector<EntityCacheNumeredDofs>
540
541 >;
542
543using CacheTupleWeakPtr = boost::weak_ptr<CacheTuple>;
544using CacheTupleSharedPtr = boost::shared_ptr<CacheTuple>;
545
546/**
547 * \brief Finite element data for entity
548 * \ingroup fe_multi_indices
549 */
551 : public interface_FiniteElement<FiniteElement, RefElement> {
552
557
558 EntFiniteElement(const boost::shared_ptr<RefElement> &ref_finite_element,
559 const boost::shared_ptr<FiniteElement> &fe_ptr);
560 virtual ~EntFiniteElement() = default;
561
562 /**
563 * \brief Get unique UId for finite element entity
564 * @return UId
565 */
566 inline UId getLocalUniqueId() const { return getLocalUniqueIdCalculate(); }
567
569 UId fe_uid) {
570 return fe_uid |= ent;
571 }
572
573 /**
574 * \brief Generate UId for finite element entity
575 * @return finite element entity unique Id
576 */
580
581 // TODO: [CORE-61] Get FEDofs by entity type
582
583 /**
584 * @brief Get the Data Dofs Ptr object
585 *
586 * @return boost::shared_ptr<FEDofEntity_multiIndex>
587 */
588 boost::shared_ptr<FEDofEntity_multiIndex> getDataDofsPtr() const;
589
590 /**
591 * \brief Get data data dos multi-index structure
592 * @return Reference multi-index FEDofEntity_multiIndex
593 */
594 boost::shared_ptr<std::vector<boost::shared_ptr<FEDofEntity>>>
595 getDataVectorDofsPtr() const;
596
598 return *getDataFieldEntsPtr();
599 };
600
601 inline boost::shared_ptr<FieldEntity_vector_view> &
606
608 return *getRowFieldEntsPtr();
609 };
610
611 inline boost::shared_ptr<FieldEntity_vector_view> &
616
618 return *getColFieldEntsPtr();
619 };
620
621 inline boost::shared_ptr<FieldEntity_vector_view> &
626
627 friend std::ostream &operator<<(std::ostream &os, const EntFiniteElement &e);
628
629 template <typename FE_ENTS, typename MOFEM_DOFS, typename MOFEM_DOFS_VIEW,
630 typename INSERTER>
631 static MoFEMErrorCode
632 getDofView(const FE_ENTS &fe_ents_view, const MOFEM_DOFS &mofem_dofs,
633 MOFEM_DOFS_VIEW &dofs_view, INSERTER &&inserter) {
635
636 auto hint = dofs_view.end();
637 using ValType = typename std::remove_reference<decltype(**hint)>::type;
638
639 for (auto &it : fe_ents_view) {
640 if (auto e = it.lock()) {
641 const auto &uid = e->getLocalUniqueId();
642 auto dit = mofem_dofs.lower_bound(uid);
643 if (dit != mofem_dofs.end()) {
644 const auto hi_dit = mofem_dofs.upper_bound(
645 uid | static_cast<UId>(MAX_DOFS_ON_ENTITY - 1));
646 for (; dit != hi_dit; ++dit)
647 hint = inserter(dofs_view, hint,
648 boost::reinterpret_pointer_cast<ValType>(*dit));
649 }
650 }
651 }
653 }
654
655 template <typename MOFEM_DOFS, typename MOFEM_DOFS_VIEW>
656 inline MoFEMErrorCode getRowDofView(const MOFEM_DOFS &mofem_dofs,
657 MOFEM_DOFS_VIEW &dofs_view) {
658
659 auto hint = dofs_view.end();
660 using ValType = typename std::remove_reference<decltype(**hint)>::type;
661 using IndexType = MOFEM_DOFS_VIEW;
662
663 struct Inserter {
664 using Idx = IndexType;
665 using It = typename Idx::iterator;
666 It operator()(Idx &dofs_view, It &hint,
667 boost::shared_ptr<ValType> &&dof) {
668 return dofs_view.emplace_hint(hint, dof);
669 }
670 };
671
672 return getDofView(getRowFieldEnts(), mofem_dofs, dofs_view, Inserter());
673 }
674
675 template <typename MOFEM_DOFS, typename MOFEM_DOFS_VIEW>
676 inline MoFEMErrorCode
677 getColDofView(const MOFEM_DOFS &mofem_dofs, MOFEM_DOFS_VIEW &dofs_view,
678 const int operation_type = moab::Interface::UNION) {
679
680 auto hint = dofs_view.end();
681 using ValType = typename std::remove_reference<decltype(**hint)>::type;
682 using IndexType = MOFEM_DOFS_VIEW;
683
684 struct Inserter {
685 using Idx = IndexType;
686 using It = typename Idx::iterator;
687 It operator()(Idx &dofs_view, It &hint,
688 boost::shared_ptr<ValType> &&dof) {
689 return dofs_view.emplace_hint(hint, dof);
690 }
691 };
692
693 return getDofView(getColFieldEnts(), mofem_dofs, dofs_view, operation_type);
694 }
695
696 MoFEMErrorCode getElementAdjacency(const boost::shared_ptr<Field> field_ptr,
697 std::vector<EntityHandle> &adjacency);
698
699private:
700 mutable boost::shared_ptr<FieldEntity_vector_view> dataFieldEnts;
701 mutable boost::shared_ptr<FieldEntity_vector_view> rowFieldEnts;
702 mutable boost::shared_ptr<FieldEntity_vector_view> colFieldEnts;
703};
704
705/**
706 * \brief interface to EntFiniteElement
707 * \ingroup fe_multi_indices
708 */
709template <typename T>
711
712 interface_EntFiniteElement(const boost::shared_ptr<T> &sptr)
713 : interface_FiniteElement<T, T>(sptr, sptr) {}
714 virtual ~interface_EntFiniteElement() = default;
715
716 inline auto getDataDofsPtr() const { return this->sPtr->getDataDofsPtr(); }
717
718 inline auto getDataVectorDofsPtr() const {
719 return this->sPtr->getDataVectorDofsPtr();
720 };
721
723 return this->sPtr->getDataFieldEnts();
724 };
725
726 inline boost::shared_ptr<FieldEntity_vector_view> &getDataFieldEntsPtr() {
727 return this->sPtr->getDataFieldEntsPtr();
728 };
729
731 return this->sPtr->getRowFieldEnts();
732 };
733
734 inline boost::shared_ptr<FieldEntity_vector_view> &
736 return this->sPtr->getRowFieldEntsPtr();
737 }
738
740 return this->sPtr->getColFieldEnts();
741 };
742
743 inline boost::shared_ptr<FieldEntity_vector_view> &
745 return this->sPtr->getColFieldEntsPtr();
746 };
747
748 /**
749 * \brief Get unique UId for finite element entity
750 * @return UId
751 */
752 inline UId getLocalUniqueId() const { return this->sPtr->getLocalUniqueId(); }
753
755 return this->sPtr->getSideNumberTable();
756 }
757
758 inline MoFEMErrorCode getElementAdjacency(const Field *field_ptr,
759 Range &adjacency) {
760 return this->getElementAdjacency(field_ptr, adjacency);
761 }
762
763 inline const boost::shared_ptr<RefElement> &getRefElement() const {
764 return this->sPtr->getRefElement();
765 }
766};
767
768/** \brief Partitioned (Indexed) Finite Element in Problem
769
770 * This type of structure is used to compose problem. Problem is build from
771 * indexed finite elements. This data structure carry information about
772 * partition, which is specific to problem.
773
774
775 * \ingroup fe_multi_indices
776 */
778 : public interface_EntFiniteElement<EntFiniteElement> {
779
780 virtual ~NumeredEntFiniteElement() = default;
781
786
787 unsigned int part; ///< Partition number
788
789 inline boost::shared_ptr<EntFiniteElement> &getEntFiniteElement() const {
790 return this->sPtr;
791 }
792
793 /**
794 * \Construct indexed finite element
795 */
796 NumeredEntFiniteElement(const boost::shared_ptr<EntFiniteElement> &sptr);
797
798 /**
799 * \brief Get partition number
800 * @return [description]
801 */
802 inline unsigned int getPart() const { return part; };
803
804 /** \brief get FE dof on row
805 * \ingroup mofem_dofs
806 */
807 boost::shared_ptr<FENumeredDofEntity_multiIndex> getRowDofsPtr() const;
808
809 /** \brief get FE dof on column
810 * \ingroup mofem_dofs
811 */
812 boost::shared_ptr<FENumeredDofEntity_multiIndex> getColDofsPtr() const;
813
814 /** \brief get FE dof by petsc index
815 * \ingroup mofem_dofs
816 */
817 boost::weak_ptr<FENumeredDofEntity>
818 getRowDofsByPetscGlobalDofIdx(const int idx) const;
819
820 /** \brief get FE dof by petsc index
821 * \ingroup mofem_dofs
822 */
823 boost::weak_ptr<FENumeredDofEntity>
824 getColDofsByPetscGlobalDofIdx(const int idx) const;
825
826 friend std::ostream &operator<<(std::ostream &os,
827 const NumeredEntFiniteElement &e);
828};
829
830/**
831 * @relates multi_index_container
832 * \brief MultiIndex container for EntFiniteElement
833 * \ingroup fe_multi_indices
834 *
835 */
836using EntFiniteElement_multiIndex = multi_index_container<
837 boost::shared_ptr<EntFiniteElement>,
838 indexed_by<
839
840 ordered_unique<tag<Unique_mi_tag>,
841 const_mem_fun<EntFiniteElement, UId,
843
844 ordered_non_unique<
845 tag<Ent_mi_tag>,
848
849 >>;
850
851/**
852 @relates multi_index_container
853 \brief MultiIndex for entities for NumeredEntFiniteElement
854 \ingroup fe_multi_indices
855 */
856using NumeredEntFiniteElement_multiIndex = multi_index_container<
857 boost::shared_ptr<NumeredEntFiniteElement>,
858 indexed_by<
859 ordered_unique<
860 tag<Unique_mi_tag>,
861 const_mem_fun<
864 ordered_non_unique<tag<Part_mi_tag>,
865 member<NumeredEntFiniteElement, unsigned int,
867 ordered_non_unique<
868 tag<Ent_mi_tag>,
871 ordered_non_unique<
872 tag<Composite_Name_And_Part_mi_tag>,
873 composite_key<
874 NumeredEntFiniteElement,
875 const_mem_fun<
877 boost::string_ref, &NumeredEntFiniteElement::getNameRef>,
878 member<NumeredEntFiniteElement, unsigned int,
880
881/**
882 @relates multi_index_container
883 \brief MultiIndex for entities for FiniteElement
884 \ingroup fe_multi_indices
885 */
886typedef multi_index_container<
887 boost::shared_ptr<FiniteElement>,
888 indexed_by<hashed_unique<tag<FiniteElement_Meshset_mi_tag>,
889 member<FiniteElement, EntityHandle,
891 hashed_unique<
892 tag<BitFEId_mi_tag>,
893 const_mem_fun<FiniteElement, BitFEId, &FiniteElement::getId>,
894 HashBit<BitFEId>, EqBit<BitFEId>>,
895 ordered_unique<tag<FiniteElement_name_mi_tag>,
896 const_mem_fun<FiniteElement, boost::string_ref,
899
900// modificators
901
902/**
903 * \brief Change finite element part
904 *
905 * \ingroup fe_multi_indices
906 */
908 unsigned int pArt;
909 NumeredEntFiniteElement_change_part(unsigned int part) : pArt(part) {};
910 void operator()(boost::shared_ptr<NumeredEntFiniteElement> &fe) {
911 fe->part = pArt;
912 }
914};
915
916/**
917 * \brief Add field to column
918 *
919 * \ingroup fe_multi_indices
920 */
924 : fIdCol(f_id_col) {};
925 void operator()(boost::shared_ptr<FiniteElement> &fe);
926};
927
928/**
929 * \brief Add field to row
930 *
931 * \ingroup fe_multi_indices
932 */
936 : fIdRow(f_id_row) {};
937 void operator()(boost::shared_ptr<FiniteElement> &fe);
938};
939
940/**
941 * \brief Add field to data
942 *
943 * \ingroup fe_multi_indices
944 */
948 : fIdData(f_id_data) {};
949 void operator()(boost::shared_ptr<FiniteElement> &fe);
950};
951
952/**
953 * \brief Unset field from column
954 *
955 * \ingroup fe_multi_indices
956 */
960 : fIdCol(f_id_col) {};
961 void operator()(boost::shared_ptr<FiniteElement> &fe);
962};
963
964/**
965 * \brief Unset field from row
966 *
967 * \ingroup fe_multi_indices
968 */
972 : fIdRow(f_id_row) {};
973 void operator()(boost::shared_ptr<FiniteElement> &fe);
974};
975
976/**
977 * \brief Unset field from data
978 *
979 * \ingroup fe_multi_indices
980 */
984 : fIdData(f_id_data) {};
985 void operator()(boost::shared_ptr<FiniteElement> &fe);
986};
987
988/**
989 * \brief Reset field from column
990 *
991 * \ingroup fe_multi_indices
992 */
995 void operator()(boost::shared_ptr<FiniteElement> &fe);
996};
997
998/**
999 * \brief Reset field from row
1000 *
1001 * \ingroup fe_multi_indices
1002 */
1005 void operator()(boost::shared_ptr<FiniteElement> &fe);
1006};
1007
1008/**
1009 * \brief Reset field from data
1010 *
1011 * \ingroup fe_multi_indices
1012 */
1015 void operator()(boost::shared_ptr<FiniteElement> &fe);
1016};
1017
1018} // namespace MoFEM
1019
1020#endif // __FEMMULTIINDICES_HPP__
1021
1022/**
1023 * \defgroup fe_multi_indices Finite elements structures and multi-indices
1024 * \ingroup mofem
1025 **/
#define MAX_DOFS_ON_ENTITY
Maximal number of DOFs on entity.
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
#define THROW_MESSAGE(msg)
Throw MoFEM exception.
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.
boost::function< MoFEMErrorCode( Interface &moab, const Field &field, const EntFiniteElement &fe, std::vector< EntityHandle > &adjacency)> ElementAdjacencyFunct
user adjacency function
multi_index_container< boost::shared_ptr< EntFiniteElement >, indexed_by< ordered_unique< tag< Unique_mi_tag >, const_mem_fun< EntFiniteElement, UId, &EntFiniteElement::getLocalUniqueId > >, ordered_non_unique< tag< Ent_mi_tag >, const_mem_fun< EntFiniteElement::interface_type_RefEntity, EntityHandle, &EntFiniteElement::getEnt > > > > EntFiniteElement_multiIndex
MultiIndex container for EntFiniteElement.
multi_index_container< boost::shared_ptr< FiniteElement >, indexed_by< hashed_unique< tag< FiniteElement_Meshset_mi_tag >, member< FiniteElement, EntityHandle, &FiniteElement::meshset > >, hashed_unique< tag< BitFEId_mi_tag >, const_mem_fun< FiniteElement, BitFEId, &FiniteElement::getId >, HashBit< BitFEId >, EqBit< BitFEId > >, ordered_unique< tag< FiniteElement_name_mi_tag >, const_mem_fun< FiniteElement, boost::string_ref, &FiniteElement::getNameRef > > > > FiniteElement_multiIndex
MultiIndex for entities for FiniteElement.
multi_index_container< boost::shared_ptr< NumeredEntFiniteElement >, indexed_by< ordered_unique< tag< Unique_mi_tag >, const_mem_fun< NumeredEntFiniteElement::interface_type_EntFiniteElement, UId, &NumeredEntFiniteElement::getLocalUniqueId > >, ordered_non_unique< tag< Part_mi_tag >, member< NumeredEntFiniteElement, unsigned int, &NumeredEntFiniteElement::part > >, ordered_non_unique< tag< Ent_mi_tag >, const_mem_fun< NumeredEntFiniteElement::interface_type_RefEntity, EntityHandle, &NumeredEntFiniteElement::getEnt > >, ordered_non_unique< tag< Composite_Name_And_Part_mi_tag >, composite_key< NumeredEntFiniteElement, const_mem_fun< NumeredEntFiniteElement::interface_type_FiniteElement, boost::string_ref, &NumeredEntFiniteElement::getNameRef >, member< NumeredEntFiniteElement, unsigned int, &NumeredEntFiniteElement::part > > > > > NumeredEntFiniteElement_multiIndex
MultiIndex for entities for NumeredEntFiniteElement.
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
std::bitset< BITFEID_SIZE > BitFEId
Finite element Id.
Definition Types.hpp:43
std::bitset< BITFIELDID_SIZE > BitFieldId
Field Id.
Definition Types.hpp:42
uint128_t UId
Unique Id.
Definition Types.hpp:31
implementation of Data Operators for Forces and Sources
Definition Common.hpp:10
boost::weak_ptr< CacheTuple > CacheTupleWeakPtr
std::tuple< std::vector< EntityCacheDofs >, std::vector< EntityCacheNumeredDofs >, std::vector< EntityCacheNumeredDofs > > CacheTuple
std::vector< boost::weak_ptr< FieldEntity > > FieldEntity_vector_view
boost::shared_ptr< CacheTuple > CacheTupleSharedPtr
static constexpr DefEntTypeMap defVertexTypeMap
static constexpr DefEntTypeMap defEdgeTypeMap
std::array< bool, MBMAXTYPE > DefEntTypeMap
static constexpr DefEntTypeMap defQuadTypeMap
static bool getDefTypeMap(const EntityType fe_type, const EntityType ent_type)
static constexpr DefEntTypeMap defTriTypeMap
static MoFEMErrorCode defaultMeshset(Interface &moab, const Field &field, const EntFiniteElement &fe, std::vector< EntityHandle > &adjacency)
static MoFEMErrorCode defaultVertex(Interface &moab, const Field &field, const EntFiniteElement &fe, std::vector< EntityHandle > &adjacency)
static MoFEMErrorCode defaultVolume(Interface &moab, const Field &field, const EntFiniteElement &fe, std::vector< EntityHandle > &adjacency)
static constexpr std::array< const DefEntTypeMap *, MBMAXTYPE > defTypeMap
static constexpr DefEntTypeMap defTetTypeMap
static constexpr DefEntTypeMap defHexTypeMap
static constexpr DefEntTypeMap defMeshsetTypeMap
static MoFEMErrorCode defaultEdge(Interface &moab, const Field &field, const EntFiniteElement &fe, std::vector< EntityHandle > &adjacency)
static MoFEMErrorCode defaultPrism(Interface &moab, const Field &field, const EntFiniteElement &fe, std::vector< EntityHandle > &adjacency)
static MoFEMErrorCode defaultFace(Interface &moab, const Field &field, const EntFiniteElement &fe, std::vector< EntityHandle > &adjacency)
static constexpr DefEntTypeMap defPrismTypeMap
Deprecated interface functions.
Finite element data for entity.
UId getLocalUniqueIdCalculate() const
Generate UId for finite element entity.
EntFiniteElement(const boost::shared_ptr< RefElement > &ref_finite_element, const boost::shared_ptr< FiniteElement > &fe_ptr)
friend std::ostream & operator<<(std::ostream &os, const EntFiniteElement &e)
boost::shared_ptr< std::vector< boost::shared_ptr< FEDofEntity > > > getDataVectorDofsPtr() const
Get data data dos multi-index structure.
boost::shared_ptr< FieldEntity_vector_view > & getDataFieldEntsPtr() const
boost::shared_ptr< FieldEntity_vector_view > dataFieldEnts
boost::shared_ptr< FEDofEntity_multiIndex > getDataDofsPtr() const
Get the Data Dofs Ptr object.
boost::shared_ptr< FieldEntity_vector_view > & getColFieldEntsPtr() const
FieldEntity_vector_view & getRowFieldEnts() const
static MoFEMErrorCode getDofView(const FE_ENTS &fe_ents_view, const MOFEM_DOFS &mofem_dofs, MOFEM_DOFS_VIEW &dofs_view, INSERTER &&inserter)
static UId getLocalUniqueIdCalculate(const EntityHandle ent, UId fe_uid)
MoFEMErrorCode getColDofView(const MOFEM_DOFS &mofem_dofs, MOFEM_DOFS_VIEW &dofs_view, const int operation_type=moab::Interface::UNION)
UId getLocalUniqueId() const
Get unique UId for finite element entity.
interface_RefEntity< RefElement > interface_type_RefEntity
MoFEMErrorCode getRowDofView(const MOFEM_DOFS &mofem_dofs, MOFEM_DOFS_VIEW &dofs_view)
boost::shared_ptr< FieldEntity_vector_view > & getRowFieldEntsPtr() const
virtual ~EntFiniteElement()=default
boost::shared_ptr< FieldEntity_vector_view > colFieldEnts
FieldEntity_vector_view & getColFieldEnts() const
MoFEMErrorCode getElementAdjacency(const boost::shared_ptr< Field > field_ptr, std::vector< EntityHandle > &adjacency)
FieldEntity_vector_view & getDataFieldEnts() const
boost::shared_ptr< FieldEntity_vector_view > rowFieldEnts
std::array< DofEntity_multiIndex::iterator, 2 > loHi
std::array< NumeredDofEntity_multiIndex::iterator, 2 > loHi
Provide data structure for (tensor) field approximation.
FiniteElement_change_bit_add(const BitFieldId f_id_data)
void operator()(boost::shared_ptr< FiniteElement > &fe)
void operator()(boost::shared_ptr< FiniteElement > &fe)
FiniteElement_change_bit_off(const BitFieldId f_id_data)
void operator()(boost::shared_ptr< FiniteElement > &fe)
void operator()(boost::shared_ptr< FiniteElement > &fe)
FiniteElement_col_change_bit_add(const BitFieldId f_id_col)
void operator()(boost::shared_ptr< FiniteElement > &fe)
FiniteElement_col_change_bit_off(const BitFieldId f_id_col)
void operator()(boost::shared_ptr< FiniteElement > &fe)
FiniteElement_row_change_bit_add(const BitFieldId f_id_row)
void operator()(boost::shared_ptr< FiniteElement > &fe)
void operator()(boost::shared_ptr< FiniteElement > &fe)
FiniteElement_row_change_bit_off(const BitFieldId f_id_row)
void operator()(boost::shared_ptr< FiniteElement > &fe)
Finite element definition.
BitFieldId * tag_BitFieldId_col_data
tag stores col id_id for fields
void * tagName
ptr to tag storing FE name
unsigned int getBitNumber() const
Get bit identifying this element.
EntityHandle getMeshset() const
Get meshset containing element entities.
BitFieldId * tag_BitFieldId_data
tag stores data id_id for fields
static MoFEMErrorCode setNoFieldTagField(moab::Interface &moab, Range &fe_ents, const Field &field, EntityHandle meshset)
Set the No Field meshset to finite element entities storing no field adjacencies to it.
static Tag getNoFieldTag(moab::Interface &moab, const Field &field)
Get the tag storing meshset with adjacent entities to finite element.
BitFEId * tagId
ptr to tag storing FE id
BitFieldId getBitFieldIdRow() const
Get field ids on rows.
std::string getName() const
Get finite element name.
BitFEId getId() const
Get finite element id.
const UId & getFEUId() const
Get finite element uid.
FiniteElement(Interface &moab, const EntityHandle _meshset)
BitFieldId * tag_BitFieldId_row_data
tag stores row id_id for fields
static EntityHandle getNoFieldAdjacencyMeshset(moab::Interface &moab, EntityHandle fe_ent, const Field &field)
Get the No Field adjacency meshset from finite element entity.
static constexpr int ent_shift
boost::string_ref getNameRef() const
Get finite element name.
friend std::ostream & operator<<(std::ostream &os, const FiniteElement &e)
print finite element
BitFieldId getBitFieldIdData() const
Get field ids on data.
BitFieldId getBitFieldIdCol() const
Get field ids on columns.
int tagNameSize
numer of characters in FE name
EntityHandle meshset
meshset stores FE ents
std::array< ElementAdjacencyFunct, MBMAXTYPE > elementAdjacencyTable
Table of functions retrieving adjacencies for finite element User can alter and change default behavi...
void operator()(boost::shared_ptr< NumeredEntFiniteElement > &fe)
void operator()(NumeredEntFiniteElement &fe)
Partitioned (Indexed) Finite Element in Problem.
interface_FiniteElement< EntFiniteElement, EntFiniteElement > interface_type_FiniteElement
boost::weak_ptr< FENumeredDofEntity > getRowDofsByPetscGlobalDofIdx(const int idx) const
get FE dof by petsc index
boost::weak_ptr< FENumeredDofEntity > getColDofsByPetscGlobalDofIdx(const int idx) const
get FE dof by petsc index
NumeredEntFiniteElement(const boost::shared_ptr< EntFiniteElement > &sptr)
boost::shared_ptr< EntFiniteElement > & getEntFiniteElement() const
unsigned int getPart() const
Get partition number.
friend std::ostream & operator<<(std::ostream &os, const NumeredEntFiniteElement &e)
virtual ~NumeredEntFiniteElement()=default
boost::shared_ptr< FENumeredDofEntity_multiIndex > getRowDofsPtr() const
get FE dof on row
interface_EntFiniteElement< EntFiniteElement > interface_type_EntFiniteElement
boost::shared_ptr< FENumeredDofEntity_multiIndex > getColDofsPtr() const
get FE dof on column
unsigned int part
Partition number.
interface to EntFiniteElement
boost::shared_ptr< FieldEntity_vector_view > & getDataFieldEntsPtr()
FieldEntity_vector_view & getDataFieldEnts() const
SideNumber_multiIndex & getSideNumberTable() const
virtual ~interface_EntFiniteElement()=default
UId getLocalUniqueId() const
Get unique UId for finite element entity.
boost::shared_ptr< FieldEntity_vector_view > & getColFieldEntsPtr() const
MoFEMErrorCode getElementAdjacency(const Field *field_ptr, Range &adjacency)
FieldEntity_vector_view & getColFieldEnts() const
interface_EntFiniteElement(const boost::shared_ptr< T > &sptr)
FieldEntity_vector_view & getRowFieldEnts() const
boost::shared_ptr< FieldEntity_vector_view > & getRowFieldEntsPtr() const
const boost::shared_ptr< RefElement > & getRefElement() const
interface_FiniteElementImpl(const boost::shared_ptr< FE > fe_ptr, const boost::shared_ptr< REFENT > ref_ents_ptr)
virtual ~interface_FiniteElementImpl()=default
const UId & getFEUId() const
Get finite element uid.
boost::string_ref getNameRef() const
Get finite element name.
EntityHandle getMeshset() const
Get meshset containing element entities.
BitFieldId getBitFieldIdData() const
Get field ids on data.
unsigned int getBitNumber() const
Get bit identifying this element.
BitFEId getId() const
Get finite element id.
BitFieldId getBitFieldIdCol() const
Get field ids on columns.
BitFieldId getBitFieldIdRow() const
Get field ids on rows.
std::string getName() const
Get finite element name.
interface_FiniteElement(const boost::shared_ptr< T > fe_ptr, const boost::shared_ptr< T > ref_ents_ptr)
boost::shared_ptr< FiniteElement > & getFiniteElementPtr() const
std::string getName() const
Get finite element name.
const UId & getFEUId() const
Get finite element uid.
boost::shared_ptr< FE > & getFiniteElementPtr() const
virtual ~interface_FiniteElement()=default
boost::shared_ptr< FE > sFiniteElementPtr
BitFEId getId() const
Get finite element id.
interface_FiniteElement(const boost::shared_ptr< FE > fe_ptr, const boost::shared_ptr< REFENT > ref_ents_ptr)
BitFieldId getBitFieldIdData() const
Get field ids on data.
BitFieldId getBitFieldIdRow() const
Get field ids on rows.
unsigned int getBitNumber() const
Get bit identifying this element.
BitFieldId getBitFieldIdCol() const
Get field ids on columns.
EntityHandle getMeshset() const
Get meshset containing element entities.
boost::string_ref getNameRef() const
Get finite element name.
interface_RefEntity< EntFiniteElement > interface_type_RefEntity
boost::shared_ptr< REFENT > & getRefElement() const