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