ug4
ug::IPreconditioner< TAlgebra > Class Template Referenceabstract

describes a linear iterator that is based on a matrix operator More...

#include <preconditioner.h>

+ Inheritance diagram for ug::IPreconditioner< TAlgebra >:

Public Types

typedef TAlgebra algebra_type
 Algebra type. More...
 
typedef MatrixOperator< matrix_type, vector_typematrix_operator_type
 Matrix Operator type. More...
 
typedef TAlgebra::matrix_type matrix_type
 Matrix type. More...
 
typedef TAlgebra::vector_type vector_type
 Vector type. More...
 
- Public Types inherited from ug::ILinearIterator< TAlgebra::vector_type >
typedef TAlgebra::vector_type codomain_function_type
 Range space. More...
 
typedef TAlgebra::vector_type domain_function_type
 Domain space. More...
 
- Public Types inherited from ug::DebugWritingObject< TAlgebra >
typedef TAlgebra algebra_type
 type of algebra More...
 
typedef TAlgebra::matrix_type matrix_type
 type of matrix More...
 
typedef TAlgebra::vector_type vector_type
 type of vector More...
 
- Public Types inherited from ug::VectorDebugWritingObject< TAlgebra::vector_type >
typedef TAlgebra::vector_type vector_type
 type of vector More...
 

Public Member Functions

virtual bool apply (vector_type &c, const vector_type &d)
 compute new correction c = B*d More...
 
virtual bool apply_update_defect (vector_type &c, vector_type &d)
 compute new correction c = B*d and update defect d:= d - L*c More...
 
SmartPtr< MatrixOperator< matrix_type, vector_type > > approx_operator ()
 underlying matrix based operator used for the preconditioner More...
 
SmartPtr< MatrixOperator< matrix_type, vector_type > > defect_operator ()
 underlying matrix based operator for calculation of defect More...
 
virtual bool init (SmartPtr< ILinearOperator< vector_type > > J, const vector_type &u)
 implements the ILinearIterator-interface for matrix based preconditioner More...
 
bool init (SmartPtr< ILinearOperator< vector_type > > L)
 implements the ILinearIterator-interface for matrix based preconditioner More...
 
bool init (SmartPtr< MatrixOperator< matrix_type, vector_type > > Op)
 initializes the preconditioner for a matrix based operator More...
 
 IPreconditioner ()
 default constructor More...
 
 IPreconditioner (const IPreconditioner< TAlgebra > &parent)
 clone constructor More...
 
 IPreconditioner (SmartPtr< IDebugWriter< algebra_type > > spDebugWriter)
 constructor setting debug writer More...
 
virtual void set_approximation (SmartPtr< MatrixOperator< matrix_type, vector_type > > approx)
 
virtual ~IPreconditioner ()
 virtual destructor More...
 
- Public Member Functions inherited from ug::ILinearIterator< TAlgebra::vector_type >
virtual SmartPtr< ILinearIterator< TAlgebra::vector_type, TAlgebra::vector_type > > clone ()=0
 clone More...
 
virtual std::string config_string () const
 
SmartPtr< IDamping< TAlgebra::vector_type, TAlgebra::vector_type > > damping ()
 returns the scaling More...
 
 ILinearIterator ()
 constructor More...
 
 ILinearIterator (const ILinearIterator< TAlgebra::vector_type, TAlgebra::vector_type > &parent)
 copy constructor More...
 
virtual bool init (SmartPtr< ILinearOperator< TAlgebra::vector_type, TAlgebra::vector_type > > J, const TAlgebra::vector_type &u)=0
 initialize for operator J(u) and linearization point u More...
 
virtual bool init (SmartPtr< ILinearOperator< TAlgebra::vector_type, TAlgebra::vector_type > > L)=0
 initialize for linear operator L More...
 
void set_damp (number factor)
 sets the damping to a constant factor More...
 
void set_damp (SmartPtr< IDamping< TAlgebra::vector_type, TAlgebra::vector_type > > spScaling)
 sets a scaling for the correction More...
 
virtual bool supports_parallel () const=0
 returns if parallel solving is supported More...
 
virtual ~ILinearIterator ()
 virtual destructor More...
 
- Public Member Functions inherited from ug::DebugWritingObject< TAlgebra >
SmartPtr< IDebugWriter< algebra_type > > debug_writer ()
 returns the debug writer More...
 
ConstSmartPtr< IDebugWriter< algebra_type > > debug_writer () const
 
bool debug_writer_valid () const
 returns true if the debug writer is set More...
 
 DebugWritingObject ()
 
 DebugWritingObject (const DebugWritingObject< algebra_type > &parent)
 clone constructor More...
 
 DebugWritingObject (SmartPtr< IDebugWriter< algebra_type > > spDebugWriter)
 
virtual void set_debug (SmartPtr< IDebugWriter< algebra_type > > spDebugWriter)
 set debug writer More...
 
virtual ~DebugWritingObject ()
 virtual destructor More...
 
- Public Member Functions inherited from ug::VectorDebugWritingObject< TAlgebra::vector_type >
virtual void set_debug (SmartPtr< IVectorDebugWriter< vector_type > > spDebugWriter)
 set debug writer More...
 
SmartPtr< IVectorDebugWriter< vector_type > > vector_debug_writer ()
 returns the debug writer More...
 
ConstSmartPtr< IVectorDebugWriter< vector_type > > vector_debug_writer () const
 
bool vector_debug_writer_valid () const
 returns true if the debug writer is set More...
 
 VectorDebugWritingObject ()
 
 VectorDebugWritingObject (SmartPtr< IVectorDebugWriter< vector_type > > spDebugWriter)
 
void write_debug (const vector_type &vec, const char *filename)
 writing debug output for a vector (if debug writer set) More...
 
virtual ~VectorDebugWritingObject ()
 virtual destructor More...
 

Protected Member Functions

virtual const char * name () const =0
 returns the name of iterator More...
 
virtual bool postprocess ()=0
 cleans the operator More...
 
virtual bool preprocess (SmartPtr< MatrixOperator< matrix_type, vector_type > > pOp)=0
 initializes the preconditioner More...
 
virtual bool step (SmartPtr< MatrixOperator< matrix_type, vector_type > > pOp, vector_type &c, const vector_type &d)=0
 computes a new correction c = B*d More...
 
- Protected Member Functions inherited from ug::DebugWritingObject< TAlgebra >
void enter_debug_writer_section (const char *secDir)
 enters a debugging section More...
 
void enter_debug_writer_section (std::string secDir)
 enters a debugging section More...
 
void leave_debug_writer_section ()
 leaves a debugging section More...
 
void write_debug (const matrix_type &mat, const char *filename)
 write debug output for a matrix (if debug writer set) More...
 
void write_debug (const matrix_type &mat, std::string name)
 write debug output for a matrix (if debug writer set) More...
 
- Protected Member Functions inherited from ug::VectorDebugWritingObject< TAlgebra::vector_type >
void enter_vector_debug_writer_section (const char *secDir)
 enters a debugging section More...
 
void enter_vector_debug_writer_section (std::string secDir)
 enters a debugging section More...
 
void leave_vector_debug_writer_section ()
 leaves a debugging section More...
 
void print_debugger_message (const char *msg)
 prints a debugger message (listing all the sections) More...
 
void print_debugger_message (std::string msg)
 prints a debugger message (listing all the sections) More...
 
virtual void write_debug (const vector_type &vec, std::string name)
 writing debug output for a vector (if debug writer set) More...
 

Protected Attributes

bool m_bInit
 init flag indicating if init has been called More...
 
bool m_bOtherApproxOperator
 
SmartPtr< MatrixOperator< matrix_type, vector_type > > m_spApproxOperator
 underlying matrix based operator used for the preconditioner More...
 
SmartPtr< ILinearOperator< vector_type > > m_spDefectOperator
 underlying matrix based operator for calculation of defect More...
 
- Protected Attributes inherited from ug::ILinearIterator< TAlgebra::vector_type >
SmartPtr< IDamping< TAlgebra::vector_type, TAlgebra::vector_type > > m_spDamping
 the scaling More...
 
- Protected Attributes inherited from ug::DebugWritingObject< TAlgebra >
SmartPtr< IDebugWriter< algebra_type > > m_spDebugWriter
 Debug Writer. More...
 
