Belos
Version of the Day
|
Factory for all solvers which Belos supports. More...
#include <BelosSolverFactory.hpp>
Inherits Describable.
Public Types | |
typedef SolverManager< Scalar, MV, OP > | solver_base_type |
The type of the solver returned by create(). More... | |
Public Member Functions | |
SolverFactory () | |
Default constructor. More... | |
Teuchos::RCP< solver_base_type > | create (const std::string &solverName, const Teuchos::RCP< Teuchos::ParameterList > &solverParams) |
Create, configure, and return the specified solver. More... | |
int | numSupportedSolvers () const |
Number of supported solvers. More... | |
Teuchos::Array< std::string > | supportedSolverNames () const |
List of supported solver names. More... | |
bool | isSupported (const std::string &solverName) const |
Whether the given solver name names a supported solver. More... | |
Implementation of Teuchos::Describable interface | |
std::string | description () const |
A string description of this object. More... | |
void | describe (Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const |
Describe this object. More... | |
Factory for all solvers which Belos supports.
New Belos users should start by creating an instance of this class, and using it to create the solver they want.
Belos implements several different iterative solvers. The usual way in which users interact with these solvers is through appropriately named subclasses of SolverManager
. This factory class tells users which solvers are supported. It can initialize and return any supported subclass of SolverManager
, given a short name of the subclass (such as "GMRES" or "CG").
Users ask for the solver they want by a string name, and supply an optional (but recommended) list of parameters (Teuchos::ParameterList) for the solver. The solver may fill in the parameter list with all the valid parameters and their default values, which users may later inspect and modify. Valid solver names include both "canonical names" (each maps one-to-one to a specific SolverManager subclass) and "aliases." Some aliases are short nicknames for canonical names, like "GMRES" for "Pseudoblock GMRES". Other aliases refer to a canonical solver name, but also modify the user's parameter list. For example, "Flexible GMRES" is an alias for "Block GMRES", and also sets the "Flexible Gmres" parameter to true in the input parameter list.
Solver name | Aliases | Solver Manager Class |
---|---|---|
Pseudoblock GMRES | GMRES, Pseudo Block GMRES, PseudoBlockGMRES, PseudoBlockGmres | PseudoBlockGmresSolMgr |
Block GMRES | Flexible GMRES | BlockGmresSolMgr |
Block CG | BlockCGSolMgr | |
Pseudoblock CG | PseudoBlockCG, Pseudo Block CG | PseudoBlockCGSolMgr |
Pseudoblock Stochastic CG | Stochastic CG | PseudoBlockStochasticCGSolMgr |
GCRODR | Recycling GMRES | GCRODRSolMgr |
RCG | Recycling CG | RCGSolMgr |
MINRES | MinresSolMgr | |
LSQR | LSQRSolMgr | |
TFQMR | Transpose-Free QMR | TFQMRSolMgr |
Pseudoblock TFQMR | Pseudo Block Transpose-Free QMR | PseudoBlockTFQMRSolMgr |
Hybrid Block GMRES | GmresPoly, Seed GMRES | GmresPolySolMgr |
PCPG | CGPoly, Seed CG | PCPGSolMgr |
This class' template parameters are the same as those of Belos::SolverManager. Scalar is the scalar type (of entries in the multivector), MV is the multivector type, and OP is the operator type. For example: Scalar=double, MV=Epetra_MultiVector, and OP=Epetra_Operator will access the Epetra specialization of the Belos solvers.
Here is a simple example of how to use SolverFactory to create a GMRES solver for your linear system. Your code needs to include BelosSolverFactory.hpp and whatever linear algebra library header files you would normally use. Suppose that Scalar, MV, and OP have been previously typedef'd to the scalar resp. multivector resp. operator type in your application.
Belos developers who have implemented a new solver (i.e., a new subclass of SolverManager) and who want to make the solver available through the factory should do the following:
Definition at line 246 of file BelosSolverFactory.hpp.
typedef SolverManager<Scalar, MV, OP> Belos::SolverFactory< Scalar, MV, OP >::solver_base_type |
The type of the solver returned by create().
This is a specialization of SolverManager for the same scalar, multivector, and operator types as the template parameters of this factory.
Definition at line 253 of file BelosSolverFactory.hpp.
Belos::SolverFactory< Scalar, MV, OP >::SolverFactory | ( | ) |
Default constructor.
Definition at line 545 of file BelosSolverFactory.hpp.
Teuchos::RCP< typename SolverFactory< Scalar, MV, OP >::solver_base_type > Belos::SolverFactory< Scalar, MV, OP >::create | ( | const std::string & | solverName, |
const Teuchos::RCP< Teuchos::ParameterList > & | solverParams | ||
) |
Create, configure, and return the specified solver.
solverName | [in] Name of the solver. |
solverParams | [in/out] List of parameters with which to configure the solver. If null, we configure the solver with default parameters. If nonnull, the solver may modify the list by filling in missing parameters with default values. You can then inspect the resulting list to learn what parameters the solver accepts. |
Some solvers may be accessed by multiple names ("aliases"). Each solver has a canonical name, and zero or more aliases. Using some aliases (such as those that access Flexible GMRES capability in GMRES-type solvers) may make this method set certain parameters in your parameter list.
The input parameter list is passed in as a Teuchos::RCP because the factory passes it to the solver, and Belos solvers want their input parameter list as a Teuchos::RCP<Teuchos::ParameterList>. We allow a null parameter list only for convenience, and will use default parameter values in that case.
Definition at line 618 of file BelosSolverFactory.hpp.
int Belos::SolverFactory< Scalar, MV, OP >::numSupportedSolvers | ( | ) | const |
Number of supported solvers.
This may differ from the number of supported solver names, since we may accept multiple names ("aliases") for some solvers.
Definition at line 746 of file BelosSolverFactory.hpp.
Teuchos::Array< std::string > Belos::SolverFactory< Scalar, MV, OP >::supportedSolverNames | ( | ) | const |
List of supported solver names.
The length of this list may differ from the number of supported solvers, since we may accept multiple names ("aliases") for some solvers.
Definition at line 781 of file BelosSolverFactory.hpp.
bool Belos::SolverFactory< Scalar, MV, OP >::isSupported | ( | const std::string & | solverName | ) | const |
Whether the given solver name names a supported solver.
std::string Belos::SolverFactory< Scalar, MV, OP >::description | ( | ) | const |
A string description of this object.
Definition at line 678 of file BelosSolverFactory.hpp.
void Belos::SolverFactory< Scalar, MV, OP >::describe | ( | Teuchos::FancyOStream & | out, |
const Teuchos::EVerbosityLevel | verbLevel = Teuchos::Describable::verbLevel_default |
||
) | const |
Describe this object.
At higher verbosity levels, this method will print out the list of names of supported solvers. You can also get this list directly by using the supportedSolverNames() method.
Definition at line 698 of file BelosSolverFactory.hpp.