v0.14.0
Files
BitRefManager

Managing BitRefLevels. More...

Collaboration diagram for BitRefManager:

Files

file  BitRefManager.hpp
 Interface managing BitRefLevels.
 

Setting and shifting bits

MoFEMErrorCode MoFEM::BitRefManager::setBitRefLevel (const Range &ents, const BitRefLevel bit, const bool only_tets=true, int verb=0, Range *adj_ents_ptr=nullptr) const
 add entities to database and set bit ref level More...
 
MoFEMErrorCode MoFEM::BitRefManager::setElementsBitRefLevel (const Range &ents, const BitRefLevel bit=BitRefLevel(), int verb=QUIET) const
 add entities to database and set bit ref level More...
 
MoFEMErrorCode MoFEM::BitRefManager::setEntitiesBitRefLevel (const Range &ents, const BitRefLevel bit=BitRefLevel(), int verb=QUIET) const
 add entities to database and set bit ref level More...
 
MoFEMErrorCode MoFEM::BitRefManager::setBitLevelToMeshset (const EntityHandle meshset, const BitRefLevel bit, int verb=0) const
 
MoFEMErrorCode MoFEM::BitRefManager::addBitRefLevel (const Range &ents, const BitRefLevel &bit, int verb=QUIET) const
 add bit ref level to ref entity More...
 
MoFEMErrorCode MoFEM::BitRefManager::setNthBitRefLevel (const int n, const bool b, int verb=QUIET) const
 Set nth bit ref level to all entities in database. More...
 
MoFEMErrorCode MoFEM::BitRefManager::shiftLeftBitRef (const int shift, const BitRefLevel mask=BitRefLevel().set(), int verb=DEFAULT_VERBOSITY) const
 left shift bit ref level More...
 
MoFEMErrorCode MoFEM::BitRefManager::shiftRightBitRef (const int shift, const BitRefLevel mask=BitRefLevel().set(), int verb=DEFAULT_VERBOSITY, MoFEMTypes mf=MF_ZERO) const
 right shift bit ref level More...
 
MoFEMErrorCode MoFEM::BitRefManager::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. More...
 
MoFEMErrorCode MoFEM::BitRefManager::setBitRefLevelByDim (const EntityHandle meshset, const int dim, const BitRefLevel bit, int verb=QUIET) const
 Set the Bit Ref Level By Dim object. More...
 
MoFEMErrorCode MoFEM::BitRefManager::setBitRefLevelByType (const EntityHandle meshset, const EntityType type, const BitRefLevel bit, int verb=QUIET) const
 Set the Bit Ref Level By Type object. More...
 
MoFEMErrorCode MoFEM::BitRefManager::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, to multi-indices in MoFEM. More...
 
MoFEMErrorCode MoFEM::BitRefManager::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, to multi-indices in MoFEM. More...
 
MoFEMErrorCode MoFEM::BitRefManager::lambdaBitRefLevel (boost::function< void(EntityHandle ent, BitRefLevel &bit)> fun) const
 Process bit ref level by lambda function. More...
 
MoFEMErrorCode MoFEM::BitRefManager::lambdaBitRefLevel (const Range &ents, boost::function< void(EntityHandle ent, BitRefLevel &bit)> fun) const
 Process bit ref level by lambda function. More...
 
MoFEMErrorCode MoFEM::BitRefManager::addBitRefLevelByDim (const EntityHandle meshset, const int dim, const BitRefLevel bit, int verb=QUIET) const
 add bit ref level by dimension More...
 
MoFEMErrorCode MoFEM::BitRefManager::setNthBitRefLevel (const Range &ents, const int n, const bool b, int verb=QUIET) const
 Set nth bit ref level. More...
 

Entity handlers by bit ref level

MoFEMErrorCode MoFEM::BitRefManager::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 More...
 
MoFEMErrorCode MoFEM::BitRefManager::getEntitiesByTypeAndRefLevel (const BitRefLevel bit, const BitRefLevel mask, const EntityType type, Range &ents, int verb=0) const
 add all ents from ref level given by bit to meshset More...
 
MoFEMErrorCode MoFEM::BitRefManager::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 More...
 
MoFEMErrorCode MoFEM::BitRefManager::getEntitiesByDimAndRefLevel (const BitRefLevel bit, const BitRefLevel mask, const int dim, Range &ents, int verb=0) const
 add all ents from ref level given by bit to meshset More...
 
MoFEMErrorCode MoFEM::BitRefManager::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 More...
 
MoFEMErrorCode MoFEM::BitRefManager::getEntitiesByRefLevel (const BitRefLevel bit, const BitRefLevel mask, Range &ents, const int verb=QUIET) const
 add all ents from ref level given by bit to meshset More...
 

Get adjacencies bit ref level

virtual MoFEMErrorCode MoFEM::BitRefManager::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. More...
 
virtual MoFEMErrorCode MoFEM::BitRefManager::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. More...
 
virtual MoFEMErrorCode MoFEM::BitRefManager::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. More...
 
