v0.15.0
Loading...
Searching...
No Matches
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.
 
- Public Member Functions inherited from MoFEM::UnknownInterface
template<class IFACE >
MoFEMErrorCode registerInterface (bool error_if_registration_failed=true)
 Register interface.
 
template<class IFACE >
MoFEMErrorCode getInterface (IFACE *&iface) const
 Get interface reference to pointer of interface.
 
template<class IFACE >
MoFEMErrorCode getInterface (IFACE **const iface) const
 Get interface pointer to pointer of interface.
 
template<class IFACE , typename boost::enable_if< boost::is_pointer< IFACE >, int >::type = 0>
IFACE getInterface () const
 Get interface pointer to pointer of interface.
 
template<class IFACE , typename boost::enable_if< boost::is_reference< IFACE >, int >::type = 0>
IFACE getInterface () const
 Get reference to interface.
 
template<class IFACE >
IFACE * getInterface () const
 Function returning pointer to interface.
 
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
 
MoFEMErrorCode setElementsBitRefLevel (const Range &ents, const BitRefLevel bit=BitRefLevel(), int verb=QUIET) const
 add entities to database and set bit ref level
 
MoFEMErrorCode setEntitiesBitRefLevel (const Range &ents, const BitRefLevel bit=BitRefLevel(), int verb=QUIET) const
 add entities to database and set bit ref level
 
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 setBitRefLevelByDim (const EntityHandle meshset, const int dim, const BitRefLevel bit, int verb=QUIET) const
 Set the Bit Ref Level By Dim object.
 
MoFEMErrorCode setBitRefLevelByType (const EntityHandle meshset, const EntityType type, const BitRefLevel bit, int verb=QUIET) const
 Set the Bit Ref Level By Type object.
 
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.
 
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.
 
MoFEMErrorCode lambdaBitRefLevel (boost::function< void(EntityHandle ent, BitRefLevel &bit)> fun) const
 Process bit ref level by lambda function.
 
MoFEMErrorCode lambdaBitRefLevel (const Range &ents, boost::function< void(EntityHandle ent, BitRefLevel &bit)> fun) const
 Process bit ref level by lambda function.
 
MoFEMErrorCode addBitRefLevel (const Range &ents, const BitRefLevel &bit, int verb=QUIET) const
 add bit ref level to ref entity
 
MoFEMErrorCode addBitRefLevelByDim (const EntityHandle meshset, const int dim, const BitRefLevel bit, int verb=QUIET) const
 add bit ref level by dimension
 
MoFEMErrorCode setNthBitRefLevel (const Range &ents, const int n, const bool b, int verb=QUIET) const
 Set nth bit ref level.
 
MoFEMErrorCode setNthBitRefLevel (const int n, const bool b, int verb=QUIET) const
 Set nth bit ref level to all entities in database.
 
MoFEMErrorCode shiftLeftBitRef (const int shift, const BitRefLevel mask=BitRefLevel().set(), int verb=DEFAULT_VERBOSITY) const
 left shift bit ref levelthis results of deletion of entities on far left side
 
MoFEMErrorCode shiftRightBitRef (const int shift, const BitRefLevel mask=BitRefLevel().set(), int verb=DEFAULT_VERBOSITY, MoFEMTypes mf=MF_ZERO) const
 right shift bit ref level
 

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
 
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
 
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
 
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
 
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
 
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
 
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
 
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
 
MoFEMErrorCode getAllEntitiesNotInDatabase (Range &ents) const
 Get all entities not in database.
 
MoFEMErrorCode filterEntitiesNotInDatabase (Range &ents) const
 Get entities not in database.
 

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.
 
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.
 
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.
 
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.
 

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

Get tag handles to data on the mesh

Tag get_th_RefParentHandle () const
 
Tag get_th_RefBitLevel () const
 
static MoFEMErrorCode fixTagSize (moab::Interface &moab, bool *changed=nullptr)
 Fix tag size when BITREFLEVEL_SIZE of core library is different than file BITREFLEVEL_SIZE.
 

Additional Inherited Members

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

Detailed Description

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}
static LoggerType & setLog(const std::string channel)
Set ans resset chanel logger.
#define MOFEM_LOG(channel, severity)
Log.
#define MOFEM_LOG_TAG(channel, tag)
Tag channel.
#define MOFEM_LOG_FUNCTION()
Set scope.
Core (interface) class.
Definition Core.hpp:82
static boost::shared_ptr< SinkType > createSink(boost::shared_ptr< std::ostream > stream_ptr, std::string comm_filter)
Create a sink object.
static boost::shared_ptr< std::ostream > getStrmWorld()
Get the strm world object.
static boost::shared_ptr< std::ostream > getStrmSync()
Get the strm sync object.
static bool checkIfChannelExist(const std::string channel)
Check if channel exist.
static boost::shared_ptr< std::ostream > getStrmSelf()
Get the strm self object.

