13static char help[] =
"...\n\n";
30 DomainEle::UserDataOperator;
37auto fun = [](
const double x,
const double y,
const double z) {
38 return x + y + x * x + y * y;
96 OpError(boost::shared_ptr<MatrixDouble> data_ptr)
102 const int nb_integration_pts = getGaussPts().size2();
103 auto t_val = getFTensor1FromMat<1>(
105 auto t_coords = getFTensor1CoordsAtGaussPts();
108 for (
int gg = 0; gg != nb_integration_pts; ++gg) {
112 double diff = t_val(0) -
fun(t_coords(0), t_coords(1), t_coords(2));
113 constexpr double eps = 1e-8;
114 if (std::abs(diff) >
eps) {
115 MOFEM_LOG(
"SELF", Sev::error) <<
"Wrong function value " << diff;
117 "Wrong function value");
125 MOFEM_LOG(
"SELF", Sev::noisy) <<
"All is OK";
175 auto rule = [](
int,
int,
int p) ->
int {
return 2 * p; };
196 MOFEM_LOG(
"WORLD", Sev::inform) <<
"Solve problem";
199 CHKERR KSPSetFromOptions(solver);
207 CHKERR VecGhostUpdateBegin(
D, INSERT_VALUES, SCATTER_FORWARD);
208 CHKERR VecGhostUpdateEnd(
D, INSERT_VALUES, SCATTER_FORWARD);
218 pipeline_mng->getDomainLhsFE().reset();
219 pipeline_mng->getDomainRhsFE().reset();
220 pipeline_mng->getOpDomainRhsPipeline().clear();
222 auto rule = [](int, int,
int p) ->
int {
return 2 * p + 1; };
223 CHKERR pipeline_mng->setDomainRhsIntegrationRule(
226 auto entity_data_l2 = boost::make_shared<EntitiesFieldData>(
230 auto mass_ptr = boost::make_shared<MatrixDouble>();
233 boost::make_shared<MatrixDouble>();
236 boost::make_shared<MatrixDouble>();
243 pipeline_mng->getOpDomainRhsPipeline().push_back(op_this);
247 pipeline_mng->getOpDomainRhsPipeline().push_back(
250 auto fe_physics_ptr = op_this->getThisFEPtr();
251 fe_physics_ptr->getRuleHook = [](int, int,
int p) {
return 2 * p; };
255 fe_physics_ptr->getOpPtrVector().push_back(
258 fe_physics_ptr->getOpPtrVector().push_back(
263 CHKERR pipeline_mng->loopFiniteElements();
269int main(
int argc,
char *argv[]) {
277 DMType dm_name =
"DMMOFEM";
282 moab::Core mb_instance;
283 moab::Interface &moab = mb_instance;
void simple(double P1[], double P2[], double P3[], double c[], const int N)
FormsIntegrators< DomainEleOp >::Assembly< PETSC >::LinearForm< GAUSS >::OpSource< 1, FIELD_DIM > OpDomainSource
ElementsAndOps< SPACE_DIM >::DomainEle DomainEle
FormsIntegrators< DomainEleOp >::Assembly< PETSC >::BiLinearForm< GAUSS >::OpMass< 1, FIELD_DIM > OpDomainMass
#define CATCH_ERRORS
Catch errors.
@ AINSWORTH_LEGENDRE_BASE
Ainsworth Cole (Legendre) approx. base .
@ L2
field with C-1 continuity
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
@ MOFEM_ATOM_TEST_INVALID
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.
constexpr char FIELD_NAME[]
auto fun
Function to approximate.
PetscErrorCode DMoFEMMeshToLocalVector(DM dm, Vec l, InsertMode mode, ScatterMode scatter_mode)
set local (or ghosted) vector values on mesh for partition only
PetscErrorCode DMRegister_MoFEM(const char sname[])
Register MoFEM problem.
auto createDMVector(DM dm)
Get smart vector from DM.
boost::ptr_deque< UserDataOperator > & getOpDomainLhsPipeline()
Get the Op Domain Lhs Pipeline object.
SmartPetscObj< KSP > createKSP(SmartPetscObj< DM > dm=nullptr)
Create KSP (linear) solver.
boost::ptr_deque< UserDataOperator > & getOpDomainRhsPipeline()
Get the Op Domain Rhs Pipeline object.
#define MOFEM_LOG(channel, severity)
Log.
constexpr char FIELD_NAME[]
auto fun
Function to approximate.
FormsIntegrators< DomainEleOp >::Assembly< PETSC >::BiLinearForm< GAUSS >::OpMass< BASE_DIM, FIELD_DIM > OpDomainMass
OPerator to integrate mass matrix for least square approximation.
FormsIntegrators< DomainEleOp >::Assembly< PETSC >::LinearForm< GAUSS >::OpSource< BASE_DIM, FIELD_DIM > OpDomainSource
Operator to integrate the right hand side matrix for the problem.
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
implementation of Data Operators for Forces and Sources
SmartPetscObj< Vec > vectorDuplicate(Vec vec)
Create duplicate vector of smart vector.
Collected data use d by operator to evaluate errors for the test.
boost::shared_ptr< VectorDouble > approxVals
SmartPetscObj< Vec > L2Vec
boost::shared_ptr< MatrixDouble > invJacPtr
boost::shared_ptr< MatrixDouble > approxHessianVals
boost::shared_ptr< MatrixDouble > approxGradVals
Operator to evaluate errors.
boost::shared_ptr< CommonData > commonDataPtr
OpError(boost::shared_ptr< MatrixDouble > data_ptr)
boost::shared_ptr< MatrixDouble > dataPtr
MoFEMErrorCode doWork(int side, EntityType type, EntData &data)
MoFEMErrorCode checkResults()
[Check results]
MoFEMErrorCode solveSystem()
AtomTest(MoFEM::Interface &m_field)
MoFEMErrorCode setupProblem()
MoFEMErrorCode readMesh()
MoFEMErrorCode assembleSystem()
MoFEM::Interface & mField
MoFEMErrorCode runProblem()
static MoFEMErrorCode Initialize(int *argc, char ***args, const char file[], const char help[])
Initializes the MoFEM database PETSc, MOAB and MPI.
static MoFEMErrorCode Finalize()
Checks for options to be called at the conclusion of the program.
Deprecated interface functions.
Data on single entity (This is passed as argument to DataOperator::doWork)
default operator for TRI element
Get values at integration pts for tensor field rank 1, i.e. vector field.
Execute "this" element in the operator.
PipelineManager interface.
MoFEM::FaceElementForcesAndSourcesCore FaceEle
MoFEMErrorCode setDomainRhsIntegrationRule(RuleHookFun rule)
MoFEMErrorCode setDomainLhsIntegrationRule(RuleHookFun rule)
Simple interface for fast problem set-up.
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.
MoFEMErrorCode loadFile(const std::string options, const std::string mesh_file_name, LoadFileFunc loadFunc=defaultLoadFileFunc)
Load mesh file.
MoFEMErrorCode getOptions()
get options
MoFEMErrorCode getDM(DM *dm)
Get DM.
MoFEMErrorCode setFieldOrder(const std::string field_name, const int order, const Range *ents=NULL)
Set field order.
MoFEMErrorCode setUp(const PetscBool is_partitioned=PETSC_TRUE)
Setup problem.
intrusive_ptr for managing petsc objects
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.