1#ifndef DUNE_FEM_FEMPRECONDITIONING_HH 
    2#define DUNE_FEM_FEMPRECONDITIONING_HH 
    6#include <dune/fem/function/common/discretefunction.hh> 
    7#include <dune/fem/operator/common/operator.hh> 
    8#include <dune/fem/solver/parameter.hh> 
   22    template< 
class DFImp, 
class OperatorImp, 
int method, 
bool assembled >
 
   23    class FemPreconditioningBase
 
   24      : 
public Operator< DFImp, DFImp >
 
   28      typedef OperatorImp  OperatorType;
 
   34      FemPreconditioningBase(
const OperatorType &op) {}
 
   38        DUNE_THROW(NotImplemented,
"preconditioning not possible for non-assembled operators");
 
   43      template < 
class YBlock, 
class XBlock >
 
   44      void applyToISTLBlockVector( 
const BlockVector< YBlock >& d,
 
   45                                   BlockVector< XBlock >& v )
 const 
   47        DUNE_THROW(NotImplemented,
"preconditioning not possible for non-assembled operators");
 
   54        DUNE_THROW(NotImplemented,
"preconditioning not possible for non-assembled operators");
 
   61    template< 
class DFImp, 
class OperatorImp, 
int method >
 
   62    class FemPreconditioningBase< DFImp, OperatorImp, method, true  >
 
   63      : 
public Operator< DFImp, DFImp >
 
   67      typedef OperatorImp        OperatorType;
 
   69      typedef typename DiscreteFunctionType :: DofType DofType;
 
   70      typedef typename Dune::FieldTraits< DofType >::real_type RealType;
 
   75      typedef typename OperatorType::MatrixType MatrixType;
 
   79      const MatrixType& matrix_;
 
   85      FemPreconditioningBase( 
const OperatorType& assembledOperator,
 
   87                              const double relax = 1.0 )
 
   88        : diagonalInv_( 
"diagInv", assembledOperator.rangeSpace()),
 
   89          matrix_( assembledOperator.exportMatrix() ),
 
   91          w_( (method == SolverParameter::gauss_seidel ) ? 1.0 : relax )
 
   94        assembledOperator.extractDiagonal( diagonalInv_ );
 
  103        const RealType eps = 16.*std::numeric_limits< RealType >::epsilon();
 
  104        const DofIteratorType dend = diagonalInv_.
dend();
 
  105        for( DofIteratorType dit = diagonalInv_.
dbegin(); dit != dend; ++dit )
 
  106          *dit = (std::abs( *dit ) < eps ? DofType( 1. ) : DofType( 1. ) / *dit);
 
  116      template < 
class YBlock, 
class XBlock >
 
  117      void applyToISTLBlockVector( 
const BlockVector< YBlock >& d,
 
  118                                   BlockVector< XBlock >& v )
 const 
  133        std::unique_ptr< DiscreteFunctionType > xTmp_;
 
  134        if constexpr ( method == SolverParameter :: jacobi )
 
  141        for( 
int i=0; i<n_; ++i )
 
  143          matrix_.forwardIterative( diagonalInv_, u, x, v, w_ );
 
  145          if constexpr ( method == SolverParameter :: ssor )
 
  147            matrix_.backwardIterative( diagonalInv_, u, x, v, w_ );
 
  153          if constexpr ( method == SolverParameter :: jacobi )
 
  176    template< 
class DFImp, 
class Operator, 
int method>
 
  178      : 
public FemPreconditioningBase< DFImp, Operator, method, std::is_base_of< AssembledOperator< DFImp, DFImp >, Operator > :: value >
 
  180      typedef FemPreconditioningBase< DFImp, Operator, method, std::is_base_of< AssembledOperator< DFImp, DFImp >, 
Operator > :: value >
 
  189    template <
class DFImp, 
class Operator>
 
  192    template <
class DFImp, 
class Operator>
 
  195    template <
class DFImp, 
class Operator>
 
  198    template <
class DFImp, 
class Operator>
 
This file implements a vector space as a tensor product of a given vector space. The number of compon...
 
void communicate()
do default communication of space for this discrete function
Definition: discretefunction.hh:825
 
void clear()
set all degrees of freedom to zero
Definition: discretefunction.hh:731
 
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
 
void assign(const DiscreteFunctionInterface< DFType > &g)
Definition: discretefunction_inline.hh:132
 
Precondtioner, implementing Jacobi, Gauss-Seidel and SOR works with.
Definition: fempreconditioning.hh:179
 
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