virtual MoFEMErrorCode MoFEM::BitRefManager::getAdjacencies (const BitRefLevel bit, 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. More...
 

Update meshsets and ranges by children

MoFEMErrorCode MoFEM::BitRefManager::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 entities. More...
 
MoFEMErrorCode MoFEM::BitRefManager::updateMeshsetByEntitiesChildren (const EntityHandle parent, const BitRefLevel &child_bit, const EntityHandle child, EntityType child_type, const bool recursive=false, int verb=0)
 Get child entities form meshset containing parent entities. More...
 
MoFEMErrorCode MoFEM::BitRefManager::updateFieldMeshsetByEntitiesChildren (const BitRefLevel &child_bit, int verb=0)
 update fields meshesets by child entities More...
 
MoFEMErrorCode MoFEM::BitRefManager::updateFieldMeshsetByEntitiesChildren (const std::string name, const BitRefLevel &child_bit, int verb=0)
 update field meshset by child entities More...
 
MoFEMErrorCode MoFEM::BitRefManager::updateFiniteElementMeshsetByEntitiesChildren (const std::string name, const BitRefLevel &child_bit, const EntityType fe_ent_type, int verb=0)
 update finite element meshset by child entities More...
 
MoFEMErrorCode MoFEM::BitRefManager::updateRangeByChildren (const Range &parent, Range &child, MoFEMTypes bh=MF_ZERO)
 Update range by childrens. More...
 
MoFEMErrorCode MoFEM::BitRefManager::updateRangeByParent (const Range &child_ents, Range &parent_ents, MoFEMTypes bh=MF_ZERO)
 Update range by parents. More...
 
DEPRECATED MoFEMErrorCode MoFEM::BitRefManager::updateRange (const Range &parent, Range &child, MoFEMTypes bh=MF_ZERO)
 

Detailed Description

Managing BitRefLevels.

Function Documentation

◆ addBitRefLevel()

MoFEMErrorCode MoFEM::BitRefManager::addBitRefLevel ( const Range ents,
const BitRefLevel bit,
int  verb = QUIET 
) const

add bit ref level to ref entity

Parameters
entsrange of entities
bitbit ref level
verbverbosity level
Returns
error code
Examples
hanging_node_approx.cpp.

Definition at line 554 of file BitRefManager.cpp.

556  {
557  return lambdaBitRefLevel(
558  ents, [&](EntityHandle ent, BitRefLevel &ent_bit) { ent_bit |= bit; });
559 }

◆ addBitRefLevelByDim()

MoFEMErrorCode MoFEM::BitRefManager::addBitRefLevelByDim ( const EntityHandle  meshset,
const int  dim,
const BitRefLevel  bit,
int  verb = QUIET 
) const

add bit ref level by dimension

Parameters
meshset
dimdimension of entities
bitadded bit
verbverbosity level
Returns
MoFEMErrorCode

Definition at line 561 of file BitRefManager.cpp.

564  {
565  MoFEM::Interface &m_field = cOre;
566  moab::Interface &moab = m_field.get_moab();
567  Range ents, adj;
569  CHKERR moab.get_entities_by_dimension(meshset, dim, ents, true);
570  for (int dd = dim - 1; dd >= 0; dd--)
571  CHKERR moab.get_adjacencies(ents, dd, false, adj, moab::Interface::UNION);
572  ents.merge(adj);
573  if (verb == VERY_NOISY)
574  MOFEM_LOG("BitRefSelf", Sev::noisy) << "Add add bit ref level by dim";
575  CHKERR addBitRefLevel(ents, bit, verb);
577 }

◆ addToDatabaseBitRefLevelByDim()

MoFEMErrorCode MoFEM::BitRefManager::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, to multi-indices in MoFEM.

Note
Every entity, used for create DoFS, or elements has to have set BitRefLevel and be added to MoFEM database.
This functions add lower dimension entities by calling setEntitiesBitRefLevel
Parameters
dimdimension of entity
bitbit ref level
verbverbosity level
Returns
MoFEMErrorCode

Definition at line 463 of file BitRefManager.cpp.

465  {
467  Range ents;
468  CHKERR getEntitiesByDimAndRefLevel(bit, mask, dim, ents);
469  CHKERR setBitRefLevel(ents, BitRefLevel(), false, verb);
471 }

◆ addToDatabaseBitRefLevelByType()

MoFEMErrorCode MoFEM::BitRefManager::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, to multi-indices in MoFEM.

Note
Every entity, used for create DoFS, or elements has to have set BitRefLevel and be added to MoFEM database.
This functions add lower dimension entities by calling setEntitiesBitRefLevel
Parameters
typeof entity
bitbit ref level
mask
verbverbosity level
Returns
MoFEMErrorCode

Definition at line 453 of file BitRefManager.cpp.

455  {
457  Range ents;
459  CHKERR setBitRefLevel(ents, BitRefLevel(), false, verb);
461 }

◆ getAdjacencies() [1/2]

MoFEMErrorCode MoFEM::BitRefManager::getAdjacencies ( const BitRefLevel  bit,
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
virtual

Get the adjacencies associated with a entity to entities of a specified dimension.

bit ref level of adjacent entities is equal to bit ref level of adjacent entities

Definition at line 988 of file BitRefManager.cpp.

991  {
992  MoFEM::Interface &m_field = cOre;
993  moab::Interface &moab(m_field.get_moab());
995 
996  if (verb > VERBOSE) {
998  MOFEM_LOG("BitRef", Sev::noisy) << "from: " << bit;
999  }
1000 
1001  CHKERR moab.get_adjacencies(from_entities, num_entities, to_dimension, false,
1002  adj_entities, operation_type);
1003  std::vector<BitRefLevel> bit_levels(adj_entities.size());
1004  CHKERR moab.tag_get_data(cOre.get_th_RefBitLevel(), adj_entities,
1005  &*bit_levels.begin());
1006  std::vector<BitRefLevel>::iterator b_it = bit_levels.begin();
1007  for (Range::iterator eit = adj_entities.begin(); eit != adj_entities.end();
1008  b_it++) {
1009 
1010  if (verb > VERBOSE) {
1011  RefEntity adj_entity(m_field.get_basic_entity_data_ptr(), *eit);
1013  MOFEM_LOG("BitRef", Sev::noisy)
1014  << "to: " << adj_entity.getBitRefLevel() << " : " << adj_entity;
1015  }
1016 
1017  if (!((*b_it) & bit).any()) {
1018  eit = adj_entities.erase(eit);
1019  } else {
1020  eit++;
1021  }
1022  }
1023  if (b_it != bit_levels.end()) {
1024  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY, "Data inconsistency");
1025  }
1027 }

◆ getAdjacencies() [2/2]

MoFEMErrorCode MoFEM::BitRefManager::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
virtual

Get the adjacencies associated with a entity to entities of a specified dimension.

bit ref level of adjacent entities is equal to bit ref level of adjacent entities

Definition at line 977 of file BitRefManager.cpp.

980  {
982  BitRefLevel bit = problem_ptr->getBitRefLevel();
983  CHKERR getAdjacencies(bit, from_entities, num_entities, to_dimension,
984  adj_entities, operation_type);
986 }

◆ getAdjacenciesAny()

MoFEMErrorCode MoFEM::BitRefManager::getAdjacenciesAny ( const EntityHandle  from_entity,
const int  to_dimension,
Range adj_entities 
) const
virtual

Get the adjacencies associated with a entity to entities of a specified dimension.

bit ref level of adjacent entities is any of bit ref level of adjacent entities

Definition at line 951 of file BitRefManager.cpp.

953  {
954  MoFEM::Interface &m_field = cOre;
955  moab::Interface &moab(m_field.get_moab());
957  BitRefLevel bit_from_entity;
958  CHKERR moab.tag_get_data(cOre.get_th_RefBitLevel(), &from_entity, 1,
959  &bit_from_entity);
960  CHKERR moab.get_adjacencies(&from_entity, 1, to_dimension, false,
961  adj_entities);
962  std::vector<BitRefLevel> bit_levels(adj_entities.size());
963  CHKERR moab.tag_get_data(cOre.get_th_RefBitLevel(), adj_entities,
964  &*bit_levels.begin());
965  std::vector<BitRefLevel>::iterator b_it = bit_levels.begin();
966  Range::iterator eit = adj_entities.begin();
967  for (; eit != adj_entities.end(); b_it++) {
968  if (!(bit_from_entity & (*b_it)).any()) {
969  eit = adj_entities.erase(eit);
970  } else {
971  eit++;
972  }
973  }
975 }

◆ getAdjacenciesEquality()

MoFEMErrorCode MoFEM::BitRefManager::getAdjacenciesEquality ( const EntityHandle  from_entity,
const int  to_dimension,
Range adj_entities 
) const
virtual

Get the adjacencies associated with a entity to entities of a specified dimension.

bit ref level of adjacent entities is equal to bit ref level of adjacent entities

Definition at line 925 of file BitRefManager.cpp.

927  {
928  MoFEM::Interface &m_field = cOre;
929  moab::Interface &moab(m_field.get_moab());
931  BitRefLevel bit_from_entity;
932  CHKERR moab.tag_get_data(cOre.get_th_RefBitLevel(), &from_entity, 1,
933  &bit_from_entity);
934  CHKERR moab.get_adjacencies(&from_entity, 1, to_dimension, false,
935  adj_entities);
936  std::vector<BitRefLevel> bit_levels(adj_entities.size());
937  CHKERR moab.tag_get_data(cOre.get_th_RefBitLevel(), adj_entities,
938  &*bit_levels.begin());
939  auto b_it = bit_levels.begin();
940  auto eit = adj_entities.begin();
941  for (; eit != adj_entities.end(); b_it++) {
942  if (bit_from_entity != *b_it) {
943  eit = adj_entities.erase(eit);
944  } else {
945  eit++;
946  }
947  }
949 }

◆ getEntitiesByDimAndRefLevel() [1/2]

MoFEMErrorCode MoFEM::BitRefManager::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

Note
Entities NOT have to be added to MoFEM database
Parameters
BitRefLevelbitLevel
BitRefLevelmask
EntityTypedimension of entities
Return values
ents
Examples
free_surface.cpp, and hanging_node_approx.cpp.

Definition at line 822 of file BitRefManager.cpp.

824  {
825  MoFEM::Interface &m_field = cOre;
826  moab::Interface &moab(m_field.get_moab());
828  Range ents;
829  CHKERR getEntitiesByDimAndRefLevel(bit, mask, dim, ents, verb);
830  CHKERR moab.add_entities(meshset, ents);
832 }

◆ getEntitiesByDimAndRefLevel() [2/2]

MoFEMErrorCode MoFEM::BitRefManager::getEntitiesByDimAndRefLevel ( const BitRefLevel  bit,
const BitRefLevel  mask,
const int  dim,
Range ents,
int  verb = 0 
) const

add all ents from ref level given by bit to meshset

Note
Entities NOT have to be added to MoFEM database
Parameters
BitRefLevelbitLevel
BitRefLevelmask
EntityTypedimension of entities
Return values
ents

Definition at line 834 of file BitRefManager.cpp.

836  {
837  MoFEM::Interface &m_field = cOre;
838  moab::Interface &moab(m_field.get_moab());
840  CHKERR moab.get_entities_by_dimension(0, dim, ents, false);
841  CHKERR filterEntitiesByRefLevel(bit, mask, ents, verb);
843 }

◆ getEntitiesByRefLevel() [1/2]

MoFEMErrorCode MoFEM::BitRefManager::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

Note
Entities NOT have to be added to MoFEM database
Parameters
BitRefLevelbitLevel
BitRefLevelmask
EntityHandlemeshset

Definition at line 845 of file BitRefManager.cpp.

848  {
849  MoFEM::Interface &m_field = cOre;
850  moab::Interface &moab(m_field.get_moab());
852  Range ents;
853  CHKERR getEntitiesByRefLevel(bit, mask, ents, verb);
854  CHKERR moab.add_entities(meshset, ents);
856 }

◆ getEntitiesByRefLevel() [2/2]

MoFEMErrorCode MoFEM::BitRefManager::getEntitiesByRefLevel ( const BitRefLevel  bit,
const BitRefLevel  mask,
Range ents,
const int  verb = QUIET 
) const

add all ents from ref level given by bit to meshset

Note
Entities NOT have to be added to MoFEM database
Parameters
BitRefLevelbitLevel
BitRefLevelmask
Return values
ents

Definition at line 858 of file BitRefManager.cpp.

861  {
862  MoFEM::Interface &m_field = cOre;
863  moab::Interface &moab(m_field.get_moab());
865  Range meshset_ents;
866  CHKERR moab.get_entities_by_type(0, MBENTITYSET, meshset_ents, false);
867  CHKERR moab.get_entities_by_handle(0, ents, false);
868  ents.merge(meshset_ents);
869  CHKERR filterEntitiesByRefLevel(bit, mask, ents, verb);
871 }

◆ getEntitiesByTypeAndRefLevel() [1/2]

MoFEMErrorCode MoFEM::BitRefManager::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

Note
Entities NOT have to be added to MoFEM database
Parameters
BitRefLevelbitLevel
BitRefLevelmask
EntityTypetype of entities
Return values
EntityHandlemeshset
Examples
mesh_cut.cpp.

Definition at line 734 of file BitRefManager.cpp.

736  {
737  MoFEM::Interface &m_field = cOre;
738  moab::Interface &moab(m_field.get_moab());
740  Range ents;
741  CHKERR getEntitiesByTypeAndRefLevel(bit, mask, type, ents, verb);
742  CHKERR moab.add_entities(meshset, ents);
744 }

◆ getEntitiesByTypeAndRefLevel() [2/2]

MoFEMErrorCode MoFEM::BitRefManager::getEntitiesByTypeAndRefLevel ( const BitRefLevel  bit,
const BitRefLevel  mask,
const EntityType  type,
Range ents,
int  verb = 0 
) const

add all ents from ref level given by bit to meshset

Note
Entities NOT have to be added to MoFEM database
Parameters
BitRefLevelbitLevel
BitRefLevelmask
EntityTypetype of entities
Return values
ents

Definition at line 811 of file BitRefManager.cpp.

813  {
814  MoFEM::Interface &m_field = cOre;
815  moab::Interface &moab(m_field.get_moab());
817  CHKERR moab.get_entities_by_type(0, type, ents, false);
818  CHKERR filterEntitiesByRefLevel(bit, mask, ents, verb);
820 }

◆ lambdaBitRefLevel() [1/2]

MoFEMErrorCode MoFEM::BitRefManager::lambdaBitRefLevel ( boost::function< void(EntityHandle ent, BitRefLevel &bit)>  fun) const

Process bit ref level by lambda function.

Note
That not apply to type of MBENTITY. To avoid problems with problem meshsets.
Parameters
fun
Returns
MoFEMErrorCode

Definition at line 524 of file BitRefManager.cpp.

525  {
526  MoFEM::Interface &m_field = cOre;
528  auto get_ents = [&]() {
529  Range ents;
530  CHKERR m_field.get_moab().get_entities_by_handle(
531  m_field.get_moab().get_root_set(), ents, true);
532  ents = subtract(ents, ents.subset_by_type(MBENTITYSET));
533  return ents;
534  };
535  CHKERR lambdaBitRefLevel(get_ents(), fun);
537 }

◆ lambdaBitRefLevel() [2/2]

MoFEMErrorCode MoFEM::BitRefManager::lambdaBitRefLevel ( const Range ents,
boost::function< void(EntityHandle ent, BitRefLevel &bit)>  fun 
) const

Process bit ref level by lambda function.

Parameters
fun
Returns
MoFEMErrorCode

Definition at line 539 of file BitRefManager.cpp.

541  {
542  MoFEM::Interface &m_field = cOre;
544  std::vector<const BitRefLevel *> ents_bits_vec;
545  CHKERR RefEntity::getBitRefLevel(m_field.get_moab(), ents, ents_bits_vec);
546  auto eit = ents.begin();
547  for (auto &it : ents_bits_vec) {
548  fun(*eit, const_cast<BitRefLevel &>(*it));
549  ++eit;
550  }
552 };

◆ setBitLevelToMeshset()

MoFEMErrorCode MoFEM::BitRefManager::setBitLevelToMeshset ( const EntityHandle  meshset,
const BitRefLevel  bit,
int  verb = 0 
) const

brief add meshset and set bit ref level

Parameters
EntityHandleMeshSet
BitRefLevelbitLevel

Definition at line 473 of file BitRefManager.cpp.

475  {
476  MoFEM::Interface &m_field = cOre;
477  auto ref_ents_ptr = m_field.get_ref_ents();
478  auto ref_fe_ptr = m_field.get_ref_finite_elements();
480  // Add ref entity
481  std::pair<RefEntity_multiIndex::iterator, bool> p_ent =
482  const_cast<RefEntity_multiIndex *>(ref_ents_ptr)
483  ->insert(boost::shared_ptr<RefEntity>(
484  new RefEntity(m_field.get_basic_entity_data_ptr(), meshset)));
485  *(const_cast<RefEntity *>(p_ent.first->get())->getBitRefLevelPtr()) |= bit;
486  // Add ref element
487  boost::shared_ptr<RefElement> fe_ptr =
488  boost::shared_ptr<RefElement>(new RefElement_MESHSET(*p_ent.first));
489  std::pair<RefElement_multiIndex::iterator, bool> p_fe =
490  const_cast<RefElement_multiIndex *>(ref_fe_ptr)->insert(fe_ptr);
491 
493  MOFEM_LOG("BitRefSelf", Sev::noisy)
494  << "Add meshset as ref_ent " << **p_fe.first;
495 
497 }

◆ setBitRefLevel()

MoFEMErrorCode MoFEM::BitRefManager::setBitRefLevel ( const Range ents,
const BitRefLevel  bit,
const bool  only_tets = true,
int  verb = 0,
Range adj_ents_ptr = nullptr 
) const

add entities to database and set bit ref level

This function set bit ref level, add entries to core database and create ref finite elements. Finite elements are create of entities in function argument, whereas all lower dimension entities are added as a field entities

Example:

EntityHandle meshset1; //contains ent1,ent2,ent3
BitRefLevel myLevel0;
myLevel0.set(0);
m_field.getInterface<BitRefManager>()->setBitRefLevelByDim(meshset1,3,myLevel0);
//refine meshset1 into meshset2 and get new ents which are ent4, ent5
EntityHandle meshset2; //contains ent1,ent2,ent3,ent4,ent5
BitRefLevel myLevel1;
myLevel1.set(1);
m_field.getInterface<BitRefManager>()->setBitRefLevelByDim(meshset2,3,myLevel1);

So entities 1,2,3 would be assigned to bit level 0 and 1
ent1[1,1,0,0,0,0,0], ent2[1,1,0,0,0,0,0], ent3[1,1,0,0,0,0,0],
and entities 4 and 5 are assigned to bit level 1 only
ent4[0,1,0,0,0,0,0], ent5[0,1,0,0,0,0,0]

Parameters
entsentities to set
bitbit refinement level
only_tetsonly add entities on tetrahedral (obsolete need to be fixed)
verbverbosity level
adj_ents_ptrif pointer is given, it is used to get adj entities by dimension/type
Returns
error code

Definition at line 279 of file BitRefManager.cpp.

282  {
283  MoFEM::Interface &m_field = cOre;
284  auto ref_ents_ptr = m_field.get_ref_ents();
285  auto ref_fe_ptr = m_field.get_ref_finite_elements();
287 
289  MOFEM_LOG_C("BitRefSelf", Sev::noisy, "Number of entities to add %d",
290  ents.size());
291 
292  CHKERR setElementsBitRefLevel(ents, bit, verb);
293 
294  if (!ents.empty()) {
295  for (int d = 3; d >= 1; --d) {
296  Range dim_ents;
297  if (only_tets && d == 3) {
298  dim_ents = ents.subset_by_type(MBTET);
299  } else {
300  dim_ents = ents.subset_by_dimension(d);
301  }
302 
304  MOFEM_LOG_C("BitRefSelf", Sev::noisy,
305  " Number of dim %d entities to add %d", d, dim_ents.size());
306 
307  if (!dim_ents.empty()) {
308  for (int dd = 0; dd < d; ++dd) {
309  Range adj_ents;
310 
311  if (dd == 0) {
312  rval = m_field.get_moab().get_connectivity(ents, adj_ents, true);
313  // rval = m_field.get_moab().get_adjacencies(
314  // dim_ents, dd, true, adj_ents, moab::Interface::UNION);
315 
316  } else {
317  if (adj_ents_ptr) {
318  if (dd == 1) {
319  adj_ents = adj_ents_ptr->subset_by_dimension(MBEDGE);
320  } else if (dd == 2) {
321  adj_ents = adj_ents_ptr->subset_by_dimension(MBTRI);
322  }
323  } else {
324  rval = m_field.get_moab().get_adjacencies(
325  dim_ents, dd, true, adj_ents, moab::Interface::UNION);
326  }
327  }
328 
329  // rval = m_field.get_moab().get_adjacencies(
330  // dim_ents, dd, true, adj_ents, moab::Interface::UNION);
331 
333  MOFEM_LOG_C("BitRefSelf", Sev::noisy,
334  " Number of dim %d adj entities for dim %d to add %d", d,
335  dd, adj_ents.size());
336 
337  if (rval == MB_MULTIPLE_ENTITIES_FOUND) {
338  auto log_message = [&](const auto sev) {
341  MOFEM_LOG("BitRefSelf", sev)
342  << "When get adjacencies moab return MB_MULTIPLE_ENTITIES_ "
343  "FOUND for dim = "
344  << dd << " and dim of entities " << d;
345  MOFEM_LOG_CHANNEL("BitRefSelf"); // reset channel
346  };
347 
348  if (verb <= QUIET)
349  log_message(Sev::noisy);
350  else
351  log_message(Sev::warning);
352 
353  rval = MB_SUCCESS;
354  }
355  MOAB_THROW(rval);
356  for (Range::pair_iterator pit = adj_ents.pair_begin();
357  pit != adj_ents.pair_end(); ++pit) {
358  Range seed_ents_range;
359  // get first and last element of range
360  EntityHandle f = pit->first;
361  EntityHandle s = pit->second;
362  CHKERR SetBitRefLevelTool(m_field, bit, ref_ents_ptr, ref_fe_ptr)
363  .findEntsToAdd(f, s, seed_ents_range);
364  if (!seed_ents_range.empty())
365  CHKERR SetBitRefLevelTool(m_field, bit, ref_ents_ptr, ref_fe_ptr)
366  .addEntsToDatabase(seed_ents_range);
367  }
368  }
369  }
370  }
371  }
372 
374 }

◆ setBitRefLevelByDim()

MoFEMErrorCode MoFEM::BitRefManager::setBitRefLevelByDim ( const EntityHandle  meshset,
const int  dim,
const BitRefLevel  bit,
int  verb = QUIET 
) const

Set the Bit Ref Level By Dim object.

Note
In THIS variant only entities in range are added. And DO NOT create elements.
Parameters
meshset
dim
bit
verb
Returns
MoFEMErrorCode

Definition at line 499 of file BitRefManager.cpp.

502  {
503  MoFEM::Interface &m_field = cOre;
505  Range ents;
506  CHKERR m_field.get_moab().get_entities_by_dimension(meshset, dim, ents,
507  false);
508  CHKERR setBitRefLevel(ents, bit, false, verb);
510 }

◆ setBitRefLevelByType()

MoFEMErrorCode MoFEM::BitRefManager::setBitRefLevelByType ( const EntityHandle  meshset,
const EntityType  type,
const BitRefLevel  bit,
int  verb = QUIET 
) const

Set the Bit Ref Level By Type object.

Note
In THIS variant only entities in range are added. And DO NOT create elements.
Parameters
meshset
type
bit
verb
Returns
MoFEMErrorCode
Examples
mesh_cut.cpp.

Definition at line 512 of file BitRefManager.cpp.

515  {
516  MoFEM::Interface &m_field = cOre;
518  Range ents;
519  CHKERR m_field.get_moab().get_entities_by_type(meshset, type, ents, false);
520  CHKERR setBitRefLevel(ents, bit, false, verb);
522 }

◆ setElementsBitRefLevel()

MoFEMErrorCode MoFEM::BitRefManager::setElementsBitRefLevel ( const Range ents,
const BitRefLevel  bit = BitRefLevel(),
int  verb = QUIET 
) const

add entities to database and set bit ref level

Note
In THIS variant only entities in range are added and ref finite elements reated.
Parameters
ents
bit
only_tets
verb
Returns
MoFEMErrorCode setBitRefLevel

Definition at line 376 of file BitRefManager.cpp.

378  {
379  MoFEM::Interface &m_field = cOre;
380  auto ref_ents_ptr = m_field.get_ref_ents();
381  auto ref_fe_ptr = m_field.get_ref_finite_elements();
383 
384  for (Range::const_pair_iterator pit = ents.pair_begin();
385  pit != ents.pair_end(); pit++) {
386  // get first and last element of range
387  EntityHandle f = pit->first;
388  EntityHandle s = pit->second;
389  Range seed_ents_range; // entities seeded not in database
390  // find ents to add
391  CHKERR SetBitRefLevelTool(m_field, bit, ref_ents_ptr, ref_fe_ptr)
392  .findEntsToAdd(f, s, seed_ents_range);
393  // add elements
394  if (!seed_ents_range.empty())
395  CHKERR SetBitRefLevelTool(m_field, bit, ref_ents_ptr, ref_fe_ptr)
396  .addEntsToDatabase(seed_ents_range);
397 
398  Range seed_fe_range;
399  CHKERR SetBitRefLevelTool(m_field, bit, ref_ents_ptr, ref_fe_ptr)
400  .findElementsToAdd(f, s, seed_fe_range);
401  if (!seed_fe_range.empty()) {
402  CHKERR SetBitRefLevelTool(m_field, bit, ref_ents_ptr, ref_fe_ptr)
403  .addElementsToDatabase(seed_fe_range);
404  }
405  }
406 
408  MOFEM_LOG("BitRefSelf", Sev::noisy)
409  << "Number of entities in databse " << ref_ents_ptr->size();
410  MOFEM_LOG("BitRefSelf", Sev::noisy)
411  << "Number of finite element entities in databse " << ref_fe_ptr->size();
412 
414 }

◆ setEntitiesBitRefLevel()

MoFEMErrorCode MoFEM::BitRefManager::setEntitiesBitRefLevel ( const Range ents,
const BitRefLevel  bit = BitRefLevel(),
int  verb = QUIET 
) const

add entities to database and set bit ref level

Note
In THIS variant only entities in range are added. And DO NOT create elements.
Parameters
ents
bit
only_tets
verb
Returns
MoFEMErrorCode setBitRefLevel

Definition at line 416 of file BitRefManager.cpp.

418  {
419  MoFEM::Interface &m_field = cOre;
420  auto ref_ents_ptr = m_field.get_ref_ents();
421  auto ref_fe_ptr = m_field.get_ref_finite_elements();
423 
424  for (Range::const_pair_iterator pit = ents.pair_begin();
425  pit != ents.pair_end(); pit++) {
426  // get first and last element of range
427  EntityHandle f = pit->first;
428  EntityHandle s = pit->second;
429  Range seed_ents_range; // entities seeded not in database
430  // find ents to add
431  CHKERR SetBitRefLevelTool(m_field, bit, ref_ents_ptr, ref_fe_ptr)
432  .findEntsToAdd(f, s, seed_ents_range);
433  // add elements
434  if (!seed_ents_range.empty())
435  CHKERR SetBitRefLevelTool(m_field, bit, ref_ents_ptr, ref_fe_ptr)
436  .addEntsToDatabase(seed_ents_range);
437  }
439 }

◆ setFieldEntitiesBitRefLevel()

MoFEMErrorCode MoFEM::BitRefManager::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.

Parameters
field_name
bit
verb
Returns
MoFEMErrorCode

Definition at line 441 of file BitRefManager.cpp.

442  {
443  MoFEM::Interface &m_field = cOre;
445  EntityHandle field_meshset = m_field.get_field_meshset(field_name);
446  Range field_ents;
447  CHKERR m_field.get_moab().get_entities_by_handle(field_meshset, field_ents,
448  true);
449  CHKERR setEntitiesBitRefLevel(field_ents, bit, verb);
451 }

◆ setNthBitRefLevel() [1/2]

MoFEMErrorCode MoFEM::BitRefManager::setNthBitRefLevel ( const int  n,
const bool  b,
int  verb = QUIET 
) const

Set nth bit ref level to all entities in database.

Parameters
nnth bit
bvalue to set
Returns
error code

Definition at line 587 of file BitRefManager.cpp.

588  {
589  if (verb == VERY_NOISY)
590  MOFEM_LOG("BitRefSelf", Sev::noisy) << "Set bit to all entities";
591  return lambdaBitRefLevel(
592  [&](EntityHandle ent, BitRefLevel &ent_bit) { ent_bit[n] = b; });
593 }

◆ setNthBitRefLevel() [2/2]

MoFEMErrorCode MoFEM::BitRefManager::setNthBitRefLevel ( const Range ents,
const int  n,
const bool  b,
int  verb = QUIET 
) const

Set nth bit ref level.

Note
This function modify bits only on entities in RefEntity_multiindex
Parameters
entsentities to set bit ref level
nnth bit
bvalue to set
Returns
error code

Definition at line 579 of file BitRefManager.cpp.

580  {
581  if (verb == VERY_NOISY)
582  MOFEM_LOG("BitRefSelf", Sev::noisy) << "Set bit to " << ents;
583  return lambdaBitRefLevel(
584  ents, [&](EntityHandle ent, BitRefLevel &ent_bit) { ent_bit[n] = b; });
585 }

◆ shiftLeftBitRef()

MoFEMErrorCode MoFEM::BitRefManager::shiftLeftBitRef ( const int  shift,
const BitRefLevel  mask = BitRefLevel().set(),
int  verb = DEFAULT_VERBOSITY 
) const

left shift bit ref level

this results of deletion of entities on far left side

Note
Not implemented

Definition at line 595 of file BitRefManager.cpp.

597  {
599  SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED, "not implemented");
601 }

