#include <BelosLinearProblem.hpp>
Public Member Functions | |
Constructors/Destructor | |
| LinearProblem (void) | |
| Default Constructor. | |
| LinearProblem (const RCP< const OP > &A, const RCP< MV > &X, const RCP< const MV > &B) | |
| Unpreconditioned linear system constructor. | |
| LinearProblem (const LinearProblem< ScalarType, MV, OP > &Problem) | |
| Copy Constructor. | |
| virtual | ~LinearProblem (void) |
| Destructor. | |
Set methods | |
| void | setOperator (const RCP< const OP > &A) |
| Set Operator A of linear problem AX = B. | |
| void | setLHS (const RCP< MV > &X) |
| Set left-hand-side X of linear problem AX = B. | |
| void | setRHS (const RCP< const MV > &B) |
| Set right-hand-side B of linear problem AX = B. | |
| void | setLeftPrec (const RCP< const OP > &LP) |
Set left preconditioning operator (LP) of linear problem AX = B. | |
| void | setRightPrec (const RCP< const OP > &RP) |
Set right preconditioning operator (RP) of linear problem AX = B. | |
| void | setCurrLS () |
| Inform the linear problem that the solver is finished with the current linear system. | |
| void | setLSIndex (std::vector< int > &index) |
| Inform the linear problem of the linear systems that need to be solved next. | |
| void | setHermitian () |
| Inform the linear problem that the operator is Hermitian. | |
| void | setLabel (const std::string &label) |
| Set the label prefix used by the timers in this object. The default is "Belos". | |
| RCP< MV > | updateSolution (const RCP< MV > &update=null, bool updateLP=false, ScalarType scale=Teuchos::ScalarTraits< ScalarType >::one()) |
| Compute the new solution to the linear system given the /c update. | |
| RCP< MV > | updateSolution (const RCP< MV > &update=null, ScalarType scale=Teuchos::ScalarTraits< ScalarType >::one()) const |
| Compute the new solution to the linear system given the /c update without updating the linear problem. | |
Set / Reset method | |
| bool | setProblem (const RCP< MV > &newX=null, const RCP< const MV > &newB=null) |
| Setup the linear problem manager. | |
Accessor methods | |
| RCP< const OP > | getOperator () const |
| Get a pointer to the operator A. | |
| RCP< MV > | getLHS () const |
| Get a pointer to the left-hand side X. | |
| RCP< const MV > | getRHS () const |
| Get a pointer to the right-hand side B. | |
| RCP< const MV > | getInitResVec () const |
| Get a pointer to the initial residual vector. | |
| RCP< const MV > | getInitPrecResVec () const |
| Get a pointer to the preconditioned initial residual vector. | |
| RCP< MV > | getCurrLHSVec () |
| Get a pointer to the current left-hand side (solution) of the linear system. | |
| RCP< MV > | getCurrRHSVec () |
| Get a pointer to the current right-hand side of the linear system. | |
| RCP< const OP > | getLeftPrec () const |
| Get a pointer to the left preconditioning operator. | |
| RCP< const OP > | getRightPrec () const |
| Get a pointer to the right preconditioning operator. | |
| const std::vector< int > | getLSIndex () const |
| Get the 0-based index std::vector indicating the current linear systems being solved for. | |
| int | getLSNumber () const |
| Get the number of linear systems that have been set with this LinearProblem object. | |
State methods | |
| bool | isSolutionUpdated () const |
| Get the current status of the solution. | |
| bool | isProblemSet () const |
| If the problem has been set, this will return true. | |
| bool | isHermitian () const |
| Get the current symmetry of the operator. | |
| bool | isLeftPrec () const |
| Get information on whether the linear system is being preconditioned on the left. | |
| bool | isRightPrec () const |
| Get information on whether the linear system is being preconditioned on the right. | |
Apply / Compute methods | |
| void | apply (const MV &x, MV &y) const |
Apply the composite operator of this linear problem to x, returning y. | |
| void | applyOp (const MV &x, MV &y) const |
Apply ONLY the operator to x, returning y. | |
| void | applyLeftPrec (const MV &x, MV &y) const |
Apply ONLY the left preconditioner to x, returning y. | |
| void | applyRightPrec (const MV &x, MV &y) const |
Apply ONLY the right preconditioner to x, returning y. | |
| void | computeCurrResVec (MV *R, const MV *X=0, const MV *B=0) const |
Compute a residual R for this operator given a solution X, and right-hand side B. | |
| void | computeCurrPrecResVec (MV *R, const MV *X=0, const MV *B=0) const |
Compute a residual R for this operator given a solution X, and right-hand side B. | |
Definition at line 67 of file BelosLinearProblem.hpp.
| Belos::LinearProblem< ScalarType, MV, OP >::LinearProblem | ( | void | ) |
Default Constructor.
Creates an empty Belos::LinearProblem instance. The operator A, left-hand-side X and right-hand-side B must be set using the setOperator(), setLHS() and setRHS() methods respectively.
Definition at line 400 of file BelosLinearProblem.hpp.
| Belos::LinearProblem< ScalarType, MV, OP >::LinearProblem | ( | const RCP< const OP > & | A, | |
| const RCP< MV > & | X, | |||
| const RCP< const MV > & | B | |||
| ) |
Unpreconditioned linear system constructor.
Creates an unpreconditioned LinearProblem instance with the Belos::Operator (A), initial guess (X), and right hand side (B). Preconditioners can be set using the setLeftPrec() and setRightPrec() methods, and scaling can also be set using the setLeftScale() and setRightScale() methods.
Definition at line 415 of file BelosLinearProblem.hpp.
| Belos::LinearProblem< ScalarType, MV, OP >::LinearProblem | ( | const LinearProblem< ScalarType, MV, OP > & | Problem | ) |
Copy Constructor.
Makes copy of an existing LinearProblem instance.
Definition at line 436 of file BelosLinearProblem.hpp.
| Belos::LinearProblem< ScalarType, MV, OP >::~LinearProblem | ( | void | ) | [virtual] |
Destructor.
Completely deletes a LinearProblem object.
Definition at line 462 of file BelosLinearProblem.hpp.
| void Belos::LinearProblem< ScalarType, MV, OP >::setOperator | ( | const RCP< const OP > & | A | ) | [inline] |
Set Operator A of linear problem AX = B.
Sets a pointer to an Operator. No copy of the operator is made.
Definition at line 108 of file BelosLinearProblem.hpp.
| void Belos::LinearProblem< ScalarType, MV, OP >::setLHS | ( | const RCP< MV > & | X | ) | [inline] |
Set left-hand-side X of linear problem AX = B.
Sets a pointer to a MultiVec. No copy of the object is made.
Definition at line 113 of file BelosLinearProblem.hpp.
| void Belos::LinearProblem< ScalarType, MV, OP >::setRHS | ( | const RCP< const MV > & | B | ) | [inline] |
Set right-hand-side B of linear problem AX = B.
Sets a pointer to a MultiVec. No copy of the object is made.
Definition at line 118 of file BelosLinearProblem.hpp.
| void Belos::LinearProblem< ScalarType, MV, OP >::setLeftPrec | ( | const RCP< const OP > & | LP | ) | [inline] |
Set left preconditioning operator (LP) of linear problem AX = B.
Sets a pointer to an Operator. No copy of the operator is made.
Definition at line 123 of file BelosLinearProblem.hpp.
| void Belos::LinearProblem< ScalarType, MV, OP >::setRightPrec | ( | const RCP< const OP > & | RP | ) | [inline] |
Set right preconditioning operator (RP) of linear problem AX = B.
Sets a pointer to an Operator. No copy of the operator is made.
Definition at line 128 of file BelosLinearProblem.hpp.
| void Belos::LinearProblem< ScalarType, MV, OP >::setCurrLS | ( | ) |
Inform the linear problem that the solver is finished with the current linear system.
Definition at line 532 of file BelosLinearProblem.hpp.
| void Belos::LinearProblem< ScalarType, MV, OP >::setLSIndex | ( | std::vector< int > & | index | ) |
Inform the linear problem of the linear systems that need to be solved next.
Any calls to get the current RHS/LHS vectors after this method is called will return the new linear systems indicated by index. The length of index is assumed to be the blocksize and entries of index must be between 0 and the number of vectors in the RHS/LHS multivector. An entry of the index std::vector can also be -1, which means this column of the linear system is augmented using a random std::vector.
Definition at line 466 of file BelosLinearProblem.hpp.
| void Belos::LinearProblem< ScalarType, MV, OP >::setHermitian | ( | ) | [inline] |
Inform the linear problem that the operator is Hermitian.
This knowledge may allow the operator to take advantage of the linear problem symmetry. However, this should not be set to true if the preconditioner is not Hermitian, or symmetrically applied.
Definition at line 152 of file BelosLinearProblem.hpp.
| void Belos::LinearProblem< ScalarType, MV, OP >::setLabel | ( | const std::string & | label | ) | [inline] |
Set the label prefix used by the timers in this object. The default is "Belos".
Definition at line 158 of file BelosLinearProblem.hpp.
| RCP< MV > Belos::LinearProblem< ScalarType, MV, OP >::updateSolution | ( | const RCP< MV > & | update = null, |
|
| bool | updateLP = false, |
|||
| ScalarType | scale = Teuchos::ScalarTraits< ScalarType >::one() | |||
| ) |
Compute the new solution to the linear system given the /c update.
updateLP is true, then the next time GetCurrResVecs is called, a new residual will be computed. This keeps the linear problem from having to recompute the residual vector everytime it's asked for if the solution hasn't been updated. If updateLP is false, the new solution is computed without actually updating the linear problem. Definition at line 566 of file BelosLinearProblem.hpp.
| RCP<MV> Belos::LinearProblem< ScalarType, MV, OP >::updateSolution | ( | const RCP< MV > & | update = null, |
|
| ScalarType | scale = Teuchos::ScalarTraits<ScalarType>::one() | |||
| ) | const [inline] |
Compute the new solution to the linear system given the /c update without updating the linear problem.
Definition at line 171 of file BelosLinearProblem.hpp.
| bool Belos::LinearProblem< ScalarType, MV, OP >::setProblem | ( | const RCP< MV > & | newX = null, |
|
| const RCP< const MV > & | newB = null | |||
| ) |
Setup the linear problem manager.
This is useful for solving the linear system with another right-hand side or getting the linear problem prepared to solve the linear system that was already passed in. The internal flags will be set as if the linear system manager was just initialized and the initial residual will be computed.
Definition at line 614 of file BelosLinearProblem.hpp.
| RCP<const OP> Belos::LinearProblem< ScalarType, MV, OP >::getOperator | ( | ) | const [inline] |
| RCP<MV> Belos::LinearProblem< ScalarType, MV, OP >::getLHS | ( | ) | const [inline] |
| RCP<const MV> Belos::LinearProblem< ScalarType, MV, OP >::getRHS | ( | ) | const [inline] |
| RCP<const MV> Belos::LinearProblem< ScalarType, MV, OP >::getInitResVec | ( | ) | const [inline] |
Get a pointer to the initial residual vector.
Definition at line 205 of file BelosLinearProblem.hpp.
| RCP<const MV> Belos::LinearProblem< ScalarType, MV, OP >::getInitPrecResVec | ( | ) | const [inline] |
Get a pointer to the preconditioned initial residual vector.
Definition at line 210 of file BelosLinearProblem.hpp.
| RCP< MV > Belos::LinearProblem< ScalarType, MV, OP >::getCurrLHSVec | ( | ) |
Get a pointer to the current left-hand side (solution) of the linear system.
This method is called by the solver or any method that is interested in the current linear system being solved for.
Definition at line 674 of file BelosLinearProblem.hpp.
| RCP< MV > Belos::LinearProblem< ScalarType, MV, OP >::getCurrRHSVec | ( | ) |
Get a pointer to the current right-hand side of the linear system.
This method is called by the solver of any method that is interested in the current linear system being solved for.
Definition at line 685 of file BelosLinearProblem.hpp.
| RCP<const OP> Belos::LinearProblem< ScalarType, MV, OP >::getLeftPrec | ( | ) | const [inline] |
Get a pointer to the left preconditioning operator.
Definition at line 233 of file BelosLinearProblem.hpp.
| RCP<const OP> Belos::LinearProblem< ScalarType, MV, OP >::getRightPrec | ( | ) | const [inline] |
Get a pointer to the right preconditioning operator.
Definition at line 236 of file BelosLinearProblem.hpp.
| const std::vector<int> Belos::LinearProblem< ScalarType, MV, OP >::getLSIndex | ( | ) | const [inline] |
Get the 0-based index std::vector indicating the current linear systems being solved for.
Since the block size is independent of the number of right-hand sides for some solvers (GMRES, CG, etc.), it is important to know which linear systems are being solved for. That may mean you need to update the information about the norms of your initial residual std::vector for weighting purposes. This information can keep you from querying the solver for information that rarely changes.
The std::vector returned from this method is valid if isProblemSet() returns true.
Definition at line 250 of file BelosLinearProblem.hpp.
| int Belos::LinearProblem< ScalarType, MV, OP >::getLSNumber | ( | ) | const [inline] |
Get the number of linear systems that have been set with this LinearProblem object.
Definition at line 256 of file BelosLinearProblem.hpp.
| bool Belos::LinearProblem< ScalarType, MV, OP >::isSolutionUpdated | ( | ) | const [inline] |
Get the current status of the solution.
This only means that the current linear system being solved for ( obtained by getCurr<LHS/RHS>Vec() ) has been updated by the solver. This will be true every iteration for solvers like CG, but not true until restarts for GMRES.
Definition at line 268 of file BelosLinearProblem.hpp.
| bool Belos::LinearProblem< ScalarType, MV, OP >::isProblemSet | ( | ) | const [inline] |
If the problem has been set, this will return true.
Definition at line 271 of file BelosLinearProblem.hpp.
| bool Belos::LinearProblem< ScalarType, MV, OP >::isHermitian | ( | ) | const [inline] |
| bool Belos::LinearProblem< ScalarType, MV, OP >::isLeftPrec | ( | ) | const [inline] |
Get information on whether the linear system is being preconditioned on the left.
Definition at line 277 of file BelosLinearProblem.hpp.
| bool Belos::LinearProblem< ScalarType, MV, OP >::isRightPrec | ( | ) | const [inline] |
Get information on whether the linear system is being preconditioned on the right.
Definition at line 280 of file BelosLinearProblem.hpp.
| void Belos::LinearProblem< ScalarType, MV, OP >::apply | ( | const MV & | x, | |
| MV & | y | |||
| ) | const |
Apply the composite operator of this linear problem to x, returning y.
This application is the composition of the left/right preconditioner and operator. Most Krylov methods will use this application method within their code.
Precondition:
getOperator().get()!=NULL Definition at line 696 of file BelosLinearProblem.hpp.
| void Belos::LinearProblem< ScalarType, MV, OP >::applyOp | ( | const MV & | x, | |
| MV & | y | |||
| ) | const |
Apply ONLY the operator to x, returning y.
This application is only of the linear problem operator, no preconditioners are applied. Flexible variants of Krylov methods will use this application method within their code.
Precondition:
getOperator().get()!=NULL Definition at line 758 of file BelosLinearProblem.hpp.
| void Belos::LinearProblem< ScalarType, MV, OP >::applyLeftPrec | ( | const MV & | x, | |
| MV & | y | |||
| ) | const |
Apply ONLY the left preconditioner to x, returning y.
This application is only of the left preconditioner, which may be required for flexible variants of Krylov methods.
Definition at line 770 of file BelosLinearProblem.hpp.
| void Belos::LinearProblem< ScalarType, MV, OP >::applyRightPrec | ( | const MV & | x, | |
| MV & | y | |||
| ) | const |
Apply ONLY the right preconditioner to x, returning y.
This application is only of the right preconditioner, which may be required for flexible variants of Krylov methods.
Definition at line 782 of file BelosLinearProblem.hpp.
| void Belos::LinearProblem< ScalarType, MV, OP >::computeCurrResVec | ( | MV * | R, | |
| const MV * | X = 0, |
|||
| const MV * | B = 0 | |||
| ) | const |
Compute a residual R for this operator given a solution X, and right-hand side B.
This method will compute the residual for the current linear system if X and B are null pointers. The result will be returned into R. Otherwise R = OP(A)X - B will be computed and returned.
Definition at line 861 of file BelosLinearProblem.hpp.
| void Belos::LinearProblem< ScalarType, MV, OP >::computeCurrPrecResVec | ( | MV * | R, | |
| const MV * | X = 0, |
|||
| const MV * | B = 0 | |||
| ) | const |
Compute a residual R for this operator given a solution X, and right-hand side B.
This method will compute the residual for the current linear system if X and B are null pointers. The result will be returned into R. Otherwise R = OP(A)X - B will be computed and returned.
Definition at line 794 of file BelosLinearProblem.hpp.
1.4.7