- Protected Attributes inherited from ug::VectorDebugWritingObject< TAlgebra::vector_type >
SmartPtr< IVectorDebugWriter< vector_type > > m_spVectorDebugWriter
 Debug Writer. More...
 

Detailed Description

template<typename TAlgebra>
class ug::IPreconditioner< TAlgebra >

describes a linear iterator that is based on a matrix operator

This class is the base class for all linear iterators, that act on matrix based linear operators. We call the matrix based iterator a 'Preconditioner'. They are used in iterative schemes when solving a linear system. Usually, a linear problem like L*u = f is intended to be solved. This is done in an iterative way by performing an iteration of

start: compute d := f - L*u iterate: - c := B*d (compute correction)

  • u := u + c (update solution)
  • d := d - L*c (update defect)

This iterator class describes the application of B in the scheme above, where L is internally represented by a matrix.

This method derives from the ILinearIterator-interface and thus must implement these to steps:

  1. init(L, u) or init(L): These methods initialize the iterator and one of these methods has to be called before any of the apply methods can be used. Passing the linear operator indicates that this operator is used as underlying for the iterator.
  2. apply or apply_return_defect: These methods are used to compute the correction (and to update the defect at the same time). Note, that these methods can only be called when the iterator has been initialized.

This splitting has been made, since initialization may be computationally expansive. Thus, the user of this class has the choice when to call this initialization. E.g. when the operator is applied several times the init of the iterator is only needed once.

In order to facilitate the implementation of derived classes a default implementation of these virtual method is given. Thus, the implementational part for a matrix based iterator is to implement the three functions:

  1. preprocess: Initializes the preconditioner for a matrix, that is used as the underlying matrix. Calling these method again with a different matrix results in a different preconditioner.
  2. step: Computes the new correction.
  3. postprocess: Clean up (if needed)
Template Parameters
TAlgebraType of Algebra

Member Typedef Documentation

◆ algebra_type

template<typename TAlgebra >
typedef TAlgebra ug::IPreconditioner< TAlgebra >::algebra_type

Algebra type.

◆ matrix_operator_type

template<typename TAlgebra >
typedef MatrixOperator<matrix_type, vector_type> ug::IPreconditioner< TAlgebra >::matrix_operator_type

Matrix Operator type.

◆ matrix_type

template<typename TAlgebra >
typedef TAlgebra::matrix_type ug::IPreconditioner< TAlgebra >::matrix_type

Matrix type.

◆ vector_type

template<typename TAlgebra >
typedef TAlgebra::vector_type ug::IPreconditioner< TAlgebra >::vector_type

Vector type.

Constructor & Destructor Documentation

◆ IPreconditioner() [1/3]

template<typename TAlgebra >
ug::IPreconditioner< TAlgebra >::IPreconditioner ( )
inline

default constructor

◆ IPreconditioner() [2/3]

template<typename TAlgebra >
ug::IPreconditioner< TAlgebra >::IPreconditioner ( SmartPtr< IDebugWriter< algebra_type > >  spDebugWriter)
inline

constructor setting debug writer

◆ IPreconditioner() [3/3]

template<typename TAlgebra >
ug::IPreconditioner< TAlgebra >::IPreconditioner ( const IPreconditioner< TAlgebra > &  parent)
inline

clone constructor

◆ ~IPreconditioner()

template<typename TAlgebra >
virtual ug::IPreconditioner< TAlgebra >::~IPreconditioner ( )
inlinevirtual

virtual destructor

Member Function Documentation

◆ apply()

template<typename TAlgebra >
virtual bool ug::IPreconditioner< TAlgebra >::apply ( vector_type c,
const vector_type d 
)
inlinevirtual

compute new correction c = B*d

This method implements the virtual method of the ILinearIterator-interface. Basically, besides some common checks the request is forwarded to the (virtual) 'step'-method.

Parameters
[out]ccorrection
[in]ddefect
Returns
bool success flag

Implements ug::ILinearIterator< TAlgebra::vector_type >.

Reimplemented in ug::AgglomeratingBase< IPreconditioner< TAlgebra >, TAlgebra >, ug::IProjGaussSeidel< TDomain, TAlgebra >, and ug::Jacobi< TAlgebra >.

