v0.14.0
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
PoissonExample::OpError Struct Reference

Evaluate error. More...

#include <users_modules/tutorials/cor-2to5/src/PoissonOperators.hpp>

Inheritance diagram for PoissonExample::OpError:
[legend]
Collaboration diagram for PoissonExample::OpError:
[legend]

Public Types

typedef boost::function< double(const double, const double, const double)> UVal
 
typedef boost::function< FTensor::Tensor1< double, 3 > const double, const double, const double)> GVal
 

Public Member Functions

 OpError (UVal u_value, GVal g_value, boost::shared_ptr< VectorDouble > &field_vals, boost::shared_ptr< MatrixDouble > &grad_vals, Vec global_error)
 
MoFEMErrorCode doWork (int row_side, EntityType row_type, EntitiesFieldData::EntData &row_data)
 
- Public Member Functions inherited from PoissonExample::OpBaseRhs< VolumeElementForcesAndSourcesCore::UserDataOperator >
 OpBaseRhs (const std::string field_name)
 
MoFEMErrorCode doWork (int row_side, EntityType row_type, EntitiesFieldData::EntData &row_data)
 This function is called by finite element. More...
 

Private Member Functions

MoFEMErrorCode iNtegrate (EntitiesFieldData::EntData &data)
 Integrate error. More...
 
MoFEMErrorCode aSsemble (EntitiesFieldData::EntData &data)
 Assemble error. More...
 

Private Attributes

Vec globalError
 ghost vector with global (integrated over volume) error More...
 
FTensor::Number< 0 > NX
 
FTensor::Number< 1 > NY
 
FTensor::Number< 2 > NZ
 
FTensor::Index< 'i', 3 > i
 
UVal uValue
 function with exact solution More...
 
GVal gValue
 function with exact solution for gradient More...
 
boost::shared_ptr< VectorDouble > fieldVals
 
boost::shared_ptr< MatrixDouble > gradVals
 

Additional Inherited Members

- Protected Attributes inherited from PoissonExample::OpBaseRhs< VolumeElementForcesAndSourcesCore::UserDataOperator >
int nbRows
 < error code More...
 
int nbIntegrationPts
 number of integration points More...
 

Detailed Description

Evaluate error.

Definition at line 491 of file PoissonOperators.hpp.

Member Typedef Documentation

◆ GVal

typedef boost::function<FTensor::Tensor1<double, 3> const double, const double, const double)> PoissonExample::OpError::GVal
Examples
PoissonOperators.hpp.

Definition at line 498 of file PoissonOperators.hpp.

◆ UVal

typedef boost::function<double(const double, const double, const double)> PoissonExample::OpError::UVal
Examples
PoissonOperators.hpp.

Definition at line 495 of file PoissonOperators.hpp.

Constructor & Destructor Documentation

◆ OpError()

PoissonExample::OpError::OpError ( UVal  u_value,
GVal  g_value,
boost::shared_ptr< VectorDouble > &  field_vals,
boost::shared_ptr< MatrixDouble > &  grad_vals,
Vec  global_error 
)
inline
Examples
PoissonOperators.hpp.

Definition at line 500 of file PoissonOperators.hpp.

503  : OpBaseRhs<VolumeElementForcesAndSourcesCore::UserDataOperator>("ERROR"),
504  globalError(global_error), uValue(u_value), gValue(g_value),
505  fieldVals(field_vals), gradVals(grad_vals) {}

Member Function Documentation

◆ aSsemble()

MoFEMErrorCode PoissonExample::OpError::aSsemble ( EntitiesFieldData::EntData data)
inlineprivatevirtual

Assemble error.

Implements PoissonExample::OpBaseRhs< VolumeElementForcesAndSourcesCore::UserDataOperator >.

Examples
PoissonOperators.hpp.

Definition at line 575 of file PoissonOperators.hpp.

575  {
577  // set error on mesh
578  data.getFieldDofs()[0]->getFieldData() = sqrt(data.getFieldData()[0]);
579  // assemble vector to global error
580  CHKERR VecSetValue(globalError, 0, data.getFieldData()[0], ADD_VALUES);
582  }

◆ doWork()

MoFEMErrorCode PoissonExample::OpError::doWork ( int  row_side,
EntityType  row_type,
EntitiesFieldData::EntData row_data 
)
inline
Examples
PoissonOperators.hpp.

Definition at line 507 of file PoissonOperators.hpp.

508  {
510  nbRows = row_data.getFieldData().size();
511  if (!nbRows)
513  nbIntegrationPts = getGaussPts().size2();
514  CHKERR iNtegrate(row_data);
515  CHKERR aSsemble(row_data);
517  }

◆ iNtegrate()

MoFEMErrorCode PoissonExample::OpError::iNtegrate ( EntitiesFieldData::EntData data)
inlineprivatevirtual

Integrate error.

Implements PoissonExample::OpBaseRhs< VolumeElementForcesAndSourcesCore::UserDataOperator >.

Examples
PoissonOperators.hpp.

Definition at line 535 of file PoissonOperators.hpp.

