v0.16.3
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
MixedPoisson::OpError Struct Reference
Inheritance diagram for MixedPoisson::OpError:
[legend]
Collaboration diagram for MixedPoisson::OpError:
[legend]

Public Member Functions

 OpError (boost::shared_ptr< CommonData > &common_data_ptr, MoFEM::Interface &m_field)
 
MoFEMErrorCode doWork (int side, EntityType type, EntData &data)
 [Output results]
 

Public Attributes

boost::shared_ptr< CommonData > commonDataPtr
 
MoFEM::Interface & mField
 

Detailed Description

Definition at line 129 of file mixed_poisson.cpp.

Constructor & Destructor Documentation

◆ OpError()

MixedPoisson::OpError::OpError ( boost::shared_ptr< CommonData > &  common_data_ptr,
MoFEM::Interface &  m_field 
)
inline

Definition at line 132 of file mixed_poisson.cpp.

134 : DomainEleOp("U", OPROW), commonDataPtr(common_data_ptr),
135 mField(m_field) {
136 std::fill(&doEntities[MBVERTEX], &doEntities[MBMAXTYPE], false);
137 doEntities[MBTRI] = doEntities[MBQUAD] = true;
138 }
DomainEle::UserDataOperator DomainEleOp
MoFEM::Interface & mField
boost::shared_ptr< CommonData > commonDataPtr

Member Function Documentation

◆ doWork()

MoFEMErrorCode MixedPoisson::OpError::doWork ( int  side,
EntityType  type,
EntData &  data 
)

[Output results]

[OpError]

Examples
mofem/tutorials/mix-0_mixed_poisson/mixed_poisson.cpp.

Definition at line 493 of file mixed_poisson.cpp.

494 {
496 const int nb_integration_pts = getGaussPts().size2();
497 const double area = getMeasure();
498 auto t_w = getFTensor0IntegrationWeight();
499 auto t_val = getFTensor0FromVec(*(commonDataPtr->approxVals));
500 auto t_val_grad = getFTensor1FromMat<2>(*(commonDataPtr->approxValsGrad));
501 auto t_flux = getFTensor1FromMat<3>(*(commonDataPtr->approxFlux));
502 auto t_coords = getFTensor1CoordsAtGaussPts();
504 FTensor::Index<'i', 2> i;
505
506 double error_l2 = 0;
507 double error_h1 = 0;
508 double error_ind = 0;
509 for (int gg = 0; gg != nb_integration_pts; ++gg) {
510 const double alpha = t_w * area;
511
512 double diff = t_val - MixedPoisson::analyticalFunction(
513 t_coords(0), t_coords(1), t_coords(2));
514 error_l2 += alpha * sqr(diff);
515
517 t_coords(0), t_coords(1), t_coords(2));
518 auto t_fun_grad = getFTensor1FromArray<2, 2>(vec);
519 t_diff(i) = t_val_grad(i) - t_fun_grad(i);
520 error_h1 += alpha * t_diff(i) * t_diff(i);
521
522 t_diff(i) = t_val_grad(i) - t_flux(i);
523 error_ind += alpha * t_diff(i) * t_diff(i);
524
525 ++t_w;
526 ++t_val;
527 ++t_val_grad;
528 ++t_flux;
529 ++t_coords;
530 }
531
532 const EntityHandle ent = getFEEntityHandle();
533 Tag th_error_l2, th_error_h1, th_error_ind;
534 CHKERR MixedPoisson::getTagHandle(mField, "ERROR_L2_NORM", MB_TYPE_DOUBLE,
535 th_error_l2);
536 CHKERR MixedPoisson::getTagHandle(mField, "ERROR_H1_SEMINORM", MB_TYPE_DOUBLE,
537 th_error_h1);
538 CHKERR MixedPoisson::getTagHandle(mField, "ERROR_INDICATOR", MB_TYPE_DOUBLE,
539 th_error_ind);
540
541 double error_l2_norm = sqrt(error_l2);
542 double error_h1_seminorm = sqrt(error_h1);
543 double error_ind_local = sqrt(error_ind);
544 CHKERR mField.get_moab().tag_set_data(th_error_l2, &ent, 1, &error_l2_norm);
545 CHKERR mField.get_moab().tag_set_data(th_error_h1, &ent, 1,
546 &error_h1_seminorm);
547 CHKERR mField.get_moab().tag_set_data(th_error_ind, &ent, 1,
548 &error_ind_local);
549
550 if (error_ind_local > commonDataPtr->maxErrorIndicator)
551 commonDataPtr->maxErrorIndicator = error_ind_local;
552
553 constexpr std::array<int, CommonData::LAST_ELEMENT> indices = {
556 std::array<double, CommonData::LAST_ELEMENT> values;
557 values[0] = error_l2;
558 values[1] = error_h1;
559 values[2] = error_ind;
561 indices.data(), values.data(), ADD_VALUES);
563}
SmartPetscObj< Vec > values
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.
FTensor::Index< 'i', SPACE_DIM > i
double sqr(double x)
static auto getFTensor0FromVec(V &data)
Get tensor rank 0 (scalar) form data vector.
MoFEMErrorCode VecSetValues(Vec V, const EntitiesFieldData::EntData &data, const double *ptr, InsertMode iora)
Assemble PETSc vector.
static VectorDouble analyticalFunctionGrad(const double x, const double y, const double z)
[Analytical function]
static double analyticalFunction(const double x, const double y, const double z)
[Analytical function]
static MoFEMErrorCode getTagHandle(MoFEM::Interface &m_field, const char *name, DataType type, Tag &tag_handle)
[Source function]
virtual moab::Interface & get_moab()=0

Member Data Documentation

◆ commonDataPtr

boost::shared_ptr<CommonData> MixedPoisson::OpError::commonDataPtr

◆ mField

MoFEM::Interface& MixedPoisson::OpError::mField

The documentation for this struct was generated from the following file: