v0.15.0
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#ifndef __PROBLEMSMULTIINDICES_HPP__
7#define __PROBLEMSMULTIINDICES_HPP__
8
9namespace MoFEM {
10
11struct Problem;
12
13/**
14 * Data structure created when composite problem is created
15 */
17
18 std::vector<const Problem *> rowProblemsAdd;
19 std::vector<const Problem *> colProblemsAdd;
20
21 std::vector<SmartPetscObj<IS>> rowIs;
22 std::vector<SmartPetscObj<IS>> colIs;
23
24 /**
25 * @brief Get the col sub dm IS
26 *
27 * @param is sub problem IS
28 * @param pp problem number
29 * @return MoFEMErrorCode
30 */
31 inline MoFEMErrorCode getRowIs(IS *is, const unsigned int pp) const;
32
33 /**
34 * @brief Get the Col sub dm IS object
35 *
36 * @param is sub problem IS
37 * @param pp problem number
38 * @return MoFEMErrorCode
39 */
40 inline MoFEMErrorCode getColIs(IS *is, const unsigned int pp) const;
41
42 virtual ~ComposedProblemsData() = default;
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 Erase elements by entities
98 *
99 * @param entities
100 * @return MoFEMErrorCode
101 */
102 MoFEMErrorCode eraseElements(Range entities) const;
103
104 /**
105 * \brief Subproblem problem data
106 */
107 struct SubProblemData;
108
109 /**
110 * Pointer to data structure. This pointer has allocated data only for
111 * sub problems.
112 */
113 mutable boost::shared_ptr<SubProblemData> subProblemData;
114
115 /**
116 * \brief Get main problem of sub-problem is
117 * @return sub problem data structure
118 */
119 inline boost::shared_ptr<SubProblemData> &getSubData() const {
120 return subProblemData;
121 }
122
123 /**
124 * Pointer to data structure from which this problem is composed
125 */
126 mutable boost::shared_ptr<ComposedProblemsData> composedProblemsData;
127
128 /**
129 * \brief Het composed problems data structure
130 */
131 inline auto &getComposedProblemsData() const { return composedProblemsData; }
132
133 /**
134 * \brief get DOFs from problem
135 *
136 * Note that \e ent_dof_idx is not coefficient number, is local number of DOFs
137 * on the entity. The coefficient number and local index of DOFs or entity are
138 * the same on vertices and H1 approximation.
139 *
140 * @param field_bit_number field name field_bit_number = (use
141 * m_field.get_field_bit_number(field_name);
142 * @param ent entity handle
143 * @param ent_dof_idx index of DOFs on entity
144 * @param row_or_col ROW or COL
145 * @param dof_ptr shared pointer to DOFs if found
146 * @return error code
147 */
149 const int field_bit_number, const EntityHandle ent, const int ent_dof_idx,
150 const RowColData row_or_col,
151 boost::shared_ptr<NumeredDofEntity> &dof_ptr) const;
152
153/**
154 * \brief use with loops to iterate row DOFs
155 * \ingroup problems_multi_indices
156 *
157 * \code
158 * for(_IT_NUMEREDDOF_ROW_FOR_LOOP_(PROBLEMPTR,IT)) {
159 * ...
160 * }
161 * \endcode
162 *
163 */
164#define _IT_NUMEREDDOF_ROW_FOR_LOOP_(PROBLEMPTR, IT) \
165 NumeredDofEntity_multiIndex::iterator IT = \
166 PROBLEMPTR->getNumeredRowDofsBegin(); \
167 IT != PROBLEMPTR->getNumeredRowDofsEnd(); \
168 IT++
169
170/**
171 * use with loops to iterate col DOFs
172 * \ingroup problems_multi_indices
173 *
174 * \code
175 * for(_IT_NUMEREDDOF_COL_FOR_LOOP_(PROBLEMPTR,IT)) {
176 * ...
177 * }
178 * \endcode
179 *
180 */
181#define _IT_NUMEREDDOF_COL_FOR_LOOP_(PROBLEMPTR, IT) \
182 NumeredDofEntity_multiIndex::iterator IT = \
183 PROBLEMPTR->getNumeredColDofsBegin(); \
184 IT != PROBLEMPTR->getNumeredColDofsEnd(); \
185 IT++
186
187 /// get begin iterator for numeredRowDofsPtr (insted you can use
188 /// #_IT_NUMEREDDOFMOFEMENTITY_ROW_FOR_LOOP_ for loops)
189 NumeredDofEntity_multiIndex::iterator getNumeredRowDofsBegin() const {
190 return numeredRowDofsPtr->begin();
191 }
192
193 /// get end iterator for numeredRowDofsPtr (insted you can use
194 /// #_IT_NUMEREDDOFMOFEMENTITY_ROW_FOR_LOOP_ for loops)
195 NumeredDofEntity_multiIndex::iterator getNumeredRowDofsEnd() const {
196 return numeredRowDofsPtr->end();
197 }
198
199 /// get begin iterator for numeredColDofsPtr (insted you can use
200 /// #_IT_NUMEREDDOFMOFEMENTITY_COL_FOR_LOOP_ for loops)
201 NumeredDofEntity_multiIndex::iterator getNumeredColDofsBegin() const {
202 return numeredColDofsPtr->begin();
203 }
204
205 /// get end iterator for numeredColDofsPtr (insted you can use
206 /// #_IT_NUMEREDDOFMOFEMENTITY_COL_FOR_LOOP_ for loops)
207 NumeredDofEntity_multiIndex::iterator getNumeredColDofsEnd() const {
208 return numeredColDofsPtr->end();
209 }
210
211/**
212 * \brief use with loops to iterate row DOFs
213 * \ingroup problems_multi_indices
214 *
215 * \code
216 * for(_IT_NUMEREDDOF_ROW_BY_LOCIDX_FOR_LOOP_(PROBLEMPTR,IT)) {
217 * ...
218 * }
219 * \endcode
220 *
221 */
222#define _IT_NUMEREDDOF_ROW_BY_LOCIDX_FOR_LOOP_(PROBLEMPTR, IT) \
223 NumeredDofEntityByLocalIdx::iterator IT = \
224 PROBLEMPTR->getNumeredRowDofsByLocIdxBegin(0); \
225 IT != PROBLEMPTR->getNumeredRowDofsByLocIdxEnd( \
226 PROBLEMPTR->getNbLocalDofsRow() - 1); \
227 IT++
228
229/**
230 * \brief use with loops to iterate col DOFs
231 *
232 * \code
233 * for(_IT_NUMEREDDOF_COL_BY_LOCIDX_FOR_LOOP_(PROBLEMPTR,IT)) {
234 * ...
235 * }
236 * \endcode
237 *
238 */
239#define _IT_NUMEREDDOF_COL_BY_LOCIDX_FOR_LOOP_(PROBLEMPTR, IT) \
240 NumeredDofEntityByUId::iterator IT = \
241 PROBLEMPTR->getNumeredColDofsByLocIdxBegin(0); \
242 IT != PROBLEMPTR->getNumeredColDofsByLocIdxEnd( \
243 PROBLEMPTR->getNbLocalDofsRow() - 1); \
244 IT++
245
246 /// get begin iterator for numeredRowDofsPtr (insted you can use
247 /// #_IT_NUMEREDDOF_ROW_FOR_LOOP_ for loops)
248 auto getNumeredRowDofsByLocIdxBegin(const DofIdx locidx) const {
249 return numeredRowDofsPtr->get<PetscLocalIdx_mi_tag>().lower_bound(locidx);
250 }
251
252 /// get end iterator for numeredRowDofsPtr (insted you can use
253 /// #_IT_NUMEREDDOF_ROW_FOR_LOOP_ for loops)
254 auto getNumeredRowDofsByLocIdxEnd(const DofIdx locidx) const {
255 return numeredRowDofsPtr->get<PetscLocalIdx_mi_tag>().upper_bound(locidx);
256 }
257
258 /// get begin iterator for numeredColDofsPtr (insted you can use
259 /// #_IT_NUMEREDDOF_COL_FOR_LOOP_ for loops)
260 auto getNumeredColDofsByLocIdxBegin(const DofIdx locidx) const {
261 return numeredColDofsPtr->get<PetscLocalIdx_mi_tag>().lower_bound(locidx);
262 }
263
264 /// get end iterator for numeredColDofsPtr (insted you can use
265 /// #_IT_NUMEREDDOF_COL_FOR_LOOP_ for loops)
266 auto getNumeredColDofsByLocIdxEnd(const DofIdx locidx) const {
267 return numeredColDofsPtr->get<PetscLocalIdx_mi_tag>().upper_bound(locidx);
268 }
269
270/**
271 * \brief use with loops to iterate row DOFs
272 * \ingroup problems_multi_indices
273 *
274 * \code
275 * for(_IT_NUMEREDDOF_BY_ENT_ROW_FOR_LOOP_(PROBLEMPTR,ENT,IT)) {
276 * ...
277 * }
278 * \endcode
279 *
280 */
281#define _IT_NUMEREDDOF_ROW_BY_ENT_FOR_LOOP_(PROBLEMPTR, ENT, IT) \
282 auto IT = PROBLEMPTR->getNumeredRowDofsByEntBegin(ENT); \
283 IT != PROBLEMPTR->getNumeredRowDofsByEntEnd(ENT); \
284 IT++
285
286/**
287 * \brief use with loops to iterate col DOFs
288 * \ingroup problems_multi_indices
289 *
290 * \code
291 * for(_IT_NUMEREDDOF_COL_BY_ENT_FOR_LOOP_(PROBLEMPTR,ENT,IT)) {
292 * ...
293 * }
294 * \endcode
295 *
296 */
297#define _IT_NUMEREDDOF_COL_BY_ENT_FOR_LOOP_(PROBLEMPTR, ENT, IT) \
298 auto IT = PROBLEMPTR->getNumeredColDofsByEntBegin(ENT); \
299 IT != PROBLEMPTR->getNumeredColDofsByEntEnd(ENT); \
300 IT++
301
302 /// get begin iterator for numeredRowDofsPtr (insted you can use
303 /// #_IT_NUMEREDDOF_ROW_BY_ENT_FOR_LOOP_ for loops)
305 return numeredRowDofsPtr->get<Ent_mi_tag>().lower_bound(ent);
306 }
307
308 /// get end iterator for numeredRowDofsPtr (insted you can use
309 /// #_IT_NUMEREDDOF_ROW_BY_ENT_FOR_LOOP_ for loops)
311 return numeredRowDofsPtr->get<Ent_mi_tag>().upper_bound(ent);
312 }
313
314 /// get begin iterator for numeredColDofsPtr (insted you can use
315 /// #_IT_NUMEREDDOF_COL_BY_ENT_FOR_LOOP_ for loops)
317 return numeredColDofsPtr->get<Ent_mi_tag>().lower_bound(ent);
318 }
319
320 /// get end iterator for numeredColDofsPtr (insted you can use
321 /// #_IT_NUMEREDDOF_COL_BY_ENT_FOR_LOOP_ for loops)
323 return numeredColDofsPtr->get<Ent_mi_tag>().upper_bound(ent);
324 }
325
326/**
327 * use with loops to iterate row DOFs
328 * \ingroup problems_multi_indices
329 *
330 * \code
331 * for(_IT_NUMEREDDOF_BY_NAME_ROW_FOR_LOOP_(PROBLEMPTR,m_field.get_field_bit_number(FIELD_BIT_NUMBER),IT))
332 * {
333 * ...
334 * }
335 * \endcode
336 *
337 */
338#define _IT_NUMEREDDOF_ROW_BY_BITNUMBER_FOR_LOOP_(PROBLEMPTR, \
339 FIELD_BIT_NUMBER, IT) \
340 auto IT = PROBLEMPTR->numeredRowDofsPtr->lower_bound( \
341 FieldEntity::getLoBitNumberUId(FIELD_BIT_NUMBER)); \
342 IT != PROBLEMPTR->numeredRowDofsPtr->upper_bound( \
343 FieldEntity::getHiBitNumberUId(FIELD_BIT_NUMBER)); \
344 IT++
345
346/**
347 * \brief use with loops to iterate col DOFs
348 * \ingroup problems_multi_indices
349 *
350 * \code
351 * for(_IT_NUMEREDDOF_COL_BY_BITNUMBER_FOR_LOOP_(PROBLEMPTR,m_field.get_field_bit_number(FIELD_BIT_NUMBER),IT))
352 * {
353 * ...
354 * }
355 * \endcode
356 *
357 */
358#define _IT_NUMEREDDOF_COL_BY_BITNUMBER_FOR_LOOP_(PROBLEMPTR, \
359 FIELD_BIT_NUMBER, IT) \
360 auto IT = PROBLEMPTR->numeredColDofsPtr->lower_bound( \
361 FieldEntity::getLoBitNumberUId(FIELD_BIT_NUMBER)); \
362 IT != PROBLEMPTR->numeredColDofsPtr->upper_bound( \
363 FieldEntity::getHiBitNumberUId(FIELD_BIT_NUMBER)); \
364 IT++
365
367
368 virtual ~Problem() = default;
369
370 inline BitProblemId getId() const { return *((BitProblemId *)tagId); }
371
372 inline auto getName() const {
373 return std::string((char *)tagName, tagNameSize);
374 }
375
376 inline DofIdx getNbDofsRow() const { return nbDofsRow; }
377 inline DofIdx getNbDofsCol() const { return nbDofsCol; }
378 inline DofIdx getNbLocalDofsRow() const { return nbLocDofsRow; }
379 inline DofIdx getNbLocalDofsCol() const { return nbLocDofsCol; }
380 inline DofIdx getNbGhostDofsRow() const { return nbGhostDofsRow; }
381 inline DofIdx getNbGhostDofsCol() const { return nbGhostDofsCol; }
382
383 inline BitRefLevel getBitRefLevel() const { return *tagBitRefLevel; }
385
386 // DEPRECATED inline BitRefLevel getMaskBitRefLevel() const {
387 // return *tagBitRefLevelMask;
388 // }
389
390 /**
391 * @brief Get the Row Dofs By Petsc Global Dof Idx object
392 *
393 * @param idx
394 * @param dof_ptr
395 * @param bh
396 * @return MoFEMErrorCode
397 */
399 const NumeredDofEntity **dof_ptr,
400 MoFEMTypes bh = MF_EXIST) const;
401
402 /**
403 * @brief Get the Col Dofs By Petsc Global Dof Idx object
404 *
405 * @param idx
406 * @param dof_ptr
407 * @param bh
408 * @return MoFEMErrorCode
409 */
411 const NumeredDofEntity **dof_ptr,
412 MoFEMTypes bh = MF_EXIST) const;
413
414 /**
415 * @brief Get the Row Dofs By Petsc Global Dof Idx object
416 *
417 * @param idx
418 * @return boost::weak_ptr<NumeredDofEntity>
419 */
420 boost::weak_ptr<NumeredDofEntity>
422
423 /**
424 * @brief Get the Col Dofs By Petsc Global Dof Idx object
425 *
426 * @param idx
427 * @return boost::weak_ptr<NumeredDofEntity>
428 */
429 boost::weak_ptr<NumeredDofEntity>
431
432 /**
433 * @brief Get the BitFEIDs in problem
434 * @return BitFEId
435 */
436 BitFEId getBitFEId() const;
437
438 friend std::ostream &operator<<(std::ostream &os, const Problem &e);
439
440 /**
441 * \brief Get number of finite elements by name on processors
442 *
443 * Size retuned IS is equal to size of processors.
444 *
445 * What PetscLayout see,
446 <http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/IS/index.html>
447 *
448 * Example of usage for layout
449 * \code
450
451 PetscInt rstart, rend;
452 ierr = PetscLayoutGetRange(layout, &rstart, &rend); CHKERRG(ierr);
453 int global_size;
454 ierr = PetscLayoutGetSize(layout,&global_size); CHKERRG(ierr);
455
456 \endcode
457 *
458 * @param comm Communicator
459 * @param name Finite element name
460 * @param layout Get number of elements on each processor
461 * @return error code
462 */
464 const std::string name,
465 PetscLayout *layout) const;
466
467 /**
468 * \brief Get number of finite elements on processors
469 *
470 * Size retuned IS is equal to size of processors.
471 *
472 * What PetscLayout see,
473 <http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/IS/index.html>
474 *
475 * Example of usage for layout
476 * \code
477
478 PetscInt rstart, rend;
479 ierr = PetscLayoutGetRange(layout, &rstart, &rend); CHKERRG(ierr);
480 int global_size;
481 ierr = PetscLayoutGetSize(layout,&global_size); CHKERRG(ierr);
482
483 \endcode
484 *
485 * @param comm Communicator
486 * @param layout Get number of elements on each processor
487 * @return error code
488 */
490 PetscLayout *layout) const;
491
492 typedef multi_index_container<boost::weak_ptr<std::vector<NumeredDofEntity>>,
493 indexed_by<sequenced<>>>
495
496 /**
497 * \brief Get reference to sequence data numbered dof container
498 *
499 * In sequence data container data are physically stored. The purpose of this
500 * is to allocate NumeredDofEntity data in bulk, having only one allocation
501 instead
502 * each time entity is inserted. That makes code efficient.
503 *
504 * The vector in sequence is destroyed if last entity inside that vector is
505 * destroyed. All MoFEM::NumeredDofEntity have aliased shared_ptr which points
506 to the vector.
507
508 * @return MoFEM::Problem::SequenceDofContainer
509 */
510 inline auto &getRowDofsSequence() const { return sequenceRowDofContainer; }
511
512 /**
513 * \brief Get reference to sequence data numbered dof container
514 *
515 * In sequence data container data are physically stored. The purpose of this
516 * is to allocate NumeredDofEntity data in bulk, having only one allocation
517 instead
518 * each time entity is inserted. That makes code efficient.
519 *
520 * The vector in sequence is destroyed if last entity inside that vector is
521 * destroyed. All MoFEM::NumeredDofEntity have aliased shared_ptr which points
522 to the vector.
523
524 * @return MoFEM::Problem::SequenceDofContainer
525 */
526 inline auto &getColDofsSequence() const { return sequenceColDofContainer; }
527
528 using BlockFieldPair = std::pair<BitFieldId, BitFieldId>;
529 using EmptyFieldBlocks = std::vector<BlockFieldPair>;
530
531 /**
532 * @brief Get the empty field blocks
533 *
534 * Emtpy field blocks is a pair contains IDs of the fields for which matrix
535 * has zero entries.
536 *
537 * @return EmptyFieldBlocks&
538 */
540 return emptyFieldBlocks;
541 }
542
543 /**
544 * @brief Add fields to the empty field blocks
545 *
546 * Emtpy field blocks is a pair contains IDs of the fields for which matrix
547 * has zero entries.
548 *
549 * @param add_fields
550 * @return EmptyFieldBlocks&
551 */
552 inline BlockFieldPair &
554 emptyFieldBlocks.push_back(add_fields);
555 return emptyFieldBlocks.back();
556 }
557
558private:
559 // Keep vector of DoFS on entity
560 mutable boost::shared_ptr<SequenceDofContainer> sequenceRowDofContainer;
561 mutable boost::shared_ptr<SequenceDofContainer> sequenceColDofContainer;
562
564};
565
568
569/**
570 * \brief Subproblem problem data
571 */
573
575 rowIs; ///< indices of main problem of which sub problem is this
577 colIs; ///< indices of main problem of which sub problem is this
579 rowMap; ///< mapping form main problem indices to sub-problem indices
581 colMap; ///< mapping form main problem indices to sub-problem indices
582
583 inline auto getSmartRowIs() { return rowIs; }
584 inline auto getSmartColIs() { return colIs; }
585 inline auto getSmartRowMap() { return rowMap; }
586 inline auto getSmartColMap() { return colMap; }
587
588 /**
589 * get row Is for sub problem
590 * @param is create is
591 * @return error code
592 */
593 inline MoFEMErrorCode getRowIs(IS *is) {
595 *is = rowIs;
596 PetscObjectReference((PetscObject)(*is));
598 }
599
600 /**
601 * get col Is for sub problem
602 * @param is create is
603 * @return error code
604 */
605 inline MoFEMErrorCode getColIs(IS *is) {
607 *is = colIs;
608 PetscObjectReference((PetscObject)(*is));
610 };
611
612 /**
613 * get row AO mapping for sub problem
614 * @param ao get mapping
615 * @return error code
616 */
617 inline MoFEMErrorCode getRowMap(AO *ao) {
619 *ao = rowMap;
620 PetscObjectReference((PetscObject)(*ao));
622 }
623
624 /**
625 * get col AO mapping for sub problem
626 * @param ao get mapping
627 * @return error code
628 */
629 inline MoFEMErrorCode getColMap(AO *ao) {
631 *ao = colMap;
632 PetscObjectReference((PetscObject)(*ao));
634 }
635
636 SubProblemData() = default;
637 virtual ~SubProblemData() = default;
638};
639
641
642/**
643 * @relates multi_index_container
644 * \brief MultiIndex for entities for Problem
645 * \ingroup fe_multi_indices
646 */
647typedef multi_index_container<
648 Problem,
649 indexed_by<
650 ordered_unique<tag<Meshset_mi_tag>,
651 member<Problem, EntityHandle, &Problem::meshset>>,
652 hashed_unique<tag<BitProblemId_mi_tag>,
653 const_mem_fun<Problem, BitProblemId, &Problem::getId>,
655 hashed_unique<tag<Problem_mi_tag>,
656 const_mem_fun<Problem, std::string, &Problem::getName>>>>
658
659/** \brief add ref level to problem
660 * \ingroup problems_multi_indices
661 */
667
668/** \brief set ref level to problem
669 * \ingroup problems_multi_indices
670 */
676
677/** \brief set prof dof bit ref mask
678 * \ingroup problems_multi_indices
679 */
685
686/** \brief add finite element to problem
687 * \ingroup problems_multi_indices
688 */
694
695/** \brief set prof dof bit ref mask
696 * \ingroup problems_multi_indices
697 */
703
704/** \brief remove finite element from problem
705 * \ingroup problems_multi_indices
706 */
712
713/** \brief zero nb. of DOFs in row
714 * \ingroup problems_multi_indices
715 */
717 void operator()(Problem &e);
718};
719
720/** \brief zero nb. of DOFs in col
721 * \ingroup problems_multi_indices
722 */
724 void operator()(Problem &e);
725};
726
727/** \brief clear problem finite elements
728 * \ingroup problems_multi_indices
729 */
733
734/**
735 * \brief Clear sub-problem data structure
736 */
740
741/**
742 * \brief Clear composed problem data structure
743 */
747
748inline MoFEMErrorCode
749ComposedProblemsData::getRowIs(IS *is, const unsigned int pp) const {
751 if (pp <= rowIs.size()) {
752 SETERRQ(PETSC_COMM_WORLD, MOFEM_INVALID_DATA, "Exceed size of array pp<%ld",
753 rowIs.size());
754 }
755 *is = rowIs[pp].get();
756 PetscObjectReference((PetscObject)(*is));
758}
759
760inline MoFEMErrorCode
761ComposedProblemsData::getColIs(IS *is, const unsigned int pp) const {
763 if (pp <= colIs.size()) {
764 SETERRQ(PETSC_COMM_WORLD, MOFEM_INVALID_DATA, "Exceed size of array pp<%ld",
765 colIs.size());
766 }
767 *is = colIs[pp].get();
768 PetscObjectReference((PetscObject)(*is));
770}
771
772} // namespace MoFEM
773
774#endif //__PROBLEMSMULTIINDICES_HPP__
775
776/**
777 * \defgroup problems_multi_indices Problems structures and multi-indices
778 * \ingroup mofem
779 ******************************************************************************/
RowColData
RowColData.
MoFEMTypes
Those types control how functions respond on arguments, f.e. error handling.
@ MF_EXIST
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
@ 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 ...
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.
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::BlockFieldPair BlockFieldPair
Problem::EmptyFieldBlocks EmptyFieldBlocks
DeprecatedCoreInterface Interface
std::vector< const Problem * > rowProblemsAdd
std::vector< SmartPetscObj< IS > > colIs
virtual ~ComposedProblemsData()=default
MoFEMErrorCode getRowIs(IS *is, const unsigned int pp) const
Get the col sub dm IS.
MoFEMErrorCode getColIs(IS *is, const unsigned int pp) const
Get the Col sub dm IS object.
std::vector< SmartPetscObj< IS > > rowIs
std::vector< const Problem * > colProblemsAdd
keeps information about indexed dofs for the problem
ProblemChangeRefLevelBitAdd(const BitRefLevel _bit)
ProblemChangeRefLevelBitSet(const BitRefLevel _bit)
Clear composed problem data structure.
Clear sub-problem data structure.
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
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
multi_index_container< boost::weak_ptr< std::vector< NumeredDofEntity > >, indexed_by< sequenced<> > > SequenceDofContainer
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
std::pair< BitFieldId, BitFieldId > BlockFieldPair
boost::shared_ptr< SequenceDofContainer > sequenceColDofContainer
BitProblemId * tagId
Unique problem ID.
auto & getColDofsSequence() const
Get reference to sequence data numbered dof container.
std::vector< BlockFieldPair > 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
boost::shared_ptr< NumeredEntFiniteElement_multiIndex > numeredFiniteElementsPtr
store finite elements
NumeredDofEntity_multiIndex::iterator getNumeredRowDofsEnd() const
auto getNumeredColDofsByLocIdxBegin(const DofIdx locidx) 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
MoFEMErrorCode eraseElements(Range entities) const
Erase elements by entities.
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
Get the BitFEIDs in problem
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
boost::shared_ptr< NumeredDofEntity_multiIndex > numeredColDofsPtr
store DOFs on columns for this problem
BlockFieldPair & addFieldToEmptyFieldBlocks(const BlockFieldPair add_fields) const
Add fields to the empty field blocks.
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