Skip to content
Snippets Groups Projects
Commit 41bba997 authored by Robert Klöfkorn's avatar Robert Klöfkorn
Browse files

Added default implementation of eval, jacobian,

which use the evaluate interface and is a bit easier to use.

[[Imported from SVN: r127]]
parent 7ce20a3f
No related branches found
No related tags found
No related merge requests found
......@@ -15,7 +15,7 @@ namespace Dune {
public:
typedef typename FunctionSpaceType::Domain Domain ;
typedef typename FunctionSpaceType::Range Range ;
typedef typename FunctionSpaceType::GradientRange GradientRange;
typedef typename FunctionSpaceType::JacobianRange JacobianRange;
typedef typename FunctionSpaceType::HessianRange HessianRange;
typedef FunctionSpaceType FunctionSpace;
......
......@@ -13,7 +13,8 @@ namespace Dune {
typedef DomainFieldType DomainField ;
typedef RangeFieldType RangeField ;
typedef Mat < n, m, RangeField> GradientRange;
typedef Mat < n, m, RangeField> JacobianRange;
typedef Vec < m, Mat< n, n, RangeField> > HessianRange ;
typedef Vec<n, DomainField> Domain;
......
......@@ -33,7 +33,7 @@ namespace Dune {
enum { n = (dim > 0) ? dim : 1 };
//! know length
enum { dimension = dim};
enum { dimension = dim };
//! Constructor making uninizialized vector
Vec() {}
......@@ -211,6 +211,10 @@ namespace Dune {
public:
enum { m = (dim > 0) ? dim : 1 };
//! remember the dimension of the matrix
enum { dimRow = dim };
enum { dimCol = n };
//! Constructor making uninizialized matrix
Mat() {}
......
......@@ -86,7 +86,7 @@ namespace Dune {
typedef typename FunctionSpaceType::Domain Domain ;
typedef typename FunctionSpaceType::Range Range ;
typedef typename FunctionSpaceType::GradientRange GradientRange;
typedef typename FunctionSpaceType::JacobianRange JacobianRange;
typedef typename FunctionSpaceType::HessianRange HessianRange;
enum { DimDomain = FunctionSpaceType::DimDomain };
......@@ -141,6 +141,86 @@ namespace Dune {
};
//*************************************************************************
//
//
//
//
//
//
//*************************************************************************
template<class FunctionSpaceType, class BaseFunctionSetImp>
class BaseFunctionSetDefault
: public BaseFunctionSetInterface < FunctionSpaceType , BaseFunctionSetImp>
{
enum { dimRow = JacobianRange::dimRow };
enum { dimCol = JacobianRange::dimCol };
public:
//! set the default diffVar Types
BaseFunctionSetDefault ( FunctionSpaceType & f ) :
BaseFunctionSetInterface < FunctionSpaceType , BaseFunctionSetImp> (f)
{
for(int i=0; i<dimCol; i++)
jacobianDiffVar_[i] = i;
};
//! default evaluate using the evaluate interface
void eval ( int baseFunct, const Domain & x, Range & phi ) const
{
asImp().evaluate(baseFunct, diffVariable_ , x , phi);
return;
}
//! default implementation for evaluation
template <class QuadratureType>
void eval ( int baseFunct, QuadratureType & quad, int quadPoint, Range & phi ) const
{
asImp().evaluate( baseFunct, diffVariable_ , quad, quadPoint, phi );
return;
}
//! default evaluate using the evaluate interface
void jacobian ( int baseFunct, const Domain & x, JacobianRange & phi ) const
{
Range tmp;
for(int i=0; i<dimCol; i++)
{
asImp().evaluate( baseFunct, jacobianDiffVar_[i] , x , tmp );
for(int j=0; j<dimRow; j++)
phi(i,j) = tmp(j);
}
return;
}
//! default implementation of evaluation the gradient
template <class QuadratureType>
void jacobian ( int baseFunct, QuadratureType & quad,
int quadPoint, JacobianRange & phi ) const
{
Range tmp;
for(int i=0; i<dimCol; i++)
{
asImp().evaluate( baseFunct, jacobianDiffVar_[i] , quad, quadPoint, tmp );
for(int j=0; j<dimRow; j++)
phi(i,j) = tmp(j);
}
return;
}
private:
//! just diffVariable for evaluation of the functions
const Vec<0,deriType> diffVariable_;
Vec<1,deriType> jacobianDiffVar_[dimCol];
//! Barton-Nackman trick
BaseFunctionSetImp &asImp() { return static_cast<BaseFunctionSetImp&>(*this); }
const BaseFunctionSetImp &asImp() const
{ return static_cast<const BaseFunctionSetImp&>(*this); }
};
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment