v0.14.0
Public Member Functions | Public Attributes | List of all members
MoFEM::BitRefManager Struct Reference

Managing BitRefLevels. More...

#include <src/interfaces/BitRefManager.hpp>

Inheritance diagram for MoFEM::BitRefManager:
[legend]
Collaboration diagram for MoFEM::BitRefManager:
[legend]

Public Member Functions

MoFEMErrorCode query_interface (boost::typeindex::type_index type_index, UnknownInterface **iface) const
 
 BitRefManager (const MoFEM::Core &core)
 
virtual ~BitRefManager ()=default
 Destructor. More...
 
- Public Member Functions inherited from MoFEM::UnknownInterface
template<class IFACE >
MoFEMErrorCode registerInterface (bool error_if_registration_failed=true)
 Register interface. More...
 
template<class IFACE >
MoFEMErrorCode getInterface (IFACE *&iface) const
 Get interface reference to pointer of interface. More...
 
template<class IFACE >
MoFEMErrorCode getInterface (IFACE **const iface) const
 Get interface pointer to pointer of interface. More...
 
template<class IFACE , typename boost::enable_if< boost::is_pointer< IFACE >, int >::type = 0>
IFACE getInterface () const
 Get interface pointer to pointer of interface. More...
 
template<class IFACE , typename boost::enable_if< boost::is_reference< IFACE >, int >::type = 0>
IFACE getInterface () const
 Get reference to interface. More...
 
template<class IFACE >
IFACE * getInterface () const
 Function returning pointer to interface. More...
 
virtual ~UnknownInterface ()=default
 

Public Attributes

MoFEM::CorecOre
 
bool dEbug
 

Setting and shifting bits

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

Entity handlers by bit ref level

MoFEMErrorCode filterEntitiesByRefLevel (const BitRefLevel bit, const BitRefLevel mask, Range &ents, int verb=QUIET) const
 filter entities by bit ref level More...
 
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 More...
 
MoFEMErrorCode 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 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 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 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 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...
 
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 More...
 
MoFEMErrorCode getAllEntitiesNotInDatabase (Range &ents) const
 Get all entities not in database. More...
 
MoFEMErrorCode filterEntitiesNotInDatabase (Range &ents) const
 Get entities not in database. More...
 

Get adjacencies bit ref level

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. More...
 
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. More...
 
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. More...
 
virtual MoFEMErrorCode 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 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 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 updateFieldMeshsetByEntitiesChildren (const BitRefLevel &child_bit, int verb=0)
 update fields meshesets by child entities More...
 
MoFEMErrorCode updateFieldMeshsetByEntitiesChildren (const std::string name, const BitRefLevel &child_bit, int verb=0)
 update field meshset by child entities More...
 
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 More...
 
MoFEMErrorCode updateRangeByChildren (const Range &parent, Range &child, MoFEMTypes bh=MF_ZERO)
 Update range by childrens. More...
 
MoFEMErrorCode updateRangeByParent (const Range &child_ents, Range &parent_ents, MoFEMTypes bh=MF_ZERO)
 Update range by parents. More...
 
DEPRECATED MoFEMErrorCode updateRange (const Range &parent, Range &child, MoFEMTypes bh=MF_ZERO)
 

Writing files

MoFEMErrorCode writeBitLevel (const BitRefLevel bit, const BitRefLevel mask, const char *file_name, const char *file_type, const char *options, const bool check_for_empty=true) const
 Write bit ref level to file. More...
 
MoFEMErrorCode writeBitLevelByDim (const BitRefLevel bit, const BitRefLevel mask, const int dim, const char *file_name, const char *file_type, const char *options, const bool check_for_empty=true) const
 Write bit ref level to file. More...
 
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. More...
 
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. More...
 
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. More...
 
static MoFEMErrorCode fixTagSize (moab::Interface &moab, bool *changed=nullptr)
 Fix tag size when BITREFLEVEL_SIZE of core library is different than file BITREFLEVEL_SIZE. More...
 

