libMesh
Public Types | Public Member Functions | Public Attributes | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
libMesh::ExactErrorEstimator Class Reference

This class implements an "error estimator" based on the difference between the approximate and exact solution. More...

#include <exact_error_estimator.h>

Inheritance diagram for libMesh::ExactErrorEstimator:
[legend]

Public Types

typedef Number(* ValueFunctionPointer) (const Point &p, const Parameters &Parameters, const std::string &sys_name, const std::string &unknown_name)
 Attach an arbitrary function which computes the exact value of the solution at any point. More...
 
typedef Gradient(* GradientFunctionPointer) (const Point &p, const Parameters &parameters, const std::string &sys_name, const std::string &unknown_name)
 Attach an arbitrary function which computes the exact gradient of the solution at any point. More...
 
typedef Tensor(* HessianFunctionPointer) (const Point &p, const Parameters &parameters, const std::string &sys_name, const std::string &unknown_name)
 Attach an arbitrary function which computes the exact second derivatives of the solution at any point. More...
 
typedef std::map< std::pair< const System *, unsigned int >, ErrorVector * > ErrorMap
 When calculating many error vectors at once, we need a data structure to hold them all. More...
 

Public Member Functions

 ExactErrorEstimator ()
 Constructor. More...
 
 ExactErrorEstimator (const ExactErrorEstimator &)=delete
 This class cannot be (default) copy constructed/assigned because it has containers of unique_ptrs. More...
 
ExactErrorEstimatoroperator= (const ExactErrorEstimator &)=delete
 
 ExactErrorEstimator (ExactErrorEstimator &&)=default
 Defaulted move ctor, move assignment operator, and destructor. More...
 
ExactErrorEstimatoroperator= (ExactErrorEstimator &&)=default
 
virtual ~ExactErrorEstimator ()=default
 
void attach_exact_values (std::vector< FunctionBase< Number > *> f)
 Clone and attach arbitrary functors which compute the exact values of the EquationSystems' solutions at any point. More...
 
void attach_exact_value (unsigned int sys_num, FunctionBase< Number > *f)
 Clone and attach an arbitrary functor which computes the exact value of the system sys_num solution at any point. More...
 
void attach_exact_value (ValueFunctionPointer fptr)
 
void attach_exact_derivs (std::vector< FunctionBase< Gradient > *> g)
 Clone and attach arbitrary functors which compute the exact gradients of the EquationSystems' solutions at any point. More...
 
void attach_exact_deriv (unsigned int sys_num, FunctionBase< Gradient > *g)
 Clone and attach an arbitrary functor which computes the exact gradient of the system sys_num solution at any point. More...
 
void attach_exact_deriv (GradientFunctionPointer gptr)
 
void attach_exact_hessians (std::vector< FunctionBase< Tensor > *> h)
 Clone and attach arbitrary functors which compute the exact second derivatives of the EquationSystems' solutions at any point. More...
 
void attach_exact_hessian (unsigned int sys_num, FunctionBase< Tensor > *h)
 Clone and attach an arbitrary functor which computes the exact second derivatives of the system sys_num solution at any point. More...
 
void attach_exact_hessian (HessianFunctionPointer hptr)
 
void attach_reference_solution (EquationSystems *es_fine)
 Attach function similar to system.h which allows the user to attach a second EquationSystems object with a reference fine grid solution. More...
 
void extra_quadrature_order (const int extraorder)
 Increases or decreases the order of the quadrature rule used for numerical integration. More...
 
virtual void estimate_error (const System &system, ErrorVector &error_per_cell, const NumericVector< Number > *solution_vector=nullptr, bool estimate_parent_error=false) override
 This function uses the exact solution function to estimate the error on each cell. More...
 
virtual ErrorEstimatorType type () const override
 
virtual void estimate_errors (const EquationSystems &equation_systems, ErrorVector &error_per_cell, const std::map< const System *, SystemNorm > &error_norms, const std::map< const System *, const NumericVector< Number > *> *solution_vectors=nullptr, bool estimate_parent_error=false)
 This virtual function can be redefined in derived classes, but by default computes the sum of the error_per_cell for each system in the equation_systems. More...
 
virtual void estimate_errors (const EquationSystems &equation_systems, ErrorMap &errors_per_cell, const std::map< const System *, const NumericVector< Number > *> *solution_vectors=nullptr, bool estimate_parent_error=false)
 This virtual function can be redefined in derived classes, but by default it calls estimate_error repeatedly to calculate the requested error vectors. More...
 

Public Attributes

SystemNorm error_norm
 When estimating the error in a single system, the error_norm is used to control the scaling and norm choice for each variable. More...
 

Protected Member Functions

void reduce_error (std::vector< ErrorVectorReal > &error_per_cell, const Parallel::Communicator &comm) const
 This method takes the local error contributions in error_per_cell from each processor and combines them to get the global error vector. More...
 

Private Member Functions

Real find_squared_element_error (const System &system, const std::string &var_name, const Elem *elem, const DenseVector< Number > &Uelem, FEBase *fe, MeshFunction *fine_values) const
 Helper method for calculating on each element. More...
 
void clear_functors ()
 Helper method for cleanup. More...
 

Private Attributes

ValueFunctionPointer _exact_value
 Function pointer to user-provided function which computes the exact value of the solution. More...
 
GradientFunctionPointer _exact_deriv
 Function pointer to user-provided function which computes the exact derivative of the solution. More...
 
HessianFunctionPointer _exact_hessian
 Function pointer to user-provided function which computes the exact hessian of the solution. More...
 
std::vector< std::unique_ptr< FunctionBase< Number > > > _exact_values
 User-provided functors which compute the exact value of the solution for each system. More...
 
std::vector< std::unique_ptr< FunctionBase< Gradient > > > _exact_derivs
 User-provided functors which compute the exact derivative of the solution for each system. More...
 
std::vector< std::unique_ptr< FunctionBase< Tensor > > > _exact_hessians
 User-provided functors which compute the exact hessians of the solution for each system. More...
 
EquationSystems_equation_systems_fine
 Constant pointer to the EquationSystems object containing a fine grid solution. More...
 
int _extra_order
 Extra order to use for quadrature rule. More...
 

Detailed Description

This class implements an "error estimator" based on the difference between the approximate and exact solution.

In theory the quadrature error in this estimate should be much lower than the approximation error in other estimates, so this estimator can be used to calculate effectivity.

Author
Roy Stogner
Date
2006

Definition at line 57 of file exact_error_estimator.h.

Member Typedef Documentation

◆ ErrorMap

typedef std::map<std::pair<const System *, unsigned int>, ErrorVector *> libMesh::ErrorEstimator::ErrorMap
inherited

When calculating many error vectors at once, we need a data structure to hold them all.

Definition at line 124 of file error_estimator.h.

◆ GradientFunctionPointer

typedef Gradient(* libMesh::ExactErrorEstimator::GradientFunctionPointer) (const Point &p, const Parameters &parameters, const std::string &sys_name, const std::string &unknown_name)

Attach an arbitrary function which computes the exact gradient of the solution at any point.

Definition at line 122 of file exact_error_estimator.h.

◆ HessianFunctionPointer

typedef Tensor(* libMesh::ExactErrorEstimator::HessianFunctionPointer) (const Point &p, const Parameters &parameters, const std::string &sys_name, const std::string &unknown_name)

Attach an arbitrary function which computes the exact second derivatives of the solution at any point.

Definition at line 145 of file exact_error_estimator.h.

◆ ValueFunctionPointer

typedef Number(* libMesh::ExactErrorEstimator::ValueFunctionPointer) (const Point &p, const Parameters &Parameters, const std::string &sys_name, const std::string &unknown_name)

Attach an arbitrary function which computes the exact value of the solution at any point.

Definition at line 99 of file exact_error_estimator.h.

Constructor & Destructor Documentation

◆ ExactErrorEstimator() [1/3]

libMesh::ExactErrorEstimator::ExactErrorEstimator ( )

Constructor.

Responsible for initializing the _bc_function function pointer to nullptr, and defaulting the norm type to H1.

◆ ExactErrorEstimator() [2/3]

libMesh::ExactErrorEstimator::ExactErrorEstimator ( const ExactErrorEstimator )
delete

This class cannot be (default) copy constructed/assigned because it has containers of unique_ptrs.

Explicitly deleting these functions is the best way to document this fact.

◆ ExactErrorEstimator() [3/3]

libMesh::ExactErrorEstimator::ExactErrorEstimator ( ExactErrorEstimator &&  )
default

