
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_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 () |
| ::ExceptionBase & | ExcSolverDoesNotExist (std::string arg1) throw (errortext << "Solver " << arg1 << " does not exist. Use one of " << std::endl << get_solver_names() ) |
Public Attributes | |
| ReductionControl | control |
Protected Attributes | |
| 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 |
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.
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);
* 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()));
* ...
* * set solver = cg *
* 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.)
| SolverSelector< VECTOR >::SolverSelector | ( | ) | [inline] |
Constructor, filling in default values
| SolverSelector< VECTOR >::SolverSelector | ( | const std::string & | solvername, | |
| SolverControl & | control, | |||
| VectorMemory< VECTOR > & | vector_memory | |||
| ) | [inline] |
| SolverSelector< VECTOR >::~SolverSelector | ( | ) | [inline] |
Destructor
| void SolverSelector< VECTOR >::solve | ( | const Matrix & | A, | |
| VECTOR & | x, | |||
| const VECTOR & | b, | |||
| const Preconditioner & | precond | |||
| ) | const [inline] |
Solver procedure. Calls the solve function of the solver whose SolverName was specified in the constructor.
References Assert, SolverSelector< VECTOR >::bicgstab_data, SolverSelector< VECTOR >::cg_data, SolverSelector< VECTOR >::control, SolverSelector< VECTOR >::ExcSolverDoesNotExist(), SolverSelector< VECTOR >::fgmres_data, SolverSelector< VECTOR >::gmres_data, SolverSelector< VECTOR >::richardson_data, SolverFGMRES< VECTOR >::solve(), SolverGMRES< VECTOR >::solve(), SolverBicgstab< VECTOR >::solve(), SolverCG< VECTOR >::solve(), SolverRichardson< VECTOR >::solve(), and SolverSelector< VECTOR >::solver_name.
| void SolverSelector< VECTOR >::select | ( | const std::string & | name | ) | [inline] |
Select a new solver. Note that all solver names used in this class are all lower case.
References SolverSelector< VECTOR >::solver_name.
| void SolverSelector< VECTOR >::set_data | ( | const typename SolverRichardson< VECTOR >::AdditionalData & | data | ) | [inline] |
Set the additional data. For more info see the Solver class.
References SolverSelector< VECTOR >::richardson_data.
| void SolverSelector< VECTOR >::set_data | ( | const typename SolverCG< VECTOR >::AdditionalData & | data | ) | [inline] |
Set the additional data. For more info see the Solver class.
References SolverSelector< VECTOR >::cg_data.
| void SolverSelector< VECTOR >::set_data | ( | const typename SolverBicgstab< VECTOR >::AdditionalData & | data | ) | [inline] |
Set the additional data. For more info see the Solver class.
References SolverSelector< VECTOR >::bicgstab_data.
| void SolverSelector< VECTOR >::set_data | ( | const typename SolverGMRES< VECTOR >::AdditionalData & | data | ) | [inline] |
Set the additional data. For more info see the Solver class.
References SolverSelector< VECTOR >::gmres_data.
| void SolverSelector< VECTOR >::set_data | ( | const typename SolverFGMRES< VECTOR >::AdditionalData & | data | ) | [inline] |
Set the additional data. For more info see the Solver class.
References SolverSelector< VECTOR >::fgmres_data.
| std::string SolverSelector< VECTOR >::get_solver_names | ( | ) | [inline, static] |
Get the names of all implemented solvers.
| ::ExceptionBase& SolverSelector< VECTOR >::ExcSolverDoesNotExist | ( | std::string | arg1 | ) | throw (errortext << "Solver " << arg1 << " does not exist. Use one of " << std::endl << get_solver_names() ) [static] |
Exception.
Referenced by SolverSelector< VECTOR >::solve().
ReductionControl SolverSelector< VECTOR >::control [mutable] |
Stores the ReductionControl that is needed in the constructor of each Solver class. This data member is public, so that it can easily be changed from its default values. If you create a SolverControl or ReductionControl object with the values needed, you can simply use solver.control = my_control to set the values here.
This object is updated in solve(), thus declared mutable here.
Referenced by SolverSelector< VECTOR >::solve().
std::string SolverSelector< VECTOR >::solver_name [protected] |
Stores the name of the solver.
Referenced by SolverSelector< VECTOR >::select(), and SolverSelector< VECTOR >::solve().
SolverRichardson<VECTOR>::AdditionalData SolverSelector< VECTOR >::richardson_data [private] |
Stores the additional data.
Referenced by SolverSelector< VECTOR >::set_data(), and SolverSelector< VECTOR >::solve().
SolverCG<VECTOR>::AdditionalData SolverSelector< VECTOR >::cg_data [private] |
Stores the additional data.
Referenced by SolverSelector< VECTOR >::set_data(), and SolverSelector< VECTOR >::solve().
SolverBicgstab<VECTOR>::AdditionalData SolverSelector< VECTOR >::bicgstab_data [private] |
Stores the additional data.
Referenced by SolverSelector< VECTOR >::set_data(), and SolverSelector< VECTOR >::solve().
SolverGMRES<VECTOR>::AdditionalData SolverSelector< VECTOR >::gmres_data [private] |
Stores the additional data.
Referenced by SolverSelector< VECTOR >::set_data(), and SolverSelector< VECTOR >::solve().
SolverFGMRES<VECTOR>::AdditionalData SolverSelector< VECTOR >::fgmres_data [private] |
Stores the additional data.
Referenced by SolverSelector< VECTOR >::set_data(), and SolverSelector< VECTOR >::solve().
documentation generated on Wed Jul 28 23:06:42 2010 by
doxygen
1.5.6