References ug::ILinearIterator< TAlgebra::vector_type >::damping(), kappa, ug::IPreconditioner< TAlgebra >::m_bInit, ug::IPreconditioner< TAlgebra >::m_spApproxOperator, ug::IPreconditioner< TAlgebra >::name(), ug::PST_ADDITIVE, ug::PST_CONSISTENT, ug::IPreconditioner< TAlgebra >::step(), THROW_IF_NOT_EQUAL_4, UG_LOG, and UG_THROW.

Referenced by ug::IPreconditioner< TAlgebra >::apply_update_defect().

◆ apply_update_defect()

template<typename TAlgebra >
virtual bool ug::IPreconditioner< TAlgebra >::apply_update_defect ( vector_type c,
vector_type d 
)
inlinevirtual

compute new correction c = B*d and update defect d:= d - L*c

This method implements the virtual method of the ILinearIterator-interface. Basically, the request is forwarded to the 'apply'-method and then the update of the defect is computed afterwards.

Parameters
[out]ccorrection
[in,out]ddefect on entry, updated defect on exit
Returns
bool success flag

Implements ug::ILinearIterator< TAlgebra::vector_type >.

Reimplemented in ug::AgglomeratingBase< IPreconditioner< TAlgebra >, TAlgebra >, and ug::IProjGaussSeidel< TDomain, TAlgebra >.

References ug::IPreconditioner< TAlgebra >::apply(), and ug::IPreconditioner< TAlgebra >::m_spDefectOperator.

◆ approx_operator()

template<typename TAlgebra >
SmartPtr<MatrixOperator<matrix_type, vector_type> > ug::IPreconditioner< TAlgebra >::approx_operator ( )
inline

underlying matrix based operator used for the preconditioner

References ug::IPreconditioner< TAlgebra >::m_spApproxOperator.

◆ defect_operator()

template<typename TAlgebra >
SmartPtr<MatrixOperator<matrix_type, vector_type> > ug::IPreconditioner< TAlgebra >::defect_operator ( )
inline

underlying matrix based operator for calculation of defect

References ug::IPreconditioner< TAlgebra >::m_spDefectOperator.

◆ init() [1/3]

template<typename TAlgebra >
virtual bool ug::IPreconditioner< TAlgebra >::init ( SmartPtr< ILinearOperator< vector_type > >  J,
const vector_type u 
)
inlinevirtual

implements the ILinearIterator-interface for matrix based preconditioner

This method implements the ILinearIterator interface. It check if the passed linear operator is matrix based (otherwise this preconditioner can not be used for the linear operator). Then the request is forwarded to the implementation of matrix based operators.

Parameters
[in]Jlinear operator
[in]ulinearization point
Returns
bool success flag

Reimplemented in ug::UzawaBase< TDomain, TAlgebra >, ug::IProjGaussSeidel< TDomain, TAlgebra >, ug::ILUTPreconditioner< TAlgebra >, and ug::ILU< TAlgebra >.

References SmartPtr< T, FreePolicy >::invalid(), ug::IPreconditioner< TAlgebra >::name(), and UG_THROW.

Referenced by ug::ILU< TAlgebra >::init(), ug::ILUTPreconditioner< TAlgebra >::init(), ug::UzawaBase< TDomain, TAlgebra >::init(), and ug::IPreconditioner< TAlgebra >::init().

◆ init() [2/3]

template<typename TAlgebra >
bool ug::IPreconditioner< TAlgebra >::init ( SmartPtr< ILinearOperator< vector_type > >  L)
inline

implements the ILinearIterator-interface for matrix based preconditioner

This method implements the ILinearIterator interface. It check if the passed linear operator is matrix based (otherwise this preconditioner can not be used for the linear operator). Then the request is forwarded to the implementation of matrix based operators.

Parameters
[in]Llinear operator
Returns
bool success flag

References ug::IPreconditioner< TAlgebra >::init(), SmartPtr< T, FreePolicy >::invalid(), ug::IPreconditioner< TAlgebra >::m_bOtherApproxOperator, ug::IPreconditioner< TAlgebra >::m_spDefectOperator, ug::IPreconditioner< TAlgebra >::name(), and UG_THROW.

◆ init() [3/3]

