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:
void vmult (VECTOR &dst, const VECTOR &src) const;
void Tvmult (VECTOR &dst, const VECTOR &src) const;
};
class VECTOR
{
public:
void reinit (const VECTOR&,
bool leave_elements_uninitialized = false);
double operator * (const VECTOR &v) const;
void add (const VECTOR &x);
void add (const double a,
const VECTOR &x);
void sadd (const double a,
const double b,
const VECTOR &x);
void equ (const double a,
const VECTOR &x);
VECTOR & operator *= (const double a);
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
SolverGMRES solver_gmres (solver_control, vector_memory,
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.