Skip to content

Commit

Permalink
Merge Pull Request #10435 from hkthorn/Trilinos/develop
Browse files Browse the repository at this point in the history
Automatically Merged using Trilinos Pull Request AutoTester
PR Title: Implements the achievedTol interface for the GmresPolySolMgr
PR Author: hkthorn
  • Loading branch information
trilinos-autotester authored Apr 25, 2022
2 parents 4a414e5 + 19c3699 commit f79e62d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
30 changes: 27 additions & 3 deletions packages/belos/src/BelosGmresPolySolMgr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,9 @@ template<class ScalarType, class MV, class OP>
class GmresPolySolMgr : public SolverManager<ScalarType,MV,OP> {
private:

typedef MultiVecTraits<ScalarType,MV> MVT;
typedef Teuchos::ScalarTraits<ScalarType> STS;
typedef typename Teuchos::ScalarTraits<ScalarType>::magnitudeType MagnitudeType;

typedef Teuchos::ScalarTraits<MagnitudeType> MTS;
typedef Belos::GmresPolyOp<ScalarType,MV,OP> gmres_poly_t;
typedef Belos::GmresPolyMv<ScalarType,MV> gmres_poly_mv_t;

Expand Down Expand Up @@ -217,6 +217,26 @@ class GmresPolySolMgr : public SolverManager<ScalarType,MV,OP> {
*/
Teuchos::RCP<const Teuchos::ParameterList> getCurrentParameters() const override { return params_; }

/*! \brief Tolerance achieved by the last \c solve() invocation.
This is the maximum over all right-hand sides' achieved
convergence tolerances, and is set whether or not the solve
actually managed to achieve the desired convergence tolerance.
\warning This solver manager may be use as either a polynomial
preconditioned iterative method or a polynomial preconditioner.
In the later case, where a static polynomial is being applied
through each call to solve(), there is not an outer solve that
can provide the achieved tolerance.
\warning This result may not be meaningful if there was a loss
of accuracy during the outer solve. You should first call \c
isLOADetected() to check for a loss of accuracy during the
last solve.
*/
MagnitudeType achievedTol() const override {
return achievedTol_;
}

/*! \brief Return the timers for this object.
*
* The timers are ordered as follows:
Expand Down Expand Up @@ -331,7 +351,7 @@ class GmresPolySolMgr : public SolverManager<ScalarType,MV,OP> {
#endif

// Current solver values.
MagnitudeType polyTol_;
MagnitudeType polyTol_, achievedTol_;
int maxDegree_, numIters_;
int verbosity_;
bool hasOuterSolver_;
Expand Down Expand Up @@ -363,6 +383,7 @@ template<class ScalarType, class MV, class OP>
GmresPolySolMgr<ScalarType,MV,OP>::GmresPolySolMgr () :
outputStream_ (Teuchos::rcp(outputStream_default_,false)),
polyTol_ (DefaultSolverParameters::polyTol),
achievedTol_(MTS::zero()),
maxDegree_ (maxDegree_default_),
numIters_ (0),
verbosity_ (verbosity_default_),
Expand Down Expand Up @@ -691,6 +712,7 @@ ReturnType GmresPolySolMgr<ScalarType,MV,OP>::solve ()
ret = solver->solve();
numIters_ = solver->getNumIters();
loaDetected_ = solver->isLOADetected();
achievedTol_ = solver->achievedTol();

} // if (hasOuterSolver_ && maxDegree_)
else if (hasOuterSolver_) {
Expand All @@ -706,12 +728,14 @@ ReturnType GmresPolySolMgr<ScalarType,MV,OP>::solve ()
ret = solver->solve();
numIters_ = solver->getNumIters();
loaDetected_ = solver->isLOADetected();
achievedTol_ = solver->achievedTol();

}
else if (maxDegree_) {

// Apply the polynomial to the current linear system
poly_Op_->ApplyPoly( *problem_->getRHS(), *problem_->getLHS() );
achievedTol_ = MTS::one();

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,9 @@ int main(int argc, char *argv[]) {
//
Belos::ReturnType ret = solver->solve();
//
// Compute actual residuals.
std::cout << "Belos::GmresPolySolMgr returned achievedTol: " << solver->achievedTol() << std::endl << std::endl;
//
// Compute actual residuals.
RCP<MyMultiVec<ST> > temp = rcp( new MyMultiVec<ST>(dim,numrhs) );
OPT::Apply( *A, *soln, *temp );
MVT::MvAddMv( one, *rhs, -one, *temp, *temp );
Expand Down

0 comments on commit f79e62d

Please sign in to comment.