dune-fem  2.4.1-rc
Classes | Public Types | Public Member Functions | Protected Member Functions | Static Protected Member Functions | Related Functions | List of all members
Dune::Fem::DiscreteFunctionInterface< Impl > Class Template Reference

#include </local/tomalk/somewhere/tmp/dune-fem/dune/fem/function/common/discretefunction.hh>

Inheritance diagram for Dune::Fem::DiscreteFunctionInterface< Impl >:
Inheritance graph

Classes

struct  CommDataHandle
 

Public Types

enum  { blockSize = DiscreteFunctionSpaceType::localBlockSize }
 size of the dof blocks More...
 
typedef DiscreteFunctionTraits< Impl > Traits
 type of the traits More...
 
typedef Traits::DiscreteFunctionType DiscreteFunctionType
 type of the implementaton (Barton-Nackman) More...
 
typedef Traits::DiscreteFunctionSpaceType DiscreteFunctionSpaceType
 type of associated discrete function space More...
 
typedef DiscreteFunctionInterface< Impl > DiscreteFunctionInterfaceType
 type of the discrete function interface (this type) More...
 
typedef DiscreteFunctionSpaceType::DomainFieldType DomainFieldType
 type of domain field, i.e. type of coordinate component More...
 
typedef DiscreteFunctionSpaceType::RangeFieldType RangeFieldType
 type of range field, i.e. dof type More...
 
typedef DiscreteFunctionSpaceType::DomainType DomainType
 type of domain, i.e. type of coordinates More...
 
typedef DiscreteFunctionSpaceType::RangeType RangeType
 type of range, i.e. result of evaluation More...
 
typedef DiscreteFunctionSpaceType::JacobianRangeType JacobianRangeType
 type of jacobian, i.e. type of evaluated gradient More...
 
typedef DiscreteFunctionSpaceType::GridPartType GridPartType
 type of the underlying grid part More...
 
typedef DiscreteFunctionSpaceType::GridType GridType
 Type of the underlying grid. More...
 
typedef Traits::LocalFunctionType LocalFunctionType
 type of local functions More...
 
typedef Traits::DofVectorType DofVectorType
 Type of the dof vector used in the discrete function implementation. More...
 
typedef Traits::DofIteratorType DofIteratorType
 Type of the dof iterator used in the discrete function implementation. More...
 
typedef Traits::ConstDofIteratorType ConstDofIteratorType
 Type of the constantdof iterator used in the discrete function implementation. More...
 
typedef Traits::DofType DofType
 
typedef Traits::DofBlockType DofBlockType
 
typedef Traits::ConstDofBlockType ConstDofBlockType
 
typedef Traits::DofBlockPtrType DofBlockPtrType
 
typedef Traits::ConstDofBlockPtrType ConstDofBlockPtrType
 
typedef BaseType::MappingType MappingType
 type of mapping base class for this discrete function More...
 
typedef DiscreteFunctionSpaceType::EntityType EntityType
 type of entity local functions are defined on More...
 
typedef LoadBalanceLeafData< ThisTypeDefaultLoadBalanceContainsCheckType
 
typedef DiscreteFunctionTraits< Impl >::DiscreteFunctionSpaceType::FunctionSpaceType FunctionSpaceType
 type of function space this function belongs to More...
 
typedef Impl FunctionType
 type of the implementation (Barton-Nackman) More...
 
typedef FunctionSpaceType::HessianRangeType HessianRangeType
 hessian type More...
 

Public Member Functions

DofVectorTypedofVector ()
 
const DofVectorTypedofVector () const
 
const std::string & name () const
 obtain the name of the discrete function More...
 
const DiscreteFunctionSpaceTypespace () const
 obtain a reference to the corresponding DiscreteFunctionSpace More...
 
const GridPartTypegridPart () const
 obtain a reference to the underlying grid part More...
 
LocalFunctionType localFunction (const EntityType &entity)
 obtain a local function for an entity (read-write) More...
 
const LocalFunctionType localFunction (const EntityType &entity) const
 obtain a local function for an entity (read-write) More...
 
void clear ()
 set all degrees of freedom to zero More...
 
int size () const
 obtain total number of DoFs More...
 
int blocks () const
 obtain total number of blocks, i.e. size / blockSize. More...
 
