1#ifndef DUNE_FEM_DIAGONALPRECONDITIONER_HH 
    2#define DUNE_FEM_DIAGONALPRECONDITIONER_HH 
    6#include <dune/fem/function/common/discretefunction.hh> 
    7#include <dune/fem/operator/common/operator.hh> 
   21    template< 
class DFImp, 
class OperatorImp, 
bool assembled >
 
   22    class DiagonalPreconditionerBase
 
   23      : 
public Operator< DFImp, DFImp >
 
   27      typedef OperatorImp  OperatorType;
 
   33      DiagonalPreconditionerBase(
const OperatorType &op) {}
 
   37        DUNE_THROW(NotImplemented,
"preconditioning not possible for non-assembled operators");
 
   42      template < 
class YBlock, 
class XBlock >
 
   43      void applyToISTLBlockVector( 
const BlockVector< YBlock >& d,
 
   44                                   BlockVector< XBlock >& v )
 const 
   46        DUNE_THROW(NotImplemented,
"preconditioning not possible for non-assembled operators");
 
   53        DUNE_THROW(NotImplemented,
"preconditioning not possible for non-assembled operators");
 
   60    template< 
class DFImp, 
class OperatorImp >
 
   61    class DiagonalPreconditionerBase< DFImp, OperatorImp, true  >
 
   62      : 
public Operator< DFImp, DFImp >
 
   66      typedef OperatorImp        OperatorType;
 
   68      typedef typename DiscreteFunctionType :: DofType DofType;
 
   69      typedef typename Dune::FieldTraits< DofType >::real_type RealType;
 
   74      typedef typename OperatorType::MatrixType MatrixType;
 
   78      const MatrixType& matrix_;
 
   81      DiagonalPreconditionerBase( 
const OperatorType& assembledOperator )
 
   82        : diagonalInv_( 
"diag-preconditioning", assembledOperator.rangeSpace()),
 
   83          matrix_( assembledOperator.exportMatrix() )
 
   87        assembledOperator.extractDiagonal( diagonalInv_ );
 
   96        const RealType eps = 16.*std::numeric_limits< RealType >::epsilon();
 
   97        const DofIteratorType dend = diagonalInv_.
dend();
 
   98        for( DofIteratorType dit = diagonalInv_.
dbegin(); dit != dend; ++dit )
 
   99          *dit = (std::abs( *dit ) < eps ? DofType( 1. ) : DofType( 1. ) / *dit);
 
  109      template < 
class YBlock, 
class XBlock >
 
  110      void applyToISTLBlockVector( 
const BlockVector< YBlock >& d,
 
  111                                   BlockVector< XBlock >& v )
 const 
  129        ConstDofIteratorType uIt     = u.
dbegin();
 
  130        ConstDofIteratorType diagInv = diagonalInv_.
dbegin();
 
  132        const DofIteratorType resEnd = res.
dend();
 
  135        for(DofIteratorType resIt = res.
dbegin();
 
  136            resIt != resEnd; ++ resIt, ++diagInv, ++ uIt )
 
  138          assert( diagInv != diagonalInv_.
dend() );
 
  139          assert( uIt     != u.
dend() );
 
  140          (*resIt) = (*uIt) * (*diagInv);
 
  159    template< 
class DFImp, 
class Operator>
 
  161      : 
public DiagonalPreconditionerBase< DFImp, Operator, std::is_base_of< AssembledOperator< DFImp, DFImp >, Operator > :: value >
 
  163      typedef DiagonalPreconditionerBase< DFImp, Operator, std::is_base_of< AssembledOperator< DFImp, DFImp >, 
Operator > :: value >
 
This file implements a vector space as a tensor product of a given vector space. The number of compon...
 
Precondtioner, multiplies with inverse of the diagonal works with.
Definition: diagonalpreconditioner.hh:162
 
void communicate()
do default communication of space for this discrete function
Definition: discretefunction.hh:825
 
Traits::ConstDofIteratorType ConstDofIteratorType
type of the const dof iterator
Definition: discretefunction.hh:628
 
ConstDofIteratorType dbegin() const
Obtain the constant iterator pointing to the first dof.
Definition: discretefunction.hh:761
 
ConstDofIteratorType dend() const
Obtain the constant iterator pointing to the last dof.
Definition: discretefunction.hh:773
 
Traits::DofIteratorType DofIteratorType
type of the dof iterator
Definition: discretefunction.hh:626
 
forward declaration
Definition: discretefunction.hh:51
 
const DiscreteFunctionSpaceType & space() const
obtain a reference to the corresponding DiscreteFunctionSpace
Definition: discretefunction.hh:709
 
#define DUNE_THROW(E,...)
Definition: exceptions.hh:314
 
Dune namespace.
Definition: alignedallocator.hh:13
 
abstract operator
Definition: operator.hh:34