Solver< VECTOR > Class Template Reference
[Linear solver classes]

Inheritance diagram for Solver< VECTOR >:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 Solver (SolverControl &solver_control, VectorMemory< VECTOR > &vector_memory)
 Solver (SolverControl &solver_control)
SolverControlcontrol () const

Protected Attributes

GrowingVectorMemory< VECTOR > static_vector_memory
SolverControlcntrl
VectorMemory< VECTOR > & memory

Detailed Description

template<class VECTOR = Vector<double>>
class Solver< VECTOR >

This class defines possible return states of linear solvers and provides interfaces to a memory pool and the control object.

Requirements for template classes

Since iterative solvers do not rely on any special structure of matrices or the format of storage, but only require that matrices and vector define certain operations such as matrix-vector products, or scalar products between vectors, this class as well as the derived classes implementing concrete linear solvers are templated on the types of matrices and vectors. However, there are some common requirements a matrix or vector type must fulfill to qualify as an applicable type for the solvers in this hierarchy. These requirements are listed following. The listed classes are not any concrete class, they are rather intended to form a `signature' which a concrete class has to conform to. Note that the matrix and vector classes within this library of course conform to this interface; therefore, SparseMatrix and Vector are good examples for these classes.

 class Matrix
 {
   public:
                        // Application of matrix to vector src.
                        // write result into dst
     void vmult (VECTOR &dst, const VECTOR &src) const;
 
                        // Application of transpose to a Vector.
                        // Only used by certain iterative methods.
     void Tvmult (VECTOR &dst, const VECTOR &src) const;
 };


 class VECTOR
 {
   public:
                        // resize to have the same structure
                        // as the one provided and/or
                        // clear vector. note
                        // that the second argument must have
                        // a default value equal to false
     void reinit (const VECTOR&,
                  bool  leave_elements_uninitialized = false);

                        // scalar product
     double operator * (const VECTOR &v) const;

                        // addition of vectors
     void add (const VECTOR &x);

                        // scaled addition of vectors
     void add (const double  a,
               const VECTOR &x);

                        // scaled addition of vectors
     void sadd (const double  a,
                const double  b,
                const VECTOR &x);
 
                        // scaled assignment of a vector
     void equ (const double  a,
               const VECTOR &x);

                        // scale the elements of the vector
                        // by a fixed value
     VECTOR & operator *= (const double a);

                        // return the l2 norm of the vector
     double l2_norm () const;
 };

In addition, for some solvers there has to be a global function swap(VECTOR &a, VECTOR &b) that exchanges the values of the two vectors.

The preconditioners used must have the same interface as matrices, i.e. in particular they have to provide a member function vmult which denotes the application of the preconditioner.

AdditionalData

Several solvers need additional data, like the damping parameter omega of the SolverRichardson class or the maximum number of temporary vectors of the SolverGMRES. To have a standardized constructor for each solver class the struct AdditionalData has been introduced to each solver class. Some solvers need no additional data, like SolverCG or SolverBicgstab. For these solvers the struct AdditionalData is empty and calling the constructor may be done without giving the additional structure as an argument as a default AdditionalData is set by default.

Now the generating of a solver looks like

                               // GMRES with 50 tmp vectors
 SolverGMRES solver_gmres (solver_control, vector_memory,
                           SolverGMRES::AdditionalData(50));

                               // Richardson with omega=0.8
 SolverRichardson solver_richardson (solver_control, vector_memory,
                                     SolverGMRES::AdditionalData(0.8));

                               // CG with default AdditionalData
 SolverCG solver_cg (solver_control, vector_memory);

Using a unified constructor parameter list for all solvers was introduced when the SolverSelector class was written; the unified interface enabled us to use this class unchanged even if the number of types of parameters to a certain solver changes and it is still possible in a simple way to give these additional data to the SolverSelector object for each solver which it may use.

Author:
Wolfgang Bangerth, Guido Kanschat, Ralf Hartmann, 1997-2001, 2005

Constructor & Destructor Documentation

template<class VECTOR >
Solver< VECTOR >::Solver ( SolverControl solver_control,
VectorMemory< VECTOR > &  vector_memory 
) [inline]

Constructor. Takes a control object which evaluates the conditions for convergence, and an object to provide memory.

Of both objects, a reference is stored, so it is the user's responsibility to guarantee that the lifetime of the two arguments is at least as long as that of the solver object.

template<class VECTOR >
Solver< VECTOR >::Solver ( SolverControl solver_control  )  [inline]

Constructor. Takes a control object which evaluates the conditions for convergence. In contrast to the other constructor, this constructor denotes an internal object of type GrowingVectorMemory to allocate memory.

A reference to the control object is stored, so it is the user's responsibility to guarantee that the lifetime of the two arguments is at least as long as that of the solver object.


Member Function Documentation

template<class VECTOR >
SolverControl & Solver< VECTOR >::control (  )  const [inline]

Access to object that controls convergence.

References Solver< VECTOR >::cntrl.

Referenced by EigenInverse< VECTOR >::solve(), and EigenPower< VECTOR >::solve().


Member Data Documentation

template<class VECTOR = Vector<double>>
GrowingVectorMemory<VECTOR> Solver< VECTOR >::static_vector_memory [mutable, protected]

A static vector memory object to be used whenever no such object has been given to the constructor.

template<class VECTOR = Vector<double>>
SolverControl& Solver< VECTOR >::cntrl [protected]

Control structure.

Referenced by Solver< VECTOR >::control().

template<class VECTOR = Vector<double>>
VectorMemory<VECTOR>& Solver< VECTOR >::memory [protected]

Memory for auxilliary vectors.

Referenced by EigenInverse< VECTOR >::solve(), and EigenPower< VECTOR >::solve().


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

deal.II documentation generated on Mon Nov 23 22:58:04 2009 by doxygen 1.6.1