10#ifndef BELOS_PSEUDO_BLOCK_CG_SOLMGR_HPP
11#define BELOS_PSEUDO_BLOCK_CG_SOLMGR_HPP
31#include "Teuchos_LAPACK.hpp"
32#ifdef BELOS_TEUCHOS_TIME_MONITOR
33#include "Teuchos_TimeMonitor.hpp"
73 template<
class ScalarType,
class MV,
class OP,
class DM = DefaultDenseMatrix<
int,ScalarType>,
74 const
bool supportsScalarType =
75 Details::LapackSupportsScalar<ScalarType>::value>
78 Details::LapackSupportsScalar<ScalarType>::value>
80 static const bool scalarTypeIsSupported =
89 const Teuchos::RCP<Teuchos::ParameterList> &pl) :
94 Teuchos::RCP<StatusTestGenResNorm<ScalarType,MV,OP,DM> >
99 template<
class ScalarType,
class MV,
class OP,
class DM>
106 using SCT = Teuchos::ScalarTraits<ScalarType>;
107 using MagnitudeType =
typename Teuchos::ScalarTraits<ScalarType>::magnitudeType;
108 using MT = Teuchos::ScalarTraits<MagnitudeType>;
138 const Teuchos::RCP<Teuchos::ParameterList> &pl );
144 Teuchos::RCP<SolverManager<ScalarType, MV, OP, DM> >
clone ()
const override {
158 Teuchos::RCP<const Teuchos::ParameterList> getValidParameters()
const override;
169 Teuchos::Array<Teuchos::RCP<Teuchos::Time> >
getTimers()
const {
170 return Teuchos::tuple(timerSolve_);
205 Teuchos::RCP<StatusTestGenResNorm<ScalarType,MV,OP,DM> >
217 void setParameters(
const Teuchos::RCP<Teuchos::ParameterList> ¶ms )
override;
221 debugStatusTest_ = debugStatusTest;
226 sTest_ = Teuchos::null;
227 outputTest_ = Teuchos::null;
270 std::string description()
const override;
275 void compute_condnum_tridiag_sym(Teuchos::ArrayView<MagnitudeType> diag,
276 Teuchos::ArrayView<MagnitudeType> offdiag,
277 Teuchos::ArrayRCP<MagnitudeType>& lambdas,
278 ScalarType & lambda_min,
279 ScalarType & lambda_max,
280 ScalarType & ConditionNumber );
283 Teuchos::RCP<LinearProblem<ScalarType,MV,OP,DM> > problem_;
286 Teuchos::RCP<OutputManager<ScalarType> > printer_;
287 Teuchos::RCP<std::ostream> outputStream_;
290 Teuchos::RCP<StatusTest<ScalarType,MV,OP,DM> > sTest_;
291 Teuchos::RCP<StatusTestMaxIters<ScalarType,MV,OP,DM> > maxIterTest_;
292 Teuchos::RCP<StatusTestGenResNorm<ScalarType,MV,OP,DM> > convTest_;
293 Teuchos::RCP<StatusTestOutput<ScalarType,MV,OP,DM> > outputTest_;
294 Teuchos::RCP<StatusTest<ScalarType,MV,OP,DM> > debugStatusTest_;
297 Teuchos::RCP<Teuchos::ParameterList> params_;
304 mutable Teuchos::RCP<const Teuchos::ParameterList> validParams_;
307 static constexpr int maxIters_default_ = 1000;
308 static constexpr bool assertPositiveDefiniteness_default_ =
true;
309 static constexpr bool showMaxResNormOnly_default_ =
false;
312 static constexpr int outputFreq_default_ = -1;
313 static constexpr int defQuorum_default_ = 1;
314 static constexpr bool foldConvergenceDetectionIntoAllreduce_default_ =
false;
315 static constexpr const char * resScale_default_ =
"Norm of Initial Residual";
316 static constexpr const char * label_default_ =
"Belos";
317 static constexpr bool genCondEst_default_ =
false;
320 MagnitudeType convtol_,achievedTol_;
321 int maxIters_, numIters_;
322 int verbosity_, outputStyle_, outputFreq_, defQuorum_;
323 bool assertPositiveDefiniteness_, showMaxResNormOnly_;
324 bool foldConvergenceDetectionIntoAllreduce_;
325 std::string resScale_;
327 ScalarType condEstimate_;
328 Teuchos::ArrayRCP<MagnitudeType> eigenEstimates_;
330 Teuchos::RCP<CGIterationStateBase<ScalarType, MV, DM> > state_;
334 Teuchos::RCP<Teuchos::Time> timerSolve_;
342template<
class ScalarType,
class MV,
class OP,
class DM>
344 outputStream_(Teuchos::rcpFromRef(std::cout)),
346 maxIters_(maxIters_default_),
348 verbosity_(verbosity_default_),
349 outputStyle_(outputStyle_default_),
350 outputFreq_(outputFreq_default_),
351 defQuorum_(defQuorum_default_),
352 assertPositiveDefiniteness_(assertPositiveDefiniteness_default_),
353 showMaxResNormOnly_(showMaxResNormOnly_default_),
354 foldConvergenceDetectionIntoAllreduce_(foldConvergenceDetectionIntoAllreduce_default_),
355 resScale_(resScale_default_),
356 genCondEst_(genCondEst_default_),
357 condEstimate_(-Teuchos::ScalarTraits<ScalarType>::one()),
358 label_(label_default_),
363template<
class ScalarType,
class MV,
class OP,
class DM>
366 const Teuchos::RCP<Teuchos::ParameterList> &pl ) :
368 outputStream_(Teuchos::rcpFromRef(std::cout)),
370 maxIters_(maxIters_default_),
372 verbosity_(verbosity_default_),
373 outputStyle_(outputStyle_default_),
374 outputFreq_(outputFreq_default_),
375 defQuorum_(defQuorum_default_),
376 assertPositiveDefiniteness_(assertPositiveDefiniteness_default_),
377 showMaxResNormOnly_(showMaxResNormOnly_default_),
378 foldConvergenceDetectionIntoAllreduce_(foldConvergenceDetectionIntoAllreduce_default_),
379 resScale_(resScale_default_),
380 genCondEst_(genCondEst_default_),
381 condEstimate_(-Teuchos::ScalarTraits<ScalarType>::one()),
382 label_(label_default_),
385 TEUCHOS_TEST_FOR_EXCEPTION(
386 problem_.is_null (), std::invalid_argument,
387 "Belos::PseudoBlockCGSolMgr two-argument constructor: "
388 "'problem' is null. You must supply a non-null Belos::LinearProblem "
389 "instance when calling this constructor.");
391 if (! pl.is_null ()) {
397template<
class ScalarType,
class MV,
class OP,
class DM>
399setParameters (
const Teuchos::RCP<Teuchos::ParameterList>& params)
401 using Teuchos::ParameterList;
402 using Teuchos::parameterList;
425 if (params_.is_null ()) {
427 params_ = parameterList (defaultParams->name ());
429 params->validateParameters (*defaultParams);
433 if (params->isParameter (
"Maximum Iterations")) {
434 maxIters_ = params->get (
"Maximum Iterations", maxIters_default_);
437 params_->set (
"Maximum Iterations", maxIters_);
438 if (! maxIterTest_.is_null ()) {
439 maxIterTest_->setMaxIters (maxIters_);
444 if (params->isParameter (
"Assert Positive Definiteness")) {
445 assertPositiveDefiniteness_ =
446 params->get (
"Assert Positive Definiteness",
447 assertPositiveDefiniteness_default_);
450 params_->set (
"Assert Positive Definiteness", assertPositiveDefiniteness_);
453 if (params->isParameter(
"Fold Convergence Detection Into Allreduce")) {
454 foldConvergenceDetectionIntoAllreduce_ = params->get(
"Fold Convergence Detection Into Allreduce",
455 foldConvergenceDetectionIntoAllreduce_default_);
459 if (params->isParameter (
"Timer Label")) {
460 const std::string tempLabel = params->get (
"Timer Label", label_default_);
463 if (tempLabel != label_) {
465 params_->set (
"Timer Label", label_);
466 const std::string solveLabel =
467 label_ +
": PseudoBlockCGSolMgr total solve time";
468#ifdef BELOS_TEUCHOS_TIME_MONITOR
469 timerSolve_ = Teuchos::TimeMonitor::getNewCounter (solveLabel);
475 if (params->isParameter (
"Verbosity")) {
476 if (Teuchos::isParameterType<int> (*params,
"Verbosity")) {
477 verbosity_ = params->get (
"Verbosity", verbosity_default_);
479 verbosity_ = (int) Teuchos::getParameter<Belos::MsgType> (*params,
"Verbosity");
483 params_->set (
"Verbosity", verbosity_);
484 if (! printer_.is_null ()) {
485 printer_->setVerbosity (verbosity_);
490 if (params->isParameter (
"Output Style")) {
491 if (Teuchos::isParameterType<int> (*params,
"Output Style")) {
492 outputStyle_ = params->get (
"Output Style", outputStyle_default_);
495 outputStyle_ = (int) Teuchos::getParameter<Belos::OutputType> (*params,
"Output Style");
500 params_->set (
"Output Style", outputStyle_);
501 outputTest_ = Teuchos::null;
505 if (params->isParameter (
"Output Stream")) {
506 outputStream_ = params->get<RCP<std::ostream> > (
"Output Stream");
509 params_->set (
"Output Stream", outputStream_);
510 if (! printer_.is_null ()) {
511 printer_->setOStream (outputStream_);
517 if (params->isParameter (
"Output Frequency")) {
518 outputFreq_ = params->get (
"Output Frequency", outputFreq_default_);
522 params_->set (
"Output Frequency", outputFreq_);
523 if (! outputTest_.is_null ()) {
524 outputTest_->setOutputFrequency (outputFreq_);
529 if (params->isParameter (
"Estimate Condition Number")) {
530 genCondEst_ = params->get (
"Estimate Condition Number", genCondEst_default_);
533 params_->set(
"Estimate Condition Number", genCondEst_);
537 if (printer_.is_null ()) {
546 if (params->isParameter (
"Convergence Tolerance")) {
547 if (params->isType<MagnitudeType> (
"Convergence Tolerance")) {
548 convtol_ = params->get (
"Convergence Tolerance",
556 params_->set (
"Convergence Tolerance", convtol_);
557 if (! convTest_.is_null ()) {
558 convTest_->setTolerance (convtol_);
562 if (params->isParameter (
"Show Maximum Residual Norm Only")) {
563 showMaxResNormOnly_ = params->get<
bool> (
"Show Maximum Residual Norm Only");
566 params_->set (
"Show Maximum Residual Norm Only", showMaxResNormOnly_);
567 if (! convTest_.is_null ()) {
568 convTest_->setShowMaxResNormOnly (showMaxResNormOnly_);
573 bool newResTest =
false;
578 std::string tempResScale = resScale_;
579 bool implicitResidualScalingName =
false;
580 if (params->isParameter (
"Residual Scaling")) {
581 tempResScale = params->get<std::string> (
"Residual Scaling");
583 else if (params->isParameter (
"Implicit Residual Scaling")) {
584 tempResScale = params->get<std::string> (
"Implicit Residual Scaling");
585 implicitResidualScalingName =
true;
589 if (resScale_ != tempResScale) {
592 resScale_ = tempResScale;
596 if (implicitResidualScalingName) {
597 params_->set (
"Implicit Residual Scaling", resScale_);
600 params_->set (
"Residual Scaling", resScale_);
603 if (! convTest_.is_null ()) {
607 catch (std::exception& e) {
616 if (params->isParameter (
"Deflation Quorum")) {
617 defQuorum_ = params->get (
"Deflation Quorum", defQuorum_);
618 params_->set (
"Deflation Quorum", defQuorum_);
619 if (! convTest_.is_null ()) {
620 convTest_->setQuorum( defQuorum_ );
627 if (maxIterTest_.is_null ()) {
632 if (convTest_.is_null () || newResTest) {
633 convTest_ = rcp (
new StatusTestResNorm_t (convtol_, defQuorum_, showMaxResNormOnly_));
637 if (sTest_.is_null () || newResTest) {
638 sTest_ = rcp (
new StatusTestCombo_t (StatusTestCombo_t::OR, maxIterTest_, convTest_));
639 if (Teuchos::nonnull(debugStatusTest_)) {
641 sTest_ = rcp (
new StatusTestCombo_t (StatusTestCombo_t::OR, sTest_, debugStatusTest_));
645 if (outputTest_.is_null () || newResTest) {
649 outputTest_ = stoFactory.
create (printer_, sTest_, outputFreq_,
653 const std::string solverDesc =
" Pseudo Block CG ";
654 outputTest_->setSolverDesc (solverDesc);
658 if (timerSolve_.is_null ()) {
659 const std::string solveLabel =
660 label_ +
": PseudoBlockCGSolMgr total solve time";
661#ifdef BELOS_TEUCHOS_TIME_MONITOR
662 timerSolve_ = Teuchos::TimeMonitor::getNewCounter (solveLabel);
671template<
class ScalarType,
class MV,
class OP,
class DM>
672Teuchos::RCP<const Teuchos::ParameterList>
675 using Teuchos::ParameterList;
676 using Teuchos::parameterList;
679 if (validParams_.is_null()) {
681 RCP<ParameterList> pl = parameterList ();
683 "The relative residual tolerance that needs to be achieved by the\n"
684 "iterative solver in order for the linear system to be declared converged.");
685 pl->set(
"Maximum Iterations",
static_cast<int>(maxIters_default_),
686 "The maximum number of block iterations allowed for each\n"
687 "set of RHS solved.");
688 pl->set(
"Assert Positive Definiteness",
static_cast<bool>(assertPositiveDefiniteness_default_),
689 "Whether or not to assert that the linear operator\n"
690 "and the preconditioner are indeed positive definite.");
691 pl->set(
"Verbosity",
static_cast<int>(verbosity_default_),
692 "What type(s) of solver information should be outputted\n"
693 "to the output stream.");
694 pl->set(
"Output Style",
static_cast<int>(outputStyle_default_),
695 "What style is used for the solver information outputted\n"
696 "to the output stream.");
697 pl->set(
"Output Frequency",
static_cast<int>(outputFreq_default_),
698 "How often convergence information should be outputted\n"
699 "to the output stream.");
700 pl->set(
"Deflation Quorum",
static_cast<int>(defQuorum_default_),
701 "The number of linear systems that need to converge before\n"
702 "they are deflated. This number should be <= block size.");
703 pl->set(
"Output Stream", Teuchos::rcpFromRef(std::cout),
704 "A reference-counted pointer to the output stream where all\n"
705 "solver output is sent.");
706 pl->set(
"Show Maximum Residual Norm Only",
static_cast<bool>(showMaxResNormOnly_default_),
707 "When convergence information is printed, only show the maximum\n"
708 "relative residual norm when the block size is greater than one.");
709 pl->set(
"Implicit Residual Scaling", resScale_default_,
710 "The type of scaling used in the residual convergence test.");
711 pl->set(
"Estimate Condition Number",
static_cast<bool>(genCondEst_default_),
712 "Whether or not to estimate the condition number of the preconditioned system.");
718 pl->set(
"Residual Scaling", resScale_default_,
719 "The type of scaling used in the residual convergence test. This "
720 "name is deprecated; the new name is \"Implicit Residual Scaling\".");
721 pl->set(
"Timer Label",
static_cast<const char *
>(label_default_),
722 "The string to use as a prefix for the timer labels.");
723 pl->set(
"Fold Convergence Detection Into Allreduce",
static_cast<bool>(foldConvergenceDetectionIntoAllreduce_default_),
724 "Merge the allreduce for convergence detection with the one for CG.\n"
725 "This saves one all-reduce, but incurs more computation.");
733template<
class ScalarType,
class MV,
class OP,
class DM>
737 condEstimate_ = -Teuchos::ScalarTraits<ScalarType>::one();
739 const char prefix[] =
"Belos::PseudoBlockCGSolMgr::solve: ";
748 TEUCHOS_TEST_FOR_EXCEPTION
750 prefix <<
"The linear problem to solve is not ready. You must call "
751 "setProblem() on the Belos::LinearProblem instance before telling the "
752 "Belos solver to solve it.");
757 int numCurrRHS = numRHS2Solve;
759 std::vector<int> currIdx( numRHS2Solve ), currIdx2( numRHS2Solve );
760 for (
int i=0; i<numRHS2Solve; ++i) {
761 currIdx[i] = startPtr+i;
766 problem_->setLSIndex( currIdx );
770 Teuchos::ParameterList plist;
772 plist.set(
"Assert Positive Definiteness",assertPositiveDefiniteness_);
773 if(genCondEst_) plist.set(
"Max Size For Condest",maxIters_);
776 outputTest_->reset();
779 bool isConverged =
true;
783 Teuchos::RCP<CGIteration<ScalarType,MV,OP,DM> > block_cg_iter;
784 if (numRHS2Solve == 1) {
785 plist.set(
"Fold Convergence Detection Into Allreduce",
786 foldConvergenceDetectionIntoAllreduce_);
799 block_cg_iter->setDoCondEst(genCondEst_);
800 bool condEstPerf =
false;
804#ifdef BELOS_TEUCHOS_TIME_MONITOR
805 Teuchos::TimeMonitor slvtimer(*timerSolve_);
808 while ( numRHS2Solve > 0 ) {
811 std::vector<int> convRHSIdx;
812 std::vector<int> currRHSIdx( currIdx );
813 currRHSIdx.resize(numCurrRHS);
816 block_cg_iter->resetNumIters();
819 outputTest_->resetNumCalls();
822 Teuchos::RCP<MV> R_0 =
MVT::CloneViewNonConst( *(Teuchos::rcp_const_cast<MV>(problem_->getInitResVec())), currIdx );
825 block_cg_iter->initializeCG(state_, R_0);
832 block_cg_iter->iterate();
839 if ( convTest_->getStatus() ==
Passed ) {
842 std::vector<int> convIdx = Teuchos::rcp_dynamic_cast<StatusTestGenResNorm<ScalarType,MV,OP,DM> >(convTest_)->convIndices();
846 if (convIdx.size() == currRHSIdx.size())
850 problem_->setCurrLS();
854 for (
unsigned int i=0; i<currRHSIdx.size(); ++i) {
856 for (
unsigned int j=0; j<convIdx.size(); ++j) {
857 if (currRHSIdx[i] == convIdx[j]) {
863 currIdx2[have] = currIdx2[i];
864 currRHSIdx[have++] = currRHSIdx[i];
867 currRHSIdx.resize(have);
868 currIdx2.resize(have);
871 if (currRHSIdx[0] != 0 && genCondEst_ && !condEstPerf)
874 ScalarType l_min, l_max;
875 Teuchos::ArrayView<MagnitudeType> diag = block_cg_iter->getDiag();
876 Teuchos::ArrayView<MagnitudeType> offdiag = block_cg_iter->getOffDiag();
877 compute_condnum_tridiag_sym(diag,offdiag,eigenEstimates_,l_min,l_max,condEstimate_);
880 block_cg_iter->setDoCondEst(
false);
885 problem_->setLSIndex( currRHSIdx );
888 std::vector<MagnitudeType> norms;
889 R_0 =
MVT::CloneCopy( *(block_cg_iter->getNativeResiduals(&norms)),currIdx2 );
890 for (
int i=0; i<have; ++i) { currIdx2[i] = i; }
893 block_cg_iter->initializeCG(state_, R_0);
901 else if ( maxIterTest_->getStatus() ==
Passed ) {
913 else if (Teuchos::nonnull(debugStatusTest_) &&
914 debugStatusTest_->getStatus() ==
Passed) {
930 TEUCHOS_TEST_FOR_EXCEPTION(
true,std::logic_error,
931 "Belos::PseudoBlockCGSolMgr::solve(): Invalid return from PseudoBlockCGIter::iterate().");
937 achievedTol_ = MT::one();
938 Teuchos::RCP<MV> X = problem_->getLHS();
940 printer_->stream(
Warnings) <<
"Belos::PseudoBlockCGSolMgr::solve(): Warning! NaN has been detected!"
944 catch (
const std::exception &e) {
946 printer_->stream(
Errors) <<
"Error! Caught std::exception in PseudoBlockCGIter::iterate() at iteration "
947 << block_cg_iter->getNumIters() << std::endl
948 << e.what() << std::endl;
954 problem_->setCurrLS();
957 startPtr += numCurrRHS;
958 numRHS2Solve -= numCurrRHS;
960 if ( numRHS2Solve > 0 ) {
962 numCurrRHS = numRHS2Solve;
963 currIdx.resize( numCurrRHS );
964 currIdx2.resize( numCurrRHS );
965 for (
int i=0; i<numCurrRHS; ++i)
966 { currIdx[i] = startPtr+i; currIdx2[i] = i; }
969 problem_->setLSIndex( currIdx );
972 currIdx.resize( numRHS2Solve );
983#ifdef BELOS_TEUCHOS_TIME_MONITOR
988 Teuchos::TimeMonitor::summarize( printer_->stream(
TimingDetails) );
992 numIters_ = maxIterTest_->getNumIters();
996 const std::vector<MagnitudeType>* pTestValues = convTest_->getTestValue();
997 if (pTestValues != NULL && pTestValues->size () > 0) {
998 achievedTol_ = *std::max_element (pTestValues->begin(), pTestValues->end());
1002 if (genCondEst_ && !condEstPerf) {
1003 ScalarType l_min, l_max;
1004 Teuchos::ArrayView<MagnitudeType> diag = block_cg_iter->getDiag();
1005 Teuchos::ArrayView<MagnitudeType> offdiag = block_cg_iter->getOffDiag();
1006 compute_condnum_tridiag_sym(diag,offdiag,eigenEstimates_,l_min,l_max,condEstimate_);
1017template<
class ScalarType,
class MV,
class OP,
class DM>
1020 std::ostringstream oss;
1021 oss <<
"Belos::PseudoBlockCGSolMgr<...,"<<Teuchos::ScalarTraits<ScalarType>::name()<<
">";
1028template<
class ScalarType,
class MV,
class OP,
class DM>
1031 Teuchos::ArrayView<MagnitudeType> offdiag,
1032 Teuchos::ArrayRCP<MagnitudeType>& lambdas,
1033 ScalarType & lambda_min,
1034 ScalarType & lambda_max,
1035 ScalarType & ConditionNumber )
1037 using STS = Teuchos::ScalarTraits<ScalarType>;
1046 const int N = diag.size ();
1047 ScalarType scalar_dummy;
1048 std::vector<MagnitudeType> mag_dummy(4*N);
1050 Teuchos::LAPACK<int,ScalarType> lapack;
1052 lambdas.resize(N, 0.0);
1053 lambda_min = STS::one ();
1054 lambda_max = STS::one ();
1056 lapack.PTEQR (char_N, N, diag.getRawPtr (), offdiag.getRawPtr (),
1057 &scalar_dummy, 1, &mag_dummy[0], &info);
1058 TEUCHOS_TEST_FOR_EXCEPTION
1059 (info < 0, std::logic_error,
"Belos::PseudoBlockCGSolMgr::"
1060 "compute_condnum_tridiag_sym: LAPACK's _PTEQR failed with info = "
1061 << info <<
" < 0. This suggests there might be a bug in the way Belos "
1062 "is calling LAPACK. Please report this to the Belos developers.");
1063 for (
int k = 0; k < N; k++) {
1064 lambdas[k] = diag[N - 1 - k];
1066 lambda_min = Teuchos::as<ScalarType> (diag[N-1]);
1067 lambda_max = Teuchos::as<ScalarType> (diag[0]);
1074 if (STS::real (lambda_max) < STS::real (lambda_min)) {
1075 ConditionNumber = STS::one ();
1079 ConditionNumber = lambda_max / lambda_min;
1090#ifdef HAVE_BELOS_TPETRA
1093#define BELOS_TPETRA_PSEUDOBLOCKCGSOLMGR_NOEXTERN_CALL(SC, LO, GO, NT) \
1094 BELOS_TPETRA_CALL(Belos::PseudoBlockCGSolMgr, SC, LO, GO, NT)
1096#define BELOS_TPETRA_PSEUDOBLOCKCGSOLMGR_EXTERN_CALL(SC, LO, GO, NT) \
1097 BELOS_TPETRA_EXTERN_CALL(Belos::PseudoBlockCGSolMgr, SC, LO, GO, NT)
1099TPETRA_INSTANTIATE_SLGN_NO_ORDINAL_SCALAR(BELOS_TPETRA_PSEUDOBLOCKCGSOLMGR_EXTERN_CALL)
Belos concrete class for performing the conjugate-gradient (CG) iteration.
Pure virtual base class which augments the basic interface for a conjugate gradient linear solver ite...
Belos header file which uses auto-configuration information to include necessary C++ headers.
Class which describes the linear problem to be solved by the iterative solver.
Class which manages the output and verbosity of the Belos solvers.
Belos concrete class for performing the pseudo-block CG iteration.
Pure virtual base class which describes the basic interface for a solver manager.
Belos::StatusTest for logically combining several status tests.
Belos::StatusTestResNorm for specifying general residual norm stopping criteria.
Belos::StatusTest class for specifying a maximum number of iterations.
A factory class for generating StatusTestOutput objects.
Collection of types and exceptions used within the Belos solvers.
BelosError(const std::string &what_arg)
This class implements the preconditioned Conjugate Gradient (CG) iteration.
Structure to contain pointers to CGIteration state variables.
Base class for Belos::SolverManager subclasses which normally can only compile with ScalarType types ...
Traits class which defines basic operations on multivectors.
static void MvInit(MV &mv, const ScalarType alpha=Teuchos::ScalarTraits< ScalarType >::zero())
static Teuchos::RCP< MV > CloneCopy(const MV &mv)
static Teuchos::RCP< MV > CloneViewNonConst(MV &mv, const std::vector< int > &index)
static int GetNumberVecs(const MV &mv)
Class which defines basic traits for the operator type.
Belos's basic output manager for sending information of select verbosity levels to the appropriate ou...
This class implements the pseudo-block CG iteration, where the basic CG algorithm is performed on all...
Structure to contain pointers to PseudoBlockCGIteration state variables.
MagnitudeType achievedTol() const override
Tolerance achieved by the last solve() invocation.
int getNumIters() const override
Get the iteration count for the most recent call to solve().
const LinearProblem< ScalarType, MV, OP, DM > & getProblem() const override
Return a reference to the linear problem being solved by this solver manager.
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const override
Get a parameter list containing the valid parameters for this object.
void reset(const ResetType type) override
Performs a reset of the solver manager specified by the ResetType. This informs the solver manager th...
void setDebugStatusTest(const Teuchos::RCP< StatusTest< ScalarType, MV, OP, DM > > &debugStatusTest) override
Set a debug status test, OR-combined into the top-level status test.
Teuchos::RCP< StatusTestGenResNorm< ScalarType, MV, OP, DM > > getResidualStatusTest() const
Return the residual status test.
PseudoBlockCGSolMgr()
Empty constructor for BlockCGSolMgr. This constructor takes no arguments and sets the default values ...
Teuchos::ArrayRCP< MagnitudeType > getEigenEstimates() const
virtual ~PseudoBlockCGSolMgr()=default
Destructor.
void setParameters(const Teuchos::RCP< Teuchos::ParameterList > ¶ms) override
Set the parameters the solver manager should use to solve the linear problem.
void setProblem(const Teuchos::RCP< LinearProblem< ScalarType, MV, OP, DM > > &problem) override
Set the linear problem that needs to be solved.
bool isLOADetected() const override
Return whether a loss of accuracy was detected by this solver during the most current solve.
Teuchos::RCP< SolverManager< ScalarType, MV, OP, DM > > clone() const override
clone for Inverted Injection (DII)
Teuchos::RCP< const Teuchos::ParameterList > getCurrentParameters() const override
Get a parameter list containing the current parameters for this object.
ScalarType getConditionEstimate() const
Gets the estimated condition number.
Teuchos::Array< Teuchos::RCP< Teuchos::Time > > getTimers() const
Return the timers for this object.
The Belos::PseudoBlockCGSolMgr provides a powerful and fully-featured solver manager over the pseudo-...
virtual ~PseudoBlockCGSolMgr()=default
PseudoBlockCGSolMgr(const Teuchos::RCP< LinearProblem< ScalarType, MV, OP, DM > > &problem, const Teuchos::RCP< Teuchos::ParameterList > &pl)
Teuchos::RCP< StatusTestGenResNorm< ScalarType, MV, OP, DM > > getResidualStatusTest() const
PseudoBlockCGSolMgrLinearProblemFailure is thrown when the linear problem is not setup (i....
PseudoBlockCGSolMgrLinearProblemFailure(const std::string &what_arg)
A class for extending the status testing capabilities of Belos via logical combinations.
An implementation of StatusTestResNorm using a family of residual norms.
A pure virtual class for defining the status tests for the Belos iterative solvers.
A Belos::StatusTest class for specifying a maximum number of iterations.
A factory class for generating StatusTestOutput objects.
Teuchos::RCP< StatusTestOutput< ScalarType, MV, OP, DM > > create(const Teuchos::RCP< OutputManager< ScalarType > > &printer, Teuchos::RCP< StatusTest< ScalarType, MV, OP, DM > > test, int mod, int printStates)
Create the StatusTestOutput object specified by the outputStyle.
ScaleType convertStringToScaleType(const std::string &scaleType)
Convert the given string to its ScaleType enum value.
ReturnType
Whether the Belos solve converged for all linear systems.
ScaleType
The type of scaling to use on the residual norm value.
ResetType
How to reset the solver.
Default parameters common to most Belos solvers.
static const double convTol
Default convergence tolerance.