Defaulted move ctor, move assignment operator, and destructor.

◆ ~ExactErrorEstimator()

virtual libMesh::ExactErrorEstimator::~ExactErrorEstimator ( )
virtualdefault

Member Function Documentation

◆ attach_exact_deriv() [1/2]

void libMesh::ExactErrorEstimator::attach_exact_deriv ( unsigned int  sys_num,
FunctionBase< Gradient > *  g 
)

Clone and attach an arbitrary functor which computes the exact gradient of the system sys_num solution at any point.

◆ attach_exact_deriv() [2/2]

void libMesh::ExactErrorEstimator::attach_exact_deriv ( GradientFunctionPointer  gptr)

◆ attach_exact_derivs()

void libMesh::ExactErrorEstimator::attach_exact_derivs ( std::vector< FunctionBase< Gradient > *>  g)

Clone and attach arbitrary functors which compute the exact gradients of the EquationSystems' solutions at any point.

◆ attach_exact_hessian() [1/2]

void libMesh::ExactErrorEstimator::attach_exact_hessian ( unsigned int  sys_num,
FunctionBase< Tensor > *  h 
)

Clone and attach an arbitrary functor which computes the exact second derivatives of the system sys_num solution at any point.

◆ attach_exact_hessian() [2/2]

void libMesh::ExactErrorEstimator::attach_exact_hessian ( HessianFunctionPointer  hptr)

◆ attach_exact_hessians()

void libMesh::ExactErrorEstimator::attach_exact_hessians ( std::vector< FunctionBase< Tensor > *>  h)

Clone and attach arbitrary functors which compute the exact second derivatives of the EquationSystems' solutions at any point.

◆ attach_exact_value() [1/2]

void libMesh::ExactErrorEstimator::attach_exact_value ( unsigned int  sys_num,
FunctionBase< Number > *  f 
)

Clone and attach an arbitrary functor which computes the exact value of the system sys_num solution at any point.

◆ attach_exact_value() [2/2]

void libMesh::ExactErrorEstimator::attach_exact_value ( ValueFunctionPointer  fptr)

◆ attach_exact_values()

void libMesh::ExactErrorEstimator::attach_exact_values ( std::vector< FunctionBase< Number > *>  f)

Clone and attach arbitrary functors which compute the exact values of the EquationSystems' solutions at any point.

◆ attach_reference_solution()

void libMesh::ExactErrorEstimator::attach_reference_solution ( EquationSystems es_fine)

Attach function similar to system.h which allows the user to attach a second EquationSystems object with a reference fine grid solution.

◆ clear_functors()

void libMesh::ExactErrorEstimator::clear_functors ( )
private

Helper method for cleanup.

◆ estimate_error()

virtual void libMesh::ExactErrorEstimator::estimate_error ( const System system,
ErrorVector error_per_cell,
const NumericVector< Number > *  solution_vector = nullptr,
bool  estimate_parent_error = false 
)
overridevirtual

This function uses the exact solution function to estimate the error on each cell.

The estimated error is output in the vector error_per_cell

Implements libMesh::ErrorEstimator.

◆ estimate_errors() [1/2]

virtual void libMesh::ErrorEstimator::estimate_errors ( const EquationSystems equation_systems,
ErrorVector error_per_cell,
const std::map< const System *, SystemNorm > &  error_norms,
const std::map< const System *, const NumericVector< Number > *> *  solution_vectors = nullptr,
bool  estimate_parent_error = false 
)
virtualinherited

This virtual function can be redefined in derived classes, but by default computes the sum of the error_per_cell for each system in the equation_systems.

Currently this function ignores the error_norm member variable, and uses the function argument error_norms instead.

This function is named estimate_errors instead of estimate_error because otherwise C++ can get confused.

Reimplemented in libMesh::UniformRefinementEstimator.

◆ estimate_errors() [2/2]

virtual void libMesh::ErrorEstimator::estimate_errors ( const EquationSystems equation_systems,
ErrorMap errors_per_cell,
const std::map< const System *, const NumericVector< Number > *> *  solution_vectors = nullptr,
bool  estimate_parent_error = false 
)
virtualinherited

This virtual function can be redefined in derived classes, but by default it calls estimate_error repeatedly to calculate the requested error vectors.