◆ shiftRightBitRef()

MoFEMErrorCode MoFEM::BitRefManager::shiftRightBitRef ( const int  shift,
const BitRefLevel  mask = BitRefLevel().set(),
int  verb = DEFAULT_VERBOSITY,
MoFEMTypes  mf = MF_ZERO 
) const

right shift bit ref level

Definition at line 603 of file BitRefManager.cpp.

605  {
606  MoFEM::Interface &m_field = cOre;
607  auto ref_ents_ptr = m_field.get_ref_ents();
609  RefEntity_change_right_shift right_shift(1, mask);
610  for (int ii = 0; ii < shift; ii++) {
611  // delete bits on the right which are shifted to zero
612  BitRefLevel delete_bits = BitRefLevel().set(0) & mask;
613  if (delete_bits.any()) {
614  CHKERR m_field.delete_ents_by_bit_ref(delete_bits, delete_bits, true,
615  verb, mf);
616  }
617  for (RefEntity_multiIndex::iterator ent_it = ref_ents_ptr->begin();
618  ent_it != ref_ents_ptr->end(); ent_it++) {
619  if (verb >= NOISY) {
621  MOFEM_LOG("BitRefSelf", Sev::noisy)
622  << (*ent_it)->getBitRefLevel() << " : ";
623  }
624  right_shift(const_cast<boost::shared_ptr<RefEntity> &>(*ent_it));
625  if (verb == VERY_NOISY) {
627  MOFEM_LOG("BitRefSelf", Sev::noisy) << (*ent_it)->getBitRefLevel();
628  }
629  }
630  }
632 }

◆ updateFieldMeshsetByEntitiesChildren() [1/2]

MoFEMErrorCode MoFEM::BitRefManager::updateFieldMeshsetByEntitiesChildren ( const BitRefLevel child_bit,
int  verb = 0 
)

update fields meshesets by child entities

Note
This calls updateMeshsetByEntitiesChildren for all entity types.

Definition at line 1065 of file BitRefManager.cpp.

1066  {
1067  MoFEM::Interface &m_field = cOre;
1068  moab::Interface &moab = m_field.get_moab();
1069  auto fields_ptr = m_field.get_fields();
1071 
1072  for (auto &fit : (*fields_ptr)) {
1073 
1074  const EntityHandle meshset = fit->getMeshset();
1075  Range parent_ents;
1076  CHKERR moab.get_entities_by_handle(meshset, parent_ents, true);
1077 
1078  if (verb >= VERY_VERBOSE) {
1080  MOFEM_LOG("BitRefSelf", Sev::noisy) << "Parnets:" << std::endl
1081  << parent_ents << std::endl;
1082  }
1083 
1084  Range children_ents;
1085  CHKERR updateRangeByChildren(parent_ents, children_ents);
1086  CHKERR filterEntitiesByRefLevel(child_bit, BitRefLevel().set(),
1087  children_ents, verb);
1088 
1089  CHKERR moab.add_entities(meshset, children_ents);
1090 
1091  if (verb >= VERY_VERBOSE) {
1093  MOFEM_LOG("BitRefSelf", Sev::noisy) << "Children: " << std::endl
1094  << children_ents << std::endl;
1095  }
1096  }
1098 }

◆ updateFieldMeshsetByEntitiesChildren() [2/2]

MoFEMErrorCode MoFEM::BitRefManager::updateFieldMeshsetByEntitiesChildren ( const std::string  name,
const BitRefLevel child_bit,
int  verb = 0 
)

update field meshset by child entities

Definition at line 1100 of file BitRefManager.cpp.

1101  {
1102  MoFEM::Interface &m_field = cOre;
1103  moab::Interface &moab = m_field.get_moab();
1105 
1106  EntityHandle field_meshset = m_field.get_field_structure(name)->getMeshset();
1107 
1108  Range parent_ents;
1109  CHKERR moab.get_entities_by_handle(field_meshset, parent_ents, true);
1110 
1111  if (verb >= VERBOSE) {
1113  MOFEM_LOG("BitRefSelf", Sev::noisy) << "Parnets:" << endl
1114  << parent_ents << std::endl;
1115  }
1116 
1117  Range children_ents;
1118  CHKERR updateRangeByChildren(parent_ents, children_ents);
1119  CHKERR filterEntitiesByRefLevel(child_bit, BitRefLevel().set(), children_ents,
1120  verb);
1121 
1122  CHKERR moab.add_entities(field_meshset, children_ents);
1123 
1124  if (verb >= VERBOSE) {
1126  MOFEM_LOG("BitRefSelf", Sev::noisy) << "Children: " << endl
1127  << children_ents << std::endl;
1128  }
1129 
1131 }

◆ updateFiniteElementMeshsetByEntitiesChildren()

MoFEMErrorCode MoFEM::BitRefManager::updateFiniteElementMeshsetByEntitiesChildren ( const std::string  name,
const BitRefLevel child_bit,
const EntityType  fe_ent_type,
int  verb = 0 
)

update finite element meshset by child entities

Definition at line 1133 of file BitRefManager.cpp.

1135  {
1136  MoFEM::Interface &m_field = cOre;
1138  EntityHandle meshset = m_field.get_finite_element_meshset(name);
1139  CHKERR updateMeshsetByEntitiesChildren(meshset, child_bit, meshset,
1140  fe_ent_type, false, verb);
1142 }

◆ updateMeshsetByEntitiesChildren() [1/2]

MoFEMErrorCode MoFEM::BitRefManager::updateMeshsetByEntitiesChildren ( const EntityHandle  parent,
const BitRefLevel child_bit,
const EntityHandle  child,
EntityType  child_type,
const bool  recursive = false,
int  verb = 0 
)

Get child entities form meshset containing parent entities.

Search for refined entities of given type whose parent are entities in the parent meshset. It can be used for example to transfer information about boundary conditions to refined mesh or split mesh by interface elements. It is used by function refineMeshset, to update MESHSET finite elements.

Parameters
parentmeshset
parent_bitrefinement level
maskof parent bit ref level
child_bitrefinement level
maskof child bit ref level
childmeshset where child entities are stored (if the child meshset is set to be the parent meshset, the parent would be updated with the refined entities)
child_typemeshset is update only by entities of specified type. if type is set to MBMAXTYPE all types are updated.
recursiveif true parent meshset is searched recursively

Definition at line 1054 of file BitRefManager.cpp.

1057  {
1060  parent, BitRefLevel().set(), BitRefLevel().set(), child_bit, child_bit,
1061  child, child_type, recursive, verb);
1063 }

◆ updateMeshsetByEntitiesChildren() [2/2]

MoFEMErrorCode MoFEM::BitRefManager::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 entities.

Search for refined entities of given type whose parent are entities in the parent meshset. It can be used for example to transfer information about boundary conditions to refined mesh or split mesh by interface elements. It is used by function refineMeshset, to update MESHSET finite elements.

Parameters
parentmeshset
parent_bitrefinement level
maskof parent bit ref level
child_bitrefinement level
maskof child bit ref level
childmeshset where child entities are stored (if the child meshset is set to be the parent meshset, the parent would be updated with the refined entities)
child_typemeshset is update only by entities of specified type. if type is set to MBMAXTYPE all types are updated.
recursiveif true parent meshset is searched recursively
Examples
hanging_node_approx.cpp.

Definition at line 1029 of file BitRefManager.cpp.

1033  {
1034  MoFEM::Interface &m_field = cOre;
1035  moab::Interface &moab = m_field.get_moab();
1037  Range parent_ents;
1038  CHKERR moab.get_entities_by_handle(parent, parent_ents, recursive);
1039  CHKERR filterEntitiesByRefLevel(parent_bit, parent_mask, parent_ents, verb);
1040  if (verb >= VERY_VERBOSE) {
1042  MOFEM_LOG("BitRefSelf", Sev::noisy) << "Parents: " << parent;
1043  }
1044  Range children_ents;
1045  CHKERR updateRangeByChildren(parent_ents, children_ents);
1046  if (child_type < MBMAXTYPE)
1047  children_ents = children_ents.subset_by_type(child_type);
1048  CHKERR filterEntitiesByRefLevel(child_bit, BitRefLevel().set(), children_ents,
1049  verb);
1050  CHKERR moab.add_entities(child, children_ents);
1052 }

◆ updateRange()

DEPRECATED MoFEMErrorCode MoFEM::BitRefManager::updateRange ( const Range parent,
Range child,
MoFEMTypes  bh = MF_ZERO 
)
inline
Deprecated:
use updateRangeByChildren

Definition at line 598 of file BitRefManager.hpp.

598  {
599  return updateRangeByChildren(parent, child, bh);
600  }

◆ updateRangeByChildren()

MoFEMErrorCode MoFEM::BitRefManager::updateRangeByChildren ( const Range parent,
Range child,
MoFEMTypes  bh = MF_ZERO 
)

Update range by childrens.

FIXME: NOT TESTED

Parameters
parentparent range
childchildren range
Returns
error code
Examples
hanging_node_approx.cpp.

Definition at line 1144 of file BitRefManager.cpp.

1146  {
1147  MoFEM::Interface &m_field = cOre;
1148  auto ref_ents_ptr = m_field.get_ref_ents();
1150  auto &ref_ents =
1151  const_cast<RefEntity_multiIndex *>(ref_ents_ptr)->get<Ent_Ent_mi_tag>();
1152  std::vector<EntityHandle> child_ents_vec;
1153  child_ents_vec.reserve(ref_ents.size());
1154  for (Range::const_pair_iterator pit = parent_ents.const_pair_begin();
1155  pit != parent_ents.const_pair_end(); pit++) {
1156  const auto f = pit->first;
1157  auto it = ref_ents.lower_bound(f);
1158  if (it != ref_ents.end()) {
1159  const auto s = pit->second;
1160  auto hi_it = ref_ents.upper_bound(s);
1161  if (bh == MF_EXIST) {
1162  if (std::distance(it, hi_it) != (s - f) + 1) {
1163  SETERRQ2(
1164  PETSC_COMM_SELF, MOFEM_NOT_FOUND,
1165  "Number of entities and entities parents is different %d != %d ",
1166  std::distance(it, hi_it), (s - f) + 1);
1167  }
1168  }
1169  for (; it != hi_it; it++) {
1170 #ifndef NDEBUG
1171  if (it->get()->getEntType() == MBENTITYSET) {
1172  SETERRQ(PETSC_COMM_SELF, MOFEM_IMPOSSIBLE_CASE,
1173  "This should not happen; Entity should not have part of the "
1174  "meshset. It has no children.");
1175  }
1176 #endif
1177  child_ents_vec.emplace_back((*it)->getEnt());
1178  }
1179  } else if (bh == MF_EXIST) {
1180  SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_FOUND, "Entities not found");
1181  }
1182  }
1183  child_ents.insert_list(child_ents_vec.begin(), child_ents_vec.end());
1185 }

◆ updateRangeByParent()

MoFEMErrorCode MoFEM::BitRefManager::updateRangeByParent ( const Range child_ents,
Range parent_ents,
MoFEMTypes  bh = MF_ZERO 
)

Update range by parents.

FIXME: NOT TESTED

Parameters
childparent range
parentchildren range
Returns
error code

Definition at line 1187 of file BitRefManager.cpp.

1189  {
1190  MoFEM::Interface &m_field = cOre;
1191  auto ref_ents_ptr = m_field.get_ref_ents();
1193  auto &ref_ents =
1194  const_cast<RefEntity_multiIndex *>(ref_ents_ptr)->get<Ent_mi_tag>();
1195  std::vector<EntityHandle> parent_ents_vec;
1196  parent_ents_vec.reserve(ref_ents.size());
1197  for (Range::const_pair_iterator pit = child_ents.const_pair_begin();
1198  pit != child_ents.const_pair_end(); pit++) {
1199  const auto f = pit->first;
1200  auto it = ref_ents.lower_bound(f);
1201  if (it != ref_ents.end()) {
1202  const auto s = pit->second;
1203  auto hi_it = ref_ents.upper_bound(s);
1204  if (bh == MF_EXIST) {
1205  if (std::distance(it, hi_it) != (s - f) + 1) {
1206  SETERRQ2(
1207  PETSC_COMM_SELF, MOFEM_NOT_FOUND,
1208  "Number of entities and entities parents is different %d != %d ",
1209  std::distance(it, hi_it), (s - f) + 1);
1210  }
1211  }
1212  for (; it != hi_it; it++) {
1213 #ifndef NDEBUG
1214  if (it->get()->getEntType() == MBENTITYSET) {
1215  SETERRQ(PETSC_COMM_SELF, MOFEM_IMPOSSIBLE_CASE,
1216  "This should not happen; Entity should not have part of the "
1217  "meshset. It has no children.");
1218  }
1219 #endif
1220  auto parent = (*it)->getParentEnt();
1221  if (parent)
1222  parent_ents_vec.emplace_back(parent);
1223  }
1224  } else if (bh == MF_EXIST) {
1225  SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_FOUND, "Entities not found");
1226  }
1227  }
1228  parent_ents.insert_list(parent_ents_vec.begin(), parent_ents_vec.end());
1230 }
MoFEMFunctionReturnHot
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:460
MoFEM::UnknownInterface::getInterface
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.
Definition: UnknownInterface.hpp:93
MoFEM::CoreInterface::get_finite_element_meshset
virtual EntityHandle get_finite_element_meshset(const std::string name) const =0
MoFEM::BitRefManager::getEntitiesByRefLevel
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
Definition: BitRefManager.cpp:845
MOFEM_LOG_CHANNEL
#define MOFEM_LOG_CHANNEL(channel)
Set and reset channel.
Definition: LogManager.hpp:284
EntityHandle
MoFEM::BitRefManager::setElementsBitRefLevel
MoFEMErrorCode setElementsBitRefLevel(const Range &ents, const BitRefLevel bit=BitRefLevel(), int verb=QUIET) const
add entities to database and set bit ref level
Definition: BitRefManager.cpp:376
NOISY
@ NOISY
Definition: definitions.h:224
MoFEM::Field::getMeshset
EntityHandle getMeshset() const
Get field meshset.
Definition: FieldMultiIndices.hpp:123
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::CoreInterface::get_field_structure
virtual const Field * get_field_structure(const std::string &name, enum MoFEMTypes bh=MF_EXIST) const =0
get field structure
VERY_NOISY
@ VERY_NOISY
Definition: definitions.h:225
MOFEM_LOG_ATTRIBUTES
#define MOFEM_LOG_ATTRIBUTES(channel, bit)
Add attributes to channel.
Definition: LogManager.hpp:296
MoFEM::BitRefManager::cOre
MoFEM::Core & cOre
Definition: BitRefManager.hpp:26
MOAB_THROW
#define MOAB_THROW(err)
Check error code of MoAB function and throw MoFEM exception.
Definition: definitions.h:554
MoFEM::CoreInterface::get_field_meshset
virtual EntityHandle get_field_meshset(const std::string name) const =0
get field meshset
MoFEM::BitRefManager::lambdaBitRefLevel
MoFEMErrorCode lambdaBitRefLevel(boost::function< void(EntityHandle ent, BitRefLevel &bit)> fun) const
Process bit ref level by lambda function.
Definition: BitRefManager.cpp:524
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
MOFEM_IMPOSSIBLE_CASE
@ MOFEM_IMPOSSIBLE_CASE
Definition: definitions.h:35
MoFEM::RefEntityTmp< 0 >::getBitRefLevel
const BitRefLevel & getBitRefLevel() const
Get entity ref bit refinement signature.
Definition: RefEntsMultiIndices.hpp:509
MoFEM::BitRefManager::filterEntitiesByRefLevel
MoFEMErrorCode filterEntitiesByRefLevel(const BitRefLevel bit, const BitRefLevel mask, Range &ents, int verb=QUIET) const
filter entities by bit ref level
Definition: BitRefManager.cpp:746
MoFEM::DeprecatedCoreInterface
Deprecated interface functions.
Definition: DeprecatedCoreInterface.hpp:16
MoFEM::Interface
DeprecatedCoreInterface Interface
Definition: Interface.hpp:2010
MOFEM_LOG_FUNCTION
#define MOFEM_LOG_FUNCTION()
Set scope.
Definition: LogManager.hpp:325
MoFEM::LogManager::BitScope
@ BitScope
Definition: LogManager.hpp:49
MoFEM::Exceptions::rval
static MoFEMErrorCodeGeneric< moab::ErrorCode > rval
Definition: Exceptions.hpp:74
MoFEM::BitRefManager::setEntitiesBitRefLevel
MoFEMErrorCode setEntitiesBitRefLevel(const Range &ents, const BitRefLevel bit=BitRefLevel(), int verb=QUIET) const
add entities to database and set bit ref level
Definition: BitRefManager.cpp:416
VERBOSE
@ VERBOSE
Definition: definitions.h:222
CHKERR
#define CHKERR
Inline error check.
Definition: definitions.h:548
MoFEM::BitRefManager::setBitRefLevel
MoFEMErrorCode setBitRefLevel(const Range &ents, const BitRefLevel bit, const bool only_tets=true, int verb=0, Range *adj_ents_ptr=nullptr) const
add entities to database and set bit ref level
Definition: BitRefManager.cpp:279
MoFEM::CoreInterface::get_moab
virtual moab::Interface & get_moab()=0
MoFEM::BitRefManager::setBitRefLevelByDim
MoFEMErrorCode setBitRefLevelByDim(const EntityHandle meshset, const int dim, const BitRefLevel bit, int verb=QUIET) const
Set the Bit Ref Level By Dim object.
Definition: BitRefManager.cpp:499
MoFEM::BitRefManager::getEntitiesByDimAndRefLevel
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
Definition: BitRefManager.cpp:822
MOFEM_LOG_C
#define MOFEM_LOG_C(channel, severity, format,...)
Definition: LogManager.hpp:311
bit
auto bit
set bit
Definition: hanging_node_approx.cpp:75
convert.type
type
Definition: convert.py:64
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::CoreTmp< 0 >::get_th_RefBitLevel
Tag get_th_RefBitLevel() const
Definition: Core.hpp:198
MoFEM::BitRefManager::updateMeshsetByEntitiesChildren
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 entities.
Definition: BitRefManager.cpp:1029
MoFEM::BitRefManager::addBitRefLevel
MoFEMErrorCode addBitRefLevel(const Range &ents, const BitRefLevel &bit, int verb=QUIET) const
add bit ref level to ref entity
Definition: BitRefManager.cpp:554
MoFEM::CoreInterface::delete_ents_by_bit_ref
virtual MoFEMErrorCode delete_ents_by_bit_ref(const BitRefLevel bit, const BitRefLevel mask, const bool remove_parent=false, int verb=DEFAULT_VERBOSITY, MoFEMTypes mf=MF_ZERO)=0
delete entities form mofem and moab database
MoFEM::BitRefManager::BitRefManager
BitRefManager(const MoFEM::Core &core)
Definition: BitRefManager.cpp:16
MoFEM::RefEntity
RefEntityTmp< 0 > RefEntity
Definition: RefEntsMultiIndices.hpp:566
MOFEM_NOT_FOUND
@ MOFEM_NOT_FOUND
Definition: definitions.h:33
field_name
constexpr auto field_name
Definition: poisson_2d_homogeneous.cpp:13
convert.n
n
Definition: convert.py:82
MoFEM::CoreInterface::get_fields
virtual const Field_multiIndex * get_fields() const =0
Get the fields object.
MoFEM::BitRefManager::updateRangeByChildren
MoFEMErrorCode updateRangeByChildren(const Range &parent, Range &child, MoFEMTypes bh=MF_ZERO)
Update range by childrens.
Definition: BitRefManager.cpp:1144
Range
FTensor::dd
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
MOFEM_LOG
#define MOFEM_LOG(channel, severity)
Log.
Definition: LogManager.hpp:308
MoFEM::BitRefManager::getAdjacencies
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.
Definition: BitRefManager.cpp:977
HenckyOps::f
auto f
Definition: HenckyOps.hpp:15
MoFEM::CoreInterface::get_ref_ents
virtual const RefEntity_multiIndex * get_ref_ents() const =0
Get the ref ents object.
MOFEM_DATA_INCONSISTENCY
@ MOFEM_DATA_INCONSISTENCY
Definition: definitions.h:31
MoFEM::CoreInterface::get_ref_finite_elements
virtual const RefElement_multiIndex * get_ref_finite_elements() const =0
Get the ref finite elements object.
sdf_hertz_2d_axisymm_plane.d
float d
Definition: sdf_hertz_2d_axisymm_plane.py:4
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:453
QUIET
@ QUIET
Definition: definitions.h:221
MoFEM::BitRefManager::getEntitiesByTypeAndRefLevel
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
Definition: BitRefManager.cpp:734
fun
auto fun
Function to approximate.
Definition: dg_projection.cpp:36
MF_EXIST
@ MF_EXIST
Definition: definitions.h:113
MoFEMFunctionReturn
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:429
MOFEM_NOT_IMPLEMENTED
@ MOFEM_NOT_IMPLEMENTED
Definition: definitions.h:32
VERY_VERBOSE
@ VERY_VERBOSE
Definition: definitions.h:223
MoFEMFunctionBegin
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:359