Public Member Functions | Static Public Member Functions | Protected Attributes | Private Attributes

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

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

List of all members.

Public Member Functions

 SolverSelector ()
 SolverSelector (const std::string &solvername, SolverControl &control, VectorMemory< VECTOR > &vector_memory)
 ~SolverSelector ()
template<class Matrix , class Preconditioner >
void solve (const Matrix &A, VECTOR &x, const VECTOR &b, const Preconditioner &precond) const
void select (const std::string &name)
void set_control (SolverControl &ctrl)
void set_data (const typename SolverRichardson< VECTOR >::AdditionalData &data)
void set_data (const typename SolverCG< VECTOR >::AdditionalData &data)
void set_data (const typename SolverBicgstab< VECTOR >::AdditionalData &data)
void set_data (const typename SolverGMRES< VECTOR >::AdditionalData &data)
void set_data (const typename SolverFGMRES< VECTOR >::AdditionalData &data)

Static Public Member Functions

static std::string get_solver_names ()
::ExceptionBaseExcSolverDoesNotExist (std::string arg1) throw (errortext << "Solver " << arg1 << " does not exist. Use one of " << std::endl << get_solver_names() )

Protected Attributes

SmartPointer< SolverControl,
SolverSelector< VECTOR > > 
control
std::string solver_name

Private Attributes

SolverRichardson< VECTOR >
::AdditionalData 
richardson_data
SolverCG< VECTOR >::AdditionalData cg_data
SolverBicgstab< VECTOR >
::AdditionalData 
bicgstab_data
SolverGMRES< VECTOR >
::AdditionalData 
gmres_data
SolverFGMRES< VECTOR >
::AdditionalData 
fgmres_data

Detailed Description

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

Selects a solver by changing a parameter.

By calling the solve function of this SolverSelector, it selects the solve function of that Solver that was specified in the constructor of this class.

Usage

The simplest use of this class is the following:

 *                                  // generate a @p SolverControl and
 *                                  // a @p VectorMemory
 * SolverControl control;
 * VectorMemory<Vector<double> > memory;
 *                                  // Line 3:
 *                                  //
 *                                  // generate a @p SolverSelector that
 *                                  // calls the @p SolverCG
 * SolverSelector<Vector<double> > 
 *   solver_selector("cg", control, memory);
 *                                  // generate e.g. a @p PreconditionRelaxation
 * PreconditionRelaxation<SparseMatrix<double>, Vector<double> >
 *   preconditioning(A, &SparseMatrix<double>
 *                   ::template precondition_SSOR<double>,0.8);
 *                                  // call the @p solve function with this
 *                                  // preconditioning as last argument
 * solver_selector.solve(A,x,b,preconditioning);
 * 

But the full usefulness of the SolverSelector class is not clear until the presentation of the following example that assumes the user using the ParameterHandler class and having declared a "solver" entry, e.g. with

 * Parameter_Handler prm;
 * prm.declare_entry ("solver", "none",
 *                    Patterns::Selection(SolverSelector<>::get_solver_names()));
 * ...
 * 

Assuming that in the users parameter file there exists the line

 * set solver = cg
 * 

then `Line 3' of the above example reads

 * SolverSelector<SparseMatrix<double>, Vector<double> > 
 *   solver_selector(prm.get("solver"), control, memory);
 * 

If at some time there exists a new solver "xyz" then the user does not need to change his program. Only in the implementation of the SolverSelector the calling of this solver has to be added and each user with program lines quoted above only needs to 'set solver = xyz' in his parameter file to get access to that new solver. :-)

(By the way, thanks to Wolfgang for implementing the ParameterHandler.)

Author:
Ralf Hartmann, 1999

Definition at line 95 of file solver_selector.h.


Constructor & Destructor Documentation

template<class VECTOR >
SolverSelector< VECTOR >::SolverSelector (  )

Constructor, filling in default values

Definition at line 245 of file solver_selector.h.

template<class VECTOR >
SolverSelector< VECTOR >::SolverSelector ( const std::string &  solvername,
SolverControl control,
VectorMemory< VECTOR > &  vector_memory 
)
Deprecated:
Use deafult constructor and select.

Constructor. Use the arguments to initialize actual solver objects. The VectorMemory argument is ignored.

Definition at line 250 of file solver_selector.h.

template<class VECTOR >
SolverSelector< VECTOR >::~SolverSelector (  )

Destructor

Definition at line 259 of file solver_selector.h.


Member Function Documentation

template<class VECTOR >
template<class Matrix , class Preconditioner >
void SolverSelector< VECTOR >::solve ( const Matrix &  A,
VECTOR &  x,
const VECTOR &  b,
const Preconditioner &  precond 
) const

Solver procedure. Calls the solve function of the solver whose SolverName was specified in the constructor.

Definition at line 274 of file solver_selector.h.

References Assert, SolverFGMRES< VECTOR >::solve(), SolverGMRES< VECTOR >::solve(), SolverBicgstab< VECTOR >::solve(), SolverCG< VECTOR >::solve(), and SolverRichardson< VECTOR >::solve().

template<class VECTOR >
void SolverSelector< VECTOR >::select ( const std::string &  name )

Select a new solver. Note that all solver names used in this class are all lower case.

Definition at line 265 of file solver_selector.h.

template<class VECTOR >
void SolverSelector< VECTOR >::set_control ( SolverControl ctrl )

Set a new SolverControl. This needs to be set before solving.

Definition at line 317 of file solver_selector.h.

template<class VECTOR >
void SolverSelector< VECTOR >::set_data ( const typename SolverRichardson< VECTOR >::AdditionalData &  data )

Set the additional data. For more info see the Solver class.

Definition at line 348 of file solver_selector.h.

template<class VECTOR >
void SolverSelector< VECTOR >::set_data ( const typename SolverCG< VECTOR >::AdditionalData &  data )

Set the additional data. For more info see the Solver class.

Definition at line 356 of file solver_selector.h.

template<class VECTOR >
void SolverSelector< VECTOR >::set_data ( const typename SolverBicgstab< VECTOR >::AdditionalData &  data )

Set the additional data. For more info see the Solver class.

Definition at line 364 of file solver_selector.h.

template<class VECTOR >
void SolverSelector< VECTOR >::set_data ( const typename SolverGMRES< VECTOR >::AdditionalData &  data )

Set the additional data. For more info see the Solver class.

Definition at line 332 of file solver_selector.h.

template<class VECTOR >
void SolverSelector< VECTOR >::set_data ( const typename SolverFGMRES< VECTOR >::AdditionalData &  data )

Set the additional data. For more info see the Solver class.

Definition at line 340 of file solver_selector.h.

template<class VECTOR >
std::string SolverSelector< VECTOR >::get_solver_names (  ) [static]

Get the names of all implemented solvers.

Definition at line 325 of file solver_selector.h.

template<class VECTOR = Vector<double>>
::ExceptionBase& SolverSelector< VECTOR >::ExcSolverDoesNotExist ( std::string  arg1 ) throw (errortext << "Solver " << arg1 << " does not exist. Use one of " << std::endl << get_solver_names() ) [static]

Exception.


Member Data Documentation

template<class VECTOR = Vector<double>>
SmartPointer< SolverControl, SolverSelector< VECTOR > > SolverSelector< VECTOR >::control [protected]

Stores the SolverControl that is needed in the constructor of each Solver class. This can be changed with set_control().

Definition at line 206 of file solver_selector.h.

template<class VECTOR = Vector<double>>
std::string SolverSelector< VECTOR >::solver_name [protected]

Stores the name of the solver.

Definition at line 211 of file solver_selector.h.

template<class VECTOR = Vector<double>>
SolverRichardson<VECTOR>::AdditionalData SolverSelector< VECTOR >::richardson_data [private]

Stores the additional data.

Definition at line 217 of file solver_selector.h.

template<class VECTOR = Vector<double>>
SolverCG<VECTOR>::AdditionalData SolverSelector< VECTOR >::cg_data [private]

Stores the additional data.

Definition at line 222 of file solver_selector.h.

template<class VECTOR = Vector<double>>
SolverBicgstab<VECTOR>::AdditionalData SolverSelector< VECTOR >::bicgstab_data [private]

Stores the additional data.

Definition at line 227 of file solver_selector.h.

template<class VECTOR = Vector<double>>
SolverGMRES<VECTOR>::AdditionalData SolverSelector< VECTOR >::gmres_data [private]

Stores the additional data.

Definition at line 232 of file solver_selector.h.

template<class VECTOR = Vector<double>>
SolverFGMRES<VECTOR>::AdditionalData SolverSelector< VECTOR >::fgmres_data [private]

Stores the additional data.

Definition at line 237 of file solver_selector.h.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

deal.II documentation generated on Fri Feb 3 2012 06:04:11 by doxygen 1.7.2