Get tag handles to data on the mesh

Tag get_th_RefParentHandle () const
 
Tag get_th_RefBitLevel () const
 

Additional Inherited Members

- Static Public Member Functions inherited from MoFEM::UnknownInterface
static MoFEMErrorCode getLibVersion (Version &version)
 Get library version. More...
 
static MoFEMErrorCode getFileVersion (moab::Interface &moab, Version &version)
 Get database major version. More...
 
static MoFEMErrorCode setFileVersion (moab::Interface &moab, Version version=Version(MoFEM_VERSION_MAJOR, MoFEM_VERSION_MINOR, MoFEM_VERSION_BUILD))
 Get database major version. More...
 
static MoFEMErrorCode getInterfaceVersion (Version &version)
 Get database major version. More...
 

Detailed Description

Managing BitRefLevels.

Examples
bernstein_bezier_generate_base.cpp, build_large_problem.cpp, build_problems.cpp, child_and_parent.cpp, continuity_check_on_contact_prism_side_ele.cpp, continuity_check_on_skeleton_3d.cpp, dm_build_partitioned_mesh.cpp, dm_create_subdm.cpp, dm_partitioned_no_field.cpp, elasticity.cpp, elasticity_mixed_formulation.cpp, ep.cpp, field_blas.cpp, field_to_vertices.cpp, forces_and_sources_testing_edge_element.cpp, forces_and_sources_testing_flat_prism_element.cpp, forces_and_sources_testing_users_base.cpp, free_surface.cpp, hanging_node_approx.cpp, hcurl_divergence_operator_2d.cpp, level_set.cpp, mesh_cut.cpp, mesh_insert_interface_atom.cpp, mesh_smoothing.cpp, minimal_surface_area.cpp, navier_stokes.cpp, node_merge.cpp, nonlinear_dynamics.cpp, plot_base.cpp, prism_elements_from_surface.cpp, prism_polynomial_approximation.cpp, quad_polynomial_approximation.cpp, Remodeling.cpp, remove_entities_from_problem.cpp, remove_entities_from_problem_not_partitioned.cpp, simple_contact.cpp, simple_contact_thermal.cpp, split_sideset.cpp, test_jacobian_of_simple_contact_element.cpp, and unsaturated_transport.cpp.

Definition at line 21 of file BitRefManager.hpp.

Constructor & Destructor Documentation

◆ BitRefManager()

MoFEM::BitRefManager::BitRefManager ( const MoFEM::Core core)

Definition at line 16 of file BitRefManager.cpp.

