v0.8.23
Public Member Functions | Public Attributes | List of all members
MoFEM::SetBitRefLevelTool Struct Reference

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

Public Member Functions

 SetBitRefLevelTool (MoFEM::Interface &m_field, const BitRefLevel &bit, const RefEntity_multiIndex *ref_ents_ptr, const RefElement_multiIndex *ref_element_ptr)
 constrictor More...
 
MoFEMErrorCode findEntsToAdd (EntityHandle f, EntityHandle s, Range &seed_ents_range) const
 find entities and change entity bit if in database More...
 
MoFEMErrorCode addEntsToDatabase (const Range &seed_ents_range) const
 add entities to database More...
 
MoFEMErrorCode findElementsToAdd (EntityHandle f, EntityHandle s, Range &seed_fe_range) const
 
MoFEMErrorCode addElementsToDatabase (Range &seed_fe_range) const
 

Public Attributes

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

Detailed Description

tool class with methods used more than twp times

Definition at line 39 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 
)

constrictor

Definition at line 48 of file BitRefManager.cpp.

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

Member Function Documentation

◆ addElementsToDatabase()

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

Definition at line 156 of file BitRefManager.cpp.

156  {
158  std::vector<boost::shared_ptr<RefElement>> shared_ref_fe_vec;
159  shared_ref_fe_vec.reserve(seed_fe_range.size());
160  // create ref entity instances
161  for (Range::const_pair_iterator pit = seed_fe_range.const_pair_begin();
162  pit != seed_fe_range.const_pair_end(); ++pit) {
163  RefEntity_multiIndex::iterator rit, hi_rit;
164  rit = refEntsPtr->lower_bound(pit->first);
165  hi_rit = refEntsPtr->upper_bound(pit->second);
166  if (static_cast<int>(std::distance(rit, hi_rit)) !=
167  static_cast<int>(pit->second - pit->first + 1)) {
168  SETERRQ2(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
169  "data inconsistency %d != %d", std::distance(rit, hi_rit),
170  pit->second - pit->first + 1);
171  }
172  switch ((*rit)->getEntType()) {
173  case MBVERTEX: {
174  boost::shared_ptr<std::vector<RefElement_VERTEX>> ref_fe_vec =
175  boost::make_shared<std::vector<RefElement_VERTEX>>();
176  ref_fe_vec->reserve(pit->second - pit->first + 1);
177  for (; rit != hi_rit; ++rit) {
178  ref_fe_vec->push_back(RefElement_VERTEX(*rit));
179  shared_ref_fe_vec.push_back(
180  boost::shared_ptr<RefElement>(ref_fe_vec, &ref_fe_vec->back()));
181  }
182  } break;
183  case MBEDGE: {
184  boost::shared_ptr<std::vector<RefElement_EDGE>> ref_fe_vec =
185  boost::make_shared<std::vector<RefElement_EDGE>>();
186  ref_fe_vec->reserve(pit->second - pit->first + 1);
187  for (; rit != hi_rit; ++rit) {
188  ref_fe_vec->push_back(RefElement_EDGE(*rit));
189  shared_ref_fe_vec.push_back(
190  boost::shared_ptr<RefElement>(ref_fe_vec, &ref_fe_vec->back()));
191  }
192  } break;
193  case MBTRI: {
194  boost::shared_ptr<std::vector<RefElement_TRI>> ref_fe_vec =
195  boost::make_shared<std::vector<RefElement_TRI>>();
196  ref_fe_vec->reserve(pit->second - pit->first + 1);
197  for (; rit != hi_rit; ++rit) {
198  ref_fe_vec->push_back(RefElement_TRI(*rit));
199  shared_ref_fe_vec.push_back(
200  boost::shared_ptr<RefElement>(ref_fe_vec, &ref_fe_vec->back()));
201  }
202  } break;
203  case MBTET: {
204  boost::shared_ptr<std::vector<RefElement_TET>> ref_fe_vec =
205  boost::make_shared<std::vector<RefElement_TET>>();
206  ref_fe_vec->reserve(pit->second - pit->first + 1);
207  for (; rit != hi_rit; ++rit) {
208  ref_fe_vec->push_back(RefElement_TET(*rit));
209  shared_ref_fe_vec.push_back(
210  boost::shared_ptr<RefElement>(ref_fe_vec, &ref_fe_vec->back()));
211  }
212  } break;
213  case MBPRISM: {
214  boost::shared_ptr<std::vector<RefElement_PRISM>> ref_fe_vec =
215  boost::make_shared<std::vector<RefElement_PRISM>>();
216  ref_fe_vec->reserve(pit->second - pit->first + 1);
217  for (; rit != hi_rit; ++rit) {
218  ref_fe_vec->push_back(RefElement_PRISM(*rit));
219  shared_ref_fe_vec.push_back(
220  boost::shared_ptr<RefElement>(ref_fe_vec, &ref_fe_vec->back()));
221  }
222  } break;
223  case MBENTITYSET: {
224  boost::shared_ptr<std::vector<RefElement_MESHSET>> ref_fe_vec =
225  boost::make_shared<std::vector<RefElement_MESHSET>>();
226  ref_fe_vec->reserve(pit->second - pit->first + 1);
227  for (; rit != hi_rit; ++rit) {
228  ref_fe_vec->push_back(RefElement_MESHSET(*rit));
229  shared_ref_fe_vec.push_back(
230  boost::shared_ptr<RefElement>(ref_fe_vec, &ref_fe_vec->back()));
231  }
232  } break;
233  default:
234  SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED, "not implemented");
235  }
236  }
237  // add shared pointers to database
238  const_cast<RefElement_multiIndex *>(refElementPtr)
239  ->insert(shared_ref_fe_vec.begin(), shared_ref_fe_vec.end());
241  }
const RefElement_multiIndex * refElementPtr
access to fe database
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:501
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:508
const RefEntity_multiIndex * refEntsPtr
access to ents database

◆ addEntsToDatabase()

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

add entities to database

Definition at line 93 of file BitRefManager.cpp.

93  {
95  std::vector<boost::shared_ptr<RefEntity>> shared_ref_ents_vec;
96  shared_ref_ents_vec.reserve(seed_ents_range.size());
97  for (Range::const_pair_iterator pit = seed_ents_range.pair_begin();
98  pit != seed_ents_range.pair_end(); pit++) {
99  // add entities to database
100  EntityHandle f = pit->first;
101  EntityHandle s = pit->second;
102  boost::shared_ptr<std::vector<RefEntity>> ref_ents_vec(
103  new std::vector<RefEntity>());
104  ref_ents_vec->reserve(s - f + 1);
105  for (auto f : Range(f, s))
106  ref_ents_vec->emplace_back(baseEntData, f);
107 
108  // Set bits to range
109  if (bIt.any()) {
110  boost::shared_ptr<std::vector<const void *>> bits_by_ptr(
111  new std::vector<const void *>());
112  bits_by_ptr->resize(s - f + 1);
113  CHKERR baseEntData->moab.tag_get_by_ptr(
114  baseEntData->th_RefBitLevel, Range(f, s), &*bits_by_ptr->begin());
115  for (auto &v_bit_ptr : *bits_by_ptr)
116  const_cast<BitRefLevel &>(
117  *(static_cast<const BitRefLevel *>(v_bit_ptr))) |= bIt;
118  }
119 
120  for (auto &re : *ref_ents_vec)
121  shared_ref_ents_vec.emplace_back(ref_ents_vec, &re);
122  }
123  if (!shared_ref_ents_vec.empty()) {
124  int s0 = refEntsPtr->size();
125  const_cast<RefEntity_multiIndex *>(refEntsPtr)
126  ->insert(shared_ref_ents_vec.begin(), shared_ref_ents_vec.end());
127  if ((refEntsPtr->size() - s0) != shared_ref_ents_vec.size()) {
128  SETERRQ2(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
129  "Data inconsistency %d != %d", refEntsPtr->size() - s0,
130  shared_ref_ents_vec.size());
131  }
132  }
134  }
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:501
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:508
const RefEntity_multiIndex * refEntsPtr
access to ents database
#define CHKERR
Inline error check.
Definition: definitions.h:596
boost::shared_ptr< BasicEntityData > & baseEntData
base entity data
const BitRefLevel & bIt
bit to set

◆ findElementsToAdd()

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

Definition at line 136 of file BitRefManager.cpp.

137  {
139  seed_fe_range.insert(f, s);
140  RefElement_multiIndex::iterator rit, hi_rit;
141  // get lower bound of multi-index
142  rit = refElementPtr->lower_bound(f);
143  if (rit == refElementPtr->end()) {
144  // all enties in range are added to database
146  } else {
147  // some entities from range are in database
148  hi_rit = refElementPtr->upper_bound(s);
149  for (; rit != hi_rit; ++rit) {
150  seed_fe_range.erase(rit->get()->getRefEnt());
151  }
152  }
154  }
const RefElement_multiIndex * refElementPtr
access to fe database
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:501
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:508

◆ findEntsToAdd()

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

find entities and change entity bit if in database

Definition at line 55 of file BitRefManager.cpp.

56  {
58 
59  seed_ents_range.insert(f, s);
60  // get lower bound of multi-index
61  auto rit = refEntsPtr->lower_bound(f);
62  if (rit == refEntsPtr->end()) {
63  // all enties in range are added to database
65  } else {
66 
67  // some entities from range are in database
68  auto hi_rit = refEntsPtr->upper_bound(s);
69 
70  Range to_erase;
71  insertOrdered(to_erase, RefEntExtractor(), rit, hi_rit);
72  if (bIt.any())
73  for (; rit != hi_rit; ++rit)
74  const_cast<BitRefLevel &>((*rit)->getBitRefLevel()) |= bIt;
75 
76  Range::iterator lo, hi = seed_ents_range.begin();
77  for (auto pt = to_erase.pair_begin(); pt != to_erase.pair_end(); ++pt) {
78  lo = seed_ents_range.lower_bound(hi, seed_ents_range.end(), pt->first);
79  if (lo != seed_ents_range.end()) {
80  hi = seed_ents_range.upper_bound(lo, seed_ents_range.end(),
81  pt->second);
82  seed_ents_range.erase(lo, hi);
83  } else
84  break;
85  }
86 
87  }
88 
90  }
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:501
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:508
moab::Range::iterator insertOrdered(Range &r, Extractor, Iterator begin_iter, Iterator end_iter)
Insert ordered mofem multi-index into range.
Definition: Templates.hpp:590
const RefEntity_multiIndex * refEntsPtr
access to ents database
const BitRefLevel & bIt
bit to set

Member Data Documentation

◆ baseEntData

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

base entity data

Definition at line 45 of file BitRefManager.cpp.

◆ bIt

const BitRefLevel& MoFEM::SetBitRefLevelTool::bIt

bit to set

Definition at line 41 of file BitRefManager.cpp.

◆ refElementPtr

const RefElement_multiIndex* MoFEM::SetBitRefLevelTool::refElementPtr

access to fe database

Definition at line 43 of file BitRefManager.cpp.

◆ refEntsPtr

const RefEntity_multiIndex* MoFEM::SetBitRefLevelTool::refEntsPtr

access to ents database

Definition at line 42 of file BitRefManager.cpp.


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