Reference documentation for deal.II version 8.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
Public Member Functions | Protected Attributes | List of all members
Solver< VECTOR > Class Template Reference

#include <solver.h>

Inheritance diagram for Solver< VECTOR >:
[legend]

Public Member Functions

 Solver (SolverControl &solver_control, VectorMemory< VECTOR > &vector_memory)
 
 Solver (SolverControl &solver_control)
 
SolverControlcontrol () const
 
- Public Member Functions inherited from Subscriptor
 Subscriptor ()
 
 Subscriptor (const Subscriptor &)
 
virtual ~Subscriptor ()
 
Subscriptoroperator= (const Subscriptor &)
 
void subscribe (const char *identifier=0) const
 
void unsubscribe (const char *identifier=0) const
 
unsigned int n_subscriptions () const
 
void list_subscribers () const
 
 DeclException3 (ExcInUse, int, char *, std::string &,<< "Object of class "<< arg2<< " is still used by "<< arg1<< " other objects.\n"<< "(Additional information: "<< arg3<< ")\n"<< "Note the entry in the Frequently Asked Questions of "<< "deal.II (linked to from http://www.dealii.org/) for "<< "more information on what this error means.")
 
 DeclException2 (ExcNoSubscriber, char *, char *,<< "No subscriber with identifier \""<< arg2<< "\" did subscribe to this object of class "<< arg1)
 
template<class Archive >
void serialize (Archive &ar, const unsigned int version)
 

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,
// Richardson with omega=0.8
SolverRichardson solver_richardson (solver_control, vector_memory,
// 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

Definition at line 147 of file solver.h.

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.

Definition at line 217 of file solver.h.

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.

Definition at line 228 of file solver.h.

Member Function Documentation

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

Access to object that controls convergence.

Definition at line 239 of file solver.h.

Member Data Documentation

template<class VECTOR = Vector<double>>
GrowingVectorMemory<VECTOR> Solver< VECTOR >::static_vector_memory
mutableprotected

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

Definition at line 200 of file solver.h.

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

Control structure.

Definition at line 205 of file solver.h.

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

Memory for auxiliary vectors.

Definition at line 210 of file solver.h.


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