v0.14.0
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] More...
 

Public Attributes

boost::shared_ptr< CommonDatacommonDataPtr
 
MoFEM::InterfacemField
 

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  }

Member Function Documentation

◆ doWork()

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

[Output results]

[OpError]

Examples
mixed_poisson.cpp.

Definition at line 494 of file mixed_poisson.cpp.

495  {
497  const int nb_integration_pts = getGaussPts().size2();
498  const double area = getMeasure();
499  auto t_w = getFTensor0IntegrationWeight();
500  auto t_val = getFTensor0FromVec(*(commonDataPtr->approxVals));
501  auto t_val_grad = getFTensor1FromMat<2>(*(commonDataPtr->approxValsGrad));
502  auto t_flux = getFTensor1FromMat<3>(*(commonDataPtr->approxFlux));
503  auto t_coords = getFTensor1CoordsAtGaussPts();
506 
507  double error_l2 = 0;
508  double error_h1 = 0;
509  double error_ind = 0;
510  for (int gg = 0; gg != nb_integration_pts; ++gg) {
511  const double alpha = t_w * area;
512 
513  double diff = t_val - MixedPoisson::analyticalFunction(
514  t_coords(0), t_coords(1), t_coords(2));
515  error_l2 += alpha * sqr(diff);
516 
518  t_coords(0), t_coords(1), t_coords(2));
519  auto t_fun_grad = getFTensor1FromArray<2, 2>(vec);
520  t_diff(i) = t_val_grad(i) - t_fun_grad(i);
521  error_h1 += alpha * t_diff(i) * t_diff(i);
522 
523  t_diff(i) = t_val_grad(i) - t_flux(i);
524  error_ind += alpha * t_diff(i) * t_diff(i);
525 
526  ++t_w;
527  ++t_val;
528  ++t_val_grad;
529  ++t_flux;
530  ++t_coords;
531  }
532 
533  const EntityHandle ent = getFEEntityHandle();
534  Tag th_error_l2, th_error_h1, th_error_ind;
535  CHKERR MixedPoisson::getTagHandle(mField, "ERROR_L2_NORM", MB_TYPE_DOUBLE,
536  th_error_l2);
537  CHKERR MixedPoisson::getTagHandle(mField, "ERROR_H1_SEMINORM", MB_TYPE_DOUBLE,
538  th_error_h1);
539  CHKERR MixedPoisson::getTagHandle(mField, "ERROR_INDICATOR", MB_TYPE_DOUBLE,
540  th_error_ind);
541 
542  double error_l2_norm = sqrt(error_l2);
543  double error_h1_seminorm = sqrt(error_h1);
544  double error_ind_local = sqrt(error_ind);
545  CHKERR mField.get_moab().tag_set_data(th_error_l2, &ent, 1, &error_l2_norm);
546  CHKERR mField.get_moab().tag_set_data(th_error_h1, &ent, 1,
547  &error_h1_seminorm);
548  CHKERR mField.get_moab().tag_set_data(th_error_ind, &ent, 1,
549  &error_ind_local);
550 
551  if (error_ind_local > commonDataPtr->maxErrorIndicator)
552  commonDataPtr->maxErrorIndicator = error_ind_local;
553 
554  int index = CommonData::ERROR_L2_NORM;
555  constexpr std::array<int, CommonData::LAST_ELEMENT> indices = {
558  std::array<double, CommonData::LAST_ELEMENT> values;
559  values[0] = error_l2;
560  values[1] = error_h1;
561  values[2] = error_ind;
563  indices.data(), values.data(), ADD_VALUES);
565 }

Member Data Documentation

◆ commonDataPtr

boost::shared_ptr<CommonData> MixedPoisson::OpError::commonDataPtr
Examples
mixed_poisson.cpp.

Definition at line 130 of file mixed_poisson.cpp.

◆ mField

MoFEM::Interface& MixedPoisson::OpError::mField
Examples
mixed_poisson.cpp.

Definition at line 131 of file mixed_poisson.cpp.


The documentation for this struct was generated from the following file:
DomainEleOp
DomainEle::UserDataOperator DomainEleOp
Definition: mixed_poisson.cpp:19
FTensor::Tensor1
Definition: Tensor1_value.hpp:8
EntityHandle
MixedPoisson::analyticalFunctionGrad
static VectorDouble analyticalFunctionGrad(const double x, const double y, const double z)
[Analytical function]
Definition: mixed_poisson.cpp:56
MixedPoisson::CommonData::ERROR_INDICATOR_TOTAL
@ ERROR_INDICATOR_TOTAL
Definition: mixed_poisson.cpp:123
MoFEM::VecSetValues
MoFEMErrorCode VecSetValues(Vec V, const EntitiesFieldData::EntData &data, const double *ptr, InsertMode iora)
Assemble PETSc vector.
Definition: EntitiesFieldData.hpp:1589
MixedPoisson::CommonData::ERROR_L2_NORM
@ ERROR_L2_NORM
Definition: mixed_poisson.cpp:121
MixedPoisson::CommonData::LAST_ELEMENT
@ LAST_ELEMENT
Definition: mixed_poisson.cpp:124
CHKERR
#define CHKERR
Inline error check.
Definition: definitions.h:548
MoFEM::CoreInterface::get_moab
virtual moab::Interface & get_moab()=0
MixedPoisson::OpError::commonDataPtr
boost::shared_ptr< CommonData > commonDataPtr
Definition: mixed_poisson.cpp:130
MoFEM::getFTensor0FromVec
static auto getFTensor0FromVec(ublas::vector< T, A > &data)
Get tensor rank 0 (scalar) form data vector.
Definition: Templates.hpp:135
i
FTensor::Index< 'i', SPACE_DIM > i
Definition: hcurl_divergence_operator_2d.cpp:27
MixedPoisson::OpError::mField
MoFEM::Interface & mField
Definition: mixed_poisson.cpp:131
FTensor::Index< 'i', 2 >
MixedPoisson::analyticalFunction
static double analyticalFunction(const double x, const double y, const double z)
[Analytical function]
Definition: mixed_poisson.cpp:49
MoFEM::Types::VectorDouble
UBlasVector< double > VectorDouble
Definition: Types.hpp:68
sqr
double sqr(double x)
Definition: mixed_poisson.cpp:29
MixedPoisson::CommonData::ERROR_H1_SEMINORM
@ ERROR_H1_SEMINORM
Definition: mixed_poisson.cpp:122
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
MixedPoisson::getTagHandle
static MoFEMErrorCode getTagHandle(MoFEM::Interface &m_field, const char *name, DataType type, Tag &tag_handle)
[Source function]
Definition: mixed_poisson.cpp:79