v0.13.1
ProblemsMultiIndices.cpp
Go to the documentation of this file.
1/** \file ProblemsMultiIndices.cpp
2 * \brief Multindex contains for problems
3 */
4
5
6namespace MoFEM {
7
9 for (unsigned int ii = 0; ii != rowIs.size(); ii++) {
10 CHKERRABORT(PETSC_COMM_SELF, ISDestroy(&rowIs[ii]));
11 }
12 for (unsigned int jj = 0; jj != colIs.size(); jj++) {
13 CHKERRABORT(PETSC_COMM_SELF, ISDestroy(&colIs[jj]));
14 }
15}
16
17// moab problem
18Problem::Problem(moab::Interface &moab, const EntityHandle meshset)
19 : meshset(meshset), numeredRowDofsPtr(new NumeredDofEntity_multiIndex()),
20 numeredColDofsPtr(new NumeredDofEntity_multiIndex()),
21 numeredFiniteElementsPtr(new NumeredEntFiniteElement_multiIndex()),
22 sequenceRowDofContainer(new SequenceDofContainer()),
23 sequenceColDofContainer(new SequenceDofContainer()) {
24 ErrorCode rval;
25 Tag th_ProblemId;
26 rval = moab.tag_get_handle("_ProblemId", th_ProblemId);
28 rval = moab.tag_get_by_ptr(th_ProblemId, &meshset, 1, (const void **)&tagId);
30 Tag th_ProblemName;
31 rval = moab.tag_get_handle("_ProblemName", th_ProblemName);
33 rval = moab.tag_get_by_ptr(th_ProblemName, &meshset, 1,
34 (const void **)&tagName, &tagNameSize);
36 Tag th_ProblemFEId;
37 rval = moab.tag_get_handle("_ProblemFEId", th_ProblemFEId);
39 rval = moab.tag_get_by_ptr(th_ProblemFEId, &meshset, 1,
40 (const void **)&tagBitFEId);
42 Tag th_RefBitLevel;
43 rval = moab.tag_get_handle("_RefBitLevel", th_RefBitLevel);
45 rval = moab.tag_get_by_ptr(th_RefBitLevel, &meshset, 1,
46 (const void **)&tagBitRefLevel);
48 Tag th_RefBitLevel_Mask;
49 rval = moab.tag_get_handle("_RefBitLevelMask", th_RefBitLevel_Mask);
51 rval = moab.tag_get_by_ptr(th_RefBitLevel_Mask, &meshset, 1,
52 (const void **)&tagBitRefLevelMask);
54}
55
56std::ostream &operator<<(std::ostream &os, const Problem &e) {
57 os << "Problem id " << e.getId() << " name " << e.getName() << endl;
58 os << "FiniteElement id " << e.getBitFEId() << endl;
59 os << "BitRefLevel " << e.getBitRefLevel() << endl;
60 os << "BitRefLevelMask " << e.getBitRefLevelMask();
61 return os;
62}
63
65
66boost::weak_ptr<NumeredDofEntity>
69 boost::weak_ptr<NumeredDofEntity> dof_weak_ptr;
70 NumeredDofEntity_multiIndex::index<PetscGlobalIdx_mi_tag>::type::iterator dit;
71 dit = numeredRowDofsPtr->get<PetscGlobalIdx_mi_tag>().find(idx);
72 if (dit != numeredRowDofsPtr->get<PetscGlobalIdx_mi_tag>().end())
73 dof_weak_ptr = *dit;
74 return dof_weak_ptr;
75}
76
77boost::weak_ptr<NumeredDofEntity>
80 boost::weak_ptr<NumeredDofEntity> dof_weak_ptr;
81 NumeredDofEntity_multiIndex::index<PetscGlobalIdx_mi_tag>::type::iterator dit;
82 dit = numeredColDofsPtr->get<PetscGlobalIdx_mi_tag>().find(idx);
83 if (dit != numeredColDofsPtr->get<PetscGlobalIdx_mi_tag>().end())
84 dof_weak_ptr = *dit;
85 return dof_weak_ptr;
86}
87
89 DofIdx idx, const NumeredDofEntity **dof_ptr, MoFEMTypes bh) const {
91 auto weak_dof_ptr = getRowDofsByPetscGlobalDofIdx(idx);
92 if (auto shared_dof_ptr = weak_dof_ptr.lock()) {
93 *dof_ptr = shared_dof_ptr.get();
94 } else {
95 if (bh == MF_EXIST)
96 SETERRQ1(PETSC_COMM_SELF, MOFEM_NOT_FOUND, "row dof <%d> not found", idx);
97 *dof_ptr = nullptr;
98 }
100}
101
103 DofIdx idx, const NumeredDofEntity **dof_ptr, MoFEMTypes bh) const {
105 auto weak_dof_ptr = getColDofsByPetscGlobalDofIdx(idx);
106 if (auto shared_dof_ptr = weak_dof_ptr.lock()) {
107 *dof_ptr = shared_dof_ptr.get();
108 } else {
109 if (bh == MF_EXIST)
110 SETERRQ1(PETSC_COMM_SELF, MOFEM_NOT_FOUND, "row dof <%d> not found", idx);
111 *dof_ptr = nullptr;
112 }
114}
115
117Problem::getNumberOfElementsByNameAndPart(MPI_Comm comm, const std::string name,
118 PetscLayout *layout) const {
120 int size, rank;
121 MPI_Comm_size(comm, &size);
122 MPI_Comm_rank(comm, &rank);
123 CHKERR PetscLayoutCreate(comm, layout);
124 CHKERR PetscLayoutSetBlockSize(*layout, 1);
125 const auto &fe_by_name_and_part =
127 int nb_elems;
128 nb_elems = fe_by_name_and_part.count(boost::make_tuple(name, rank));
129 CHKERR PetscLayoutSetLocalSize(*layout, nb_elems);
130 CHKERR PetscLayoutSetUp(*layout);
132}
133
135 PetscLayout *layout) const {
137 int size, rank;
138 MPI_Comm_size(comm, &size);
139 MPI_Comm_rank(comm, &rank);
140 CHKERR PetscLayoutCreate(comm, layout);
141 CHKERR PetscLayoutSetBlockSize(*layout, 1);
143 const FeByPart &fe_by_part = numeredFiniteElementsPtr->get<Part_mi_tag>();
144 int nb_elems;
145 nb_elems = fe_by_part.count(rank);
146 CHKERR PetscLayoutSetLocalSize(*layout, nb_elems);
147 CHKERR PetscLayoutSetUp(*layout);
149}
150
152 const int field_bit_number, const EntityHandle ent, const int ent_dof_idx,
153 const RowColData row_or_col,
154 boost::shared_ptr<NumeredDofEntity> &dof_ptr) const {
156 decltype(numeredRowDofsPtr) numered_dofs;
157 switch (row_or_col) {
158 case ROW:
159 if (!numeredRowDofsPtr) {
160 SETERRQ(PETSC_COMM_SELF, MOFEM_INVALID_DATA,
161 "Row numbered index in problem not allocated");
162 }
163 numered_dofs = numeredRowDofsPtr;
164 break;
165 case COL:
166 if (!numeredColDofsPtr) {
167 SETERRQ(PETSC_COMM_SELF, MOFEM_INVALID_DATA,
168 "Col numbered index in problem not allocated");
169 }
170 numered_dofs = numeredColDofsPtr;
171 break;
172 default:
173 SETERRQ(PETSC_COMM_SELF, MOFEM_INVALID_DATA,
174 "Only ROW and COL is possible for 3rd argument");
175 }
176
177 auto it =
178 numered_dofs->get<Unique_mi_tag>().find(DofEntity::getUniqueIdCalculate(
179 ent_dof_idx,
180 FieldEntity::getLocalUniqueIdCalculate(field_bit_number, ent)));
181 if (it != numered_dofs->get<Unique_mi_tag>().end()) {
182 dof_ptr = *it;
183 } else {
184 dof_ptr = boost::shared_ptr<NumeredDofEntity>();
185 }
187}
188
190 *(p.tagBitFEId) |= f_id;
191}
193 *(p.tagBitFEId) &= ~f_id;
194}
196 e.nbDofsRow = 0;
197 e.nbLocDofsRow = 0;
198 e.nbGhostDofsRow = 0;
199 e.numeredRowDofsPtr->clear();
200}
202 e.nbDofsCol = 0;
203 e.nbLocDofsCol = 0;
204 e.nbGhostDofsCol = 0;
205 e.numeredColDofsPtr->clear();
206}
208 e.numeredFiniteElementsPtr->clear();
209}
210
211} // namespace MoFEM
static Index< 'p', 3 > p
RowColData
RowColData.
Definition: definitions.h:123
@ COL
Definition: definitions.h:123
@ ROW
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 MOAB_THROW(err)
Check error code of MoAB function and throw MoFEM exception.
Definition: definitions.h:541
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:447
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:346
@ MOFEM_NOT_FOUND
Definition: definitions.h:33
@ MOFEM_INVALID_DATA
Definition: definitions.h:36
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:416
#define CHKERR
Inline error check.
Definition: definitions.h:535
#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< boost::shared_ptr< NumeredDofEntity >, indexed_by< ordered_unique< tag< Unique_mi_tag >, const_mem_fun< NumeredDofEntity::interface_type_DofEntity, UId, &NumeredDofEntity::getLocalUniqueId > >, ordered_non_unique< tag< Part_mi_tag >, member< NumeredDofEntity, unsigned int, &NumeredDofEntity::pArt > >, ordered_non_unique< tag< Idx_mi_tag >, member< NumeredDofEntity, DofIdx, &NumeredDofEntity::dofIdx > >, ordered_non_unique< tag< PetscGlobalIdx_mi_tag >, member< NumeredDofEntity, DofIdx, &NumeredDofEntity::petscGloablDofIdx > >, ordered_non_unique< tag< PetscLocalIdx_mi_tag >, member< NumeredDofEntity, DofIdx, &NumeredDofEntity::petscLocalDofIdx > >, ordered_non_unique< tag< Ent_mi_tag >, const_mem_fun< NumeredDofEntity::interface_type_DofEntity, EntityHandle, &NumeredDofEntity::getEnt > > > > NumeredDofEntity_multiIndex
MultiIndex container keeps NumeredDofEntity.
multi_index_container< boost::shared_ptr< NumeredEntFiniteElement >, indexed_by< ordered_unique< tag< Unique_mi_tag >, const_mem_fun< NumeredEntFiniteElement::interface_type_EntFiniteElement, UId, &NumeredEntFiniteElement::getLocalUniqueId > >, ordered_non_unique< tag< Part_mi_tag >, member< NumeredEntFiniteElement, unsigned int, &NumeredEntFiniteElement::part > >, ordered_non_unique< tag< FiniteElement_name_mi_tag >, const_mem_fun< NumeredEntFiniteElement::interface_type_FiniteElement, boost::string_ref, &NumeredEntFiniteElement::getNameRef > >, ordered_non_unique< tag< Ent_mi_tag >, const_mem_fun< NumeredEntFiniteElement::interface_type_RefEntity, EntityHandle, &NumeredEntFiniteElement::getEnt > >, ordered_non_unique< tag< Composite_Name_And_Ent_mi_tag >, composite_key< NumeredEntFiniteElement, const_mem_fun< NumeredEntFiniteElement::interface_type_FiniteElement, boost::string_ref, &NumeredEntFiniteElement::getNameRef >, const_mem_fun< NumeredEntFiniteElement::interface_type_RefEntity, EntityHandle, &NumeredEntFiniteElement::getEnt > > >, ordered_non_unique< tag< Composite_Name_And_Part_mi_tag >, composite_key< NumeredEntFiniteElement, const_mem_fun< NumeredEntFiniteElement::interface_type_FiniteElement, boost::string_ref, &NumeredEntFiniteElement::getNameRef >, member< NumeredEntFiniteElement, unsigned int, &NumeredEntFiniteElement::part > > > > > NumeredEntFiniteElement_multiIndex
MultiIndex for entities for NumeredEntFiniteElement.
static MoFEMErrorCodeGeneric< moab::ErrorCode > rval
Definition: Exceptions.hpp:74
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
implementation of Data Operators for Forces and Sources
Definition: MoFEM.hpp:24
std::ostream & operator<<(std::ostream &os, const EntitiesFieldData::EntData &e)
DeprecatedCoreInterface Interface
Definition: Interface.hpp:1955
static UId getUniqueIdCalculate(const DofIdx dof, UId ent_uid)
UId getLocalUniqueIdCalculate()
Get the Local Unique Id Calculate object.
keeps information about indexed dofs for the problem
keeps basic data about problem
MoFEMErrorCode getNumberOfElementsByPart(MPI_Comm comm, PetscLayout *layout) const
Get number of finite elements on processors.
MoFEMErrorCode getNumberOfElementsByNameAndPart(MPI_Comm comm, const std::string name, PetscLayout *layout) const
Get number of finite elements by name on processors.
const char * tagName
Problem name.
BitRefLevel getBitRefLevel() const
BitProblemId * tagId
Unique problem ID.
MoFEMErrorCode getDofByNameEntAndEntDofIdx(const int field_bit_number, const EntityHandle ent, const int ent_dof_idx, const RowColData row_or_col, boost::shared_ptr< NumeredDofEntity > &dof_ptr) const
get DOFs from problem
BitRefLevel getBitRefLevelMask() const
DofIdx nbGhostDofsCol
Number of ghost DOFs in col.
boost::shared_ptr< NumeredDofEntity_multiIndex > numeredRowDofsPtr
store DOFs on rows for this problem
boost::shared_ptr< NumeredEntFiniteElement_multiIndex > numeredFiniteElementsPtr
store finite elements
Problem(Interface &moab, const EntityHandle meshset)
MoFEMErrorCode getRowDofsByPetscGlobalDofIdx(DofIdx idx, const NumeredDofEntity **dof_ptr, MoFEMTypes bh=MF_EXIST) const
Get the Row Dofs By Petsc Global Dof Idx object.
DofIdx nbLocDofsRow
Local number of DOFs in row.
BitFEId getBitFEId() const
BitProblemId getId() const
DofIdx nbDofsCol
Global number of DOFs in col.
DofIdx nbGhostDofsRow
Number of ghost DOFs in row.
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.
DofIdx nbDofsRow
Global number of DOFs in row.
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.