LifeV
|
LinearSolver - Class to wrap linear solver. More...
#include <LinearSolver.hpp>
Public Types | |
enum | SolverType { UndefinedSolver, Belos, AztecOO } |
typedef Real | value_Type |
typedef LinearSolver | solver_Type |
typedef Epetra_MultiVector | multiVector_Type |
typedef std::shared_ptr< multiVector_Type > | multiVectorPtr_Type |
typedef Epetra_Operator | operator_Type |
typedef std::shared_ptr< operator_Type > | operatorPtr_Type |
typedef Operators::SolverOperator | SolverOperator_Type |
typedef std::shared_ptr< SolverOperator_Type > | SolverOperatorPtr_Type |
typedef MatrixEpetra< Real > | matrix_Type |
typedef std::shared_ptr< matrix_Type > | matrixPtr_Type |
typedef VectorEpetra | vector_Type |
typedef std::shared_ptr< VectorEpetra > | vectorPtr_Type |
typedef Preconditioner | preconditioner_Type |
typedef std::shared_ptr< preconditioner_Type > | preconditionerPtr_Type |
typedef Teuchos::ParameterList | parameterList_Type |
typedef Teuchos::RCP< parameterList_Type > | parameterListPtr_Type |
Constructors & Destructor | |
LinearSolver () | |
Empty constructor. More... | |
LinearSolver (const std::shared_ptr< Epetra_Comm > commPtr) | |
Constructor. More... | |
~LinearSolver () | |
Destructor. More... | |
Methods | |
Int | solve (vectorPtr_Type solutionPtr) |
Solves the system and returns the number of iterations. More... | |
Real | computeResidual (vectorPtr_Type solutionPtr) |
Compute the residual. More... | |
std::string | printStatus () |
return the solver status More... | |
void | setPreconditionerFromGetPot (const GetPot &dataFile, const std::string §ion) |
Setup the preconditioner from a GetPot file. More... | |
void | buildPreconditioner () |
Builds the preconditioner starting from the matrix "baseMatrixForPreconditioner". More... | |
void | resetPreconditioner () |
Reset the stored preconditioner. More... | |
bool | isPreconditionerSet () const |
Return true if preconditioner has been setted. More... | |
void | resetStatus () |
Reset the status for the state of convergence and loss of accuracy. More... | |
void | showMe (std::ostream &output=std::cout) const |
Print informations about the solver. More... | |
void | setupSolverOperator () |
Setup the solver operator to be used. More... | |
Set Method | |
void | setSolverType (const SolverType &solverType) |
Set the solver which should be used. More... | |
void | setCommunicator (const std::shared_ptr< Epetra_Comm > commPtr) |
Method to set communicator for Displayer (for empty constructor) More... | |
void | setOperator (matrixPtr_Type matrixPtr) |
Method to set matrix from MatrixEpetra. More... | |
void | setOperator (operatorPtr_Type operPtr) |
Method to set a general linear operator (of class derived from Epetra_Operator) defining the linear system. More... | |
void | setRightHandSide (const vectorPtr_Type rhsPtr) |
Method to set the right hand side (rhs) of the linear system. More... | |
void | setPreconditioner (preconditionerPtr_Type preconditionerPtr) |
Method to set an Preconditioner preconditioner. More... | |
void | setPreconditioner (operatorPtr_Type preconditionerPtr) |
Method to set a general Epetra_Operator as preconditioner. More... | |
void | setBaseMatrixForPreconditioner (matrixPtr_Type baseMatrixPtr) |
Method to set a matrix on which the preconditioner should be created. More... | |
void | setParameters (const Teuchos::ParameterList &list) |
Method to setup the solver using Teuchos::ParameterList. More... | |
template<typename T > | |
void | setParameter (const std::string &name, T value) |
Method to set a particular parameter. More... | |
void | resetParameters () |
Method to reset the parameters list of the solver. More... | |
void | setReusePreconditioner (const bool reusePreconditioner) |
Specify if the preconditioner should be reuse or not. More... | |
void | setQuitOnFailure (const bool enable) |
Specify if the application should stop when problems occur in the iterations. More... | |
void | setTolerance (const Real &tolerance) |
Set the tolerance of the solver. More... | |
Get Method | |
Int | numIterations () const |
Return the total number of iterations. More... | |
Real | recursiveResidual () |
Return the recursive residual. More... | |
preconditionerPtr_Type & | preconditioner () |
Method to get a shared pointer to the preconditioner. More... | |
Teuchos::ParameterList & | parametersList () |
Return a Teuchos parameters list. More... | |
SolverOperatorPtr_Type | solver () |
Return a pointer on the Belos solver manager. More... | |
std::shared_ptr< Displayer > | displayer () |
Return a shared pointer on the displayer. More... | |
Int | maxItersForReuse () const |
Returns the maximum of iterations tolerate to avoid recomputing the preconditioner. More... | |
bool | reusePreconditioner () const |
Returns if the preconditioner can be reused. More... | |
bool | quitOnFailure () const |
Returns if the application should stop if a problem occurs. More... | |
bool | silent () const |
Returns if the solver is in silent mode. More... | |
SolverOperator_Type::SolverOperatorStatusType | hasReachedMaxNumIters () const |
Returns if the maximum number of iterations has been reached. More... | |
SolverOperator_Type::SolverOperatorStatusType | isLossOfAccuracyDetected () const |
Returns if a loss of precision has been detected. More... | |
SolverOperator_Type::SolverOperatorStatusType | hasConverged () const |
Returns if the convergence has been achieved. More... | |
LinearSolver - Class to wrap linear solver.
By default the solver is block gmres.
Definition at line 92 of file LinearSolver.hpp.
typedef Real value_Type |
Definition at line 99 of file LinearSolver.hpp.
typedef LinearSolver solver_Type |
Definition at line 101 of file LinearSolver.hpp.
typedef Epetra_MultiVector multiVector_Type |
Definition at line 102 of file LinearSolver.hpp.
typedef std::shared_ptr<multiVector_Type> multiVectorPtr_Type |
Definition at line 103 of file LinearSolver.hpp.
typedef Epetra_Operator operator_Type |
Definition at line 104 of file LinearSolver.hpp.
typedef std::shared_ptr<operator_Type> operatorPtr_Type |
Definition at line 105 of file LinearSolver.hpp.
Definition at line 106 of file LinearSolver.hpp.
typedef std::shared_ptr< SolverOperator_Type > SolverOperatorPtr_Type |
Definition at line 107 of file LinearSolver.hpp.
typedef MatrixEpetra<Real> matrix_Type |
Definition at line 108 of file LinearSolver.hpp.
typedef std::shared_ptr<matrix_Type> matrixPtr_Type |
Definition at line 109 of file LinearSolver.hpp.
typedef VectorEpetra vector_Type |
Definition at line 110 of file LinearSolver.hpp.
typedef std::shared_ptr<VectorEpetra> vectorPtr_Type |
Definition at line 111 of file LinearSolver.hpp.
typedef Preconditioner preconditioner_Type |
Definition at line 112 of file LinearSolver.hpp.
typedef std::shared_ptr<preconditioner_Type> preconditionerPtr_Type |
Definition at line 113 of file LinearSolver.hpp.
typedef Teuchos::ParameterList parameterList_Type |
Definition at line 114 of file LinearSolver.hpp.
typedef Teuchos::RCP< parameterList_Type > parameterListPtr_Type |
Definition at line 115 of file LinearSolver.hpp.
enum SolverType |
Enumerator | |
---|---|
UndefinedSolver | |
Belos | |
AztecOO |
Definition at line 117 of file LinearSolver.hpp.
LinearSolver | ( | ) |
Empty constructor.
Definition at line 49 of file LinearSolver.cpp.
LinearSolver | ( | const std::shared_ptr< Epetra_Comm > | commPtr | ) |
Constructor.
commPtr | Communicator |
Definition at line 71 of file LinearSolver.cpp.
~LinearSolver | ( | ) |
Destructor.
Definition at line 93 of file LinearSolver.cpp.
Int solve | ( | vectorPtr_Type | solutionPtr | ) |
Solves the system and returns the number of iterations.
The Matrix has already been passed by the method setMatrix or setOperator
The preconditioner is build starting from the matrix baseMatrixForPreconditioner if it is set otherwise from the problem matrix.
solutionPtr | Vector to store the solution |
Definition at line 102 of file LinearSolver.cpp.
Real computeResidual | ( | vectorPtr_Type | solutionPtr | ) |
Compute the residual.
solutionPtr | Shared pointer on the solution of the system The method returns -1 if an error occurs |
Definition at line 218 of file LinearSolver.cpp.
std::string printStatus | ( | ) |
return the solver status
Definition at line 241 of file LinearSolver.cpp.
void setPreconditionerFromGetPot | ( | const GetPot & | dataFile, |
const std::string & | section | ||
) |
Setup the preconditioner from a GetPot file.
dataFile | GetPot object which contains the data about the preconditioner |
section | Section the GetPot structure where to find the informations about the preconditioner |
Definition at line 267 of file LinearSolver.cpp.
void buildPreconditioner | ( | ) |
Builds the preconditioner starting from the matrix "baseMatrixForPreconditioner".
The preconditioner is build starting from the matrix baseMatrixForPreconditioner by the preconditioner object passed in by the method setPreconditioner
baseMatrixForPreconditioner | Base matrix for the preconditioner construction |
Definition at line 278 of file LinearSolver.cpp.
void resetPreconditioner | ( | ) |
Reset the stored preconditioner.
Note: This method only affects the LifeV::Preconditioner (i.e. not the Epetra_Operators used as preconditioner
Definition at line 328 of file LinearSolver.cpp.
bool isPreconditionerSet | ( | ) | const |
Return true if preconditioner has been setted.
Definition at line 337 of file LinearSolver.cpp.
void resetStatus | ( | ) |
Reset the status for the state of convergence and loss of accuracy.
Definition at line 348 of file LinearSolver.cpp.
void showMe | ( | std::ostream & | output = std::cout | ) | const |
Print informations about the solver.
Definition at line 356 of file LinearSolver.cpp.
void setupSolverOperator | ( | ) |
Setup the solver operator to be used.
Definition at line 368 of file LinearSolver.cpp.
void setSolverType | ( | const SolverType & | solverType | ) |
Set the solver which should be used.
solverOperatorType | Type of solver manager The solver type can be chosen from one of the following: Aztecoo, Belos |
Definition at line 415 of file LinearSolver.cpp.
void setCommunicator | ( | const std::shared_ptr< Epetra_Comm > | commPtr | ) |
Method to set communicator for Displayer (for empty constructor)
commPtr | Communicator for the displayer |
Definition at line 421 of file LinearSolver.cpp.
void setOperator | ( | matrixPtr_Type | matrixPtr | ) |
Method to set matrix from MatrixEpetra.
matrixPtr | Matrix of the system |
Definition at line 426 of file LinearSolver.cpp.
void setOperator | ( | operatorPtr_Type | operPtr | ) |
Method to set a general linear operator (of class derived from Epetra_Operator) defining the linear system.
operPtr | Pointer to an operator for the system |
Definition at line 433 of file LinearSolver.cpp.
void setRightHandSide | ( | const vectorPtr_Type | rhsPtr | ) |
Method to set the right hand side (rhs) of the linear system.
rhsPtr | right hand side of the system |
Definition at line 440 of file LinearSolver.cpp.
void setPreconditioner | ( | preconditionerPtr_Type | preconditionerPtr | ) |
Method to set an Preconditioner preconditioner.
preconditionerPtr | Preconditioner to be used to solve the system |
Definition at line 446 of file LinearSolver.cpp.
void setPreconditioner | ( | operatorPtr_Type | preconditionerPtr | ) |
Method to set a general Epetra_Operator as preconditioner.
preconditionerPtr | Preconditioner to be set of type Epetra_Operator |
Definition at line 455 of file LinearSolver.cpp.
void setBaseMatrixForPreconditioner | ( | matrixPtr_Type | baseMatrixPtr | ) |
Method to set a matrix on which the preconditioner should be created.
baseMatrixPtr | matrix on which the preconditioner should be created |
Definition at line 464 of file LinearSolver.cpp.
void setParameters | ( | const Teuchos::ParameterList & | list | ) |
Method to setup the solver using Teuchos::ParameterList.
list | Teuchos::ParameterList object Note: The parameters are added to the existing one. Use resetParameters to clean the parameters list. |
Definition at line 470 of file LinearSolver.cpp.
void setParameter | ( | const std::string & | name, |
T | value | ||
) |
Method to set a particular parameter.
name | Name of the parameter |
value | Value of the parameter Note: The parameters are added to the existing one. Use resetParameters to clean the parameters list. |
Definition at line 379 of file LinearSolver.hpp.
void resetParameters | ( | ) |
Method to reset the parameters list of the solver.
Definition at line 492 of file LinearSolver.cpp.
void setReusePreconditioner | ( | const bool | reusePreconditioner | ) |
Specify if the preconditioner should be reuse or not.
reusePreconditioner | If set to true, do not recompute the preconditioner |
Definition at line 498 of file LinearSolver.cpp.
void setQuitOnFailure | ( | const bool | enable | ) |
Specify if the application should stop when problems occur in the iterations.
enable | If set to true, application will stop if problems occur Note: This option is useful for simulation on clusters. In particular if the system does not converge or if a loss of precision occurs time is saved by stoping the simulation |
Definition at line 504 of file LinearSolver.cpp.
void setTolerance | ( | const Real & | tolerance | ) |
Set the tolerance of the solver.
tolerance | Tolerance used by the solver |
Definition at line 510 of file LinearSolver.cpp.
Int numIterations | ( | ) | const |
Return the total number of iterations.
Definition at line 520 of file LinearSolver.cpp.
Real recursiveResidual | ( | ) |
Return the recursive residual.
The method returns -1 if an error occurs
Definition at line 527 of file LinearSolver.cpp.
LinearSolver::preconditionerPtr_Type & preconditioner | ( | ) |
Method to get a shared pointer to the preconditioner.
Definition at line 547 of file LinearSolver.cpp.
Teuchos::ParameterList & parametersList | ( | ) |
Return a Teuchos parameters list.
Definition at line 553 of file LinearSolver.cpp.
LinearSolver::SolverOperatorPtr_Type solver | ( | ) |
Return a pointer on the Belos solver manager.
Definition at line 559 of file LinearSolver.cpp.
std::shared_ptr< Displayer > displayer | ( | ) |
Return a shared pointer on the displayer.
Definition at line 565 of file LinearSolver.cpp.
Int maxItersForReuse | ( | ) | const |
Returns the maximum of iterations tolerate to avoid recomputing the preconditioner.
Definition at line 571 of file LinearSolver.cpp.
bool reusePreconditioner | ( | ) | const |
Returns if the preconditioner can be reused.
Definition at line 577 of file LinearSolver.cpp.
bool quitOnFailure | ( | ) | const |
Returns if the application should stop if a problem occurs.
Definition at line 583 of file LinearSolver.cpp.
bool silent | ( | ) | const |
Returns if the solver is in silent mode.
Definition at line 589 of file LinearSolver.cpp.
LinearSolver::SolverOperator_Type::SolverOperatorStatusType hasReachedMaxNumIters | ( | ) | const |
Returns if the maximum number of iterations has been reached.
Definition at line 595 of file LinearSolver.cpp.
LinearSolver::SolverOperator_Type::SolverOperatorStatusType isLossOfAccuracyDetected | ( | ) | const |
Returns if a loss of precision has been detected.
Definition at line 601 of file LinearSolver.cpp.
LinearSolver::SolverOperator_Type::SolverOperatorStatusType hasConverged | ( | ) | const |
Returns if the convergence has been achieved.
Definition at line 607 of file LinearSolver.cpp.
|
private |
Definition at line 348 of file LinearSolver.hpp.
|
private |
Definition at line 349 of file LinearSolver.hpp.
|
private |
Definition at line 350 of file LinearSolver.hpp.
|
private |
Definition at line 351 of file LinearSolver.hpp.
|
private |
Definition at line 353 of file LinearSolver.hpp.
|
private |
Definition at line 354 of file LinearSolver.hpp.
|
private |
Definition at line 356 of file LinearSolver.hpp.
|
private |
Definition at line 357 of file LinearSolver.hpp.
|
private |
Definition at line 359 of file LinearSolver.hpp.
|
private |
Definition at line 360 of file LinearSolver.hpp.
|
private |
Definition at line 363 of file LinearSolver.hpp.
|
private |
Definition at line 364 of file LinearSolver.hpp.
|
private |
Definition at line 365 of file LinearSolver.hpp.
|
private |
Definition at line 366 of file LinearSolver.hpp.
|
private |
Definition at line 369 of file LinearSolver.hpp.
|
private |
Definition at line 370 of file LinearSolver.hpp.
|
private |
Definition at line 371 of file LinearSolver.hpp.
|
private |
Definition at line 373 of file LinearSolver.hpp.