42 #ifndef BELOS_BLOCK_CG_SOLMGR_HPP 43 #define BELOS_BLOCK_CG_SOLMGR_HPP 64 #include "Teuchos_LAPACK.hpp" 65 #ifdef BELOS_TEUCHOS_TIME_MONITOR 66 # include "Teuchos_TimeMonitor.hpp" 68 #if defined(HAVE_TEUCHOSCORE_CXX11) 69 # include <type_traits> 70 #endif // defined(HAVE_TEUCHOSCORE_CXX11) 104 template<
class ScalarType,
class MV,
class OP,
105 const bool lapackSupportsScalarType =
120 const Teuchos::RCP<Teuchos::ParameterList>& pl) :
130 template<
class ScalarType,
class MV,
class OP>
157 typedef Teuchos::ScalarTraits<ScalarType>
SCT;
158 typedef typename Teuchos::ScalarTraits<ScalarType>::magnitudeType
MagnitudeType;
159 typedef Teuchos::ScalarTraits<MagnitudeType>
MT;
210 const Teuchos::RCP<Teuchos::ParameterList> &pl );
216 Teuchos::RCP<SolverManager<ScalarType, MV, OP> >
clone ()
const override {
230 Teuchos::RCP<const Teuchos::ParameterList> getValidParameters()
const override;
241 Teuchos::Array<Teuchos::RCP<Teuchos::Time> >
getTimers()
const {
242 return Teuchos::tuple(timerSolve_);
272 void setParameters(
const Teuchos::RCP<Teuchos::ParameterList> ¶ms )
override;
313 std::string description()
const override;
320 Teuchos::RCP<LinearProblem<ScalarType,MV,OP> >
problem_;
331 Teuchos::RCP<StatusTest<ScalarType,MV,OP> >
sTest_;
337 Teuchos::RCP<StatusTestGenResNorm<ScalarType,MV,OP> >
convTest_;
343 Teuchos::RCP<MatOrthoManager<ScalarType,MV,OP> >
ortho_;
351 static constexpr
int maxIters_default_ = 1000;
352 static constexpr
bool adaptiveBlockSize_default_ =
true;
353 static constexpr
bool showMaxResNormOnly_default_ =
false;
354 static constexpr
bool useSingleReduction_default_ =
false;
355 static constexpr
int blockSize_default_ = 1;
358 static constexpr
int outputFreq_default_ = -1;
359 static constexpr
const char * resNorm_default_ =
"TwoNorm";
360 static constexpr
bool foldConvergenceDetectionIntoAllreduce_default_ =
false;
361 static constexpr
const char * resScale_default_ =
"Norm of Initial Residual";
362 static constexpr
const char * label_default_ =
"Belos";
363 static constexpr
const char * orthoType_default_ =
"ICGS";
364 static constexpr
bool assertPositiveDefiniteness_default_ =
true;
366 #if defined(_WIN32) && defined(__clang__) 367 static constexpr std::ostream * outputStream_default_ =
368 __builtin_constant_p(reinterpret_cast<const std::ostream*>(&std::cout));
370 static constexpr std::ostream * outputStream_default_ = &std::cout;
415 template<
class ScalarType,
class MV,
class OP>
417 outputStream_(
Teuchos::rcp(outputStream_default_,false)),
421 maxIters_(maxIters_default_),
423 blockSize_(blockSize_default_),
424 verbosity_(verbosity_default_),
425 outputStyle_(outputStyle_default_),
426 outputFreq_(outputFreq_default_),
427 adaptiveBlockSize_(adaptiveBlockSize_default_),
428 showMaxResNormOnly_(showMaxResNormOnly_default_),
429 useSingleReduction_(useSingleReduction_default_),
430 orthoType_(orthoType_default_),
431 resScale_(resScale_default_),
432 assertPositiveDefiniteness_(assertPositiveDefiniteness_default_),
433 foldConvergenceDetectionIntoAllreduce_(foldConvergenceDetectionIntoAllreduce_default_),
434 label_(label_default_),
440 template<
class ScalarType,
class MV,
class OP>
443 const Teuchos::RCP<Teuchos::ParameterList> &pl) :
445 outputStream_(
Teuchos::rcp(outputStream_default_,false)),
449 maxIters_(maxIters_default_),
451 blockSize_(blockSize_default_),
452 verbosity_(verbosity_default_),
453 outputStyle_(outputStyle_default_),
454 outputFreq_(outputFreq_default_),
455 adaptiveBlockSize_(adaptiveBlockSize_default_),
456 showMaxResNormOnly_(showMaxResNormOnly_default_),
457 useSingleReduction_(useSingleReduction_default_),
458 orthoType_(orthoType_default_),
459 resScale_(resScale_default_),
460 assertPositiveDefiniteness_(assertPositiveDefiniteness_default_),
461 foldConvergenceDetectionIntoAllreduce_(foldConvergenceDetectionIntoAllreduce_default_),
462 label_(label_default_),
465 TEUCHOS_TEST_FOR_EXCEPTION(problem_.is_null(), std::invalid_argument,
466 "BlockCGSolMgr's constructor requires a nonnull LinearProblem instance.");
471 if (! pl.is_null()) {
476 template<
class ScalarType,
class MV,
class OP>
482 if (params_ == Teuchos::null) {
483 params_ = Teuchos::rcp(
new Teuchos::ParameterList(*getValidParameters()) );
486 params->validateParameters(*getValidParameters());
490 if (params->isParameter(
"Maximum Iterations")) {
491 maxIters_ = params->get(
"Maximum Iterations",maxIters_default_);
494 params_->set(
"Maximum Iterations", maxIters_);
495 if (maxIterTest_!=Teuchos::null)
496 maxIterTest_->setMaxIters( maxIters_ );
500 if (params->isParameter(
"Block Size")) {
501 blockSize_ = params->get(
"Block Size",blockSize_default_);
502 TEUCHOS_TEST_FOR_EXCEPTION(blockSize_ <= 0, std::invalid_argument,
503 "Belos::BlockCGSolMgr: \"Block Size\" must be strictly positive.");
506 params_->set(
"Block Size", blockSize_);
510 if (params->isParameter(
"Adaptive Block Size")) {
511 adaptiveBlockSize_ = params->get(
"Adaptive Block Size",adaptiveBlockSize_default_);
514 params_->set(
"Adaptive Block Size", adaptiveBlockSize_);
518 if (params->isParameter(
"Use Single Reduction")) {
519 useSingleReduction_ = params->get(
"Use Single Reduction", useSingleReduction_default_);
522 if (params->isParameter(
"Fold Convergence Detection Into Allreduce")) {
523 foldConvergenceDetectionIntoAllreduce_ = params->get(
"Fold Convergence Detection Into Allreduce",
524 foldConvergenceDetectionIntoAllreduce_default_);
528 if (params->isParameter(
"Timer Label")) {
529 std::string tempLabel = params->get(
"Timer Label", label_default_);
532 if (tempLabel != label_) {
534 params_->set(
"Timer Label", label_);
535 std::string solveLabel = label_ +
": BlockCGSolMgr total solve time";
536 #ifdef BELOS_TEUCHOS_TIME_MONITOR 537 timerSolve_ = Teuchos::TimeMonitor::getNewCounter(solveLabel);
539 if (ortho_ != Teuchos::null) {
540 ortho_->setLabel( label_ );
546 if (params->isParameter(
"Verbosity")) {
547 if (Teuchos::isParameterType<int>(*params,
"Verbosity")) {
548 verbosity_ = params->get(
"Verbosity", verbosity_default_);
550 verbosity_ = (int)Teuchos::getParameter<Belos::MsgType>(*params,
"Verbosity");
554 params_->set(
"Verbosity", verbosity_);
555 if (printer_ != Teuchos::null)
556 printer_->setVerbosity(verbosity_);
560 if (params->isParameter(
"Output Style")) {
561 if (Teuchos::isParameterType<int>(*params,
"Output Style")) {
562 outputStyle_ = params->get(
"Output Style", outputStyle_default_);
564 outputStyle_ = (int)Teuchos::getParameter<Belos::OutputType>(*params,
"Output Style");
568 params_->set(
"Output Style", outputStyle_);
569 outputTest_ = Teuchos::null;
573 if (params->isParameter(
"Output Stream")) {
574 outputStream_ = Teuchos::getParameter<Teuchos::RCP<std::ostream> >(*params,
"Output Stream");
577 params_->set(
"Output Stream", outputStream_);
578 if (printer_ != Teuchos::null)
579 printer_->setOStream( outputStream_ );
584 if (params->isParameter(
"Output Frequency")) {
585 outputFreq_ = params->get(
"Output Frequency", outputFreq_default_);
589 params_->set(
"Output Frequency", outputFreq_);
590 if (outputTest_ != Teuchos::null)
591 outputTest_->setOutputFrequency( outputFreq_ );
595 if (printer_ == Teuchos::null) {
600 bool changedOrthoType =
false;
601 if (params->isParameter(
"Orthogonalization")) {
602 std::string tempOrthoType = params->get(
"Orthogonalization",orthoType_default_);
603 if (tempOrthoType != orthoType_) {
604 orthoType_ = tempOrthoType;
605 changedOrthoType =
true;
608 params_->set(
"Orthogonalization", orthoType_);
611 if (params->isParameter(
"Orthogonalization Constant")) {
612 if (params->isType<
MagnitudeType> (
"Orthogonalization Constant")) {
613 orthoKappa_ = params->get (
"Orthogonalization Constant",
617 orthoKappa_ = params->get (
"Orthogonalization Constant",
622 params_->set(
"Orthogonalization Constant",orthoKappa_);
623 if (orthoType_==
"DGKS") {
624 if (orthoKappa_ > 0 && ortho_ != Teuchos::null && !changedOrthoType) {
631 if (ortho_ == Teuchos::null || changedOrthoType) {
633 Teuchos::RCP<Teuchos::ParameterList> paramsOrtho;
634 if (orthoType_==
"DGKS" && orthoKappa_ > 0) {
635 paramsOrtho->set (
"depTol", orthoKappa_ );
638 ortho_ = factory.
makeMatOrthoManager (orthoType_, Teuchos::null, printer_, label_, paramsOrtho);
646 if (params->isParameter(
"Convergence Tolerance")) {
647 if (params->isType<
MagnitudeType> (
"Convergence Tolerance")) {
648 convtol_ = params->get (
"Convergence Tolerance",
656 params_->set(
"Convergence Tolerance", convtol_);
657 if (convTest_ != Teuchos::null)
661 if (params->isParameter(
"Show Maximum Residual Norm Only")) {
662 showMaxResNormOnly_ = Teuchos::getParameter<bool>(*params,
"Show Maximum Residual Norm Only");
665 params_->set(
"Show Maximum Residual Norm Only", showMaxResNormOnly_);
666 if (convTest_ != Teuchos::null)
667 convTest_->setShowMaxResNormOnly( showMaxResNormOnly_ );
671 bool newResTest =
false;
673 std::string tempResScale = resScale_;
674 if (params->isParameter (
"Implicit Residual Scaling")) {
675 tempResScale = params->get<std::string> (
"Implicit Residual Scaling");
679 if (resScale_ != tempResScale) {
682 resScale_ = tempResScale;
685 params_->set (
"Implicit Residual Scaling", resScale_);
687 if (! convTest_.is_null ()) {
690 if (params->isParameter(
"Residual Norm")) {
691 if (params->isType<std::string> (
"Residual Norm")) {
695 convTest_->defineResForm(StatusTestResNorm_t::Implicit, normType);
698 catch (std::exception& e) {
709 if (maxIterTest_ == Teuchos::null)
713 if (convTest_.is_null () || newResTest) {
716 if (params->isParameter(
"Residual Norm")) {
717 if (params->isType<std::string> (
"Residual Norm")) {
722 convTest_ = rcp (
new StatusTestResNorm_t (convtol_, 1, showMaxResNormOnly_));
723 convTest_->defineResForm(StatusTestResNorm_t::Implicit, normType);
727 if (sTest_.is_null () || newResTest)
728 sTest_ = Teuchos::rcp(
new StatusTestCombo_t( StatusTestCombo_t::OR, maxIterTest_, convTest_ ) );
730 if (outputTest_.is_null () || newResTest) {
738 std::string solverDesc =
" Block CG ";
739 outputTest_->setSolverDesc( solverDesc );
744 if (params->isParameter(
"Assert Positive Definiteness")) {
745 assertPositiveDefiniteness_ = Teuchos::getParameter<bool>(*params,
"Assert Positive Definiteness");
746 params_->set(
"Assert Positive Definiteness", assertPositiveDefiniteness_);
750 if (timerSolve_ == Teuchos::null) {
751 std::string solveLabel = label_ +
": BlockCGSolMgr total solve time";
752 #ifdef BELOS_TEUCHOS_TIME_MONITOR 753 timerSolve_ = Teuchos::TimeMonitor::getNewCounter(solveLabel);
762 template<
class ScalarType,
class MV,
class OP>
763 Teuchos::RCP<const Teuchos::ParameterList>
766 static Teuchos::RCP<const Teuchos::ParameterList> validPL;
769 if(is_null(validPL)) {
770 Teuchos::RCP<Teuchos::ParameterList> pl = Teuchos::parameterList();
772 "The relative residual tolerance that needs to be achieved by the\n" 773 "iterative solver in order for the linear system to be declared converged.");
774 pl->set(
"Maximum Iterations", static_cast<int>(maxIters_default_),
775 "The maximum number of block iterations allowed for each\n" 776 "set of RHS solved.");
777 pl->set(
"Block Size", static_cast<int>(blockSize_default_),
778 "The number of vectors in each block.");
779 pl->set(
"Adaptive Block Size", static_cast<bool>(adaptiveBlockSize_default_),
780 "Whether the solver manager should adapt to the block size\n" 781 "based on the number of RHS to solve.");
782 pl->set(
"Verbosity", static_cast<int>(verbosity_default_),
783 "What type(s) of solver information should be outputted\n" 784 "to the output stream.");
785 pl->set(
"Output Style", static_cast<int>(outputStyle_default_),
786 "What style is used for the solver information outputted\n" 787 "to the output stream.");
788 pl->set(
"Output Frequency", static_cast<int>(outputFreq_default_),
789 "How often convergence information should be outputted\n" 790 "to the output stream.");
791 pl->set(
"Output Stream", Teuchos::rcp(outputStream_default_,
false),
792 "A reference-counted pointer to the output stream where all\n" 793 "solver output is sent.");
794 pl->set(
"Show Maximum Residual Norm Only", static_cast<bool>(showMaxResNormOnly_default_),
795 "When convergence information is printed, only show the maximum\n" 796 "relative residual norm when the block size is greater than one.");
797 pl->set(
"Use Single Reduction", static_cast<bool>(useSingleReduction_default_),
798 "Use single reduction iteration when the block size is one.");
799 pl->set(
"Implicit Residual Scaling", resScale_default_,
800 "The type of scaling used in the residual convergence test.");
801 pl->set(
"Timer Label", static_cast<const char *>(label_default_),
802 "The string to use as a prefix for the timer labels.");
803 pl->set(
"Orthogonalization", static_cast<const char *>(orthoType_default_),
804 "The type of orthogonalization to use: DGKS, ICGS, or IMGS.");
805 pl->set(
"Assert Positive Definiteness",static_cast<bool>(assertPositiveDefiniteness_default_),
806 "Assert for positivity of p^H*A*p in CG iteration.");
808 "The constant used by DGKS orthogonalization to determine\n" 809 "whether another step of classical Gram-Schmidt is necessary.");
810 pl->set(
"Residual Norm",static_cast<const char *>(resNorm_default_),
811 "Norm used for the convergence check on the residual.");
812 pl->set(
"Fold Convergence Detection Into Allreduce",static_cast<bool>(foldConvergenceDetectionIntoAllreduce_default_),
813 "Merge the allreduce for convergence detection with the one for CG.\n" 814 "This saves one all-reduce, but incurs more computation.");
822 template<
class ScalarType,
class MV,
class OP>
826 using Teuchos::rcp_const_cast;
827 using Teuchos::rcp_dynamic_cast;
834 setParameters(Teuchos::parameterList(*getValidParameters()));
837 Teuchos::LAPACK<int,ScalarType> lapack;
839 TEUCHOS_TEST_FOR_EXCEPTION( !problem_->isProblemSet(),
841 "Belos::BlockCGSolMgr::solve(): Linear problem is not ready, setProblem() " 842 "has not been called.");
846 int numRHS2Solve = MVT::GetNumberVecs( *(problem_->getRHS()) );
847 int numCurrRHS = ( numRHS2Solve < blockSize_) ? numRHS2Solve : blockSize_;
849 std::vector<int> currIdx, currIdx2;
854 if ( adaptiveBlockSize_ ) {
855 blockSize_ = numCurrRHS;
856 currIdx.resize( numCurrRHS );
857 currIdx2.resize( numCurrRHS );
858 for (
int i=0; i<numCurrRHS; ++i)
859 { currIdx[i] = startPtr+i; currIdx2[i]=i; }
863 currIdx.resize( blockSize_ );
864 currIdx2.resize( blockSize_ );
865 for (
int i=0; i<numCurrRHS; ++i)
866 { currIdx[i] = startPtr+i; currIdx2[i]=i; }
867 for (
int i=numCurrRHS; i<blockSize_; ++i)
868 { currIdx[i] = -1; currIdx2[i] = i; }
872 problem_->setLSIndex( currIdx );
876 Teuchos::ParameterList plist;
877 plist.set(
"Block Size",blockSize_);
880 outputTest_->reset();
884 bool isConverged =
true;
889 plist.set(
"Assert Positive Definiteness", assertPositiveDefiniteness_);
891 RCP<CGIteration<ScalarType,MV,OP> > block_cg_iter;
892 if (blockSize_ == 1) {
896 plist.set(
"Fold Convergence Detection Into Allreduce",
897 foldConvergenceDetectionIntoAllreduce_);
898 if (useSingleReduction_) {
901 outputTest_, convTest_, plist));
906 outputTest_, convTest_, plist));
917 #ifdef BELOS_TEUCHOS_TIME_MONITOR 918 Teuchos::TimeMonitor slvtimer(*timerSolve_);
921 while ( numRHS2Solve > 0 ) {
924 std::vector<int> convRHSIdx;
925 std::vector<int> currRHSIdx( currIdx );
926 currRHSIdx.resize(numCurrRHS);
929 block_cg_iter->resetNumIters();
932 outputTest_->resetNumCalls();
935 RCP<MV> R_0 = MVT::CloneViewNonConst( *(rcp_const_cast<MV>(problem_->getInitResVec())), currIdx );
940 block_cg_iter->initializeCG(newstate);
946 block_cg_iter->iterate();
950 if (convTest_->getStatus() ==
Passed) {
955 std::vector<int> convIdx =
956 rcp_dynamic_cast<conv_test_type>(convTest_)->convIndices();
961 if (convIdx.size() == currRHSIdx.size())
966 problem_->setCurrLS();
971 std::vector<int> unconvIdx(currRHSIdx.size());
972 for (
unsigned int i=0; i<currRHSIdx.size(); ++i) {
974 for (
unsigned int j=0; j<convIdx.size(); ++j) {
975 if (currRHSIdx[i] == convIdx[j]) {
981 currIdx2[have] = currIdx2[i];
982 currRHSIdx[have++] = currRHSIdx[i];
987 currRHSIdx.resize(have);
988 currIdx2.resize(have);
991 problem_->setLSIndex( currRHSIdx );
994 std::vector<MagnitudeType> norms;
995 R_0 = MVT::CloneCopy( *(block_cg_iter->getNativeResiduals(&norms)),currIdx2 );
996 for (
int i=0; i<have; ++i) { currIdx2[i] = i; }
999 block_cg_iter->setBlockSize( have );
1004 block_cg_iter->initializeCG(defstate);
1010 else if (maxIterTest_->getStatus() ==
Passed) {
1011 isConverged =
false;
1019 TEUCHOS_TEST_FOR_EXCEPTION(
true,std::logic_error,
1020 "Belos::BlockCGSolMgr::solve(): Neither the convergence test nor " 1021 "the maximum iteration count test passed. Please report this bug " 1022 "to the Belos developers.");
1025 catch (
const std::exception &e) {
1026 std::ostream& err = printer_->stream (
Errors);
1027 err <<
"Error! Caught std::exception in CGIteration::iterate() at " 1028 <<
"iteration " << block_cg_iter->getNumIters() << std::endl
1029 << e.what() << std::endl;
1036 problem_->setCurrLS();
1039 startPtr += numCurrRHS;
1040 numRHS2Solve -= numCurrRHS;
1041 if ( numRHS2Solve > 0 ) {
1042 numCurrRHS = ( numRHS2Solve < blockSize_) ? numRHS2Solve : blockSize_;
1044 if ( adaptiveBlockSize_ ) {
1045 blockSize_ = numCurrRHS;
1046 currIdx.resize( numCurrRHS );
1047 currIdx2.resize( numCurrRHS );
1048 for (
int i=0; i<numCurrRHS; ++i)
1049 { currIdx[i] = startPtr+i; currIdx2[i] = i; }
1052 currIdx.resize( blockSize_ );
1053 currIdx2.resize( blockSize_ );
1054 for (
int i=0; i<numCurrRHS; ++i)
1055 { currIdx[i] = startPtr+i; currIdx2[i] = i; }
1056 for (
int i=numCurrRHS; i<blockSize_; ++i)
1057 { currIdx[i] = -1; currIdx2[i] = i; }
1060 problem_->setLSIndex( currIdx );
1063 block_cg_iter->setBlockSize( blockSize_ );
1066 currIdx.resize( numRHS2Solve );
1077 #ifdef BELOS_TEUCHOS_TIME_MONITOR 1083 Teuchos::TimeMonitor::summarize( printer_->stream(
TimingDetails) );
1088 numIters_ = maxIterTest_->getNumIters();
1094 const std::vector<MagnitudeType>* pTestValues =
1095 rcp_dynamic_cast<conv_test_type>(convTest_)->getTestValue();
1097 TEUCHOS_TEST_FOR_EXCEPTION(pTestValues == NULL, std::logic_error,
1098 "Belos::BlockCGSolMgr::solve(): The convergence test's getTestValue() " 1099 "method returned NULL. Please report this bug to the Belos developers.");
1101 TEUCHOS_TEST_FOR_EXCEPTION(pTestValues->size() < 1, std::logic_error,
1102 "Belos::BlockCGSolMgr::solve(): The convergence test's getTestValue() " 1103 "method returned a vector of length zero. Please report this bug to the " 1104 "Belos developers.");
1109 achievedTol_ = *std::max_element (pTestValues->begin(), pTestValues->end());
1119 template<
class ScalarType,
class MV,
class OP>
1122 std::ostringstream oss;
1123 oss <<
"Belos::BlockCGSolMgr<...,"<<Teuchos::ScalarTraits<ScalarType>::name()<<
">";
1125 oss <<
"Ortho Type='"<<orthoType_<<
"\', Block Size=" << blockSize_;
static const double orthoKappa
DGKS orthogonalization constant.
ScaleType convertStringToScaleType(const std::string &scaleType)
Convert the given string to its ScaleType enum value.
Teuchos::RCP< const MV > R
The current residual.
bool isLOADetected() const override
Return whether a loss of accuracy was detected by this solver during the most current solve...
Collection of types and exceptions used within the Belos solvers.
Belos's basic output manager for sending information of select verbosity levels to the appropriate ou...
int maxIters_
Maximum iteration count (read from parameter list).
Class which manages the output and verbosity of the Belos solvers.
bool isSet_
Whether or not the parameters have been set (via setParameters()).
Teuchos::RCP< Teuchos::ParameterList > params_
Current parameter list.
Teuchos::Array< Teuchos::RCP< Teuchos::Time > > getTimers() const
Return the timers for this object.
Teuchos::RCP< StatusTestOutput< ScalarType, MV, OP > > outputTest_
Output "status test" that controls all the other status tests.
ScaleType
The type of scaling to use on the residual norm value.
Teuchos::RCP< SolverManager< ScalarType, MV, OP > > clone() const override
clone for Inverted Injection (DII)
Teuchos::ScalarTraits< ScalarType > SCT
This class implements the preconditioned Conjugate Gradient (CG) iteration.
Structure to contain pointers to CGIteration state variables.
Belos concrete class for performing the conjugate-gradient (CG) iteration.
A factory class for generating StatusTestOutput objects.
Belos concrete class for performing the block conjugate-gradient (CG) iteration.
An implementation of StatusTestResNorm using a family of residual norms.
void setProblem(const Teuchos::RCP< LinearProblem< ScalarType, MV, OP > > &problem) override
Set the linear problem that needs to be solved.
std::string label_
Prefix label for all the timers.
The Belos::BlockCGSolMgr provides a powerful and fully-featured solver manager over the CG and BlockC...
static const double convTol
Default convergence tolerance.
Belos::StatusTest class for specifying a maximum number of iterations.
BlockCGSolMgrLinearProblemFailure(const std::string &what_arg)
Teuchos::RCP< const Teuchos::ParameterList > getCurrentParameters() const override
Get a parameter list containing the current parameters for this object.
BlockCGSolMgrLinearProblemFailure is thrown when the linear problem is not setup (i.e.
A factory class for generating StatusTestOutput objects.
Teuchos::RCP< MatOrthoManager< ScalarType, MV, OP > > ortho_
Orthogonalization manager.
BlockCGSolMgr(const Teuchos::RCP< LinearProblem< ScalarType, MV, OP > > &problem, const Teuchos::RCP< Teuchos::ParameterList > &pl)
Teuchos::RCP< StatusTestMaxIters< ScalarType, MV, OP > > maxIterTest_
Maximum iteration count stopping criterion.
Traits class which defines basic operations on multivectors.
Belos::StatusTest for logically combining several status tests.
Teuchos::RCP< StatusTest< ScalarType, MV, OP > > sTest_
Aggregate stopping criterion.
bool assertPositiveDefiniteness_
Details::SolverManagerRequiresLapack< ScalarType, MV, OP, requiresLapack > base_type
virtual ~BlockCGSolMgr()
Destructor.
OperatorTraits< ScalarType, MV, OP > OPT
MultiVecTraits< ScalarType, MV > MVT
A Belos::StatusTest class for specifying a maximum number of iterations.
ResetType
How to reset the solver.
void reset(const ResetType type) override
Performs a reset of the solver manager specified by the ResetType. This informs the solver manager th...
Pure virtual base class which describes the basic interface for a solver manager. ...
Belos concrete class for performing a single-reduction conjugate-gradient (CG) iteration.
NormType convertStringToNormType(const std::string &normType)
Convert the given string to its NormType enum value.
A linear system to solve, and its associated information.
Class which describes the linear problem to be solved by the iterative solver.
MagnitudeType achievedTol_
Tolerance achieved by the last solve() invocation.
MagnitudeType achievedTol() const override
Tolerance achieved by the last solve() invocation.
Type traits class that says whether Teuchos::LAPACK has a valid implementation for the given ScalarTy...
Teuchos::ScalarTraits< ScalarType >::magnitudeType MagnitudeType
ReturnType
Whether the Belos solve converged for all linear systems.
Teuchos::RCP< StatusTestGenResNorm< ScalarType, MV, OP > > convTest_
Convergence stopping criterion.
int getNumIters() const override
Get the iteration count for the most recent call to solve().
Teuchos::RCP< LinearProblem< ScalarType, MV, OP > > problem_
The linear problem to solve.
int setTolerance(MagnitudeType tolerance)
Set the value of the tolerance.
NormType
The type of vector norm to compute.
Teuchos::RCP< StatusTestOutput< ScalarType, MV, OP > > create(const Teuchos::RCP< OutputManager< ScalarType > > &printer, Teuchos::RCP< StatusTest< ScalarType, MV, OP > > test, int mod, int printStates)
Create the StatusTestOutput object specified by the outputStyle.
Belos::StatusTestResNorm for specifying general residual norm stopping criteria.
MagnitudeType convtol_
Convergence tolerance (read from parameter list).
Teuchos::RCP< Teuchos::Time > timerSolve_
Solve timer.
An implementation of the Belos::MatOrthoManager that performs orthogonalization using (potentially) m...
A class for extending the status testing capabilities of Belos via logical combinations.
const LinearProblem< ScalarType, MV, OP > & getProblem() const override
Return a reference to the linear problem being solved by this solver manager.
Class which defines basic traits for the operator type.
bool foldConvergenceDetectionIntoAllreduce_
Parent class to all Belos exceptions.
Default parameters common to most Belos solvers.
This class implements the preconditioned single-reduction Conjugate Gradient (CG) iteration...
Teuchos::RCP< OutputManager< ScalarType > > printer_
Output manager, that handles printing of different kinds of messages.
Base class for Belos::SolverManager subclasses which normally can only compile with ScalarType types ...
Belos header file which uses auto-configuration information to include necessary C++ headers...
int numIters_
Number of iterations taken by the last solve() invocation.
Teuchos::ScalarTraits< MagnitudeType > MT
static const bool requiresLapack
Teuchos::RCP< std::ostream > outputStream_
Output stream to which the output manager prints.
MagnitudeType orthoKappa_
Orthogonalization parameter (read from parameter list).
Stub implementation of BlockCGIter, for ScalarType types for which Teuchos::LAPACK does NOT have a va...
Teuchos::RCP< Belos::MatOrthoManager< Scalar, MV, OP > > makeMatOrthoManager(const std::string &ortho, const Teuchos::RCP< const OP > &M, const Teuchos::RCP< OutputManager< Scalar > > &, const std::string &label, const Teuchos::RCP< Teuchos::ParameterList > ¶ms)
Return an instance of the specified MatOrthoManager subclass.