45 #ifndef BELOS_BLOCK_GCRODR_SOLMGR_HPP
46 #define BELOS_BLOCK_GCRODR_SOLMGR_HPP
65 #ifdef BELOS_TEUCHOS_TIME_MONITOR
67 #endif // BELOS_TEUCHOS_TIME_MONITOR
126 template<
class ScalarType,
class MV,
class OP>
221 "Belos::BlockGCRODRSolMgr::setProblem: The input LinearProblem cannot be null.");
224 if (! problem->isProblemSet()) {
225 const bool success = problem->setProblem();
227 "Belos::BlockGCRODRSolMgr::setProblem: Calling the input LinearProblem's setProblem() method failed. This likely means that the "
228 "LinearProblem has a missing (null) matrix A, solution vector X, or right-hand side vector B. Please set these items in the LinearProblem and try again.");
250 problem_->setProblem();
288 void initializeStateStorage();
306 int getHarmonicVecsKryl (
int m,
const SDM& HH, SDM& PP);
311 int getHarmonicVecsAugKryl (
int keff,
318 void sort (std::vector<ScalarType>& dlist,
int n, std::vector<int>& iperm);
338 ortho_factory_type orthoFactory_;
363 static const bool adaptiveBlockSize_default_;
364 static const std::string recycleMethod_default_;
367 MagnitudeType convTol_, orthoKappa_;
368 int blockSize_, maxRestarts_, maxIters_, numIters_;
369 int verbosity_, outputStyle_, outputFreq_;
370 bool adaptiveBlockSize_;
371 std::string orthoType_, recycleMethod_;
372 std::string impResScale_, expResScale_;
380 int numBlocks_, recycledBlocks_;
402 std::vector<ScalarType> tau_;
403 std::vector<ScalarType> work_;
405 std::vector<int> ipiv_;
417 bool builtRecycleSpace_;
423 template<
class ScalarType,
class MV,
class OP>
424 const bool BlockGCRODRSolMgr<ScalarType,MV,OP>::adaptiveBlockSize_default_ =
true;
426 template<
class ScalarType,
class MV,
class OP>
427 const std::string BlockGCRODRSolMgr<ScalarType,MV,OP>::recycleMethod_default_ =
"harmvecs";
433 template<
class ScalarType,
class MV,
class OP>
439 template<
class ScalarType,
class MV,
class OP>
448 "Belos::BlockGCRODR constructor: The solver manager's constructor needs "
449 "the linear problem argument 'problem' to be nonnull.");
459 template<
class ScalarType,
class MV,
class OP>
461 adaptiveBlockSize_ = adaptiveBlockSize_default_;
462 recycleMethod_ = recycleMethod_default_;
464 loaDetected_ =
false;
465 builtRecycleSpace_ =
false;
536 template<
class ScalarType,
class MV,
class OP>
538 std::ostringstream oss;
539 oss <<
"Belos::BlockGCRODRSolMgr<" << SCT::name() <<
", ...>";
541 oss <<
"Ortho Type='"<<orthoType_ ;
542 oss <<
", Num Blocks=" <<numBlocks_;
543 oss <<
", Block Size=" <<blockSize_;
544 oss <<
", Num Recycle Blocks=" << recycledBlocks_;
545 oss <<
", Max Restarts=" << maxRestarts_;
550 template<
class ScalarType,
class MV,
class OP>
554 using Teuchos::parameterList;
556 using Teuchos::rcpFromRef;
558 if (defaultParams_.is_null()) {
559 RCP<ParameterList> pl = parameterList ();
561 const MagnitudeType convTol = SMT::squareroot (SCT::magnitude (SCT::eps()));
562 const int maxRestarts = 1000;
563 const int maxIters = 5000;
564 const int blockSize = 2;
565 const int numBlocks = 100;
566 const int numRecycledBlocks = 25;
569 const int outputFreq = 1;
570 RCP<std::ostream> outputStream = rcpFromRef (std::cout);
571 const std::string impResScale (
"Norm of Preconditioned Initial Residual");
572 const std::string expResScale (
"Norm of Initial Residual");
573 const std::string timerLabel (
"Belos");
574 const std::string orthoType (
"DGKS");
575 RCP<const ParameterList> orthoParams = orthoFactory_.getDefaultParameters (orthoType);
582 const MagnitudeType orthoKappa = -SCT::one();
585 pl->set (
"Convergence Tolerance", convTol,
586 "The tolerance that the solver needs to achieve in order for "
587 "the linear system(s) to be declared converged. The meaning "
588 "of this tolerance depends on the convergence test details.");
589 pl->set(
"Maximum Restarts", maxRestarts,
590 "The maximum number of restart cycles (not counting the first) "
591 "allowed for each set of right-hand sides solved.");
592 pl->set(
"Maximum Iterations", maxIters,
593 "The maximum number of iterations allowed for each set of "
594 "right-hand sides solved.");
595 pl->set(
"Block Size", blockSize,
596 "How many linear systems to solve at once.");
597 pl->set(
"Num Blocks", numBlocks,
598 "The maximum number of blocks allowed in the Krylov subspace "
599 "for each set of right-hand sides solved. This includes the "
600 "initial block. Total Krylov basis storage, not counting the "
601 "recycled subspace, is \"Num Blocks\" times \"Block Size\".");
602 pl->set(
"Num Recycled Blocks", numRecycledBlocks,
603 "The maximum number of vectors in the recycled subspace." );
604 pl->set(
"Verbosity", verbosity,
605 "What type(s) of solver information should be written "
606 "to the output stream.");
607 pl->set(
"Output Style", outputStyle,
608 "What style is used for the solver information to write "
609 "to the output stream.");
610 pl->set(
"Output Frequency", outputFreq,
611 "How often convergence information should be written "
612 "to the output stream.");
613 pl->set(
"Output Stream", outputStream,
614 "A reference-counted pointer to the output stream where all "
615 "solver output is sent.");
616 pl->set(
"Implicit Residual Scaling", impResScale,
617 "The type of scaling used in the implicit residual convergence test.");
618 pl->set(
"Explicit Residual Scaling", expResScale,
619 "The type of scaling used in the explicit residual convergence test.");
620 pl->set(
"Timer Label", timerLabel,
621 "The string to use as a prefix for the timer labels.");
623 pl->set(
"Orthogonalization", orthoType,
624 "The orthogonalization method to use. Valid options: " +
625 orthoFactory_.validNamesString());
626 pl->set (
"Orthogonalization Parameters", *orthoParams,
627 "Sublist of parameters specific to the orthogonalization method to use.");
628 pl->set(
"Orthogonalization Constant", orthoKappa,
629 "When using DGKS orthogonalization: the \"depTol\" constant, used "
630 "to determine whether another step of classical Gram-Schmidt is "
631 "necessary. Otherwise ignored. Nonpositive values are ignored.");
634 return defaultParams_;
637 template<
class ScalarType,
class MV,
class OP>
641 using Teuchos::isParameterType;
642 using Teuchos::getParameter;
645 using Teuchos::parameterList;
648 using Teuchos::rcp_dynamic_cast;
649 using Teuchos::rcpFromRef;
655 RCP<const ParameterList> defaultParams = getValidParameters();
662 params_ = parameterList (*defaultParams);
690 const int maxRestarts = params_->
get<
int> (
"Maximum Restarts");
692 "Belos::BlockGCRODRSolMgr: The \"Maximum Restarts\" parameter "
693 "must be nonnegative, but you specified a negative value of "
694 << maxRestarts <<
".");
696 const int maxIters = params_->get<
int> (
"Maximum Iterations");
697 TEUCHOS_TEST_FOR_EXCEPTION(maxIters <= 0, std::invalid_argument,
698 "Belos::BlockGCRODRSolMgr: The \"Maximum Iterations\" parameter "
699 "must be positive, but you specified a nonpositive value of "
702 const int numBlocks = params_->get<
int> (
"Num Blocks");
703 TEUCHOS_TEST_FOR_EXCEPTION(numBlocks <= 0, std::invalid_argument,
704 "Belos::BlockGCRODRSolMgr: The \"Num Blocks\" parameter must be "
705 "positive, but you specified a nonpositive value of " << numBlocks
708 const int blockSize = params_->get<
int> (
"Block Size");
709 TEUCHOS_TEST_FOR_EXCEPTION(blockSize <= 0, std::invalid_argument,
710 "Belos::BlockGCRODRSolMgr: The \"Block Size\" parameter must be "
711 "positive, but you specified a nonpositive value of " << blockSize
714 const int recycledBlocks = params_->get<
int> (
"Num Recycled Blocks");
715 TEUCHOS_TEST_FOR_EXCEPTION(recycledBlocks <= 0, std::invalid_argument,
716 "Belos::BlockGCRODRSolMgr: The \"Num Recycled Blocks\" parameter must "
717 "be positive, but you specified a nonpositive value of "
718 << recycledBlocks <<
".");
719 TEUCHOS_TEST_FOR_EXCEPTION(recycledBlocks >= numBlocks,
720 std::invalid_argument,
"Belos::BlockGCRODRSolMgr: The \"Num Recycled "
721 "Blocks\" parameter must be less than the \"Num Blocks\" parameter, "
722 "but you specified \"Num Recycled Blocks\" = " << recycledBlocks
723 <<
" and \"Num Blocks\" = " << numBlocks <<
".");
727 maxRestarts_ = maxRestarts;
728 maxIters_ = maxIters;
729 numBlocks_ = numBlocks;
730 blockSize_ = blockSize;
731 recycledBlocks_ = recycledBlocks;
738 std::string tempLabel = params_->get<std::string> (
"Timer Label");
739 const bool labelChanged = (tempLabel != label_);
741 #ifdef BELOS_TEUCHOS_TIME_MONITOR
742 std::string solveLabel = label_ +
": BlockGCRODRSolMgr total solve time";
743 if (timerSolve_.is_null()) {
746 }
else if (labelChanged) {
755 #endif // BELOS_TEUCHOS_TIME_MONITOR
761 if (params_->isParameter (
"Verbosity")) {
762 if (isParameterType<int> (*params_,
"Verbosity")) {
763 verbosity_ = params_->get<
int> (
"Verbosity");
766 verbosity_ = (int) getParameter<MsgType> (*params_,
"Verbosity");
773 if (params_->isParameter (
"Output Style")) {
774 if (isParameterType<int> (*params_,
"Output Style")) {
775 outputStyle_ = params_->get<
int> (
"Output Style");
778 outputStyle_ = (int) getParameter<OutputType> (*params_,
"Output Style");
806 if (params_->isParameter (
"Output Stream")) {
808 outputStream_ = getParameter<RCP<std::ostream> > (*params_,
"Output Stream");
810 catch (InvalidParameter&) {
811 outputStream_ = rcpFromRef (std::cout);
818 if (outputStream_.is_null()) {
823 outputFreq_ = params_->get<
int> (
"Output Frequency");
826 if (! outputTest_.is_null()) {
827 outputTest_->setOutputFrequency (outputFreq_);
835 if (printer_.is_null()) {
838 printer_->setVerbosity (verbosity_);
839 printer_->setOStream (outputStream_);
848 bool changedOrthoType =
false;
849 if (params_->isParameter (
"Orthogonalization")) {
850 const std::string& tempOrthoType =
851 params_->get<std::string> (
"Orthogonalization");
853 if (! orthoFactory_.isValidName (tempOrthoType)) {
854 std::ostringstream os;
855 os <<
"Belos::BlockGCRODRSolMgr: Invalid orthogonalization name \""
856 << tempOrthoType <<
"\". The following are valid options "
857 <<
"for the \"Orthogonalization\" name parameter: ";
858 orthoFactory_.printValidNames (os);
861 if (tempOrthoType != orthoType_) {
862 changedOrthoType =
true;
863 orthoType_ = tempOrthoType;
880 RCP<ParameterList> orthoParams = sublist (params,
"Orthogonalization Parameters",
true);
882 "Failed to get orthogonalization parameters. "
883 "Please report this bug to the Belos developers.");
909 ortho_ = orthoFactory_.makeMatOrthoManager (orthoType_, null, printer_,
910 label_, orthoParams);
920 bool gotValidOrthoKappa =
false;
921 if (params_->isParameter (
"Orthogonalization Constant")) {
922 const MagnitudeType orthoKappa =
923 params_->get<MagnitudeType> (
"Orthogonalization Constant");
924 if (orthoKappa > 0) {
925 orthoKappa_ = orthoKappa;
926 gotValidOrthoKappa =
true;
928 if (orthoType_ ==
"DGKS" && ! ortho_.is_null()) {
934 rcp_dynamic_cast<ortho_man_type>(ortho_)->setDepTol (orthoKappa_);
944 convTol_ = params_->get<MagnitudeType> (
"Convergence Tolerance");
945 if (! impConvTest_.is_null()) {
948 if (! expConvTest_.is_null()) {
949 expConvTest_->setTolerance (convTol_);
953 if (params_->isParameter (
"Implicit Residual Scaling")) {
954 std::string tempImpResScale =
955 getParameter<std::string> (*params_,
"Implicit Residual Scaling");
958 if (impResScale_ != tempImpResScale) {
960 impResScale_ = tempImpResScale;
962 if (! impConvTest_.is_null()) {
975 if (params_->isParameter(
"Explicit Residual Scaling")) {
976 std::string tempExpResScale =
977 getParameter<std::string> (*params_,
"Explicit Residual Scaling");
980 if (expResScale_ != tempExpResScale) {
982 expResScale_ = tempExpResScale;
984 if (! expConvTest_.is_null()) {
1002 if (maxIterTest_.is_null()) {
1005 maxIterTest_->setMaxIters (maxIters_);
1010 if (impConvTest_.is_null()) {
1011 impConvTest_ =
rcp (
new StatusTestResNorm_t (convTol_));
1017 if (expConvTest_.is_null()) {
1018 expConvTest_ =
rcp (
new StatusTestResNorm_t (convTol_));
1019 expConvTest_->defineResForm (StatusTestResNorm_t::Explicit,
Belos::TwoNorm);
1025 if (convTest_.is_null()) {
1026 convTest_ =
rcp (
new StatusTestCombo_t (StatusTestCombo_t::SEQ,
1034 sTest_ =
rcp (
new StatusTestCombo_t (StatusTestCombo_t::OR,
1035 maxIterTest_, convTest_));
1039 outputTest_ = stoFactory.
create (printer_, sTest_, outputFreq_,
1043 std::string solverDesc =
"Block GCRODR ";
1044 outputTest_->setSolverDesc (solverDesc);
1051 template<
class ScalarType,
class MV,
class OP>
1062 int KrylSpaDim = (numBlocks_ - 1) * blockSize_;
1065 int augSpaDim = KrylSpaDim + recycledBlocks_ + 1;
1068 int augSpaImgDim = KrylSpaDim + blockSize_ + recycledBlocks_+1;
1092 if (U_ == Teuchos::null) {
1093 U_ = MVT::Clone( *rhsMV, recycledBlocks_+1 );
1097 if (MVT::GetNumberVecs(*U_) < recycledBlocks_+1) {
1099 U_ = MVT::Clone( *tmp, recycledBlocks_+1 );
1104 if (C_ == Teuchos::null) {
1105 C_ = MVT::Clone( *rhsMV, recycledBlocks_+1 );
1109 if (MVT::GetNumberVecs(*C_) < recycledBlocks_+1) {
1111 C_ = MVT::Clone( *tmp, recycledBlocks_+1 );
1116 if (U1_ == Teuchos::null) {
1117 U1_ = MVT::Clone( *rhsMV, recycledBlocks_+1 );
1121 if (MVT::GetNumberVecs(*U1_) < recycledBlocks_+1) {
1123 U1_ = MVT::Clone( *tmp, recycledBlocks_+1 );
1128 if (C1_ == Teuchos::null) {
1129 C1_ = MVT::Clone( *rhsMV, recycledBlocks_+1 );
1133 if (MVT::GetNumberVecs(*U1_) < recycledBlocks_+1) {
1135 C1_ = MVT::Clone( *tmp, recycledBlocks_+1 );
1140 if (R_ == Teuchos::null){
1141 R_ = MVT::Clone( *rhsMV, blockSize_ );
1147 if (G_ == Teuchos::null){
1148 G_ =
Teuchos::rcp(
new SDM( augSpaImgDim, augSpaDim ) );
1151 if ( (G_->numRows() != augSpaImgDim) || (G_->numCols() != augSpaDim) )
1153 G_->reshape( augSpaImgDim, augSpaDim );
1155 G_->putScalar(zero);
1159 if (H_ == Teuchos::null){
1160 H_ =
Teuchos::rcp (
new SDM (
Teuchos::View, *G_, KrylSpaDim + blockSize_, KrylSpaDim, recycledBlocks_+1 ,recycledBlocks_+1 ) );
1164 if (F_ == Teuchos::null){
1165 F_ =
Teuchos::rcp(
new SDM( recycledBlocks_+1, recycledBlocks_+1 ) );
1168 if ( (F_->numRows() != recycledBlocks_+1) || (F_->numCols() != recycledBlocks_+1) ){
1169 F_->reshape( recycledBlocks_+1, recycledBlocks_+1 );
1172 F_->putScalar(zero);
1175 if (PP_ == Teuchos::null){
1176 PP_ =
Teuchos::rcp(
new SDM( augSpaImgDim, recycledBlocks_+1 ) );
1179 if ( (PP_->numRows() != augSpaImgDim) || (PP_->numCols() != recycledBlocks_+1) ){
1180 PP_->reshape( augSpaImgDim, recycledBlocks_+1 );
1185 if (HP_ == Teuchos::null)
1186 HP_ =
Teuchos::rcp(
new SDM( augSpaImgDim, augSpaDim ) );
1188 if ( (HP_->numRows() != augSpaImgDim) || (HP_->numCols() != augSpaDim) ){
1189 HP_->reshape( augSpaImgDim, augSpaDim );
1194 tau_.resize(recycledBlocks_+1);
1197 work_.resize(recycledBlocks_+1);
1200 ipiv_.resize(recycledBlocks_+1);
1204 template<
class ScalarType,
class MV,
class OP>
1205 void BlockGCRODRSolMgr<ScalarType,MV,OP>::buildRecycleSpaceKryl(
int& keff,
Teuchos::RCP<BlockGmresIter<ScalarType,MV,OP> > block_gmres_iter){
1211 int p = block_gmres_iter->getState().curDim;
1212 std::vector<int> index(keff);
1217 if(recycledBlocks_ >= p + blockSize_){
1221 for (
int ii=0; ii < p; ++ii) index[ii] = ii;
1223 MVT::SetBlock(*V_, index, *Utmp);
1229 if(recycleMethod_ ==
"harmvecs"){
1230 keff = getHarmonicVecsKryl(p, HH, *PPtmp);
1231 printer_->stream(
Debug) <<
"keff = " << keff << std::endl;
1237 for (
int ii=0; ii<keff; ++ii) index[ii] = ii;
1242 for (
int ii=0; ii < p; ++ii) index[ii] = ii;
1247 MVT::MvTimesMatAddMv( one, *Vtmp, *PPtmp, zero, *U1tmp );
1255 lapack.GEQRF(HPtmp.numRows(),HPtmp.numCols(),HPtmp.values(),HPtmp.stride(),&tau_[0],&work_[0],lwork,&info);
1256 TEUCHOS_TEST_FOR_EXCEPTION(info != 0, BlockGCRODRSolMgrLAPACKFailure,
"Belos::BlockGCRODRSolMgr::solve(): LAPACK _GEQRF failed to compute a workspace size.");
1259 lwork = (int)work_[0];
1260 work_.resize(lwork);
1261 lapack.GEQRF(HPtmp.numRows(),HPtmp.numCols(),HPtmp.values(),HPtmp.stride(),&tau_[0],&work_[0],lwork,&info);
1262 TEUCHOS_TEST_FOR_EXCEPTION(info != 0, BlockGCRODRSolMgrLAPACKFailure,
"Belos::BlockGCRODRSolMgr::solve(): LAPACK _GEQRF failed to compute a QR factorization.");
1267 for(
int ii=0;ii<keff;ii++) {
for(
int jj=ii;jj<keff;jj++) Rtmp(ii,jj) = HPtmp(ii,jj); }
1268 lapack.ORGQR(HPtmp.numRows(),HPtmp.numCols(),HPtmp.numCols(),HPtmp.values(),HPtmp.stride(),&tau_[0],&work_[0],lwork,&info);
1269 TEUCHOS_TEST_FOR_EXCEPTION(info != 0, BlockGCRODRSolMgrLAPACKFailure,
"Belos::BlockGCRODRSolMgr::solve(): LAPACK _ORGQR failed to construct the Q factor.");
1273 index.resize( p+blockSize_ );
1274 for (
int ii=0; ii < (p+blockSize_); ++ii) { index[ii] = ii; }
1275 Vtmp = MVT::CloneView( *V_, index );
1276 MVT::MvTimesMatAddMv( one, *Vtmp, HPtmp, zero, *Ctmp );
1283 ipiv_.resize(Rtmp.numRows());
1284 lapack.GETRF(Rtmp.numRows(),Rtmp.numCols(),Rtmp.values(),Rtmp.stride(),&ipiv_[0],&info);
1285 TEUCHOS_TEST_FOR_EXCEPTION(info != 0, BlockGCRODRSolMgrLAPACKFailure,
"Belos::GCRODRSolMgr::solve(): LAPACK _GETRF failed to compute an LU factorization.");
1287 lwork = Rtmp.numRows();
1288 work_.resize(lwork);
1289 lapack.GETRI(Rtmp.numRows(),Rtmp.values(),Rtmp.stride(),&ipiv_[0],&work_[0],lwork,&info);
1292 MVT::MvTimesMatAddMv( one, *U1tmp, Rtmp, zero, *Utmp );
1298 template<
class ScalarType,
class MV,
class OP>
1299 void BlockGCRODRSolMgr<ScalarType,MV,OP>::buildRecycleSpaceAugKryl(
Teuchos::RCP<BlockGCRODRIter<ScalarType,MV,OP> > block_gcrodr_iter){
1303 std::vector<MagnitudeType> d(keff);
1304 std::vector<int> index(numBlocks_+1);
1307 BlockGCRODRIterState<ScalarType,MV> oldState = block_gcrodr_iter->getState();
1308 int p = oldState.curDim;
1313 if(recycledBlocks_ >= keff + p){
1316 for (
int ii=0; ii < p; ++ii) { index[ii] = keff+ii; }
1318 for (
int ii=0; ii < p; ++ii) { index[ii] =ii; }
1319 MVT::SetBlock(*V_, index, *Utmp);
1326 for (
int ii=0; ii<keff; ++ii) { index[ii] = ii; }
1329 MVT::MvNorm( *Utmp, d );
1330 for (
int i=0; i<keff; ++i)
1332 MVT::MvScale( *Utmp, d );
1340 for (
int i=0; i<keff; ++i)
1341 (*Gtmp)(i,i) = d[i];
1348 SDM PPtmp(
Teuchos::View, *PP_, p+keff-blockSize_, recycledBlocks_+1 );
1349 keff_new = getHarmonicVecsAugKryl( keff, p-blockSize_, *Gtmp, oldState.V, PPtmp );
1358 index.resize( keff );
1359 for (
int ii=0; ii<keff; ++ii) { index[ii] = ii; }
1361 index.resize( keff_new );
1362 for (
int ii=0; ii<keff_new; ++ii) { index[ii] = ii; }
1363 U1tmp = MVT::CloneViewNonConst( *U1_, index );
1365 MVT::MvTimesMatAddMv( one, *Utmp, PPtmp, zero, *U1tmp );
1370 index.resize(p-blockSize_);
1371 for (
int ii=0; ii < p-blockSize_; ii++) { index[ii] = ii; }
1373 SDM PPtmp(
Teuchos::View, *PP_, p-blockSize_, keff_new, keff );
1374 MVT::MvTimesMatAddMv( one, *Vtmp, PPtmp, one, *U1tmp );
1380 SDM PPtmp(
Teuchos::View, *PP_, p-blockSize_+keff, keff_new );
1385 int info = 0, lwork = -1;
1386 tau_.resize(keff_new);
1387 lapack.GEQRF(HPtmp.numRows(),HPtmp.numCols(),HPtmp.values(),HPtmp.stride(),&tau_[0],&work_[0],lwork,&info);
1388 TEUCHOS_TEST_FOR_EXCEPTION(info != 0,BlockGCRODRSolMgrLAPACKFailure,
"Belos::BlockGCRODRSolMgr::solve(): LAPACK _GEQRF failed to compute a workspace size.");
1390 lwork = (int)work_[0];
1391 work_.resize(lwork);
1392 lapack.GEQRF(HPtmp.numRows(),HPtmp.numCols(),HPtmp.values(),HPtmp.stride(),&tau_[0],&work_[0],lwork,&info);
1393 TEUCHOS_TEST_FOR_EXCEPTION(info != 0,BlockGCRODRSolMgrLAPACKFailure,
"Belos::BlockGCRODRSolMgr::solve(): LAPACK _GEQRF failed to compute a QR factorization.");
1398 for(
int i=0;i<keff_new;i++) {
for(
int j=i;j<keff_new;j++) Ftmp(i,j) = HPtmp(i,j); }
1399 lapack.ORGQR(HPtmp.numRows(),HPtmp.numCols(),HPtmp.numCols(),HPtmp.values(),HPtmp.stride(),&tau_[0],&work_[0],lwork,&info);
1400 TEUCHOS_TEST_FOR_EXCEPTION(info != 0,BlockGCRODRSolMgrLAPACKFailure,
"Belos::BlockGCRODRSolMgr::solve(): LAPACK _ORGQR failed to construct the Q factor.");
1410 for (
int i=0; i < keff; i++) { index[i] = i; }
1412 index.resize(keff_new);
1413 for (
int i=0; i < keff_new; i++) { index[i] = i; }
1414 C1tmp = MVT::CloneViewNonConst( *C1_, index );
1416 MVT::MvTimesMatAddMv( one, *Ctmp, PPtmp, zero, *C1tmp );
1421 for (
int i=0; i < p; ++i) { index[i] = i; }
1424 MVT::MvTimesMatAddMv( one, *Vtmp, PPtmp, one, *C1tmp );
1433 ipiv_.resize(Ftmp.numRows());
1434 lapack.GETRF(Ftmp.numRows(),Ftmp.numCols(),Ftmp.values(),Ftmp.stride(),&ipiv_[0],&info);
1435 TEUCHOS_TEST_FOR_EXCEPTION(info != 0,BlockGCRODRSolMgrLAPACKFailure,
"Belos::BlockGCRODRSolMgr::solve(): LAPACK _GETRF failed to compute an LU factorization.");
1438 lwork = Ftmp.numRows();
1439 work_.resize(lwork);
1440 lapack.GETRI(Ftmp.numRows(),Ftmp.values(),Ftmp.stride(),&ipiv_[0],&work_[0],lwork,&info);
1441 TEUCHOS_TEST_FOR_EXCEPTION(info != 0, BlockGCRODRSolMgrLAPACKFailure,
"Belos::BlockGCRODRSolMgr::solve(): LAPACK _GETRI failed to compute an LU factorization.");
1444 index.resize(keff_new);
1445 for (
int i=0; i < keff_new; i++) { index[i] = i; }
1447 MVT::MvTimesMatAddMv( one, *U1tmp, Ftmp, zero, *Utmp );
1452 if (keff != keff_new) {
1454 block_gcrodr_iter->setSize( keff, numBlocks_ );
1456 SDM b1(
Teuchos::View, *G_, recycledBlocks_+2, 1, 0, recycledBlocks_ );
1462 template<
class ScalarType,
class MV,
class OP>
1463 int BlockGCRODRSolMgr<ScalarType,MV,OP>::getHarmonicVecsAugKryl(
int keff,
int m,
const SDM& GG,
const Teuchos::RCP<const MV>& VV, SDM& PP){
1465 int m2 = GG.numCols();
1466 bool xtraVec =
false;
1469 std::vector<int> index;
1472 std::vector<ScalarType> wr(m2), wi(m2);
1475 std::vector<MagnitudeType> w(m2);
1478 SDM vr(m2,m2,
false);
1481 std::vector<int> iperm(m2);
1484 builtRecycleSpace_ =
true;
1494 SDM A_tmp( keff+m+blockSize_, keff+m );
1499 for (
int i=0; i<keff; ++i) { index[i] = i; }
1503 MVT::MvTransMv( one, *Ctmp, *Utmp, A11 );
1507 index.resize(m+blockSize_);
1508 for (i=0; i < m+blockSize_; i++) { index[i] = i; }
1510 MVT::MvTransMv( one, *Vp, *Utmp, A21 );
1513 for( i=keff; i<keff+m; i++)
1517 SDM A( m2, A_tmp.numCols() );
1526 char balanc=
'P', jobvl=
'N', jobvr=
'V', sense=
'N';
1527 int ld = A.numRows();
1529 int ldvl = ld, ldvr = ld;
1530 int info = 0,ilo = 0,ihi = 0;
1531 ScalarType abnrm = zero, bbnrm = zero;
1533 std::vector<ScalarType> beta(ld);
1534 std::vector<ScalarType> work(lwork);
1535 std::vector<MagnitudeType> lscale(ld), rscale(ld);
1536 std::vector<MagnitudeType> rconde(ld), rcondv(ld);
1537 std::vector<int> iwork(ld+6);
1539 lapack.GGEVX(balanc, jobvl, jobvr, sense, ld, A.values(), ld, B.values(), ld, &wr[0], &wi[0],
1540 &beta[0], vl, ldvl, vr.values(), ldvr, &ilo, &ihi, &lscale[0], &rscale[0],
1541 &abnrm, &bbnrm, &rconde[0], &rcondv[0], &work[0], lwork, &iwork[0], bwork, &info);
1542 TEUCHOS_TEST_FOR_EXCEPTION(info != 0, BlockGCRODRSolMgrLAPACKFailure,
"Belos::BlockGCRODRSolMgr::solve(): LAPACK GGEVX failed to compute eigensolutions.");
1546 for( i=0; i<ld; i++ )
1549 this->sort(w,ld,iperm);
1552 if (wi[iperm[ld-recycledBlocks_]] != zero) {
1554 for ( i=ld-recycledBlocks_; i<ld; i++ )
1555 if (wi[iperm[i]] != zero) countImag++;
1557 if (countImag % 2) xtraVec =
true;
1562 for( i=0; i<recycledBlocks_; i++ )
1563 for( j=0; j<ld; j++ )
1564 PP(j,i) = vr(j,iperm[ld-recycledBlocks_+i]);
1567 if (wi[iperm[ld-recycledBlocks_]] > 0) {
1568 for( j=0; j<ld; j++ )
1569 PP(j,recycledBlocks_) = vr(j,iperm[ld-recycledBlocks_]+1);
1572 for( j=0; j<ld; j++ )
1573 PP(j,recycledBlocks_) = vr(j,iperm[ld-recycledBlocks_]-1);
1579 return recycledBlocks_+1;
1581 return recycledBlocks_;
1585 template<
class ScalarType,
class MV,
class OP>
1586 int BlockGCRODRSolMgr<ScalarType,MV,OP>::getHarmonicVecsKryl(
int m,
const SDM& HH, SDM& PP){
1587 bool xtraVec =
false;
1592 std::vector<MagnitudeType> wr(m), wi(m);
1598 std::vector<MagnitudeType> w(m);
1601 std::vector<int> iperm(m);
1605 std::vector<ScalarType> work(lwork);
1611 builtRecycleSpace_ =
true;
1618 for(
int i=0; i<=blockSize_-1; i++) (*harmRitzMatrix)[blockSize_-1-i][harmRitzMatrix->numRows()-1-i] = 1;
1621 lapack.GESV(m, blockSize_, HHt.values(), HHt.stride(), &iperm[0], harmRitzMatrix->values(), harmRitzMatrix->stride(), &info);
1623 TEUCHOS_TEST_FOR_EXCEPTION(info != 0, BlockGCRODRSolMgrLAPACKFailure,
"Belos::BlockGCRODRSolMgr::solve(): LAPACK GESV failed to compute a solution.");
1634 Htemp =
Teuchos::rcp(
new SDM(H_lbl_t.numRows(), H_lbl_t.numCols()));
1636 H_lbl_t.assign(*Htemp);
1638 Htemp =
Teuchos::rcp(
new SDM(harmRitzMatrix -> numRows(), harmRitzMatrix -> numCols()));
1640 harmRitzMatrix -> assign(*Htemp);
1643 int harmColIndex, HHColIndex;
1645 for(
int i = 0; i<blockSize_; i++){
1646 harmColIndex = harmRitzMatrix -> numCols() - i -1;
1648 for(
int j=0; j<m; j++) (*Htemp)[HHColIndex][j] += (*harmRitzMatrix)[harmColIndex][j];
1650 harmRitzMatrix = Htemp;
1658 lapack.GEEV(
'N',
'V', m, harmRitzMatrix -> values(), harmRitzMatrix -> stride(), &wr[0], &wi[0],
1659 vl, ldvl, vr.values(), vr.stride(), &work[0], lwork, &info);
1660 TEUCHOS_TEST_FOR_EXCEPTION(info != 0, BlockGCRODRSolMgrLAPACKFailure,
"Belos::BlockGCRODRSolMgr::solve(): LAPACK GEEV failed to compute eigensolutions.");
1663 for(
int i=0; i<m; ++i ) w[i] = Teuchos::ScalarTraits<ScalarType>::squareroot( wr[i]*wr[i] + wi[i]*wi[i] );
1665 this->sort(w, m, iperm);
1668 if (wi[iperm[recycledBlocks_-1]] != zero) {
1670 for (
int i=0; i<recycledBlocks_; ++i )
1671 if (wi[iperm[i]] != zero) countImag++;
1673 if (countImag % 2) xtraVec =
true;
1677 for(
int i=0; i<recycledBlocks_; ++i )
1678 for(
int j=0; j<m; j++ )
1679 PP(j,i) = vr(j,iperm[i]);
1682 if (wi[iperm[recycledBlocks_-1]] > 0) {
1683 for(
int j=0; j<m; ++j )
1684 PP(j,recycledBlocks_) = vr(j,iperm[recycledBlocks_-1]+1);
1687 for(
int j=0; j<m; ++j )
1688 PP(j,recycledBlocks_) = vr(j,iperm[recycledBlocks_-1]-1);
1694 printer_->stream(
Debug) <<
"Recycled " << recycledBlocks_+1 <<
" vectors" << std::endl;
1695 return recycledBlocks_+1;
1697 printer_->stream(
Debug) <<
"Recycled " << recycledBlocks_ <<
" vectors" << std::endl;
1698 return recycledBlocks_;
1704 template<
class ScalarType,
class MV,
class OP>
1705 void BlockGCRODRSolMgr<ScalarType,MV,OP>::sort(std::vector<ScalarType>& dlist,
int n, std::vector<int>& iperm) {
1706 int l, r, j, i, flag;
1733 if (dlist[j] > dlist[j - 1]) j = j + 1;
1734 if (dlist[j - 1] > dK) {
1735 dlist[i - 1] = dlist[j - 1];
1736 iperm[i - 1] = iperm[j - 1];
1749 dlist[r] = dlist[0];
1750 iperm[r] = iperm[0];
1764 template<
class ScalarType,
class MV,
class OP>
1768 using Teuchos::rcp_const_cast;
1774 std::vector<int> index(numBlocks_+1);
1790 int numRHS2Solve = MVT::GetNumberVecs( *(problem_->getRHS()) );
1791 int numCurrRHS = ( numRHS2Solve < blockSize_) ? numRHS2Solve : blockSize_;
1795 std::vector<int> currIdx;
1797 if ( adaptiveBlockSize_ ) {
1798 blockSize_ = numCurrRHS;
1799 currIdx.resize( numCurrRHS );
1800 for (
int i=0; i<numCurrRHS; ++i)
1801 currIdx[i] = startPtr+i;
1804 currIdx.resize( blockSize_ );
1805 for (
int i=0; i<numCurrRHS; ++i)
1806 currIdx[i] = startPtr+i;
1807 for (
int i=numCurrRHS; i<blockSize_; ++i)
1812 problem_->setLSIndex( currIdx );
1818 loaDetected_ =
false;
1821 bool isConverged =
true;
1824 initializeStateStorage();
1829 while (numRHS2Solve > 0){
1833 int prime_iterations;
1839 printer_->stream(
Debug) <<
" Now solving RHS index " << currIdx[0] <<
" using recycled subspace of dimension " << keff << std::endl << std::endl;
1843 for (
int ii=0; ii<keff; ++ii) { index[ii] = ii; }
1844 RCP<const MV> Utmp = MVT::CloneView( *U_, index );
1845 RCP<MV> Ctmp = MVT::CloneViewNonConst( *C_, index );
1846 problem_->apply( *Utmp, *Ctmp );
1848 RCP<MV> U1tmp = MVT::CloneViewNonConst( *U1_, index );
1853 int rank = ortho_->normalize(*Ctmp,
rcp(&Ftmp,
false));
1866 work_.resize(lwork);
1871 MVT::MvTimesMatAddMv( one, *Utmp, Ftmp, zero, *U1tmp );
1876 for (
int ii=0; ii<keff; ++ii) { index[ii] = ii; }
1877 Ctmp = MVT::CloneViewNonConst( *C_, index );
1878 Utmp = MVT::CloneView( *U_, index );
1881 SDM Ctr(keff,blockSize_);
1882 problem_->computeCurrPrecResVec( &*R_ );
1883 MVT::MvTransMv( one, *Ctmp, *R_, Ctr );
1886 RCP<MV> update = MVT::Clone( *problem_->getCurrLHSVec(), blockSize_ );
1887 MVT::MvInit( *update, 0.0 );
1888 MVT::MvTimesMatAddMv( one, *Utmp, Ctr, one, *update );
1889 problem_->updateSolution( update,
true );
1892 MVT::MvTimesMatAddMv( -one, *Ctmp, Ctr, one, *R_ );
1895 prime_iterations = 0;
1900 if (V_ == Teuchos::null) {
1903 V_ = MVT::Clone( *rhsMV, (numBlocks_+1)*blockSize_ );
1907 if (MVT::GetNumberVecs(*V_) < (numBlocks_+1)*blockSize_ ) {
1909 V_ = MVT::Clone( *tmp, (numBlocks_+1)*blockSize_ );
1914 printer_->stream(
Debug) <<
" No recycled subspace available for RHS index " << std::endl << std::endl;
1919 primeList.
set(
"Num Blocks",numBlocks_-1);
1920 primeList.
set(
"Block Size",blockSize_);
1921 primeList.
set(
"Recycled Blocks",0);
1922 primeList.
set(
"Keep Hessenberg",
true);
1923 primeList.
set(
"Initialize Hessenberg",
true);
1925 ptrdiff_t dim = MVText::GetGlobalLength( *(problem_->getRHS()) );
1926 if (blockSize_*static_cast<ptrdiff_t>(numBlocks_) > dim) {
1927 ptrdiff_t tmpNumBlocks = 0;
1928 if (blockSize_ == 1)
1929 tmpNumBlocks = dim / blockSize_;
1931 tmpNumBlocks = ( dim - blockSize_) / blockSize_;
1932 printer_->stream(
Warnings) <<
"Belos::BlockGmresSolMgr::solve(): Warning! Requested Krylov subspace dimension is larger than operator dimension!"
1933 << std::endl <<
"The maximum number of blocks allowed for the Krylov subspace will be adjusted to " << tmpNumBlocks << std::endl;
1934 primeList.
set(
"Num Blocks",Teuchos::as<int>(tmpNumBlocks));
1938 primeList.
set(
"Num Blocks",numBlocks_-1);
1945 block_gmres_iter->setSize( blockSize_, numBlocks_-1 );
1949 if (currIdx[blockSize_-1] == -1) {
1950 V_0 = MVT::Clone( *(problem_->getInitPrecResVec()), blockSize_ );
1951 problem_->computeCurrPrecResVec( &*V_0 );
1954 V_0 = MVT::CloneCopy( *(problem_->getInitPrecResVec()), currIdx );
1961 int rank = ortho_->normalize( *V_0, z_0 );
1969 block_gmres_iter->initializeGmres(newstate);
1971 bool primeConverged =
false;
1974 printer_->stream(
Debug) <<
" Preparing to Iterate!!!!" << std::endl << std::endl;
1975 block_gmres_iter->iterate();
1980 if ( convTest_->getStatus() ==
Passed ) {
1981 printer_->stream(
Debug) <<
"We converged during the prime the pump stage" << std::endl << std::endl;
1982 primeConverged = !(expConvTest_->getLOADetected());
1983 if ( expConvTest_->getLOADetected() ) {
1985 loaDetected_ =
true;
1986 printer_->stream(
Warnings) <<
"Belos::BlockGmresSolMgr::solve(): Warning! Solver has experienced a loss of accuracy!" << std::endl;
1992 else if( maxIterTest_->getStatus() ==
Passed ) {
1994 primeConverged =
false;
2000 printer_->stream(
Debug) <<
" We did not converge on priming cycle of Block GMRES. Therefore we recycle and restart. " << std::endl << std::endl;
2005 if (blockSize_ != 1) {
2006 printer_->stream(
Errors) <<
"Error! Caught std::exception in BlockGmresIter::iterate() at iteration "
2007 << block_gmres_iter->getNumIters() << std::endl
2008 << e.what() << std::endl;
2009 if (convTest_->getStatus() !=
Passed)
2010 primeConverged =
false;
2014 block_gmres_iter->updateLSQR( block_gmres_iter->getCurSubspaceDim() );
2016 sTest_->checkStatus( &*block_gmres_iter );
2017 if (convTest_->getStatus() !=
Passed)
2018 isConverged =
false;
2021 catch (
const std::exception &e) {
2022 printer_->stream(
Errors) <<
"Error! Caught std::exception in BlockGmresIter::iterate() at iteration "
2023 << block_gmres_iter->getNumIters() << std::endl
2024 << e.what() << std::endl;
2029 prime_iterations = block_gmres_iter->getNumIters();
2032 RCP<MV> update = block_gmres_iter->getCurrentUpdate();
2033 problem_->updateSolution( update,
true );
2037 problem_->computeCurrPrecResVec( &*R_ );
2040 newstate = block_gmres_iter->getState();
2042 H_->assign(*(newstate.
H));
2051 V_ = rcp_const_cast<MV>(newstate.
V);
2054 buildRecycleSpaceKryl(keff, block_gmres_iter);
2055 printer_->stream(
Debug) <<
"Generated recycled subspace using RHS index " << currIdx[0] <<
" of dimension " << keff << std::endl << std::endl;
2059 if (primeConverged) {
2080 problem_->setCurrLS();
2083 startPtr += numCurrRHS;
2084 numRHS2Solve -= numCurrRHS;
2085 if ( numRHS2Solve > 0 ) {
2086 numCurrRHS = ( numRHS2Solve < blockSize_) ? numRHS2Solve : blockSize_;
2087 if ( adaptiveBlockSize_ ) {
2088 blockSize_ = numCurrRHS;
2089 currIdx.resize( numCurrRHS );
2090 for (
int i=0; i<numCurrRHS; ++i) currIdx[i] = startPtr+i;
2093 currIdx.resize( blockSize_ );
2094 for (
int i=0; i<numCurrRHS; ++i) currIdx[i] = startPtr+i;
2095 for (
int i=numCurrRHS; i<blockSize_; ++i) currIdx[i] = -1;
2098 problem_->setLSIndex( currIdx );
2101 currIdx.resize( numRHS2Solve );
2112 blockgcrodrList.
set(
"Num Blocks",numBlocks_);
2113 blockgcrodrList.
set(
"Block Size",blockSize_);
2114 blockgcrodrList.
set(
"Recycled Blocks",keff);
2120 index.resize( blockSize_ );
2121 for(
int ii = 0; ii < blockSize_; ii++) index[ii] = ii;
2125 MVT::Assign(*R_,*V0);
2128 for(
int i=0; i < keff; i++){ index[i] = i;};
2130 H_ =
rcp(
new SDM(
Teuchos::View, *G_, (numBlocks_-1)*blockSize_ + blockSize_, (numBlocks_-1)*blockSize_, keff ,keff ));
2134 newstate.
U = MVT::CloneViewNonConst(*U_, index);
2135 newstate.
C = MVT::CloneViewNonConst(*C_, index);
2137 newstate.
curDim = blockSize_;
2138 block_gcrodr_iter -> initialize(newstate);
2140 int numRestarts = 0;
2144 block_gcrodr_iter -> iterate();
2149 if( convTest_->getStatus() ==
Passed ) {
2157 else if(maxIterTest_->getStatus() ==
Passed ){
2159 isConverged =
false;
2166 else if (block_gcrodr_iter->getCurSubspaceDim() == block_gcrodr_iter->getMaxSubspaceDim()){
2172 problem_->updateSolution(update,
true);
2173 buildRecycleSpaceAugKryl(block_gcrodr_iter);
2175 printer_->stream(
Debug) <<
" Generated new recycled subspace using RHS index " << currIdx[0] <<
" of dimension " << keff << std::endl << std::endl;
2177 if(numRestarts >= maxRestarts_) {
2178 isConverged =
false;
2184 printer_ -> stream(
Debug) <<
" Performing restart number " << numRestarts <<
" of " << maxRestarts_ << std::endl << std::endl;
2187 problem_->computeCurrPrecResVec( &*R_ );
2188 index.resize( blockSize_ );
2189 for (
int ii=0; ii<blockSize_; ++ii) index[ii] = ii;
2191 MVT::SetBlock(*R_,index,*V0);
2195 index.resize( numBlocks_*blockSize_ );
2196 for (
int ii=0; ii<(numBlocks_*blockSize_); ++ii) index[ii] = ii;
2197 restartState.
V = MVT::CloneViewNonConst( *V_, index );
2198 index.resize( keff );
2199 for (
int ii=0; ii<keff; ++ii) index[ii] = ii;
2200 restartState.
U = MVT::CloneViewNonConst( *U_, index );
2201 restartState.
C = MVT::CloneViewNonConst( *C_, index );
2203 H_ =
rcp(
new SDM(
Teuchos::View, *G_, numBlocks_*blockSize_, (numBlocks_-1)*blockSize_, keff ,keff ));
2204 restartState.
B = B_;
2205 restartState.
H = H_;
2206 restartState.
curDim = blockSize_;
2207 block_gcrodr_iter->initialize(restartState);
2216 TEUCHOS_TEST_FOR_EXCEPTION(
true,std::logic_error,
"Belos::BlockGCRODRSolMgr::solve(): Invalid return from BlockGCRODRIter::iterate().");
2222 block_gcrodr_iter->updateLSQR( block_gcrodr_iter->getCurSubspaceDim() );
2224 sTest_->checkStatus( &*block_gcrodr_iter );
2225 if (convTest_->getStatus() !=
Passed) isConverged =
false;
2228 catch(
const std::exception &e){
2229 printer_->stream(
Errors) <<
"Error! Caught exception in BlockGCRODRIter::iterate() at iteration "
2230 << block_gcrodr_iter->getNumIters() << std::endl
2231 << e.what() << std::endl;
2239 problem_->updateSolution( update,
true );
2258 problem_->setCurrLS();
2261 startPtr += numCurrRHS;
2262 numRHS2Solve -= numCurrRHS;
2263 if ( numRHS2Solve > 0 ) {
2264 numCurrRHS = ( numRHS2Solve < blockSize_) ? numRHS2Solve : blockSize_;
2265 if ( adaptiveBlockSize_ ) {
2266 blockSize_ = numCurrRHS;
2267 currIdx.resize( numCurrRHS );
2268 for (
int i=0; i<numCurrRHS; ++i) currIdx[i] = startPtr+i;
2271 currIdx.resize( blockSize_ );
2272 for (
int i=0; i<numCurrRHS; ++i) currIdx[i] = startPtr+i;
2273 for (
int i=numCurrRHS; i<blockSize_; ++i) currIdx[i] = -1;
2276 problem_->setLSIndex( currIdx );
2279 currIdx.resize( numRHS2Solve );
2283 if (!builtRecycleSpace_) {
2284 buildRecycleSpaceAugKryl(block_gcrodr_iter);
2285 printer_->stream(
Debug) <<
" Generated new recycled subspace using RHS index " << currIdx[0] <<
" of dimension " << keff << std::endl << std::endl;
2293 #ifdef BELOS_TEUCHOS_TIME_MONITOR
2299 numIters_ = maxIterTest_->getNumIters();
ScaleType convertStringToScaleType(const std::string &scaleType)
Convert the given string to its ScaleType enum value.
ScalarType * values() const
Collection of types and exceptions used within the Belos solvers.
const LinearProblem< ScalarType, MV, OP > & getProblem() const
Get current linear problem being solved for in this object.
Belos's basic output manager for sending information of select verbosity levels to the appropriate ou...
Class which manages the output and verbosity of the Belos solvers.
Structure to contain pointers to BlockGCRODRIter state variables.
virtual ~BlockGCRODRSolMgr()
Destructor.
int getNumIters() const
Get the iteration count for the most recent call to solve().
ScaleType
The type of scaling to use on the residual norm value.
Teuchos::RCP< Teuchos::SerialDenseMatrix< int, ScalarType > > B
The projection of the Krylov subspace against the recycled subspace *.
Exception thrown to signal error in a status test during Belos::StatusTest::checkStatus().
Teuchos::RCP< const Teuchos::ParameterList > getCurrentParameters() const
Get a parameter list containing the current parameters for this object.
This class implements the block GMRES iteration, where a block Krylov subspace is constructed...
Teuchos::RCP< const MV > V
The current Krylov basis.
T & get(const std::string &name, T def_value)
BlockGCRODRIterOrthoFailure is thrown when the BlockGCRODRIter object is unable to compute independen...
ParameterList & set(std::string const &name, T const &value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
Thrown when the linear problem was not set up correctly.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
A factory class for generating StatusTestOutput objects.
void setParameters(const Teuchos::RCP< Teuchos::ParameterList > ¶ms)
Set the parameters the solver should use to solve the linear problem.
Teuchos::RCP< const Teuchos::SerialDenseMatrix< int, ScalarType > > z
The current right-hand side of the least squares system RY = Z.
An implementation of StatusTestResNorm using a family of residual norms.
Structure to contain pointers to GmresIteration state variables.
An extension of the MultiVecTraits class that adds a new vector length method.
Belos::StatusTest class for specifying a maximum number of iterations.
BlockGCRODRSolMgrRecyclingFailure(const std::string &what_arg)
void reset(const ResetType type)
Performs a reset of the solver manager specified by the ResetType.
Thrown if any problem occurs in using or creating the recycle subspace.
A factory class for generating StatusTestOutput objects.
Teuchos::RCP< MV > V
The current Krylov basis.
BlockGCRODRSolMgrOrthoFailure(const std::string &what_arg)
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="")
int curDim
The current dimension of the reduction.
Traits class which defines basic operations on multivectors.
Belos::StatusTest for logically combining several status tests.
A Belos::StatusTest class for specifying a maximum number of iterations.
ResetType
How to reset the solver.
BlockGCRODRSolMgrLAPACKFailure(const std::string &what_arg)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
A solver manager for the Block GCRO-DR (Block Recycling GMRES) linear solver.
Pure virtual base class which describes the basic interface for a solver manager. ...
int curDim
The current dimension of the reduction.
Belos concrete class for performing the block GCRO-DR (block GMRES with recycling) iteration...
BlockGCRODRSolMgr()
Default constructor.
A linear system to solve, and its associated information.
std::string description() const
A description of the Block GCRODR solver manager.
Class which describes the linear problem to be solved by the iterative solver.
void setProblem(const Teuchos::RCP< LinearProblem< ScalarType, MV, OP > > &problem)
Set the linear problem to solve on the next call to solve().
void validateParametersAndSetDefaults(ParameterList const &validParamList, int const depth=1000)
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 ...
Thrown when the solution manager was unable to orthogonalize the basis vectors.
Teuchos::RCP< MV > U
The recycled subspace and its projection.
Belos concrete class for performing the block GMRES iteration.
Implementation of the Block GCRO-DR (Block Recycling GMRES) iteration.
OrdinalType numCols() const
int setTolerance(MagnitudeType tolerance)
Set the value of the tolerance.
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.
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const
Get a parameter list containing the valid parameters for this object.
Belos::StatusTestResNorm for specifying general residual norm stopping criteria.
Teuchos::RCP< Teuchos::SerialDenseMatrix< int, ScalarType > > H
The current Hessenberg matrix.
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.
Class which defines basic traits for the operator type.
Parent class to all Belos exceptions.
Pure virtual base class which augments the basic interface for a Gmres linear solver iteration...
GmresIterationOrthoFailure is thrown when the GmresIteration object is unable to compute independent ...
Belos header file which uses auto-configuration information to include necessary C++ headers...
BlockGCRODRSolMgrLinearProblemFailure(const std::string &what_arg)
ReturnType solve()
Solve the current linear problem.
Thrown when an LAPACK call fails.
OrdinalType stride() const
OrdinalType numRows() const
Belos concrete class for performing the block, flexible GMRES iteration.
bool isLOADetected() const
Whether a loss of accuracy was detected during the most recent solve.
OutputType
Style of output used to display status test information.
Teuchos::RCP< const Teuchos::SerialDenseMatrix< int, ScalarType > > H
The current Hessenberg matrix.