v0.15.0
Loading...
Searching...
No Matches
MoFEM::SetBitRefLevelTool Struct Reference

tool class with methods used more than twp times More...

Collaboration diagram for MoFEM::SetBitRefLevelTool:
[legend]

Public Member Functions

 SetBitRefLevelTool (MoFEM::Interface &m_field, const BitRefLevel &bit, const RefEntity_multiIndex *ref_ents_ptr, const RefElement_multiIndex *ref_element_ptr)
 constructor
 
MoFEMErrorCode findEntsToAdd (EntityHandle f, EntityHandle s, Range &seed_ents_range) const
 find entities and change entity bit if in database
 
template<int N>
MoFEMErrorCode addEntsToDatabaseImpl (const Range &seed_ents_range) const
 add entities to database
 
MoFEMErrorCode addEntsToDatabase (const Range &seed_ents_range) const
 
MoFEMErrorCode findElementsToAdd (EntityHandle f, EntityHandle s, Range &seed_fe_range) const
 
MoFEMErrorCode addElementsToDatabase (Range &seed_fe_range) const
 

Public Attributes

MoFEM::InterfacemField
 
const BitRefLevelbIt
 bit to set
 
const RefEntity_multiIndexrefEntsPtr
 access to ents database
 
const RefElement_multiIndexrefElementPtr
 access to fe database
 
boost::shared_ptr< BasicEntityData > & baseEntData
 base entity data
 

Detailed Description

tool class with methods used more than twp times

Definition at line 40 of file BitRefManager.cpp.

Constructor & Destructor Documentation

◆ SetBitRefLevelTool()

MoFEM::SetBitRefLevelTool::SetBitRefLevelTool ( MoFEM::Interface & m_field,
const BitRefLevel & bit,
const RefEntity_multiIndex * ref_ents_ptr,
const RefElement_multiIndex * ref_element_ptr )
inline

constructor

Definition at line 51 of file BitRefManager.cpp.

54 : mField(m_field), bIt(bit), refEntsPtr(ref_ents_ptr),
55 refElementPtr(ref_element_ptr),
auto bit
set bit
virtual boost::shared_ptr< BasicEntityData > & get_basic_entity_data_ptr()=0
Get pointer to basic entity data.
boost::shared_ptr< BasicEntityData > & baseEntData
base entity data
MoFEM::Interface & mField
const RefEntity_multiIndex * refEntsPtr
access to ents database
const BitRefLevel & bIt
bit to set
const RefElement_multiIndex * refElementPtr
access to fe database

Member Function Documentation

◆ addElementsToDatabase()

MoFEMErrorCode MoFEM::SetBitRefLevelTool::addElementsToDatabase ( Range & seed_fe_range) const
inline

Definition at line 191 of file BitRefManager.cpp.