535  {
537  // clear field dofs
538  data.getFieldData().clear();
539  // get volume of element
540  const double vol = getVolume();
541  // get integration weight
542  auto t_w = getFTensor0IntegrationWeight();
543  // get solution at integration point
544  auto t_u = getFTensor0FromVec(*fieldVals);
545  // get solution at integration point
546  auto t_grad = getFTensor1FromMat<3>(*gradVals);
547  // get coordinates at integration point
548  auto t_coords = getFTensor1CoordsAtGaussPts();
549  // keep exact gradient and error or gradient
550  FTensor::Tensor1<double, 3> t_exact_grad, t_error_grad;
551  // integrate over
552  for (int gg = 0; gg != nbIntegrationPts; gg++) {
553  double alpha = vol * t_w;
554  // evaluate exact value
555  double exact_u = uValue(t_coords(NX), t_coords(NY), t_coords(NZ));
556  // evaluate exact gradient
557  t_exact_grad = gValue(t_coords(NX), t_coords(NY), t_coords(NZ));
558  // calculate gradient errro
559  t_error_grad(i) = t_grad(i) - t_exact_grad(i);
560  // error
561  double error = pow(t_u - exact_u, 2) + t_error_grad(i) * t_error_grad(i);
562  // iterate over base functions
563  data.getFieldData()[0] += alpha * error;
564  ++t_w; // move to next integration point
565  ++t_u; // next value of function at integration point
566  ++t_grad; // next gradient at integration point
567  ++t_coords; // next coordinate at integration point
568  }
570  }

Member Data Documentation

◆ fieldVals

boost::shared_ptr<VectorDouble> PoissonExample::OpError::fieldVals
private
Examples
PoissonOperators.hpp.

Definition at line 529 of file PoissonOperators.hpp.

◆ globalError

Vec PoissonExample::OpError::globalError
private

ghost vector with global (integrated over volume) error

Examples
PoissonOperators.hpp.

Definition at line 520 of file PoissonOperators.hpp.

◆ gradVals

boost::shared_ptr<MatrixDouble> PoissonExample::OpError::gradVals
private
Examples
PoissonOperators.hpp.

Definition at line 530 of file PoissonOperators.hpp.

◆ gValue

GVal PoissonExample::OpError::gValue
private

function with exact solution for gradient

Examples
PoissonOperators.hpp.

Definition at line 527 of file PoissonOperators.hpp.

◆ i

FTensor::Index<'i', 3> PoissonExample::OpError::i
private
Examples
PoissonOperators.hpp.

Definition at line 525 of file PoissonOperators.hpp.

◆ NX

FTensor::Number<0> PoissonExample::OpError::NX
private
Examples
PoissonOperators.hpp.

Definition at line 522 of file PoissonOperators.hpp.

◆ NY

FTensor::Number<1> PoissonExample::OpError::NY
private
Examples
PoissonOperators.hpp.

Definition at line 523 of file PoissonOperators.hpp.

◆ NZ

FTensor::Number<2> PoissonExample::OpError::NZ
private
Examples
PoissonOperators.hpp.

Definition at line 524 of file PoissonOperators.hpp.

◆ uValue

UVal PoissonExample::OpError::uValue
private

function with exact solution

Examples
PoissonOperators.hpp.

Definition at line 526 of file PoissonOperators.hpp.


The documentation for this struct was generated from the following file:
MoFEMFunctionReturnHot
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:447
PoissonExample::OpError::globalError
Vec globalError
ghost vector with global (integrated over volume) error
Definition: PoissonOperators.hpp:520
PoissonExample::OpError::fieldVals
boost::shared_ptr< VectorDouble > fieldVals
Definition: PoissonOperators.hpp:529
FTensor::Tensor1< double, 3 >
PoissonExample::OpError::gValue
GVal gValue
function with exact solution for gradient
Definition: PoissonOperators.hpp:527
CHKERR
#define CHKERR
Inline error check.
Definition: definitions.h:535
PoissonExample::OpError::NX
FTensor::Number< 0 > NX
Definition: PoissonOperators.hpp:522
MoFEM::getFTensor0FromVec
static auto getFTensor0FromVec(ublas::vector< T, A > &data)
Get tensor rank 0 (scalar) form data vector.
Definition: Templates.hpp:135
PoissonExample::OpError::NZ
FTensor::Number< 2 > NZ
Definition: PoissonOperators.hpp:524
PoissonExample::OpError::NY
FTensor::Number< 1 > NY
Definition: PoissonOperators.hpp:523
PoissonExample::OpError::i
FTensor::Index< 'i', 3 > i
Definition: PoissonOperators.hpp:525
PoissonExample::OpError::uValue
UVal uValue
function with exact solution
Definition: PoissonOperators.hpp:526
PoissonExample::OpError::gradVals
boost::shared_ptr< MatrixDouble > gradVals
Definition: PoissonOperators.hpp:530
PoissonExample::OpError::iNtegrate
MoFEMErrorCode iNtegrate(EntitiesFieldData::EntData &data)
Integrate error.
Definition: PoissonOperators.hpp:535
MoFEMFunctionReturn
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:416
PoissonExample::OpError::aSsemble
MoFEMErrorCode aSsemble(EntitiesFieldData::EntData &data)
Assemble error.
Definition: PoissonOperators.hpp:575
MoFEMFunctionBegin
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:346
PoissonExample::OpBaseRhs< VolumeElementForcesAndSourcesCore::UserDataOperator >::nbRows
int nbRows
< error code
Definition: PoissonOperators.hpp:204
PoissonExample::OpBaseRhs< VolumeElementForcesAndSourcesCore::UserDataOperator >::nbIntegrationPts
int nbIntegrationPts
number of integration points
Definition: PoissonOperators.hpp:205