v0.14.0
simple_l2_only.cpp

Test iterating over boundary and skeleton elements only when L2 field is presents on the domain.

/**
* \file simple_l2_only.cpp
* \ingroup mofem_simple_interface
* \example simple_l2_only.cpp
*
* Test iterating over boundary and skeleton elements only when L2 field is
* presents on the domain.
*
*/
#include <MoFEM.hpp>
using namespace MoFEM;
static char help[] = "...\n\n";
constexpr int SPACE_DIM = 2;
template <int DIM> struct ElementsAndOps {};
template <> struct ElementsAndOps<2> {
};
int main(int argc, char *argv[]) {
// initialize petsc
MoFEM::Core::Initialize(&argc, &argv, (char *)0, help);
try {
// Create MoAB database
moab::Core moab_core;
moab::Interface &moab = moab_core;
// Create MoFEM database and link it to MoAB
MoFEM::Core mofem_core(moab);
MoFEM::Interface &m_field = mofem_core;
// Register DM Manager
DMType dm_name = "DMMOFEM";
// Simple interface
Simple *simple_interface;
CHKERR m_field.getInterface(simple_interface);
{
// get options from command line
CHKERR simple_interface->getOptions();
// load mesh file
CHKERR simple_interface->loadFile();
CHKERR simple_interface->addDomainField("FIELD", L2,
simple_interface->getAddBoundaryFE() = true;
simple_interface->getAddSkeletonFE() = true;
// set fields order
CHKERR simple_interface->setFieldOrder("FIELD", 1);
// setup problem
CHKERR simple_interface->setUp();
int count_fe;
int count_side_fe;
PipelineManager *pipeline_mng = m_field.getInterface<PipelineManager>();
// Create OP for side FE
auto op_side_fe = new DomainEleOp(NOSPACE, DomainEleOp::OPSPACE);
op_side_fe->doWorkRhsHook = [&](DataOperator *op_ptr, int side,
EntityType type,
auto domain_op = static_cast<DomainEleOp *>(op_ptr);
MOFEM_LOG("SELF", Sev::verbose)
<< "Side element name [ " << count_side_fe << " ] "
<< domain_op->getFEName();
++count_side_fe;
};
// Create side FE
auto side_fe = boost::make_shared<DomainEle>(m_field);
side_fe->getOpPtrVector().push_back(op_side_fe);
// Create boundary FE OP
auto do_work_rhs = [&](DataOperator *op_ptr, int side, EntityType type,
auto bdy_op = static_cast<BoundaryEleOp *>(op_ptr);
MOFEM_LOG("SELF", Sev::verbose) << "Element name [ " << count_fe
<< " ] " << bdy_op->getFEName();
CHKERR bdy_op->loopSide(simple_interface->getDomainFEName(),
side_fe.get(), SPACE_DIM);
++count_fe;
};
auto op_bdy_fe = new BoundaryEleOp(NOSPACE, DomainEleOp::OPSPACE);
op_bdy_fe->doWorkRhsHook = do_work_rhs;
auto op_skeleton_fe = new BoundaryEleOp(NOSPACE, DomainEleOp::OPSPACE);
op_skeleton_fe->doWorkRhsHook = do_work_rhs;
// Count boundary
count_fe = 0;
count_side_fe = 0;
pipeline_mng->getOpBoundaryRhsPipeline().push_back(op_bdy_fe);
pipeline_mng->getOpSkeletonRhsPipeline().push_back(op_skeleton_fe);
pipeline_mng->loopFiniteElements();
MOFEM_LOG("SELF", Sev::inform) << "Number of elements " << count_fe;
MOFEM_LOG("SELF", Sev::inform)
<< "Number of side elements " << count_side_fe;
if (count_fe != 16)
SETERRQ(PETSC_COMM_SELF, MOFEM_ATOM_TEST_INVALID,
"Wrong numbers of FEs");
if (count_side_fe != 24)
SETERRQ(PETSC_COMM_SELF, MOFEM_ATOM_TEST_INVALID,
"Wrong numbers of side FEs");
}
}
// finish work cleaning memory, getting statistics, etc.
return 0;
}
NOSPACE
@ NOSPACE
Definition: definitions.h:83
MoFEM::UnknownInterface::getInterface
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface refernce to pointer of interface.
Definition: UnknownInterface.hpp:93
MoFEM::EntitiesFieldData::EntData
Data on single entity (This is passed as argument to DataOperator::doWork)
Definition: EntitiesFieldData.hpp:127
BoundaryEle
ElementsAndOps< SPACE_DIM >::BoundaryEle BoundaryEle
Definition: child_and_parent.cpp:39
MoFEM::CoreTmp< 0 >
Core (interface) class.
Definition: Core.hpp:82
MoFEM::DataOperator
base operator to do operations at Gauss Pt. level
Definition: DataOperators.hpp:24
MoFEM::PipelineManager::getOpSkeletonRhsPipeline
boost::ptr_deque< UserDataOperator > & getOpSkeletonRhsPipeline()
Get the Op Skeleton Rhs Pipeline object.
Definition: PipelineManager.hpp:869
BoundaryEleOp
BoundaryEle::UserDataOperator BoundaryEleOp
Definition: simple_l2_only.cpp:32
L2
@ L2
field with C-1 continuity
Definition: definitions.h:88
MoFEM::PipelineManager::loopFiniteElements
MoFEMErrorCode loopFiniteElements(SmartPetscObj< DM > dm=nullptr)
Iterate finite elements.
Definition: PipelineManager.cpp:19
help
static char help[]
Definition: simple_l2_only.cpp:16
MoFEM::Simple::loadFile
MoFEMErrorCode loadFile(const std::string options, const std::string mesh_file_name, LoadFileFunc loadFunc=defaultLoadFileFunc)
Load mesh file.
Definition: Simple.cpp:194
MoFEM::PipelineManager
PipelineManager interface.
Definition: PipelineManager.hpp:24
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::Simple
Simple interface for fast problem set-up.
Definition: Simple.hpp:27
MoFEM::DeprecatedCoreInterface
Deprecated interface functions.
Definition: DeprecatedCoreInterface.hpp:16
DomainEleOp
DomainEle::UserDataOperator DomainEleOp
Definition: simple_l2_only.cpp:30
MoFEM::Interface
DeprecatedCoreInterface Interface
Definition: Interface.hpp:1975
MoFEM::Simple::getOptions
MoFEMErrorCode getOptions()
get options
Definition: Simple.cpp:180
MoFEM::PipelineManager::EdgeEle
MoFEM::EdgeElementForcesAndSourcesCore EdgeEle
Definition: PipelineManager.hpp:36
MoFEM::Simple::getAddSkeletonFE
bool & getAddSkeletonFE()
Get the addSkeletonFE.
Definition: Simple.hpp:425
CHKERR
#define CHKERR
Inline error check.
Definition: definitions.h:535
MoFEM
implementation of Data Operators for Forces and Sources
Definition: Common.hpp:10
MoFEM::FaceElementForcesAndSourcesCore::UserDataOperator
default operator for TRI element
Definition: FaceElementForcesAndSourcesCore.hpp:94
convert.type
type
Definition: convert.py:64
MoFEM::PipelineManager::FaceEle
MoFEM::FaceElementForcesAndSourcesCore FaceEle
Definition: PipelineManager.hpp:35
MoFEM::Simple::addDomainField
MoFEMErrorCode addDomainField(const std::string &name, const FieldSpace space, const FieldApproximationBase base, const FieldCoefficientsNumber nb_of_coefficients, const TagType tag_type=MB_TAG_SPARSE, const enum MoFEMTypes bh=MF_ZERO, int verb=-1)
Add field on domain.
Definition: Simple.cpp:264
MoFEM::Simple::getAddBoundaryFE
bool & getAddBoundaryFE()
Get the addSkeletonFE.
Definition: Simple.hpp:436
MoFEM::DMRegister_MoFEM
PetscErrorCode DMRegister_MoFEM(const char sname[])
Register MoFEM problem.
Definition: DMMoFEM.cpp:47
MoFEM::Simple::getDomainFEName
const std::string getDomainFEName() const
Get the Domain FE Name.
Definition: Simple.hpp:341
MoFEM::Simple::setFieldOrder
MoFEMErrorCode setFieldOrder(const std::string field_name, const int order, const Range *ents=NULL)
Set field order.
Definition: Simple.cpp:473
ElementsAndOps
Definition: child_and_parent.cpp:18
DomainEleOp
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
MOFEM_LOG
#define MOFEM_LOG(channel, severity)
Log.
Definition: LogManager.hpp:308
CATCH_ERRORS
#define CATCH_ERRORS
Catch errors.
Definition: definitions.h:372
SPACE_DIM
constexpr int SPACE_DIM
Definition: simple_l2_only.cpp:18
MoFEM::Core
CoreTmp< 0 > Core
Definition: Core.hpp:1094
UserDataOperator
ForcesAndSourcesCore::UserDataOperator UserDataOperator
Definition: HookeElement.hpp:75
AINSWORTH_LEGENDRE_BASE
@ AINSWORTH_LEGENDRE_BASE
Ainsworth Cole (Legendre) approx. base .
Definition: definitions.h:60
MoFEM::PipelineManager::getOpBoundaryRhsPipeline
boost::ptr_deque< UserDataOperator > & getOpBoundaryRhsPipeline()
Get the Op Boundary Rhs Pipeline object.
Definition: PipelineManager.hpp:821
EntData
EntitiesFieldData::EntData EntData
Definition: simple_l2_only.cpp:33
MOFEM_ATOM_TEST_INVALID
@ MOFEM_ATOM_TEST_INVALID
Definition: definitions.h:40
DomainEle
ElementsAndOps< SPACE_DIM >::DomainEle DomainEle
Definition: child_and_parent.cpp:34
main
int main(int argc, char *argv[])
Definition: simple_l2_only.cpp:35
MoFEM::Simple::setUp
MoFEMErrorCode setUp(const PetscBool is_partitioned=PETSC_TRUE)
Setup problem.
Definition: Simple.cpp:611
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