◆ ~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 747 of file BitRefManager.cpp.

750 {
751 MoFEM::Interface &m_field = cOre;
752 moab::Interface &moab(m_field.get_moab());
754
755 std::vector<EntityHandle> ents_vec;
756 ents_vec.reserve(ents.size());
757
758 std::vector<BitRefLevel *> tags_bits_ptr_vec(ents.size());
759
760 Range swap_ents;
761 auto hint = swap_ents.begin();
762
763 for (Range::pair_iterator p_eit = ents.pair_begin(); p_eit != ents.pair_end();
764 ++p_eit) {
765
766 EntityHandle f = p_eit->first;
767 const EntityHandle s = p_eit->second;
768
769 // get bits on entities
770 rval = moab.tag_get_by_ptr(cOre.get_th_RefBitLevel(), Range(f, s),
771 (const void **)(&*tags_bits_ptr_vec.begin()));
772
773 if (rval == MB_SUCCESS) {
774
775 auto bit_it = tags_bits_ptr_vec.begin();
776
777 auto check = [&bit, &mask](const auto &entity_bit) -> bool {
778 return
779
780 (entity_bit & bit).any() &&
781
782 ((entity_bit & mask) == entity_bit);
783 };
784
785 while (f != s + 1) {
786
787 while (f != s + 1 && !check(**bit_it)) {
788 ++bit_it;
789 ++f;
790 }
791
792 if (f != s + 1) {
793
794 const EntityHandle start = f;
795
796 while (f != (s + 1) && check(**bit_it)) {
797 ++bit_it;
798 ++f;
799 };
800
801 hint = swap_ents.insert(hint, start, f - 1);
802 }
803 }
804 }
805 }
806
807 ents.swap(swap_ents);
808
810}
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
auto bit
set bit
static MoFEMErrorCodeGeneric< moab::ErrorCode > rval
virtual moab::Interface & get_moab()=0
Tag get_th_RefBitLevel() const
Definition Core.hpp:198
Deprecated interface functions.

◆ filterEntitiesNotInDatabase()

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

Get entities not in database.

Parameters
ents
Returns
MoFEMErrorCode

Definition at line 909 of file BitRefManager.cpp.

909 {
910 MoFEM::Interface &m_field = cOre;
911 auto ref_ents_ptr = m_field.get_ref_ents();
913 auto eit = ents.begin();
914 for (; eit != ents.end();) {
915 auto rit = ref_ents_ptr->get<Ent_mi_tag>().find(*eit);
916 if (rit != ref_ents_ptr->get<Ent_mi_tag>().end()) {
917 eit = ents.erase(eit);
918 } else {
919 eit++;
920 }
921 }
923}
virtual const RefEntity_multiIndex * get_ref_ents() const =0
Get the ref ents object.

◆ 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 1233 of file BitRefManager.cpp.

1233 {
1235 MOFEM_LOG_CHANNEL("WORLD");
1236
1237 if (changes)
1238 *changes = false;
1239
1240 if (Tag th = 0; moab.tag_get_handle("_RefBitLevel", th) == MB_SUCCESS) {
1241
1242 MOFEM_TAG_AND_LOG("WORLD", Sev::verbose, "BitRefManager") << "Tag found";
1243
1244 auto get_old_tag = [&](auto &&name) {
1245 Tag th;
1246 CHK_MOAB_THROW(moab.tag_get_handle(name, th),
1247 "bit ref level handle does not exist");
1248 return th;
1249 };
1250
1251 auto get_new_tag = [&](auto &&name, auto &&def_val) {
1252 Tag th;
1253 CHK_MOAB_THROW(moab.tag_get_handle(
1254 name, sizeof(BitRefLevel), MB_TYPE_OPAQUE, th,
1255 MB_TAG_CREAT | MB_TAG_BYTES | MB_TAG_SPARSE, &def_val),
1256 "can not create tag");
1257 return th;
1258 };
1259
1260 int length;
1261 CHKERR moab.tag_get_length(get_old_tag("_RefBitLevel"), length);
1262
1263 if (sizeof(BitRefLevel) != length) {
1264
1265 if(changes)
1266 *changes = true;
1267
1268 MOFEM_TAG_AND_LOG("WORLD", Sev::verbose, "BitRefManager")
1269 << "Fixing tag length";
1270
1271 Range all_ents;
1272 CHKERR moab.get_entities_by_type(0, MBENTITYSET, all_ents, true);
1273 CHKERR moab.get_entities_by_handle(0, all_ents, true);
1274
1275 auto process_tag = [&](auto &&name, auto &&def_val) {
1277 auto tag_old = get_old_tag(name);
1278 auto get_bits = [&]() {
1279 std::vector<BitRefLevel> bits;
1280 bits.reserve(all_ents.size());
1281 auto it_bit = bits.begin();
1282 for (auto e : all_ents) {
1283 const void *data;
1284 int data_size;
1285 CHKERR moab.tag_get_by_ptr(tag_old, &e, 1, (const void **)&data,
1286 &data_size);
1287 bcopy(
1288 data, &*it_bit,
1289 std::min(sizeof(BitRefLevel), static_cast<size_t>(data_size)));
1290 ++it_bit;
1291 }
1292 return bits;
1293 };
1294 auto bits = get_bits();
1295 CHKERR moab.tag_delete(tag_old);
1296 auto tag_new = get_new_tag(name, def_val);
1297 auto it_bit = bits.begin();
1298 for (auto e : all_ents) {
1299 if (it_bit->any()) {
1300 CHKERR moab.tag_set_data(tag_new, &e, 1, &*it_bit);
1301 }
1302 ++it_bit;
1303 }
1305 };
1306
1307 CHKERR process_tag("_RefBitLevel", BitRefLevel() = 0);
1308 CHKERR process_tag("_RefBitLevelMask", BitRefLevel().set());
1309 }
1310 }
1311
1312 MOFEM_LOG_CHANNEL("WORLD");
1314}
#define MOFEM_TAG_AND_LOG(channel, severity, tag)
Tag and log in channel.
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
#define CHK_MOAB_THROW(err, msg)
Check error code of MoAB function and throw MoFEM exception.
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.
#define MOFEM_LOG_CHANNEL(channel)
Set and reset channel.
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
Definition Types.hpp:40

◆ 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 {
708 }
Tag get_th_RefParentHandle() const
Definition Core.hpp:197

◆ getAllEntitiesNotInDatabase()

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

Get all entities not in database.

Parameters
ents
Returns
MoFEMErrorCode

Definition at line 899 of file BitRefManager.cpp.

899 {
900 MoFEM::Interface &m_field = cOre;
901 moab::Interface &moab = m_field.get_moab();
903 CHKERR moab.get_entities_by_handle(0, ents, false);
904 ents = subtract(ents, ents.subset_by_type(MBENTITYSET));
907}
MoFEMErrorCode filterEntitiesNotInDatabase(Range &ents) const
Get entities not in database.

◆ 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 874 of file BitRefManager.cpp.

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

◆ 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}
BitRefManager(const MoFEM::Core &core)

◆ 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 635 of file BitRefManager.cpp.

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

◆ 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 661 of file BitRefManager.cpp.

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

◆ 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 683 of file BitRefManager.cpp.

686 {
687 MoFEM::Interface &m_field = cOre;
688 moab::Interface &moab(m_field.get_moab());
690 Range ents;
691 CHKERR getEntitiesByTypeAndRefLevel(bit, mask, type, ents);
692 if (check_for_empty && ents.empty()) {
693 MOFEM_LOG("SELF", Sev::warning)
694 << "No entities to save < " << file_name << " > in writeBitLevelByType";
696 }
697 EntityHandle meshset;
698 CHKERR moab.create_meshset(MESHSET_SET, meshset);
699 CHKERR moab.add_entities(meshset, ents);
700 CHKERR moab.write_file(file_name, file_type, options, &meshset, 1);
701 CHKERR moab.delete_entities(&meshset, 1);
703}
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

◆ 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 723 of file BitRefManager.cpp.

725 {
727 for (int ll = 0; ll != BITREFLEVEL_SIZE; ++ll) {
728 std::string name = boost::lexical_cast<std::string>(ll) + "_" + file_name;
729 CHKERR writeBitLevelByType(BitRefLevel().set(ll), mask, type, name.c_str(),
730 file_type, options, true);
731 }
733}
#define BITREFLEVEL_SIZE
max number of refinements
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.

◆ 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 705 of file BitRefManager.cpp.

707 {
708 MoFEM::Interface &m_field = cOre;
709 moab::Interface &moab(m_field.get_moab());
711 EntityHandle meshset;
712 Range ents;
714 if (check_for_empty && ents.empty())
716 CHKERR moab.create_meshset(MESHSET_SET, meshset);
717 CHKERR moab.add_entities(meshset, ents);
718 CHKERR moab.write_file(file_name, file_type, options, &meshset, 1);
719 CHKERR moab.delete_entities(&meshset, 1);
721}
MoFEMErrorCode getAllEntitiesNotInDatabase(Range &ents) const
Get all entities not in database.

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: