42 #ifndef BELOS_GMRES_POLY_SOLMGR_HPP
43 #define BELOS_GMRES_POLY_SOLMGR_HPP
70 #ifdef BELOS_TEUCHOS_TIME_MONITOR
122 template<
class ScalarType,
class MV,
class OP>
188 return Teuchos::tuple(timerSolve_, timerPoly_);
222 problem_->setProblem();
223 isPolyBuilt_ =
false;
263 bool checkStatusTest();
289 static const MagnitudeType polytol_default_;
290 static const MagnitudeType convtol_default_;
291 static const MagnitudeType orthoKappa_default_;
292 static const int maxDegree_default_;
293 static const int maxRestarts_default_;
294 static const int maxIters_default_;
295 static const bool strictConvTol_default_;
296 static const bool showMaxResNormOnly_default_;
297 static const int blockSize_default_;
298 static const int numBlocks_default_;
299 static const int verbosity_default_;
300 static const int outputStyle_default_;
301 static const int outputFreq_default_;
302 static const std::string impResScale_default_;
303 static const std::string expResScale_default_;
304 static const std::string label_default_;
305 static const std::string orthoType_default_;
309 MagnitudeType polytol_, convtol_, orthoKappa_;
310 int maxDegree_, maxRestarts_, maxIters_, numIters_;
311 int blockSize_, numBlocks_, verbosity_, outputStyle_, outputFreq_;
312 bool strictConvTol_, showMaxResNormOnly_;
313 std::string orthoType_;
314 std::string impResScale_, expResScale_;
328 bool isSet_, isSTSet_, expResTest_;
334 template<
class ScalarType,
class MV,
class OP>
335 const typename GmresPolySolMgr<ScalarType,MV,OP>::MagnitudeType GmresPolySolMgr<ScalarType,MV,OP>::polytol_default_ = 1e-12;
337 template<
class ScalarType,
class MV,
class OP>
338 const typename GmresPolySolMgr<ScalarType,MV,OP>::MagnitudeType GmresPolySolMgr<ScalarType,MV,OP>::convtol_default_ = 1e-8;
340 template<
class ScalarType,
class MV,
class OP>
341 const typename GmresPolySolMgr<ScalarType,MV,OP>::MagnitudeType GmresPolySolMgr<ScalarType,MV,OP>::orthoKappa_default_ = -1.0;
343 template<
class ScalarType,
class MV,
class OP>
344 const int GmresPolySolMgr<ScalarType,MV,OP>::maxDegree_default_ = 25;
346 template<
class ScalarType,
class MV,
class OP>
347 const int GmresPolySolMgr<ScalarType,MV,OP>::maxRestarts_default_ = 20;
349 template<
class ScalarType,
class MV,
class OP>
350 const int GmresPolySolMgr<ScalarType,MV,OP>::maxIters_default_ = 1000;
352 template<
class ScalarType,
class MV,
class OP>
353 const bool GmresPolySolMgr<ScalarType,MV,OP>::strictConvTol_default_ =
false;
355 template<
class ScalarType,
class MV,
class OP>
356 const bool GmresPolySolMgr<ScalarType,MV,OP>::showMaxResNormOnly_default_ =
false;
358 template<
class ScalarType,
class MV,
class OP>
359 const int GmresPolySolMgr<ScalarType,MV,OP>::blockSize_default_ = 1;
361 template<
class ScalarType,
class MV,
class OP>
362 const int GmresPolySolMgr<ScalarType,MV,OP>::numBlocks_default_ = 300;
364 template<
class ScalarType,
class MV,
class OP>
365 const int GmresPolySolMgr<ScalarType,MV,OP>::verbosity_default_ =
Belos::Errors;
367 template<
class ScalarType,
class MV,
class OP>
368 const int GmresPolySolMgr<ScalarType,MV,OP>::outputStyle_default_ =
Belos::General;
370 template<
class ScalarType,
class MV,
class OP>
371 const int GmresPolySolMgr<ScalarType,MV,OP>::outputFreq_default_ = -1;
373 template<
class ScalarType,
class MV,
class OP>
374 const std::string GmresPolySolMgr<ScalarType,MV,OP>::impResScale_default_ =
"Norm of RHS";
376 template<
class ScalarType,
class MV,
class OP>
377 const std::string GmresPolySolMgr<ScalarType,MV,OP>::expResScale_default_ =
"Norm of RHS";
379 template<
class ScalarType,
class MV,
class OP>
380 const std::string GmresPolySolMgr<ScalarType,MV,OP>::label_default_ =
"Belos";
382 template<
class ScalarType,
class MV,
class OP>
383 const std::string GmresPolySolMgr<ScalarType,MV,OP>::orthoType_default_ =
"DGKS";
385 template<
class ScalarType,
class MV,
class OP>
390 template<
class ScalarType,
class MV,
class OP>
392 outputStream_(outputStream_default_),
393 polytol_(polytol_default_),
394 convtol_(convtol_default_),
395 orthoKappa_(orthoKappa_default_),
396 maxDegree_(maxDegree_default_),
397 maxRestarts_(maxRestarts_default_),
398 maxIters_(maxIters_default_),
399 blockSize_(blockSize_default_),
400 numBlocks_(numBlocks_default_),
401 verbosity_(verbosity_default_),
402 outputStyle_(outputStyle_default_),
403 outputFreq_(outputFreq_default_),
404 strictConvTol_(strictConvTol_default_),
405 showMaxResNormOnly_(showMaxResNormOnly_default_),
406 orthoType_(orthoType_default_),
407 impResScale_(impResScale_default_),
408 expResScale_(expResScale_default_),
409 label_(label_default_),
419 template<
class ScalarType,
class MV,
class OP>
424 outputStream_(outputStream_default_),
425 polytol_(polytol_default_),
426 convtol_(convtol_default_),
427 orthoKappa_(orthoKappa_default_),
428 maxDegree_(maxDegree_default_),
429 maxRestarts_(maxRestarts_default_),
430 maxIters_(maxIters_default_),
431 blockSize_(blockSize_default_),
432 numBlocks_(numBlocks_default_),
433 verbosity_(verbosity_default_),
434 outputStyle_(outputStyle_default_),
435 outputFreq_(outputFreq_default_),
436 strictConvTol_(strictConvTol_default_),
437 showMaxResNormOnly_(showMaxResNormOnly_default_),
438 orthoType_(orthoType_default_),
439 impResScale_(impResScale_default_),
440 expResScale_(expResScale_default_),
441 label_(label_default_),
459 template<
class ScalarType,
class MV,
class OP>
466 pl->
set(
"Polynomial Tolerance", polytol_default_,
467 "The relative residual tolerance that used to construct the GMRES polynomial.");
468 pl->
set(
"Maximum Degree", maxDegree_default_,
469 "The maximum degree allowed for any GMRES polynomial.");
470 pl->
set(
"Convergence Tolerance", convtol_default_,
471 "The relative residual tolerance that needs to be achieved by the\n"
472 "iterative solver in order for the linear system to be declared converged." );
473 pl->
set(
"Maximum Restarts", maxRestarts_default_,
474 "The maximum number of restarts allowed for each\n"
475 "set of RHS solved.");
476 pl->
set(
"Maximum Iterations", maxIters_default_,
477 "The maximum number of block iterations allowed for each\n"
478 "set of RHS solved.");
479 pl->
set(
"Num Blocks", numBlocks_default_,
480 "The maximum number of blocks allowed in the Krylov subspace\n"
481 "for each set of RHS solved.");
482 pl->
set(
"Block Size", blockSize_default_,
483 "The number of vectors in each block. This number times the\n"
484 "number of blocks is the total Krylov subspace dimension.");
485 pl->
set(
"Verbosity", verbosity_default_,
486 "What type(s) of solver information should be outputted\n"
487 "to the output stream.");
488 pl->
set(
"Output Style", outputStyle_default_,
489 "What style is used for the solver information outputted\n"
490 "to the output stream.");
491 pl->
set(
"Output Frequency", outputFreq_default_,
492 "How often convergence information should be outputted\n"
493 "to the output stream.");
494 pl->
set(
"Output Stream", outputStream_default_,
495 "A reference-counted pointer to the output stream where all\n"
496 "solver output is sent.");
497 pl->
set(
"Strict Convergence", strictConvTol_default_,
498 "After polynomial is applied, whether solver should try to achieve\n"
499 "the relative residual tolerance.");
500 pl->
set(
"Show Maximum Residual Norm Only", showMaxResNormOnly_default_,
501 "When convergence information is printed, only show the maximum\n"
502 "relative residual norm when the block size is greater than one.");
503 pl->
set(
"Implicit Residual Scaling", impResScale_default_,
504 "The type of scaling used in the implicit residual convergence test.");
505 pl->
set(
"Explicit Residual Scaling", expResScale_default_,
506 "The type of scaling used in the explicit residual convergence test.");
507 pl->
set(
"Timer Label", label_default_,
508 "The string to use as a prefix for the timer labels.");
510 pl->
set(
"Orthogonalization", orthoType_default_,
511 "The type of orthogonalization to use: DGKS, ICGS, or IMGS.");
512 pl->
set(
"Orthogonalization Constant",orthoKappa_default_,
513 "The constant used by DGKS orthogonalization to determine\n"
514 "whether another step of classical Gram-Schmidt is necessary.");
521 template<
class ScalarType,
class MV,
class OP>
526 if (params_ == Teuchos::null) {
535 maxDegree_ = params->
get(
"Maximum Degree",maxDegree_default_);
538 params_->set(
"Maximum Degree", maxDegree_);
543 maxRestarts_ = params->
get(
"Maximum Restarts",maxRestarts_default_);
546 params_->set(
"Maximum Restarts", maxRestarts_);
551 maxIters_ = params->
get(
"Maximum Iterations",maxIters_default_);
554 params_->set(
"Maximum Iterations", maxIters_);
555 if (maxIterTest_!=Teuchos::null)
556 maxIterTest_->setMaxIters( maxIters_ );
561 blockSize_ = params->
get(
"Block Size",blockSize_default_);
563 "Belos::GmresPolySolMgr: \"Block Size\" must be strictly positive.");
566 params_->set(
"Block Size", blockSize_);
571 numBlocks_ = params->
get(
"Num Blocks",numBlocks_default_);
573 "Belos::GmresPolySolMgr: \"Num Blocks\" must be strictly positive.");
576 params_->set(
"Num Blocks", numBlocks_);
581 std::string tempLabel = params->
get(
"Timer Label", label_default_);
584 if (tempLabel != label_) {
586 params_->set(
"Timer Label", label_);
587 std::string solveLabel = label_ +
": GmresPolySolMgr total solve time";
588 #ifdef BELOS_TEUCHOS_TIME_MONITOR
591 std::string polyLabel = label_ +
": GmresPolySolMgr polynomial creation time";
592 #ifdef BELOS_TEUCHOS_TIME_MONITOR
595 if (ortho_ != Teuchos::null) {
596 ortho_->setLabel( label_ );
603 std::string tempOrthoType = params->
get(
"Orthogonalization",orthoType_default_);
605 std::invalid_argument,
606 "Belos::GmresPolySolMgr: \"Orthogonalization\" must be either \"DGKS\", \"ICGS\", or \"IMGS\".");
607 if (tempOrthoType != orthoType_) {
608 orthoType_ = tempOrthoType;
610 if (orthoType_==
"DGKS") {
611 if (orthoKappa_ <= 0) {
619 else if (orthoType_==
"ICGS") {
622 else if (orthoType_==
"IMGS") {
629 if (params->
isParameter(
"Orthogonalization Constant")) {
630 orthoKappa_ = params->
get(
"Orthogonalization Constant",orthoKappa_default_);
633 params_->set(
"Orthogonalization Constant",orthoKappa_);
634 if (orthoType_==
"DGKS") {
635 if (orthoKappa_ > 0 && ortho_ != Teuchos::null) {
643 if (Teuchos::isParameterType<int>(*params,
"Verbosity")) {
644 verbosity_ = params->
get(
"Verbosity", verbosity_default_);
646 verbosity_ = (int)Teuchos::getParameter<Belos::MsgType>(*params,
"Verbosity");
650 params_->set(
"Verbosity", verbosity_);
651 if (printer_ != Teuchos::null)
652 printer_->setVerbosity(verbosity_);
657 if (Teuchos::isParameterType<int>(*params,
"Output Style")) {
658 outputStyle_ = params->
get(
"Output Style", outputStyle_default_);
660 outputStyle_ = (int)Teuchos::getParameter<Belos::OutputType>(*params,
"Output Style");
664 params_->set(
"Output Style", outputStyle_);
665 if (outputTest_ != Teuchos::null) {
672 outputStream_ = Teuchos::getParameter<Teuchos::RCP<std::ostream> >(*params,
"Output Stream");
675 params_->set(
"Output Stream", outputStream_);
676 if (printer_ != Teuchos::null)
677 printer_->setOStream( outputStream_ );
683 outputFreq_ = params->
get(
"Output Frequency", outputFreq_default_);
687 params_->set(
"Output Frequency", outputFreq_);
688 if (outputTest_ != Teuchos::null)
689 outputTest_->setOutputFrequency( outputFreq_ );
693 if (printer_ == Teuchos::null) {
703 polytol_ = params->
get(
"Polynomial Tolerance",polytol_default_);
706 params_->set(
"Polynomial Tolerance", polytol_);
710 if (params->
isParameter(
"Convergence Tolerance")) {
711 convtol_ = params->
get(
"Convergence Tolerance",convtol_default_);
714 params_->set(
"Convergence Tolerance", convtol_);
715 if (impConvTest_ != Teuchos::null)
716 impConvTest_->setTolerance( convtol_ );
717 if (expConvTest_ != Teuchos::null)
718 expConvTest_->setTolerance( convtol_ );
723 strictConvTol_ = params->
get(
"Strict Convergence",strictConvTol_default_);
726 params_->set(
"Strict Convergence", strictConvTol_);
730 if (params->
isParameter(
"Implicit Residual Scaling")) {
731 std::string tempImpResScale = Teuchos::getParameter<std::string>( *params,
"Implicit Residual Scaling" );
734 if (impResScale_ != tempImpResScale) {
736 impResScale_ = tempImpResScale;
739 params_->set(
"Implicit Residual Scaling", impResScale_);
740 if (impConvTest_ != Teuchos::null) {
744 catch (std::exception& e) {
752 if (params->
isParameter(
"Explicit Residual Scaling")) {
753 std::string tempExpResScale = Teuchos::getParameter<std::string>( *params,
"Explicit Residual Scaling" );
756 if (expResScale_ != tempExpResScale) {
758 expResScale_ = tempExpResScale;
761 params_->set(
"Explicit Residual Scaling", expResScale_);
762 if (expConvTest_ != Teuchos::null) {
766 catch (std::exception& e) {
775 if (params->
isParameter(
"Show Maximum Residual Norm Only")) {
776 showMaxResNormOnly_ = Teuchos::getParameter<bool>(*params,
"Show Maximum Residual Norm Only");
779 params_->set(
"Show Maximum Residual Norm Only", showMaxResNormOnly_);
780 if (impConvTest_ != Teuchos::null)
781 impConvTest_->setShowMaxResNormOnly( showMaxResNormOnly_ );
782 if (expConvTest_ != Teuchos::null)
783 expConvTest_->setShowMaxResNormOnly( showMaxResNormOnly_ );
787 if (ortho_ == Teuchos::null) {
788 if (orthoType_==
"DGKS") {
789 if (orthoKappa_ <= 0) {
797 else if (orthoType_==
"ICGS") {
800 else if (orthoType_==
"IMGS") {
805 "Belos::GmresPolySolMgr(): Invalid orthogonalization type.");
810 if (timerSolve_ == Teuchos::null) {
811 std::string solveLabel = label_ +
": GmresPolySolMgr total solve time";
812 #ifdef BELOS_TEUCHOS_TIME_MONITOR
817 if (timerPoly_ == Teuchos::null) {
818 std::string polyLabel = label_ +
": GmresPolySolMgr polynomial creation time";
819 #ifdef BELOS_TEUCHOS_TIME_MONITOR
829 template<
class ScalarType,
class MV,
class OP>
851 tmpImpConvTest->setShowMaxResNormOnly( showMaxResNormOnly_ );
852 impConvTest_ = tmpImpConvTest;
857 tmpExpConvTest->defineResForm( StatusTestGenResNorm_t::Explicit,
Belos::TwoNorm );
859 tmpExpConvTest->setShowMaxResNormOnly( showMaxResNormOnly_ );
860 expConvTest_ = tmpExpConvTest;
863 convTest_ =
Teuchos::rcp(
new StatusTestCombo_t( StatusTestCombo_t::SEQ, impConvTest_, expConvTest_ ) );
872 tmpImpConvTest->setShowMaxResNormOnly( showMaxResNormOnly_ );
873 impConvTest_ = tmpImpConvTest;
876 expConvTest_ = impConvTest_;
877 convTest_ = impConvTest_;
880 sTest_ =
Teuchos::rcp(
new StatusTestCombo_t( StatusTestCombo_t::OR, maxIterTest_, convTest_ ) );
884 StatusTestOutputFactory<ScalarType,MV,OP> stoFactory( outputStyle_ );
888 std::string solverDesc =
" Gmres Polynomial ";
889 outputTest_->setSolverDesc( solverDesc );
898 template<
class ScalarType,
class MV,
class OP>
899 bool GmresPolySolMgr<ScalarType,MV,OP>::generatePoly()
904 MVT::MvInit( *newX, SCT::zero() );
905 MVT::MvRandom( *newB );
907 Teuchos::rcp(
new LinearProblem<ScalarType,MV,OP>( problem_->getOperator(), newX, newB ) );
908 newProblem->setLeftPrec( problem_->getLeftPrec() );
909 newProblem->setRightPrec( problem_->getRightPrec() );
910 newProblem->setLabel(
"Belos GMRES Poly Generation");
911 newProblem->setProblem();
912 std::vector<int> idx(1,0);
913 newProblem->setLSIndex( idx );
919 polyList.
set(
"Num Blocks",maxDegree_);
920 polyList.
set(
"Block Size",1);
921 polyList.
set(
"Keep Hessenberg",
true);
925 Teuchos::rcp(
new StatusTestMaxIters<ScalarType,MV,OP>( maxDegree_ ) );
929 Teuchos::rcp(
new StatusTestGenResNorm<ScalarType,MV,OP>( polytol_ ) );
934 Teuchos::rcp(
new StatusTestCombo<ScalarType,MV,OP>( StatusTestCombo<ScalarType,MV,OP>::OR, maxItrTst, convTst ) );
938 gmres_iter =
Teuchos::rcp(
new BlockGmresIter<ScalarType,MV,OP>(newProblem,printer_,polyTest,ortho_,polyList) );
942 newProblem->computeCurrPrecResVec( &*V_0 );
948 int rank = ortho_->normalize( *V_0, poly_r0_ );
950 "Belos::GmresPolySolMgr::generatePoly(): Failed to compute initial block of orthonormal vectors for polynomial generation.");
953 GmresIterationState<ScalarType,MV> newstate;
955 newstate.z = poly_r0_;
957 gmres_iter->initializeGmres(newstate);
960 bool polyConverged =
false;
962 gmres_iter->iterate();
965 if ( convTst->getStatus() ==
Passed ) {
967 polyConverged =
true;
970 catch (GmresIterationOrthoFailure e) {
972 gmres_iter->updateLSQR( gmres_iter->getCurSubspaceDim() );
975 polyTest->checkStatus( &*gmres_iter );
976 if (convTst->getStatus() ==
Passed)
977 polyConverged =
true;
979 catch (std::exception e) {
980 printer_->stream(
Errors) <<
"Error! Caught exception in BlockGmresIter::iterate() at iteration "
981 << gmres_iter->getNumIters() << std::endl
982 << e.what() << std::endl;
989 (void) polyConverged;
995 GmresIterationState<ScalarType,MV> gmresState = gmres_iter->getState();
998 poly_dim_ = gmresState.curDim;
999 if (poly_dim_ == 0) {
1014 gmresState.R->values(), gmresState.R->stride(),
1015 poly_y_->values(), poly_y_->stride() );
1026 template<
class ScalarType,
class MV,
class OP>
1033 setParameters(Teuchos::parameterList(*getValidParameters()));
1040 "Belos::GmresPolySolMgr::solve(): Linear problem is not a valid object.");
1043 "Belos::GmresPolySolMgr::solve(): Linear problem is not ready, setProblem() has not been called.");
1045 if (!isSTSet_ || (!expResTest_ && !
Teuchos::is_null(problem_->getLeftPrec())) ) {
1047 "Belos::GmresPolySolMgr::solve(): Linear problem and requested status tests are incompatible.");
1051 if (!isPolyBuilt_) {
1052 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1055 isPolyBuilt_ = generatePoly();
1057 "Belos::GmresPolySolMgr::generatePoly(): Failed to generate a non-trivial polynomial, reduce polynomial tolerance.");
1059 "Belos::GmresPolySolMgr::generatePoly(): Failed to generate polynomial that satisfied requirements.");
1063 bool isConverged =
true;
1067 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1072 poly_Op_->Apply( *problem_->getRHS(), *problem_->getLHS() );
1075 problem_->setProblem();
1078 if (strictConvTol_) {
1082 int numRHS2Solve = MVT::GetNumberVecs( *(problem_->getRHS()) );
1083 int numCurrRHS = ( numRHS2Solve < blockSize_) ? numRHS2Solve : blockSize_;
1085 std::vector<int> currIdx;
1088 currIdx.resize( blockSize_ );
1089 for (
int i=0; i<numCurrRHS; ++i)
1090 { currIdx[i] = startPtr+i; }
1091 for (
int i=numCurrRHS; i<blockSize_; ++i)
1092 { currIdx[i] = -1; }
1095 problem_->setLSIndex( currIdx );
1100 plist.
set(
"Block Size",blockSize_);
1102 ptrdiff_t dim = MVText::GetGlobalLength( *(problem_->getRHS()) );
1103 if (blockSize_*static_cast<ptrdiff_t>(numBlocks_) > dim) {
1104 ptrdiff_t tmpNumBlocks = 0;
1105 if (blockSize_ == 1)
1106 tmpNumBlocks = dim / blockSize_;
1108 tmpNumBlocks = ( dim - blockSize_) / blockSize_;
1110 "Warning! Requested Krylov subspace dimension is larger than operator dimension!" << std::endl <<
1111 " The maximum number of blocks allowed for the Krylov subspace will be adjusted to " << tmpNumBlocks << std::endl;
1112 plist.
set(
"Num Blocks",Teuchos::asSafe<int>(tmpNumBlocks));
1115 plist.
set(
"Num Blocks",numBlocks_);
1118 outputTest_->reset();
1119 loaDetected_ =
false;
1132 while ( numRHS2Solve > 0 ) {
1135 if (blockSize_*numBlocks_ > dim) {
1136 int tmpNumBlocks = 0;
1137 if (blockSize_ == 1)
1138 tmpNumBlocks = dim / blockSize_;
1140 tmpNumBlocks = ( dim - blockSize_) / blockSize_;
1141 block_gmres_iter->setSize( blockSize_, tmpNumBlocks );
1144 block_gmres_iter->setSize( blockSize_, numBlocks_ );
1147 block_gmres_iter->resetNumIters();
1150 outputTest_->resetNumCalls();
1154 V_0 = MVT::CloneCopy( *(problem_->getInitPrecResVec()), currIdx );
1162 int rank = ortho_->normalize( *V_0, z_0 );
1164 "Belos::GmresPolySolMgr::solve(): Failed to compute initial block of orthonormal vectors.");
1171 block_gmres_iter->initializeGmres(newstate);
1172 int numRestarts = 0;
1177 block_gmres_iter->iterate();
1184 if ( convTest_->getStatus() ==
Passed ) {
1185 if ( expConvTest_->getLOADetected() ) {
1187 loaDetected_ =
true;
1188 isConverged =
false;
1197 else if ( maxIterTest_->getStatus() ==
Passed ) {
1199 isConverged =
false;
1207 else if ( block_gmres_iter->getCurSubspaceDim() == block_gmres_iter->getMaxSubspaceDim() ) {
1209 if ( numRestarts >= maxRestarts_ ) {
1210 isConverged =
false;
1215 printer_->stream(
Debug) <<
" Performing restart number " << numRestarts <<
" of " << maxRestarts_ << std::endl << std::endl;
1219 problem_->updateSolution( update,
true );
1227 problem_->computeCurrPrecResVec( &*V_0 );
1234 int rank = ortho_->normalize( *V_0, z_0 );
1236 "Belos::GmresPolySolMgr::solve(): Failed to compute initial block of orthonormal vectors after restart.");
1243 block_gmres_iter->initializeGmres(newstate);
1256 "Belos::GmresPolySolMgr::solve(): Invalid return from BlockGmresIter::iterate().");
1261 if (blockSize_ != 1) {
1262 printer_->stream(
Errors) <<
"Error! Caught std::exception in BlockGmresIter::iterate() at iteration "
1263 << block_gmres_iter->getNumIters() << std::endl
1264 << e.what() << std::endl;
1265 if (convTest_->getStatus() !=
Passed)
1266 isConverged =
false;
1271 block_gmres_iter->updateLSQR( block_gmres_iter->getCurSubspaceDim() );
1274 sTest_->checkStatus( &*block_gmres_iter );
1275 if (convTest_->getStatus() !=
Passed)
1276 isConverged =
false;
1280 catch (
const std::exception &e) {
1281 printer_->stream(
Errors) <<
"Error! Caught std::exception in BlockGmresIter::iterate() at iteration "
1282 << block_gmres_iter->getNumIters() << std::endl
1283 << e.what() << std::endl;
1294 MVT::MvAddMv( 0.0, *newX, 1.0, *newX, *curX );
1298 problem_->updateSolution( update,
true );
1302 problem_->setCurrLS();
1305 startPtr += numCurrRHS;
1306 numRHS2Solve -= numCurrRHS;
1307 if ( numRHS2Solve > 0 ) {
1308 numCurrRHS = ( numRHS2Solve < blockSize_) ? numRHS2Solve : blockSize_;
1310 currIdx.resize( blockSize_ );
1311 for (
int i=0; i<numCurrRHS; ++i)
1312 { currIdx[i] = startPtr+i; }
1313 for (
int i=numCurrRHS; i<blockSize_; ++i)
1314 { currIdx[i] = -1; }
1317 problem_->setLSIndex( currIdx );
1320 currIdx.resize( numRHS2Solve );
1332 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1340 if (!isConverged || loaDetected_) {
1347 template<
class ScalarType,
class MV,
class OP>
1350 std::ostringstream oss;
1353 oss <<
"Ortho Type='"<<orthoType_<<
"\', Block Size=" <<blockSize_;
1354 oss <<
", Num Blocks=" <<numBlocks_<<
", Max Restarts=" << maxRestarts_;
ScaleType convertStringToScaleType(const std::string &scaleType)
Convert the given string to its ScaleType enum value.
std::string description() const
Method to return description of the hybrid block GMRES solver manager.
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...
bool isLOADetected() const
Return whether a loss of accuracy was detected by this solver during the most current solve...
Class which manages the output and verbosity of the Belos solvers.
bool is_null(const boost::shared_ptr< T > &p)
virtual ~GmresPolySolMgr()
Destructor.
Defines the GMRES polynomial operator hybrid-GMRES iterative linear solver.
ScaleType
The type of scaling to use on the residual norm value.
This class implements the block GMRES iteration, where a block Krylov subspace is constructed...
Convergence test using the implicit residual norm(s), with an explicit residual norm(s) check for los...
Teuchos::RCP< const MV > V
The current Krylov basis.
T & get(const std::string &name, T def_value)
ParameterList & set(std::string const &name, T const &value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
Teuchos::Array< Teuchos::RCP< Teuchos::Time > > getTimers() const
Return the timers for this object.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
void setProblem(const Teuchos::RCP< LinearProblem< ScalarType, MV, OP > > &problem)
Set the linear problem that needs to be solved.
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.
static std::string name()
A factory class for generating StatusTestOutput objects.
Iterated Modified Gram-Schmidt (IMGS) implementation of the Belos::OrthoManager class.
void reset(const ResetType type)
Performs a reset of the solver manager specified by the ResetType. This informs the solver manager th...
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="")
Traits class which defines basic operations on multivectors.
Belos::StatusTest for logically combining several status tests.
bool isParameter(const std::string &name) const
Classical Gram-Schmidt (with DGKS correction) implementation of the Belos::OrthoManager class...
A Belos::StatusTest class for specifying a maximum number of iterations.
ResetType
How to reset the solver.
GmresPolySolMgrLinearProblemFailure is thrown when the linear problem is not setup (i...
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. ...
int curDim
The current dimension of the reduction.
Teuchos::RCP< const Teuchos::ParameterList > getCurrentParameters() const
Get a parameter list containing the current parameters for this object.
A linear system to solve, and its associated information.
Class which describes the linear problem to be solved by the iterative solver.
void setParameters(const Teuchos::RCP< Teuchos::ParameterList > ¶ms)
Set the parameters the solver manager should use to solve the linear problem.
The Belos::GmresPolySolMgr provides a powerful and fully-featured solver manager over the hybrid bloc...
ReturnType
Whether the Belos solve converged for all linear systems.
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const
Get a parameter list containing the valid parameters for this object.
The Belos::SolverManager is a templated virtual base class that defines the basic interface that any ...
ReturnType solve()
This method performs possibly repeated calls to the underlying linear solver's iterate() routine unti...
Belos's class for applying the GMRES polynomial operator that is used by the hybrid-GMRES linear solv...
Belos concrete class for performing the block GMRES iteration.
Iterated Classical Gram-Schmidt (ICGS) implementation of the Belos::OrthoManager class.
void validateParameters(ParameterList const &validParamList, int const depth=1000, EValidateUsed const validateUsed=VALIDATE_USED_ENABLED, EValidateDefaults const validateDefaults=VALIDATE_DEFAULTS_ENABLED) const
An implementation of the Belos::MatOrthoManager that performs orthogonalization using multiple steps ...
An implementation of the Belos::MatOrthoManager that performs orthogonalization using multiple steps ...
GmresPolySolMgrPolynomialFailure is thrown when their is a problem generating the GMRES polynomial fo...
GmresPolySolMgrPolynomialFailure(const std::string &what_arg)
Belos::StatusTestResNorm for specifying general residual norm stopping criteria.
Belos::StatusTest for specifying an implicit residual norm stopping criteria that checks for loss of ...
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.
void TRSM(ESide side, EUplo uplo, ETransp transa, EDiag diag, const OrdinalType m, const OrdinalType n, const alpha_type alpha, const A_type *A, const OrdinalType lda, ScalarType *B, const OrdinalType ldb) const
Class which defines basic traits for the operator type.
const LinearProblem< ScalarType, MV, OP > & getProblem() const
Get current linear problem being solved for in this object.
Parent class to all Belos exceptions.
GmresPolySolMgr()
Empty constructor for GmresPolySolMgr. This constructor takes no arguments and sets the default value...
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...
int getNumIters() const
Get the iteration count for the most recent call to solve().
GmresPolySolMgrOrthoFailure is thrown when the orthogonalization manager is unable to generate orthon...
GmresPolySolMgrOrthoFailure(const std::string &what_arg)
GmresPolySolMgrLinearProblemFailure(const std::string &what_arg)