Saddle-Point
Loading...
Searching...
No Matches
RHSFunction< dim > Class Template Reference

Analytic right-hand-side function for the saddle-point Laplace problem. More...

#include <rhs_function.h>

Inheritance diagram for RHSFunction< dim >:
Collaboration diagram for RHSFunction< dim >:

Public Types

enum  FunctionType {
  TYPE_X_Y , TYPE_EXP_COS , TYPE_ZERO , TYPE_SIN_SIN ,
  TYPE_R_COS
}
 Selector for the analytic right-hand-side expression to use. More...
 

Public Member Functions

 RHSFunction (FunctionType type)
 Construct a single-component RHSFunction of the requested type.
 
virtual double value (const Point< dim > &p, const unsigned int component=0) const override
 Evaluate the analytic right-hand side at point p.
 
virtual Tensor< 1, dim > gradient (const Point< dim > &p, const unsigned int component=0) const override
 Evaluate the analytic gradient at point p.
 

Detailed Description

template<int dim>
class RHSFunction< dim >

Analytic right-hand-side function for the saddle-point Laplace problem.

This class is derived from the abstract base class dealii::Function<dim>, which declares the common interface that all "functions of position" have to follow in deal.II. The virtual keyword on the base methods means that the function there can be overridden by derived classes; the override keyword means that we know the function has been declared as part of the base class, so the compiler can verify the signature.

The actual analytic expression is selected at construction time through the FunctionType enum. Several test cases were used during development:

  • TYPE_ZERO : \(f \equiv 0\).
  • TYPE_SIN_SIN : \(f(x,y) = 2\sin(x)\sin(y)\) (alternate forms with \(\pi\) scaling are commented out in the source).
  • TYPE_X_Y : \(f(x,y) = -10xy\), used as the boundary forcing \(g\).
  • TYPE_R_COS : a polar-coordinate test case \(f(r,\theta) = (r - 1/r - 1/(rR^2))\cos(\theta/R)\) that was ultimately not used for the manufactured solution but is left in for reference.
Template Parameters
dimSpatial dimension (the implementation assumes dim == 2).

Member Enumeration Documentation

◆ FunctionType

template<int dim>
enum RHSFunction::FunctionType

Selector for the analytic right-hand-side expression to use.

Enumerator
TYPE_X_Y 

\(f(x,y) = -10\,x\,y\).

TYPE_EXP_COS 

Reserved for an \(e^x\cos y\) variant (not currently implemented in value()).

TYPE_ZERO 

The zero function \(f \equiv 0\).

TYPE_SIN_SIN 

\(f(x,y) = 2\sin(x)\sin(y)\).

TYPE_R_COS 

Polar test case \((r - 1/r - 1/(r R^2))\cos(\theta/R)\).

Constructor & Destructor Documentation

◆ RHSFunction()

template<int dim>
RHSFunction< dim >::RHSFunction ( FunctionType  type)
inline

Construct a single-component RHSFunction of the requested type.

Parameters
[in]typeOne of FunctionType, selects which analytic expression value() and gradient() will return.

Member Function Documentation

◆ gradient()

template<int dim>
Tensor< 1, dim > RHSFunction< dim >::gradient ( const Point< dim > &  p,
const unsigned int  component = 0 
) const
overridevirtual

Evaluate the analytic gradient at point p.

Returns the analytic gradient of the function selected by FunctionType. For TYPE_SIN_SIN the formula uses the \(\pi\)-scaled variant in the source code; see the inline definition below for the exact expressions.

Parameters
[in]pPoint at which to evaluate the gradient.
[in]componentComponent index (unused; the class is scalar).
Returns
Rank-1 tensor representing the gradient at p.

◆ value()

template<int dim>
double RHSFunction< dim >::value ( const Point< dim > &  p,
const unsigned int  component = 0 
) const
overridevirtual

Evaluate the analytic right-hand side at point p.

The actual formula returned depends on the FunctionType passed to the constructor. See the class description for the analytic expressions.

Parameters
[in]pPoint at which to evaluate the function.
[in]componentComponent index (unused; the class is scalar).
Returns
The value of the chosen analytic function at p.

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