42 #ifndef BELOS_PSEUDO_BLOCK_GMRES_SOLMGR_HPP
43 #define BELOS_PSEUDO_BLOCK_GMRES_SOLMGR_HPP
61 #ifdef BELOS_TEUCHOS_TIME_MONITOR
120 template<
class ScalarType,
class MV,
class OP>
285 return Teuchos::tuple(timerSolve_);
465 bool checkStatusTest();
492 static constexpr
int maxRestarts_default_ = 20;
493 static constexpr
int maxIters_default_ = 1000;
494 static constexpr
bool showMaxResNormOnly_default_ =
false;
495 static constexpr
int blockSize_default_ = 1;
496 static constexpr
int numBlocks_default_ = 300;
499 static constexpr
int outputFreq_default_ = -1;
500 static constexpr
int defQuorum_default_ = 1;
501 static constexpr
const char * impResScale_default_ =
"Norm of Preconditioned Initial Residual";
502 static constexpr
const char * expResScale_default_ =
"Norm of Initial Residual";
503 static constexpr
const char * label_default_ =
"Belos";
504 static constexpr
const char * orthoType_default_ =
"ICGS";
505 static constexpr std::ostream * outputStream_default_ = &std::cout;
508 MagnitudeType convtol_, orthoKappa_, achievedTol_;
509 int maxRestarts_, maxIters_, numIters_;
510 int blockSize_, numBlocks_, verbosity_, outputStyle_, outputFreq_, defQuorum_;
511 bool showMaxResNormOnly_;
512 std::string orthoType_;
513 std::string impResScale_, expResScale_;
514 MagnitudeType resScaleFactor_;
521 bool isSet_, isSTSet_, expResTest_;
527 template<
class ScalarType,
class MV,
class OP>
529 outputStream_(Teuchos::
rcp(outputStream_default_,false)),
530 taggedTests_(Teuchos::null),
533 achievedTol_(Teuchos::ScalarTraits<typename Teuchos::ScalarTraits<ScalarType>::magnitudeType>::zero()),
534 maxRestarts_(maxRestarts_default_),
535 maxIters_(maxIters_default_),
537 blockSize_(blockSize_default_),
538 numBlocks_(numBlocks_default_),
539 verbosity_(verbosity_default_),
540 outputStyle_(outputStyle_default_),
541 outputFreq_(outputFreq_default_),
542 defQuorum_(defQuorum_default_),
543 showMaxResNormOnly_(showMaxResNormOnly_default_),
544 orthoType_(orthoType_default_),
545 impResScale_(impResScale_default_),
546 expResScale_(expResScale_default_),
548 label_(label_default_),
556 template<
class ScalarType,
class MV,
class OP>
561 outputStream_(Teuchos::
rcp(outputStream_default_,false)),
562 taggedTests_(Teuchos::null),
565 achievedTol_(Teuchos::ScalarTraits<typename Teuchos::ScalarTraits<ScalarType>::magnitudeType>::zero()),
566 maxRestarts_(maxRestarts_default_),
567 maxIters_(maxIters_default_),
569 blockSize_(blockSize_default_),
570 numBlocks_(numBlocks_default_),
571 verbosity_(verbosity_default_),
572 outputStyle_(outputStyle_default_),
573 outputFreq_(outputFreq_default_),
574 defQuorum_(defQuorum_default_),
575 showMaxResNormOnly_(showMaxResNormOnly_default_),
576 orthoType_(orthoType_default_),
577 impResScale_(impResScale_default_),
578 expResScale_(expResScale_default_),
580 label_(label_default_),
595 template<
class ScalarType,
class MV,
class OP>
601 using Teuchos::parameterList;
603 using Teuchos::rcp_dynamic_cast;
606 if (params_ == Teuchos::null) {
607 params_ = parameterList (*getValidParameters ());
619 maxRestarts_ = params->
get (
"Maximum Restarts", maxRestarts_default_);
622 params_->set (
"Maximum Restarts", maxRestarts_);
627 maxIters_ = params->
get (
"Maximum Iterations", maxIters_default_);
630 params_->set (
"Maximum Iterations", maxIters_);
631 if (! maxIterTest_.is_null ()) {
632 maxIterTest_->setMaxIters (maxIters_);
638 blockSize_ = params->
get (
"Block Size", blockSize_default_);
640 blockSize_ <= 0, std::invalid_argument,
641 "Belos::PseudoBlockGmresSolMgr::setParameters: "
642 "The \"Block Size\" parameter must be strictly positive, "
643 "but you specified a value of " << blockSize_ <<
".");
646 params_->set (
"Block Size", blockSize_);
651 numBlocks_ = params->
get (
"Num Blocks", numBlocks_default_);
653 numBlocks_ <= 0, std::invalid_argument,
654 "Belos::PseudoBlockGmresSolMgr::setParameters: "
655 "The \"Num Blocks\" parameter must be strictly positive, "
656 "but you specified a value of " << numBlocks_ <<
".");
659 params_->set (
"Num Blocks", numBlocks_);
664 const std::string tempLabel = params->
get (
"Timer Label", label_default_);
667 if (tempLabel != label_) {
669 params_->set (
"Timer Label", label_);
670 const std::string solveLabel =
671 label_ +
": PseudoBlockGmresSolMgr total solve time";
672 #ifdef BELOS_TEUCHOS_TIME_MONITOR
674 #endif // BELOS_TEUCHOS_TIME_MONITOR
675 if (ortho_ != Teuchos::null) {
676 ortho_->setLabel( label_ );
684 if (Teuchos::isParameterType<int> (*params,
"Verbosity")) {
685 verbosity_ = params->
get (
"Verbosity", verbosity_default_);
687 verbosity_ = (int) Teuchos::getParameter<Belos::MsgType> (*params,
"Verbosity");
691 params_->set (
"Verbosity", verbosity_);
692 if (! printer_.is_null ()) {
693 printer_->setVerbosity (verbosity_);
699 if (Teuchos::isParameterType<int> (*params,
"Output Style")) {
700 outputStyle_ = params->
get (
"Output Style", outputStyle_default_);
702 outputStyle_ = (int) Teuchos::getParameter<Belos::OutputType> (*params,
"Output Style");
706 params_->set (
"Output Style", verbosity_);
707 if (! outputTest_.is_null ()) {
714 if (params->
isSublist (
"User Status Tests")) {
716 if ( userStatusTestsList.
numParams() > 0 ) {
717 std::string userCombo_string = params->
get<std::string>(
"User Status Tests Combo Type",
"SEQ");
719 setUserConvStatusTest( testFactory->buildStatusTests(userStatusTestsList), testFactory->stringToComboType(userCombo_string) );
720 taggedTests_ = testFactory->getTaggedTests();
727 outputStream_ = Teuchos::getParameter<Teuchos::RCP<std::ostream> > (*params,
"Output Stream");
730 params_->set(
"Output Stream", outputStream_);
731 if (! printer_.is_null ()) {
732 printer_->setOStream (outputStream_);
739 outputFreq_ = params->
get (
"Output Frequency", outputFreq_default_);
743 params_->set (
"Output Frequency", outputFreq_);
744 if (! outputTest_.is_null ()) {
745 outputTest_->setOutputFrequency (outputFreq_);
750 if (printer_.is_null ()) {
755 bool changedOrthoType =
false;
757 std::string tempOrthoType = params->
get (
"Orthogonalization", orthoType_default_);
758 if (tempOrthoType != orthoType_) {
759 orthoType_ = tempOrthoType;
760 changedOrthoType =
true;
763 params_->set(
"Orthogonalization", orthoType_);
766 if (params->
isParameter (
"Orthogonalization Constant")) {
767 if (params->
isType<MagnitudeType> (
"Orthogonalization Constant")) {
768 orthoKappa_ = params->
get (
"Orthogonalization Constant",
772 orthoKappa_ = params->
get (
"Orthogonalization Constant",
777 params_->set (
"Orthogonalization Constant", orthoKappa_);
778 if (orthoType_ ==
"DGKS") {
779 if (orthoKappa_ > 0 && ! ortho_.is_null() && !changedOrthoType) {
781 rcp_dynamic_cast<ortho_type> (ortho_)->setDepTol (orthoKappa_);
787 if (ortho_.is_null() || changedOrthoType) {
790 if (orthoType_==
"DGKS" && orthoKappa_ > 0) {
791 paramsOrtho->
set (
"depTol", orthoKappa_ );
794 ortho_ = factory.
makeMatOrthoManager (orthoType_, Teuchos::null, printer_, label_, paramsOrtho);
800 if (params->
isParameter (
"Convergence Tolerance")) {
801 if (params->
isType<MagnitudeType> (
"Convergence Tolerance")) {
802 convtol_ = params->
get (
"Convergence Tolerance",
810 params_->set (
"Convergence Tolerance", convtol_);
811 if (! impConvTest_.is_null ()) {
812 impConvTest_->setTolerance (convtol_);
814 if (! expConvTest_.is_null ()) {
815 expConvTest_->setTolerance (convtol_);
820 bool userDefinedResidualScalingUpdated =
false;
821 if (params->
isParameter (
"User Defined Residual Scaling")) {
823 if (params->
isType<MagnitudeType> (
"User Defined Residual Scaling")) {
824 tempResScaleFactor = params->
get (
"User Defined Residual Scaling",
828 tempResScaleFactor = params->
get (
"User Defined Residual Scaling",
833 if (resScaleFactor_ != tempResScaleFactor) {
834 resScaleFactor_ = tempResScaleFactor;
835 userDefinedResidualScalingUpdated =
true;
838 if(userDefinedResidualScalingUpdated)
840 if (! params->
isParameter (
"Implicit Residual Scaling") && ! impConvTest_.is_null ()) {
842 if(impResScale_ ==
"User Provided")
845 catch (std::exception& e) {
850 if (! params->
isParameter (
"Explicit Residual Scaling") && ! expConvTest_.is_null ()) {
852 if(expResScale_ ==
"User Provided")
855 catch (std::exception& e) {
864 if (params->
isParameter (
"Implicit Residual Scaling")) {
865 const std::string tempImpResScale =
866 Teuchos::getParameter<std::string> (*params,
"Implicit Residual Scaling");
869 if (impResScale_ != tempImpResScale) {
871 impResScale_ = tempImpResScale;
874 params_->set (
"Implicit Residual Scaling", impResScale_);
875 if (! impConvTest_.is_null ()) {
877 if(impResScale_ ==
"User Provided")
878 impConvTest_->defineScaleForm (impResScaleType,
Belos::TwoNorm, resScaleFactor_);
882 catch (std::exception& e) {
888 else if (userDefinedResidualScalingUpdated) {
891 if (! impConvTest_.is_null ()) {
893 if(impResScale_ ==
"User Provided")
894 impConvTest_->defineScaleForm (impResScaleType,
Belos::TwoNorm, resScaleFactor_);
896 catch (std::exception& e) {
904 if (params->
isParameter (
"Explicit Residual Scaling")) {
905 const std::string tempExpResScale =
906 Teuchos::getParameter<std::string> (*params,
"Explicit Residual Scaling");
909 if (expResScale_ != tempExpResScale) {
911 expResScale_ = tempExpResScale;
914 params_->set (
"Explicit Residual Scaling", expResScale_);
915 if (! expConvTest_.is_null ()) {
917 if(expResScale_ ==
"User Provided")
918 expConvTest_->defineScaleForm (expResScaleType,
Belos::TwoNorm, resScaleFactor_);
922 catch (std::exception& e) {
928 else if (userDefinedResidualScalingUpdated) {
931 if (! expConvTest_.is_null ()) {
933 if(expResScale_ ==
"User Provided")
934 expConvTest_->defineScaleForm (expResScaleType,
Belos::TwoNorm, resScaleFactor_);
936 catch (std::exception& e) {
945 if (params->
isParameter (
"Show Maximum Residual Norm Only")) {
946 showMaxResNormOnly_ =
947 Teuchos::getParameter<bool> (*params,
"Show Maximum Residual Norm Only");
950 params_->set (
"Show Maximum Residual Norm Only", showMaxResNormOnly_);
951 if (! impConvTest_.is_null ()) {
952 impConvTest_->setShowMaxResNormOnly (showMaxResNormOnly_);
954 if (! expConvTest_.is_null ()) {
955 expConvTest_->setShowMaxResNormOnly (showMaxResNormOnly_);
963 defQuorum_ = params->
get(
"Deflation Quorum", defQuorum_);
965 defQuorum_ > blockSize_, std::invalid_argument,
966 "Belos::PseudoBlockGmresSolMgr::setParameters: "
967 "The \"Deflation Quorum\" parameter (= " << defQuorum_ <<
") must not be "
968 "larger than \"Block Size\" (= " << blockSize_ <<
").");
969 params_->set (
"Deflation Quorum", defQuorum_);
970 if (! impConvTest_.is_null ()) {
971 impConvTest_->setQuorum (defQuorum_);
973 if (! expConvTest_.is_null ()) {
974 expConvTest_->setQuorum (defQuorum_);
979 if (timerSolve_ == Teuchos::null) {
980 std::string solveLabel = label_ +
": PseudoBlockGmresSolMgr total solve time";
981 #ifdef BELOS_TEUCHOS_TIME_MONITOR
991 template<
class ScalarType,
class MV,
class OP>
998 userConvStatusTest_ = userConvStatusTest;
999 comboType_ = comboType;
1002 template<
class ScalarType,
class MV,
class OP>
1008 debugStatusTest_ = debugStatusTest;
1013 template<
class ScalarType,
class MV,
class OP>
1026 "The relative residual tolerance that needs to be achieved by the\n"
1027 "iterative solver in order for the linear system to be declared converged.");
1028 pl->
set(
"Maximum Restarts", static_cast<int>(maxRestarts_default_),
1029 "The maximum number of restarts allowed for each\n"
1030 "set of RHS solved.");
1031 pl->
set(
"Maximum Iterations", static_cast<int>(maxIters_default_),
1032 "The maximum number of block iterations allowed for each\n"
1033 "set of RHS solved.");
1034 pl->
set(
"Num Blocks", static_cast<int>(numBlocks_default_),
1035 "The maximum number of vectors allowed in the Krylov subspace\n"
1036 "for each set of RHS solved.");
1037 pl->
set(
"Block Size", static_cast<int>(blockSize_default_),
1038 "The number of RHS solved simultaneously.");
1039 pl->
set(
"Verbosity", static_cast<int>(verbosity_default_),
1040 "What type(s) of solver information should be outputted\n"
1041 "to the output stream.");
1042 pl->
set(
"Output Style", static_cast<int>(outputStyle_default_),
1043 "What style is used for the solver information outputted\n"
1044 "to the output stream.");
1045 pl->
set(
"Output Frequency", static_cast<int>(outputFreq_default_),
1046 "How often convergence information should be outputted\n"
1047 "to the output stream.");
1048 pl->
set(
"Deflation Quorum", static_cast<int>(defQuorum_default_),
1049 "The number of linear systems that need to converge before\n"
1050 "they are deflated. This number should be <= block size.");
1052 "A reference-counted pointer to the output stream where all\n"
1053 "solver output is sent.");
1054 pl->
set(
"Show Maximum Residual Norm Only", static_cast<bool>(showMaxResNormOnly_default_),
1055 "When convergence information is printed, only show the maximum\n"
1056 "relative residual norm when the block size is greater than one.");
1057 pl->
set(
"Implicit Residual Scaling", static_cast<const char *>(impResScale_default_),
1058 "The type of scaling used in the implicit residual convergence test.");
1059 pl->
set(
"Explicit Residual Scaling", static_cast<const char *>(expResScale_default_),
1060 "The type of scaling used in the explicit residual convergence test.");
1061 pl->
set(
"Timer Label", static_cast<const char *>(label_default_),
1062 "The string to use as a prefix for the timer labels.");
1063 pl->
set(
"Orthogonalization", static_cast<const char *>(orthoType_default_),
1064 "The type of orthogonalization to use.");
1066 "The constant used by DGKS orthogonalization to determine\n"
1067 "whether another step of classical Gram-Schmidt is necessary.");
1068 pl->
sublist(
"User Status Tests");
1069 pl->
set(
"User Status Tests Combo Type",
"SEQ",
1070 "Type of logical combination operation of user-defined\n"
1071 "and/or solver-specific status tests.");
1078 template<
class ScalarType,
class MV,
class OP>
1098 Teuchos::rcp(
new StatusTestGenResNorm_t( convtol_, defQuorum_ ) );
1099 if(impResScale_ ==
"User Provided")
1104 tmpImpConvTest->setShowMaxResNormOnly( showMaxResNormOnly_ );
1105 impConvTest_ = tmpImpConvTest;
1109 Teuchos::rcp(
new StatusTestGenResNorm_t( convtol_, defQuorum_ ) );
1110 tmpExpConvTest->defineResForm( StatusTestGenResNorm_t::Explicit,
Belos::TwoNorm );
1111 if(expResScale_ ==
"User Provided")
1115 tmpExpConvTest->setShowMaxResNormOnly( showMaxResNormOnly_ );
1116 expConvTest_ = tmpExpConvTest;
1119 convTest_ =
Teuchos::rcp(
new StatusTestCombo_t( StatusTestCombo_t::SEQ, impConvTest_, expConvTest_ ) );
1126 Teuchos::rcp(
new StatusTestImpResNorm_t( convtol_, defQuorum_ ) );
1127 if(impResScale_ ==
"User Provided")
1131 tmpImpConvTest->setShowMaxResNormOnly( showMaxResNormOnly_ );
1132 impConvTest_ = tmpImpConvTest;
1135 expConvTest_ = impConvTest_;
1136 convTest_ = impConvTest_;
1139 if (
nonnull(userConvStatusTest_) ) {
1142 if (tmpComboTest != Teuchos::null) {
1143 std::vector<Teuchos::RCP<StatusTest<ScalarType,MV,OP> > > tmpVec = tmpComboTest->getStatusTests();
1144 comboType_ = tmpComboTest->getComboType();
1145 const int numResTests =
static_cast<int>(tmpVec.size());
1146 auto newConvTest =
Teuchos::rcp(
new StatusTestCombo_t(comboType_));
1147 newConvTest->addStatusTest(convTest_);
1148 for (
int j = 0; j < numResTests; ++j) {
1149 newConvTest->addStatusTest(tmpVec[j]);
1151 convTest_ = newConvTest;
1156 new StatusTestCombo_t( comboType_, convTest_, userConvStatusTest_ ) );
1164 sTest_ =
Teuchos::rcp(
new StatusTestCombo_t( StatusTestCombo_t::OR, maxIterTest_, convTest_ ) );
1167 if (
nonnull(debugStatusTest_) ) {
1169 Teuchos::rcp_dynamic_cast<StatusTestCombo_t>(sTest_)->addStatusTest( debugStatusTest_ );
1174 StatusTestOutputFactory<ScalarType,MV,OP> stoFactory( outputStyle_, taggedTests_ );
1178 std::string solverDesc =
" Pseudo Block Gmres ";
1179 outputTest_->setSolverDesc( solverDesc );
1190 template<
class ScalarType,
class MV,
class OP>
1196 if (!isSet_) { setParameters( params_ ); }
1201 "Belos::PseudoBlockGmresSolMgr::solve(): Linear problem is not ready, setProblem() has not been called.");
1204 if (!isSTSet_ || (!expResTest_ && !
Teuchos::is_null(problem_->getLeftPrec())) ) {
1206 "Belos::BlockGmresSolMgr::solve(): Linear problem and requested status tests are incompatible.");
1211 int numRHS2Solve = MVT::GetNumberVecs( *(problem_->getRHS()) );
1212 int numCurrRHS = ( numRHS2Solve < blockSize_) ? numRHS2Solve : blockSize_;
1214 std::vector<int> currIdx( numCurrRHS );
1215 blockSize_ = numCurrRHS;
1216 for (
int i=0; i<numCurrRHS; ++i)
1217 { currIdx[i] = startPtr+i; }
1220 problem_->setLSIndex( currIdx );
1225 plist.
set(
"Num Blocks",numBlocks_);
1228 outputTest_->reset();
1229 loaDetected_ =
false;
1232 bool isConverged =
true;
1242 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1246 while ( numRHS2Solve > 0 ) {
1249 std::vector<int> convRHSIdx;
1250 std::vector<int> currRHSIdx( currIdx );
1251 currRHSIdx.resize(numCurrRHS);
1254 block_gmres_iter->setNumBlocks( numBlocks_ );
1257 block_gmres_iter->resetNumIters();
1260 outputTest_->resetNumCalls();
1266 std::vector<int> index(1);
1267 Teuchos::RCP<MV> tmpV, R_0 = MVT::CloneCopy( *(problem_->getInitPrecResVec()), currIdx );
1268 newState.
V.resize( blockSize_ );
1269 newState.
Z.resize( blockSize_ );
1270 for (
int i=0; i<blockSize_; ++i) {
1272 tmpV = MVT::CloneViewNonConst( *R_0, index );
1279 int rank = ortho_->normalize( *tmpV, tmpZ );
1281 "Belos::PseudoBlockGmresSolMgr::solve(): Failed to compute initial block of orthonormal vectors.");
1283 newState.
V[i] = tmpV;
1284 newState.
Z[i] = tmpZ;
1288 block_gmres_iter->initialize(newState);
1289 int numRestarts = 0;
1295 block_gmres_iter->iterate();
1302 if ( convTest_->getStatus() ==
Passed ) {
1304 if ( expConvTest_->getLOADetected() ) {
1314 loaDetected_ =
true;
1316 "Belos::PseudoBlockGmresSolMgr::solve(): Warning! Solver has experienced a loss of accuracy!" << std::endl;
1317 isConverged =
false;
1321 std::vector<int> convIdx = expConvTest_->convIndices();
1325 if (convIdx.size() == currRHSIdx.size())
1332 problem_->setCurrLS();
1336 int curDim = oldState.
curDim;
1341 std::vector<int> oldRHSIdx( currRHSIdx );
1342 std::vector<int> defRHSIdx;
1343 for (
unsigned int i=0; i<currRHSIdx.size(); ++i) {
1345 for (
unsigned int j=0; j<convIdx.size(); ++j) {
1346 if (currRHSIdx[i] == convIdx[j]) {
1352 defRHSIdx.push_back( i );
1355 defState.
V.push_back( Teuchos::rcp_const_cast<MV>( oldState.
V[i] ) );
1360 currRHSIdx[have] = currRHSIdx[i];
1364 defRHSIdx.resize(currRHSIdx.size()-have);
1365 currRHSIdx.resize(have);
1373 problem_->setLSIndex( convIdx );
1376 problem_->updateSolution( defUpdate,
true );
1380 problem_->setLSIndex( currRHSIdx );
1383 defState.
curDim = curDim;
1386 block_gmres_iter->initialize(defState);
1393 else if ( maxIterTest_->getStatus() ==
Passed ) {
1395 isConverged =
false;
1403 else if ( block_gmres_iter->getCurSubspaceDim() == block_gmres_iter->getMaxSubspaceDim() ) {
1405 if ( numRestarts >= maxRestarts_ ) {
1406 isConverged =
false;
1411 printer_->stream(
Debug) <<
" Performing restart number " << numRestarts <<
" of " << maxRestarts_ << std::endl << std::endl;
1415 problem_->updateSolution( update,
true );
1422 newstate.
V.resize(currRHSIdx.size());
1423 newstate.
Z.resize(currRHSIdx.size());
1427 R_0 = MVT::Clone( *(problem_->getInitPrecResVec()), currRHSIdx.size() );
1428 problem_->computeCurrPrecResVec( &*R_0 );
1429 for (
unsigned int i=0; i<currRHSIdx.size(); ++i) {
1432 tmpV = MVT::CloneViewNonConst( *R_0, index );
1439 int rank = ortho_->normalize( *tmpV, tmpZ );
1441 "Belos::PseudoBlockGmresSolMgr::solve(): Failed to compute initial block of orthonormal vectors after the restart.");
1443 newstate.
V[i] = tmpV;
1444 newstate.
Z[i] = tmpZ;
1449 block_gmres_iter->initialize(newstate);
1462 "Belos::PseudoBlockGmresSolMgr::solve(): Invalid return from PseudoBlockGmresIter::iterate().");
1468 block_gmres_iter->updateLSQR( block_gmres_iter->getCurSubspaceDim() );
1471 sTest_->checkStatus( &*block_gmres_iter );
1472 if (convTest_->getStatus() !=
Passed)
1473 isConverged =
false;
1476 catch (
const std::exception &e) {
1477 printer_->stream(
Errors) <<
"Error! Caught std::exception in PseudoBlockGmresIter::iterate() at iteration "
1478 << block_gmres_iter->getNumIters() << std::endl
1479 << e.what() << std::endl;
1486 if (
nonnull(userConvStatusTest_)) {
1489 problem_->updateSolution( update,
true );
1491 else if (
nonnull(expConvTest_->getSolution())) {
1495 MVT::MvAddMv( 0.0, *newX, 1.0, *newX, *curX );
1500 problem_->updateSolution( update,
true );
1504 problem_->setCurrLS();
1507 startPtr += numCurrRHS;
1508 numRHS2Solve -= numCurrRHS;
1509 if ( numRHS2Solve > 0 ) {
1510 numCurrRHS = ( numRHS2Solve < blockSize_) ? numRHS2Solve : blockSize_;
1512 blockSize_ = numCurrRHS;
1513 currIdx.resize( numCurrRHS );
1514 for (
int i=0; i<numCurrRHS; ++i)
1515 { currIdx[i] = startPtr+i; }
1518 if (defQuorum_ > blockSize_) {
1519 if (impConvTest_ != Teuchos::null)
1520 impConvTest_->setQuorum( blockSize_ );
1521 if (expConvTest_ != Teuchos::null)
1522 expConvTest_->setQuorum( blockSize_ );
1526 problem_->setLSIndex( currIdx );
1529 currIdx.resize( numRHS2Solve );
1540 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1549 numIters_ = maxIterTest_->getNumIters();
1562 const std::vector<MagnitudeType>* pTestValues = NULL;
1564 pTestValues = expConvTest_->getTestValue();
1565 if (pTestValues == NULL || pTestValues->size() < 1) {
1566 pTestValues = impConvTest_->getTestValue();
1571 pTestValues = impConvTest_->getTestValue();
1574 "Belos::PseudoBlockGmresSolMgr::solve(): The implicit convergence test's "
1575 "getTestValue() method returned NULL. Please report this bug to the "
1576 "Belos developers.");
1578 "Belos::PseudoBlockGmresSolMgr::solve(): The implicit convergence test's "
1579 "getTestValue() method returned a vector of length zero. Please report "
1580 "this bug to the Belos developers.");
1585 achievedTol_ = *std::max_element (pTestValues->begin(), pTestValues->end());
1588 if (!isConverged || loaDetected_) {
1595 template<
class ScalarType,
class MV,
class OP>
1598 std::ostringstream out;
1600 out <<
"\"Belos::PseudoBlockGmresSolMgr\": {";
1601 if (this->getObjectLabel () !=
"") {
1602 out <<
"Label: " << this->getObjectLabel () <<
", ";
1604 out <<
"Num Blocks: " << numBlocks_
1605 <<
", Maximum Iterations: " << maxIters_
1606 <<
", Maximum Restarts: " << maxRestarts_
1607 <<
", Convergence Tolerance: " << convtol_
1613 template<
class ScalarType,
class MV,
class OP>
1635 out <<
"\"Belos::PseudoBlockGmresSolMgr\":" << endl;
1637 out <<
"Template parameters:" << endl;
1640 out <<
"ScalarType: " << TypeNameTraits<ScalarType>::name () << endl
1641 <<
"MV: " << TypeNameTraits<MV>::name () << endl
1642 <<
"OP: " << TypeNameTraits<OP>::name () << endl;
1644 if (this->getObjectLabel () !=
"") {
1645 out <<
"Label: " << this->getObjectLabel () << endl;
1647 out <<
"Num Blocks: " << numBlocks_ << endl
1648 <<
"Maximum Iterations: " << maxIters_ << endl
1649 <<
"Maximum Restarts: " << maxRestarts_ << endl
1650 <<
"Convergence Tolerance: " << convtol_ << endl;
static const double orthoKappa
DGKS orthogonalization constant.
ScaleType convertStringToScaleType(const std::string &scaleType)
Convert the given string to its ScaleType enum value.
std::vector< Teuchos::RCP< const Teuchos::SerialDenseMatrix< int, ScalarType > > > H
The current Hessenberg matrix.
Collection of types and exceptions used within the Belos solvers.
ComboType
The test can be either the AND of all the component tests, or the OR of all the component tests...
virtual ~PseudoBlockGmresSolMgr()
Destructor.
Belos's basic output manager for sending information of select verbosity levels to the appropriate ou...
void setParameters(const Teuchos::RCP< Teuchos::ParameterList > ¶ms) override
Set the parameters the solver manager should use to solve the linear problem.
Class which manages the output and verbosity of the Belos solvers.
bool is_null(const boost::shared_ptr< T > &p)
PseudoBlockGmresSolMgr()
Empty constructor.
PseudoBlockGmresSolMgrLinearProblemFailure(const std::string &what_arg)
ScaleType
The type of scaling to use on the residual norm value.
Convergence test using the implicit residual norm(s), with an explicit residual norm(s) check for los...
T & get(const std::string &name, T def_value)
PseudoBlockGmresSolMgrOrthoFailure(const std::string &what_arg)
ParameterList & set(std::string const &name, T const &value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
bool is_null(const std::shared_ptr< T > &p)
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
void setDebugStatusTest(const Teuchos::RCP< StatusTest< ScalarType, MV, OP > > &debugStatusTest) override
Set a debug status test that will be checked at the same time as the top-level status test...
An abstract class of StatusTest for stopping criteria using residual norms.
std::vector< Teuchos::RCP< const MV > > V
The current Krylov basis.
An implementation of StatusTestResNorm using a family of residual norms.
Ordinal numParams() const
static const double convTol
Default convergence tolerance.
A pure virtual class for defining the status tests for the Belos iterative solvers.
Structure to contain pointers to PseudoBlockGmresIter state variables.
Teuchos::Array< Teuchos::RCP< Teuchos::Time > > getTimers() const
Return the timers for this object.
A factory class for generating StatusTestOutput objects.
Traits class which defines basic operations on multivectors.
bool isParameter(const std::string &name) const
A Belos::StatusTest class for specifying a maximum number of iterations.
ResetType
How to reset the solver.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Pure virtual base class which describes the basic interface for a solver manager. ...
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const override
Print the object with the given verbosity level to a FancyOStream.
static void summarize(Ptr< const Comm< int > > comm, std::ostream &out=std::cout, const bool alwaysWriteLocal=false, const bool writeGlobalStats=true, const bool writeZeroTimers=true, const ECounterSetOp setOp=Intersection, const std::string &filter="", const bool ignoreZeroTimers=false)
bool isSublist(const std::string &name) const
PseudoBlockGmresSolMgrLinearProblemFailure is thrown when the linear problem is not setup (i...
std::vector< Teuchos::RCP< const Teuchos::SerialDenseVector< int, MagnitudeType > > > cs
A linear system to solve, and its associated information.
Class which describes the linear problem to be solved by the iterative solver.
void reset(const ResetType type) override
Performs a reset of the solver manager specified by the ResetType. This informs the solver manager th...
Interface to standard and "pseudoblock" GMRES.
int getNumIters() const override
Iteration count for the most recent call to solve().
ReturnType
Whether the Belos solve converged for all linear systems.
The Belos::SolverManager is a templated virtual base class that defines the basic interface that any ...
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const override
A list of valid default parameters for this solver.
void validateParameters(ParameterList const &validParamList, int const depth=1000, EValidateUsed const validateUsed=VALIDATE_USED_ENABLED, EValidateDefaults const validateDefaults=VALIDATE_DEFAULTS_ENABLED) const
static const EVerbosityLevel verbLevel_default
bool isLOADetected() const override
Whether a "loss of accuracy" was detected during the last solve().
bool nonnull(const boost::shared_ptr< T > &p)
std::vector< Teuchos::RCP< const Teuchos::SerialDenseVector< int, ScalarType > > > Z
The current right-hand side of the least squares system RY = Z.
void setProblem(const Teuchos::RCP< LinearProblem< ScalarType, MV, OP > > &problem) override
Set the linear problem to solve.
Belos concrete class for performing the pseudo-block GMRES iteration.
bool isType(const std::string &name) const
Teuchos::RCP< SolverManager< ScalarType, MV, OP > > clone() const override
clone for Inverted Injection (DII)
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.
std::string description() const override
Return a one-line description of this object.
const StatusTestResNorm< ScalarType, MV, OP > * getResidualStatusTest() const
Return the residual status test.
Class which defines basic traits for the operator type.
ParameterList & sublist(const std::string &name, bool mustAlreadyExist=false, const std::string &docString="")
int curDim
The current dimension of the reduction.
Parent class to all Belos exceptions.
ReturnType solve() override
This method performs possibly repeated calls to the underlying linear solver's iterate() routine unti...
Default parameters common to most Belos solvers.
std::vector< Teuchos::RCP< const Teuchos::SerialDenseVector< int, ScalarType > > > sn
The current Given's rotation coefficients.
static const double resScaleFactor
User-defined residual scaling factor.
Belos header file which uses auto-configuration information to include necessary C++ headers...
This class implements the pseudo-block GMRES iteration, where a block Krylov subspace is constructed ...
Factory to build a set of status tests from a parameter list.
Teuchos::RCP< const Teuchos::ParameterList > getCurrentParameters() const override
The current parameters for this solver.
PseudoBlockGmresIterOrthoFailure is thrown when the orthogonalization manager is unable to generate o...
const LinearProblem< ScalarType, MV, OP > & getProblem() const override
Return a reference to the linear problem being solved by this solver manager.
PseudoBlockGmresSolMgrOrthoFailure is thrown when the orthogonalization manager is unable to generate...
virtual void setUserConvStatusTest(const Teuchos::RCP< StatusTest< ScalarType, MV, OP > > &userConvStatusTest, const typename StatusTestCombo< ScalarType, MV, OP >::ComboType &comboType=StatusTestCombo< ScalarType, MV, OP >::SEQ) override
Set a custom status test.
MagnitudeType achievedTol() const override
Tolerance achieved by the last solve() invocation.
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.