v0.14.0
Public Member Functions | Public Attributes | List of all members
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)
 constrictor More...
 
MoFEMErrorCode findEntsToAdd (EntityHandle f, EntityHandle s, Range &seed_ents_range) const
 find entities and change entity bit if in database More...
 
template<int N>
MoFEMErrorCode addEntsToDatabaseImpl (const Range &seed_ents_range) const
 add entities to database More...
 
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 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 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

constrictor

Definition at line 51 of file BitRefManager.cpp.

54  : mField(m_field), bIt(bit), refEntsPtr(ref_ents_ptr),
55  refElementPtr(ref_element_ptr),

Member Function Documentation

◆ addElementsToDatabase()

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

Definition at line 189 of file BitRefManager.cpp.

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

◆ addEntsToDatabase()

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

Definition at line 151 of file BitRefManager.cpp.

151  {
153 
154  switch (mField.getValue()) {
155  case -1:
156  return addEntsToDatabaseImpl<-1>(seed_ents_range);
157  case 0:
158  return addEntsToDatabaseImpl<0>(seed_ents_range);
159  case 1:
160  return addEntsToDatabaseImpl<1>(seed_ents_range);
161  default:
162  SETERRQ1(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
163  "Core index can vary from -1 to %d", MAX_CORE_TMP);
164  }
165 
167  }

◆ addEntsToDatabaseImpl()

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

add entities to database

Definition at line 97 of file BitRefManager.cpp.

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

◆ findElementsToAdd()

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

Definition at line 169 of file BitRefManager.cpp.

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

◆ 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  {
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 enties in range are added to database
69  } else {
70 
71  // some entities from range are in database
72  auto hi_rit = refEntsPtr->upper_bound(s);
73 
74  Range to_erase;
75  insertOrdered(to_erase, RefEntExtractor(), rit, hi_rit);
76  if (bIt.any())
77  for (; rit != hi_rit; ++rit)
78  const_cast<BitRefLevel &>((*rit)->getBitRefLevel()) |= bIt;
79 
80  Range::iterator lo, hi = seed_ents_range.begin();
81  for (auto pt = to_erase.pair_begin(); pt != to_erase.pair_end(); ++pt) {
82  lo = seed_ents_range.lower_bound(hi, seed_ents_range.end(), pt->first);
83  if (lo != seed_ents_range.end()) {
84  hi = seed_ents_range.upper_bound(lo, seed_ents_range.end(),
85  pt->second);
86  seed_ents_range.erase(lo, hi);
87  } else
88  break;
89  }
90  }
91 
93  }

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:
MoFEMFunctionReturnHot
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:447
EntityHandle
MoFEM::RefElement_multiIndex
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
Definition: RefElementMultiIndices.hpp:180
MoFEM::SetBitRefLevelTool::refEntsPtr
const RefEntity_multiIndex * refEntsPtr
access to ents database
Definition: BitRefManager.cpp:45
MoFEM::RefEntity_multiIndex
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
Definition: RefEntsMultiIndices.hpp:760
CHKERR
#define CHKERR
Inline error check.
Definition: definitions.h:535
MoFEM::insertOrdered
moab::Range::iterator insertOrdered(Range &r, Extractor, Iterator begin_iter, Iterator end_iter)
Insert ordered mofem multi-index into range.
Definition: Templates.hpp:1788
bit
auto bit
set bit
Definition: hanging_node_approx.cpp:75
MoFEM::CoreInterface::get_basic_entity_data_ptr
virtual boost::shared_ptr< BasicEntityData > & get_basic_entity_data_ptr()=0
Get pointer to basic entity data.
MoFEM::SetBitRefLevelTool::mField
MoFEM::Interface & mField
Definition: BitRefManager.cpp:42
MoFEM::RefEntity
RefEntityTmp< 0 > RefEntity
Definition: RefEntsMultiIndices.hpp:566
Range
MAX_CORE_TMP
#define MAX_CORE_TMP
maximal number of cores
Definition: definitions.h:217
HenckyOps::f
auto f
Definition: HenckyOps.hpp:15
MoFEM::SetBitRefLevelTool::bIt
const BitRefLevel & bIt
bit to set
Definition: BitRefManager.cpp:44
MOFEM_DATA_INCONSISTENCY
@ MOFEM_DATA_INCONSISTENCY
Definition: definitions.h:31
MoFEM::Types::BitRefLevel
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
Definition: Types.hpp:40
MoFEMFunctionBeginHot
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:440
MoFEM::SetBitRefLevelTool::baseEntData
boost::shared_ptr< BasicEntityData > & baseEntData
base entity data
Definition: BitRefManager.cpp:48
MoFEM::SetBitRefLevelTool::refElementPtr
const RefElement_multiIndex * refElementPtr
access to fe database
Definition: BitRefManager.cpp:46
MOFEM_NOT_IMPLEMENTED
@ MOFEM_NOT_IMPLEMENTED
Definition: definitions.h:32
MoFEM::CoreInterface::getValue
virtual const int getValue() const =0
Get the core.
MoFEM::SetBitRefLevelTool::addEntsToDatabaseImpl
MoFEMErrorCode addEntsToDatabaseImpl(const Range &seed_ents_range) const
add entities to database
Definition: BitRefManager.cpp:97