Belos Package Browser (Single Doxygen Collection)  Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
BelosMinresSolMgr.hpp
Go to the documentation of this file.
1 //@HEADER
2 // ************************************************************************
3 //
4 // Belos: Block Linear Solvers Package
5 // Copyright 2004 Sandia Corporation
6 //
7 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
8 // the U.S. Government retains certain rights in this software.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
38 //
39 // ************************************************************************
40 //@HEADER
41 
42 #ifndef BELOS_MINRES_SOLMGR_HPP
43 #define BELOS_MINRES_SOLMGR_HPP
44 
47 
48 #include "BelosConfigDefs.hpp"
49 #include "BelosTypes.hpp"
50 
51 #include "BelosLinearProblem.hpp"
52 #include "BelosSolverManager.hpp"
53 
54 #include "BelosMinresIter.hpp"
57 #include "BelosStatusTestCombo.hpp"
59 #include "BelosOutputManager.hpp"
60 #ifdef BELOS_TEUCHOS_TIME_MONITOR
61 #include "Teuchos_TimeMonitor.hpp"
62 #endif
63 
65 // Teuchos::ScalarTraits<int> doesn't define rmax(), alas, so we get
66 // INT_MAX from here.
67 #include <climits>
68 
69 namespace Belos {
70 
72 
73 
83  //
88  public:
89  MinresSolMgrLinearProblemFailure (const std::string& what_arg) :
90  BelosError(what_arg)
91  {}
92  };
93 
112  template<class ScalarType, class MV, class OP>
113  class MinresSolMgr : public SolverManager<ScalarType,MV,OP> {
114 
115  private:
121 
122  public:
123 
136 
138 
139 
148  MinresSolMgr();
149 
183 
185  virtual ~MinresSolMgr() {};
186 
190  }
192 
194 
195 
197  const LinearProblem<ScalarType,MV,OP>& getProblem() const override {
198  return *problem_;
199  }
200 
203  if (defaultParams_.is_null()) {
205  }
206  return defaultParams_;
207  }
208 
211  return params_;
212  }
213 
224  return Teuchos::tuple (timerSolve_);
225  }
226 
232  MagnitudeType achievedTol() const override {
233  return achievedTol_;
234  }
235 
237  int getNumIters() const override {
238  return numIters_;
239  }
240 
246  bool isLOADetected() const override { return false; }
247 
249 
251 
252 
253  void
255  {
256  problem_ = problem;
257  }
258 
259  void
260  setParameters (const Teuchos::RCP<Teuchos::ParameterList>& params) override;
261 
263 
265 
266 
267  void
268  reset (const ResetType type) override
269  {
270  if ((type & Belos::Problem) && ! problem_.is_null()) {
271  problem_->setProblem ();
272  }
273  }
275 
277 
278 
296  ReturnType solve() override;
297 
299 
302 
303  std::string description() const override;
304 
306 
307  private:
310 
314 
322 
327 
332 
337 
342 
348 
353 
356 
359 
362 
365 
368 
371 
374 
377 
380 
382  std::string label_;
383 
386 
389 
395  static void
397  };
398 
399 
400  template<class ScalarType, class MV, class OP>
403  {
405  using Teuchos::parameterList;
406  using Teuchos::RCP;
407  using Teuchos::rcp;
408  using Teuchos::rcpFromRef;
410  typedef MagnitudeType MT;
411 
412  // List of parameters accepted by MINRES, and their default values.
413  RCP<ParameterList> pl = parameterList ("MINRES");
414 
415  pl->set ("Convergence Tolerance", MST::squareroot (MST::eps()),
416  "Relative residual tolerance that needs to be achieved by "
417  "the iterative solver, in order for the linear system to be "
418  "declared converged.",
419  rcp (new EnhancedNumberValidator<MT> (MST::zero(), MST::rmax())));
420  pl->set ("Maximum Iterations", static_cast<int>(1000),
421  "Maximum number of iterations allowed for each right-hand "
422  "side solved.",
423  rcp (new EnhancedNumberValidator<int> (0, INT_MAX)));
424  pl->set ("Num Blocks", static_cast<int> (-1),
425  "Ignored, but permitted, for compatibility with other Belos "
426  "solvers.");
427  pl->set ("Block Size", static_cast<int> (1),
428  "Number of vectors in each block. WARNING: The current "
429  "implementation of MINRES only accepts a block size of 1, "
430  "since it can only solve for 1 right-hand side at a time.",
431  rcp (new EnhancedNumberValidator<int> (1, 1)));
432  pl->set ("Verbosity", (int) Belos::Errors,
433  "The type(s) of solver information that should "
434  "be written to the output stream.");
435  pl->set ("Output Style", (int) Belos::General,
436  "What style is used for the solver information written "
437  "to the output stream.");
438  pl->set ("Output Frequency", static_cast<int>(-1),
439  "How often (in terms of number of iterations) intermediate "
440  "convergence information should be written to the output stream."
441  " -1 means never.");
442  pl->set ("Output Stream", rcpFromRef(std::cout),
443  "A reference-counted pointer to the output stream where all "
444  "solver output is sent. The output stream defaults to stdout.");
445  pl->set ("Timer Label", std::string("Belos"),
446  "The string to use as a prefix for the timer labels.");
447  return pl;
448  }
449 
450  //
451  // Empty Constructor
452  //
453  template<class ScalarType, class MV, class OP>
455  convtol_(0.0),
456  achievedTol_(0.0),
457  maxIters_(0),
458  numIters_ (0),
459  blockSize_(0),
460  verbosity_(0),
461  outputStyle_(0),
462  outputFreq_(0),
463  parametersSet_ (false)
464  {}
465 
466  //
467  // Primary constructor (use this one)
468  //
469  template<class ScalarType, class MV, class OP>
472  const Teuchos::RCP<Teuchos::ParameterList>& params) :
473  problem_ (problem),
474  numIters_ (0),
475  parametersSet_ (false)
476  {
477  TEUCHOS_TEST_FOR_EXCEPTION(problem_.is_null(), std::invalid_argument,
478  "MinresSolMgr: The version of the constructor "
479  "that takes a LinearProblem to solve was given a "
480  "null LinearProblem.");
481  setParameters (params);
482  }
483 
484  template<class ScalarType, class MV, class OP>
485  void
488  {
489  TEUCHOS_TEST_FOR_EXCEPTION(problem.is_null(),
491  "MINRES requires that you have provided a nonnull LinearProblem to the "
492  "solver manager, before you call the solve() method.");
493  TEUCHOS_TEST_FOR_EXCEPTION(problem->getOperator().is_null(),
495  "MINRES requires a LinearProblem object with a non-null operator (the "
496  "matrix A).");
497  TEUCHOS_TEST_FOR_EXCEPTION(problem->getRHS().is_null(),
499  "MINRES requires a LinearProblem object with a non-null right-hand side.");
500  TEUCHOS_TEST_FOR_EXCEPTION( ! problem->isProblemSet(),
502  "MINRES requires that before you give it a LinearProblem to solve, you "
503  "must first call the linear problem's setProblem() method.");
504  }
505 
506  template<class ScalarType, class MV, class OP>
507  void
510  {
512  using Teuchos::parameterList;
513  using Teuchos::RCP;
514  using Teuchos::rcp;
515  using Teuchos::rcpFromRef;
516  using Teuchos::null;
517  using Teuchos::is_null;
518  using std::string;
519  using std::ostream;
520  using std::endl;
521 
522  if (params_.is_null()) {
523  params_ = parameterList (*getValidParameters());
524  }
525  RCP<ParameterList> pl = params;
526  pl->validateParametersAndSetDefaults (*params_);
527 
528  //
529  // Read parameters from the parameter list. We have already
530  // populated it with defaults.
531  //
532  blockSize_ = pl->get<int> ("Block Size");
533  verbosity_ = pl->get<int> ("Verbosity");
534  outputStyle_ = pl->get<int> ("Output Style");
535  outputFreq_ = pl->get<int>("Output Frequency");
536  outputStream_ = pl->get<RCP<std::ostream> > ("Output Stream");
537  convtol_ = pl->get<MagnitudeType> ("Convergence Tolerance");
538  maxIters_ = pl->get<int> ("Maximum Iterations");
539  //
540  // All done reading parameters from the parameter list.
541  // Now we know it's valid and we can store it.
542  //
543  params_ = pl;
544 
545  // Change the timer label, and create the timer if necessary.
546  const string newLabel = pl->get<string> ("Timer Label");
547  {
548  if (newLabel != label_ || timerSolve_.is_null()) {
549  label_ = newLabel;
550 #ifdef BELOS_TEUCHOS_TIME_MONITOR
551  const string solveLabel = label_ + ": MinresSolMgr total solve time";
552  // Unregister the old timer before creating a new one.
553  if (! timerSolve_.is_null()) {
555  timerSolve_ = Teuchos::null;
556  }
557  timerSolve_ = Teuchos::TimeMonitor::getNewCounter (solveLabel);
558 #endif // BELOS_TEUCHOS_TIME_MONITOR
559  }
560  }
561 
562  // Create output manager, if necessary; otherwise, set its parameters.
563  bool recreatedPrinter = false;
564  if (printer_.is_null()) {
565  printer_ = rcp (new OutputManager<ScalarType> (verbosity_, outputStream_));
566  recreatedPrinter = true;
567  } else {
568  // Set the output stream's verbosity level.
569  printer_->setVerbosity (verbosity_);
570  // Tell the output manager about the new output stream.
571  printer_->setOStream (outputStream_);
572  }
573 
574  //
575  // Set up the convergence tests
576  //
577  typedef StatusTestGenResNorm<ScalarType, MV, OP> res_norm_type;
578  typedef StatusTestCombo<ScalarType, MV, OP> combo_type;
579 
580  // Do we need to allocate at least one of the implicit or explicit
581  // residual norm convergence tests?
582  const bool allocatedConvergenceTests =
583  impConvTest_.is_null() || expConvTest_.is_null();
584 
585  // Allocate or set the tolerance of the implicit residual norm
586  // convergence test.
587  if (impConvTest_.is_null()) {
588  impConvTest_ = rcp (new res_norm_type (convtol_));
589  impConvTest_->defineResForm (res_norm_type::Implicit, TwoNorm);
590  // TODO (mfh 03 Nov 2011) Allow users to define the type of
591  // scaling (or a custom scaling factor).
592  impConvTest_->defineScaleForm (NormOfInitRes, TwoNorm);
593  } else {
594  impConvTest_->setTolerance (convtol_);
595  }
596 
597  // Allocate or set the tolerance of the explicit residual norm
598  // convergence test.
599  if (expConvTest_.is_null()) {
600  expConvTest_ = rcp (new res_norm_type (convtol_));
601  expConvTest_->defineResForm (res_norm_type::Explicit, TwoNorm);
602  // TODO (mfh 03 Nov 2011) Allow users to define the type of
603  // scaling (or a custom scaling factor).
604  expConvTest_->defineScaleForm (NormOfInitRes, TwoNorm);
605  } else {
606  expConvTest_->setTolerance (convtol_);
607  }
608 
609  // Whether we need to recreate the full status test. We only need
610  // to do that if at least one of convTest_ or maxIterTest_ had to
611  // be reallocated.
612  bool needToRecreateFullStatusTest = sTest_.is_null();
613 
614  // Residual status test is a combo of the implicit and explicit
615  // convergence tests.
616  if (convTest_.is_null() || allocatedConvergenceTests) {
617  convTest_ = rcp (new combo_type (combo_type::SEQ, impConvTest_, expConvTest_));
618  needToRecreateFullStatusTest = true;
619  }
620 
621  // Maximum number of iterations status test. It tells the solver to
622  // stop iteration, if the maximum number of iterations has been
623  // exceeded. Initialize it if we haven't yet done so, otherwise
624  // tell it the new maximum number of iterations.
625  if (maxIterTest_.is_null()) {
626  maxIterTest_ = rcp (new StatusTestMaxIters<ScalarType,MV,OP> (maxIters_));
627  needToRecreateFullStatusTest = true;
628  } else {
629  maxIterTest_->setMaxIters (maxIters_);
630  }
631 
632  // Create the full status test if we need to.
633  //
634  // The full status test: the maximum number of iterations have
635  // been reached, OR the residual has converged.
636  //
637  // "If we need to" means either that the status test was never
638  // created before, or that its two component tests had to be
639  // reallocated.
640  if (needToRecreateFullStatusTest) {
641  sTest_ = rcp (new combo_type (combo_type::OR, maxIterTest_, convTest_));
642  }
643 
644  // If necessary, create the status test output class. This class
645  // manages and formats the output from the status test. We have
646  // to recreate the output test if we had to (re)allocate either
647  // printer_ or sTest_.
648  if (outputTest_.is_null() || needToRecreateFullStatusTest || recreatedPrinter) {
649  StatusTestOutputFactory<ScalarType,MV,OP> stoFactory (outputStyle_);
650  outputTest_ = stoFactory.create (printer_, sTest_, outputFreq_,
652  } else {
653  outputTest_->setOutputFrequency (outputFreq_);
654  }
655  // Set the solver string for the output test.
656  // StatusTestOutputFactory has no constructor argument for this.
657  outputTest_->setSolverDesc (std::string (" MINRES "));
658 
659  // Inform the solver manager that the current parameters were set.
660  parametersSet_ = true;
661 
662  if (verbosity_ & Debug) {
663  using std::endl;
664 
665  std::ostream& dbg = printer_->stream (Debug);
666  dbg << "MINRES parameters:" << endl << params_ << endl;
667  }
668  }
669 
670 
671  template<class ScalarType, class MV, class OP>
673  {
674  using Teuchos::RCP;
675  using Teuchos::rcp;
676  using Teuchos::rcp_const_cast;
677  using std::endl;
678 
679  if (! parametersSet_) {
680  setParameters (params_);
681  }
682  std::ostream& dbg = printer_->stream (Debug);
683 
684 #ifdef BELOS_TEUCHOS_TIME_MONITOR
685  Teuchos::TimeMonitor solveTimerMonitor (*timerSolve_);
686 #endif // BELOS_TEUCHOS_TIME_MONITOR
687 
688  // We need a problem to solve, else we can't solve it.
689  validateProblem (problem_);
690 
691  // Reset the status test for this solve.
692  outputTest_->reset();
693 
694  // The linear problem has this many right-hand sides to solve.
695  // MINRES can solve only one at a time, so we solve for each
696  // right-hand side in succession.
697  const int numRHS2Solve = MVT::GetNumberVecs (*(problem_->getRHS()));
698 
699  // Create MINRES iteration object. Pass along the solver
700  // manager's parameters, which have already been validated.
701  typedef MinresIter<ScalarType, MV, OP> iter_type;
702  RCP<iter_type> minres_iter =
703  rcp (new iter_type (problem_, printer_, outputTest_, *params_));
704 
705  // The index/indices of the right-hand sides for which MINRES did
706  // _not_ converge. Hopefully this is empty after the for loop
707  // below! If it is not empty, at least one right-hand side did
708  // not converge.
709  std::vector<int> notConverged;
710  std::vector<int> currentIndices(1);
711 
712  numIters_ = 0;
713 
714  // Solve for each right-hand side in turn.
715  for (int currentRHS = 0; currentRHS < numRHS2Solve; ++currentRHS) {
716  // Inform the linear problem of the right-hand side(s) currently
717  // being solved. MINRES only knows how to solve linear problems
718  // with one right-hand side, so we only include one index, which
719  // is the index of the current right-hand side.
720  currentIndices[0] = currentRHS;
721  problem_->setLSIndex (currentIndices);
722 
723  dbg << "-- Current right-hand side index being solved: "
724  << currentRHS << endl;
725 
726  // Reset the number of iterations.
727  minres_iter->resetNumIters();
728  // Reset the number of calls that the status test output knows about.
729  outputTest_->resetNumCalls();
730  // Set the new state and initialize the solver.
732 
733  // Get the residual vector for the current linear system
734  // (that is, for the current right-hand side).
735  newstate.Y = MVT::CloneViewNonConst (*(rcp_const_cast<MV> (problem_->getInitResVec())), currentIndices);
736  minres_iter->initializeMinres (newstate);
737 
738  // Attempt to solve for the solution corresponding to the
739  // current right-hand side.
740  while (true) {
741  try {
742  minres_iter->iterate();
743 
744  // First check for convergence
745  if (convTest_->getStatus() == Passed) {
746  dbg << "---- Converged after " << maxIterTest_->getNumIters()
747  << " iterations" << endl;
748  break;
749  }
750  // Now check for max # of iterations
751  else if (maxIterTest_->getStatus() == Passed) {
752  dbg << "---- Did not converge after " << maxIterTest_->getNumIters()
753  << " iterations" << endl;
754  // This right-hand side didn't converge!
755  notConverged.push_back (currentRHS);
756  break;
757  } else {
758  // If we get here, we returned from iterate(), but none of
759  // our status tests Passed. Something is wrong, and it is
760  // probably our fault.
761  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
762  "Belos::MinresSolMgr::solve(): iterations neither converged, "
763  "nor reached the maximum number of iterations " << maxIters_
764  << ". That means something went wrong.");
765  }
766  }
767  catch (const StatusTestNaNError& e) {
768  // A NaN was detected in the solver. Set the solution to zero and return unconverged.
769  achievedTol_ = MST::one();
770  Teuchos::RCP<MV> X = problem_->getLHS();
771  MVT::MvInit( *X, SCT::zero() );
772  printer_->stream(Warnings) << "Belos::MinresSolMgr::solve(): Warning! NaN has been detected!"
773  << std::endl;
774  return Unconverged;
775  }
776  catch (const std::exception &e) {
777  printer_->stream (Errors)
778  << "Error! Caught std::exception in MinresIter::iterate() at "
779  << "iteration " << minres_iter->getNumIters() << endl
780  << e.what() << endl;
781  throw e;
782  }
783  }
784 
785  // Inform the linear problem that we are finished with the
786  // current right-hand side. It may or may not have converged,
787  // but we don't try again if the first time didn't work.
788  problem_->setCurrLS();
789 
790  // Get iteration information for this solve: total number of
791  // iterations for all right-hand sides.
792  numIters_ += maxIterTest_->getNumIters();
793  }
794 
795  // Print final summary of the solution process
796  sTest_->print (printer_->stream (FinalSummary));
797 
798  // Print timing information, if the corresponding compile-time and
799  // run-time options are enabled.
800 #ifdef BELOS_TEUCHOS_TIME_MONITOR
801  // Calling summarize() can be expensive, so don't call unless the
802  // user wants to print out timing details. summarize() will do all
803  // the work even if it's passed a "black hole" output stream.
804  if (verbosity_ & TimingDetails) {
805  Teuchos::TimeMonitor::summarize (printer_->stream (TimingDetails));
806  }
807 #endif // BELOS_TEUCHOS_TIME_MONITOR
808 
809  // Save the convergence test value ("achieved tolerance") for this
810  // solve. This solver always has two residual norm status tests:
811  // an explicit and an implicit test. The master convergence test
812  // convTest_ is a SEQ combo of the implicit resp. explicit tests.
813  // If the implicit test never passes, then the explicit test won't
814  // ever be executed. This manifests as
815  // expConvTest_->getTestValue()->size() < 1. We deal with this
816  // case by using the values returned by
817  // impConvTest_->getTestValue().
818  {
819  const std::vector<MagnitudeType>* pTestValues = expConvTest_->getTestValue();
820  if (pTestValues == NULL || pTestValues->size() < 1) {
821  pTestValues = impConvTest_->getTestValue();
822  }
823  TEUCHOS_TEST_FOR_EXCEPTION(pTestValues == NULL, std::logic_error,
824  "Belos::MinresSolMgr::solve(): The implicit convergence test's getTestValue() "
825  "method returned NULL. Please report this bug to the Belos developers.");
826  TEUCHOS_TEST_FOR_EXCEPTION(pTestValues->size() < 1, std::logic_error,
827  "Belos::MinresSolMgr::solve(): The implicit convergence test's getTestValue() "
828  "method returned a vector of length zero. Please report this bug to the "
829  "Belos developers.");
830 
831  // FIXME (mfh 12 Dec 2011) Does pTestValues really contain the
832  // achieved tolerances for all vectors in the current solve(), or
833  // just for the vectors from the last deflation?
834  achievedTol_ = *std::max_element (pTestValues->begin(), pTestValues->end());
835  }
836 
837  if (notConverged.size() > 0) {
838  return Unconverged;
839  } else {
840  return Converged;
841  }
842  }
843 
844  // This method requires the solver manager to return a std::string that describes itself.
845  template<class ScalarType, class MV, class OP>
847  {
848  std::ostringstream oss;
849  oss << "Belos::MinresSolMgr< "
851  <<", MV, OP >";
852  // oss << "{";
853  // oss << "Block Size=" << blockSize_;
854  // oss << "}";
855  return oss.str();
856  }
857 
858 } // end Belos namespace
859 
860 #endif /* BELOS_MINRES_SOLMGR_HPP */
int blockSize_
Current block size (i.e., number of right-hand sides): always 1 (one).
Collection of types and exceptions used within the Belos solvers.
Teuchos::RCP< StatusTestGenResNorm< ScalarType, MV, OP > > impConvTest_
The implicit (a.k.a.
Belos&#39;s basic output manager for sending information of select verbosity levels to the appropriate ou...
std::string label_
Timer label.
Teuchos::RCP< StatusTestMaxIters< ScalarType, MV, OP > > maxIterTest_
The status test for maximum iteration count.
Class which manages the output and verbosity of the Belos solvers.
Teuchos::Array< Teuchos::RCP< Teuchos::Time > > getTimers() const
Return all timers for this object.
Teuchos::RCP< Teuchos::ParameterList > params_
List of current parameters.
Teuchos::RCP< StatusTestGenResNorm< ScalarType, MV, OP > > expConvTest_
The explicit residual norm test.
OperatorTraits< ScalarType, MV, OP > OPT
virtual ~MinresSolMgr()
Destructor.
MINRES implementation.
static void clearCounter(const std::string &name)
int outputFreq_
Current frequency of output.
Teuchos::RCP< OutputManager< ScalarType > > printer_
Output manager.
static RCP< Time > getNewCounter(const std::string &name)
bool is_null(const std::shared_ptr< T > &p)
Teuchos::RCP< LinearProblem< ScalarType, MV, OP > > problem_
Linear problem to solve.
int getNumIters() const override
Get the iteration count for the most recent call to solve().
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
A factory class for generating StatusTestOutput objects.
static Teuchos::RCP< const Teuchos::ParameterList > defaultParameters()
List of valid MINRES parameters and their default values.
static void validateProblem(const Teuchos::RCP< LinearProblem< ScalarType, MV, OP > > &problem)
Validate the given linear problem.
An implementation of StatusTestResNorm using a family of residual norms.
Teuchos::ScalarTraits< MagnitudeType > MST
Belos::StatusTest class for specifying a maximum number of iterations.
static std::string name()
A factory class for generating StatusTestOutput objects.
Teuchos::RCP< SolverManager< ScalarType, MV, OP > > clone() const override
clone for Inverted Injection (DII)
Traits class which defines basic operations on multivectors.
Belos::StatusTest for logically combining several status tests.
const LinearProblem< ScalarType, MV, OP > & getProblem() const override
Return the linear problem to be solved.
MinresSolMgrLinearProblemFailure(const std::string &what_arg)
A Belos::StatusTest class for specifying a maximum number of iterations.
ResetType
How to reset the solver.
Definition: BelosTypes.hpp:206
MagnitudeType achievedTol() const override
Tolerance achieved by the last solve() invocation.
void setParameters(const Teuchos::RCP< Teuchos::ParameterList > &params) override
Set the parameters to use when solving the linear problem.
This subclass of std::exception may be thrown from the MinresSolMgr::solve() method.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Pure virtual base class which describes the basic interface for a solver manager. ...
MagnitudeType achievedTol_
Tolerance achieved by the last solve() invocation.
bool parametersSet_
Whether the solver manager&#39;s parameters have been set.
Teuchos::RCP< StatusTestOutput< ScalarType, MV, OP > > outputTest_
The &quot;status test&quot; that handles output.
static void summarize(Ptr< const Comm< int > > comm, std::ostream &out=std::cout, const bool alwaysWriteLocal=false, const bool writeGlobalStats=true, const bool writeZeroTimers=true, const ECounterSetOp setOp=Intersection, const std::string &filter="", const bool ignoreZeroTimers=false)
bool is_null(const RCP< T > &p)
Teuchos::RCP< const Teuchos::ParameterList > defaultParams_
List of default parameters.
MINRES linear solver solution manager.
Teuchos::RCP< Teuchos::Time > timerSolve_
Total time to solution.
int maxIters_
Maximum number of iterations before stopping.
MINRES iteration implementation.
std::string description() const override
A linear system to solve, and its associated information.
Teuchos::ScalarTraits< ScalarType > SCT
Class which describes the linear problem to be solved by the iterative solver.
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const override
Return the list of default parameters for this object.
Teuchos::ScalarTraits< ScalarType >::magnitudeType MagnitudeType
Structure to contain pointers to MinresIteration state variables.
void validateParametersAndSetDefaults(ParameterList const &validParamList, int const depth=1000)
ReturnType
Whether the Belos solve converged for all linear systems.
Definition: BelosTypes.hpp:155
int numIters_
Current number of iterations.
The Belos::SolverManager is a templated virtual base class that defines the basic interface that any ...
Teuchos::RCP< const Teuchos::ParameterList > getCurrentParameters() const override
Return the list of current parameters for this object.
Teuchos::RCP< StatusTest< ScalarType, MV, OP > > convTest_
The combined status test for convergence.
Teuchos::RCP< std::ostream > outputStream_
void reset(const ResetType type) override
Reset the solver manager.
void setProblem(const Teuchos::RCP< LinearProblem< ScalarType, MV, OP > > &problem) override
Set the linear problem that needs to be solved.
Teuchos::RCP< const MV > Y
The current residual.
Teuchos::RCP< StatusTestOutput< ScalarType, MV, OP > > create(const Teuchos::RCP< OutputManager< ScalarType > > &printer, Teuchos::RCP< StatusTest< ScalarType, MV, OP > > test, int mod, int printStates)
Create the StatusTestOutput object specified by the outputStyle.
Belos::StatusTestResNorm for specifying general residual norm stopping criteria.
A class for extending the status testing capabilities of Belos via logical combinations.
MinresSolMgr()
Default constructor.
MagnitudeType convtol_
Current relative residual 2-norm convergence tolerance.
Class which defines basic traits for the operator type.
Parent class to all Belos exceptions.
Definition: BelosTypes.hpp:60
Belos header file which uses auto-configuration information to include necessary C++ headers...
Teuchos::RCP< StatusTest< ScalarType, MV, OP > > sTest_
The full status test.
ReturnType solve() override
Iterate until the status test tells us to stop.
int verbosity_
Current output verbosity.
MultiVecTraits< ScalarType, MV > MVT
bool isLOADetected() const override
Whether a loss of accuracy was detected in the solver.
int outputStyle_
Current output style.