Currently this function ignores the error_norm.weight() values because it calculates each variable's error individually, unscaled.

The user selects which errors get computed by filling a map with error vectors: If errors_per_cell[&system][v] exists, it will be filled with the error values in variable v of system

Reimplemented in libMesh::UniformRefinementEstimator.

◆ extra_quadrature_order()

void libMesh::ExactErrorEstimator::extra_quadrature_order ( const int  extraorder)

Increases or decreases the order of the quadrature rule used for numerical integration.

Definition at line 163 of file exact_error_estimator.h.

References _extra_order.

164  { _extra_order = extraorder; }
int _extra_order
Extra order to use for quadrature rule.

◆ find_squared_element_error()

Real libMesh::ExactErrorEstimator::find_squared_element_error ( const System system,
const std::string &  var_name,
const Elem elem,
const DenseVector< Number > &  Uelem,
FEBase fe,
MeshFunction fine_values 
) const
private

Helper method for calculating on each element.

◆ operator=() [1/2]

ExactErrorEstimator& libMesh::ExactErrorEstimator::operator= ( const ExactErrorEstimator )
delete

◆ operator=() [2/2]

ExactErrorEstimator& libMesh::ExactErrorEstimator::operator= ( ExactErrorEstimator &&  )
default

◆ reduce_error()

void libMesh::ErrorEstimator::reduce_error ( std::vector< ErrorVectorReal > &  error_per_cell,
const Parallel::Communicator comm 
) const
protectedinherited

This method takes the local error contributions in error_per_cell from each processor and combines them to get the global error vector.

◆ type()

virtual ErrorEstimatorType libMesh::ExactErrorEstimator::type ( ) const
overridevirtual
Returns
The type for the ErrorEstimator subclass.

Implements libMesh::ErrorEstimator.

Member Data Documentation

◆ _equation_systems_fine

EquationSystems* libMesh::ExactErrorEstimator::_equation_systems_fine
private

Constant pointer to the EquationSystems object containing a fine grid solution.

Definition at line 229 of file exact_error_estimator.h.

◆ _exact_deriv

GradientFunctionPointer libMesh::ExactErrorEstimator::_exact_deriv
private

Function pointer to user-provided function which computes the exact derivative of the solution.

Definition at line 199 of file exact_error_estimator.h.

◆ _exact_derivs

std::vector<std::unique_ptr<FunctionBase<Gradient> > > libMesh::ExactErrorEstimator::_exact_derivs
private

User-provided functors which compute the exact derivative of the solution for each system.

Definition at line 217 of file exact_error_estimator.h.

◆ _exact_hessian

HessianFunctionPointer libMesh::ExactErrorEstimator::_exact_hessian
private

Function pointer to user-provided function which computes the exact hessian of the solution.

Definition at line 205 of file exact_error_estimator.h.

◆ _exact_hessians

std::vector<std::unique_ptr<FunctionBase<Tensor> > > libMesh::ExactErrorEstimator::_exact_hessians
private

User-provided functors which compute the exact hessians of the solution for each system.

Definition at line 223 of file exact_error_estimator.h.

◆ _exact_value

ValueFunctionPointer libMesh::ExactErrorEstimator::_exact_value
private

Function pointer to user-provided function which computes the exact value of the solution.

Definition at line 193 of file exact_error_estimator.h.

◆ _exact_values

std::vector<std::unique_ptr<FunctionBase<Number> > > libMesh::ExactErrorEstimator::_exact_values
private

User-provided functors which compute the exact value of the solution for each system.

Definition at line 211 of file exact_error_estimator.h.

◆ _extra_order

int libMesh::ExactErrorEstimator::_extra_order
private

Extra order to use for quadrature rule.

Definition at line 249 of file exact_error_estimator.h.

Referenced by extra_quadrature_order().

◆ error_norm

SystemNorm libMesh::ErrorEstimator::error_norm
inherited

When estimating the error in a single system, the error_norm is used to control the scaling and norm choice for each variable.

Not all estimators will support all norm choices. The default scaling is for all variables to be weighted equally. The default norm choice depends on the error estimator.

Part of this functionality was supported via component_scale and sobolev_order in older libMesh versions, and a small part was supported via component_mask in even older versions. Hopefully the encapsulation here will allow us to avoid changing this API again.

Definition at line 161 of file error_estimator.h.


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