v0.10.0
BitRefManager.cpp
Go to the documentation of this file.
1 /** \file BitRefManager.cpp
2  * \brief Managing BitRefLevels
3  * \mofem_bit_ref
4  */
5 
6 /* MoFEM is free software: you can redistribute it and/or modify it under
7  * the terms of the GNU Lesser General Public License as published by the
8  * Free Software Foundation, either version 3 of the License, or (at your
9  * option) any later version.
10  *
11  * MoFEM is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14  * License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with MoFEM. If not, see <http://www.gnu.org/licenses/>
18  */
19 
20 namespace MoFEM {
21 
23  UnknownInterface **iface) const {
25  *iface = NULL;
26  if (uuid == IDD_MOFEMBitRefManager) {
27  *iface = const_cast<BitRefManager *>(this);
29  }
30  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY, "unknown interface");
32 }
33 
35  : cOre(const_cast<MoFEM::Core &>(core)), dEbug(false) {
36 
37  try {
38  MoFEM::LogManager::getLog("BitRefSelf");
39  } catch (...) {
40  auto core_log = logging::core::get();
41  core_log->add_sink(
43  LogManager::setLog("BitRefSelf");
44  core_log->add_sink(
46  LogManager::setLog("BitRefWorld");
47  core_log->add_sink(
49  LogManager::setLog("BitRefSync");
50  MOFEM_LOG_TAG("BitRefSelf", "BitRefManager");
51  MOFEM_LOG_TAG("BitRefWorld", "BitRefManager");
52  MOFEM_LOG_TAG("BitRefSync", "BitRefManager");
53  }
54 
56  MOFEM_LOG("BitRefWorld", Sev::noisy) << "BitRefManager interface created";
57 }
58 
59 /// tool class with methods used more than twp times
61 
63 
64  const BitRefLevel &bIt; ///< bit to set
65  const RefEntity_multiIndex *refEntsPtr; ///< access to ents database
66  const RefElement_multiIndex *refElementPtr; ///< access to fe database
67 
68  boost::shared_ptr<BasicEntityData> &baseEntData; ///< base entity data
69 
70  /// constrictor
72  const RefEntity_multiIndex *ref_ents_ptr,
73  const RefElement_multiIndex *ref_element_ptr)
74  : mField(m_field), bIt(bit), refEntsPtr(ref_ents_ptr),
75  refElementPtr(ref_element_ptr),
76  baseEntData(m_field.get_basic_entity_data_ptr()) {}
77 
78  /// find entities and change entity bit if in database
80  Range &seed_ents_range) const {
82 
83  seed_ents_range.insert(f, s);
84  // get lower bound of multi-index
85  auto rit = refEntsPtr->lower_bound(f);
86  if (rit == refEntsPtr->end()) {
87  // all enties in range are added to database
89  } else {
90 
91  // some entities from range are in database
92  auto hi_rit = refEntsPtr->upper_bound(s);
93 
94  Range to_erase;
95  insertOrdered(to_erase, RefEntExtractor(), rit, hi_rit);
96  if (bIt.any())
97  for (; rit != hi_rit; ++rit)
98  const_cast<BitRefLevel &>((*rit)->getBitRefLevel()) |= bIt;
99 
100  Range::iterator lo, hi = seed_ents_range.begin();
101  for (auto pt = to_erase.pair_begin(); pt != to_erase.pair_end(); ++pt) {
102  lo = seed_ents_range.lower_bound(hi, seed_ents_range.end(), pt->first);
103  if (lo != seed_ents_range.end()) {
104  hi = seed_ents_range.upper_bound(lo, seed_ents_range.end(),
105  pt->second);
106  seed_ents_range.erase(lo, hi);
107  } else
108  break;
109  }
110  }
111 
113  }
114 
115  /// add entities to database
116  template <int N>
117  MoFEMErrorCode addEntsToDatabaseImpl(const Range &seed_ents_range) const {
119  std::vector<boost::shared_ptr<RefEntity>> shared_ref_ents_vec;
120  shared_ref_ents_vec.reserve(seed_ents_range.size());
121  for (Range::const_pair_iterator pit = seed_ents_range.pair_begin();
122  pit != seed_ents_range.pair_end(); pit++) {
123  // add entities to database
124  EntityHandle f = pit->first;
125  EntityHandle s = pit->second;
126  boost::shared_ptr<std::vector<RefEntityTmp<N>>> ref_ents_vec(
127  new std::vector<RefEntityTmp<N>>());
128  ref_ents_vec->reserve(s - f + 1);
129  for (auto f : Range(f, s))
130  ref_ents_vec->emplace_back(baseEntData, f);
131 
132  // Set bits to range
133  if (bIt.any()) {
134  boost::shared_ptr<std::vector<const void *>> bits_by_ptr(
135  new std::vector<const void *>());
136  bits_by_ptr->resize(s - f + 1);
137  CHKERR baseEntData->moab.tag_get_by_ptr(
138  baseEntData->th_RefBitLevel, Range(f, s), &*bits_by_ptr->begin());
139  for (auto &v_bit_ptr : *bits_by_ptr)
140  const_cast<BitRefLevel &>(
141  *(static_cast<const BitRefLevel *>(v_bit_ptr))) |= bIt;
142  }
143 
144  for (auto &re : *ref_ents_vec)
145  shared_ref_ents_vec.emplace_back(ref_ents_vec,
146  static_cast<RefEntity *>(&re));
147  }
148  if (!shared_ref_ents_vec.empty()) {
149  int s0 = refEntsPtr->size();
150  const_cast<RefEntity_multiIndex *>(refEntsPtr)
151  ->insert(shared_ref_ents_vec.begin(), shared_ref_ents_vec.end());
152  if ((refEntsPtr->size() - s0) != shared_ref_ents_vec.size()) {
153  SETERRQ2(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
154  "Data inconsistency %d != %d", refEntsPtr->size() - s0,
155  shared_ref_ents_vec.size());
156  }
157  }
159  }
160 
161  MoFEMErrorCode addEntsToDatabase(const Range &seed_ents_range) const {
163 
164  boost::hana::for_each(
165 
166  boost::hana::make_range(boost::hana::int_c<-1>,
167  boost::hana::int_c<MAX_CORE_TMP>),
168 
169  [&](auto r) {
170  if (mField.getValue() == r)
171  CHKERR addEntsToDatabaseImpl<r>(seed_ents_range);
172  }
173 
174  );
175 
177  }
178 
180  Range &seed_fe_range) const {
182  seed_fe_range.insert(f, s);
183  RefElement_multiIndex::iterator rit, hi_rit;
184  // get lower bound of multi-index
185  rit = refElementPtr->lower_bound(f);
186  if (rit == refElementPtr->end()) {
187  // all enties in range are added to database
189  } else {
190  // some entities from range are in database
191  hi_rit = refElementPtr->upper_bound(s);
192  for (; rit != hi_rit; ++rit) {
193  seed_fe_range.erase(rit->get()->getEnt());
194  }
195  }
197  }
198 
199  MoFEMErrorCode addElementsToDatabase(Range &seed_fe_range) const {
201  std::vector<boost::shared_ptr<RefElement>> shared_ref_fe_vec;
202  shared_ref_fe_vec.reserve(seed_fe_range.size());
203  // create ref entity instances
204  for (Range::const_pair_iterator pit = seed_fe_range.const_pair_begin();
205  pit != seed_fe_range.const_pair_end(); ++pit) {
206  RefEntity_multiIndex::iterator rit, hi_rit;
207  rit = refEntsPtr->lower_bound(pit->first);
208  hi_rit = refEntsPtr->upper_bound(pit->second);
209  if (static_cast<int>(std::distance(rit, hi_rit)) !=
210  static_cast<int>(pit->second - pit->first + 1)) {
211  SETERRQ2(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
212  "data inconsistency %d != %d", std::distance(rit, hi_rit),
213  pit->second - pit->first + 1);
214  }
215  switch ((*rit)->getEntType()) {
216  case MBVERTEX: {
217  boost::shared_ptr<std::vector<RefElement_VERTEX>> ref_fe_vec =
218  boost::make_shared<std::vector<RefElement_VERTEX>>();
219  ref_fe_vec->reserve(pit->second - pit->first + 1);
220  for (; rit != hi_rit; ++rit) {
221  ref_fe_vec->push_back(RefElement_VERTEX(*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 MBEDGE: {
227  boost::shared_ptr<std::vector<RefElement_EDGE>> ref_fe_vec =
228  boost::make_shared<std::vector<RefElement_EDGE>>();
229  ref_fe_vec->reserve(pit->second - pit->first + 1);
230  for (; rit != hi_rit; ++rit) {
231  ref_fe_vec->push_back(RefElement_EDGE(*rit));
232  shared_ref_fe_vec.push_back(
233  boost::shared_ptr<RefElement>(ref_fe_vec, &ref_fe_vec->back()));
234  }
235  } break;
236  case MBTRI:
237  case MBQUAD: {
238  boost::shared_ptr<std::vector<RefElementFace>> ref_fe_vec =
239  boost::make_shared<std::vector<RefElementFace>>();
240  ref_fe_vec->reserve(pit->second - pit->first + 1);
241  for (; rit != hi_rit; ++rit) {
242  ref_fe_vec->push_back(RefElementFace(*rit));
243  shared_ref_fe_vec.push_back(
244  boost::shared_ptr<RefElement>(ref_fe_vec, &ref_fe_vec->back()));
245  }
246  } break;
247  case MBTET: {
248  boost::shared_ptr<std::vector<RefElement_TET>> ref_fe_vec =
249  boost::make_shared<std::vector<RefElement_TET>>();
250  ref_fe_vec->reserve(pit->second - pit->first + 1);
251  for (; rit != hi_rit; ++rit) {
252  ref_fe_vec->push_back(RefElement_TET(*rit));
253  shared_ref_fe_vec.push_back(
254  boost::shared_ptr<RefElement>(ref_fe_vec, &ref_fe_vec->back()));
255  }
256  } break;
257  case MBPRISM: {
258  boost::shared_ptr<std::vector<RefElement_PRISM>> ref_fe_vec =
259  boost::make_shared<std::vector<RefElement_PRISM>>();
260  ref_fe_vec->reserve(pit->second - pit->first + 1);
261  for (; rit != hi_rit; ++rit) {
262  ref_fe_vec->push_back(RefElement_PRISM(*rit));
263  shared_ref_fe_vec.push_back(
264  boost::shared_ptr<RefElement>(ref_fe_vec, &ref_fe_vec->back()));
265  }
266  } break;
267  case MBENTITYSET: {
268  boost::shared_ptr<std::vector<RefElement_MESHSET>> ref_fe_vec =
269  boost::make_shared<std::vector<RefElement_MESHSET>>();
270  ref_fe_vec->reserve(pit->second - pit->first + 1);
271  for (; rit != hi_rit; ++rit) {
272  ref_fe_vec->push_back(RefElement_MESHSET(*rit));
273  shared_ref_fe_vec.push_back(
274  boost::shared_ptr<RefElement>(ref_fe_vec, &ref_fe_vec->back()));
275  }
276  } break;
277  default:
278  SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED, "not implemented");
279  }
280  }
281  // add shared pointers to database
282  const_cast<RefElement_multiIndex *>(refElementPtr)
283  ->insert(shared_ref_fe_vec.begin(), shared_ref_fe_vec.end());
285  }
286 };
287 
289  const BitRefLevel bit,
290  const bool only_tets,
291  int verb) const {
292  MoFEM::Interface &m_field = cOre;
293  auto ref_ents_ptr = m_field.get_ref_ents();
294  auto ref_fe_ptr = m_field.get_ref_finite_elements();
296 
298  MOFEM_LOG_C("BitRefSelf", Sev::noisy, "nb. entities to add %d", ents.size());
299 
300  CHKERR setElementsBitRefLevel(ents, bit, verb);
301 
302  if (!ents.empty()) {
303  for (int d = 3; d >= 1; --d) {
304  Range dim_ents;
305  if (only_tets && d == 3) {
306  dim_ents = ents.subset_by_type(MBTET);
307  } else {
308  dim_ents = ents.subset_by_dimension(d);
309  }
310  if (!dim_ents.empty()) {
311  for (int dd = 0; dd < d; ++dd) {
312  Range adj_ents;
313  CHKERR m_field.get_moab().get_adjacencies(
314  dim_ents, dd, true, adj_ents, moab::Interface::UNION);
315  for (Range::pair_iterator pit = adj_ents.pair_begin();
316  pit != adj_ents.pair_end(); ++pit) {
317  Range seed_ents_range;
318  // get first and last element of range
319  EntityHandle f = pit->first;
320  EntityHandle s = pit->second;
321  CHKERR SetBitRefLevelTool(m_field, bit, ref_ents_ptr, ref_fe_ptr)
322  .findEntsToAdd(f, s, seed_ents_range);
323  if (!seed_ents_range.empty())
324  CHKERR SetBitRefLevelTool(m_field, bit, ref_ents_ptr, ref_fe_ptr)
325  .addEntsToDatabase(seed_ents_range);
326  }
327  }
328  }
329  }
330  }
331 
333 }
334 
336  const BitRefLevel bit,
337  int verb) const {
338  MoFEM::Interface &m_field = cOre;
339  auto ref_ents_ptr = m_field.get_ref_ents();
340  auto ref_fe_ptr = m_field.get_ref_finite_elements();
342 
343  for (Range::const_pair_iterator pit = ents.pair_begin();
344  pit != ents.pair_end(); pit++) {
345  // get first and last element of range
346  EntityHandle f = pit->first;
347  EntityHandle s = pit->second;
348  Range seed_ents_range; // entities seeded not in database
349  // find ents to add
350  CHKERR SetBitRefLevelTool(m_field, bit, ref_ents_ptr, ref_fe_ptr)
351  .findEntsToAdd(f, s, seed_ents_range);
352  // add elements
353  if (!seed_ents_range.empty())
354  CHKERR SetBitRefLevelTool(m_field, bit, ref_ents_ptr, ref_fe_ptr)
355  .addEntsToDatabase(seed_ents_range);
356 
357  Range seed_fe_range;
358  CHKERR SetBitRefLevelTool(m_field, bit, ref_ents_ptr, ref_fe_ptr)
359  .findElementsToAdd(f, s, seed_fe_range);
360  if (!seed_fe_range.empty()) {
361  CHKERR SetBitRefLevelTool(m_field, bit, ref_ents_ptr, ref_fe_ptr)
362  .addElementsToDatabase(seed_fe_range);
363  }
364  }
365 
367 }
368 
370  const BitRefLevel bit,
371  int verb) const {
372  MoFEM::Interface &m_field = cOre;
373  auto ref_ents_ptr = m_field.get_ref_ents();
374  auto ref_fe_ptr = m_field.get_ref_finite_elements();
376 
377  for (Range::const_pair_iterator pit = ents.pair_begin();
378  pit != ents.pair_end(); pit++) {
379  // get first and last element of range
380  EntityHandle f = pit->first;
381  EntityHandle s = pit->second;
382  Range seed_ents_range; // entities seeded not in database
383  // find ents to add
384  CHKERR SetBitRefLevelTool(m_field, bit, ref_ents_ptr, ref_fe_ptr)
385  .findEntsToAdd(f, s, seed_ents_range);
386  // add elements
387  if (!seed_ents_range.empty())
388  CHKERR SetBitRefLevelTool(m_field, bit, ref_ents_ptr, ref_fe_ptr)
389  .addEntsToDatabase(seed_ents_range);
390  }
392 }
393 
395  const std::string field_name, const BitRefLevel bit, int verb) const {
396  MoFEM::Interface &m_field = cOre;
398  EntityHandle field_meshset = m_field.get_field_meshset(field_name);
399  Range field_ents;
400  CHKERR m_field.get_moab().get_entities_by_handle(field_meshset, field_ents,
401  true);
402  CHKERR setEntitiesBitRefLevel(field_ents, bit, verb);
404 }
405 
407  const EntityType type, const BitRefLevel bit, const BitRefLevel mask,
408  int verb) const {
410  Range ents;
411  CHKERR getEntitiesByTypeAndRefLevel(bit, mask, type, ents);
414 }
415 
417  const int dim, const BitRefLevel bit, const BitRefLevel mask,
418  int verb) const {
420  Range ents;
421  CHKERR getEntitiesByDimAndRefLevel(bit, mask, dim, ents);
424 }
425 
427  const BitRefLevel bit,
428  int verb) const {
429  MoFEM::Interface &m_field = cOre;
430  auto ref_ents_ptr = m_field.get_ref_ents();
431  auto ref_fe_ptr = m_field.get_ref_finite_elements();
433  // Add ref entity
434  std::pair<RefEntity_multiIndex::iterator, bool> p_ent =
435  const_cast<RefEntity_multiIndex *>(ref_ents_ptr)
436  ->insert(boost::shared_ptr<RefEntity>(
437  new RefEntity(m_field.get_basic_entity_data_ptr(), meshset)));
438  *(const_cast<RefEntity *>(p_ent.first->get())->getBitRefLevelPtr()) |= bit;
439  // Add ref element
440  boost::shared_ptr<RefElement> fe_ptr =
441  boost::shared_ptr<RefElement>(new RefElement_MESHSET(*p_ent.first));
442  std::pair<RefElement_multiIndex::iterator, bool> p_fe =
443  const_cast<RefElement_multiIndex *>(ref_fe_ptr)->insert(fe_ptr);
444 
446  MOFEM_LOG("BitRefSelf", Sev::noisy)
447  << "Add meshset as ref_ent " << **p_fe.first;
448 
450 }
451 
453  const int dim,
454  const BitRefLevel bit,
455  int verb) const {
456  MoFEM::Interface &m_field = cOre;
458  Range ents;
459  CHKERR m_field.get_moab().get_entities_by_dimension(meshset, dim, ents,
460  false);
461  CHKERR setBitRefLevel(ents, bit, false, verb);
463 }
464 
466  const EntityType type,
467  const BitRefLevel bit,
468  int verb) const {
469  MoFEM::Interface &m_field = cOre;
471  Range ents;
472  CHKERR m_field.get_moab().get_entities_by_type(meshset, type, ents, false);
473  CHKERR setBitRefLevel(ents, bit, false, verb);
475 }
476 
478  const BitRefLevel bit,
479  int verb) const {
480  MoFEM::Interface &m_field = cOre;
482  std::vector<const BitRefLevel *> ents_bits_vec;
483  CHKERR RefEntity::getBitRefLevel(m_field.get_moab(), ents, ents_bits_vec);
484  for (auto it : ents_bits_vec)
485  const_cast<BitRefLevel &>(*it) |= bit;
487 }
488 
490  const int dim,
491  const BitRefLevel bit,
492  int verb) const {
493  MoFEM::Interface &m_field = cOre;
494  moab::Interface &moab = m_field.get_moab();
495  Range ents, adj;
497  CHKERR moab.get_entities_by_dimension(meshset, dim, ents, true);
498  for (int dd = dim - 1; dd >= 0; dd--) {
499  CHKERR moab.get_adjacencies(ents, dd, false, adj, moab::Interface::UNION);
500  }
501  ents.merge(adj);
502  if (verb == VERY_NOISY) {
504  MOFEM_LOG("BitRefSelf", Sev::noisy) << "Add add bit ref level by dim ";
505  }
506 
507  CHKERR addBitRefLevel(ents, bit, verb);
509 }
510 
511 MoFEMErrorCode BitRefManager::setNthBitRefLevel(const Range &ents, const int n,
512  const bool b, int verb) const {
513  MoFEM::Interface &m_field = cOre;
515  std::vector<const BitRefLevel *> ents_bits_vec;
516  CHKERR RefEntity::getBitRefLevel(m_field.get_moab(), ents, ents_bits_vec);
517  for (std::vector<const BitRefLevel *>::iterator it = ents_bits_vec.begin();
518  it != ents_bits_vec.end(); ++it) {
519  const_cast<BitRefLevel &>(**it)[n] = b;
520  }
521  if (verb == VERY_NOISY) {
522  cerr << ents << endl;
523  }
525 }
526 
528  int verb) const {
529  MoFEM::Interface &m_field = cOre;
530  auto ref_ents_ptr = m_field.get_ref_ents();
532  RefEntity_multiIndex::iterator dit, hi_dit;
533  dit = ref_ents_ptr->begin();
534  hi_dit = ref_ents_ptr->end();
535  for (; dit != hi_dit; dit++) {
536  (*const_cast<RefEntity *>(dit->get())->getBitRefLevelPtr())[n] = b;
537  if (verb >= VERY_VERBOSE) {
538  cerr << **dit << endl;
539  }
540  }
542 }
543 
545  const BitRefLevel mask,
546  int verb) const {
548  SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED, "not implemented");
550 }
551 
553  const BitRefLevel mask,
554  int verb) const {
555  MoFEM::Interface &m_field = cOre;
556  auto ref_ents_ptr = m_field.get_ref_ents();
558  RefEntity_change_right_shift right_shift(1, mask);
559  for (int ii = 0; ii < shift; ii++) {
560  // delete bits on the right which are shifted to zero
561  BitRefLevel delete_bits = BitRefLevel().set(0) & mask;
562  if (delete_bits.any()) {
563  CHKERR m_field.delete_ents_by_bit_ref(delete_bits, delete_bits, true,
564  verb);
565  }
566  for (RefEntity_multiIndex::iterator ent_it = ref_ents_ptr->begin();
567  ent_it != ref_ents_ptr->end(); ent_it++) {
568  if (verb > NOISY) {
570  MOFEM_LOG("BitRefSelf", Sev::noisy)
571  << (*ent_it)->getBitRefLevel() << " : ";
572  }
573  right_shift(const_cast<boost::shared_ptr<RefEntity> &>(*ent_it));
574  if (verb >= VERY_NOISY) {
576  MOFEM_LOG("BitRefSelf", Sev::noisy) << (*ent_it)->getBitRefLevel();
577  }
578  }
579  }
581 }
582 
584  const BitRefLevel bit, const BitRefLevel mask, const EntityType type,
585  const char *file_name, const char *file_type, const char *options,
586  const bool check_for_empty) const {
587  MoFEM::Interface &m_field = cOre;
588  moab::Interface &moab(m_field.get_moab());
590  Range ents;
591  CHKERR getEntitiesByTypeAndRefLevel(bit, mask, type, ents);
592  if (check_for_empty && ents.empty())
594  EntityHandle meshset;
595  CHKERR moab.create_meshset(MESHSET_SET, meshset);
596  CHKERR moab.add_entities(meshset, ents);
597  CHKERR moab.write_file(file_name, file_type, options, &meshset, 1);
598  CHKERR moab.delete_entities(&meshset, 1);
600 }
601 
603  const char *file_name, const char *file_type, const char *options,
604  const bool check_for_empty) const {
605  MoFEM::Interface &m_field = cOre;
606  moab::Interface &moab(m_field.get_moab());
608  EntityHandle meshset;
609  Range ents;
611  if (check_for_empty && ents.empty())
613  CHKERR moab.create_meshset(MESHSET_SET, meshset);
614  CHKERR moab.add_entities(meshset, ents);
615  CHKERR moab.write_file(file_name, file_type, options, &meshset, 1);
616  CHKERR moab.delete_entities(&meshset, 1);
618 }
619 
621  const BitRefLevel mask, const EntityType type, const char *file_name,
622  const char *file_type, const char *options) {
624  for (int ll = 0; ll != BITREFLEVEL_SIZE; ++ll) {
625  std::string name = boost::lexical_cast<std::string>(ll) + "_" + file_name;
626  CHKERR writeBitLevelByType(BitRefLevel().set(ll), mask, type, name.c_str(),
627  file_type, options, true);
628  }
630 }
631 
633  const BitRefLevel bit, const BitRefLevel mask, const EntityType type,
634  const EntityHandle meshset, int verb) const {
635  MoFEM::Interface &m_field = cOre;
636  moab::Interface &moab(m_field.get_moab());
638  Range ents;
639  CHKERR getEntitiesByTypeAndRefLevel(bit, mask, type, ents, verb);
640  CHKERR moab.add_entities(meshset, ents);
642 }
643 
645  const BitRefLevel mask,
646  Range &ents,
647  int verb) const {
648  MoFEM::Interface &m_field = cOre;
649  moab::Interface &moab(m_field.get_moab());
651 
652  std::vector<EntityHandle> ents_vec;
653  ents_vec.reserve(ents.size());
654 
655  std::vector<BitRefLevel *> tags_bits_ptr_vec(ents.size());
656 
657  Range swap_ents;
658  auto hint = swap_ents.begin();
659 
660  for (Range::pair_iterator p_eit = ents.pair_begin(); p_eit != ents.pair_end();
661  ++p_eit) {
662 
663  EntityHandle f = p_eit->first;
664  const EntityHandle s = p_eit->second;
665 
666  // get bits on entities
667  rval = moab.tag_get_by_ptr(cOre.get_th_RefBitLevel(), Range(f, s),
668  (const void **)(&*tags_bits_ptr_vec.begin()));
669 
670  if (rval == MB_SUCCESS) {
671 
672  auto bit_it = tags_bits_ptr_vec.begin();
673 
674  auto check = [&bit, &mask](const auto &entity_bit) -> bool {
675  return
676 
677  (entity_bit & bit).any() &&
678 
679  ((entity_bit & mask) == entity_bit);
680  };
681 
682  while (f != s + 1) {
683 
684  while (f != s + 1 && !check(**bit_it)) {
685  ++bit_it;
686  ++f;
687  }
688 
689  if (f != s + 1) {
690 
691  const EntityHandle start = f;
692 
693  while (f != (s + 1) && check(**bit_it)) {
694  ++bit_it;
695  ++f;
696  };
697 
698  hint = swap_ents.insert(hint, start, f - 1);
699  }
700  }
701  }
702  }
703 
704  ents.swap(swap_ents);
705 
707 }
708 
710  const BitRefLevel bit, const BitRefLevel mask, const EntityType type,
711  Range &ents, int verb) const {
712  MoFEM::Interface &m_field = cOre;
713  moab::Interface &moab(m_field.get_moab());
715  CHKERR moab.get_entities_by_type(0, type, ents, false);
716  CHKERR filterEntitiesByRefLevel(bit, mask, ents, verb);
718 }
719 
721  const BitRefLevel bit, const BitRefLevel mask, const int dim,
722  const EntityHandle meshset, int verb) const {
723  MoFEM::Interface &m_field = cOre;
724  moab::Interface &moab(m_field.get_moab());
726  Range ents;
727  CHKERR getEntitiesByDimAndRefLevel(bit, mask, dim, ents, verb);
728  CHKERR moab.add_entities(meshset, ents);
730 }
731 
733  const BitRefLevel bit, const BitRefLevel mask, const int dim, Range &ents,
734  int verb) const {
735  MoFEM::Interface &m_field = cOre;
736  moab::Interface &moab(m_field.get_moab());
738  CHKERR moab.get_entities_by_dimension(0, dim, ents, false);
739  CHKERR filterEntitiesByRefLevel(bit, mask, ents, verb);
741 }
742 
744  const BitRefLevel mask,
745  const EntityHandle meshset,
746  const int verb) const {
747  MoFEM::Interface &m_field = cOre;
748  moab::Interface &moab(m_field.get_moab());
750  Range ents;
751  CHKERR getEntitiesByRefLevel(bit, mask, ents, verb);
752  CHKERR moab.add_entities(meshset, ents);
754 }
755 
757  const BitRefLevel mask,
758  Range &ents,
759  const int verb) const {
760  MoFEM::Interface &m_field = cOre;
761  moab::Interface &moab(m_field.get_moab());
763  Range meshset_ents;
764  CHKERR moab.get_entities_by_type(0, MBENTITYSET, meshset_ents, false);
765  CHKERR moab.get_entities_by_handle(0, ents, false);
766  ents.merge(meshset_ents);
767  CHKERR filterEntitiesByRefLevel(bit, mask, ents, verb);
769 }
770 
772  const BitRefLevel mask,
773  const EntityType type,
774  Range &ents,
775  const int verb) const {
776  MoFEM::Interface &m_field = cOre;
777  auto ref_ents_ptr = m_field.get_ref_ents();
779  auto &ref_ents = ref_ents_ptr->get<Ent_Ent_mi_tag>();
780  auto it = ref_ents.lower_bound(get_id_for_min_type(type));
781  auto hi_it = ref_ents.upper_bound(get_id_for_max_type(type));
782  std::vector<EntityHandle> ents_vec;
783  ents_vec.reserve(std::distance(it, hi_it));
784  for (; it != hi_it; it++) {
785  const BitRefLevel &ent_bit = it->get()->getBitRefLevel();
786  if ((ent_bit & mask) == ent_bit && (ent_bit & bit).any())
787  ents_vec.emplace_back(it->get()->getEnt());
788  }
789  ents.insert_list(ents_vec.begin(), ents_vec.end());
790  if (verb > NOISY)
791  cerr << "getEntitiesByParentType: " << ents << endl;
793 }
794 
796  MoFEM::Interface &m_field = cOre;
797  moab::Interface &moab = m_field.get_moab();
799  CHKERR moab.get_entities_by_handle(0, ents, false);
800  ents = subtract(ents, ents.subset_by_type(MBENTITYSET));
803 }
804 
806  MoFEM::Interface &m_field = cOre;
807  auto ref_ents_ptr = m_field.get_ref_ents();
809  auto eit = ents.begin();
810  for (; eit != ents.end();) {
811  auto rit = ref_ents_ptr->get<Ent_mi_tag>().find(*eit);
812  if (rit != ref_ents_ptr->get<Ent_mi_tag>().end()) {
813  eit = ents.erase(eit);
814  } else {
815  eit++;
816  }
817  }
819 }
820 
823  const int to_dimension,
824  Range &adj_entities) const {
825  MoFEM::Interface &m_field = cOre;
826  moab::Interface &moab(m_field.get_moab());
828  BitRefLevel bit_from_entity;
829  CHKERR moab.tag_get_data(cOre.get_th_RefBitLevel(), &from_entity, 1,
830  &bit_from_entity);
831  CHKERR moab.get_adjacencies(&from_entity, 1, to_dimension, false,
832  adj_entities);
833  std::vector<BitRefLevel> bit_levels(adj_entities.size());
834  CHKERR moab.tag_get_data(cOre.get_th_RefBitLevel(), adj_entities,
835  &*bit_levels.begin());
836  auto b_it = bit_levels.begin();
837  auto eit = adj_entities.begin();
838  for (; eit != adj_entities.end(); b_it++) {
839  if (bit_from_entity != *b_it) {
840  eit = adj_entities.erase(eit);
841  } else {
842  eit++;
843  }
844  }
846 }
847 
849  const int to_dimension,
850  Range &adj_entities) const {
851  MoFEM::Interface &m_field = cOre;
852  moab::Interface &moab(m_field.get_moab());
854  BitRefLevel bit_from_entity;
855  CHKERR moab.tag_get_data(cOre.get_th_RefBitLevel(), &from_entity, 1,
856  &bit_from_entity);
857  CHKERR moab.get_adjacencies(&from_entity, 1, to_dimension, false,
858  adj_entities);
859  std::vector<BitRefLevel> bit_levels(adj_entities.size());
860  CHKERR moab.tag_get_data(cOre.get_th_RefBitLevel(), adj_entities,
861  &*bit_levels.begin());
862  std::vector<BitRefLevel>::iterator b_it = bit_levels.begin();
863  Range::iterator eit = adj_entities.begin();
864  for (; eit != adj_entities.end(); b_it++) {
865  if (!(bit_from_entity & (*b_it)).any()) {
866  eit = adj_entities.erase(eit);
867  } else {
868  eit++;
869  }
870  }
872 }
873 
875  const Problem *problem_ptr, const EntityHandle *from_entities,
876  const int num_entities, const int to_dimension, Range &adj_entities,
877  const int operation_type, const int verb) const {
879  BitRefLevel bit = problem_ptr->getBitRefLevel();
880  CHKERR getAdjacencies(bit, from_entities, num_entities, to_dimension,
881  adj_entities, operation_type);
883 }
884 
886  const BitRefLevel bit, const EntityHandle *from_entities,
887  const int num_entities, const int to_dimension, Range &adj_entities,
888  const int operation_type, const int verb) const {
889  MoFEM::Interface &m_field = cOre;
890  moab::Interface &moab(m_field.get_moab());
892 
893  if (verb > VERBOSE) {
895  MOFEM_LOG("BitRef", Sev::noisy) << "from: " << bit;
896  }
897 
898  CHKERR moab.get_adjacencies(from_entities, num_entities, to_dimension, false,
899  adj_entities, operation_type);
900  std::vector<BitRefLevel> bit_levels(adj_entities.size());
901  CHKERR moab.tag_get_data(cOre.get_th_RefBitLevel(), adj_entities,
902  &*bit_levels.begin());
903  std::vector<BitRefLevel>::iterator b_it = bit_levels.begin();
904  for (Range::iterator eit = adj_entities.begin(); eit != adj_entities.end();
905  b_it++) {
906 
907  if (verb > VERBOSE) {
908  RefEntity adj_entity(m_field.get_basic_entity_data_ptr(), *eit);
910  MOFEM_LOG("BitRef", Sev::noisy)
911  << "to: " << adj_entity.getBitRefLevel() << " : " << adj_entity;
912  }
913 
914  if (!((*b_it) & bit).any()) {
915  eit = adj_entities.erase(eit);
916  } else {
917  eit++;
918  }
919  }
920  if (b_it != bit_levels.end()) {
921  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY, "Data inconsistency");
922  }
924 }
925 
927  const EntityHandle parent, const BitRefLevel &parent_bit,
928  const BitRefLevel &parent_mask, const BitRefLevel &child_bit,
929  const BitRefLevel &child_mask, const EntityHandle child,
930  EntityType child_type, const bool recursive, int verb) {
931  MoFEM::Interface &m_field = cOre;
932  moab::Interface &moab = m_field.get_moab();
934  Range parent_ents;
935  CHKERR moab.get_entities_by_handle(parent, parent_ents, recursive);
936  CHKERR filterEntitiesByRefLevel(parent_bit, parent_mask, parent_ents, verb);
937  if (verb >= VERY_VERBOSE) {
939  MOFEM_LOG("BitRefSelf", Sev::noisy) << "Parnets: " << parent;
940  }
941  Range children_ents;
942  CHKERR updateRange(parent_ents, children_ents);
943  CHKERR filterEntitiesByRefLevel(child_bit, BitRefLevel().set(), children_ents,
944  verb);
945  CHKERR moab.add_entities(child, children_ents);
947 }
948 
950  const EntityHandle parent, const BitRefLevel &child_bit,
951  const EntityHandle child, EntityType child_type, const bool recursive,
952  int verb) {
955  parent, BitRefLevel().set(), BitRefLevel().set(), child_bit, child_bit,
956  child, child_type, recursive, verb);
958 }
959 
961  const BitRefLevel &child_bit, int verb) {
962  MoFEM::Interface &m_field = cOre;
963  moab::Interface &moab = m_field.get_moab();
964  auto fields_ptr = m_field.get_fields();
965  auto ref_ents_ptr = m_field.get_ref_ents();
967 
968  for (auto &fit : (*fields_ptr)) {
969 
970  const EntityHandle meshset = fit->getMeshset();
971  Range parent_ents;
972  CHKERR moab.get_entities_by_handle(meshset, parent_ents, true);
973 
974  if (verb >= VERY_VERBOSE) {
976  MOFEM_LOG("BitRefSelf", Sev::noisy) << "Parnets:" << std::endl
977  << parent_ents << std::endl;
978  }
979 
980  Range children_ents;
981  CHKERR updateRange(parent_ents, children_ents);
982  CHKERR filterEntitiesByRefLevel(child_bit, BitRefLevel().set(),
983  children_ents, verb);
984 
985  CHKERR moab.add_entities(meshset, children_ents);
986 
987  if (verb >= VERY_VERBOSE) {
989  MOFEM_LOG("BitRefSelf", Sev::noisy) << "Children: " << std::endl
990  << children_ents << std::endl;
991  }
992  }
994 }
995 
997  const std::string name, const BitRefLevel &child_bit, int verb) {
998  MoFEM::Interface &m_field = cOre;
999  moab::Interface &moab = m_field.get_moab();
1001 
1002  EntityHandle field_meshset = m_field.get_field_structure(name)->getMeshset();
1003 
1004  Range parent_ents;
1005  CHKERR moab.get_entities_by_handle(field_meshset, parent_ents, true);
1006 
1007  if (verb >= VERBOSE) {
1009  MOFEM_LOG("BitRefSelf", Sev::noisy) << "Parnets:" << endl
1010  << parent_ents << std::endl;
1011  }
1012 
1013  Range children_ents;
1014  CHKERR updateRange(parent_ents, children_ents);
1015  CHKERR filterEntitiesByRefLevel(child_bit, BitRefLevel().set(), children_ents,
1016  verb);
1017 
1018  CHKERR moab.add_entities(field_meshset, children_ents);
1019 
1020  if (verb >= VERBOSE) {
1022  MOFEM_LOG("BitRefSelf", Sev::noisy) << "Children: " << endl
1023  << children_ents << std::endl;
1024  }
1025 
1027 }
1028 
1030  const std::string name, const BitRefLevel &child_bit,
1031  const EntityType fe_ent_type, int verb) {
1032  MoFEM::Interface &m_field = cOre;
1034  EntityHandle meshset = m_field.get_finite_element_meshset(name);
1035  CHKERR updateMeshsetByEntitiesChildren(meshset, child_bit, meshset,
1036  fe_ent_type, false, verb);
1038 }
1039 
1041  Range &child_ents, MoFEMTypes bh) {
1042  MoFEM::Interface &m_field = cOre;
1043  auto ref_ents_ptr = m_field.get_ref_ents();
1045  auto &ref_ents =
1046  const_cast<RefEntity_multiIndex *>(ref_ents_ptr)->get<Ent_Ent_mi_tag>();
1047  std::vector<EntityHandle> child_ents_vec;
1048  child_ents_vec.reserve(ref_ents.size());
1049  for (Range::const_pair_iterator pit = parent_ents.const_pair_begin();
1050  pit != parent_ents.const_pair_end(); pit++) {
1051  const auto f = pit->first;
1052  auto it = ref_ents.lower_bound(f);
1053  if (it != ref_ents.end()) {
1054  const auto s = pit->second;
1055  auto hi_it = ref_ents.upper_bound(s);
1056  if (bh == MF_EXIST) {
1057  if (std::distance(it, hi_it) != (s - f) + 1) {
1058  SETERRQ2(
1059  PETSC_COMM_SELF, MOFEM_NOT_FOUND,
1060  "Number of entities and enties parents is diffrent %d != %d ",
1061  std::distance(it, hi_it), (s - f) + 1);
1062  }
1063  }
1064  for (; it != hi_it; it++) {
1065  if (it->get()->getEntType() == MBENTITYSET) {
1066  SETERRQ(PETSC_COMM_SELF, MOFEM_IMPOSIBLE_CASE,
1067  "This should not happen; Entity should not have part of the "
1068  "meshset. It has no children.");
1069  }
1070  child_ents_vec.emplace_back((*it)->getEnt());
1071  }
1072  } else if (bh == MF_EXIST) {
1073  SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_FOUND, "Entities not found");
1074  }
1075  }
1076  child_ents.insert_list(child_ents_vec.begin(), child_ents_vec.end());
1078 }
1079 } // namespace MoFEM
MoFEMErrorCode setFieldEntitiesBitRefLevel(const std::string field_name, const BitRefLevel bit=BitRefLevel(), int verb=QUIET) const
Set the bit ref level to entities in the field meshset.
MoFEMErrorCode setEntitiesBitRefLevel(const Range &ents, const BitRefLevel bit=BitRefLevel(), int verb=QUIET) const
add entities to database and set bit ref level
keeps data about abstract VERTEX finite element
static boost::shared_ptr< std::ostream > getStrmWorld()
Get the strm world object.
Definition: LogManager.cpp:322
EntityHandle get_id_for_max_type()
EntityHandle get_id_for_min_type()
Deprecated interface functions.
MoFEM interface unique ID.
MoFEMErrorCode setBitRefLevel(const Range &ents, const BitRefLevel bit, const bool only_tets=true, int verb=0) const
add entities to database and set bit ref levelThis function set bit ref level, add entries to core da...
MoFEMErrorCode findEntsToAdd(EntityHandle f, EntityHandle s, Range &seed_ents_range) const
find entities and change entity bit if in database
MoFEMErrorCode getEntitiesByDimAndRefLevel(const BitRefLevel bit, const BitRefLevel mask, const int dim, const EntityHandle meshset, int verb=0) const
add all ents from ref level given by bit to meshset
virtual moab::Interface & get_moab()=0
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
MoFEMErrorCode addToDatabaseBitRefLevelByDim(const int dim, const BitRefLevel bit, const BitRefLevel mask=BitRefLevel().set(), int verb=QUIET) const
Add entities which exist in MoAB database, and have set appropiate BitRef level tag,...
virtual boost::shared_ptr< BasicEntityData > & get_basic_entity_data_ptr()=0
Get pointer to basic entity data.
MoFEMErrorCode getEntitiesByTypeAndRefLevel(const BitRefLevel bit, const BitRefLevel mask, const EntityType type, const EntityHandle meshset, int verb=0) const
add all ents from ref level given by bit to meshset
Tag get_th_RefBitLevel() const
Definition: Core.hpp:193
MoFEMErrorCode setNthBitRefLevel(const Range &ents, const int n, const bool b, int verb=0) const
Set nth bit ref level.
const RefElement_multiIndex * refElementPtr
access to fe database
MoFEMErrorCode addBitRefLevel(const Range &ents, const BitRefLevel bit, int verb=QUIET) const
add bit ref level to ref entity
MoFEMErrorCode setBitRefLevelByType(const EntityHandle meshset, const EntityType type, const BitRefLevel bit, int verb=QUIET) const
Set the Bit Ref Level By Type object.
RefEntityTmp< 0 > RefEntity
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:509
Struct keeps handle to refined handle.
#define MOFEM_LOG_TAG(channel, tag)
Tag channelTag channel tag is set until MOFEM_LOG_CHANNEL is called, then new tag can be set.
Definition: LogManager.hpp:334
virtual const Field_multiIndex * get_fields() const =0
Get the fields object.
#define MOFEM_LOG(channel, severity)
Log.
Definition: LogManager.hpp:303
keeps data about abstract PRISM finite element
base class for all interface classes
MoFEMErrorCode addEntsToDatabase(const Range &seed_ents_range) const
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:485
#define MOFEM_LOG_C(channel, severity, format,...)
Definition: LogManager.hpp:306
virtual const RefEntity_multiIndex * get_ref_ents() const =0
Get the ref ents object.
static const MOFEMuuid IDD_MOFEMBitRefManager
static boost::shared_ptr< std::ostream > getStrmSelf()
Get the strm self object.
Definition: LogManager.cpp:318
virtual MoFEMErrorCode delete_ents_by_bit_ref(const BitRefLevel bit, const BitRefLevel mask, const bool remove_parent=false, int verb=DEFAULT_VERBOSITY)=0
delete entities form mofem and moab database
virtual MoFEMErrorCode getAdjacenciesAny(const EntityHandle from_entity, const int to_dimension, Range &adj_entities) const
Get the adjacencies associated with a entity to entities of a specified dimension....
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:516
keeps basic data about problemThis is low level structure with information about problem,...
virtual const RefElement_multiIndex * get_ref_finite_elements() const =0
Get the ref finite elements object.
MoFEMErrorCode addToDatabaseBitRefLevelByType(const EntityType type, const BitRefLevel bit, const BitRefLevel mask=BitRefLevel().set(), int verb=QUIET) const
Add entities which exist in MoAB database, and have set appropiate BitRef level tag,...
implementation of Data Operators for Forces and Sources
Definition: Common.hpp:21
static Index< 'n', 3 > n
MoFEMErrorCode addBitRefLevelByDim(const EntityHandle meshset, const int dim, const BitRefLevel bit, int verb=QUIET) const
add bit ref level by dimension
moab::Range::iterator insertOrdered(Range &r, Extractor, Iterator begin_iter, Iterator end_iter)
Insert ordered mofem multi-index into range.
Definition: Templates.hpp:746
static boost::shared_ptr< SinkType > createSink(boost::shared_ptr< std::ostream > stream_ptr, std::string comm_filter)
Create a sink object.
Definition: LogManager.cpp:278
Extract entity handle form multi-index container.
Definition: Templates.hpp:722
static MoFEMErrorCodeGeneric< moab::ErrorCode > rval
Definition: Exceptions.hpp:85
virtual const int getValue() const =0
Get the core.
const int dim
virtual MoFEMErrorCode getAdjacenciesEquality(const EntityHandle from_entity, const int to_dimension, Range &adj_entities) const
Get the adjacencies associated with a entity to entities of a specified dimension....
MoFEMErrorCode query_interface(const MOFEMuuid &uuid, UnknownInterface **iface) const
#define BITREFLEVEL_SIZE
max number of refinements
Definition: definitions.h:286
static LoggerType & setLog(const std::string channel)
Set ans resset chanel logger.
Definition: LogManager.cpp:363
static boost::shared_ptr< std::ostream > getStrmSync()
Get the strm sync object.
Definition: LogManager.cpp:326
tool class with methods used more than twp times
const RefEntity_multiIndex * refEntsPtr
access to ents database
const Tensor1_Expr< const dTensor0< T, Dim, i >, typename promote< T, double >::V, Dim, i > d(const Tensor0< T * > &a, const Index< i, Dim > index, const Tensor1< int, Dim > &d_ijk, const Tensor1< double, Dim > &d_xyz)
Definition: dTensor0.hpp:27
MoFEMErrorCode getEntitiesByParentType(const BitRefLevel bit, const BitRefLevel mask, const EntityType type, Range &ents, const int verb=QUIET) const
get entities by bit ref level and type of parent
const Tensor2_symmetric_Expr< const ddTensor0< T, Dim, i, j >, typename promote< T, double >::V, Dim, i, j > dd(const Tensor0< T * > &a, const Index< i, Dim > index1, const Index< j, Dim > index2, const Tensor1< int, Dim > &d_ijk, const Tensor1< double, Dim > &d_xyz)
Definition: ddTensor0.hpp:33
keeps data about abstract TRI finite element
MoFEMErrorCode writeEntitiesNotInDatabase(const char *file_name, const char *file_type, const char *options, const bool check_for_empty=true) const
Write ents not in database.
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
Definition: Exceptions.hpp:67
MoFEMErrorCode updateMeshsetByEntitiesChildren(const EntityHandle parent, const BitRefLevel &parent_bit, const BitRefLevel &parent_mask, const BitRefLevel &child_bit, const BitRefLevel &child_mask, const EntityHandle child, EntityType child_type, const bool recursive=false, int verb=0)
Get child entities form meshset containing parent entitiesSearch for refined entities of given type w...
const BitRefLevel & getBitRefLevel() const
Get entity ref bit refinement signature.
MoFEMErrorCode setBitLevelToMeshset(const EntityHandle meshset, const BitRefLevel bit, int verb=0) const
keeps data about abstract TET finite element
MoFEMErrorCode updateFieldMeshsetByEntitiesChildren(const BitRefLevel &child_bit, int verb=0)
update fields meshesets by child entities
MoFEM::Interface & mField
static LoggerType & getLog(const std::string channel)
Get logger by channel.
Definition: LogManager.cpp:369
#define CHKERR
Inline error check.
Definition: definitions.h:604
virtual EntityHandle get_finite_element_meshset(const std::string &name) const =0
const double r
rate factor
boost::shared_ptr< BasicEntityData > & baseEntData
base entity data
virtual EntityHandle get_field_meshset(const std::string name) const =0
get field meshset
MoFEMErrorCode filterEntitiesByRefLevel(const BitRefLevel bit, const BitRefLevel mask, Range &ents, int verb=QUIET) const
filter entities by bit ref level
BitRefLevel getBitRefLevel() const
MoFEMErrorCode writeBitLevelByType(const BitRefLevel bit, const BitRefLevel mask, const EntityType type, const char *file_name, const char *file_type, const char *options, const bool check_for_empty=true) const
Write bit ref level to file.
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
Definition: Types.hpp:51
MoFEMErrorCode updateRange(const Range &parent, Range &child, MoFEMTypes bh=MF_ZERO)
Update range by prents.
MoFEMErrorCode getEntitiesByRefLevel(const BitRefLevel bit, const BitRefLevel mask, const EntityHandle meshset, const int verb=QUIET) const
add all ents from ref level given by bit to meshset
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
MoFEMErrorCode addEntsToDatabaseImpl(const Range &seed_ents_range) const
add entities to database
MoFEMErrorCode shiftLeftBitRef(const int shift, const BitRefLevel mask=BitRefLevel().set(), int verb=-1) const
left shift bit ref levelthis results of deletion of entities on far left side
MoFEMErrorCode addElementsToDatabase(Range &seed_fe_range) const
MoFEMErrorCode setElementsBitRefLevel(const Range &ents, const BitRefLevel bit=BitRefLevel(), int verb=QUIET) const
add entities to database and set bit ref level
keeps data about abstract EDGE finite element
DeprecatedCoreInterface Interface
Definition: Interface.hpp:1943
MoFEMErrorCode findElementsToAdd(EntityHandle f, EntityHandle s, Range &seed_fe_range) const
Core (interface) class.
Definition: Core.hpp:77
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:415
MoFEMErrorCode shiftRightBitRef(const int shift, const BitRefLevel mask=BitRefLevel().set(), int verb=-1) const
right shift bit ref level
virtual const Field * get_field_structure(const std::string &name)=0
get field structure
EntityHandle getMeshset() const
Get field meshset.
MoFEMErrorCode updateFiniteElementMeshsetByEntitiesChildren(const std::string name, const BitRefLevel &child_bit, const EntityType fe_ent_type, int verb=0)
update finite element meshset by child entities
virtual MoFEMErrorCode getAdjacencies(const Problem *problem_ptr, const EntityHandle *from_entities, const int num_entities, const int to_dimension, Range &adj_entities, const int operation_type=moab::Interface::INTERSECT, const int verb=0) const
Get the adjacencies associated with a entity to entities of a specified dimension....
SetBitRefLevelTool(MoFEM::Interface &m_field, const BitRefLevel &bit, const RefEntity_multiIndex *ref_ents_ptr, const RefElement_multiIndex *ref_element_ptr)
constrictor
MoFEMErrorCode writeEntitiesAllBitLevelsByType(const BitRefLevel mask, const EntityType type, const char *file_name, const char *file_type, const char *options)
Write all entities by bit levels and type.
#define MOFEM_LOG_FUNCTION()
Set scopeMacro for function scope markup. The scope name is constructed with help of compiler and con...
Definition: LogManager.hpp:320
keeps data about abstract MESHSET finite element
MoFEMErrorCode setBitRefLevelByDim(const EntityHandle meshset, const int dim, const BitRefLevel bit, int verb=QUIET) const
Set the Bit Ref Level By Dim object.
BitRefManager(const MoFEM::Core &core)
MoFEMErrorCode filterEntitiesNotInDatabase(Range &ents) const
Get entities not in database.
const BitRefLevel & bIt
bit to set
MoFEMErrorCode getAllEntitiesNotInDatabase(Range &ents) const
Get all entities not in database.
MoFEMTypes
Those types control how functions respond on arguments, f.e. error handling.
Definition: definitions.h:189