191 {
193 std::vector<boost::shared_ptr<RefElement>> shared_ref_fe_vec;
194 shared_ref_fe_vec.reserve(seed_fe_range.size());
195 // create ref entity instances
196 for (Range::const_pair_iterator pit = seed_fe_range.const_pair_begin();
197 pit != seed_fe_range.const_pair_end(); ++pit) {
198 RefEntity_multiIndex::iterator rit, hi_rit;
199 rit = refEntsPtr->lower_bound(pit->first);
200 hi_rit = refEntsPtr->upper_bound(pit->second);
201 if (static_cast<int>(std::distance(rit, hi_rit)) !=
202 static_cast<int>(pit->second - pit->first + 1)) {
203 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
204 "data inconsistency %ld != %ld", std::distance(rit, hi_rit),
205 pit->second - pit->first + 1);
206 }
207 switch ((*rit)->getEntType()) {
208 case MBVERTEX: {
209 boost::shared_ptr<std::vector<RefElement_VERTEX>> ref_fe_vec =
210 boost::make_shared<std::vector<RefElement_VERTEX>>();
211 ref_fe_vec->reserve(pit->second - pit->first + 1);
212 for (; rit != hi_rit; ++rit) {
213 ref_fe_vec->push_back(RefElement_VERTEX(*rit));
214 shared_ref_fe_vec.push_back(
215 boost::shared_ptr<RefElement>(ref_fe_vec, &ref_fe_vec->back()));
216 }
217 } break;
218 case MBEDGE: {
219 boost::shared_ptr<std::vector<RefElement_EDGE>> ref_fe_vec =
220 boost::make_shared<std::vector<RefElement_EDGE>>();
221 ref_fe_vec->reserve(pit->second - pit->first + 1);
222 for (; rit != hi_rit; ++rit) {
223 ref_fe_vec->push_back(RefElement_EDGE(*rit));
224 shared_ref_fe_vec.push_back(
225 boost::shared_ptr<RefElement>(ref_fe_vec, &ref_fe_vec->back()));
226 }
227 } break;
228 case MBTRI:
229 case MBQUAD: {
230 boost::shared_ptr<std::vector<RefElementFace>> ref_fe_vec =
231 boost::make_shared<std::vector<RefElementFace>>();
232 ref_fe_vec->reserve(pit->second - pit->first + 1);
233 for (; rit != hi_rit; ++rit) {
234 ref_fe_vec->push_back(RefElementFace(*rit));
235 shared_ref_fe_vec.push_back(
236 boost::shared_ptr<RefElement>(ref_fe_vec, &ref_fe_vec->back()));
237 }
238 } break;
239 case MBTET:
240 case MBHEX: {
241 boost::shared_ptr<std::vector<RefElementVolume>> ref_fe_vec =
242 boost::make_shared<std::vector<RefElementVolume>>();
243 ref_fe_vec->reserve(pit->second - pit->first + 1);
244 for (; rit != hi_rit; ++rit) {
245 ref_fe_vec->push_back(RefElementVolume(*rit));
246 shared_ref_fe_vec.push_back(
247 boost::shared_ptr<RefElement>(ref_fe_vec, &ref_fe_vec->back()));
248 }
249 } break;
250 case MBPRISM: {
251 boost::shared_ptr<std::vector<RefElement_PRISM>> ref_fe_vec =
252 boost::make_shared<std::vector<RefElement_PRISM>>();
253 ref_fe_vec->reserve(pit->second - pit->first + 1);
254 for (; rit != hi_rit; ++rit) {
255 ref_fe_vec->push_back(RefElement_PRISM(*rit));
256 shared_ref_fe_vec.push_back(
257 boost::shared_ptr<RefElement>(ref_fe_vec, &ref_fe_vec->back()));
258 }
259 } break;
260 case MBENTITYSET: {
261 boost::shared_ptr<std::vector<RefElement_MESHSET>> ref_fe_vec =
262 boost::make_shared<std::vector<RefElement_MESHSET>>();
263 ref_fe_vec->reserve(pit->second - pit->first + 1);
264 for (; rit != hi_rit; ++rit) {
265 ref_fe_vec->push_back(RefElement_MESHSET(*rit));
266 shared_ref_fe_vec.push_back(
267 boost::shared_ptr<RefElement>(ref_fe_vec, &ref_fe_vec->back()));
268 }
269 } break;
270 default:
271 SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED, "not implemented");
272 }
273 }
274 // add shared pointers to database
276 ->insert(shared_ref_fe_vec.begin(), shared_ref_fe_vec.end());
278 }
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
@ MOFEM_DATA_INCONSISTENCY
Definition definitions.h:31
@ MOFEM_NOT_IMPLEMENTED
Definition definitions.h:32
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
multi_index_container< boost::shared_ptr< RefElement >, indexed_by< ordered_unique< tag< Ent_mi_tag >, const_mem_fun< RefElement::interface_type_RefEntity, EntityHandle, &RefElement::getEnt > > > > RefElement_multiIndex

◆ addEntsToDatabase()

MoFEMErrorCode MoFEM::SetBitRefLevelTool::addEntsToDatabase ( const Range & seed_ents_range) const
inline

Definition at line 153 of file BitRefManager.cpp.

153 {
155
156 switch (mField.getValue()) {
157 case -1:
159 case 0:
161 case 1:
163 default:
164 SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
165 "Core index can vary from -1 to %d", MAX_CORE_TMP);
166 }
167
169 }
#define MAX_CORE_TMP
maximal number of cores
virtual const int getValue() const =0
Get the core.
MoFEMErrorCode addEntsToDatabaseImpl(const Range &seed_ents_range) const
add entities to database

◆ addEntsToDatabaseImpl()

template<int N>
MoFEMErrorCode MoFEM::SetBitRefLevelTool::addEntsToDatabaseImpl ( const Range & seed_ents_range) const
inline

add entities to database

Definition at line 99 of file BitRefManager.cpp.

99 {
101 std::vector<boost::shared_ptr<RefEntity>> shared_ref_ents_vec;
102 shared_ref_ents_vec.reserve(seed_ents_range.size());
103 std::vector<const void *> tag_by_ptr;
104 for (Range::const_pair_iterator pit = seed_ents_range.pair_begin();
105 pit != seed_ents_range.pair_end(); pit++) {
106 // add entities to database
107 EntityHandle f = pit->first;
108 EntityHandle s = pit->second;
109
110 boost::shared_ptr<std::vector<RefEntityTmp<N>>> ref_ents_vec(
111 new std::vector<RefEntityTmp<N>>());
112 ref_ents_vec->reserve(s - f + 1);
113
114 tag_by_ptr.resize(s - f + 1);
115 CHKERR baseEntData->moab.tag_get_by_ptr(
116 baseEntData->th_RefParentHandle, Range(f, s), &*tag_by_ptr.begin());
117 auto tag_parent_it = tag_by_ptr.begin();
118 for (auto f : Range(f, s)) {
119 ref_ents_vec->emplace_back(
120 baseEntData, f,
121 const_cast<EntityHandle *>(
122 static_cast<const EntityHandle *>(*tag_parent_it)));
123 ++tag_parent_it;
124 }
125
126 // Set bits to range
127 if (bIt.any()) {
128 tag_by_ptr.resize(s - f + 1);
129 CHKERR baseEntData->moab.tag_get_by_ptr(
130 baseEntData->th_RefBitLevel, Range(f, s), &*tag_by_ptr.begin());
131 for (auto &v_bit_ptr : tag_by_ptr)
132 const_cast<BitRefLevel &>(
133 *(static_cast<const BitRefLevel *>(v_bit_ptr))) |= bIt;
134 }
135
136 for (auto &re : *ref_ents_vec)
137 shared_ref_ents_vec.emplace_back(ref_ents_vec,
138 static_cast<RefEntity *>(&re));
139 }
140 if (!shared_ref_ents_vec.empty()) {
141 int s0 = refEntsPtr->size();
142 const_cast<RefEntity_multiIndex *>(refEntsPtr)
143 ->insert(shared_ref_ents_vec.begin(), shared_ref_ents_vec.end());
144 if ((refEntsPtr->size() - s0) != shared_ref_ents_vec.size()) {
145 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
146 "Data inconsistency %ld != %ld", refEntsPtr->size() - s0,
147 shared_ref_ents_vec.size());
148 }
149 }
151 }
#define CHKERR
Inline error check.
multi_index_container< boost::shared_ptr< RefEntity >, indexed_by< ordered_unique< tag< Ent_mi_tag >, const_mem_fun< RefEntity, EntityHandle, &RefEntity::getEnt > >, ordered_non_unique< tag< Ent_Ent_mi_tag >, const_mem_fun< RefEntity, EntityHandle, &RefEntity::getParentEnt > >, ordered_non_unique< tag< Composite_EntType_and_ParentEntType_mi_tag >, composite_key< RefEntity, const_mem_fun< RefEntity, EntityType, &RefEntity::getEntType >, const_mem_fun< RefEntity, EntityType, &RefEntity::getParentEntType > > >, ordered_non_unique< tag< Composite_ParentEnt_And_EntType_mi_tag >, composite_key< RefEntity, const_mem_fun< RefEntity, EntityType, &RefEntity::getEntType >, const_mem_fun< RefEntity, EntityHandle, &RefEntity::getParentEnt > > > > > RefEntity_multiIndex
RefEntityTmp< 0 > RefEntity

