v0.15.0
Loading...
Searching...
No Matches
PoissonExample::OpError Struct Reference

Evaluate error. More...

#include "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.
 
virtual MoFEMErrorCode iNtegrate (EntitiesFieldData::EntData &data)=0
 Class dedicated to integrate operator.
 
virtual MoFEMErrorCode aSsemble (EntitiesFieldData::EntData &data)=0
 Class dedicated to assemble operator to global system vector.
 

Private Member Functions

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

Private Attributes

Vec globalError
 ghost vector with global (integrated over volume) error
 
FTensor::Number< 0 > NX
 
FTensor::Number< 1 > NY
 
FTensor::Number< 2 > NZ
 
FTensor::Index< 'i', 3 > i
 
UVal uValue
 function with exact solution
 
GVal gValue
 function with exact solution for gradient
 
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
 
int nbIntegrationPts
 number of integration points
 

Detailed Description

Evaluate error.

Definition at line 494 of file PoissonOperators.hpp.

Member Typedef Documentation

◆ GVal

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

Definition at line 501 of file PoissonOperators.hpp.

◆ UVal

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

Definition at line 498 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 503 of file PoissonOperators.hpp.

506 : OpBaseRhs<VolumeElementForcesAndSourcesCore::UserDataOperator>("ERROR"),
507 globalError(global_error), uValue(u_value), gValue(g_value),
508 fieldVals(field_vals), gradVals(grad_vals) {}
Vec globalError
ghost vector with global (integrated over volume) error
UVal uValue
function with exact solution
boost::shared_ptr< MatrixDouble > gradVals
GVal gValue
function with exact solution for gradient
boost::shared_ptr< VectorDouble > fieldVals

Member Function Documentation

◆ aSsemble()

MoFEMErrorCode PoissonExample::OpError::aSsemble ( EntitiesFieldData::EntData & data)
inlineprivate

Assemble error.

Examples
PoissonOperators.hpp.

Definition at line 578 of file PoissonOperators.hpp.

578 {
580 // set error on mesh
581 data.getFieldDofs()[0]->getFieldData() = sqrt(data.getFieldData()[0]);
582 // assemble vector to global error
583 CHKERR VecSetValue(globalError, 0, data.getFieldData()[0], ADD_VALUES);
585 }
#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.
const VectorDouble & getFieldData() const
get dofs values
const VectorDofs & getFieldDofs() const
get dofs data stature FEDofEntity

◆ doWork()

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

Definition at line 510 of file PoissonOperators.hpp.

511 {
513 nbRows = row_data.getFieldData().size();
514 if (!nbRows)
516 nbIntegrationPts = getGaussPts().size2();
517 CHKERR iNtegrate(row_data);
518 CHKERR aSsemble(row_data);
520 }
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
MoFEMErrorCode iNtegrate(EntitiesFieldData::EntData &data)
Integrate error.
MoFEMErrorCode aSsemble(EntitiesFieldData::EntData &data)
Assemble error.

◆ iNtegrate()

MoFEMErrorCode PoissonExample::OpError::iNtegrate ( EntitiesFieldData::EntData & data)
inlineprivate

Integrate error.

Examples
PoissonOperators.hpp.

Definition at line 538 of file PoissonOperators.hpp.

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

Member Data Documentation

◆ fieldVals

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

Definition at line 532 of file PoissonOperators.hpp.

◆ globalError

Vec PoissonExample::OpError::globalError
private

ghost vector with global (integrated over volume) error

Examples
PoissonOperators.hpp.

Definition at line 523 of file PoissonOperators.hpp.

◆ gradVals

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

Definition at line 533 of file PoissonOperators.hpp.

◆ gValue

GVal PoissonExample::OpError::gValue
private

function with exact solution for gradient

Examples
PoissonOperators.hpp.

Definition at line 530 of file PoissonOperators.hpp.

◆ i

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

Definition at line 528 of file PoissonOperators.hpp.

◆ NX

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

Definition at line 525 of file PoissonOperators.hpp.

◆ NY

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

Definition at line 526 of file PoissonOperators.hpp.

◆ NZ

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

Definition at line 527 of file PoissonOperators.hpp.

◆ uValue

UVal PoissonExample::OpError::uValue
private

function with exact solution

Examples
PoissonOperators.hpp.

Definition at line 529 of file PoissonOperators.hpp.


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