Belos Version of the Day
Loading...
Searching...
No Matches
BelosBlockGmresSolMgr.hpp
Go to the documentation of this file.
1// @HEADER
2// *****************************************************************************
3// Belos: Block Linear Solvers Package
4//
5// Copyright 2004-2016 NTESS and the Belos contributors.
6// SPDX-License-Identifier: BSD-3-Clause
7// *****************************************************************************
8// @HEADER
9
10#ifndef BELOS_BLOCK_GMRES_SOLMGR_HPP
11#define BELOS_BLOCK_GMRES_SOLMGR_HPP
12
17#include "BelosConfigDefs.hpp"
18#include "BelosTypes.hpp"
19
25
37#ifdef BELOS_TEUCHOS_TIME_MONITOR
38#include "Teuchos_TimeMonitor.hpp"
39#endif
40
57namespace Belos {
58
60
61
71
81
98template<class ScalarType, class MV, class OP, class DM = DefaultDenseMatrix<int, ScalarType>>
99class BlockGmresSolMgr : public SolverManager<ScalarType,MV,OP,DM> {
100
101private:
105 typedef Teuchos::ScalarTraits<ScalarType> SCT;
106 typedef typename Teuchos::ScalarTraits<ScalarType>::magnitudeType MagnitudeType;
107 typedef Teuchos::ScalarTraits<MagnitudeType> MT;
108
109public:
110
112
113
120
142 const Teuchos::RCP<Teuchos::ParameterList> &pl );
143
145 virtual ~BlockGmresSolMgr() {};
146
148 Teuchos::RCP<SolverManager<ScalarType, MV, OP, DM> > clone () const override {
149 return Teuchos::rcp(new BlockGmresSolMgr<ScalarType,MV,OP,DM>);
150 }
152
154
155
159 return *problem_;
160 }
161
164 Teuchos::RCP<const Teuchos::ParameterList> getValidParameters() const override;
165
168 Teuchos::RCP<const Teuchos::ParameterList> getCurrentParameters() const override { return params_; }
169
175 Teuchos::Array<Teuchos::RCP<Teuchos::Time> > getTimers() const {
176 return Teuchos::tuple(timerSolve_);
177 }
178
189 MagnitudeType achievedTol() const override {
190 return achievedTol_;
191 }
192
194 int getNumIters() const override {
195 return numIters_;
196 }
197
201 bool isLOADetected() const override { return loaDetected_; }
202
204
206
207
209 void setProblem( const Teuchos::RCP<LinearProblem<ScalarType,MV,OP,DM> > &problem ) override { problem_ = problem; isSTSet_ = false; needsIterRebuild_ = true; }
210
212 void setParameters( const Teuchos::RCP<Teuchos::ParameterList> &params ) override;
213
215 void setDebugStatusTest( const Teuchos::RCP<StatusTest<ScalarType,MV,OP,DM> > &debugStatusTest ) override;
216
218
220
221
225 void reset( const ResetType type ) override { if ((type & Belos::Problem) && !Teuchos::is_null(problem_)) problem_->setProblem(); }
227
229
230
248 ReturnType solve() override;
249
251
254
261 void
262 describe (Teuchos::FancyOStream& out,
263 const Teuchos::EVerbosityLevel verbLevel =
264 Teuchos::Describable::verbLevel_default) const override;
265
267 std::string description () const override;
268
270
271private:
272
273 // Method for checking current status test against defined linear problem.
274 bool checkStatusTest();
275
276 // Linear problem.
277 Teuchos::RCP<LinearProblem<ScalarType,MV,OP,DM> > problem_;
278
279 // Output manager.
280 Teuchos::RCP<OutputManager<ScalarType> > printer_;
281 Teuchos::RCP<std::ostream> outputStream_;
282
283 // Status test.
284 Teuchos::RCP<StatusTest<ScalarType,MV,OP,DM> > debugStatusTest_;
285 Teuchos::RCP<StatusTest<ScalarType,MV,OP,DM> > sTest_;
286 Teuchos::RCP<StatusTestMaxIters<ScalarType,MV,OP,DM> > maxIterTest_;
287 Teuchos::RCP<StatusTest<ScalarType,MV,OP,DM> > convTest_;
288 Teuchos::RCP<StatusTestResNorm<ScalarType,MV,OP,DM> > expConvTest_, impConvTest_;
289 Teuchos::RCP<StatusTestOutput<ScalarType,MV,OP,DM> > outputTest_;
290
291 // Orthogonalization manager.
292 Teuchos::RCP<MatOrthoManager<ScalarType,MV,OP,DM> > ortho_;
293
294 // Current parameter list.
295 Teuchos::RCP<Teuchos::ParameterList> params_;
296
297 // Default solver values.
298 static constexpr int maxRestarts_default_ = 20;
299 static constexpr int maxIters_default_ = 1000;
300 static constexpr bool adaptiveBlockSize_default_ = true;
301 static constexpr bool showMaxResNormOnly_default_ = false;
302 static constexpr bool flexibleGmres_default_ = false;
303 static constexpr bool keepHessenberg_default_ = false;
304 static constexpr bool expResTest_default_ = false;
305 static constexpr int blockSize_default_ = 1;
306 static constexpr int numBlocks_default_ = 300;
307 static constexpr int verbosity_default_ = Belos::Errors;
308 static constexpr int outputStyle_default_ = Belos::General;
309 static constexpr int outputFreq_default_ = -1;
310 static constexpr const char * impResScale_default_ = "Norm of Preconditioned Initial Residual";
311 static constexpr const char * expResScale_default_ = "Norm of Initial Residual";
312 static constexpr const char * label_default_ = "Belos";
313 static constexpr const char * orthoType_default_ = "ICGS";
314
315 // Current solver values.
316 MagnitudeType convtol_, orthoKappa_, achievedTol_;
317 int maxRestarts_, maxIters_, numIters_;
318 int blockSize_, numBlocks_, verbosity_, outputStyle_, outputFreq_;
319 bool adaptiveBlockSize_, showMaxResNormOnly_, isFlexible_, keepHessenberg_, expResTest_;
320 std::string orthoType_;
321 std::string impResScale_, expResScale_;
322
323 // Timers.
324 std::string label_;
325 Teuchos::RCP<Teuchos::Time> timerSolve_;
326
327 // Cached iterator (reused across solve() calls to avoid reallocating Krylov subspace).
328 Teuchos::RCP<GmresIteration<ScalarType,MV,OP,DM> > block_gmres_iter_;
329
330 // Internal state variables.
331 bool isSet_, isSTSet_;
332 bool needsIterRebuild_;
333 bool loaDetected_;
334};
335
336
337// Empty Constructor
338template<class ScalarType, class MV, class OP, class DM>
340 outputStream_(Teuchos::rcpFromRef(std::cout)),
341 convtol_(DefaultSolverParameters::convTol),
342 orthoKappa_(DefaultSolverParameters::orthoKappa),
343 achievedTol_(Teuchos::ScalarTraits<typename Teuchos::ScalarTraits<ScalarType>::magnitudeType>::zero()),
344 maxRestarts_(maxRestarts_default_),
345 maxIters_(maxIters_default_),
346 numIters_(0),
347 blockSize_(blockSize_default_),
348 numBlocks_(numBlocks_default_),
349 verbosity_(verbosity_default_),
350 outputStyle_(outputStyle_default_),
351 outputFreq_(outputFreq_default_),
352 adaptiveBlockSize_(adaptiveBlockSize_default_),
353 showMaxResNormOnly_(showMaxResNormOnly_default_),
354 isFlexible_(flexibleGmres_default_),
355 keepHessenberg_(keepHessenberg_default_),
356 expResTest_(expResTest_default_),
357 orthoType_(orthoType_default_),
358 impResScale_(impResScale_default_),
359 expResScale_(expResScale_default_),
360 label_(label_default_),
361 isSet_(false),
362 isSTSet_(false),
363 needsIterRebuild_(true),
364 loaDetected_(false)
365{}
366
367
368// Basic Constructor
369template<class ScalarType, class MV, class OP, class DM>
372 const Teuchos::RCP<Teuchos::ParameterList> &pl) :
373 problem_(problem),
374 outputStream_(Teuchos::rcpFromRef(std::cout)),
375 convtol_(DefaultSolverParameters::convTol),
376 orthoKappa_(DefaultSolverParameters::orthoKappa),
377 achievedTol_(Teuchos::ScalarTraits<typename Teuchos::ScalarTraits<ScalarType>::magnitudeType>::zero()),
378 maxRestarts_(maxRestarts_default_),
379 maxIters_(maxIters_default_),
380 numIters_(0),
381 blockSize_(blockSize_default_),
382 numBlocks_(numBlocks_default_),
383 verbosity_(verbosity_default_),
384 outputStyle_(outputStyle_default_),
385 outputFreq_(outputFreq_default_),
386 adaptiveBlockSize_(adaptiveBlockSize_default_),
387 showMaxResNormOnly_(showMaxResNormOnly_default_),
388 isFlexible_(flexibleGmres_default_),
389 keepHessenberg_(keepHessenberg_default_),
390 expResTest_(expResTest_default_),
391 orthoType_(orthoType_default_),
392 impResScale_(impResScale_default_),
393 expResScale_(expResScale_default_),
394 label_(label_default_),
395 isSet_(false),
396 isSTSet_(false),
397 needsIterRebuild_(true),
398 loaDetected_(false)
399{
400
401 TEUCHOS_TEST_FOR_EXCEPTION(problem_ == Teuchos::null, std::invalid_argument, "Problem not given to solver manager.");
402
403 // If the parameter list pointer is null, then set the current parameters to the default parameter list.
404 if ( !is_null(pl) ) {
405 setParameters( pl );
406 }
407
408}
409
410
411template<class ScalarType, class MV, class OP, class DM>
412Teuchos::RCP<const Teuchos::ParameterList>
414{
415 static Teuchos::RCP<const Teuchos::ParameterList> validPL;
416 if (is_null(validPL)) {
417 Teuchos::RCP<Teuchos::ParameterList> pl = Teuchos::parameterList();
418
419 // The static_cast is to resolve an issue with older clang versions which
420 // would cause the constexpr to link fail. With c++17 the problem is resolved.
421 pl->set("Convergence Tolerance", static_cast<MagnitudeType>(DefaultSolverParameters::convTol),
422 "The relative residual tolerance that needs to be achieved by the\n"
423 "iterative solver in order for the linear system to be declared converged." );
424 pl->set("Maximum Restarts", static_cast<int>(maxRestarts_default_),
425 "The maximum number of restarts allowed for each\n"
426 "set of RHS solved.");
427 pl->set("Maximum Iterations", static_cast<int>(maxIters_default_),
428 "The maximum number of block iterations allowed for each\n"
429 "set of RHS solved.");
430 pl->set("Num Blocks", static_cast<int>(numBlocks_default_),
431 "The maximum number of blocks allowed in the Krylov subspace\n"
432 "for each set of RHS solved.");
433 pl->set("Block Size", static_cast<int>(blockSize_default_),
434 "The number of vectors in each block. This number times the\n"
435 "number of blocks is the total Krylov subspace dimension.");
436 pl->set("Adaptive Block Size", static_cast<bool>(adaptiveBlockSize_default_),
437 "Whether the solver manager should adapt the block size\n"
438 "based on the number of RHS to solve.");
439 pl->set("Verbosity", static_cast<int>(verbosity_default_),
440 "What type(s) of solver information should be outputted\n"
441 "to the output stream.");
442 pl->set("Output Style", static_cast<int>(outputStyle_default_),
443 "What style is used for the solver information outputted\n"
444 "to the output stream.");
445 pl->set("Output Frequency", static_cast<int>(outputFreq_default_),
446 "How often convergence information should be outputted\n"
447 "to the output stream.");
448 pl->set("Output Stream", Teuchos::rcpFromRef(std::cout),
449 "A reference-counted pointer to the output stream where all\n"
450 "solver output is sent.");
451 pl->set("Show Maximum Residual Norm Only", static_cast<bool>(showMaxResNormOnly_default_),
452 "When convergence information is printed, only show the maximum\n"
453 "relative residual norm when the block size is greater than one.");
454 pl->set("Flexible Gmres", static_cast<bool>(flexibleGmres_default_),
455 "Whether the solver manager should use the flexible variant\n"
456 "of GMRES.");
457 pl->set("Keep Hessenberg", static_cast<bool>(keepHessenberg_default_),
458 "Whether the raw upper Hessenberg matrix should be stored separately\n"
459 "from the QR-factored least squares system. Useful for harmonic Ritz\n"
460 "pair computation from the GMRES iteration state.");
461 pl->set("Explicit Residual Test", static_cast<bool>(expResTest_default_),
462 "Whether the explicitly computed residual should be used in the convergence test.");
463 pl->set("Implicit Residual Scaling", static_cast<const char *>(impResScale_default_),
464 "The type of scaling used in the implicit residual convergence test.");
465 pl->set("Explicit Residual Scaling", static_cast<const char *>(expResScale_default_),
466 "The type of scaling used in the explicit residual convergence test.");
467 pl->set("Timer Label", static_cast<const char *>(label_default_),
468 "The string to use as a prefix for the timer labels.");
469 pl->set("Orthogonalization", static_cast<const char *>(orthoType_default_),
470 "The type of orthogonalization to use: DGKS, ICGS, or IMGS.");
471 pl->set("Orthogonalization Constant",static_cast<MagnitudeType>(DefaultSolverParameters::orthoKappa),
472 "The constant used by DGKS orthogonalization to determine\n"
473 "whether another step of classical Gram-Schmidt is necessary.");
474 validPL = pl;
475 }
476 return validPL;
477}
478
479
480template<class ScalarType, class MV, class OP, class DM>
481void BlockGmresSolMgr<ScalarType,MV,OP,DM>::setParameters( const Teuchos::RCP<Teuchos::ParameterList> &params )
482{
483
484 // Create the internal parameter list if ones doesn't already exist.
485 if (params_ == Teuchos::null) {
486 params_ = Teuchos::rcp( new Teuchos::ParameterList(*getValidParameters()) );
487 }
488 else {
489 params->validateParameters(*getValidParameters());
490 }
491
492 // Check for maximum number of restarts
493 if (params->isParameter("Maximum Restarts")) {
494 maxRestarts_ = params->get("Maximum Restarts",maxRestarts_default_);
495
496 // Update parameter in our list.
497 params_->set("Maximum Restarts", maxRestarts_);
498 }
499
500 // Check for maximum number of iterations
501 if (params->isParameter("Maximum Iterations")) {
502 maxIters_ = params->get("Maximum Iterations",maxIters_default_);
503
504 // Update parameter in our list and in status test.
505 params_->set("Maximum Iterations", maxIters_);
506 if (maxIterTest_!=Teuchos::null)
507 maxIterTest_->setMaxIters( maxIters_ );
508 }
509
510 // Check for blocksize
511 if (params->isParameter("Block Size")) {
512 blockSize_ = params->get("Block Size",blockSize_default_);
513 TEUCHOS_TEST_FOR_EXCEPTION(blockSize_ <= 0, std::invalid_argument,
514 "Belos::BlockGmresSolMgr: \"Block Size\" must be strictly positive.");
515
516 // Update parameter in our list.
517 params_->set("Block Size", blockSize_);
518 }
519
520 // Check if the blocksize should be adaptive
521 if (params->isParameter("Adaptive Block Size")) {
522 adaptiveBlockSize_ = params->get("Adaptive Block Size",adaptiveBlockSize_default_);
523
524 // Update parameter in our list.
525 params_->set("Adaptive Block Size", adaptiveBlockSize_);
526 }
527
528 // Check for the maximum number of blocks.
529 if (params->isParameter("Num Blocks")) {
530 numBlocks_ = params->get("Num Blocks",numBlocks_default_);
531 TEUCHOS_TEST_FOR_EXCEPTION(numBlocks_ <= 0, std::invalid_argument,
532 "Belos::BlockGmresSolMgr: \"Num Blocks\" must be strictly positive.");
533
534 // Update parameter in our list.
535 params_->set("Num Blocks", numBlocks_);
536 }
537
538 // Check to see if the timer label changed.
539 if (params->isParameter("Timer Label")) {
540 std::string tempLabel = params->get("Timer Label", label_default_);
541
542 // Update parameter in our list, solver timer, and orthogonalization label
543 if (tempLabel != label_) {
544 label_ = tempLabel;
545 params_->set("Timer Label", label_);
546 std::string solveLabel = label_ + ": BlockGmresSolMgr total solve time";
547#ifdef BELOS_TEUCHOS_TIME_MONITOR
548 timerSolve_ = Teuchos::TimeMonitor::getNewCounter(solveLabel);
549#endif
550 if (ortho_ != Teuchos::null) {
551 ortho_->setLabel( label_ );
552 }
553 }
554 }
555
556 // Determine whether the raw Hessenberg should be stored separately from R.
557 if (params->isParameter("Keep Hessenberg")) {
558 keepHessenberg_ = Teuchos::getParameter<bool>(*params,"Keep Hessenberg");
559 params_->set("Keep Hessenberg", keepHessenberg_);
560 }
561
562 // Determine whether this solver should be "flexible".
563 if (params->isParameter("Flexible Gmres")) {
564 isFlexible_ = Teuchos::getParameter<bool>(*params,"Flexible Gmres");
565 params_->set("Flexible Gmres", isFlexible_);
566 if (isFlexible_ && expResTest_) {
567 // Use an implicit convergence test if the Gmres solver is flexible
568 isSTSet_ = false;
569 }
570 }
571
572 // Check for a change in verbosity level
573 if (params->isParameter("Verbosity")) {
574 if (Teuchos::isParameterType<int>(*params,"Verbosity")) {
575 verbosity_ = params->get("Verbosity", verbosity_default_);
576 } else {
577 verbosity_ = (int)Teuchos::getParameter<Belos::MsgType>(*params,"Verbosity");
578 }
579
580 // Update parameter in our list.
581 params_->set("Verbosity", verbosity_);
582 if (printer_ != Teuchos::null)
583 printer_->setVerbosity(verbosity_);
584 }
585
586 // Check for a change in output style
587 if (params->isParameter("Output Style")) {
588 if (Teuchos::isParameterType<int>(*params,"Output Style")) {
589 outputStyle_ = params->get("Output Style", outputStyle_default_);
590 } else {
591 outputStyle_ = (int)Teuchos::getParameter<Belos::OutputType>(*params,"Output Style");
592 }
593
594 // Reconstruct the convergence test if the explicit residual test is not being used.
595 params_->set("Output Style", outputStyle_);
596 if (outputTest_ != Teuchos::null) {
597 isSTSet_ = false;
598 }
599 }
600
601 // output stream
602 if (params->isParameter("Output Stream")) {
603 outputStream_ = Teuchos::getParameter<Teuchos::RCP<std::ostream> >(*params,"Output Stream");
604
605 // Update parameter in our list.
606 params_->set("Output Stream", outputStream_);
607 if (printer_ != Teuchos::null)
608 printer_->setOStream( outputStream_ );
609 }
610
611 // frequency level
612 if (verbosity_ & Belos::StatusTestDetails) {
613 if (params->isParameter("Output Frequency")) {
614 outputFreq_ = params->get("Output Frequency", outputFreq_default_);
615 }
616
617 // Update parameter in out list and output status test.
618 params_->set("Output Frequency", outputFreq_);
619 if (outputTest_ != Teuchos::null)
620 outputTest_->setOutputFrequency( outputFreq_ );
621 }
622
623 // Create output manager if we need to.
624 if (printer_ == Teuchos::null) {
625 printer_ = Teuchos::rcp( new OutputManager<ScalarType>(verbosity_, outputStream_) );
626 }
627
628 // Check if the orthogonalization changed.
629 bool changedOrthoType = false;
630 if (params->isParameter("Orthogonalization")) {
631 std::string tempOrthoType = params->get("Orthogonalization",orthoType_default_);
632 if (tempOrthoType != orthoType_) {
633 orthoType_ = tempOrthoType;
634 changedOrthoType = true;
635 }
636 }
637 params_->set("Orthogonalization", orthoType_);
638
639 // Check which orthogonalization constant to use.
640 if (params->isParameter("Orthogonalization Constant")) {
641 if (params->isType<MagnitudeType> ("Orthogonalization Constant")) {
642 orthoKappa_ = params->get ("Orthogonalization Constant",
643 static_cast<MagnitudeType> (DefaultSolverParameters::orthoKappa));
644 }
645 else {
646 orthoKappa_ = params->get ("Orthogonalization Constant",
648 }
649
650 // Update parameter in our list.
651 params_->set("Orthogonalization Constant",orthoKappa_);
652 if (orthoType_=="DGKS") {
653 if (orthoKappa_ > 0 && ortho_ != Teuchos::null && !changedOrthoType) {
654 Teuchos::rcp_dynamic_cast<DGKSOrthoManager<ScalarType,MV,OP,DM> >(ortho_)->setDepTol( orthoKappa_ );//TODO
655 }
656 }
657 }
658
659 // Create orthogonalization manager if we need to.
660 if (ortho_ == Teuchos::null || changedOrthoType) {
662 Teuchos::RCP<Teuchos::ParameterList> paramsOrtho;
663 if (orthoType_=="DGKS" && orthoKappa_ > 0) {
664 paramsOrtho = Teuchos::rcp(new Teuchos::ParameterList());
665 paramsOrtho->set ("depTol", orthoKappa_ );
666 }
667
668 ortho_ = factory.makeMatOrthoManager (orthoType_, Teuchos::null, printer_, label_, paramsOrtho);
669 }
670
671 // Check for convergence tolerance
672 if (params->isParameter("Convergence Tolerance")) {
673 if (params->isType<MagnitudeType> ("Convergence Tolerance")) {
674 convtol_ = params->get ("Convergence Tolerance",
675 static_cast<MagnitudeType> (DefaultSolverParameters::convTol));
676 }
677 else {
678 convtol_ = params->get ("Convergence Tolerance", DefaultSolverParameters::convTol);
679 }
680
681 // Update parameter in our list and residual tests.
682 params_->set("Convergence Tolerance", convtol_);
683 if (impConvTest_ != Teuchos::null)
684 impConvTest_->setTolerance( convtol_ );
685 if (expConvTest_ != Teuchos::null)
686 expConvTest_->setTolerance( convtol_ );
687 }
688
689 // Check for a change in scaling, if so we need to build new residual tests.
690 if (params->isParameter("Implicit Residual Scaling")) {
691 std::string tempImpResScale = Teuchos::getParameter<std::string>( *params, "Implicit Residual Scaling" );
692
693 // Only update the scaling if it's different.
694 if (impResScale_ != tempImpResScale) {
696 impResScale_ = tempImpResScale;
697
698 // Update parameter in our list and residual tests
699 params_->set("Implicit Residual Scaling", impResScale_);
700 if (impConvTest_ != Teuchos::null) {
701 try {
702 impConvTest_->defineScaleForm( impResScaleType, Belos::TwoNorm );
703 }
704 catch (std::exception& e) {
705 // Make sure the convergence test gets constructed again.
706 isSTSet_ = false;
707 }
708 }
709 }
710 }
711
712 if (params->isParameter("Explicit Residual Scaling")) {
713 std::string tempExpResScale = Teuchos::getParameter<std::string>( *params, "Explicit Residual Scaling" );
714
715 // Only update the scaling if it's different.
716 if (expResScale_ != tempExpResScale) {
718 expResScale_ = tempExpResScale;
719
720 // Update parameter in our list and residual tests
721 params_->set("Explicit Residual Scaling", expResScale_);
722 if (expConvTest_ != Teuchos::null) {
723 try {
724 expConvTest_->defineScaleForm( expResScaleType, Belos::TwoNorm );
725 }
726 catch (std::exception& e) {
727 // Make sure the convergence test gets constructed again.
728 isSTSet_ = false;
729 }
730 }
731 }
732 }
733
734 if (params->isParameter("Explicit Residual Test")) {
735 expResTest_ = Teuchos::getParameter<bool>( *params,"Explicit Residual Test" );
736
737 // Reconstruct the convergence test if the explicit residual test is not being used.
738 params_->set("Explicit Residual Test", expResTest_);
739 if (expConvTest_ == Teuchos::null) {
740 isSTSet_ = false;
741 }
742 }
743
744 if (params->isParameter("Show Maximum Residual Norm Only")) {
745 showMaxResNormOnly_ = Teuchos::getParameter<bool>(*params,"Show Maximum Residual Norm Only");
746
747 // Update parameter in our list and residual tests
748 params_->set("Show Maximum Residual Norm Only", showMaxResNormOnly_);
749 if (impConvTest_ != Teuchos::null)
750 impConvTest_->setShowMaxResNormOnly( showMaxResNormOnly_ );
751 if (expConvTest_ != Teuchos::null)
752 expConvTest_->setShowMaxResNormOnly( showMaxResNormOnly_ );
753 }
754
755
756 // Create the timer if we need to.
757 if (timerSolve_ == Teuchos::null) {
758 std::string solveLabel = label_ + ": BlockGmresSolMgr total solve time";
759#ifdef BELOS_TEUCHOS_TIME_MONITOR
760 timerSolve_ = Teuchos::TimeMonitor::getNewCounter(solveLabel);
761#endif
762 }
763
764 // Inform the solver manager that the current parameters were set.
765 // The cached iterator must be rebuilt since printer_, outputTest_, and ortho_ may have changed.
766 needsIterRebuild_ = true;
767 isSet_ = true;
768}
769
770// Check the status test versus the defined linear problem
771template<class ScalarType, class MV, class OP, class DM>
773
774 typedef Belos::StatusTestCombo<ScalarType,MV,OP,DM> StatusTestCombo_t;
777
778 // Basic test checks maximum iterations and native residual.
779 maxIterTest_ = Teuchos::rcp( new StatusTestMaxIters<ScalarType,MV,OP,DM>( maxIters_ ) );
780
781 // Perform sanity checking for flexible Gmres here.
782 // NOTE: If the user requests that the solver manager use flexible GMRES, but there is no right preconditioner, don't use flexible GMRES.
783 // Throw an error is the user provided a left preconditioner, as that is inconsistent with flexible GMRES.
784 if (isFlexible_ && Teuchos::is_null(problem_->getRightPrec())) {
785 isFlexible_ = false;
786 params_->set("Flexible Gmres", isFlexible_);
787
788 // If the user specified the preconditioner as a left preconditioner, throw an error.
789 TEUCHOS_TEST_FOR_EXCEPTION( !Teuchos::is_null(problem_->getLeftPrec()),BlockGmresSolMgrLinearProblemFailure,
790 "Belos::BlockGmresSolMgr::solve(): Linear problem has a left preconditioner, not a right preconditioner, which is required for flexible GMRES.");
791 }
792
793 // If there is a left preconditioner, we create a combined status test that checks the implicit
794 // and then explicit residual norm to see if we have convergence.
795 if (!Teuchos::is_null(problem_->getLeftPrec()) && !isFlexible_) {
796 expResTest_ = true;
797 }
798
799 if (expResTest_) {
800
801 // Implicit residual test, using the native residual to determine if convergence was achieved.
802 Teuchos::RCP<StatusTestGenResNorm_t> tmpImpConvTest =
803 Teuchos::rcp( new StatusTestGenResNorm_t( convtol_ ) );
804 tmpImpConvTest->defineScaleForm( convertStringToScaleType(impResScale_), Belos::TwoNorm );
805 tmpImpConvTest->setShowMaxResNormOnly( showMaxResNormOnly_ );
806 impConvTest_ = tmpImpConvTest;
807
808 // Explicit residual test once the native residual is below the tolerance
809 Teuchos::RCP<StatusTestGenResNorm_t> tmpExpConvTest =
810 Teuchos::rcp( new StatusTestGenResNorm_t( convtol_ ) );
811 tmpExpConvTest->defineResForm( StatusTestGenResNorm_t::Explicit, Belos::TwoNorm );
812 tmpExpConvTest->defineScaleForm( convertStringToScaleType(expResScale_), Belos::TwoNorm );
813 tmpExpConvTest->setShowMaxResNormOnly( showMaxResNormOnly_ );
814 expConvTest_ = tmpExpConvTest;
815
816 // The convergence test is a combination of the "cheap" implicit test and explicit test.
817 convTest_ = Teuchos::rcp( new StatusTestCombo_t( StatusTestCombo_t::SEQ, impConvTest_, expConvTest_ ) );
818 }
819 else {
820
821 if (isFlexible_) {
822 // Implicit residual test, using the native residual to determine if convergence was achieved.
823 Teuchos::RCP<StatusTestGenResNorm_t> tmpImpConvTest =
824 Teuchos::rcp( new StatusTestGenResNorm_t( convtol_ ) );
825 tmpImpConvTest->defineScaleForm( convertStringToScaleType(impResScale_), Belos::TwoNorm );
826 tmpImpConvTest->setShowMaxResNormOnly( showMaxResNormOnly_ );
827 impConvTest_ = tmpImpConvTest;
828 }
829 else {
830 // Implicit residual test, using the native residual to determine if convergence was achieved.
831 // Use test that checks for loss of accuracy.
832 Teuchos::RCP<StatusTestImpResNorm_t> tmpImpConvTest =
833 Teuchos::rcp( new StatusTestImpResNorm_t( convtol_ ) );
834 tmpImpConvTest->defineScaleForm( convertStringToScaleType(impResScale_), Belos::TwoNorm );
835 tmpImpConvTest->setShowMaxResNormOnly( showMaxResNormOnly_ );
836 impConvTest_ = tmpImpConvTest;
837 }
838
839 // Set the explicit and total convergence test to this implicit test that checks for accuracy loss.
840 expConvTest_ = impConvTest_;
841 convTest_ = impConvTest_;
842 }
843
844 // Create the status test.
845 sTest_ = Teuchos::rcp( new StatusTestCombo_t( StatusTestCombo_t::OR, maxIterTest_, convTest_ ) );
846
847 // Add debug status test, if one is provided by the user
848 if (nonnull(debugStatusTest_) ) {
849 // Add debug convergence test
850 Teuchos::rcp_dynamic_cast<StatusTestCombo_t>(sTest_)->addStatusTest( debugStatusTest_ );
851 }
852
853 // Create the status test output class.
854 // This class manages and formats the output from the status test.
856 outputTest_ = stoFactory.create( printer_, sTest_, outputFreq_, Passed+Failed+Undefined );
857
858 // Set the solver string for the output test
859 std::string solverDesc = " Block Gmres ";
860 if (isFlexible_)
861 solverDesc = "Flexible" + solverDesc;
862 outputTest_->setSolverDesc( solverDesc );
863
864 // The status test is now set.
865 isSTSet_ = true;
866
867 return false;
868}
869
870template<class ScalarType, class MV, class OP, class DM>
877
878
879// solve()
880template<class ScalarType, class MV, class OP, class DM>
883
884 // Set the current parameters if they were not set before.
885 // NOTE: This may occur if the user generated the solver manager with the default constructor and
886 // then didn't set any parameters using setParameters().
887 if (!isSet_) {
888 setParameters(Teuchos::parameterList(*getValidParameters()));
889 }
890
892 "Belos::BlockGmresSolMgr::solve(): Linear problem is not a valid object.");
893
895 "Belos::BlockGmresSolMgr::solve(): Linear problem is not ready, setProblem() has not been called.");
896
897 if (!isSTSet_ || (!expResTest_ && !Teuchos::is_null(problem_->getLeftPrec())) ) {
899 "Belos::BlockGmresSolMgr::solve(): Linear problem and requested status tests are incompatible.");
900 }
901
902 // Create indices for the linear systems to be solved.
903 int startPtr = 0;
904 int numRHS2Solve = MVT::GetNumberVecs( *(problem_->getRHS()) );
905 int numCurrRHS = ( numRHS2Solve < blockSize_) ? numRHS2Solve : blockSize_;
906
907 std::vector<int> currIdx;
908 // If an adaptive block size is allowed then only the linear systems that need to be solved are solved.
909 // Otherwise, the index set is generated that informs the linear problem that some linear systems are augmented.
910 if ( adaptiveBlockSize_ ) {
911 blockSize_ = numCurrRHS;
912 currIdx.resize( numCurrRHS );
913 for (int i=0; i<numCurrRHS; ++i)
914 { currIdx[i] = startPtr+i; }
915
916 }
917 else {
918 currIdx.resize( blockSize_ );
919 for (int i=0; i<numCurrRHS; ++i)
920 { currIdx[i] = startPtr+i; }
921 for (int i=numCurrRHS; i<blockSize_; ++i)
922 { currIdx[i] = -1; }
923 }
924
925 // Inform the linear problem of the current linear system to solve.
926 problem_->setLSIndex( currIdx );
927
929 // Parameter list
930 Teuchos::ParameterList plist;
931 plist.set("Block Size",blockSize_);
932 plist.set("Keep Hessenberg",keepHessenberg_);
933
934 ptrdiff_t dim = MVT::GetGlobalLength( *(problem_->getRHS()) );
935 if (blockSize_*static_cast<ptrdiff_t>(numBlocks_) > dim) {
936 int tmpNumBlocks = 0;
937 if (blockSize_ == 1)
938 tmpNumBlocks = dim / blockSize_; // Allow for a good breakdown.
939 else
940 tmpNumBlocks = ( dim - blockSize_) / blockSize_; // Allow for restarting.
941 printer_->stream(Warnings) <<
942 "Belos::BlockGmresSolMgr::solve(): Warning! Requested Krylov subspace dimension is larger than operator dimension!"
943 << std::endl << " The maximum number of blocks allowed for the Krylov subspace will be adjusted to " << tmpNumBlocks << std::endl;
944 plist.set("Num Blocks",tmpNumBlocks);
945 }
946 else
947 plist.set("Num Blocks",numBlocks_);
948
949 // Reset the status test.
950 outputTest_->reset();
951 loaDetected_ = false;
952
953 // Assume convergence is achieved, then let any failed convergence set this to false.
954 bool isConverged = true;
955
957 // BlockGmres solver
958
959 if (needsIterRebuild_) {
960 if (isFlexible_)
961 block_gmres_iter_ = Teuchos::rcp( new BlockFGmresIter<ScalarType,MV,OP,DM>(problem_,printer_,outputTest_,ortho_,plist) );
962 else
963 block_gmres_iter_ = Teuchos::rcp( new BlockGmresIter<ScalarType,MV,OP,DM>(problem_,printer_,outputTest_,ortho_,plist) );
964 needsIterRebuild_ = false;
965 }
966 Teuchos::RCP<GmresIteration<ScalarType,MV,OP,DM> > &block_gmres_iter = block_gmres_iter_;
967
968 // Enter solve() iterations
969 {
970#ifdef BELOS_TEUCHOS_TIME_MONITOR
971 Teuchos::TimeMonitor slvtimer(*timerSolve_);
972#endif
973
974 while ( numRHS2Solve > 0 ) {
975
976 // Set the current number of blocks and blocksize with the Gmres iteration.
977 if (blockSize_*numBlocks_ > dim) {
978 int tmpNumBlocks = 0;
979 if (blockSize_ == 1)
980 tmpNumBlocks = dim / blockSize_; // Allow for a good breakdown.
981 else
982 tmpNumBlocks = ( dim - blockSize_) / blockSize_; // Allow for restarting.
983 block_gmres_iter->setSize( blockSize_, tmpNumBlocks );
984 }
985 else
986 block_gmres_iter->setSize( blockSize_, numBlocks_ );
987
988 // Reset the number of iterations.
989 block_gmres_iter->resetNumIters();
990
991 // Reset the number of calls that the status test output knows about.
992 outputTest_->resetNumCalls();
993
994 // Create the first block in the current Krylov basis.
995 Teuchos::RCP<MV> V_0;
996 if (isFlexible_) {
997 // Load the correct residual if the system is augmented
998 if (currIdx[blockSize_-1] == -1) {
999 V_0 = MVT::Clone( *(problem_->getInitResVec()), blockSize_ );
1000 problem_->computeCurrResVec( &*V_0 );
1001 }
1002 else {
1003 V_0 = MVT::CloneCopy( *(problem_->getInitResVec()), currIdx );
1004 }
1005 }
1006 else {
1007 // Load the correct residual if the system is augmented
1008 if (currIdx[blockSize_-1] == -1) {
1009 V_0 = MVT::Clone( *(problem_->getInitPrecResVec()), blockSize_ );
1010 problem_->computeCurrPrecResVec( &*V_0 );
1011 }
1012 else {
1013 V_0 = MVT::CloneCopy( *(problem_->getInitPrecResVec()), currIdx );
1014 }
1015 }
1016
1017 // Get a matrix to hold the orthonormalization coefficients.
1018 Teuchos::RCP<DM> z_0 = DMT::Create(blockSize_, blockSize_);
1019
1020 // Orthonormalize the new V_0
1021 int rank = ortho_->normalize( *V_0, z_0 );
1023 "Belos::BlockGmresSolMgr::solve(): Failed to compute initial block of orthonormal vectors.");
1024
1025 // Set the new state and initialize the solver.
1027 newstate.V = V_0;
1028 newstate.z = z_0;
1029 newstate.curDim = 0;
1030 block_gmres_iter->initializeGmres(newstate);
1031 int numRestarts = 0;
1032
1033 while(1) {
1034 // tell block_gmres_iter to iterate
1035 try {
1036 block_gmres_iter->iterate();
1037
1039 //
1040 // check convergence first
1041 //
1043 if ( convTest_->getStatus() == Passed ) {
1044 if ( expConvTest_->getLOADetected() ) {
1045 // we don't have convergence
1047 loaDetected_ = true;
1048 printer_->stream(Warnings) <<
1049 "Belos::BlockGmresSolMgr::solve(): Warning! Solver has experienced a loss of accuracy!" << std::endl;
1050 isConverged = false;
1051 }
1052 break; // break from while(1){block_gmres_iter->iterate()}
1053 }
1055 //
1056 // check for maximum iterations
1057 //
1059 else if ( maxIterTest_->getStatus() == Passed ) {
1060 // we don't have convergence
1062 isConverged = false;
1063 break; // break from while(1){block_gmres_iter->iterate()}
1064 }
1066 //
1067 // check for restarting, i.e. the subspace is full
1068 //
1070 else if ( block_gmres_iter->getCurSubspaceDim() == block_gmres_iter->getMaxSubspaceDim() ) {
1071
1072 if ( numRestarts >= maxRestarts_ ) {
1074 isConverged = false;
1075 break; // break from while(1){block_gmres_iter->iterate()}
1076 }
1077 numRestarts++;
1078
1079 printer_->stream(Debug) << " Performing restart number " << numRestarts << " of " << maxRestarts_ << std::endl << std::endl;
1080
1081 // Update the linear problem.
1082 Teuchos::RCP<MV> update = block_gmres_iter->getCurrentUpdate();
1083 if (isFlexible_) {
1084 // Update the solution manually, since the preconditioning doesn't need to be undone.
1085 Teuchos::RCP<MV> curX = problem_->getCurrLHSVec();
1086 MVT::MvAddMv( 1.0, *curX, 1.0, *update, *curX );
1087 }
1088 else
1089 problem_->updateSolution( update, true );
1090
1091 // Get the state.
1093
1094 // Compute the restart std::vector.
1095 // Get a view of the current Krylov basis.
1096 V_0 = MVT::Clone( *(oldState.V), blockSize_ );
1097 if (isFlexible_)
1098 problem_->computeCurrResVec( &*V_0 );
1099 else
1100 problem_->computeCurrPrecResVec( &*V_0 );
1101
1102 // Get a view of the first block of the Krylov basis.
1103 z_0 = DMT::Create(blockSize_, blockSize_);
1104
1105 // Orthonormalize the new V_0
1106 rank = ortho_->normalize( *V_0, z_0 );
1108 "Belos::BlockGmresSolMgr::solve(): Failed to compute initial block of orthonormal vectors after restart.");
1109
1110 // Set the new state and initialize the solver.
1111 newstate.V = V_0;
1112 newstate.z = z_0;
1113 newstate.curDim = 0;
1114 block_gmres_iter->initializeGmres(newstate);
1115
1116 } // end of restarting
1117
1119 //
1120 // we returned from iterate(), but none of our status tests Passed.
1121 // something is wrong, and it is probably our fault.
1122 //
1124
1125 else {
1127 TEUCHOS_TEST_FOR_EXCEPTION(true,std::logic_error,
1128 "Belos::BlockGmresSolMgr::solve(): Invalid return from BlockGmresIter::iterate().");
1129 }
1130 }
1131 catch (const GmresIterationOrthoFailure &e) {
1132 // If the block size is not one, it's not considered a lucky breakdown.
1133 if (blockSize_ != 1) {
1134 printer_->stream(Errors) << "Error! Caught std::exception in BlockGmresIter::iterate() at iteration "
1135 << block_gmres_iter->getNumIters() << std::endl
1136 << e.what() << std::endl;
1137 if (convTest_->getStatus() != Passed) {
1139 isConverged = false;
1140 }
1141 break;
1142 }
1143 else {
1144 // If the block size is one, try to recover the most recent least-squares solution
1145 block_gmres_iter->updateLSQR( block_gmres_iter->getCurSubspaceDim() );
1146
1147 // Check to see if the most recent least-squares solution yielded convergence.
1148 sTest_->checkStatus( &*block_gmres_iter );
1149 if (convTest_->getStatus() != Passed) {
1151 isConverged = false;
1152 }
1153 break;
1154 }
1155 }
1156 catch (const StatusTestNaNError& e) {
1157 // A NaN was detected in the solver. Set the solution to zero and return unconverged.
1159 achievedTol_ = MT::one();
1160 Teuchos::RCP<MV> X = problem_->getLHS();
1161 MVT::MvInit( *X, SCT::zero() );
1162 printer_->stream(Warnings) << "Belos::BlockGmresSolMgr::solve(): Warning! NaN has been detected!"
1163 << std::endl;
1164 return retType;
1165 }
1166 catch (const std::exception &e) {
1168 printer_->stream(Errors) << "Error! Caught std::exception in BlockGmresIter::iterate() at iteration "
1169 << block_gmres_iter->getNumIters() << std::endl
1170 << e.what() << std::endl;
1171 throw;
1172 }
1173 }
1174
1175 // Compute the current solution.
1176 // Update the linear problem.
1177 if (isFlexible_) {
1178 // Update the solution manually, since the preconditioning doesn't need to be undone.
1179 Teuchos::RCP<MV> update = block_gmres_iter->getCurrentUpdate();
1180 Teuchos::RCP<MV> curX = problem_->getCurrLHSVec();
1181 // Update the solution only if there is a valid update from the iteration
1182 if (update != Teuchos::null)
1183 MVT::MvAddMv( 1.0, *curX, 1.0, *update, *curX );
1184 }
1185 else {
1186 // Attempt to get the current solution from the residual status test, if it has one.
1187 if ( !Teuchos::is_null(expConvTest_->getSolution()) ) {
1188 Teuchos::RCP<MV> newX = expConvTest_->getSolution();
1189 Teuchos::RCP<MV> curX = problem_->getCurrLHSVec();
1190 MVT::Assign( *newX, *curX );
1191 }
1192 else {
1193 Teuchos::RCP<MV> update = block_gmres_iter->getCurrentUpdate();
1194 problem_->updateSolution( update, true );
1195 }
1196 }
1197
1198 // Inform the linear problem that we are finished with this block linear system.
1199 problem_->setCurrLS();
1200
1201 // Update indices for the linear systems to be solved.
1204 if ( numRHS2Solve > 0 ) {
1205 numCurrRHS = ( numRHS2Solve < blockSize_) ? numRHS2Solve : blockSize_;
1206
1207 if ( adaptiveBlockSize_ ) {
1208 blockSize_ = numCurrRHS;
1209 currIdx.resize( numCurrRHS );
1210 for (int i=0; i<numCurrRHS; ++i)
1211 { currIdx[i] = startPtr+i; }
1212 }
1213 else {
1214 currIdx.resize( blockSize_ );
1215 for (int i=0; i<numCurrRHS; ++i)
1216 { currIdx[i] = startPtr+i; }
1217 for (int i=numCurrRHS; i<blockSize_; ++i)
1218 { currIdx[i] = -1; }
1219 }
1220 // Set the next indices.
1221 problem_->setLSIndex( currIdx );
1222 }
1223 else {
1224 currIdx.resize( numRHS2Solve );
1225 }
1226
1227 }// while ( numRHS2Solve > 0 )
1228
1229 }
1230
1231 // print final summary
1232 sTest_->print( printer_->stream(FinalSummary) );
1233
1234 // print timing information
1235#ifdef BELOS_TEUCHOS_TIME_MONITOR
1236 // Calling summarize() can be expensive, so don't call unless the
1237 // user wants to print out timing details. summarize() will do all
1238 // the work even if it's passed a "black hole" output stream.
1239 if (verbosity_ & TimingDetails)
1240 Teuchos::TimeMonitor::summarize( printer_->stream(TimingDetails) );
1241#endif
1242
1243 // get iteration information for this solve
1244 numIters_ = maxIterTest_->getNumIters();
1245
1246 // Save the convergence test value ("achieved tolerance") for this
1247 // solve. This requires a bit more work than for BlockCGSolMgr,
1248 // since for this solver, convTest_ may either be a single residual
1249 // norm test, or a combination of two residual norm tests. In the
1250 // latter case, the master convergence test convTest_ is a SEQ combo
1251 // of the implicit resp. explicit tests. If the implicit test never
1252 // passes, then the explicit test won't ever be executed. This
1253 // manifests as expConvTest_->getTestValue()->size() < 1. We deal
1254 // with this case by using the values returned by
1255 // impConvTest_->getTestValue().
1256 {
1257 // We'll fetch the vector of residual norms one way or the other.
1258 const std::vector<MagnitudeType>* pTestValues = NULL;
1259 if (expResTest_) {
1260 pTestValues = expConvTest_->getTestValue();
1261 if (pTestValues == NULL || pTestValues->size() < 1) {
1262 pTestValues = impConvTest_->getTestValue();
1263 }
1264 }
1265 else {
1266 // Only the implicit residual norm test is being used.
1267 pTestValues = impConvTest_->getTestValue();
1268 }
1269 TEUCHOS_TEST_FOR_EXCEPTION(pTestValues == NULL, std::logic_error,
1270 "Belos::BlockGmresSolMgr::solve(): The implicit convergence test's "
1271 "getTestValue() method returned NULL. Please report this bug to the "
1272 "Belos developers.");
1273 TEUCHOS_TEST_FOR_EXCEPTION(pTestValues->size() < 1, std::logic_error,
1274 "Belos::BlockGmresSolMgr::solve(): The implicit convergence test's "
1275 "getTestValue() method returned a vector of length zero. Please report "
1276 "this bug to the Belos developers.");
1277
1278 // FIXME (mfh 12 Dec 2011) Does pTestValues really contain the
1279 // achieved tolerances for all vectors in the current solve(), or
1280 // just for the vectors from the last deflation?
1281 achievedTol_ = *std::max_element (pTestValues->begin(), pTestValues->end());
1282 }
1283
1284 if (!isConverged || loaDetected_) {
1285 return retType; // return from BlockGmresSolMgr::solve()
1286 }
1287 return Converged; // return from BlockGmresSolMgr::solve()
1288}
1289
1290
1291template<class ScalarType, class MV, class OP, class DM>
1293{
1294 std::ostringstream out;
1295 out << "\"Belos::BlockGmresSolMgr\": {";
1296 if (this->getObjectLabel () != "") {
1297 out << "Label: " << this->getObjectLabel () << ", ";
1298 }
1299 out << "Flexible: " << (isFlexible_ ? "true" : "false")
1300 << ", Num Blocks: " << numBlocks_
1301 << ", Maximum Iterations: " << maxIters_
1302 << ", Maximum Restarts: " << maxRestarts_
1303 << ", Convergence Tolerance: " << convtol_
1304 << "}";
1305 return out.str ();
1306}
1307
1308
1309template<class ScalarType, class MV, class OP, class DM>
1310void
1312describe (Teuchos::FancyOStream &out,
1313 const Teuchos::EVerbosityLevel verbLevel) const
1314{
1315 using Teuchos::TypeNameTraits;
1316 using Teuchos::VERB_DEFAULT;
1317 using Teuchos::VERB_NONE;
1318 using Teuchos::VERB_LOW;
1319 // using Teuchos::VERB_MEDIUM;
1320 // using Teuchos::VERB_HIGH;
1321 // using Teuchos::VERB_EXTREME;
1322 using std::endl;
1323
1324 // Set default verbosity if applicable.
1325 const Teuchos::EVerbosityLevel vl =
1327
1328 if (vl != VERB_NONE) {
1329 Teuchos::OSTab tab0 (out);
1330
1331 out << "\"Belos::BlockGmresSolMgr\":" << endl;
1332 Teuchos::OSTab tab1 (out);
1333 out << "Template parameters:" << endl;
1334 {
1335 Teuchos::OSTab tab2 (out);
1336 out << "ScalarType: " << TypeNameTraits<ScalarType>::name () << endl
1337 << "MV: " << TypeNameTraits<MV>::name () << endl
1338 << "OP: " << TypeNameTraits<OP>::name () << endl;
1339 }
1340 if (this->getObjectLabel () != "") {
1341 out << "Label: " << this->getObjectLabel () << endl;
1342 }
1343 out << "Flexible: " << (isFlexible_ ? "true" : "false") << endl
1344 << "Num Blocks: " << numBlocks_ << endl
1345 << "Maximum Iterations: " << maxIters_ << endl
1346 << "Maximum Restarts: " << maxRestarts_ << endl
1347 << "Convergence Tolerance: " << convtol_ << endl;
1348 }
1349}
1350
1351
1352} // end Belos namespace
1353
1354#endif /* BELOS_BLOCK_GMRES_SOLMGR_HPP */
Belos concrete class for performing the block, flexible GMRES iteration.
Belos concrete class for performing the block GMRES iteration.
Belos header file which uses auto-configuration information to include necessary C++ headers.
Pure virtual base class which augments the basic interface for a Gmres linear solver iteration.
Full specialization of Belos::DenseMatTraits for Kokkos::DualView with arbitrary scalarType....
Class which describes the linear problem to be solved by the iterative solver.
Class which manages the output and verbosity of the Belos solvers.
Pure virtual base class which describes the basic interface for a solver manager.
Belos::StatusTest for logically combining several status tests.
Belos::StatusTestResNorm for specifying general residual norm stopping criteria.
Belos::StatusTest for specifying an implicit residual norm stopping criteria that checks for loss of ...
Belos::StatusTest class for specifying a maximum number of iterations.
Virtual base class for StatusTest that printing status tests.
A factory class for generating StatusTestOutput objects.
Full specialization of Belos::DenseMatTraits for Teuchos::SerialDenseMatrix with ordinal type int and...
Collection of types and exceptions used within the Belos solvers.
Parent class to all Belos exceptions.
Interface to Block GMRES and Flexible GMRES.
Teuchos::RCP< const Teuchos::ParameterList > getCurrentParameters() const override
Get a parameter list containing the current parameters for this object.
MagnitudeType achievedTol() const override
Tolerance achieved by the last solve() invocation.
void setDebugStatusTest(const Teuchos::RCP< StatusTest< ScalarType, MV, OP, DM > > &debugStatusTest) override
Set a debug status test that will be checked at the same time as the top-level status test.
void setParameters(const Teuchos::RCP< Teuchos::ParameterList > &params) override
Set the parameters the solver manager should use to solve the linear problem.
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.
std::string description() const override
Return a one-line description of this object.
Teuchos::Array< Teuchos::RCP< Teuchos::Time > > getTimers() const
Return the timers for this object.
void setProblem(const Teuchos::RCP< LinearProblem< ScalarType, MV, OP, DM > > &problem) override
Set the linear problem that needs to be solved.
Teuchos::RCP< SolverManager< ScalarType, MV, OP, DM > > clone() const override
clone for Inverted Injection (DII)
int getNumIters() const override
Get the iteration count for the most recent call to solve().
ReturnType solve() override
This method performs possibly repeated calls to the underlying linear solver's iterate() routine unti...
BlockGmresSolMgr()
Empty constructor for BlockGmresSolMgr. This constructor takes no arguments and sets the default valu...
bool isLOADetected() const override
Return whether a loss of accuracy was detected by this solver during the most current solve.
virtual ~BlockGmresSolMgr()
Destructor.
const LinearProblem< ScalarType, MV, OP, DM > & getProblem() const override
Get current linear problem being solved for in this object.
void reset(const ResetType type) override
Performs a reset of the solver manager specified by the ResetType. This informs the solver manager th...
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const override
Get a parameter list containing the valid parameters for this object.
BlockGmresSolMgrLinearProblemFailure is thrown when the linear problem is not setup (i....
BlockGmresSolMgrLinearProblemFailure(const std::string &what_arg)
BlockGmresSolMgrOrthoFailure is thrown when the orthogonalization manager is unable to generate ortho...
BlockGmresSolMgrOrthoFailure(const std::string &what_arg)
GmresIterationOrthoFailure is thrown when the GmresIteration object is unable to compute independent ...
Alternative run-time polymorphic interface for operators.
Operator()
Default constructor (does nothing).
The Belos::SolverManager is a templated virtual base class that defines the basic interface that any ...
ScaleType convertStringToScaleType(const std::string &scaleType)
Convert the given string to its ScaleType enum value.
@ StatusTestDetails
@ FinalSummary
@ TimingDetails
ReturnType
Whether the Belos solve converged for all linear systems.
@ NaNDetected
@ MaxItersReached
@ NonspecificException
@ MaxRestartsReached
@ LossOfAccuracyDetected
@ InconsistentState
@ OrthonormFailure
@ Undetermined
ScaleType
The type of scaling to use on the residual norm value.
ResetType
How to reset the solver.
Default parameters common to most Belos solvers.
static const double convTol
Default convergence tolerance.
static const double orthoKappa
DGKS orthogonalization constant.

Generated for Belos by doxygen 1.9.8