◆ findElementsToAdd()

MoFEMErrorCode MoFEM::SetBitRefLevelTool::findElementsToAdd ( EntityHandle f,
EntityHandle s,
Range & seed_fe_range ) const
inline

Definition at line 171 of file BitRefManager.cpp.

172 {
174 seed_fe_range.insert(f, s);
175 RefElement_multiIndex::iterator rit, hi_rit;
176 // get lower bound of multi-index
177 rit = refElementPtr->lower_bound(f);
178 if (rit == refElementPtr->end()) {
179 // all entities in range are added to database
181 } else {
182 // some entities from range are in database
183 hi_rit = refElementPtr->upper_bound(s);
184 for (; rit != hi_rit; ++rit) {
185 seed_fe_range.erase(rit->get()->getEnt());
186 }
187 }
189 }

◆ findEntsToAdd()

MoFEMErrorCode MoFEM::SetBitRefLevelTool::findEntsToAdd ( EntityHandle f,
EntityHandle s,
Range & seed_ents_range ) const
inline

find entities and change entity bit if in database

Definition at line 59 of file BitRefManager.cpp.

60 {
61 // MoFEMFunctionBeginHot;
62
63 seed_ents_range.insert(f, s);
64 // get lower bound of multi-index
65 auto rit = refEntsPtr->lower_bound(f);
66 if (rit == refEntsPtr->end()) {
67 // all entities in range are added to database
68 // MoFEMFunctionReturnHot(0);
69 return 0;
70 } else {
71
72 // some entities from range are in database
73 auto hi_rit = refEntsPtr->upper_bound(s);
74
75 Range to_erase;
76 insertOrdered(to_erase, RefEntExtractor(), rit, hi_rit);
77 if (bIt.any())
78 for (; rit != hi_rit; ++rit)
79 const_cast<BitRefLevel &>((*rit)->getBitRefLevel()) |= bIt;
80
81 Range::iterator lo, hi = seed_ents_range.begin();
82 for (auto pt = to_erase.pair_begin(); pt != to_erase.pair_end(); ++pt) {
83 lo = seed_ents_range.lower_bound(hi, seed_ents_range.end(), pt->first);
84 if (lo != seed_ents_range.end()) {
85 hi = seed_ents_range.upper_bound(lo, seed_ents_range.end(),
86 pt->second);
87 seed_ents_range.erase(lo, hi);
88 } else
89 break;
90 }
91 }
92
93 // MoFEMFunctionReturnHot(0);
94 return 0;
95 }
moab::Range::iterator insertOrdered(Range &r, Extractor, Iterator begin_iter, Iterator end_iter)
Insert ordered mofem multi-index into range.

Member Data Documentation

◆ baseEntData

boost::shared_ptr<BasicEntityData>& MoFEM::SetBitRefLevelTool::baseEntData

base entity data

Definition at line 48 of file BitRefManager.cpp.

◆ bIt

const BitRefLevel& MoFEM::SetBitRefLevelTool::bIt

bit to set

Definition at line 44 of file BitRefManager.cpp.

◆ mField

MoFEM::Interface& MoFEM::SetBitRefLevelTool::mField

Definition at line 42 of file BitRefManager.cpp.

◆ refElementPtr

const RefElement_multiIndex* MoFEM::SetBitRefLevelTool::refElementPtr

access to fe database

Definition at line 46 of file BitRefManager.cpp.

◆ refEntsPtr

const RefEntity_multiIndex* MoFEM::SetBitRefLevelTool::refEntsPtr

access to ents database

Definition at line 45 of file BitRefManager.cpp.


The documentation for this struct was generated from the following file: