v0.8.13
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 131 of file BitRefManager.cpp.

131  {
133  std::vector<boost::shared_ptr<RefElement> > shared_ref_fe_vec;
134  shared_ref_fe_vec.reserve(seed_fe_range.size());
135  // create ref entity instances
136  for (Range::const_pair_iterator pit = seed_fe_range.const_pair_begin();
137  pit != seed_fe_range.const_pair_end(); ++pit) {
138  RefEntity_multiIndex::iterator rit, hi_rit;
139  rit = refEntsPtr->lower_bound(pit->first);
140  hi_rit = refEntsPtr->upper_bound(pit->second);
141  if(static_cast<int>(std::distance(rit,hi_rit)) != static_cast<int>(pit->second-pit->first+1)) {
142  SETERRQ2(PETSC_COMM_WORLD, MOFEM_DATA_INCONSISTENCY,
143  "data inconsistency %d != %d", std::distance(rit, hi_rit),
144  pit->second - pit->first + 1);
145  }
146  switch ((*rit)->getEntType()) {
147  case MBVERTEX: {
148  boost::shared_ptr<std::vector<RefElement_VERTEX> > ref_fe_vec =
149  boost::make_shared<std::vector<RefElement_VERTEX> >();
150  ref_fe_vec->reserve(pit->second - pit->first + 1);
151  for (; rit != hi_rit; ++rit) {
152  ref_fe_vec->push_back(RefElement_VERTEX(*rit));
153  shared_ref_fe_vec.push_back(
154  boost::shared_ptr<RefElement>(ref_fe_vec, &ref_fe_vec->back()));
155  }
156  } break;
157  case MBEDGE: {
158  boost::shared_ptr<std::vector<RefElement_EDGE> > ref_fe_vec =
159  boost::make_shared<std::vector<RefElement_EDGE> >();
160  ref_fe_vec->reserve(pit->second - pit->first + 1);
161  for (; rit != hi_rit; ++rit) {
162  ref_fe_vec->push_back(RefElement_EDGE(*rit));
163  shared_ref_fe_vec.push_back(
164  boost::shared_ptr<RefElement>(ref_fe_vec, &ref_fe_vec->back()));
165  }
166  } break;
167  case MBTRI:{
168  boost::shared_ptr<std::vector<RefElement_TRI> > ref_fe_vec =
169  boost::make_shared<std::vector<RefElement_TRI> >();
170  ref_fe_vec->reserve(pit->second - pit->first + 1);
171  for (; rit != hi_rit; ++rit) {
172  ref_fe_vec->push_back(RefElement_TRI(*rit));
173  shared_ref_fe_vec.push_back(
174  boost::shared_ptr<RefElement>(ref_fe_vec, &ref_fe_vec->back()));
175  }
176  } break;
177  case MBTET:{
178  boost::shared_ptr<std::vector<RefElement_TET> > ref_fe_vec =
179  boost::make_shared<std::vector<RefElement_TET> >();
180  ref_fe_vec->reserve(pit->second - pit->first + 1);
181  for (; rit != hi_rit; ++rit) {
182  ref_fe_vec->push_back(RefElement_TET(*rit));
183  shared_ref_fe_vec.push_back(
184  boost::shared_ptr<RefElement>(ref_fe_vec, &ref_fe_vec->back()));
185  }
186  } break;
187  case MBPRISM:{
188  boost::shared_ptr<std::vector<RefElement_PRISM> > ref_fe_vec =
189  boost::make_shared<std::vector<RefElement_PRISM> >();
190  ref_fe_vec->reserve(pit->second - pit->first + 1);
191  for (; rit != hi_rit; ++rit) {
192  ref_fe_vec->push_back(RefElement_PRISM(*rit));
193  shared_ref_fe_vec.push_back(
194  boost::shared_ptr<RefElement>(ref_fe_vec, &ref_fe_vec->back()));
195  }
196  } break;
197  case MBENTITYSET:{
198  boost::shared_ptr<std::vector<RefElement_MESHSET> > ref_fe_vec =
199  boost::make_shared<std::vector<RefElement_MESHSET> >();
200  ref_fe_vec->reserve(pit->second - pit->first + 1);
201  for (; rit != hi_rit; ++rit) {
202  ref_fe_vec->push_back(RefElement_MESHSET(*rit));
203  shared_ref_fe_vec.push_back(
204  boost::shared_ptr<RefElement>(ref_fe_vec, &ref_fe_vec->back()));
205  }
206  } break;
207  default:
208  SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED, "not implemented");
209  }
210  }
211  // add shared pointers to database
212  const_cast<RefElement_multiIndex *>(refElementPtr)
213  ->insert(shared_ref_fe_vec.begin(), shared_ref_fe_vec.end());
215  }
multi_index_container< boost::shared_ptr< RefElement >, indexed_by< ordered_unique< tag< Ent_mi_tag >, const_mem_fun< RefElement::interface_type_RefEntity, EntityHandle, &RefElement::getRefEnt > >, ordered_non_unique< tag< EntType_mi_tag >, const_mem_fun< RefElement::interface_type_RefEntity, EntityType, &RefElement::getEntType > > > > RefElement_multiIndex
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:519
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return() ...
Definition: definitions.h:526
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  // if (bIt.none())
80  // MoFEMFunctionReturnHot(0);
81  std::vector<boost::shared_ptr<RefEntity> > shared_ref_ents_vec;
82  shared_ref_ents_vec.reserve(seed_ents_range.size());
83  for (Range::const_pair_iterator pit = seed_ents_range.pair_begin();
84  pit != seed_ents_range.pair_end(); pit++) {
85  // add entities to database
86  EntityHandle f = pit->first;
87  EntityHandle s = pit->second;
88  boost::shared_ptr<std::vector<RefEntity> > ref_ents_vec =
89  boost::make_shared<std::vector<RefEntity> >();
90  ref_ents_vec->reserve(s - f + 1);
91  for (; f != (s+1); ++f) {
92  ref_ents_vec->push_back(RefEntity(baseEntData, f));
93  *(ref_ents_vec->back().getBitRefLevelPtr()) |= bIt;
94  shared_ref_ents_vec.push_back(
95  boost::shared_ptr<RefEntity>(ref_ents_vec, &ref_ents_vec->back()));
96  }
97  }
98  if (!shared_ref_ents_vec.empty()) {
99  int s0 = refEntsPtr->size();
100  const_cast<RefEntity_multiIndex *>(refEntsPtr)
101  ->insert(shared_ref_ents_vec.begin(), shared_ref_ents_vec.end());
102  if ((refEntsPtr->size() - s0) != shared_ref_ents_vec.size()) {
103  SETERRQ2(PETSC_COMM_WORLD, MOFEM_DATA_INCONSISTENCY,
104  "Data inconsistency %d != %d", refEntsPtr->size() - s0,
105  shared_ref_ents_vec.size());
106  }
107  }
109  }
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:519
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return() ...
Definition: definitions.h:526
const RefEntity_multiIndex * refEntsPtr
access to ents database
boost::shared_ptr< BasicEntityData > & baseEntData
base entity data
multi_index_container< boost::shared_ptr< RefEntity >, indexed_by< ordered_unique< tag< Ent_mi_tag >, member< RefEntity::BasicEntity, EntityHandle, &RefEntity::ent > >, ordered_non_unique< tag< Ent_Ent_mi_tag >, const_mem_fun< RefEntity, EntityHandle, &RefEntity::getParentEnt > >, ordered_non_unique< tag< EntType_mi_tag >, const_mem_fun< RefEntity::BasicEntity, EntityType, &RefEntity::getEntType > >, ordered_non_unique< tag< ParentEntType_mi_tag >, const_mem_fun< RefEntity, EntityType, &RefEntity::getParentEntType > >, ordered_non_unique< tag< Composite_EntType_and_ParentEntType_mi_tag >, composite_key< RefEntity, const_mem_fun< RefEntity::BasicEntity, 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::BasicEntity, EntityType, &RefEntity::getEntType >, const_mem_fun< RefEntity, EntityHandle, &RefEntity::getParentEnt > > > > > RefEntity_multiIndex
const BitRefLevel & bIt
bit to set

◆ findElementsToAdd()

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

Definition at line 111 of file BitRefManager.cpp.

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

◆ 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:519
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return() ...
Definition: definitions.h:526
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: