Belos Version of the Day
Loading...
Searching...
No Matches
BelosFixedPointSolMgr.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_FIXEDPOINT_SOLMGR_HPP
11#define BELOS_FIXEDPOINT_SOLMGR_HPP
12
17#include "BelosConfigDefs.hpp"
18#include "BelosTypes.hpp"
19
22
23#include "BelosCGIter.hpp"
32#ifdef BELOS_TEUCHOS_TIME_MONITOR
33# include "Teuchos_TimeMonitor.hpp"
34#endif
35#include <algorithm>
36
45namespace Belos {
46
48
49
59
60 template<class ScalarType, class MV, class OP, class DM = DefaultDenseMatrix<int, ScalarType>>
61 class FixedPointSolMgr : public SolverManager<ScalarType,MV,OP,DM> {
62
63 private:
66 typedef Teuchos::ScalarTraits<ScalarType> SCT;
67 typedef typename Teuchos::ScalarTraits<ScalarType>::magnitudeType MagnitudeType;
68 typedef Teuchos::ScalarTraits<MagnitudeType> MT;
69
70 public:
71
73
74
81
100 const Teuchos::RCP<Teuchos::ParameterList> &pl );
101
103 virtual ~FixedPointSolMgr() {};
104
106 Teuchos::RCP<SolverManager<ScalarType, MV, OP, DM> > clone () const override {
107 return Teuchos::rcp(new FixedPointSolMgr<ScalarType,MV,OP,DM>);
108 }
110
112
113
115 return *problem_;
116 }
117
120 Teuchos::RCP<const Teuchos::ParameterList> getValidParameters() const override;
121
124 Teuchos::RCP<const Teuchos::ParameterList> getCurrentParameters() const override { return params_; }
125
131 Teuchos::Array<Teuchos::RCP<Teuchos::Time> > getTimers() const {
132 return Teuchos::tuple(timerSolve_);
133 }
134
140 MagnitudeType achievedTol() const override {
141 return achievedTol_;
142 }
143
145 int getNumIters() const override {
146 return numIters_;
147 }
148
151 bool isLOADetected() const override { return false; }
153
155
156
158 void setProblem( const Teuchos::RCP<LinearProblem<ScalarType,MV,OP,DM> > &problem ) override { problem_ = problem; }
159
161 void setParameters( const Teuchos::RCP<Teuchos::ParameterList> &params ) override;
162
165 {
166
167 convTest_ = userConvStatusTest;
168
169 typedef Belos::StatusTestCombo<ScalarType,MV,OP,DM> StatusTestCombo_t;
170 sTest_ = Teuchos::rcp( new StatusTestCombo_t( StatusTestCombo_t::OR, maxIterTest_, convTest_ ) );
171
173 outputTest_ = stoFactory.create( printer_, sTest_, outputFreq_, Passed+Failed+Undefined );
174
175 std::string solverDesc = " Fixed Point ";
176 outputTest_->setSolverDesc( solverDesc );
177 }
178
180
182
183
187 void reset( const ResetType type ) override { if ((type & Belos::Problem) && !Teuchos::is_null(problem_)) problem_->setProblem(); }
189
191
192
210 ReturnType solve() override;
212
215
217 std::string description() const override;
219
220 private:
221
223 Teuchos::RCP<LinearProblem<ScalarType,MV,OP,DM> > problem_;
224
226 Teuchos::RCP<OutputManager<ScalarType> > printer_;
228 Teuchos::RCP<std::ostream> outputStream_;
229
234 Teuchos::RCP<StatusTest<ScalarType,MV,OP,DM> > sTest_;
235
237 Teuchos::RCP<StatusTestMaxIters<ScalarType,MV,OP,DM> > maxIterTest_;
238
240 Teuchos::RCP<StatusTestResNorm<ScalarType,MV,OP,DM> > convTest_;
241
243 Teuchos::RCP<StatusTestOutput<ScalarType,MV,OP,DM> > outputTest_;
244
246 Teuchos::RCP<Teuchos::ParameterList> params_;
247
248 //
249 // Default solver parameters.
250 //
251 static constexpr int maxIters_default_ = 1000;
252 static constexpr bool showMaxResNormOnly_default_ = false;
253 static constexpr int blockSize_default_ = 1;
254 static constexpr int verbosity_default_ = Belos::Errors;
255 static constexpr int outputStyle_default_ = Belos::General;
256 static constexpr int outputFreq_default_ = -1;
257 static constexpr const char * label_default_ = "Belos";
258
259 //
260 // Current solver parameters and other values.
261 //
262
264 MagnitudeType convtol_;
265
271 MagnitudeType achievedTol_;
272
274 int maxIters_;
275
277 int numIters_;
278
279 int blockSize_, verbosity_, outputStyle_, outputFreq_;
280 bool showMaxResNormOnly_;
281
283 std::string label_;
284
286 Teuchos::RCP<Teuchos::Time> timerSolve_;
287
289 bool isSet_;
290 };
291
292
293// Empty Constructor
294template<class ScalarType, class MV, class OP, class DM>
296 outputStream_(Teuchos::rcpFromRef(std::cout)),
297 convtol_(DefaultSolverParameters::convTol),
298 achievedTol_(Teuchos::ScalarTraits<MagnitudeType>::zero()),
299 maxIters_(maxIters_default_),
300 numIters_(0),
301 blockSize_(blockSize_default_),
302 verbosity_(verbosity_default_),
303 outputStyle_(outputStyle_default_),
304 outputFreq_(outputFreq_default_),
305 showMaxResNormOnly_(showMaxResNormOnly_default_),
306 label_(label_default_),
307 isSet_(false)
308{}
309
310
311// Basic Constructor
312template<class ScalarType, class MV, class OP, class DM>
315 const Teuchos::RCP<Teuchos::ParameterList> &pl) :
316 problem_(problem),
317 outputStream_(Teuchos::rcpFromRef(std::cout)),
318 convtol_(DefaultSolverParameters::convTol),
319 achievedTol_(Teuchos::ScalarTraits<MagnitudeType>::zero()),
320 maxIters_(maxIters_default_),
321 numIters_(0),
322 blockSize_(blockSize_default_),
323 verbosity_(verbosity_default_),
324 outputStyle_(outputStyle_default_),
325 outputFreq_(outputFreq_default_),
326 showMaxResNormOnly_(showMaxResNormOnly_default_),
327 label_(label_default_),
328 isSet_(false)
329{
330 TEUCHOS_TEST_FOR_EXCEPTION(problem_.is_null(), std::invalid_argument,
331 "FixedPointSolMgr's constructor requires a nonnull LinearProblem instance.");
332
333 // If the user passed in a nonnull parameter list, set parameters.
334 // Otherwise, the next solve() call will use default parameters,
335 // unless the user calls setParameters() first.
336 if (! pl.is_null()) {
338 }
339}
340
341template<class ScalarType, class MV, class OP, class DM>
342void
344setParameters (const Teuchos::RCP<Teuchos::ParameterList> &params)
345{
346 // Create the internal parameter list if one doesn't already exist.
347 if (params_ == Teuchos::null) {
348 params_ = Teuchos::rcp( new Teuchos::ParameterList(*getValidParameters()) );
349 }
350 else {
351 params->validateParameters(*getValidParameters());
352 }
353
354 // Check for maximum number of iterations
355 if (params->isParameter("Maximum Iterations")) {
356 maxIters_ = params->get("Maximum Iterations",maxIters_default_);
357
358 // Update parameter in our list and in status test.
359 params_->set("Maximum Iterations", maxIters_);
360 if (maxIterTest_!=Teuchos::null)
361 maxIterTest_->setMaxIters( maxIters_ );
362 }
363
364 // Check for blocksize
365 if (params->isParameter("Block Size")) {
366 blockSize_ = params->get("Block Size",blockSize_default_);
367 TEUCHOS_TEST_FOR_EXCEPTION(blockSize_ <= 0, std::invalid_argument,
368 "Belos::FixedPointSolMgr: \"Block Size\" must be strictly positive.");
369
370 // Update parameter in our list.
371 params_->set("Block Size", blockSize_);
372 }
373
374 // Check to see if the timer label changed.
375 if (params->isParameter("Timer Label")) {
376 std::string tempLabel = params->get("Timer Label", label_default_);
377
378 // Update parameter in our list and solver timer
379 if (tempLabel != label_) {
380 label_ = tempLabel;
381 params_->set("Timer Label", label_);
382 std::string solveLabel = label_ + ": FixedPointSolMgr total solve time";
383#ifdef BELOS_TEUCHOS_TIME_MONITOR
384 timerSolve_ = Teuchos::TimeMonitor::getNewCounter(solveLabel);
385#endif
386 }
387 }
388
389 // Check for a change in verbosity level
390 if (params->isParameter("Verbosity")) {
391 if (Teuchos::isParameterType<int>(*params,"Verbosity")) {
392 verbosity_ = params->get("Verbosity", verbosity_default_);
393 } else {
394 verbosity_ = (int)Teuchos::getParameter<Belos::MsgType>(*params,"Verbosity");
395 }
396
397 // Update parameter in our list.
398 params_->set("Verbosity", verbosity_);
399 if (printer_ != Teuchos::null)
400 printer_->setVerbosity(verbosity_);
401 }
402
403 // Check for a change in output style
404 if (params->isParameter("Output Style")) {
405 if (Teuchos::isParameterType<int>(*params,"Output Style")) {
406 outputStyle_ = params->get("Output Style", outputStyle_default_);
407 } else {
408 outputStyle_ = (int)Teuchos::getParameter<Belos::OutputType>(*params,"Output Style");
409 }
410
411 // Update parameter in our list.
412 params_->set("Output Style", outputStyle_);
413 outputTest_ = Teuchos::null;
414 }
415
416 // output stream
417 if (params->isParameter("Output Stream")) {
418 outputStream_ = Teuchos::getParameter<Teuchos::RCP<std::ostream> >(*params,"Output Stream");
419
420 // Update parameter in our list.
421 params_->set("Output Stream", outputStream_);
422 if (printer_ != Teuchos::null)
423 printer_->setOStream( outputStream_ );
424 }
425
426 // frequency level
427 if (verbosity_ & Belos::StatusTestDetails) {
428 if (params->isParameter("Output Frequency")) {
429 outputFreq_ = params->get("Output Frequency", outputFreq_default_);
430 }
431
432 // Update parameter in out list and output status test.
433 params_->set("Output Frequency", outputFreq_);
434 if (outputTest_ != Teuchos::null)
435 outputTest_->setOutputFrequency( outputFreq_ );
436 }
437
438 // Create output manager if we need to.
439 if (printer_ == Teuchos::null) {
440 printer_ = Teuchos::rcp( new OutputManager<ScalarType>(verbosity_, outputStream_) );
441 }
442
443 // Convergence
444 typedef Belos::StatusTestCombo<ScalarType,MV,OP,DM> StatusTestCombo_t;
445 typedef Belos::StatusTestGenResNorm<ScalarType,MV,OP,DM> StatusTestResNorm_t;
446
447 // Check for convergence tolerance
448 if (params->isParameter("Convergence Tolerance")) {
449 if (params->isType<MagnitudeType> ("Convergence Tolerance")) {
450 convtol_ = params->get ("Convergence Tolerance",
451 static_cast<MagnitudeType> (DefaultSolverParameters::convTol));
452 }
453 else {
454 convtol_ = params->get ("Convergence Tolerance", DefaultSolverParameters::convTol);
455 }
456
457 // Update parameter in our list and residual tests.
458 params_->set("Convergence Tolerance", convtol_);
459 if (convTest_ != Teuchos::null)
460 convTest_->setTolerance( convtol_ );
461 }
462
463 if (params->isParameter("Show Maximum Residual Norm Only")) {
464 showMaxResNormOnly_ = Teuchos::getParameter<bool>(*params,"Show Maximum Residual Norm Only");
465
466 // Update parameter in our list and residual tests
467 params_->set("Show Maximum Residual Norm Only", showMaxResNormOnly_);
468 if (convTest_ != Teuchos::null)
469 convTest_->setShowMaxResNormOnly( showMaxResNormOnly_ );
470 }
471
472 // Create status tests if we need to.
473
474 // Basic test checks maximum iterations and native residual.
475 if (maxIterTest_ == Teuchos::null)
476 maxIterTest_ = Teuchos::rcp( new StatusTestMaxIters<ScalarType,MV,OP,DM>( maxIters_ ) );
477
478 // Implicit residual test, using the native residual to determine if convergence was achieved.
479 if (convTest_ == Teuchos::null)
480 convTest_ = Teuchos::rcp( new StatusTestResNorm_t( convtol_, 1 ) );
481
482 if (sTest_ == Teuchos::null)
483 sTest_ = Teuchos::rcp( new StatusTestCombo_t( StatusTestCombo_t::OR, maxIterTest_, convTest_ ) );
484
485 if (outputTest_ == Teuchos::null) {
486
487 // Create the status test output class.
488 // This class manages and formats the output from the status test.
490 outputTest_ = stoFactory.create( printer_, sTest_, outputFreq_, Passed+Failed+Undefined );
491
492 // Set the solver string for the output test
493 std::string solverDesc = " Fixed Point ";
494 outputTest_->setSolverDesc( solverDesc );
495
496 }
497
498 // Create the timer if we need to.
499 if (timerSolve_ == Teuchos::null) {
500 std::string solveLabel = label_ + ": FixedPointSolMgr total solve time";
501#ifdef BELOS_TEUCHOS_TIME_MONITOR
502 timerSolve_ = Teuchos::TimeMonitor::getNewCounter(solveLabel);
503#endif
504 }
505
506 // Inform the solver manager that the current parameters were set.
507 isSet_ = true;
508}
509
510
511template<class ScalarType, class MV, class OP, class DM>
512Teuchos::RCP<const Teuchos::ParameterList>
514{
515 static Teuchos::RCP<const Teuchos::ParameterList> validPL;
516
517 // Set all the valid parameters and their default values.
518 if(is_null(validPL)) {
519 Teuchos::RCP<Teuchos::ParameterList> pl = Teuchos::parameterList();
520
521 // The static_cast is to resolve an issue with older clang versions which
522 // would cause the constexpr to link fail. With c++17 the problem is resolved.
523 pl->set("Convergence Tolerance", static_cast<MagnitudeType>(DefaultSolverParameters::convTol),
524 "The relative residual tolerance that needs to be achieved by the\n"
525 "iterative solver in order for the linear system to be declared converged.");
526 pl->set("Maximum Iterations", static_cast<int>(maxIters_default_),
527 "The maximum number of block iterations allowed for each\n"
528 "set of RHS solved.");
529 pl->set("Block Size", static_cast<int>(blockSize_default_),
530 "The number of vectors in each block.");
531 pl->set("Verbosity", static_cast<int>(verbosity_default_),
532 "What type(s) of solver information should be outputted\n"
533 "to the output stream.");
534 pl->set("Output Style", static_cast<int>(outputStyle_default_),
535 "What style is used for the solver information outputted\n"
536 "to the output stream.");
537 pl->set("Output Frequency", static_cast<int>(outputFreq_default_),
538 "How often convergence information should be outputted\n"
539 "to the output stream.");
540 pl->set("Output Stream", Teuchos::rcpFromRef(std::cout),
541 "A reference-counted pointer to the output stream where all\n"
542 "solver output is sent.");
543 pl->set("Show Maximum Residual Norm Only", static_cast<bool>(showMaxResNormOnly_default_),
544 "When convergence information is printed, only show the maximum\n"
545 "relative residual norm when the block size is greater than one.");
546 pl->set("Timer Label", static_cast<const char *>(label_default_),
547 "The string to use as a prefix for the timer labels.");
548 validPL = pl;
549 }
550 return validPL;
551}
552
553
554// solve()
555template<class ScalarType, class MV, class OP, class DM>
557 using Teuchos::RCP;
558 using Teuchos::rcp;
559 using Teuchos::rcp_const_cast;
560 using Teuchos::rcp_dynamic_cast;
561
563
564 // Set the current parameters if they were not set before. NOTE:
565 // This may occur if the user generated the solver manager with the
566 // default constructor and then didn't set any parameters using
567 // setParameters().
568 if (!isSet_) {
569 setParameters(Teuchos::parameterList(*getValidParameters()));
570 }
571
572 TEUCHOS_TEST_FOR_EXCEPTION( !problem_->isProblemSet(),
574 "Belos::FixedPointSolMgr::solve(): Linear problem is not ready, setProblem() "
575 "has not been called.");
576
577 // Create indices for the linear systems to be solved.
578 int startPtr = 0;
579 int numRHS2Solve = MVT::GetNumberVecs( *(problem_->getRHS()) );
580 int numCurrRHS = ( numRHS2Solve < blockSize_) ? numRHS2Solve : blockSize_;
581
582 std::vector<int> currIdx, currIdx2;
583 currIdx.resize( blockSize_ );
584 currIdx2.resize( blockSize_ );
585 for (int i=0; i<numCurrRHS; ++i)
586 { currIdx[i] = startPtr+i; currIdx2[i]=i; }
587 for (int i=numCurrRHS; i<blockSize_; ++i)
588 { currIdx[i] = -1; currIdx2[i] = i; }
589
590 // Inform the linear problem of the current linear system to solve.
591 problem_->setLSIndex( currIdx );
592
594 // Set up the parameter list for the Iteration subclass.
595 Teuchos::ParameterList plist;
596 plist.set("Block Size",blockSize_);
597
598 // Reset the output status test (controls all the other status tests).
599 outputTest_->reset();
600
601 // Assume convergence is achieved, then let any failed convergence
602 // set this to false. "Innocent until proven guilty."
603 bool isConverged = true;
604
606 // Set up the FixedPoint Iteration subclass.
607
609 block_fp_iter = rcp (new FixedPointIter<ScalarType,MV,OP,DM> (problem_, printer_, outputTest_, plist));
610
611 // Enter solve() iterations
612 {
613#ifdef BELOS_TEUCHOS_TIME_MONITOR
614 Teuchos::TimeMonitor slvtimer(*timerSolve_);
615#endif
616
617 while ( numRHS2Solve > 0 ) {
618 //
619 // Reset the active / converged vectors from this block
620 std::vector<int> convRHSIdx;
621 std::vector<int> currRHSIdx( currIdx );
622 currRHSIdx.resize(numCurrRHS);
623
624 // Reset the number of iterations.
625 block_fp_iter->resetNumIters();
626
627 // Reset the number of calls that the status test output knows about.
628 outputTest_->resetNumCalls();
629
630 // Get the current residual for this block of linear systems.
631 RCP<MV> R_0 = MVT::CloneViewNonConst( *(rcp_const_cast<MV>(problem_->getInitResVec())), currIdx );
632
633 // Set the new state and initialize the solver.
635 newstate.R = R_0;
636 block_fp_iter->initializeFixedPoint(newstate);
637
638 while(1) {
639
640 // tell block_fp_iter to iterate
641 try {
642 block_fp_iter->iterate();
643 //
644 // Check whether any of the linear systems converged.
645 //
646 if (convTest_->getStatus() == Passed) {
647 // At least one of the linear system(s) converged.
648 //
649 // Get the column indices of the linear systems that converged.
650 std::vector<int> convIdx = convTest_->convIndices();
651
652 // If the number of converged linear systems equals the
653 // number of linear systems currently being solved, then
654 // we are done with this block.
655 if (convIdx.size() == currRHSIdx.size())
656 break; // break from while(1){block_fp_iter->iterate()}
657
658 // Inform the linear problem that we are finished with
659 // this current linear system.
660 problem_->setCurrLS();
661
662 // Reset currRHSIdx to contain the right-hand sides that
663 // are left to converge for this block.
664 int have = 0;
665 std::vector<int> unconvIdx(currRHSIdx.size());
666 for (unsigned int i=0; i<currRHSIdx.size(); ++i) {
667 bool found = false;
668 for (unsigned int j=0; j<convIdx.size(); ++j) {
669 if (currRHSIdx[i] == convIdx[j]) {
670 found = true;
671 break;
672 }
673 }
674 if (!found) {
677 }
678 else {
679 }
680 }
681 currRHSIdx.resize(have);
682 currIdx2.resize(have);
683
684 // Set the remaining indices after deflation.
685 problem_->setLSIndex( currRHSIdx );
686
687 // Get the current residual vector.
688 std::vector<MagnitudeType> norms;
689 R_0 = MVT::CloneCopy( *(block_fp_iter->getNativeResiduals(&norms)),currIdx2 );
690 for (int i=0; i<have; ++i) { currIdx2[i] = i; }
691
692 // Set the new blocksize for the solver.
693 block_fp_iter->setBlockSize( have );
694
695 // Set the new state and initialize the solver.
697 defstate.R = R_0;
698 block_fp_iter->initializeFixedPoint(defstate);
699 }
700 //
701 // None of the linear systems converged. Check whether the
702 // maximum iteration count was reached.
703 //
704 else if (maxIterTest_->getStatus() == Passed) {
706 isConverged = false; // None of the linear systems converged.
707 break; // break from while(1){block_fp_iter->iterate()}
708 }
709 //
710 // iterate() returned, but none of our status tests Passed.
711 // This indicates a bug.
712 //
713 else {
715 TEUCHOS_TEST_FOR_EXCEPTION(true,std::logic_error,
716 "Belos::FixedPointSolMgr::solve(): Neither the convergence test nor "
717 "the maximum iteration count test passed. Please report this bug "
718 "to the Belos developers.");
719 }
720 }
721 catch (const StatusTestNaNError& e) {
722 // A NaN was detected in the solver. Set the solution to zero and return unconverged.
724 achievedTol_ = MT::one();
725 Teuchos::RCP<MV> X = problem_->getLHS();
726 MVT::MvInit( *X, SCT::zero() );
727 printer_->stream(Warnings) << "Belos::FixedPointSolMgr::solve(): Warning! NaN has been detected!"
728 << std::endl;
729 return retType;
730 }
731 catch (const std::exception &e) {
733 std::ostream& err = printer_->stream (Errors);
734 err << "Error! Caught std::exception in FixedPointIteration::iterate() at "
735 << "iteration " << block_fp_iter->getNumIters() << std::endl
736 << e.what() << std::endl;
737 throw;
738 }
739 }
740
741 // Inform the linear problem that we are finished with this
742 // block linear system.
743 problem_->setCurrLS();
744
745 // Update indices for the linear systems to be solved.
748 if ( numRHS2Solve > 0 ) {
749 numCurrRHS = ( numRHS2Solve < blockSize_) ? numRHS2Solve : blockSize_;
750
751
752 currIdx.resize( blockSize_ );
753 currIdx2.resize( blockSize_ );
754 for (int i=0; i<numCurrRHS; ++i)
755 { currIdx[i] = startPtr+i; currIdx2[i] = i; }
756 for (int i=numCurrRHS; i<blockSize_; ++i)
757 { currIdx[i] = -1; currIdx2[i] = i; }
758
759 // Set the next indices.
760 problem_->setLSIndex( currIdx );
761
762 // Set the new blocksize for the solver.
763 block_fp_iter->setBlockSize( blockSize_ );
764 }
765 else {
766 currIdx.resize( numRHS2Solve );
767 }
768
769 }// while ( numRHS2Solve > 0 )
770
771 }
772
773 // print final summary
774 sTest_->print( printer_->stream(FinalSummary) );
775
776 // print timing information
777#ifdef BELOS_TEUCHOS_TIME_MONITOR
778 // Calling summarize() requires communication in general, so don't
779 // call it unless the user wants to print out timing details.
780 // summarize() will do all the work even if it's passed a "black
781 // hole" output stream.
782 if (verbosity_ & TimingDetails) {
783 Teuchos::TimeMonitor::summarize( printer_->stream(TimingDetails) );
784 }
785#endif
786
787 // Save the iteration count for this solve.
788 numIters_ = maxIterTest_->getNumIters();
789
790 // Save the convergence test value ("achieved tolerance") for this solve.
791 {
792 // testValues is nonnull and not persistent.
793 const std::vector<MagnitudeType>* pTestValues = convTest_->getTestValue();
794
795 TEUCHOS_TEST_FOR_EXCEPTION(pTestValues == NULL, std::logic_error,
796 "Belos::FixedPointSolMgr::solve(): The convergence test's getTestValue() "
797 "method returned NULL. Please report this bug to the Belos developers.");
798
799 TEUCHOS_TEST_FOR_EXCEPTION(pTestValues->size() < 1, std::logic_error,
800 "Belos::FixedPointSolMgr::solve(): The convergence test's getTestValue() "
801 "method returned a vector of length zero. Please report this bug to the "
802 "Belos developers.");
803
804 // FIXME (mfh 12 Dec 2011) Does pTestValues really contain the
805 // achieved tolerances for all vectors in the current solve(), or
806 // just for the vectors from the last deflation?
807 achievedTol_ = *std::max_element (pTestValues->begin(), pTestValues->end());
808 }
809
810 if (!isConverged) {
811 return retType; // return from FixedPointSolMgr::solve()
812 }
813 return Converged; // return from FixedPointSolMgr::solve()
814}
815
816// This method requires the solver manager to return a std::string that describes itself.
817template<class ScalarType, class MV, class OP, class DM>
819{
820 std::ostringstream oss;
821 oss << "Belos::FixedPointSolMgr<...,"<<Teuchos::ScalarTraits<ScalarType>::name()<<">";
822 return oss.str();
823}
824
825} // end Belos namespace
826
827#endif /* BELOS_FIXEDPOINT_SOLMGR_HPP */
Belos concrete class for performing the conjugate-gradient (CG) iteration.
Belos header file which uses auto-configuration information to include necessary C++ headers.
Belos concrete class for performing fixed point iteration 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 class for specifying a maximum number of iterations.
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.
The Belos::FixedPointSolMgr provides a powerful and fully-featured solver manager over the FixedPoint...
Teuchos::RCP< SolverManager< ScalarType, MV, OP, DM > > clone() const override
clone for Inverted Injection (DII)
const LinearProblem< ScalarType, MV, OP, DM > & getProblem() const override
Return a reference to the linear problem being solved by this solver manager.
MagnitudeType achievedTol() const override
Tolerance achieved by the last solve() invocation.
virtual ~FixedPointSolMgr()
Destructor.
ReturnType solve() override
This method performs possibly repeated calls to the underlying linear solver's iterate() routine unti...
void reset(const ResetType type) override
Performs a reset of the solver manager specified by the ResetType. This informs the solver manager th...
void replaceUserConvStatusTest(const Teuchos::RCP< StatusTestResNorm< ScalarType, MV, OP, DM > > &userConvStatusTest)
Set user-defined convergence status test.
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.
void setParameters(const Teuchos::RCP< Teuchos::ParameterList > &params) override
Set the parameters the solver manager should use to solve the linear problem.
int getNumIters() const override
Get the iteration count for the most recent call to solve().
bool isLOADetected() const override
Return whether a loss of accuracy was detected by this solver during the most current solve.
FixedPointSolMgr()
Empty constructor for FixedPointSolMgr. This constructor takes no arguments and sets the default valu...
std::string description() const override
Method to return description of the block CG solver manager.
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const override
Get a parameter list containing the valid parameters for this object.
Teuchos::RCP< const Teuchos::ParameterList > getCurrentParameters() const override
Get a parameter list containing the current parameters for this object.
FixedPointSolMgrLinearProblemFailure is thrown when the linear problem is not setup (i....
FixedPointSolMgrLinearProblemFailure(const std::string &what_arg)
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 ...
@ StatusTestDetails
@ FinalSummary
@ TimingDetails
ReturnType
Whether the Belos solve converged for all linear systems.
@ NaNDetected
@ MaxItersReached
@ NonspecificException
@ InconsistentState
@ Undetermined
ResetType
How to reset the solver.
Default parameters common to most Belos solvers.
static const double convTol
Default convergence tolerance.

Generated for Belos by doxygen 1.9.8