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 138 of file BitRefManager.cpp.

138  {
140  std::vector<boost::shared_ptr<RefElement> > shared_ref_fe_vec;
141  shared_ref_fe_vec.reserve(seed_fe_range.size());
142  // create ref entity instances
143  for (Range::const_pair_iterator pit = seed_fe_range.const_pair_begin();
144  pit != seed_fe_range.const_pair_end(); ++pit) {
145  RefEntity_multiIndex::iterator rit, hi_rit;
146  rit = refEntsPtr->lower_bound(pit->first);
147  hi_rit = refEntsPtr->upper_bound(pit->second);
148  if(static_cast<int>(std::distance(rit,hi_rit)) != static_cast<int>(pit->second-pit->first+1)) {
149  SETERRQ2(PETSC_COMM_WORLD, MOFEM_DATA_INCONSISTENCY,
150  "data inconsistency %d != %d", std::distance(rit, hi_rit),
151  pit->second - pit->first + 1);
152  }
153  switch ((*rit)->getEntType()) {
154  case MBVERTEX: {
155  boost::shared_ptr<std::vector<RefElement_VERTEX> > ref_fe_vec =
156  boost::make_shared<std::vector<RefElement_VERTEX> >();
157  ref_fe_vec->reserve(pit->second - pit->first + 1);
158  for (; rit != hi_rit; ++rit) {
159  ref_fe_vec->push_back(RefElement_VERTEX(*rit));
160  shared_ref_fe_vec.push_back(
161  boost::shared_ptr<RefElement>(ref_fe_vec, &ref_fe_vec->back()));
162  }
163  } break;
164  case MBEDGE: {
165  boost::shared_ptr<std::vector<RefElement_EDGE> > ref_fe_vec =
166  boost::make_shared<std::vector<RefElement_EDGE> >();
167  ref_fe_vec->reserve(pit->second - pit->first + 1);
168  for (; rit != hi_rit; ++rit) {
169  ref_fe_vec->push_back(RefElement_EDGE(*rit));
170  shared_ref_fe_vec.push_back(
171  boost::shared_ptr<RefElement>(ref_fe_vec, &ref_fe_vec->back()));
172  }
173  } break;
174  case MBTRI:{
175  boost::shared_ptr<std::vector<RefElement_TRI> > ref_fe_vec =
176  boost::make_shared<std::vector<RefElement_TRI> >();
177  ref_fe_vec->reserve(pit->second - pit->first + 1);
178  for (; rit != hi_rit; ++rit) {
179  ref_fe_vec->push_back(RefElement_TRI(*rit));
180  shared_ref_fe_vec.push_back(
181  boost::shared_ptr<RefElement>(ref_fe_vec, &ref_fe_vec->back()));
182  }
183  } break;
184  case MBTET:{
185  boost::shared_ptr<std::vector<RefElement_TET> > ref_fe_vec =
186  boost::make_shared<std::vector<RefElement_TET> >();
187  ref_fe_vec->reserve(pit->second - pit->first + 1);
188  for (; rit != hi_rit; ++rit) {
189  ref_fe_vec->push_back(RefElement_TET(*rit));
190  shared_ref_fe_vec.push_back(
191  boost::shared_ptr<RefElement>(ref_fe_vec, &ref_fe_vec->back()));
192  }
193  } break;
194  case MBPRISM:{
195  boost::shared_ptr<std::vector<RefElement_PRISM> > ref_fe_vec =
196  boost::make_shared<std::vector<RefElement_PRISM> >();
197  ref_fe_vec->reserve(pit->second - pit->first + 1);
198  for (; rit != hi_rit; ++rit) {
199  ref_fe_vec->push_back(RefElement_PRISM(*rit));
200  shared_ref_fe_vec.push_back(
201  boost::shared_ptr<RefElement>(ref_fe_vec, &ref_fe_vec->back()));
202  }
203  } break;
204  case MBENTITYSET:{
205  boost::shared_ptr<std::vector<RefElement_MESHSET> > ref_fe_vec =
206  boost::make_shared<std::vector<RefElement_MESHSET> >();
207  ref_fe_vec->reserve(pit->second - pit->first + 1);
208  for (; rit != hi_rit; ++rit) {
209  ref_fe_vec->push_back(RefElement_MESHSET(*rit));
210  shared_ref_fe_vec.push_back(
211  boost::shared_ptr<RefElement>(ref_fe_vec, &ref_fe_vec->back()));
212  }
213  } break;
214  default:
215  SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED, "not implemented");
216  }
217  }
218  // add shared pointers to database
219  const_cast<RefElement_multiIndex *>(refElementPtr)
220  ->insert(shared_ref_fe_vec.begin(), shared_ref_fe_vec.end());
222  }
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:500
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:507
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 77 of file BitRefManager.cpp.

77  {
79  std::vector<boost::shared_ptr<RefEntity> > shared_ref_ents_vec;
80  shared_ref_ents_vec.reserve(seed_ents_range.size());
81  for (Range::const_pair_iterator pit = seed_ents_range.pair_begin();
82  pit != seed_ents_range.pair_end(); pit++) {
83  // add entities to database
84  EntityHandle f = pit->first;
85  EntityHandle s = pit->second;
86  boost::shared_ptr<std::vector<RefEntity>> ref_ents_vec(
87  new std::vector<RefEntity>());
88  ref_ents_vec->reserve(s - f + 1);
89  for (auto f : Range(f, s))
90  ref_ents_vec->emplace_back(baseEntData, f);
91 
92  // Set bits to range
93  boost::shared_ptr<std::vector<const void *>> bits_by_ptr(
94  new std::vector<const void *>());
95  bits_by_ptr->resize(s - f + 1);
96  CHKERR baseEntData->moab.tag_get_by_ptr(
97  baseEntData->th_RefBitLevel, Range(f, s), &*bits_by_ptr->begin());
98  for (auto &v_bit_ptr : *bits_by_ptr)
99  const_cast<BitRefLevel &>(
100  *(static_cast<const BitRefLevel *>(v_bit_ptr))) |= bIt;
101 
102  for (auto &re : *ref_ents_vec)
103  shared_ref_ents_vec.emplace_back(ref_ents_vec, &re);
104  }
105  if (!shared_ref_ents_vec.empty()) {
106  int s0 = refEntsPtr->size();
107  const_cast<RefEntity_multiIndex *>(refEntsPtr)
108  ->insert(shared_ref_ents_vec.begin(), shared_ref_ents_vec.end());
109  if ((refEntsPtr->size() - s0) != shared_ref_ents_vec.size()) {
110  SETERRQ2(PETSC_COMM_WORLD, MOFEM_DATA_INCONSISTENCY,
111  "Data inconsistency %d != %d", refEntsPtr->size() - s0,
112  shared_ref_ents_vec.size());
113  }
114  }
116  }
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:500
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:507
const RefEntity_multiIndex * refEntsPtr
access to ents database
#define CHKERR
Inline error check.
Definition: definitions.h:595
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 118 of file BitRefManager.cpp.

119  {
121  seed_fe_range.insert(f, s);
122  RefElement_multiIndex::iterator rit, hi_rit;
123  // get lower bound of multi-index
124  rit = refElementPtr->lower_bound(f);
125  if (rit == refElementPtr->end()) {
126  // all enties in range are added to database
128  } else {
129  // some entities from range are in database
130  hi_rit = refElementPtr->upper_bound(s);
131  for (; rit != hi_rit; ++rit) {
132  seed_fe_range.erase(rit->get()->getRefEnt());
133  }
134  }
136  }
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:500
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:507

◆ 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  seed_ents_range.insert(f, s);
59  RefEntity_multiIndex::iterator rit, hi_rit;
60  // get lower bound of multi-index
61  rit = refEntsPtr->lower_bound(f);
62  if (rit == refEntsPtr->end()) {
63  // all enties in range are added to database
65  } else {
66  // some entities from range are in database
67  hi_rit = refEntsPtr->upper_bound(s);
68  for (; rit != hi_rit; ++rit) {
69  *(const_cast<RefEntity *>(rit->get())->getBitRefLevelPtr()) |= bIt;
70  seed_ents_range.erase(rit->get()->getRefEnt());
71  }
72  }
74  }
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:500
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:507
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: