v0.10.0
ProblemsMultiIndices.hpp
Go to the documentation of this file.
1 /** \file ProblemsMultiIndices.hpp
2  * \brief Multi-index containers, data structures for problems and other
3  * 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 __PROBLEMSMULTIINDICES_HPP__
21 #define __PROBLEMSMULTIINDICES_HPP__
22 
23 namespace MoFEM {
24 
25 struct Problem;
26 
27 /**
28  * Data structure created when composite problem is created
29  */
31 
32  std::vector<const Problem *> rowProblemsAdd;
33  std::vector<const Problem *> colProblemsAdd;
34 
35  std::vector<IS> rowIs;
36  std::vector<IS> colIs;
37 
38  inline MoFEMErrorCode getRowIs(IS *is, const unsigned int pp) const {
40  PetscObjectReference((PetscObject)rowIs[pp]);
41  if (pp <= rowIs.size()) {
42  SETERRQ1(PETSC_COMM_WORLD, MOFEM_INVALID_DATA,
43  "Exceed size of array pp<%d", rowIs.size());
44  }
45  *is = rowIs[pp];
47  }
48 
49  inline MoFEMErrorCode getColIs(IS *is, const unsigned int pp) const {
51  PetscObjectReference((PetscObject)colIs[pp]);
52  if (pp <= colIs.size()) {
53  SETERRQ1(PETSC_COMM_WORLD, MOFEM_INVALID_DATA,
54  "Exceed size of array pp<%d", colIs.size());
55  }
56  *is = colIs[pp];
58  }
59 
61  for (unsigned int ii = 0; ii != rowIs.size(); ii++) {
62  ISDestroy(&rowIs[ii]);
63  }
64  for (unsigned int jj = 0; jj != colIs.size(); jj++) {
65  ISDestroy(&colIs[jj]);
66  }
67  }
68 };
69 
70 /** \brief keeps basic data about problem
71  * \ingroup problems_multi_indices
72  *
73  * This is low level structure with information about problem, what elements
74  * compose problem and what DOFs are on rows and columns.
75  *
76  * \todo fix names following name convention
77  *
78  */
79 struct Problem {
80 
81  EntityHandle meshset; ///< Problem meshset (on tag of this meshset all data
82  ///< related to problem are stored)
83  BitProblemId *tagId; ///< Unique problem ID
84  const char *tagName; ///< Problem name
85  int tagNameSize; ///< Size of problem name
86  BitFEId *tagBitFEId; ///< IDs of finite elements in problem
87  BitRefLevel *tagBitRefLevel; ///< BitRef level of finite elements in problem
88  BitRefLevel *tagMaskBitRefLevel; ///< BItRefMask of elements in problem
89 
90  mutable DofIdx nbDofsRow; ///< Global number of DOFs in row
91  mutable DofIdx nbDofsCol; ///< Global number of DOFs in col
92  mutable DofIdx nbLocDofsRow; ///< Local number of DOFs in row
93  mutable DofIdx nbLocDofsCol; ///< Local number of DOFs in colIs
94  mutable DofIdx nbGhostDofsRow; ///< Number of ghost DOFs in row
95  mutable DofIdx nbGhostDofsCol; ///< Number of ghost DOFs in col
96 
97  mutable boost::shared_ptr<NumeredDofEntity_multiIndex>
98  numeredRowDofsPtr; ///< store DOFs on rows for this problem
99  mutable boost::shared_ptr<NumeredDofEntity_multiIndex>
100  numeredColDofsPtr; ///< store DOFs on columns for this problem
101  mutable boost::shared_ptr<NumeredEntFiniteElement_multiIndex>
102  numeredFiniteElementsPtr; ///< store finite elements
103 
104  /**
105  * \brief get access to numeredRowDofsPtr storing DOFs on rows
106  */
107  boost::shared_ptr<NumeredDofEntity_multiIndex> &getNumeredRowDofsPtr() const {
108  return numeredRowDofsPtr;
109  }
110 
111  /**
112  * \brief get access to numeredColDofsPtr storing DOFs on cols
113  */
114  boost::shared_ptr<NumeredDofEntity_multiIndex> &getNumeredColDofsPtr() const {
115  return numeredColDofsPtr;
116  }
117 
118  /**
119  * \brief get access to reference for multi-index storing finite elements
120  */
121  const boost::shared_ptr<NumeredEntFiniteElement_multiIndex> &
124  }
125 
126  /**
127  * \brief get access to numeredRowDofsPtr storing DOFs on rows
128  * \deprected Use getNumeredRowDofsPtr
129  */
130  DEPRECATED boost::shared_ptr<NumeredDofEntity_multiIndex> &
132  return numeredRowDofsPtr;
133  }
134 
135  /**
136  * \brief get access to numeredColDofsPtr storing DOFs on cols
137  * \deprecated Use getNumeredColDofsPtr
138  */
139  DEPRECATED boost::shared_ptr<NumeredDofEntity_multiIndex> &
141  return numeredColDofsPtr;
142  }
143 
144  /**
145  * \brief get access to reference for multi-index storing finite elements
146  * \deprecated getNumeredFiniteElementsPtr
147  */
148  const boost::shared_ptr<NumeredEntFiniteElement_multiIndex> &DEPRECATED
151  }
152 
153  /**
154  * \brief Subproblem problem data
155  */
156  struct SubProblemData {
157 
159  rowIs; ///< indices of main problem of which sub problem is this
161  colIs; ///< indices of main problem of which sub problem is this
163  rowMap; ///< mapping form main problem indices to sub-problem indices
165  colMap; ///< mapping form main problem indices to sub-problem indices
166 
167  inline auto getSmartRowIs() { return rowIs; }
168  inline auto getSmartColIs() { return colIs; }
169  inline auto getSmartRowMap() { return rowMap; }
170  inline auto getSmartColMap() { return colMap; }
171 
172  /**
173  * get row Is for sub problem
174  * @param is create is
175  * @return error code
176  */
177  inline MoFEMErrorCode getRowIs(IS *is) {
179  PetscObjectReference((PetscObject)rowIs);
180  *is = rowIs;
182  }
183 
184  /**
185  * get col Is for sub problem
186  * @param is create is
187  * @return error code
188  */
189  inline MoFEMErrorCode getColIs(IS *is) {
191  PetscObjectReference((PetscObject)colIs);
192  *is = colIs;
194  };
195 
196  /**
197  * get row AO mapping for sub problem
198  * @param ao get mapping
199  * @return error code
200  */
201  inline MoFEMErrorCode getRowMap(AO *ao) {
203  PetscObjectReference((PetscObject)rowMap);
204  *ao = rowMap;
206  }
207 
208  /**
209  * get col AO mapping for sub problem
210  * @param ao get mapping
211  * @return error code
212  */
213  inline MoFEMErrorCode getColMap(AO *ao) {
215  PetscObjectReference((PetscObject)colMap);
216  *ao = colMap;
218  }
219 
220  SubProblemData() = default;
221  virtual ~SubProblemData() = default;
222  };
223 
224  /**
225  * Pointer to data structure. This pointer has allocated data only for
226  * sub problems.
227  */
228  mutable boost::shared_ptr<SubProblemData> subProblemData;
229 
230  /**
231  * \brief Get main problem of sub-problem is
232  * @return sub problem data structure
233  */
234  inline boost::shared_ptr<SubProblemData> &getSubData() const {
235  return subProblemData;
236  }
237 
238  /**
239  * Pointer to data structure from which this problem is composed
240  */
241  mutable boost::shared_ptr<ComposedProblemsData> composedProblemsData;
242 
243  /**
244  * \brief Het composed problems data structure
245  */
246  inline boost::shared_ptr<ComposedProblemsData> &
248  return composedProblemsData;
249  }
250 
251  /**
252  * \brief get DOFs from problem
253  *
254  * Note that \e ent_dof_idx is not coefficient number, is local number of DOFs
255  * on the entity. The coefficient number and local index of DOFs or entity are
256  * the same on vertices and H1 approximation.
257  *
258  * @param field_bit_number field name field_bit_number = (use
259  * m_field.get_field_bit_number(field_name);
260  * @param ent entity handle
261  * @param ent_dof_idx index of DOFs on entity
262  * @param row_or_col ROW or COL
263  * @param dof_ptr shared pointer to DOFs if found
264  * @return error code
265  */
267  const int field_bit_number, const EntityHandle ent, const int ent_dof_idx,
268  const RowColData row_or_col,
269  boost::shared_ptr<NumeredDofEntity> &dof_ptr) const;
270 
271 /**
272  * use with loops to iterate problem fes
273  * \ingroup problems_multi_indices
274  *
275  * for(_IT_NUMEREDFE_BY_NAME_FOR_LOOP_(PROBLEMPTR,NAME,IT)) {
276  * ...
277  * }
278  *
279  */
280 #define _IT_NUMEREDFE_BY_NAME_FOR_LOOP_(PROBLEMPTR, NAME, IT) \
281  NumeredEntFiniteElementbyName::iterator IT = \
282  PROBLEMPTR->getNumeredFEsBegin(NAME); \
283  IT != PROBLEMPTR->getNumeredFEsEnd(NAME); \
284  IT++
285 
286  NumeredEntFiniteElementbyName::iterator
287  getNumeredFEsBegin(std::string fe_name) const {
289  .lower_bound(fe_name);
290  }
291 
292  NumeredEntFiniteElementbyName::iterator
293  getNumeredFEsEnd(std::string fe_name) const {
295  .upper_bound(fe_name);
296  }
297 
298 /**
299  * \brief use with loops to iterate row DOFs
300  * \ingroup problems_multi_indices
301  *
302  * \code
303  * for(_IT_NUMEREDDOF_ROW_FOR_LOOP_(PROBLEMPTR,IT)) {
304  * ...
305  * }
306  * \endcode
307  *
308  */
309 #define _IT_NUMEREDDOF_ROW_FOR_LOOP_(PROBLEMPTR, IT) \
310  NumeredDofEntity_multiIndex::iterator IT = \
311  PROBLEMPTR->getNumeredRowDofsBegin(); \
312  IT != PROBLEMPTR->getNumeredRowDofsEnd(); \
313  IT++
314 
315 /**
316  * use with loops to iterate col DOFs
317  * \ingroup problems_multi_indices
318  *
319  * \code
320  * for(_IT_NUMEREDDOF_COL_FOR_LOOP_(PROBLEMPTR,IT)) {
321  * ...
322  * }
323  * \endcode
324  *
325  */
326 #define _IT_NUMEREDDOF_COL_FOR_LOOP_(PROBLEMPTR, IT) \
327  NumeredDofEntity_multiIndex::iterator IT = \
328  PROBLEMPTR->getNumeredColDofsBegin(); \
329  IT != PROBLEMPTR->getNumeredColDofsEnd(); \
330  IT++
331 
332  /// get begin iterator for numeredRowDofsPtr (insted you can use
333  /// #_IT_NUMEREDDOFMOFEMENTITY_ROW_FOR_LOOP_ for loops)
334  NumeredDofEntity_multiIndex::iterator getNumeredRowDofsBegin() const {
335  return numeredRowDofsPtr->begin();
336  }
337 
338  /// get end iterator for numeredRowDofsPtr (insted you can use
339  /// #_IT_NUMEREDDOFMOFEMENTITY_ROW_FOR_LOOP_ for loops)
340  NumeredDofEntity_multiIndex::iterator getNumeredRowDofsEnd() const {
341  return numeredRowDofsPtr->end();
342  }
343 
344  /// get begin iterator for numeredColDofsPtr (insted you can use
345  /// #_IT_NUMEREDDOFMOFEMENTITY_COL_FOR_LOOP_ for loops)
346  NumeredDofEntity_multiIndex::iterator getNumeredColDofsBegin() const {
347  return numeredColDofsPtr->begin();
348  }
349 
350  /// get end iterator for numeredColDofsPtr (insted you can use
351  /// #_IT_NUMEREDDOFMOFEMENTITY_COL_FOR_LOOP_ for loops)
352  NumeredDofEntity_multiIndex::iterator getNumeredColDofsEnd() const {
353  return numeredColDofsPtr->end();
354  }
355 
356 /**
357  * \brief use with loops to iterate row DOFs
358  * \ingroup problems_multi_indices
359  *
360  * \code
361  * for(_IT_NUMEREDDOF_ROW_BY_LOCIDX_FOR_LOOP_(PROBLEMPTR,IT)) {
362  * ...
363  * }
364  * \endcode
365  *
366  */
367 #define _IT_NUMEREDDOF_ROW_BY_LOCIDX_FOR_LOOP_(PROBLEMPTR, IT) \
368  NumeredDofEntityByLocalIdx::iterator IT = \
369  PROBLEMPTR->getNumeredRowDofsByLocIdxBegin(0); \
370  IT != PROBLEMPTR->getNumeredRowDofsByLocIdxEnd( \
371  PROBLEMPTR->getNbLocalDofsRow() - 1); \
372  IT++
373 
374 /**
375  * \brief use with loops to iterate col DOFs
376  *
377  * \code
378  * for(_IT_NUMEREDDOF_COL_BY_LOCIDX_FOR_LOOP_(PROBLEMPTR,IT)) {
379  * ...
380  * }
381  * \endcode
382  *
383  */
384 #define _IT_NUMEREDDOF_COL_BY_LOCIDX_FOR_LOOP_(PROBLEMPTR, IT) \
385  NumeredDofEntityByUId::iterator IT = \
386  PROBLEMPTR->getNumeredColDofsByLocIdxBegin(0); \
387  IT != PROBLEMPTR->getNumeredColDofsByLocIdxEnd( \
388  PROBLEMPTR->getNbLocalDofsRow() - 1); \
389  IT++
390 
391  /// get begin iterator for numeredRowDofsPtr (insted you can use
392  /// #_IT_NUMEREDDOF_ROW_FOR_LOOP_ for loops)
393  NumeredDofEntityByLocalIdx::iterator
395  return numeredRowDofsPtr->get<PetscLocalIdx_mi_tag>().lower_bound(locidx);
396  }
397 
398  /// get end iterator for numeredRowDofsPtr (insted you can use
399  /// #_IT_NUMEREDDOF_ROW_FOR_LOOP_ for loops)
400  NumeredDofEntityByLocalIdx::iterator
401  getNumeredRowDofsByLocIdxEnd(const DofIdx locidx) const {
402  return numeredRowDofsPtr->get<PetscLocalIdx_mi_tag>().upper_bound(locidx);
403  }
404 
405  /// get begin iterator for numeredColDofsPtr (insted you can use
406  /// #_IT_NUMEREDDOF_COL_FOR_LOOP_ for loops)
407  NumeredDofEntityByLocalIdx::iterator
409  return numeredColDofsPtr->get<PetscLocalIdx_mi_tag>().lower_bound(locidx);
410  }
411 
412  /// get end iterator for numeredColDofsPtr (insted you can use
413  /// #_IT_NUMEREDDOF_COL_FOR_LOOP_ for loops)
414  NumeredDofEntityByLocalIdx::iterator
415  getNumeredColDofsByLocIdxEnd(const DofIdx locidx) const {
416  return numeredColDofsPtr->get<PetscLocalIdx_mi_tag>().upper_bound(locidx);
417  }
418 
419 /**
420  * \brief use with loops to iterate row DOFs
421  * \ingroup problems_multi_indices
422  *
423  * \code
424  * for(_IT_NUMEREDDOF_BY_ENT_ROW_FOR_LOOP_(PROBLEMPTR,ENT,IT)) {
425  * ...
426  * }
427  * \endcode
428  *
429  */
430 #define _IT_NUMEREDDOF_ROW_BY_ENT_FOR_LOOP_(PROBLEMPTR, ENT, IT) \
431  NumeredDofEntityByEnt::iterator IT = \
432  PROBLEMPTR->getNumeredRowDofsByEntBegin(ENT); \
433  IT != PROBLEMPTR->getNumeredRowDofsByEntEnd(ENT); \
434  IT++
435 
436 /**
437  * \brief use with loops to iterate col DOFs
438  * \ingroup problems_multi_indices
439  *
440  * \code
441  * for(_IT_NUMEREDDOF_COL_BY_ENT_FOR_LOOP_(PROBLEMPTR,ENT,IT)) {
442  * ...
443  * }
444  * \endcode
445  *
446  */
447 #define _IT_NUMEREDDOF_COL_BY_ENT_FOR_LOOP_(PROBLEMPTR, ENT, IT) \
448  NumeredDofEntityByEnt::iterator IT = \
449  PROBLEMPTR->getNumeredColDofsByEntBegin(ENT); \
450  IT != PROBLEMPTR->getNumeredColDofsByEntEnd(ENT); \
451  IT++
452 
453  /// get begin iterator for numeredRowDofsPtr (insted you can use
454  /// #_IT_NUMEREDDOF_ROW_BY_ENT_FOR_LOOP_ for loops)
455  NumeredDofEntityByEnt::iterator
456  getNumeredRowDofsByEntBegin(const EntityHandle ent) const {
457  return numeredRowDofsPtr->get<Ent_mi_tag>().lower_bound(ent);
458  }
459 
460  /// get end iterator for numeredRowDofsPtr (insted you can use
461  /// #_IT_NUMEREDDOF_ROW_BY_ENT_FOR_LOOP_ for loops)
462  NumeredDofEntityByEnt::iterator
463  getNumeredRowDofsByEntEnd(const EntityHandle ent) const {
464  return numeredRowDofsPtr->get<Ent_mi_tag>().upper_bound(ent);
465  }
466 
467  /// get begin iterator for numeredColDofsPtr (insted you can use
468  /// #_IT_NUMEREDDOF_COL_BY_ENT_FOR_LOOP_ for loops)
469  NumeredDofEntityByEnt::iterator
470  getNumeredColDofsByEntBegin(const EntityHandle ent) const {
471  return numeredColDofsPtr->get<Ent_mi_tag>().lower_bound(ent);
472  }
473 
474  /// get end iterator for numeredColDofsPtr (insted you can use
475  /// #_IT_NUMEREDDOF_COL_BY_ENT_FOR_LOOP_ for loops)
476  NumeredDofEntityByEnt::iterator
477  getNumeredColDofsByEntEnd(const EntityHandle ent) const {
478  return numeredColDofsPtr->get<Ent_mi_tag>().upper_bound(ent);
479  }
480 
481 /**
482  * use with loops to iterate row DOFs
483  * \ingroup problems_multi_indices
484  *
485  * \code
486  * for(_IT_NUMEREDDOF_BY_NAME_ROW_FOR_LOOP_(PROBLEMPTR,m_field.get_field_bit_number(FIELD_BIT_NUMBER),IT))
487  * {
488  * ...
489  * }
490  * \endcode
491  *
492  */
493 #define _IT_NUMEREDDOF_ROW_BY_BITNUMBER_FOR_LOOP_(PROBLEMPTR, \
494  FIELD_BIT_NUMBER, IT) \
495  auto IT = PROBLEMPTR->numeredRowDofsPtr->lower_bound( \
496  FieldEntity::getLoBitNumberUId(FIELD_BIT_NUMBER)); \
497  IT != PROBLEMPTR->numeredRowDofsPtr->upper_bound( \
498  FieldEntity::getHiBitNumberUId(FIELD_BIT_NUMBER)); \
499  IT++
500 
501 /**
502  * \brief use with loops to iterate col DOFs
503  * \ingroup problems_multi_indices
504  *
505  * \code
506  * for(_IT_NUMEREDDOF_COL_BY_BITNUMBER_FOR_LOOP_(PROBLEMPTR,m_field.get_field_bit_number(FIELD_BIT_NUMBER),IT))
507  * {
508  * ...
509  * }
510  * \endcode
511  *
512  */
513 #define _IT_NUMEREDDOF_COL_BY_BITNUMBER_FOR_LOOP_(PROBLEMPTR, \
514  FIELD_BIT_NUMBER, IT) \
515  auto IT = PROBLEMPTR->numeredColDofsPtr->lower_bound( \
516  FieldEntity::getLoBitNumberUId(FIELD_BIT_NUMBER)); \
517  IT != PROBLEMPTR->numeredColDofsPtr->upper_bound( \
518  FieldEntity::getHiBitNumberUId(FIELD_BIT_NUMBER)); \
519  IT++
520 
521  Problem(Interface &moab, const EntityHandle meshset);
522 
523  virtual ~Problem() = default;
524 
525  inline BitProblemId getId() const { return *((BitProblemId *)tagId); }
526 
527  inline std::string getName() const {
528  return std::string((char *)tagName, tagNameSize);
529  }
530 
531  inline DofIdx getNbDofsRow() const { return nbDofsRow; }
532  inline DofIdx getNbDofsCol() const { return nbDofsCol; }
533  inline DofIdx getNbLocalDofsRow() const { return nbLocDofsRow; }
534  inline DofIdx getNbLocalDofsCol() const { return nbLocDofsCol; }
535  inline DofIdx getNbGhostDofsRow() const { return nbGhostDofsRow; }
536  inline DofIdx getNbGhostDofsCol() const { return nbGhostDofsCol; }
537 
538  inline BitRefLevel getBitRefLevel() const { return *tagBitRefLevel; }
540 
541  /**
542  * @brief Get the Row Dofs By Petsc Global Dof Idx object
543  *
544  * @param idx
545  * @param dof_ptr
546  * @param bh
547  * @return MoFEMErrorCode
548  */
550  const NumeredDofEntity **dof_ptr,
551  MoFEMTypes bh = MF_EXIST) const;
552 
553  /**
554  * @brief Get the Col Dofs By Petsc Global Dof Idx object
555  *
556  * @param idx
557  * @param dof_ptr
558  * @param bh
559  * @return MoFEMErrorCode
560  */
562  const NumeredDofEntity **dof_ptr,
563  MoFEMTypes bh = MF_EXIST) const;
564 
565  /**
566  * @brief Get the Row Dofs By Petsc Global Dof Idx object
567  *
568  * @param idx
569  * @return boost::weak_ptr<NumeredDofEntity>
570  */
571  boost::weak_ptr<NumeredDofEntity>
573 
574  /**
575  * @brief Get the Col Dofs By Petsc Global Dof Idx object
576  *
577  * @param idx
578  * @return boost::weak_ptr<NumeredDofEntity>
579  */
580  boost::weak_ptr<NumeredDofEntity>
582 
583  BitFEId getBitFEId() const;
584 
585  friend std::ostream &operator<<(std::ostream &os, const Problem &e);
586 
587  /**
588  * \brief Get number of finite elements by name on processors
589  *
590  * Size retuned IS is equal to size of processors.
591  *
592  * What PetscLayout see,
593  <http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/IS/index.html>
594  *
595  * Example of usage for layout
596  * \code
597 
598  PetscInt rstart, rend;
599  ierr = PetscLayoutGetRange(layout, &rstart, &rend); CHKERRG(ierr);
600  int global_size;
601  ierr = PetscLayoutGetSize(layout,&global_size); CHKERRG(ierr);
602 
603  \endcode
604  *
605  * @param comm Communicator
606  * @param name Finite element name
607  * @param layout Get number of elements on each processor
608  * @return error code
609  */
611  const std::string name,
612  PetscLayout *layout) const;
613 
614  /**
615  * \brief Get number of finite elements on processors
616  *
617  * Size retuned IS is equal to size of processors.
618  *
619  * What PetscLayout see,
620  <http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/IS/index.html>
621  *
622  * Example of usage for layout
623  * \code
624 
625  PetscInt rstart, rend;
626  ierr = PetscLayoutGetRange(layout, &rstart, &rend); CHKERRG(ierr);
627  int global_size;
628  ierr = PetscLayoutGetSize(layout,&global_size); CHKERRG(ierr);
629 
630  \endcode
631  *
632  * @param comm Communicator
633  * @param layout Get number of elements on each processor
634  * @return error code
635  */
637  PetscLayout *layout) const;
638 
639  typedef multi_index_container<boost::weak_ptr<std::vector<NumeredDofEntity>>,
640  indexed_by<sequenced<>>>
642 
643  /**
644  * \brief Get reference to sequence data numbered dof container
645  *
646  * In sequence data container data are physically stored. The purpose of this
647  * is to allocate NumeredDofEntity data in bulk, having only one allocation
648  instead
649  * each time entity is inserted. That makes code efficient.
650  *
651  * The vector in sequence is destroyed if last entity inside that vector is
652  * destroyed. All MoFEM::NumeredDofEntity have aliased shared_ptr which points
653  to the vector.
654 
655  * @return MoFEM::Problem::SequenceDofContainer
656  */
657  inline boost::shared_ptr<SequenceDofContainer> &getRowDofsSequence() const {
659  }
660 
661  /**
662  * \brief Get reference to sequence data numbered dof container
663  *
664  * In sequence data container data are physically stored. The purpose of this
665  * is to allocate NumeredDofEntity data in bulk, having only one allocation
666  instead
667  * each time entity is inserted. That makes code efficient.
668  *
669  * The vector in sequence is destroyed if last entity inside that vector is
670  * destroyed. All MoFEM::NumeredDofEntity have aliased shared_ptr which points
671  to the vector.
672 
673  * @return MoFEM::Problem::SequenceDofContainer
674  */
675  inline boost::shared_ptr<SequenceDofContainer> &getColDofsSequence() const {
677  }
678 
679 private:
680  // Keep vector of DoFS on entity
681  mutable boost::shared_ptr<SequenceDofContainer> sequenceRowDofContainer;
682  mutable boost::shared_ptr<SequenceDofContainer> sequenceColDofContainer;
683 };
684 
685 /// \deprecated use just Problem
687 
688 /**
689  * @relates multi_index_container
690  * \brief MultiIndex for entities for Problem
691  * \ingroup fe_multi_indices
692  */
693 typedef multi_index_container<
694  Problem,
695  indexed_by<
696  ordered_unique<tag<Meshset_mi_tag>,
697  member<Problem, EntityHandle, &Problem::meshset>>,
698  hashed_unique<tag<BitProblemId_mi_tag>,
699  const_mem_fun<Problem, BitProblemId, &Problem::getId>,
701  hashed_unique<tag<Problem_mi_tag>,
702  const_mem_fun<Problem, std::string, &Problem::getName>>>>
704 
705 /** \brief add ref level to problem
706  * \ingroup problems_multi_indices
707  */
711  void operator()(Problem &p) { *(p.tagBitRefLevel) |= bit; };
712 };
713 
714 /** \brief set ref level to problem
715  * \ingroup problems_multi_indices
716  */
720  void operator()(Problem &p) { *(p.tagBitRefLevel) = bit; };
721 };
722 
723 /** \brief set prof dof bit ref mask
724  * \ingroup problems_multi_indices
725  */
729  void operator()(Problem &p) { *(p.tagMaskBitRefLevel) = bit; };
730 };
731 
732 /** \brief add finite element to problem
733  * \ingroup problems_multi_indices
734  */
738  void operator()(Problem &p);
739 };
740 
741 /** \brief set prof dof bit ref mask
742  * \ingroup problems_multi_indices
743  */
747  void operator()(Problem &p) { *(p.tagMaskBitRefLevel) |= bit; };
748 };
749 
750 /** \brief remove finite element from problem
751  * \ingroup problems_multi_indices
752  */
756  void operator()(Problem &p);
757 };
758 
759 /** \brief zero nb. of DOFs in row
760  * \ingroup problems_multi_indices
761  */
763  void operator()(Problem &e);
764 };
765 
766 /** \brief zero nb. of DOFs in col
767  * \ingroup problems_multi_indices
768  */
770  void operator()(Problem &e);
771 };
772 
773 /** \brief clear problem finite elements
774  * \ingroup problems_multi_indices
775  */
777  void operator()(Problem &e);
778 };
779 
780 /**
781  * \brief Clear sub-problem data structure
782  */
784  void operator()(Problem &e) { e.subProblemData.reset(); }
785 };
786 
787 /**
788  * \brief Clear composed problem data structure
789  */
791  void operator()(Problem &e) { e.composedProblemsData.reset(); }
792 };
793 
794 } // namespace MoFEM
795 
796 #endif //__PROBLEMSMULTIINDICES_HPP__
797 
798 /**
799  * \defgroup problems_multi_indices Problems structures and multi-indices
800  * \ingroup mofem
801  ******************************************************************************/
static Index< 'p', 3 > p
RowColData
RowColData.
Definition: definitions.h:192
MoFEMTypes
Those types control how functions respond on arguments, f.e. error handling.
Definition: definitions.h:189
@ MF_EXIST
Definition: definitions.h:189
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:516
@ MOFEM_INVALID_DATA
Definition: definitions.h:128
#define DEPRECATED
Definition: definitions.h:29
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:509
multi_index_container< Problem, indexed_by< ordered_unique< tag< Meshset_mi_tag >, member< Problem, EntityHandle, &Problem::meshset > >, hashed_unique< tag< BitProblemId_mi_tag >, const_mem_fun< Problem, BitProblemId, &Problem::getId >, HashBit< BitProblemId >, EqBit< BitProblemId > >, hashed_unique< tag< Problem_mi_tag >, const_mem_fun< Problem, std::string, &Problem::getName > > > > Problem_multiIndex
MultiIndex for entities for Problem.
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
Definition: Exceptions.hpp:67
std::bitset< BITFEID_SIZE > BitFEId
Finite element Id.
Definition: Types.hpp:54
int DofIdx
Index of DOF.
Definition: Types.hpp:29
std::bitset< BITPROBLEMID_SIZE > BitProblemId
Problem Id.
Definition: Types.hpp:55
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
Definition: Types.hpp:51
implementation of Data Operators for Forces and Sources
Definition: Common.hpp:21
DEPRECATED typedef Problem MoFEMProblem
DeprecatedCoreInterface Interface
Definition: Interface.hpp:1943
std::vector< const Problem * > rowProblemsAdd
MoFEMErrorCode getRowIs(IS *is, const unsigned int pp) const
MoFEMErrorCode getColIs(IS *is, const unsigned int pp) const
std::vector< const Problem * > colProblemsAdd
keeps information about indexed dofs for the problem
SmartPetscObj< AO > rowMap
mapping form main problem indices to sub-problem indices
virtual ~SubProblemData()=default
SmartPetscObj< IS > rowIs
indices of main problem of which sub problem is this
SmartPetscObj< AO > colMap
mapping form main problem indices to sub-problem indices
SmartPetscObj< IS > colIs
indices of main problem of which sub problem is this
ProblemChangeRefLevelBitAdd(const BitRefLevel _bit)
ProblemChangeRefLevelBitDofMaskAdd(const BitRefLevel _bit)
ProblemChangeRefLevelBitDofMaskSet(const BitRefLevel _bit)
ProblemChangeRefLevelBitSet(const BitRefLevel _bit)
Clear composed problem data structure.
Clear sub-problem data structure.
remove finite element from problem
keeps basic data about problem
MoFEMErrorCode getNumberOfElementsByPart(MPI_Comm comm, PetscLayout *layout) const
Get number of finite elements on processors.
NumeredDofEntity_multiIndex::iterator getNumeredRowDofsBegin() const
BitRefLevel getMaskBitRefLevel() const
std::string getName() const
const boost::shared_ptr< NumeredEntFiniteElement_multiIndex > & getNumeredFiniteElementsPtr() const
get access to reference for multi-index storing finite elements
NumeredDofEntityByEnt::iterator getNumeredColDofsByEntBegin(const EntityHandle ent) const
DofIdx getNbLocalDofsRow() const
MoFEMErrorCode getNumberOfElementsByNameAndPart(MPI_Comm comm, const std::string name, PetscLayout *layout) const
Get number of finite elements by name on processors.
DofIdx getNbDofsRow() const
const char * tagName
Problem name.
BitRefLevel getBitRefLevel() const
boost::shared_ptr< SequenceDofContainer > sequenceColDofContainer
BitProblemId * tagId
Unique problem ID.
MoFEMErrorCode getDofByNameEntAndEntDofIdx(const int field_bit_number, const EntityHandle ent, const int ent_dof_idx, const RowColData row_or_col, boost::shared_ptr< NumeredDofEntity > &dof_ptr) const
get DOFs from problem
virtual ~Problem()=default
BitRefLevel * tagMaskBitRefLevel
BItRefMask of elements in problem.
boost::shared_ptr< ComposedProblemsData > & getComposedProblemsData() const
Het composed problems data structure.
NumeredDofEntityByEnt::iterator getNumeredRowDofsByEntEnd(const EntityHandle ent) const
NumeredDofEntityByLocalIdx::iterator getNumeredRowDofsByLocIdxEnd(const DofIdx locidx) const
DofIdx nbGhostDofsCol
Number of ghost DOFs in col.
boost::shared_ptr< NumeredDofEntity_multiIndex > numeredRowDofsPtr
store DOFs on rows for this problem
boost::shared_ptr< NumeredDofEntity_multiIndex > & getNumeredColDofsPtr() const
get access to numeredColDofsPtr storing DOFs on cols
boost::shared_ptr< NumeredEntFiniteElement_multiIndex > numeredFiniteElementsPtr
store finite elements
NumeredDofEntity_multiIndex::iterator getNumeredRowDofsEnd() const
const boost::shared_ptr< NumeredEntFiniteElement_multiIndex > &DEPRECATED getNumeredFiniteElements() const
get access to reference for multi-index storing finite elements
DEPRECATED boost::shared_ptr< NumeredDofEntity_multiIndex > & getNumeredRowDofs() const
get access to numeredRowDofsPtr storing DOFs on rows \deprected Use getNumeredRowDofsPtr
Problem(Interface &moab, const EntityHandle meshset)
boost::shared_ptr< SequenceDofContainer > sequenceRowDofContainer
MoFEMErrorCode getRowDofsByPetscGlobalDofIdx(DofIdx idx, const NumeredDofEntity **dof_ptr, MoFEMTypes bh=MF_EXIST) const
Get the Row Dofs By Petsc Global Dof Idx object.
boost::shared_ptr< ComposedProblemsData > composedProblemsData
NumeredDofEntityByLocalIdx::iterator getNumeredRowDofsByLocIdxBegin(const DofIdx locidx) const
boost::shared_ptr< SequenceDofContainer > & getRowDofsSequence() const
Get reference to sequence data numbered dof container.
boost::shared_ptr< SequenceDofContainer > & getColDofsSequence() const
Get reference to sequence data numbered dof container.
DofIdx getNbGhostDofsCol() const
boost::shared_ptr< NumeredDofEntity_multiIndex > & getNumeredRowDofsPtr() const
get access to numeredRowDofsPtr storing DOFs on rows
DofIdx nbLocDofsRow
Local number of DOFs in row.
BitFEId getBitFEId() const
BitProblemId getId() const
DofIdx nbDofsCol
Global number of DOFs in col.
boost::shared_ptr< SubProblemData > & getSubData() const
Get main problem of sub-problem is.
DofIdx getNbDofsCol() const
DofIdx getNbLocalDofsCol() const
DofIdx nbGhostDofsRow
Number of ghost DOFs in row.
boost::shared_ptr< SubProblemData > subProblemData
DEPRECATED boost::shared_ptr< NumeredDofEntity_multiIndex > & getNumeredColDofs() const
get access to numeredColDofsPtr storing DOFs on cols
DofIdx nbLocDofsCol
Local number of DOFs in colIs.
NumeredEntFiniteElementbyName::iterator getNumeredFEsEnd(std::string fe_name) const
int tagNameSize
Size of problem name.
MoFEMErrorCode getColDofsByPetscGlobalDofIdx(DofIdx idx, const NumeredDofEntity **dof_ptr, MoFEMTypes bh=MF_EXIST) const
Get the Col Dofs By Petsc Global Dof Idx object.
BitFEId * tagBitFEId
IDs of finite elements in problem.
NumeredDofEntityByEnt::iterator getNumeredRowDofsByEntBegin(const EntityHandle ent) const
NumeredDofEntityByEnt::iterator getNumeredColDofsByEntEnd(const EntityHandle ent) const
NumeredDofEntity_multiIndex::iterator getNumeredColDofsEnd() const
DofIdx nbDofsRow
Global number of DOFs in row.
DofIdx getNbGhostDofsRow() const
multi_index_container< boost::weak_ptr< std::vector< NumeredDofEntity > >, indexed_by< sequenced<> > > SequenceDofContainer
boost::shared_ptr< NumeredDofEntity_multiIndex > numeredColDofsPtr
store DOFs on columns for this problem
NumeredEntFiniteElementbyName::iterator getNumeredFEsBegin(std::string fe_name) const
friend std::ostream & operator<<(std::ostream &os, const Problem &e)
BitRefLevel * tagBitRefLevel
BitRef level of finite elements in problem.
NumeredDofEntity_multiIndex::iterator getNumeredColDofsBegin() const
NumeredDofEntityByLocalIdx::iterator getNumeredColDofsByLocIdxBegin(const DofIdx locidx) const
NumeredDofEntityByLocalIdx::iterator getNumeredColDofsByLocIdxEnd(const DofIdx locidx) const