template<typename TAlgebra >
bool ug::IPreconditioner< TAlgebra >::init ( SmartPtr< MatrixOperator< matrix_type, vector_type > >  Op)
inline

initializes the preconditioner for a matrix based operator

This method initializes the preconditioner for matrix based operators. It performs some default checks and then forwards internally the initialization to the (virtual) 'preprocess'-method

Parameters
[in]Opmatrix based operator
Returns
bool success flag

References ug::IPreconditioner< TAlgebra >::m_bInit, ug::IPreconditioner< TAlgebra >::m_spApproxOperator, ug::IPreconditioner< TAlgebra >::m_spDefectOperator, ug::IPreconditioner< TAlgebra >::name(), ug::IPreconditioner< TAlgebra >::preprocess(), UG_LOG, and UG_THROW.

◆ name()

template<typename TAlgebra >
virtual const char* ug::IPreconditioner< TAlgebra >::name ( ) const
protectedpure virtual

returns the name of iterator

This method returns the name of the iterator operator. This function is typically needed, when the iterator operator is used inside of another operator and some debug output should be printed

Returns
const char* name of inverse operator

Implements ug::ILinearIterator< TAlgebra::vector_type >.

Implemented in ug::IProjGaussSeidel< TDomain, TAlgebra >, ug::GaussSeidelBase< TAlgebra >, ug::LineVanka< TDomain, TAlgebra >, ug::LineGaussSeidel< TDomain, TAlgebra >, ug::UzawaBase< TDomain, TAlgebra >, ug::SequentialSubspaceCorrection< TDomain, TAlgebra >, ug::ElementGaussSeidel< TDomain, TAlgebra >, ug::ComponentGaussSeidel< TDomain, TAlgebra >, ug::DiagVanka< TAlgebra >, ug::Vanka< TAlgebra >, ug::SchurPrecond< TAlgebra >, ug::ProjSymmetricGaussSeidel< TDomain, TAlgebra >, ug::ProjBackwardGaussSeidel< TDomain, TAlgebra >, ug::ProjGaussSeidel< TDomain, TAlgebra >, ug::PILUTPreconditioner< TAlgebra >, ug::Jacobi< TAlgebra >, ug::ILUTScalarPreconditioner< TAlgebra >, ug::ILUTPreconditioner< TAlgebra >, ug::ILU< TAlgebra >, ug::SymmetricGaussSeidel< TAlgebra >, ug::BackwardGaussSeidel< TAlgebra >, ug::GaussSeidel< TAlgebra >, ug::SparseBlockGaussSeidel2< TAlgebra, backward, forward >, ug::SparseBlockGaussSeidel< TAlgebra, backward, forward >, ug::BlockGaussSeidelIterative< TAlgebra, backward, forward >, ug::BlockGaussSeidel< TAlgebra, backward, forward >, ug::AgglomeratingPreconditioner< TAlgebra >, ug::CRILUTPreconditioner< class >, and ug::PCRILUTPreconditioner< class >.

Referenced by ug::IPreconditioner< TAlgebra >::apply(), ug::IPreconditioner< TAlgebra >::init(), and ug::IPreconditioner< TAlgebra >::set_approximation().

◆ postprocess()

◆ preprocess()

template<typename TAlgebra >
virtual bool ug::IPreconditioner< TAlgebra >::preprocess ( SmartPtr< MatrixOperator< matrix_type, vector_type > >  pOp)
protectedpure virtual

◆ set_approximation()

◆ step()

Member Data Documentation

◆ m_bInit

template<typename TAlgebra >
bool ug::IPreconditioner< TAlgebra >::m_bInit
protected

◆ m_bOtherApproxOperator

template<typename TAlgebra >
bool ug::IPreconditioner< TAlgebra >::m_bOtherApproxOperator
protected

◆ m_spApproxOperator

template<typename TAlgebra >
SmartPtr<MatrixOperator<matrix_type, vector_type> > ug::IPreconditioner< TAlgebra >::m_spApproxOperator
protected

◆ m_spDefectOperator

template<typename TAlgebra >
SmartPtr<ILinearOperator<vector_type> > ug::IPreconditioner< TAlgebra >::m_spDefectOperator
protected

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