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