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

This class handles the computation of the L2 and/or H1 error for the Systems in the EquationSystems object which is passed to it. More...

#include <exact_solution.h>

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...
 

Public Member Functions

 ExactSolution (const EquationSystems &es)
 Constructor. More...
 
 ExactSolution (const ExactSolution &)=delete
 The copy constructor and copy/move assignment operators are deleted. More...
 
ExactSolutionoperator= (const ExactSolution &)=delete
 
ExactSolutionoperator= (ExactSolution &&)=delete
 
 ExactSolution (ExactSolution &&)
 Move constructor and destructor are defaulted out-of-line (in the C file) to play nicely with our forward declarations. More...
 
 ~ExactSolution ()
 
void attach_reference_solution (const 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 attach_exact_values (const 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 (const 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 extra_quadrature_order (const int extraorder)
 Increases or decreases the order of the quadrature rule used for numerical integration. More...
 
void compute_error (const std::string &sys_name, const std::string &unknown_name)
 Computes and stores the error in the solution value e = u-u_h, the gradient grad(e) = grad(u) - grad(u_h), and possibly the hessian grad(grad(e)) = grad(grad(u)) - grad(grad(u_h)). More...
 
Real l2_error (const std::string &sys_name, const std::string &unknown_name)
 
Real l1_error (const std::string &sys_name, const std::string &unknown_name)
 
Real l_inf_error (const std::string &sys_name, const std::string &unknown_name)
 
Real h1_error (const std::string &sys_name, const std::string &unknown_name)
 
Real hcurl_error (const std::string &sys_name, const std::string &unknown_name)
 
Real hdiv_error (const std::string &sys_name, const std::string &unknown_name)
 
Real h2_error (const std::string &sys_name, const std::string &unknown_name)
 
Real error_norm (const std::string &sys_name, const std::string &unknown_name, const FEMNormType &norm)
 

Private Types

typedef std::map< std::string, std::vector< Real > > SystemErrorMap
 Data structure which stores the errors: ||e|| = ||u - u_h|| ||grad(e)|| = ||grad(u) - grad(u_h)|| for each unknown in a single system. More...
 

Private Member Functions

template<typename OutputShape >
void _compute_error (const std::string &sys_name, const std::string &unknown_name, std::vector< Real > &error_vals)
 This function computes the error (in the solution and its first derivative) for a single unknown in a single system. More...
 
std::vector< Real > & _check_inputs (const std::string &sys_name, const std::string &unknown_name)
 This function is responsible for checking the validity of the sys_name and unknown_name inputs. More...
 

Private Attributes

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...
 
std::map< std::string, SystemErrorMap_errors
 A map of SystemErrorMaps, which contains entries for each system in the EquationSystems object. More...
 
const EquationSystems_equation_systems
 Constant reference to the EquationSystems object used for the simulation. More...
 
const EquationSystems_equation_systems_fine
 Constant pointer to the EquationSystems object containing the fine grid solution. More...
 
int _extra_order
 Extra order to use for quadrature rule. More...
 

Detailed Description

This class handles the computation of the L2 and/or H1 error for the Systems in the EquationSystems object which is passed to it.

Note
For this to be useful, the user must attach at least one, and possibly two, functions which can compute the exact solution and its derivative for any component of any system. These are the exact_value and exact_deriv functions below.
Author
Benjamin S. Kirk
John W. Peterson (modifications for libmesh)
Date
2004

Definition at line 72 of file exact_solution.h.

Member Typedef Documentation

◆ GradientFunctionPointer

typedef Gradient(* libMesh::ExactSolution::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 148 of file exact_solution.h.

◆ HessianFunctionPointer

typedef Tensor(* libMesh::ExactSolution::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 171 of file exact_solution.h.

◆ SystemErrorMap

typedef std::map<std::string, std::vector<Real> > libMesh::ExactSolution::SystemErrorMap
private

Data structure which stores the errors: ||e|| = ||u - u_h|| ||grad(e)|| = ||grad(u) - grad(u_h)|| for each unknown in a single system.

The name of the unknown is the key for the map.

Definition at line 336 of file exact_solution.h.

◆ ValueFunctionPointer

typedef Number(* libMesh::ExactSolution::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 125 of file exact_solution.h.

Constructor & Destructor Documentation

◆ ExactSolution() [1/3]

libMesh::ExactSolution::ExactSolution ( const EquationSystems es)
explicit

Constructor.

The ExactSolution object must be initialized with an EquationSystems object.

◆ ExactSolution() [2/3]

libMesh::ExactSolution::ExactSolution ( const ExactSolution )
delete

The copy constructor and copy/move assignment operators are deleted.

This class has containers of unique_ptrs so it can't be default (shallow) copied, and it has a const reference so it can't be assigned to after creation.

◆ ExactSolution() [3/3]

libMesh::ExactSolution::ExactSolution ( ExactSolution &&  )

Move constructor and destructor are defaulted out-of-line (in the C file) to play nicely with our forward declarations.

◆ ~ExactSolution()

libMesh::ExactSolution::~ExactSolution ( )

Member Function Documentation

◆ _check_inputs()

std::vector<Real>& libMesh::ExactSolution::_check_inputs ( const std::string &  sys_name,
const std::string &  unknown_name 
)
private

This function is responsible for checking the validity of the sys_name and unknown_name inputs.

Returns
A reference to the proper vector for storing the values.

◆ _compute_error()

template<typename OutputShape >
void libMesh::ExactSolution::_compute_error ( const std::string &  sys_name,
const std::string &  unknown_name,
std::vector< Real > &  error_vals 
)
private

This function computes the error (in the solution and its first derivative) for a single unknown in a single system.

It is a private function since it is used by the implementation when solving for several unknowns in several systems.

◆ attach_exact_deriv() [1/2]

void libMesh::ExactSolution::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::ExactSolution::attach_exact_deriv ( GradientFunctionPointer  gptr)

◆ attach_exact_derivs()

void libMesh::ExactSolution::attach_exact_derivs ( const 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::ExactSolution::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::ExactSolution::attach_exact_hessian ( HessianFunctionPointer  hptr)

◆ attach_exact_hessians()

void libMesh::ExactSolution::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::ExactSolution::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::ExactSolution::attach_exact_value ( ValueFunctionPointer  fptr)

◆ attach_exact_values()

void libMesh::ExactSolution::attach_exact_values ( const 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::ExactSolution::attach_reference_solution ( const 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.

◆ compute_error()

void libMesh::ExactSolution::compute_error ( const std::string &  sys_name,
const std::string &  unknown_name 
)

Computes and stores the error in the solution value e = u-u_h, the gradient grad(e) = grad(u) - grad(u_h), and possibly the hessian grad(grad(e)) = grad(grad(u)) - grad(grad(u_h)).

Does not return any value. For that you need to call the l2_error(), h1_error() or h2_error() functions respectively.

◆ error_norm()

Real libMesh::ExactSolution::error_norm ( const std::string &  sys_name,
const std::string &  unknown_name,
const FEMNormType norm 
)
Returns
The error in the requested norm for the system sys_name for the unknown unknown_name.
Note
No error computations are actually performed, you must call compute_error() for that.
The result is not exact, but an approximation based on the chosen quadrature rule.

◆ extra_quadrature_order()

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

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

Definition at line 181 of file exact_solution.h.

References _extra_order.

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

◆ h1_error()

Real libMesh::ExactSolution::h1_error ( const std::string &  sys_name,
const std::string &  unknown_name 
)
Returns
The H1 error for the system sys_name for the unknown unknown_name.
Note
No error computations are actually performed, you must call compute_error() for that.

◆ h2_error()

Real libMesh::ExactSolution::h2_error ( const std::string &  sys_name,
const std::string &  unknown_name 
)
Returns
The H2 error for the system sys_name for the unknown unknown_name.
Note
No error computations are actually performed, you must call compute_error() for that.

◆ hcurl_error()

Real libMesh::ExactSolution::hcurl_error ( const std::string &  sys_name,
const std::string &  unknown_name 
)
Returns
The H(curl) error for the system sys_name for the unknown unknown_name.
Note
No error computations are actually performed, you must call compute_error() for that.
This is only valid for vector-valued elements. An error is thrown if requested for scalar-valued elements.

◆ hdiv_error()

Real libMesh::ExactSolution::hdiv_error ( const std::string &  sys_name,
const std::string &  unknown_name 
)
Returns
The H(div) error for the system sys_name for the unknown unknown_name.
Note
No error computations are actually performed, you must call compute_error() for that.
This is only valid for vector-valued elements. An error is thrown if requested for scalar-valued elements.

◆ l1_error()

Real libMesh::ExactSolution::l1_error ( const std::string &  sys_name,
const std::string &  unknown_name 
)
Returns
The integrated L1 error for the system sys_name for the unknown unknown_name.
Note
No error computations are actually performed, you must call compute_error() for that.

◆ l2_error()

Real libMesh::ExactSolution::l2_error ( const std::string &  sys_name,
const std::string &  unknown_name 
)
Returns
The integrated L2 error for the system sys_name for the unknown unknown_name.
Note
No error computations are actually performed, you must call compute_error() for that.

◆ l_inf_error()

Real libMesh::ExactSolution::l_inf_error ( const std::string &  sys_name,
const std::string &  unknown_name 
)
Returns
The L_INF error for the system sys_name for the unknown unknown_name.
Note
No error computations are actually performed, you must call compute_error() for that.
The result (as for the other norms as well) is not exact, but an approximation based on the chosen quadrature rule: to compute it, we take the max of the absolute value of the error over all the quadrature points.

◆ operator=() [1/2]

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

◆ operator=() [2/2]

ExactSolution& libMesh::ExactSolution::operator= ( ExactSolution &&  )
delete

Member Data Documentation

◆ _equation_systems

const EquationSystems& libMesh::ExactSolution::_equation_systems
private

Constant reference to the EquationSystems object used for the simulation.

Definition at line 350 of file exact_solution.h.

◆ _equation_systems_fine

const EquationSystems* libMesh::ExactSolution::_equation_systems_fine
private

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

Definition at line 356 of file exact_solution.h.

◆ _errors

std::map<std::string, SystemErrorMap> libMesh::ExactSolution::_errors
private

A map of SystemErrorMaps, which contains entries for each system in the EquationSystems object.

This is required, since it is possible for two systems to have unknowns with the same name.

Definition at line 344 of file exact_solution.h.

◆ _exact_derivs

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

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

Definition at line 320 of file exact_solution.h.

◆ _exact_hessians

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

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

Definition at line 326 of file exact_solution.h.

◆ _exact_values

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

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

Definition at line 314 of file exact_solution.h.

◆ _extra_order

int libMesh::ExactSolution::_extra_order
private

Extra order to use for quadrature rule.

Definition at line 361 of file exact_solution.h.

Referenced by extra_quadrature_order().


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