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