v0.14.0
add_blockset.cpp

Create blockset and add entities. Next check if entities are in the blockset.

/**
* \file add_blockset.cpp
* \example add_blockset.cpp
*
* Create blockset and add entities. Next check if entities are in the blockset.
*
*/
#include <MoFEM.hpp>
using namespace MoFEM;
static char help[] = "...\n\n";
int main(int argc, char *argv[]) {
MoFEM::Core::Initialize(&argc, &argv, (char *)0, help);
try {
moab::Core mb_instance;
moab::Interface &moab = mb_instance;
// Create MoFEM instance
MoFEM::Core core(moab);
MoFEM::Interface &m_field = core;
const char *option = "";
CHKERR moab.load_file("rectangle_tri.h5m", 0, option);
auto meshsets_mng = m_field.getInterface<MeshsetsManager>();
auto get_ents_on_mesh_skin = [&]() {
Range faces;
CHKERR m_field.get_moab().get_entities_by_type(0, MBTRI, faces);
Skinner skin(&m_field.get_moab());
Range skin_edges;
CHKERR skin.find_skin(0, faces, false, skin_edges);
Range skin_verts;
CHKERR moab.get_connectivity(skin_edges, skin_verts, true);
skin_edges.merge(skin_verts);
return skin_edges;
};
auto add_blockset = [&](const Range skin_ents) {
CHKERR meshsets_mng->addMeshset(BLOCKSET, 1);
CHKERR meshsets_mng->addEntitiesToMeshset(BLOCKSET, 1, skin_ents);
};
auto print_blocksets = [&]() {
for (auto &it : meshsets_mng->getMeshsetsMultindex())
cout << it << endl;
};
auto check_meshset = [&](const Range skin_ents) {
std::vector<EntityHandle> ents(skin_ents.size());
std::copy(skin_ents.begin(), skin_ents.end(), ents.begin());
const bool test = meshsets_mng->checkIfMeshsetContainsEntities(
1, BLOCKSET, &*ents.begin(), ents.size());
if (!test)
SETERRQ(PETSC_COMM_SELF, MOFEM_ATOM_TEST_INVALID,
"All entities should be in blockset");
};
auto skin_ents = get_ents_on_mesh_skin();
CHKERR add_blockset(skin_ents);
CHKERR print_blocksets();
CHKERR check_meshset(skin_ents);
}
}
MoFEM::UnknownInterface::getInterface
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.
Definition: UnknownInterface.hpp:93
MoFEM::CoreTmp< 0 >
Core (interface) class.
Definition: Core.hpp:82
MoFEM.hpp
MoFEM::CoreTmp< 0 >::Finalize
static MoFEMErrorCode Finalize()
Checks for options to be called at the conclusion of the program.
Definition: Core.cpp:112
MoFEM::DeprecatedCoreInterface
Deprecated interface functions.
Definition: DeprecatedCoreInterface.hpp:16
MoFEM::Interface
DeprecatedCoreInterface Interface
Definition: Interface.hpp:2010
CHKERR
#define CHKERR
Inline error check.
Definition: definitions.h:548
MoFEM::CoreInterface::get_moab
virtual moab::Interface & get_moab()=0
MoFEM
implementation of Data Operators for Forces and Sources
Definition: Common.hpp:10
Range
help
static char help[]
Definition: add_blockset.cpp:13
MoFEM::CoreTmp< 0 >::Initialize
static MoFEMErrorCode Initialize(int *argc, char ***args, const char file[], const char help[])
Initializes the MoFEM database PETSc, MOAB and MPI.
Definition: Core.cpp:72
CATCH_ERRORS
#define CATCH_ERRORS
Catch errors.
Definition: definitions.h:385
MoFEM::Core
CoreTmp< 0 > Core
Definition: Core.hpp:1148
BLOCKSET
@ BLOCKSET
Definition: definitions.h:161
MoFEM::MeshsetsManager
Interface for managing meshsets containing materials and boundary conditions.
Definition: MeshsetsManager.hpp:104
MOFEM_ATOM_TEST_INVALID
@ MOFEM_ATOM_TEST_INVALID
Definition: definitions.h:40
main
int main(int argc, char *argv[])
Definition: add_blockset.cpp:15
MoFEMFunctionReturn
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:429
MoFEMFunctionBegin
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:359