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