v0.13.1
Loading...
Searching...
No Matches
hello_world.cpp

Prints basic information about users data operator. See more details in FUN-0: Hello world

/**
* \file hello_world.cpp
* \ingroup mofem_simple_interface
* \example hello_world.cpp
*
* Prints basic information about users data operator.
* See more details in \ref hello_world_tut1
*
*/
using namespace MoFEM;
static char help[] = "...\n\n";
#define HelloFunctionBegin \
MoFEMFunctionBegin; \
MOFEM_LOG_CHANNEL("SYNC"); \
MOFEM_LOG_FUNCTION(); \
MOFEM_LOG_TAG("WORLD", "HelloWorld");
OpRow(const std::string &field_name)
if (type == MBVERTEX) {
// get number of evaluated element in the loop
MOFEM_LOG("SYNC", Sev::inform) << "**** " << getNinTheLoop() << " ****";
MOFEM_LOG("SYNC", Sev::inform) << "**** Operators ****";
}
MOFEM_LOG("SYNC", Sev::inform)
<< "Hello Operator OpRow:"
<< " field name " << rowFieldName << " side " << side << " type "
<< CN::EntityTypeName(type) << " nb dofs on entity "
<< data.getIndices().size();
}
};
OpRowCol(const std::string row_field, const std::string col_field,
const bool symm)
: ForcesAndSourcesCore::UserDataOperator(row_field, col_field, OPROWCOL,
symm) {}
MoFEMErrorCode doWork(int row_side, int col_side, EntityType row_type,
EntityType col_type,
MOFEM_LOG("SYNC", Sev::inform)
<< "Hello Operator OpRowCol:"
<< " row field name " << rowFieldName << " row side " << row_side
<< " row type " << CN::EntityTypeName(row_type)
<< " nb dofs on row entity " << row_data.getIndices().size() << " : "
<< " col field name " << colFieldName << " col side " << col_side
<< " col type " << CN::EntityTypeName(col_type)
<< " nb dofs on col entity " << col_data.getIndices().size();
}
};
OpVolume(const std::string &field_name)
field_name, OPROW) {
}
if (type == MBVERTEX) {
MOFEM_LOG("SYNC", Sev::inform) << "Hello Operator OpVolume:"
<< " volume " << getVolume();
}
}
};
OpFace(const std::string &field_name)
if (type == MBVERTEX) {
MOFEM_LOG("SYNC", Sev::inform) << "Hello Operator OpFace:"
<< " normal " << getNormal();
}
}
};
boost::shared_ptr<VolumeElementForcesAndSourcesCoreOnSide> &feSidePtr;
const std::string &field_name,
boost::shared_ptr<VolumeElementForcesAndSourcesCoreOnSide> &fe_side_ptr)
feSidePtr(fe_side_ptr) {}
if (type == MBVERTEX) {
MOFEM_LOG("SYNC", Sev::inform) << "Hello Operator OpSideFace";
CHKERR loopSideVolumes("dFE", *feSidePtr);
}
}
};
OpVolumeSide(const std::string &field_name)
field_name, field_name, OPROW) {}
if (type == MBVERTEX) {
MOFEM_LOG("SYNC", Sev::inform)
<< "Hello Operator OpVolumeSide:"
<< " volume " << getVolume() << " normal " << getNormal();
}
}
};
int main(int argc, char *argv[]) {
// initialize petsc
MoFEM::Core::Initialize(&argc, &argv, (char *)0, help);
try {
// Register DM Manager
DMType dm_name = "DMMOFEM";
// 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;
// Simple interface
CHKERR m_field.getInterface(simple);
// get options from command line
CHKERR simple->getOptions();
// load mesh file
CHKERR simple->loadFile();
// add fields
CHKERR simple->addDomainField("U", H1, AINSWORTH_LEGENDRE_BASE, 3);
CHKERR simple->addBoundaryField("L", H1, AINSWORTH_LEGENDRE_BASE, 3);
CHKERR simple->addSkeletonField("S", H1, AINSWORTH_LEGENDRE_BASE, 3);
// set fields order
CHKERR simple->setFieldOrder("U", 4);
CHKERR simple->setFieldOrder("L", 3);
CHKERR simple->setFieldOrder("S", 3);
// setup problem
CHKERR simple->setUp();
auto pipeline_mng = m_field.getInterface<PipelineManager>();
//! [set operator to the volume element instance]
pipeline_mng->getOpDomainRhsPipeline().push_back(new OpRow("U"));
pipeline_mng->getOpDomainRhsPipeline().push_back(new OpVolume("U"));
pipeline_mng->getOpDomainLhsPipeline().push_back(
new OpRowCol("U", "U", true));
//! [set operator to the volume element instance]
//! [set operator to the face element instance]
pipeline_mng->getOpBoundaryRhsPipeline().push_back(new OpRow("L"));
pipeline_mng->getOpBoundaryRhsPipeline().push_back(new OpFace("L"));
pipeline_mng->getOpBoundaryLhsPipeline().push_back(
new OpRowCol("U", "L", false));
//! [set operator to the face element instance]
//! [create skeleton side element and push operator to it]
boost::shared_ptr<VolumeElementForcesAndSourcesCoreOnSide> side_fe(
side_fe->getOpPtrVector().push_back(new OpVolumeSide("U"));
//! [create skeleton side element and push operator to it]
//! [set operator to the face element on skeleton instance]
pipeline_mng->getOpSkeletonRhsPipeline().push_back(new OpRow("S"));
pipeline_mng->getOpSkeletonRhsPipeline().push_back(
new OpFaceSide("S", side_fe));
//! [set operator to the face element on skeleton instance]
//! [executing finite elements]
CHKERR pipeline_mng->loopFiniteElements();
//! [executing finite elements]
}
// finish work cleaning memory, getting statistics, etc.
return 0;
}
ForcesAndSourcesCore::UserDataOperator UserDataOperator
#define MOFEM_LOG_SYNCHRONISE(comm)
Synchronise "SYNC" channel.
Definition: LogManager.hpp:338
void simple(double P1[], double P2[], double P3[], double c[], const int N)
Definition: acoustic.cpp:69
static char help[]
int main()
Definition: adol-c_atom.cpp:46
#define CATCH_ERRORS
Catch errors.
Definition: definitions.h:372
@ AINSWORTH_LEGENDRE_BASE
Ainsworth Cole (Legendre) approx. base .
Definition: definitions.h:60
@ H1
continuous field
Definition: definitions.h:85
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:416
#define CHKERR
Inline error check.
Definition: definitions.h:535
PetscErrorCode DMRegister_MoFEM(const char sname[])
Register MoFEM problem.
Definition: DMMMoFEM.cpp:47
boost::ptr_vector< UserDataOperator > & getOpDomainRhsPipeline()
Get the Op Domain Rhs Pipeline object.
#define MOFEM_LOG(channel, severity)
Log.
Definition: LogManager.hpp:301
#define HelloFunctionBegin
Definition: hello_world.cpp:16
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
Definition: Exceptions.hpp:56
implementation of Data Operators for Forces and Sources
Definition: Common.hpp:10
constexpr auto field_name
virtual MPI_Comm & get_comm() const =0
Core (interface) class.
Definition: Core.hpp:82
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
static MoFEMErrorCode Finalize()
Checks for options to be called at the conclusion of the program.
Definition: Core.cpp:112
Deprecated interface functions.
Data on single entity (This is passed as argument to DataOperator::doWork)
const VectorInt & getIndices() const
Get global indices of dofs on entity.
@ OPROW
operator doWork function is executed on FE rows
structure to get information form mofem into EntitiesFieldData
PipelineManager interface.
Simple interface for fast problem set-up.
Definition: Simple.hpp:26
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface refernce to pointer of interface.
Base volume element used to integrate on skeleton.
MoFEMErrorCode doWork(int side, EntityType type, EntitiesFieldData::EntData &data)
Operator for linear form, usually to calculate values on right hand side.
boost::shared_ptr< VolumeElementForcesAndSourcesCoreOnSide > & feSidePtr
Definition: hello_world.cpp:95
MoFEMErrorCode doWork(int side, EntityType type, EntitiesFieldData::EntData &data)
MoFEMErrorCode doWork(int row_side, int col_side, EntityType row_type, EntityType col_type, EntitiesFieldData::EntData &row_data, EntitiesFieldData::EntData &col_data)
Definition: hello_world.cpp:47
MoFEMErrorCode doWork(int side, EntityType type, EntitiesFieldData::EntData &data)
Definition: hello_world.cpp:25
MoFEMErrorCode doWork(int side, EntityType type, EntitiesFieldData::EntData &data)
MoFEMErrorCode doWork(int side, EntityType type, EntitiesFieldData::EntData &data)