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 
158  IS rowIs; ///< indices of main problem of which sub problem is this
159  IS colIs; ///< indices of main problem of which sub problem is this
160  AO rowMap; ///< mapping form main problem indices to sub-problem indices
161  AO colMap;
162 
163  /**
164  * get row Is for sub problem
165  * @param is create is
166  * @return error code
167  */
168  inline MoFEMErrorCode getRowIs(IS *is) {
170  PetscObjectReference((PetscObject)rowIs);
171  *is = rowIs;
173  }
174 
175  /**
176  * get col Is for sub problem
177  * @param is create is
178  * @return error code
179  */
180  inline MoFEMErrorCode getColIs(IS *is) {
182  PetscObjectReference((PetscObject)colIs);
183  *is = colIs;
185  };
186 
187  /**
188  * get row AO mapping for sub problem
189  * @param ao get mapping
190  * @return error code
191  */
192  inline MoFEMErrorCode getRowMap(AO *ao) {
194  PetscObjectReference((PetscObject)rowMap);
195  *ao = rowMap;
197  }
198 
199  /**
200  * get col AO mapping for sub problem
201  * @param ao get mapping
202  * @return error code
203  */
204  inline MoFEMErrorCode getColMap(AO *ao) {
206  PetscObjectReference((PetscObject)colMap);
207  *ao = colMap;
209  }
210 
212  : rowIs(PETSC_NULL), colIs(PETSC_NULL), rowMap(PETSC_NULL),
213  colMap(PETSC_NULL) {}
214  virtual ~SubProblemData() {
215  // int flg;
216  // MPI_Finalized(&flg);
217  // if(!flg) {
218  ISDestroy(&rowIs);
219  ISDestroy(&colIs);
220  AODestroy(&rowMap);
221  AODestroy(&colMap);
222  // }
223  }
224  };
225 
226  /**
227  * Pointer to data structure. This pointer has allocated data only for
228  * sub problems.
229  */
230  mutable boost::shared_ptr<SubProblemData> subProblemData;
231 
232  /**
233  * \brief Get main problem of sub-problem is
234  * @return sub problem data structure
235  */
236  inline boost::shared_ptr<SubProblemData> &getSubData() const {
237  return subProblemData;
238  }
239 
240  /**
241  * Pointer to data structure from which this problem is composed
242  */
243  mutable boost::shared_ptr<ComposedProblemsData> composedProblemsData;
244 
245  /**
246  * \brief Het composed problems data structure
247  */
248  inline boost::shared_ptr<ComposedProblemsData> &
250  return composedProblemsData;
251  }
252 
253  /**
254  * \brief get DOFs from problem
255  *
256  * Note that \e ent_dof_idx is not coefficient number, is local number of DOFs
257  * on the entity. The coefficient number and local index of DOFs or entity are
258  * the same on vertices and H1 approximation.
259  *
260  * @param field_bit_number field name field_bit_number = (use
261  * m_field.get_field_bit_number(field_name);
262  * @param ent entity handle
263  * @param ent_dof_idx index of DOFs on entity
264  * @param row_or_col ROW or COL
265  * @param dof_ptr shared pointer to DOFs if found
266  * @return error code
267  */
269  const int field_bit_number, const EntityHandle ent, const int ent_dof_idx,
270  const RowColData row_or_col,
271  boost::shared_ptr<NumeredDofEntity> &dof_ptr) const;
272 
273 /**
274  * use with loops to iterate problem fes
275  * \ingroup problems_multi_indices
276  *
277  * for(_IT_NUMEREDFE_BY_NAME_FOR_LOOP_(PROBLEMPTR,NAME,IT)) {
278  * ...
279  * }
280  *
281  */
282 #define _IT_NUMEREDFE_BY_NAME_FOR_LOOP_(PROBLEMPTR, NAME, IT) \
283  NumeredEntFiniteElementbyName::iterator IT = \
284  PROBLEMPTR->getNumeredFEsBegin(NAME); \
285  IT != PROBLEMPTR->getNumeredFEsEnd(NAME); \
286  IT++
287 
288  NumeredEntFiniteElementbyName::iterator
289  getNumeredFEsBegin(std::string fe_name) const {
291  .lower_bound(fe_name);
292  }
293 
294  NumeredEntFiniteElementbyName::iterator
295  getNumeredFEsEnd(std::string fe_name) const {
297  .upper_bound(fe_name);
298  }
299 
300 /**
301  * \brief use with loops to iterate row DOFs
302  * \ingroup problems_multi_indices
303  *
304  * \code
305  * for(_IT_NUMEREDDOF_ROW_FOR_LOOP_(PROBLEMPTR,IT)) {
306  * ...
307  * }
308  * \endcode
309  *
310  */
311 #define _IT_NUMEREDDOF_ROW_FOR_LOOP_(PROBLEMPTR, IT) \
312  NumeredDofEntity_multiIndex::iterator IT = \
313  PROBLEMPTR->getNumeredRowDofsBegin(); \
314  IT != PROBLEMPTR->getNumeredRowDofsEnd(); \
315  IT++
316 
317 /**
318  * use with loops to iterate col DOFs
319  * \ingroup problems_multi_indices
320  *
321  * \code
322  * for(_IT_NUMEREDDOF_COL_FOR_LOOP_(PROBLEMPTR,IT)) {
323  * ...
324  * }
325  * \endcode
326  *
327  */
328 #define _IT_NUMEREDDOF_COL_FOR_LOOP_(PROBLEMPTR, IT) \
329  NumeredDofEntity_multiIndex::iterator IT = \
330  PROBLEMPTR->getNumeredColDofsBegin(); \
331  IT != PROBLEMPTR->getNumeredColDofsEnd(); \
332  IT++
333 
334  /// get begin iterator for numeredRowDofsPtr (insted you can use
335  /// #_IT_NUMEREDDOFMOFEMENTITY_ROW_FOR_LOOP_ for loops)
336  NumeredDofEntity_multiIndex::iterator getNumeredRowDofsBegin() const {
337  return numeredRowDofsPtr->begin();
338  }
339 
340  /// get end iterator for numeredRowDofsPtr (insted you can use
341  /// #_IT_NUMEREDDOFMOFEMENTITY_ROW_FOR_LOOP_ for loops)
342  NumeredDofEntity_multiIndex::iterator getNumeredRowDofsEnd() const {
343  return numeredRowDofsPtr->end();
344  }
345 
346  /// get begin iterator for numeredColDofsPtr (insted you can use
347  /// #_IT_NUMEREDDOFMOFEMENTITY_COL_FOR_LOOP_ for loops)
348  NumeredDofEntity_multiIndex::iterator getNumeredColDofsBegin() const {
349  return numeredColDofsPtr->begin();
350  }
351 
352  /// get end iterator for numeredColDofsPtr (insted you can use
353  /// #_IT_NUMEREDDOFMOFEMENTITY_COL_FOR_LOOP_ for loops)
354  NumeredDofEntity_multiIndex::iterator getNumeredColDofsEnd() const {
355  return numeredColDofsPtr->end();
356  }
357 
358 /**
359  * \brief use with loops to iterate row DOFs
360  * \ingroup problems_multi_indices
361  *
362  * \code
363  * for(_IT_NUMEREDDOF_ROW_BY_LOCIDX_FOR_LOOP_(PROBLEMPTR,IT)) {
364  * ...
365  * }
366  * \endcode
367  *
368  */
369 #define _IT_NUMEREDDOF_ROW_BY_LOCIDX_FOR_LOOP_(PROBLEMPTR, IT) \
370  NumeredDofEntityByLocalIdx::iterator IT = \
371  PROBLEMPTR->getNumeredRowDofsByLocIdxBegin(0); \
372  IT != PROBLEMPTR->getNumeredRowDofsByLocIdxEnd( \
373  PROBLEMPTR->getNbLocalDofsRow() - 1); \
374  IT++
375 
376 /**
377  * \brief use with loops to iterate col DOFs
378  *
379  * \code
380  * for(_IT_NUMEREDDOF_COL_BY_LOCIDX_FOR_LOOP_(PROBLEMPTR,IT)) {
381  * ...
382  * }
383  * \endcode
384  *
385  */
386 #define _IT_NUMEREDDOF_COL_BY_LOCIDX_FOR_LOOP_(PROBLEMPTR, IT) \
387  NumeredDofEntityByUId::iterator IT = \
388  PROBLEMPTR->getNumeredColDofsByLocIdxBegin(0); \
389  IT != PROBLEMPTR->getNumeredColDofsByLocIdxEnd( \
390  PROBLEMPTR->getNbLocalDofsRow() - 1); \
391  IT++
392 
393  /// get begin iterator for numeredRowDofsPtr (insted you can use
394  /// #_IT_NUMEREDDOF_ROW_FOR_LOOP_ for loops)
395  NumeredDofEntityByLocalIdx::iterator
397  return numeredRowDofsPtr->get<PetscLocalIdx_mi_tag>().lower_bound(locidx);
398  }
399 
400  /// get end iterator for numeredRowDofsPtr (insted you can use
401  /// #_IT_NUMEREDDOF_ROW_FOR_LOOP_ for loops)
402  NumeredDofEntityByLocalIdx::iterator
403  getNumeredRowDofsByLocIdxEnd(const DofIdx locidx) const {
404  return numeredRowDofsPtr->get<PetscLocalIdx_mi_tag>().upper_bound(locidx);
405  }
406 
407  /// get begin iterator for numeredColDofsPtr (insted you can use
408  /// #_IT_NUMEREDDOF_COL_FOR_LOOP_ for loops)
409  NumeredDofEntityByLocalIdx::iterator
411  return numeredColDofsPtr->get<PetscLocalIdx_mi_tag>().lower_bound(locidx);
412  }
413 
414  /// get end iterator for numeredColDofsPtr (insted you can use
415  /// #_IT_NUMEREDDOF_COL_FOR_LOOP_ for loops)
416  NumeredDofEntityByLocalIdx::iterator
417  getNumeredColDofsByLocIdxEnd(const DofIdx locidx) const {
418  return numeredColDofsPtr->get<PetscLocalIdx_mi_tag>().upper_bound(locidx);
419  }
420 
421 /**
422  * \brief use with loops to iterate row DOFs
423  * \ingroup problems_multi_indices
424  *
425  * \code
426  * for(_IT_NUMEREDDOF_BY_ENT_ROW_FOR_LOOP_(PROBLEMPTR,ENT,IT)) {
427  * ...
428  * }
429  * \endcode
430  *
431  */
432 #define _IT_NUMEREDDOF_ROW_BY_ENT_FOR_LOOP_(PROBLEMPTR, ENT, IT) \
433  NumeredDofEntityByEnt::iterator IT = \
434  PROBLEMPTR->getNumeredRowDofsByEntBegin(ENT); \
435  IT != PROBLEMPTR->getNumeredRowDofsByEntEnd(ENT); \
436  IT++
437 
438 /**
439  * \brief use with loops to iterate col DOFs
440  * \ingroup problems_multi_indices
441  *
442  * \code
443  * for(_IT_NUMEREDDOF_COL_BY_ENT_FOR_LOOP_(PROBLEMPTR,ENT,IT)) {
444  * ...
445  * }
446  * \endcode
447  *
448  */
449 #define _IT_NUMEREDDOF_COL_BY_ENT_FOR_LOOP_(PROBLEMPTR, ENT, IT) \
450  NumeredDofEntityByEnt::iterator IT = \
451  PROBLEMPTR->getNumeredColDofsByEntBegin(ENT); \
452  IT != PROBLEMPTR->getNumeredColDofsByEntEnd(ENT); \
453  IT++
454 
455  /// get begin iterator for numeredRowDofsPtr (insted you can use
456  /// #_IT_NUMEREDDOF_ROW_BY_ENT_FOR_LOOP_ for loops)
457  NumeredDofEntityByEnt::iterator
459  return numeredRowDofsPtr->get<Ent_mi_tag>().lower_bound(ent);
460  }
461 
462  /// get end iterator for numeredRowDofsPtr (insted you can use
463  /// #_IT_NUMEREDDOF_ROW_BY_ENT_FOR_LOOP_ for loops)
464  NumeredDofEntityByEnt::iterator
466  return numeredRowDofsPtr->get<Ent_mi_tag>().upper_bound(ent);
467  }
468 
469  /// get begin iterator for numeredColDofsPtr (insted you can use
470  /// #_IT_NUMEREDDOF_COL_BY_ENT_FOR_LOOP_ for loops)
471  NumeredDofEntityByEnt::iterator
473  return numeredColDofsPtr->get<Ent_mi_tag>().lower_bound(ent);
474  }
475 
476  /// get end iterator for numeredColDofsPtr (insted you can use
477  /// #_IT_NUMEREDDOF_COL_BY_ENT_FOR_LOOP_ for loops)
478  NumeredDofEntityByEnt::iterator
480  return numeredColDofsPtr->get<Ent_mi_tag>().upper_bound(ent);
481  }
482 
483 /**
484  * use with loops to iterate row DOFs
485  * \ingroup problems_multi_indices
486  *
487  * \code
488  * for(_IT_NUMEREDDOF_BY_NAME_ROW_FOR_LOOP_(PROBLEMPTR,m_field.get_field_bit_number(FIELD_BIT_NUMBER),IT))
489  * {
490  * ...
491  * }
492  * \endcode
493  *
494  */
495 #define _IT_NUMEREDDOF_ROW_BY_BITNUMBER_FOR_LOOP_(PROBLEMPTR, \
496  FIELD_BIT_NUMBER, IT) \
497  auto IT = PROBLEMPTR->numeredRowDofsPtr->lower_bound( \
498  FieldEntity::getLoBitNumberUId(FIELD_BIT_NUMBER)); \
499  IT != PROBLEMPTR->numeredRowDofsPtr->upper_bound( \
500  FieldEntity::getHiBitNumberUId(FIELD_BIT_NUMBER)); \
501  IT++
502 
503 /**
504  * \brief use with loops to iterate col DOFs
505  * \ingroup problems_multi_indices
506  *
507  * \code
508  * for(_IT_NUMEREDDOF_COL_BY_BITNUMBER_FOR_LOOP_(PROBLEMPTR,m_field.get_field_bit_number(FIELD_BIT_NUMBER),IT))
509  * {
510  * ...
511  * }
512  * \endcode
513  *
514  */
515 #define _IT_NUMEREDDOF_COL_BY_BITNUMBER_FOR_LOOP_(PROBLEMPTR, \
516  FIELD_BIT_NUMBER, IT) \
517  auto IT = PROBLEMPTR->numeredColDofsPtr->lower_bound( \
518  FieldEntity::getLoBitNumberUId(FIELD_BIT_NUMBER)); \
519  IT != PROBLEMPTR->numeredColDofsPtr->upper_bound( \
520  FieldEntity::getHiBitNumberUId(FIELD_BIT_NUMBER)); \
521  IT++
522 
523  Problem(Interface &moab, const EntityHandle meshset);
524 
525  virtual ~Problem() = default;
526 
527  inline BitProblemId getId() const { return *((BitProblemId *)tagId); }
528 
529  inline std::string getName() const {
530  return std::string((char *)tagName, tagNameSize);
531  }
532 
533  inline DofIdx getNbDofsRow() const { return nbDofsRow; }
534  inline DofIdx getNbDofsCol() const { return nbDofsCol; }
535  inline DofIdx getNbLocalDofsRow() const { return nbLocDofsRow; }
536  inline DofIdx getNbLocalDofsCol() const { return nbLocDofsCol; }
537  inline DofIdx getNbGhostDofsRow() const { return nbGhostDofsRow; }
538  inline DofIdx getNbGhostDofsCol() const { return nbGhostDofsCol; }
539 
540  inline BitRefLevel getBitRefLevel() const { return *tagBitRefLevel; }
542 
543  /**
544  * @brief Get the Row Dofs By Petsc Global Dof Idx object
545  *
546  * @param idx
547  * @param dof_ptr
548  * @param bh
549  * @return MoFEMErrorCode
550  */
552  const NumeredDofEntity **dof_ptr,
553  MoFEMTypes bh = MF_EXIST) const;
554 
555  /**
556  * @brief Get the Col Dofs By Petsc Global Dof Idx object
557  *
558  * @param idx
559  * @param dof_ptr
560  * @param bh
561  * @return MoFEMErrorCode
562  */
564  const NumeredDofEntity **dof_ptr,
565  MoFEMTypes bh = MF_EXIST) const;
566 
567  /**
568  * @brief Get the Row Dofs By Petsc Global Dof Idx object
569  *
570  * @param idx
571  * @return boost::weak_ptr<NumeredDofEntity>
572  */
573  boost::weak_ptr<NumeredDofEntity>
575 
576  /**
577  * @brief Get the Col Dofs By Petsc Global Dof Idx object
578  *
579  * @param idx
580  * @return boost::weak_ptr<NumeredDofEntity>
581  */
582  boost::weak_ptr<NumeredDofEntity>
584 
585  BitFEId getBitFEId() const;
586 
587  friend std::ostream &operator<<(std::ostream &os, const Problem &e);
588 
589  /**
590  * \brief Get number of finite elements by name on processors
591  *
592  * Size retuned IS is equal to size of processors.
593  *
594  * What PetscLayout see,
595  <http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/IS/index.html>
596  *
597  * Example of usage for layout
598  * \code
599 
600  PetscInt rstart, rend;
601  ierr = PetscLayoutGetRange(layout, &rstart, &rend); CHKERRG(ierr);
602  int global_size;
603  ierr = PetscLayoutGetSize(layout,&global_size); CHKERRG(ierr);
604 
605  \endcode
606  *
607  * @param comm Communicator
608  * @param name Finite element name
609  * @param layout Get number of elements on each processor
610  * @return error code
611  */
613  const std::string name,
614  PetscLayout *layout) const;
615 
616  /**
617  * \brief Get number of finite elements on processors
618  *
619  * Size retuned IS is equal to size of processors.
620  *
621  * What PetscLayout see,
622  <http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/IS/index.html>
623  *
624  * Example of usage for layout
625  * \code
626 
627  PetscInt rstart, rend;
628  ierr = PetscLayoutGetRange(layout, &rstart, &rend); CHKERRG(ierr);
629  int global_size;
630  ierr = PetscLayoutGetSize(layout,&global_size); CHKERRG(ierr);
631 
632  \endcode
633  *
634  * @param comm Communicator
635  * @param layout Get number of elements on each processor
636  * @return error code
637  */
639  PetscLayout *layout) const;
640 
641  typedef multi_index_container<boost::weak_ptr<std::vector<NumeredDofEntity>>,
642  indexed_by<sequenced<>>>
644 
645  /**
646  * \brief Get reference to sequence data numbered dof container
647  *
648  * In sequence data container data are physically stored. The purpose of this
649  * is to allocate NumeredDofEntity data in bulk, having only one allocation
650  instead
651  * each time entity is inserted. That makes code efficient.
652  *
653  * The vector in sequence is destroyed if last entity inside that vector is
654  * destroyed. All MoFEM::NumeredDofEntity have aliased shared_ptr which points
655  to the vector.
656 
657  * @return MoFEM::Problem::SequenceDofContainer
658  */
659  inline boost::shared_ptr<SequenceDofContainer> &getRowDofsSequence() const {
661  }
662 
663  /**
664  * \brief Get reference to sequence data numbered dof container
665  *
666  * In sequence data container data are physically stored. The purpose of this
667  * is to allocate NumeredDofEntity data in bulk, having only one allocation
668  instead
669  * each time entity is inserted. That makes code efficient.
670  *
671  * The vector in sequence is destroyed if last entity inside that vector is
672  * destroyed. All MoFEM::NumeredDofEntity have aliased shared_ptr which points
673  to the vector.
674 
675  * @return MoFEM::Problem::SequenceDofContainer
676  */
677  inline boost::shared_ptr<SequenceDofContainer> &getColDofsSequence() const {
679  }
680 
681 private:
682  // Keep vector of DoFS on entity
683  mutable boost::shared_ptr<SequenceDofContainer> sequenceRowDofContainer;
684  mutable boost::shared_ptr<SequenceDofContainer> sequenceColDofContainer;
685 };
686 
687 /// \deprecated use just Problem
689 
690 /**
691  * @relates multi_index_container
692  * \brief MultiIndex for entities for Problem
693  * \ingroup fe_multi_indices
694  */
695 typedef multi_index_container<
696  Problem,
697  indexed_by<
698  ordered_unique<tag<Meshset_mi_tag>,
699  member<Problem, EntityHandle, &Problem::meshset>>,
700  hashed_unique<tag<BitProblemId_mi_tag>,
701  const_mem_fun<Problem, BitProblemId, &Problem::getId>,
703  hashed_unique<tag<Problem_mi_tag>,
704  const_mem_fun<Problem, std::string, &Problem::getName>>>>
706 
707 /** \brief add ref level to problem
708  * \ingroup problems_multi_indices
709  */
713  void operator()(Problem &p) { *(p.tagBitRefLevel) |= bit; };
714 };
715 
716 /** \brief set ref level to problem
717  * \ingroup problems_multi_indices
718  */
722  void operator()(Problem &p) { *(p.tagBitRefLevel) = bit; };
723 };
724 
725 /** \brief set prof dof bit ref mask
726  * \ingroup problems_multi_indices
727  */
731  void operator()(Problem &p) { *(p.tagMaskBitRefLevel) = bit; };
732 };
733 
734 /** \brief add finite element to problem
735  * \ingroup problems_multi_indices
736  */
740  void operator()(Problem &p);
741 };
742 
743 /** \brief set prof dof bit ref mask
744  * \ingroup problems_multi_indices
745  */
749  void operator()(Problem &p) { *(p.tagMaskBitRefLevel) |= bit; };
750 };
751 
752 /** \brief remove finite element from problem
753  * \ingroup problems_multi_indices
754  */
758  void operator()(Problem &p);
759 };
760 
761 /** \brief zero nb. of DOFs in row
762  * \ingroup problems_multi_indices
763  */
765  void operator()(Problem &e);
766 };
767 
768 /** \brief zero nb. of DOFs in col
769  * \ingroup problems_multi_indices
770  */
772  void operator()(Problem &e);
773 };
774 
775 /** \brief clear problem finite elements
776  * \ingroup problems_multi_indices
777  */
779  void operator()(Problem &e);
780 };
781 
782 /**
783  * \brief Clear sub-problem data structure
784  */
786  void operator()(Problem &e) { e.subProblemData.reset(); }
787 };
788 
789 /**
790  * \brief Clear composed problem data structure
791  */
793  void operator()(Problem &e) { e.composedProblemsData.reset(); }
794 };
795 
796 } // namespace MoFEM
797 
798 #endif //__PROBLEMSMULTIINDICES_HPP__
799 
800 /**
801  * \defgroup problems_multi_indices Problems structures and multi-indices
802  * \ingroup mofem
803  ******************************************************************************/
Clear sub-problem data structure.
boost::shared_ptr< NumeredDofEntity_multiIndex > & getNumeredRowDofsPtr() const
get access to numeredRowDofsPtr storing DOFs on rows
DofIdx getNbDofsRow() const
NumeredDofEntityByEnt::iterator getNumeredColDofsByEntBegin(const EntityHandle ent) const
ProblemChangeRefLevelBitSet(const BitRefLevel _bit)
Problem(Interface &moab, const EntityHandle meshset)
BitFEId getBitFEId() const
ProblemChangeRefLevelBitDofMaskSet(const BitRefLevel _bit)
const boost::shared_ptr< NumeredEntFiniteElement_multiIndex > &DEPRECATED getNumeredFiniteElements() const
get access to reference for multi-index storing finite elements
NumeredDofEntity_multiIndex::iterator getNumeredRowDofsEnd() const
DofIdx nbLocDofsCol
Local number of DOFs in colIs.
NumeredDofEntity_multiIndex::iterator getNumeredRowDofsBegin() const
DofIdx getNbGhostDofsCol() const
boost::shared_ptr< SubProblemData > & getSubData() const
Get main problem of sub-problem is.
DEPRECATED boost::shared_ptr< NumeredDofEntity_multiIndex > & getNumeredColDofs() const
get access to numeredColDofsPtr storing DOFs on cols
NumeredDofEntity_multiIndex::iterator getNumeredColDofsEnd() const
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.
MoFEMErrorCode getRowIs(IS *is, const unsigned int pp) const
std::vector< const Problem * > rowProblemsAdd
int tagNameSize
Size of problem name.
DofIdx nbDofsCol
Global number of DOFs in col.
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:509
IS rowIs
indices of main problem of which sub problem is this
boost::shared_ptr< SubProblemData > subProblemData
DofIdx nbGhostDofsCol
Number of ghost DOFs in col.
BitProblemId * tagId
Unique problem ID.
static Index< 'p', 3 > p
AO rowMap
mapping form main problem indices to sub-problem indices
DofIdx getNbLocalDofsRow() const
NumeredDofEntityByLocalIdx::iterator getNumeredColDofsByLocIdxEnd(const DofIdx locidx) const
NumeredDofEntityByLocalIdx::iterator getNumeredColDofsByLocIdxBegin(const DofIdx locidx) const
IS colIs
indices of main problem of which sub problem is this
std::bitset< BITPROBLEMID_SIZE > BitProblemId
Problem Id.
Definition: Types.hpp:55
const char * tagName
Problem name.
boost::shared_ptr< NumeredDofEntity_multiIndex > numeredRowDofsPtr
store DOFs on rows for this problem
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:516
keeps basic data about problemThis is low level structure with information about problem,...
DofIdx getNbGhostDofsRow() const
MoFEMErrorCode getRowDofsByPetscGlobalDofIdx(DofIdx idx, const NumeredDofEntity **dof_ptr, MoFEMTypes bh=MF_EXIST) const
Get the Row Dofs By Petsc Global Dof Idx object.
RowColData
RowColData.
Definition: definitions.h:192
BitFEId * tagBitFEId
IDs of finite elements in problem.
implementation of Data Operators for Forces and Sources
Definition: Common.hpp:21
NumeredDofEntityByEnt::iterator getNumeredRowDofsByEntBegin(const EntityHandle ent) const
NumeredDofEntityByLocalIdx::iterator getNumeredRowDofsByLocIdxBegin(const DofIdx locidx) const
DofIdx nbGhostDofsRow
Number of ghost DOFs in row.
std::bitset< BITFEID_SIZE > BitFEId
Finite element Id.
Definition: Types.hpp:54
DofIdx nbLocDofsRow
Local number of DOFs in row.
boost::shared_ptr< ComposedProblemsData > composedProblemsData
NumeredDofEntity_multiIndex::iterator getNumeredColDofsBegin() const
remove finite element from problem
BitRefLevel * tagMaskBitRefLevel
BItRefMask of elements in problem.
boost::shared_ptr< NumeredEntFiniteElement_multiIndex > numeredFiniteElementsPtr
store finite elements
NumeredDofEntityByEnt::iterator getNumeredRowDofsByEntEnd(const EntityHandle ent) const
BitRefLevel * tagBitRefLevel
BitRef level of finite elements in problem.
const boost::shared_ptr< NumeredEntFiniteElement_multiIndex > & getNumeredFiniteElementsPtr() const
get access to reference for multi-index storing finite elements
std::vector< const Problem * > colProblemsAdd
MoFEMErrorCode getNumberOfElementsByPart(MPI_Comm comm, PetscLayout *layout) const
Get number of finite elements on processors.
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
Definition: Exceptions.hpp:67
boost::shared_ptr< SequenceDofContainer > & getColDofsSequence() const
Get reference to sequence data numbered dof container.
friend std::ostream & operator<<(std::ostream &os, const Problem &e)
MoFEMErrorCode getColIs(IS *is, const unsigned int pp) const
DofIdx nbDofsRow
Global number of DOFs in row.
NumeredDofEntityByEnt::iterator getNumeredColDofsByEntEnd(const EntityHandle ent) const
BitRefLevel getMaskBitRefLevel() const
NumeredEntFiniteElementbyName::iterator getNumeredFEsBegin(std::string fe_name) const
boost::shared_ptr< SequenceDofContainer > sequenceColDofContainer
DofIdx getNbDofsCol() const
ProblemChangeRefLevelBitDofMaskAdd(const BitRefLevel _bit)
BitRefLevel getBitRefLevel() const
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
Definition: Types.hpp:51
#define DEPRECATED
Definition: definitions.h:29
boost::shared_ptr< SequenceDofContainer > sequenceRowDofContainer
boost::shared_ptr< NumeredDofEntity_multiIndex > numeredColDofsPtr
store DOFs on columns for this problem
boost::shared_ptr< SequenceDofContainer > & getRowDofsSequence() const
Get reference to sequence data numbered dof container.
NumeredEntFiniteElementbyName::iterator getNumeredFEsEnd(std::string fe_name) const
keeps information about indexed dofs for the problemFIXME: Is too many iterator, this has to be manag...
DeprecatedCoreInterface Interface
Definition: Interface.hpp:1943
virtual ~Problem()=default
ProblemChangeRefLevelBitAdd(const BitRefLevel _bit)
int DofIdx
Index of DOF.
Definition: Types.hpp:29
DEPRECATED boost::shared_ptr< NumeredDofEntity_multiIndex > & getNumeredRowDofs() const
get access to numeredRowDofsPtr storing DOFs on rows \deprected Use getNumeredRowDofsPtr
boost::shared_ptr< ComposedProblemsData > & getComposedProblemsData() const
Het composed problems data structure.
std::string getName() const
boost::shared_ptr< NumeredDofEntity_multiIndex > & getNumeredColDofsPtr() const
get access to numeredColDofsPtr storing DOFs on cols
Clear composed problem data structure.
DEPRECATED typedef Problem MoFEMProblem
DofIdx getNbLocalDofsCol() const
MoFEMErrorCode getNumberOfElementsByNameAndPart(MPI_Comm comm, const std::string name, PetscLayout *layout) const
Get number of finite elements by name on processors.
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
NumeredDofEntityByLocalIdx::iterator getNumeredRowDofsByLocIdxEnd(const DofIdx locidx) const
multi_index_container< boost::weak_ptr< std::vector< NumeredDofEntity > >, indexed_by< sequenced<> > > SequenceDofContainer
MoFEMTypes
Those types control how functions respond on arguments, f.e. error handling.
Definition: definitions.h:189
MoFEMErrorCode getColDofsByPetscGlobalDofIdx(DofIdx idx, const NumeredDofEntity **dof_ptr, MoFEMTypes bh=MF_EXIST) const
Get the Col Dofs By Petsc Global Dof Idx object.
BitProblemId getId() const