17  : cOre(const_cast<MoFEM::Core &>(core)), dEbug(false) {
18 
19  if (!LogManager::checkIfChannelExist("BitRefSelf")) {
20  auto core_log = logging::core::get();
21  core_log->add_sink(
23  LogManager::setLog("BitRefSelf");
24  core_log->add_sink(
26  LogManager::setLog("BitRefWorld");
27  core_log->add_sink(
29  LogManager::setLog("BitRefSync");
30  MOFEM_LOG_TAG("BitRefSelf", "BitRefManager");
31  MOFEM_LOG_TAG("BitRefWorld", "BitRefManager");
32  MOFEM_LOG_TAG("BitRefSync", "BitRefManager");
33  }
34 
36  MOFEM_LOG("BitRefWorld", Sev::noisy) << "BitRefManager interface created";
37 }

◆ ~BitRefManager()

virtual MoFEM::BitRefManager::~BitRefManager ( )
virtualdefault

Destructor.

Member Function Documentation

◆ filterEntitiesByRefLevel()

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

filter entities by bit ref level

Parameters
bit
mask
ents
QUIET
Returns
MoFEMErrorCode
Examples
hanging_node_approx.cpp.

Definition at line 746 of file BitRefManager.cpp.

749  {
750  MoFEM::Interface &m_field = cOre;
751  moab::Interface &moab(m_field.get_moab());
753 
754  std::vector<EntityHandle> ents_vec;
755  ents_vec.reserve(ents.size());
756 
757  std::vector<BitRefLevel *> tags_bits_ptr_vec(ents.size());
758 
759  Range swap_ents;
760  auto hint = swap_ents.begin();
761 
762  for (Range::pair_iterator p_eit = ents.pair_begin(); p_eit != ents.pair_end();
763  ++p_eit) {
764 
765  EntityHandle f = p_eit->first;
766  const EntityHandle s = p_eit->second;
767 
768  // get bits on entities
769  rval = moab.tag_get_by_ptr(cOre.get_th_RefBitLevel(), Range(f, s),
770  (const void **)(&*tags_bits_ptr_vec.begin()));
771 
772  if (rval == MB_SUCCESS) {
773 
774  auto bit_it = tags_bits_ptr_vec.begin();
775 
776  auto check = [&bit, &mask](const auto &entity_bit) -> bool {
777  return
778 
779  (entity_bit & bit).any() &&
780 
781  ((entity_bit & mask) == entity_bit);
782  };
783 
784  while (f != s + 1) {
785 
786  while (f != s + 1 && !check(**bit_it)) {
787  ++bit_it;
788  ++f;
789  }
790 
791  if (f != s + 1) {
792 
793  const EntityHandle start = f;
794 
795  while (f != (s + 1) && check(**bit_it)) {
796  ++bit_it;
797  ++f;
798  };
799 
800  hint = swap_ents.insert(hint, start, f - 1);
801  }
802  }
803  }
804  }
805 
806  ents.swap(swap_ents);
807 
809 }

◆ filterEntitiesNotInDatabase()

MoFEMErrorCode MoFEM::BitRefManager::filterEntitiesNotInDatabase ( Range ents) const

Get entities not in database.

Parameters
ents
Returns
MoFEMErrorCode

Definition at line 908 of file BitRefManager.cpp.

908  {
909  MoFEM::Interface &m_field = cOre;
910  auto ref_ents_ptr = m_field.get_ref_ents();
912  auto eit = ents.begin();
913  for (; eit != ents.end();) {
914  auto rit = ref_ents_ptr->get<Ent_mi_tag>().find(*eit);
915  if (rit != ref_ents_ptr->get<Ent_mi_tag>().end()) {
916  eit = ents.erase(eit);
917  } else {
918  eit++;
919  }
920  }
922 }

◆ fixTagSize()

MoFEMErrorCode MoFEM::BitRefManager::fixTagSize ( moab::Interface &  moab,
bool changed = nullptr 
)
static

Fix tag size when BITREFLEVEL_SIZE of core library is different than file BITREFLEVEL_SIZE.

Returns
MoFEMErrorCode

Definition at line 1232 of file BitRefManager.cpp.

1232  {
1234  MOFEM_LOG_CHANNEL("WORLD");
1235 
1236  if (changes)
1237  *changes = false;
1238 
1239  if (Tag th = 0; moab.tag_get_handle("_RefBitLevel", th) == MB_SUCCESS) {
1240 
1241  MOFEM_TAG_AND_LOG("WORLD", Sev::verbose, "BitRefManager") << "Tag found";
1242 
1243  auto get_old_tag = [&](auto &&name) {
1244  Tag th;
1245  CHK_MOAB_THROW(moab.tag_get_handle(name, th),
1246  "bit ref level handle does not exist");
1247  return th;
1248  };
1249 
1250  auto get_new_tag = [&](auto &&name, auto &&def_val) {
1251  Tag th;
1252  CHK_MOAB_THROW(moab.tag_get_handle(
1253  name, sizeof(BitRefLevel), MB_TYPE_OPAQUE, th,
1254  MB_TAG_CREAT | MB_TAG_BYTES | MB_TAG_SPARSE, &def_val),
1255  "can not create tag");
1256  return th;
1257  };
1258 
1259  int length;
1260  CHKERR moab.tag_get_length(get_old_tag("_RefBitLevel"), length);
1261 
1262  if (sizeof(BitRefLevel) != length) {
1263 
1264  if(changes)
1265  *changes = true;
1266 
1267  MOFEM_TAG_AND_LOG("WORLD", Sev::verbose, "BitRefManager")
1268  << "Fixing tag length";
1269 
1270  Range all_ents;
1271  CHKERR moab.get_entities_by_type(0, MBENTITYSET, all_ents, true);
1272  CHKERR moab.get_entities_by_handle(0, all_ents, true);
1273 
1274  auto process_tag = [&](auto &&name, auto &&def_val) {
1276  auto tag_old = get_old_tag(name);
1277  auto get_bits = [&]() {
1278  std::vector<BitRefLevel> bits;
1279  bits.reserve(all_ents.size());
1280  auto it_bit = bits.begin();
1281  for (auto e : all_ents) {
1282  const void *data;
1283  int data_size;
1284  CHKERR moab.tag_get_by_ptr(tag_old, &e, 1, (const void **)&data,
1285  &data_size);
1286  bcopy(
1287  data, &*it_bit,
1288  std::min(sizeof(BitRefLevel), static_cast<size_t>(data_size)));
1289  ++it_bit;
1290  }
1291  return bits;
1292  };
1293  auto bits = get_bits();
1294  CHKERR moab.tag_delete(tag_old);
1295  auto tag_new = get_new_tag(name, def_val);
1296  auto it_bit = bits.begin();
1297  for (auto e : all_ents) {
1298  if (it_bit->any()) {
1299  CHKERR moab.tag_set_data(tag_new, &e, 1, &*it_bit);
1300  }
1301  ++it_bit;
1302  }
1304  };
1305 
1306  CHKERR process_tag("_RefBitLevel", BitRefLevel() = 0);
1307  CHKERR process_tag("_RefBitLevelMask", BitRefLevel().set());
1308  }
1309  }
1310 
1311  MOFEM_LOG_CHANNEL("WORLD");
1313 }

◆ get_th_RefBitLevel()

Tag MoFEM::BitRefManager::get_th_RefBitLevel ( ) const
inline

Definition at line 709 of file BitRefManager.hpp.

709 { return cOre.get_th_RefBitLevel(); }

◆ get_th_RefParentHandle()

Tag MoFEM::BitRefManager::get_th_RefParentHandle ( ) const
inline

Definition at line 706 of file BitRefManager.hpp.

706  {
707  return cOre.get_th_RefParentHandle();
708  }

◆ getAllEntitiesNotInDatabase()

MoFEMErrorCode MoFEM::BitRefManager::getAllEntitiesNotInDatabase ( Range ents) const

Get all entities not in database.

Parameters
ents
Returns
MoFEMErrorCode

Definition at line 898 of file BitRefManager.cpp.

898  {
899  MoFEM::Interface &m_field = cOre;
900  moab::Interface &moab = m_field.get_moab();
902  CHKERR moab.get_entities_by_handle(0, ents, false);
903  ents = subtract(ents, ents.subset_by_type(MBENTITYSET));
906 }

◆ getEntitiesByParentType()

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

Note
Entities have to be added to MoFEM database
Parameters
BitRefLevelbitLevel
BitRefLevelmask
typeof parent
entsreturned ents
Returns
error code

Definition at line 873 of file BitRefManager.cpp.

877  {
878  MoFEM::Interface &m_field = cOre;
879  auto ref_ents_ptr = m_field.get_ref_ents();
881  auto &ref_ents = ref_ents_ptr->get<Ent_Ent_mi_tag>();
882  auto it = ref_ents.lower_bound(get_id_for_min_type(type));
883  auto hi_it = ref_ents.upper_bound(get_id_for_max_type(type));
884  std::vector<EntityHandle> ents_vec;
885  ents_vec.reserve(std::distance(it, hi_it));
886  for (; it != hi_it; it++) {
887  const BitRefLevel &ent_bit = it->get()->getBitRefLevel();
888  if ((ent_bit & mask) == ent_bit && (ent_bit & bit).any())
889  ents_vec.emplace_back(it->get()->getEnt());
890  }
891  ents.insert_list(ents_vec.begin(), ents_vec.end());
892  if (verb > NOISY)
893  MOFEM_LOG("BitRefSelf", Sev::noisy)
894  << "getEntitiesByParentType: " << ents << endl;
896 }

◆ query_interface()

MoFEMErrorCode MoFEM::BitRefManager::query_interface ( boost::typeindex::type_index  type_index,
UnknownInterface **  iface 
) const
virtual

Implements MoFEM::UnknownInterface.

Definition at line 9 of file BitRefManager.cpp.

10  {
12  *iface = const_cast<BitRefManager *>(this);
14 }

◆ writeBitLevel()

MoFEMErrorCode MoFEM::BitRefManager::writeBitLevel ( const BitRefLevel  bit,
const BitRefLevel  mask,
const char *  file_name,
const char *  file_type,
const char *  options,
const bool  check_for_empty = true 
) const

Write bit ref level to file.

Parameters
bitbit ref level
maskmask of bit ref level
dimdimension
file_namefile name (see moab documentation)
file_typefile type (see moab documentation)
optionsfile options (see moab documentation)
Returns
error code

Definition at line 634 of file BitRefManager.cpp.

639  {
640  MoFEM::Interface &m_field = cOre;
641  moab::Interface &moab(m_field.get_moab());
643  EntityHandle meshset;
644  CHKERR moab.create_meshset(MESHSET_SET, meshset);
645  CHKERR getEntitiesByRefLevel(bit, mask, meshset);
646  int nb_ents;
647  CHKERR moab.get_number_entities_by_handle(meshset, nb_ents, true);
648  if (check_for_empty && !nb_ents) {
649  MOFEM_LOG("SELF", Sev::warning)
650  << "No entities to save < " << file_name << " > in writeBitLevel";
652  }
653 
654  CHKERR moab.write_file(file_name, file_type, options, &meshset, 1);
655  CHKERR moab.delete_entities(&meshset, 1);
657 }

◆ writeBitLevelByDim()

MoFEMErrorCode MoFEM::BitRefManager::writeBitLevelByDim ( const BitRefLevel  bit,
const BitRefLevel  mask,
const int  dim,
const char *  file_name,
const char *  file_type,
const char *  options,
const bool  check_for_empty = true 
) const

Write bit ref level to file.

Parameters
bitbit ref level
maskmask of bit ref level
dimdimension
file_namefile name (see moab documentation)
file_typefile type (see moab documentation)
optionsfile options (see moab documentation)
Returns
error code
Examples
hanging_node_approx.cpp.

Definition at line 660 of file BitRefManager.cpp.

663  {
664  MoFEM::Interface &m_field = cOre;
665  moab::Interface &moab(m_field.get_moab());
667  Range ents;
668  CHKERR getEntitiesByDimAndRefLevel(bit, mask, dim, ents);
669  if (check_for_empty && ents.empty()) {
670  MOFEM_LOG("SELF", Sev::warning)
671  << "No entities to save < " << file_name << " > in writeBitLevelByDim";
673  }
674  EntityHandle meshset;
675  CHKERR moab.create_meshset(MESHSET_SET, meshset);
676  CHKERR moab.add_entities(meshset, ents);
677  CHKERR moab.write_file(file_name, file_type, options, &meshset, 1);
678  CHKERR moab.delete_entities(&meshset, 1);
680 }

◆ writeBitLevelByType()

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

Parameters
bitbit ref level
maskmask of bit ref level
typetype of entity
file_namefile name (see moab documentation)
file_typefile type (see moab documentation)
optionsfile options (see moab documentation)
Returns
error code

Definition at line 682 of file BitRefManager.cpp.

685  {
686  MoFEM::Interface &m_field = cOre;
687  moab::Interface &moab(m_field.get_moab());
689  Range ents;
691  if (check_for_empty && ents.empty()) {
692  MOFEM_LOG("SELF", Sev::warning)
693  << "No entities to save < " << file_name << " > in writeBitLevelByType";
695  }
696  EntityHandle meshset;
697  CHKERR moab.create_meshset(MESHSET_SET, meshset);
698  CHKERR moab.add_entities(meshset, ents);
699  CHKERR moab.write_file(file_name, file_type, options, &meshset, 1);
700  CHKERR moab.delete_entities(&meshset, 1);
702 }

◆ writeEntitiesAllBitLevelsByType()

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

Parameters
mask
type
file_name
file_type
options
Returns
MoFEMErrorCode

Definition at line 722 of file BitRefManager.cpp.

724  {
726  for (int ll = 0; ll != BITREFLEVEL_SIZE; ++ll) {
727  std::string name = boost::lexical_cast<std::string>(ll) + "_" + file_name;
728  CHKERR writeBitLevelByType(BitRefLevel().set(ll), mask, type, name.c_str(),
729  file_type, options, true);
730  }
732 }

◆ writeEntitiesNotInDatabase()

MoFEMErrorCode MoFEM::BitRefManager::writeEntitiesNotInDatabase ( const char *  file_name,
const char *  file_type,
const char *  options,
const bool  check_for_empty = true 
) const

Write ents not in database.

Parameters
file_name
file_typefor example "VTK"
options
check_for_empty
Returns
MoFEMErrorCode

Definition at line 704 of file BitRefManager.cpp.

706  {
707  MoFEM::Interface &m_field = cOre;
708  moab::Interface &moab(m_field.get_moab());
710  EntityHandle meshset;
711  Range ents;
713  if (check_for_empty && ents.empty())
715  CHKERR moab.create_meshset(MESHSET_SET, meshset);
716  CHKERR moab.add_entities(meshset, ents);
717  CHKERR moab.write_file(file_name, file_type, options, &meshset, 1);
718  CHKERR moab.delete_entities(&meshset, 1);
720 }

Member Data Documentation

◆ cOre

MoFEM::Core& MoFEM::BitRefManager::cOre

Definition at line 26 of file BitRefManager.hpp.

◆ dEbug

bool MoFEM::BitRefManager::dEbug

Definition at line 27 of file BitRefManager.hpp.


The documentation for this struct was generated from the following files:
MoFEMFunctionReturnHot
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:447
CHK_MOAB_THROW
#define CHK_MOAB_THROW(err, msg)
Check error code of MoAB function and throw MoFEM exception.
Definition: definitions.h:576
MoFEM::LogManager::checkIfChannelExist
static bool checkIfChannelExist(const std::string channel)
Check if channel exist.
Definition: LogManager.cpp:404
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::CoreTmp< 0 >
Core (interface) class.
Definition: Core.hpp:82
MOFEM_LOG_CHANNEL
#define MOFEM_LOG_CHANNEL(channel)
Set and reset channel.
Definition: LogManager.hpp:284
EntityHandle
NOISY
@ NOISY
Definition: definitions.h:211
MoFEM::BitRefManager::dEbug
bool dEbug
Definition: BitRefManager.hpp:27
MoFEM::BitRefManager::filterEntitiesNotInDatabase
MoFEMErrorCode filterEntitiesNotInDatabase(Range &ents) const
Get entities not in database.
Definition: BitRefManager.cpp:908
MoFEM::th
Tag th
Definition: Projection10NodeCoordsOnField.cpp:122
MoFEM::BitRefManager::cOre
MoFEM::Core & cOre
Definition: BitRefManager.hpp:26
MoFEM::LogManager::createSink
static boost::shared_ptr< SinkType > createSink(boost::shared_ptr< std::ostream > stream_ptr, std::string comm_filter)
Create a sink object.
Definition: LogManager.cpp:298
MoFEM::DeprecatedCoreInterface
Deprecated interface functions.
Definition: DeprecatedCoreInterface.hpp:16
MoFEM::Interface
DeprecatedCoreInterface Interface
Definition: Interface.hpp:1975
MOFEM_LOG_FUNCTION
#define MOFEM_LOG_FUNCTION()
Set scope.
Definition: LogManager.hpp:325
MoFEM::Exceptions::rval
static MoFEMErrorCodeGeneric< moab::ErrorCode > rval
Definition: Exceptions.hpp:74
CHKERR
#define CHKERR
Inline error check.
Definition: definitions.h:535
MoFEM::CoreInterface::get_moab
virtual moab::Interface & get_moab()=0
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
bit
auto bit
set bit
Definition: hanging_node_approx.cpp:75
convert.type
type
Definition: convert.py:64
MoFEM::CoreTmp< 0 >::get_th_RefParentHandle
Tag get_th_RefParentHandle() const
Definition: Core.hpp:197
MoFEM::LogManager::getStrmSync
static boost::shared_ptr< std::ostream > getStrmSync()
Get the strm sync object.
Definition: LogManager.cpp:348
MoFEM::CoreTmp< 0 >::get_th_RefBitLevel
Tag get_th_RefBitLevel() const
Definition: Core.hpp:198
MoFEM::LogManager::getStrmWorld
static boost::shared_ptr< std::ostream > getStrmWorld()
Get the strm world object.
Definition: LogManager.cpp:344
MoFEM::get_id_for_max_type
EntityHandle get_id_for_max_type()
Definition: RefEntsMultiIndices.hpp:13
MoFEM::LogManager::getStrmSelf
static boost::shared_ptr< std::ostream > getStrmSelf()
Get the strm self object.
Definition: LogManager.cpp:340
MoFEM::BitRefManager::BitRefManager
BitRefManager(const MoFEM::Core &core)
Definition: BitRefManager.cpp:16
MOFEM_LOG_TAG
#define MOFEM_LOG_TAG(channel, tag)
Tag channel.
Definition: LogManager.hpp:339
Range
MOFEM_TAG_AND_LOG
#define MOFEM_TAG_AND_LOG(channel, severity, tag)
Tag and log in channel.
Definition: LogManager.hpp:362
MOFEM_LOG
#define MOFEM_LOG(channel, severity)
Log.
Definition: LogManager.hpp:308
HenckyOps::f
auto f
Definition: HenckyOps.hpp:15
BITREFLEVEL_SIZE
#define BITREFLEVEL_SIZE
max number of refinements
Definition: definitions.h:219
MoFEM::BitRefManager::writeBitLevelByType
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.
Definition: BitRefManager.cpp:682
MoFEM::CoreInterface::get_ref_ents
virtual const RefEntity_multiIndex * get_ref_ents() const =0
Get the ref ents object.
MoFEM::Types::BitRefLevel
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
Definition: Types.hpp:40
MoFEMFunctionBeginHot
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:440
MoFEM::LogManager::setLog
static LoggerType & setLog(const std::string channel)
Set ans resset chanel logger.
Definition: LogManager.cpp:389
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
MoFEM::get_id_for_min_type
EntityHandle get_id_for_min_type()
Definition: RefEntsMultiIndices.hpp:18
MoFEM::BitRefManager::getAllEntitiesNotInDatabase
MoFEMErrorCode getAllEntitiesNotInDatabase(Range &ents) const
Get all entities not in database.
Definition: BitRefManager.cpp:898
MoFEMFunctionReturn
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:416
MoFEMFunctionBegin
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:346