ConstDofBlockPtrType block (unsigned int index) const
 obtain pointer to block of discrete function with block number index More...
 
DofBlockPtrType block (unsigned int index)
 obtain pointer to block of discrete function with block number index (read-only) More...
 
ConstDofIteratorType dbegin () const
 obtain an iterator pointing to the first DoF (read-only) More...
 
ConstDofIteratorType dend () const
 obtain an iterator pointing behind the last DoF (read-only) More...
 
DofIteratorType dbegin ()
 obtain an iterator pointing to the first DoF (read-write) More...
 
DofIteratorType dend ()
 obtain an iterator pointing behind the last DoF (read-write) More...
 
RangeFieldTypeallocDofPointer () const
 allocate a pointer to a consecutive array storing the DoFs More...
 
void freeDofPointer (RangeFieldType *dofPointer)
 allocate a pointer to a consecutive array storing the DoFs More...
 
void freeDofPointerNoCopy (const RangeFieldType *dofPointer) const
 allocate a pointer to a consecutive array storing the DoFs More...
 
void axpy (const RangeFieldType &s, const DiscreteFunctionInterfaceType &g)
 axpy operation More...
 
template<class DFType >
RangeFieldType scalarProductDofs (const DiscreteFunctionInterface< DFType > &other) const
 Scalar product between the DoFs of two discrete functions. More...
 
Dune::FieldTraits< RangeFieldType >::real_type normSquaredDofs () const
 Squared small l^2 norm of all dofs. More...
 
void print (std::ostream &out) const
 print all DoFs to a stream (for debugging purposes) More...
 
bool dofsValid () const
 check for NaNs More...
 
template<class DFType >
void assign (const DiscreteFunctionInterface< DFType > &g)
 assign the DoFs of another discrete function to this one More...
 
template<class Operation >
CommDataHandle< Operation >::Type dataHandle (const Operation *operation)
 return reference to data handle object More...
 
void communicate ()
 do default communication of space for this discrete function More...
 
template<class DFType >
DiscreteFunctionTypeoperator+= (const DiscreteFunctionInterface< DFType > &g)
 add another discrete function to this one More...
 
template<class DFType >
DiscreteFunctionTypeoperator-= (const DiscreteFunctionInterface< DFType > &g)
 substract all degrees of freedom from given discrete function using the dof iterators More...
 
DiscreteFunctionTypeoperator*= (const RangeFieldType &scalar)
 multiply all DoFs by a scalar factor More...
 
DiscreteFunctionTypeoperator/= (const RangeFieldType &scalar)
 devide all DoFs by a scalar factor More...
 
template<class StreamTraits >
void read (InStreamInterface< StreamTraits > &in)
 read the discrete function from a stream More...
 
template<class StreamTraits >
void write (OutStreamInterface< StreamTraits > &out) const
 write the discrete function into a stream More...
 
void enableDofCompression ()
 Enable this discrete function for dof compression, i.e. during grdi changes a dof compression is done when the DofManagers compress is called. More...
 
DefaultLoadBalanceContainsCheckType defaultLoadBalanceContainsCheck () const
 
virtual void operator() (const DomainType &arg, RangeType &dest) const
 application operator call evaluate More...
 
void operator() (const DomainType &arg, RangeType &dest) const
 Application operator that applies all operators in the linear combination stack. More...
 
void evaluate (const DomainType &x, RangeType &value) const
 evaluate the function More...
 
void jacobian (const DomainType &x, JacobianRangeType &jacobian) const
 evaluate the Jacobian of the function More...
 
void hessian (const DomainType &x, HessianRangeType &hessian) const
 evaluate the hessian of the function More...
 

Protected Member Functions

 DiscreteFunctionInterface ()
 default constructor More...
 
const Impl & asImp () const
 
Impl & asImp ()
 

Static Protected Member Functions

static const Impl & asImp (const ThisType &other)
 
static Impl & asImp (ThisType &other)
 

Related Functions

(Note that these are not member functions.)

template<class Impl >
std::ostream & operator<< (std::ostream &out, const DiscreteFunctionInterface< Impl > &df)
 write a discrete function into an STL stream More...
 

Detailed Description

template<class Impl>
class Dune::Fem::DiscreteFunctionInterface< Impl >

This is the interface of a discrete function which describes the features of a discrete function. It contains a local function and a dof iterator which can iterate over all dofs of one level. Via the method access the local dofs and basis functions can be accessed for a given entity. The DOF-Iterators are STL-like Iterators, i.e. they can be dereferenced giving the corresponding DOF.

An interface class:

Member Typedef Documentation

Type of the constantdof iterator used in the discrete function implementation.

type of the discrete function interface (this type)

type of associated discrete function space

type of the implementaton (Barton-Nackman)

template<class Impl>
typedef Traits :: DofBlockType Dune::Fem::DiscreteFunctionInterface< Impl >::DofBlockType

Type of the dof iterator used in the discrete function implementation.

template<class Impl>
typedef Traits :: DofType Dune::Fem::DiscreteFunctionInterface< Impl >::DofType
template<class Impl>
typedef Traits :: DofVectorType Dune::Fem::DiscreteFunctionInterface< Impl >::DofVectorType

Type of the dof vector used in the discrete function implementation.

type of domain field, i.e. type of coordinate component

type of domain, i.e. type of coordinates

type of entity local functions are defined on

typedef DiscreteFunctionTraits< Impl >::DiscreteFunctionSpaceType::FunctionSpaceType Dune::Fem::Function< DiscreteFunctionTraits< Impl >::DiscreteFunctionSpaceType::FunctionSpaceType , Impl >::FunctionSpaceType
inherited

type of function space this function belongs to

typedef Impl Dune::Fem::Function< DiscreteFunctionTraits< Impl >::DiscreteFunctionSpaceType::FunctionSpaceType , Impl >::FunctionType
inherited

type of the implementation (Barton-Nackman)

template<class Impl>
typedef DiscreteFunctionSpaceType::GridPartType Dune::Fem::DiscreteFunctionInterface< Impl >::GridPartType

type of the underlying grid part

Type of the underlying grid.

typedef FunctionSpaceType :: HessianRangeType Dune::Fem::Function< DiscreteFunctionTraits< Impl >::DiscreteFunctionSpaceType::FunctionSpaceType , Impl >::HessianRangeType
inherited

hessian type

type of jacobian, i.e. type of evaluated gradient

type of local functions

template<class Impl>
typedef BaseType :: MappingType Dune::Fem::DiscreteFunctionInterface< Impl >::MappingType

type of mapping base class for this discrete function

type of range field, i.e. dof type

type of range, i.e. result of evaluation

template<class Impl>
typedef DiscreteFunctionTraits< Impl > Dune::Fem::DiscreteFunctionInterface< Impl >::Traits

type of the traits

Member Enumeration Documentation

template<class Impl>
anonymous enum

size of the dof blocks

Enumerator
blockSize 

Constructor & Destructor Documentation

template<class Impl>
Dune::Fem::DiscreteFunctionInterface< Impl >::DiscreteFunctionInterface ( )
inlineprotected

default constructor

Member Function Documentation

template<class Impl>
RangeFieldType* Dune::Fem::DiscreteFunctionInterface< Impl >::allocDofPointer ( ) const
inline

allocate a pointer to a consecutive array storing the DoFs

To support external packages, it is often required to have the DoFs in a consecutive array. This function ensures this, making a copy if necessary.

Note
The allocated pointer has to be freed by freeDofPointer.
Only one DoF pointer may be allocated at a time.
Returns
a pointer to a consecutive copy of the DoF vector
static const Impl & Dune::Fem::BartonNackmanInterface< Function< DiscreteFunctionTraits< Impl >::DiscreteFunctionSpaceType::FunctionSpaceType, Impl > , Impl >::asImp ( const ThisType other)
inlinestaticprotectedinherited
static Impl & Dune::Fem::BartonNackmanInterface< Function< DiscreteFunctionTraits< Impl >::DiscreteFunctionSpaceType::FunctionSpaceType, Impl > , Impl >::asImp ( ThisType other)
inlinestaticprotectedinherited
const Impl & Dune::Fem::BartonNackmanInterface< Function< DiscreteFunctionTraits< Impl >::DiscreteFunctionSpaceType::FunctionSpaceType, Impl > , Impl >::asImp ( ) const
inlineprotectedinherited
Impl & Dune::Fem::BartonNackmanInterface< Function< DiscreteFunctionTraits< Impl >::DiscreteFunctionSpaceType::FunctionSpaceType, Impl > , Impl >::asImp ( )
inlineprotectedinherited
template<class Impl>
template<class DFType >
void Dune::Fem::DiscreteFunctionInterface< Impl >::assign ( const DiscreteFunctionInterface< DFType > &  g)
inline

assign the DoFs of another discrete function to this one

Parameters
[in]gdiscrete function which is copied
template<class Impl>
void Dune::Fem::DiscreteFunctionInterface< Impl >::axpy ( const RangeFieldType s,
const DiscreteFunctionInterfaceType g 
)
inline

axpy operation

Adds s * g to this discrete function.

Parameters
[in]sscalar value to scale g with
[in]gdiscrete function to add
template<class Impl>
ConstDofBlockPtrType Dune::Fem::DiscreteFunctionInterface< Impl >::block ( unsigned int  index) const
inline

obtain pointer to block of discrete function with block number index

Returns
a DoFBlockPtrType pointing to block index
template<class Impl>
DofBlockPtrType Dune::Fem::DiscreteFunctionInterface< Impl >::block ( unsigned int  index)
inline

obtain pointer to block of discrete function with block number index (read-only)

Returns
a DoFBlockPtrType pointing to block index (read-only)
template<class Impl>
int Dune::Fem::DiscreteFunctionInterface< Impl >::blocks ( ) const
inline

obtain total number of blocks, i.e. size / blockSize.

The number of blocks of DoFs (degrees of freedom) can also be seen as the size of the discrete function divided by the blockSize.

Returns
total number of DoFs blocks
template<class Impl>
void Dune::Fem::DiscreteFunctionInterface< Impl >::clear ( )
inline

set all degrees of freedom to zero

template<class Impl>
void Dune::Fem::DiscreteFunctionInterface< Impl >::communicate ( )
inline

do default communication of space for this discrete function

template<class Impl>
template<class Operation >
CommDataHandle< Operation >:: Type Dune::Fem::DiscreteFunctionInterface< Impl >::dataHandle ( const Operation *  operation)
inline

return reference to data handle object

template<class Impl>
ConstDofIteratorType Dune::Fem::DiscreteFunctionInterface< Impl >::dbegin ( ) const
inline
template<class Impl>
DofIteratorType Dune::Fem::DiscreteFunctionInterface< Impl >::dbegin ( )
inline

obtain an iterator pointing to the first DoF (read-write)

Returns
a DoF iterator pointing to first DoF (degre of freedom)
template<class Impl>
DefaultLoadBalanceContainsCheckType Dune::Fem::DiscreteFunctionInterface< Impl >::defaultLoadBalanceContainsCheck ( ) const
inline
template<class Impl>
ConstDofIteratorType Dune::Fem::DiscreteFunctionInterface< Impl >::dend ( ) const
inline

obtain an iterator pointing behind the last DoF (read-only)

Returns
a DoF iterator pointing behind the last DoF (degree of freedom)
template<class Impl>
DofIteratorType Dune::Fem::DiscreteFunctionInterface< Impl >::dend ( )
inline

obtain an iterator pointing behind the last DoF (read-write)

Returns
a DoF iterator pointing behind the last DoF (degree of freedom)
template<class Impl>
bool Dune::Fem::DiscreteFunctionInterface< Impl >::dofsValid ( ) const
inline

check for NaNs

Returns
if one of the DoFs is NaN false is returned, otherwise true
template<class Impl>
DofVectorType& Dune::Fem::DiscreteFunctionInterface< Impl >::dofVector ( )
inline
template<class Impl>
const DofVectorType& Dune::Fem::DiscreteFunctionInterface< Impl >::dofVector ( ) const
inline
template<class Impl>
void Dune::Fem::DiscreteFunctionInterface< Impl >::enableDofCompression ( )
inline

Enable this discrete function for dof compression, i.e. during grdi changes a dof compression is done when the DofManagers compress is called.

void Dune::Fem::Function< DiscreteFunctionTraits< Impl >::DiscreteFunctionSpaceType::FunctionSpaceType , Impl >::evaluate ( const DomainType x,
RangeType value 
) const
inlineinherited

evaluate the function

Parameters
[in]xevaluation point
[out]valuevalue of the function in x
template<class Impl>
void Dune::Fem::DiscreteFunctionInterface< Impl >::freeDofPointer ( RangeFieldType dofPointer)
inline

allocate a pointer to a consecutive array storing the DoFs

This method serves two purposes:

  • The user cannot know, if the DoF array returned by allocDofPointer has to be freed.
  • If the DoF array is just a copy, the DoFs shall be stored back into the discrete function.
Note
The pointer must have been allocated by allocDofPointer.
Only one DoF pointer may be allocated at a time.
Parameters
[in]dofPointerpointer to the dof array previously allocated by allocDofPointer
template<class Impl>
void Dune::Fem::DiscreteFunctionInterface< Impl >::freeDofPointerNoCopy ( const RangeFieldType dofPointer) const
inline

allocate a pointer to a consecutive array storing the DoFs

This method serves sincet the user cannot know, if the DoF array returned by allocDofPointer has to be freed.

Note
The pointer must have been allocated by allocDofPointer.
Only one DoF pointer may be allocated at a time.
DoFs are NOT stored back into the discrete function.
Parameters
[in]dofPointerpointer to the dof array previously allocated by allocDofPointer
template<class Impl>
const GridPartType& Dune::Fem::DiscreteFunctionInterface< Impl >::gridPart ( ) const
inline

obtain a reference to the underlying grid part

void Dune::Fem::Function< DiscreteFunctionTraits< Impl >::DiscreteFunctionSpaceType::FunctionSpaceType , Impl >::hessian ( const DomainType x,
HessianRangeType hessian 
) const
inlineinherited

evaluate the hessian of the function

Parameters
[in]xevaluation point
[out]hessianvalue of the hessian in x
void Dune::Fem::Function< DiscreteFunctionTraits< Impl >::DiscreteFunctionSpaceType::FunctionSpaceType , Impl >::jacobian ( const DomainType x,
JacobianRangeType jacobian 
) const
inlineinherited

evaluate the Jacobian of the function

Parameters
[in]xevaluation point
[out]jacobianvalue of the Jacobian in x
template<class Impl>
LocalFunctionType Dune::Fem::DiscreteFunctionInterface< Impl >::localFunction ( const EntityType entity)
inline

obtain a local function for an entity (read-write)

Parameters
[in]entityEntity to focus view of discrete function
Returns
a local function associated with the entity
template<class Impl>
const LocalFunctionType Dune::Fem::DiscreteFunctionInterface< Impl >::localFunction ( const EntityType entity) const
inline

obtain a local function for an entity (read-write)

Parameters
[in]entityEntity to focus view of discrete function
Returns
a local function associated with the entity
template<class Impl>
const std::string& Dune::Fem::DiscreteFunctionInterface< Impl >::name ( ) const
inline

obtain the name of the discrete function

Returns
string holding name of discrete function
template<class Impl>
Dune::FieldTraits< RangeFieldType >::real_type Dune::Fem::DiscreteFunctionInterface< Impl >::normSquaredDofs ( ) const
inline

Squared small l^2 norm of all dofs.

Note
This is already parallel, so do not sum over all processes after calling scalarProductDofs!
It is assumed that the discrete function has been communicated (i.e., every local DoF hat the value of the corresponding global DoF).
Returns
the squared norm of the DoF-vectors
virtual void Dune::Fem::Function< DiscreteFunctionTraits< Impl >::DiscreteFunctionSpaceType::FunctionSpaceType , Impl >::operator() ( const DomainType arg,
RangeType dest 
) const
inlinevirtualinherited

application operator call evaluate

Parameters
[in]argargument
[out]destdestination, i.e. f(arg)
void Dune::Fem::Mapping< DiscreteFunctionTraits< Impl >::DiscreteFunctionSpaceType::FunctionSpaceType::DomainFieldType , DiscreteFunctionTraits< Impl >::DiscreteFunctionSpaceType::FunctionSpaceType::RangeFieldType , DiscreteFunctionTraits< Impl >::DiscreteFunctionSpaceType::FunctionSpaceType::DomainType , DiscreteFunctionTraits< Impl >::DiscreteFunctionSpaceType::FunctionSpaceType::RangeType >::operator() ( const DomainType arg,
RangeType dest 
) const
inlineinherited

Application operator that applies all operators in the linear combination stack.

Parameters
[in]argargument
[out]destdestination
template<class Impl>
DiscreteFunctionType& Dune::Fem::DiscreteFunctionInterface< Impl >::operator*= ( const RangeFieldType scalar)
inline

multiply all DoFs by a scalar factor

Parameters
[in]scalarfactor to muliply all DoFs by
Returns
a reference to this discrete function (i.e. *this)
template<class Impl>
template<class DFType >
DiscreteFunctionType& Dune::Fem::DiscreteFunctionInterface< Impl >::operator+= ( const DiscreteFunctionInterface< DFType > &  g)
inline

add another discrete function to this one

Parameters
[in]gdiscrete function to add
Returns
a reference to this discrete function (i.e. *this)
template<class Impl>
template<class DFType >
DiscreteFunctionType& Dune::Fem::DiscreteFunctionInterface< Impl >::operator-= ( const DiscreteFunctionInterface< DFType > &  g)
inline

substract all degrees of freedom from given discrete function using the dof iterators

Parameters
[in]gdiscrete function which is substracted from this discrete function
Returns
reference to this (i.e. *this)
template<class Impl>
DiscreteFunctionType& Dune::Fem::DiscreteFunctionInterface< Impl >::operator/= ( const RangeFieldType scalar)
inline

devide all DoFs by a scalar factor

Parameters
[in]scalarfactor to divide all DoFs by
Returns
a reference to this discrete function (i.e. *this)
template<class Impl>
void Dune::Fem::DiscreteFunctionInterface< Impl >::print ( std::ostream &  out) const
inline

print all DoFs to a stream (for debugging purposes)

Parameters
[in]outstream to print to

Referenced by Dune::Fem::DiscreteFunctionInterface< Impl >::operator<<().

template<class Impl>
template<class StreamTraits >
void Dune::Fem::DiscreteFunctionInterface< Impl >::read ( InStreamInterface< StreamTraits > &  in)
inline

read the discrete function from a stream

Parameters
[in]instream to read the discrete function from

Referenced by Dune::Fem::operator>>().

template<class Impl>
template<class DFType >
RangeFieldType Dune::Fem::DiscreteFunctionInterface< Impl >::scalarProductDofs ( const DiscreteFunctionInterface< DFType > &  other) const
inline

Scalar product between the DoFs of two discrete functions.

Note
This is a parallel scalar product, so do not sum over all processes after calling scalarProductDofs!
It is assumed that the discrete function has been communicated (i.e., every local DoF hat the value of the corresponding global DoF).
Parameters
[in]otherdiscrete function to evaluate the scalar product with
Returns
the scalar product of the DoF-vectors
template<class Impl>
int Dune::Fem::DiscreteFunctionInterface< Impl >::size ( ) const
inline

obtain total number of DoFs

The number of DoFs (degrees of freedom) can also be seen as the size of the discrete function, i.e., the size of the vector that forms this discrete funciton.

Returns
total number of DoFs for this discrete function

Referenced by Dune::Fem::DiscreteFunctionDefault< Impl >::assign(), Dune::Fem::DiscreteFunctionDefault< Impl >::axpy(), Dune::Fem::DiscreteFunctionDefault< Impl >::operator+=(), Dune::Fem::DiscreteFunctionDefault< Impl >::operator-=(), and Dune::Fem::DiscreteFunctionDefault< Impl >::operator==().

template<class Impl>
const DiscreteFunctionSpaceType& Dune::Fem::DiscreteFunctionInterface< Impl >::space ( ) const
inline

obtain a reference to the corresponding DiscreteFunctionSpace

template<class Impl>
template<class StreamTraits >
void Dune::Fem::DiscreteFunctionInterface< Impl >::write ( OutStreamInterface< StreamTraits > &  out) const
inline

write the discrete function into a stream

Parameters
[in]outstream to write the discrete function to

Referenced by Dune::Fem::operator<<().

Friends And Related Function Documentation

template<class Impl >
std::ostream & operator<< ( std::ostream &  out,
const DiscreteFunctionInterface< Impl > &  df 
)
related

write a discrete function into an STL stream

Parameters
[in]outSTL stream to write to
[in]dfdiscrete function to write
Returns
the STL stream (for concatenation)

References Dune::Fem::DiscreteFunctionInterface< Impl >::print().


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