Belos  Version of the Day
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 #include "Teuchos_BLAS.hpp"
61 #include "Teuchos_LAPACK.hpp"
62 #ifdef BELOS_TEUCHOS_TIME_MONITOR
63 #include "Teuchos_TimeMonitor.hpp"
64 #endif
65 
66 #include "Teuchos_StandardParameterEntryValidators.hpp"
67 // Teuchos::ScalarTraits<int> doesn't define rmax(), alas, so we get
68 // INT_MAX from here.
69 #include <climits>
70 
71 namespace Belos {
72 
74 
75 
85  //
90  public:
91  MinresSolMgrLinearProblemFailure (const std::string& what_arg) :
92  BelosError(what_arg)
93  {}
94  };
95 
114  template<class ScalarType, class MV, class OP>
115  class MinresSolMgr : public SolverManager<ScalarType,MV,OP> {
116 
117  private:
120  typedef Teuchos::ScalarTraits<ScalarType> SCT;
121  typedef typename Teuchos::ScalarTraits<ScalarType>::magnitudeType MagnitudeType;
122  typedef Teuchos::ScalarTraits< MagnitudeType > MT;
123 
124  public:
125 
137  static Teuchos::RCP<const Teuchos::ParameterList> defaultParameters();
138 
140 
141 
150  MinresSolMgr();
151 
178  MinresSolMgr (const Teuchos::RCP<LinearProblem< ScalarType, MV, OP> > &problem,
179  const Teuchos::RCP<Teuchos::ParameterList> &params);
180 
182  virtual ~MinresSolMgr() {};
184 
186 
187 
190  return *problem_;
191  }
192 
194  Teuchos::RCP<const Teuchos::ParameterList> getValidParameters() const {
195  if (defaultParams_.is_null()) {
196  defaultParams_ = defaultParameters ();
197  }
198  return defaultParams_;
199  }
200 
202  Teuchos::RCP<const Teuchos::ParameterList> getCurrentParameters() const {
203  return params_;
204  }
205 
215  Teuchos::Array<Teuchos::RCP<Teuchos::Time> > getTimers() const {
216  return Teuchos::tuple (timerSolve_);
217  }
218 
224  MagnitudeType achievedTol() const {
225  return achievedTol_;
226  }
227 
229  int getNumIters() const {
230  return numIters_;
231  }
232 
238  bool isLOADetected() const { return false; }
239 
241 
243 
244 
245  void
246  setProblem (const Teuchos::RCP<LinearProblem<ScalarType, MV, OP> > &problem)
247  {
248  problem_ = problem;
249  }
250 
251  void
252  setParameters (const Teuchos::RCP<Teuchos::ParameterList>& params);
253 
255 
257 
258 
259  void
260  reset (const ResetType type)
261  {
262  if ((type & Belos::Problem) && ! problem_.is_null()) {
263  problem_->setProblem ();
264  }
265  }
267 
269 
270 
288  ReturnType solve();
289 
291 
294 
295  std::string description() const;
296 
298 
299  private:
301  Teuchos::RCP<LinearProblem<ScalarType,MV,OP> > problem_;
302 
304  Teuchos::RCP<OutputManager<ScalarType> > printer_;
305  Teuchos::RCP<std::ostream> outputStream_;
306 
313  Teuchos::RCP<StatusTest<ScalarType,MV,OP> > sTest_;
314 
318  Teuchos::RCP<StatusTestMaxIters<ScalarType,MV,OP> > maxIterTest_;
319 
323  Teuchos::RCP<StatusTest<ScalarType,MV,OP> > convTest_;
324 
328  Teuchos::RCP<StatusTestGenResNorm<ScalarType,MV,OP> > impConvTest_;
329 
333  Teuchos::RCP<StatusTestGenResNorm<ScalarType,MV,OP> > expConvTest_;
334 
339  Teuchos::RCP<StatusTestOutput<ScalarType,MV,OP> > outputTest_;
340 
344  mutable Teuchos::RCP<const Teuchos::ParameterList> defaultParams_;
345 
347  Teuchos::RCP<Teuchos::ParameterList> params_;
348 
350  MagnitudeType convtol_;
351 
353  MagnitudeType achievedTol_;
354 
356  int maxIters_;
357 
359  int numIters_;
360 
362  int blockSize_;
363 
365  int verbosity_;
366 
368  int outputStyle_;
369 
371  int outputFreq_;
372 
374  std::string label_;
375 
377  Teuchos::RCP<Teuchos::Time> timerSolve_;
378 
380  bool parametersSet_;
381 
387  static void
388  validateProblem (const Teuchos::RCP<LinearProblem<ScalarType, MV, OP> >& problem);
389  };
390 
391 
392  template<class ScalarType, class MV, class OP>
393  Teuchos::RCP<const Teuchos::ParameterList>
395  {
396  using Teuchos::ParameterList;
397  using Teuchos::parameterList;
398  using Teuchos::RCP;
399  using Teuchos::rcp;
400  using Teuchos::rcpFromRef;
401  using Teuchos::EnhancedNumberValidator;
402  typedef MagnitudeType MT;
403  typedef Teuchos::ScalarTraits<MT> MST;
404 
405  // List of parameters accepted by MINRES, and their default values.
406  RCP<ParameterList> pl = parameterList ("MINRES");
407 
408  pl->set ("Convergence Tolerance", MST::squareroot (MST::eps()),
409  "Relative residual tolerance that needs to be achieved by "
410  "the iterative solver, in order for the linear system to be "
411  "declared converged.",
412  rcp (new EnhancedNumberValidator<MT> (MST::zero(), MST::rmax())));
413  pl->set ("Maximum Iterations", static_cast<int>(1000),
414  "Maximum number of iterations allowed for each right-hand "
415  "side solved.",
416  rcp (new EnhancedNumberValidator<int> (0, INT_MAX)));
417  pl->set ("Block Size", static_cast<int>(1),
418  "Number of vectors in each block. WARNING: The current "
419  "implementation of MINRES only accepts a block size of 1, "
420  "since it can only solve for 1 right-hand side at a time.",
421  rcp (new EnhancedNumberValidator<int> (1, 1)));
422  pl->set ("Verbosity", (int) Belos::Errors,
423  "The type(s) of solver information that should "
424  "be written to the output stream.");
425  pl->set ("Output Style", (int) Belos::General,
426  "What style is used for the solver information written "
427  "to the output stream.");
428  pl->set ("Output Frequency", static_cast<int>(-1),
429  "How often (in terms of number of iterations) intermediate "
430  "convergence information should be written to the output stream."
431  " -1 means never.");
432  pl->set ("Output Stream", rcpFromRef(std::cout),
433  "A reference-counted pointer to the output stream where all "
434  "solver output is sent. The output stream defaults to stdout.");
435  pl->set ("Timer Label", std::string("Belos"),
436  "The string to use as a prefix for the timer labels.");
437  return pl;
438  }
439 
440  //
441  // Empty Constructor
442  //
443  template<class ScalarType, class MV, class OP>
445  numIters_ (0),
446  parametersSet_ (false)
447  {}
448 
449  //
450  // Primary constructor (use this one)
451  //
452  template<class ScalarType, class MV, class OP>
454  MinresSolMgr (const Teuchos::RCP<LinearProblem<ScalarType, MV, OP> > &problem,
455  const Teuchos::RCP<Teuchos::ParameterList>& params) :
456  problem_ (problem),
457  numIters_ (0),
458  parametersSet_ (false)
459  {
460  TEUCHOS_TEST_FOR_EXCEPTION(problem_.is_null(), std::invalid_argument,
461  "MinresSolMgr: The version of the constructor "
462  "that takes a LinearProblem to solve was given a "
463  "null LinearProblem.");
464  setParameters (params);
465  }
466 
467  template<class ScalarType, class MV, class OP>
468  void
470  validateProblem (const Teuchos::RCP<LinearProblem<ScalarType, MV, OP> >& problem)
471  {
472  TEUCHOS_TEST_FOR_EXCEPTION(problem.is_null(),
474  "MINRES requires that you have provided a nonnull LinearProblem to the "
475  "solver manager, before you call the solve() method.");
476  TEUCHOS_TEST_FOR_EXCEPTION(problem->getOperator().is_null(),
478  "MINRES requires a LinearProblem object with a non-null operator (the "
479  "matrix A).");
480  TEUCHOS_TEST_FOR_EXCEPTION(problem->getRHS().is_null(),
482  "MINRES requires a LinearProblem object with a non-null right-hand side.");
483  TEUCHOS_TEST_FOR_EXCEPTION( ! problem->isProblemSet(),
485  "MINRES requires that before you give it a LinearProblem to solve, you "
486  "must first call the linear problem's setProblem() method.");
487  }
488 
489  template<class ScalarType, class MV, class OP>
490  void
492  setParameters (const Teuchos::RCP<Teuchos::ParameterList>& params)
493  {
494  using Teuchos::ParameterList;
495  using Teuchos::parameterList;
496  using Teuchos::RCP;
497  using Teuchos::rcp;
498  using Teuchos::rcpFromRef;
499  using Teuchos::null;
500  using Teuchos::is_null;
501  using std::string;
502  using std::ostream;
503  using std::endl;
504 
505  if (params_.is_null()) {
506  params_ = parameterList (*getValidParameters());
507  }
508  RCP<ParameterList> pl = params;
509  pl->validateParametersAndSetDefaults (*params_);
510 
511  //
512  // Read parameters from the parameter list. We have already
513  // populated it with defaults.
514  //
515  blockSize_ = pl->get<int> ("Block Size");
516  verbosity_ = pl->get<int> ("Verbosity");
517  outputStyle_ = pl->get<int> ("Output Style");
518  outputFreq_ = pl->get<int>("Output Frequency");
519  outputStream_ = pl->get<RCP<std::ostream> > ("Output Stream");
520  convtol_ = pl->get<MagnitudeType> ("Convergence Tolerance");
521  maxIters_ = pl->get<int> ("Maximum Iterations");
522  //
523  // All done reading parameters from the parameter list.
524  // Now we know it's valid and we can store it.
525  //
526  params_ = pl;
527 
528  // Change the timer label, and create the timer if necessary.
529  const string newLabel = pl->get<string> ("Timer Label");
530  {
531  if (newLabel != label_ || timerSolve_.is_null()) {
532  label_ = newLabel;
533 #ifdef BELOS_TEUCHOS_TIME_MONITOR
534  const string solveLabel = label_ + ": MinresSolMgr total solve time";
535  // Unregister the old timer before creating a new one.
536  if (! timerSolve_.is_null()) {
537  Teuchos::TimeMonitor::clearCounter (label_);
538  timerSolve_ = Teuchos::null;
539  }
540  timerSolve_ = Teuchos::TimeMonitor::getNewCounter (solveLabel);
541 #endif // BELOS_TEUCHOS_TIME_MONITOR
542  }
543  }
544 
545  // Create output manager, if necessary; otherwise, set its parameters.
546  bool recreatedPrinter = false;
547  if (printer_.is_null()) {
548  printer_ = rcp (new OutputManager<ScalarType> (verbosity_, outputStream_));
549  recreatedPrinter = true;
550  } else {
551  // Set the output stream's verbosity level.
552  printer_->setVerbosity (verbosity_);
553  // Tell the output manager about the new output stream.
554  printer_->setOStream (outputStream_);
555  }
556 
557  //
558  // Set up the convergence tests
559  //
560  typedef StatusTestGenResNorm<ScalarType, MV, OP> res_norm_type;
561  typedef StatusTestCombo<ScalarType, MV, OP> combo_type;
562 
563  // Do we need to allocate at least one of the implicit or explicit
564  // residual norm convergence tests?
565  const bool allocatedConvergenceTests =
566  impConvTest_.is_null() || expConvTest_.is_null();
567 
568  // Allocate or set the tolerance of the implicit residual norm
569  // convergence test.
570  if (impConvTest_.is_null()) {
571  impConvTest_ = rcp (new res_norm_type (convtol_));
572  impConvTest_->defineResForm (res_norm_type::Implicit, TwoNorm);
573  // TODO (mfh 03 Nov 2011) Allow users to define the type of
574  // scaling (or a custom scaling factor).
575  impConvTest_->defineScaleForm (NormOfInitRes, TwoNorm);
576  } else {
577  impConvTest_->setTolerance (convtol_);
578  }
579 
580  // Allocate or set the tolerance of the explicit residual norm
581  // convergence test.
582  if (expConvTest_.is_null()) {
583  expConvTest_ = rcp (new res_norm_type (convtol_));
584  expConvTest_->defineResForm (res_norm_type::Explicit, TwoNorm);
585  // TODO (mfh 03 Nov 2011) Allow users to define the type of
586  // scaling (or a custom scaling factor).
587  expConvTest_->defineScaleForm (NormOfInitRes, TwoNorm);
588  } else {
589  expConvTest_->setTolerance (convtol_);
590  }
591 
592  // Whether we need to recreate the full status test. We only need
593  // to do that if at least one of convTest_ or maxIterTest_ had to
594  // be reallocated.
595  bool needToRecreateFullStatusTest = sTest_.is_null();
596 
597  // Residual status test is a combo of the implicit and explicit
598  // convergence tests.
599  if (convTest_.is_null() || allocatedConvergenceTests) {
600  convTest_ = rcp (new combo_type (combo_type::SEQ, impConvTest_, expConvTest_));
601  needToRecreateFullStatusTest = true;
602  }
603 
604  // Maximum number of iterations status test. It tells the solver to
605  // stop iteration, if the maximum number of iterations has been
606  // exceeded. Initialize it if we haven't yet done so, otherwise
607  // tell it the new maximum number of iterations.
608  if (maxIterTest_.is_null()) {
609  maxIterTest_ = rcp (new StatusTestMaxIters<ScalarType,MV,OP> (maxIters_));
610  needToRecreateFullStatusTest = true;
611  } else {
612  maxIterTest_->setMaxIters (maxIters_);
613  }
614 
615  // Create the full status test if we need to.
616  //
617  // The full status test: the maximum number of iterations have
618  // been reached, OR the residual has converged.
619  //
620  // "If we need to" means either that the status test was never
621  // created before, or that its two component tests had to be
622  // reallocated.
623  if (needToRecreateFullStatusTest) {
624  sTest_ = rcp (new combo_type (combo_type::OR, maxIterTest_, convTest_));
625  }
626 
627  // If necessary, create the status test output class. This class
628  // manages and formats the output from the status test. We have
629  // to recreate the output test if we had to (re)allocate either
630  // printer_ or sTest_.
631  if (outputTest_.is_null() || needToRecreateFullStatusTest || recreatedPrinter) {
632  StatusTestOutputFactory<ScalarType,MV,OP> stoFactory (outputStyle_);
633  outputTest_ = stoFactory.create (printer_, sTest_, outputFreq_,
635  } else {
636  outputTest_->setOutputFrequency (outputFreq_);
637  }
638  // Set the solver string for the output test.
639  // StatusTestOutputFactory has no constructor argument for this.
640  outputTest_->setSolverDesc (std::string (" MINRES "));
641 
642  // Inform the solver manager that the current parameters were set.
643  parametersSet_ = true;
644 
645  if (verbosity_ & Debug) {
646  using std::endl;
647 
648  std::ostream& dbg = printer_->stream (Debug);
649  dbg << "MINRES parameters:" << endl << params_ << endl;
650  }
651  }
652 
653 
654  template<class ScalarType, class MV, class OP>
656  {
657  using Teuchos::RCP;
658  using Teuchos::rcp;
659  using Teuchos::rcp_const_cast;
660  using std::endl;
661 
662  if (! parametersSet_) {
663  setParameters (params_);
664  }
665  std::ostream& dbg = printer_->stream (Debug);
666 
667 #ifdef BELOS_TEUCHOS_TIME_MONITOR
668  Teuchos::TimeMonitor solveTimerMonitor (*timerSolve_);
669 #endif // BELOS_TEUCHOS_TIME_MONITOR
670 
671  // We need a problem to solve, else we can't solve it.
672  validateProblem (problem_);
673 
674  // Reset the status test for this solve.
675  outputTest_->reset();
676 
677  // The linear problem has this many right-hand sides to solve.
678  // MINRES can solve only one at a time, so we solve for each
679  // right-hand side in succession.
680  const int numRHS2Solve = MVT::GetNumberVecs (*(problem_->getRHS()));
681 
682  // Create MINRES iteration object. Pass along the solver
683  // manager's parameters, which have already been validated.
684  typedef MinresIter<ScalarType, MV, OP> iter_type;
685  RCP<iter_type> minres_iter =
686  rcp (new iter_type (problem_, printer_, outputTest_, *params_));
687 
688  // The index/indices of the right-hand sides for which MINRES did
689  // _not_ converge. Hopefully this is empty after the for loop
690  // below! If it is not empty, at least one right-hand side did
691  // not converge.
692  std::vector<int> notConverged;
693  std::vector<int> currentIndices(1);
694 
695  numIters_ = 0;
696 
697  // Solve for each right-hand side in turn.
698  for (int currentRHS = 0; currentRHS < numRHS2Solve; ++currentRHS) {
699  // Inform the linear problem of the right-hand side(s) currently
700  // being solved. MINRES only knows how to solve linear problems
701  // with one right-hand side, so we only include one index, which
702  // is the index of the current right-hand side.
703  currentIndices[0] = currentRHS;
704  problem_->setLSIndex (currentIndices);
705 
706  dbg << "-- Current right-hand side index being solved: "
707  << currentRHS << endl;
708 
709  // Reset the number of iterations.
710  minres_iter->resetNumIters();
711  // Reset the number of calls that the status test output knows about.
712  outputTest_->resetNumCalls();
713  // Set the new state and initialize the solver.
715 
716  // Get the residual vector for the current linear system
717  // (that is, for the current right-hand side).
718  newstate.Y = MVT::CloneViewNonConst (*(rcp_const_cast<MV> (problem_->getInitResVec())), currentIndices);
719  minres_iter->initializeMinres (newstate);
720 
721  // Attempt to solve for the solution corresponding to the
722  // current right-hand side.
723  while (true) {
724  try {
725  minres_iter->iterate();
726 
727  // First check for convergence
728  if (convTest_->getStatus() == Passed) {
729  dbg << "---- Converged after " << maxIterTest_->getNumIters()
730  << " iterations" << endl;
731  break;
732  }
733  // Now check for max # of iterations
734  else if (maxIterTest_->getStatus() == Passed) {
735  dbg << "---- Did not converge after " << maxIterTest_->getNumIters()
736  << " iterations" << endl;
737  // This right-hand side didn't converge!
738  notConverged.push_back (currentRHS);
739  break;
740  } else {
741  // If we get here, we returned from iterate(), but none of
742  // our status tests Passed. Something is wrong, and it is
743  // probably our fault.
744  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
745  "Belos::MinresSolMgr::solve(): iterations neither converged, "
746  "nor reached the maximum number of iterations " << maxIters_
747  << ". That means something went wrong.");
748  }
749  } catch (const std::exception &e) {
750  printer_->stream (Errors)
751  << "Error! Caught std::exception in MinresIter::iterate() at "
752  << "iteration " << minres_iter->getNumIters() << endl
753  << e.what() << endl;
754  throw e;
755  }
756  }
757 
758  // Inform the linear problem that we are finished with the
759  // current right-hand side. It may or may not have converged,
760  // but we don't try again if the first time didn't work.
761  problem_->setCurrLS();
762 
763  // Get iteration information for this solve: total number of
764  // iterations for all right-hand sides.
765  numIters_ += maxIterTest_->getNumIters();
766  }
767 
768  // Print final summary of the solution process
769  sTest_->print (printer_->stream (FinalSummary));
770 
771  // Print timing information, if the corresponding compile-time and
772  // run-time options are enabled.
773 #ifdef BELOS_TEUCHOS_TIME_MONITOR
774  // Calling summarize() can be expensive, so don't call unless the
775  // user wants to print out timing details. summarize() will do all
776  // the work even if it's passed a "black hole" output stream.
777  if (verbosity_ & TimingDetails) {
778  Teuchos::TimeMonitor::summarize (printer_->stream (TimingDetails));
779  }
780 #endif // BELOS_TEUCHOS_TIME_MONITOR
781 
782  // Save the convergence test value ("achieved tolerance") for this
783  // solve. This solver always has two residual norm status tests:
784  // an explicit and an implicit test. The master convergence test
785  // convTest_ is a SEQ combo of the implicit resp. explicit tests.
786  // If the implicit test never passes, then the explicit test won't
787  // ever be executed. This manifests as
788  // expConvTest_->getTestValue()->size() < 1. We deal with this
789  // case by using the values returned by
790  // impConvTest_->getTestValue().
791  {
792  const std::vector<MagnitudeType>* pTestValues = expConvTest_->getTestValue();
793  if (pTestValues == NULL || pTestValues->size() < 1) {
794  pTestValues = impConvTest_->getTestValue();
795  }
796  TEUCHOS_TEST_FOR_EXCEPTION(pTestValues == NULL, std::logic_error,
797  "Belos::MinresSolMgr::solve(): The implicit convergence test's getTestValue() "
798  "method returned NULL. Please report this bug to the Belos developers.");
799  TEUCHOS_TEST_FOR_EXCEPTION(pTestValues->size() < 1, std::logic_error,
800  "Belos::MinresSolMgr::solve(): The implicit 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 (notConverged.size() > 0) {
811  return Unconverged;
812  } else {
813  return Converged;
814  }
815  }
816 
817  // This method requires the solver manager to return a std::string that describes itself.
818  template<class ScalarType, class MV, class OP>
820  {
821  std::ostringstream oss;
822  oss << "Belos::MinresSolMgr< "
823  << Teuchos::ScalarTraits<ScalarType>::name()
824  <<", MV, OP >";
825  // oss << "{";
826  // oss << "Block Size=" << blockSize_;
827  // oss << "}";
828  return oss.str();
829  }
830 
831 } // end Belos namespace
832 
833 #endif /* BELOS_MINRES_SOLMGR_HPP */
Collection of types and exceptions used within the Belos solvers.
Belos&#39;s basic output manager for sending information of select verbosity levels to the appropriate ou...
ReturnType solve()
Iterate until the status test tells us to stop.
Class which manages the output and verbosity of the Belos solvers.
void setProblem(const Teuchos::RCP< LinearProblem< ScalarType, MV, OP > > &problem)
Set the linear problem that needs to be solved.
Teuchos::Array< Teuchos::RCP< Teuchos::Time > > getTimers() const
Return all timers for this object.
virtual ~MinresSolMgr()
Destructor.
MINRES implementation.
A factory class for generating StatusTestOutput objects.
static Teuchos::RCP< const Teuchos::ParameterList > defaultParameters()
List of valid MINRES parameters and their default values.
An implementation of StatusTestResNorm using a family of residual norms.
Belos::StatusTest class for specifying a maximum number of iterations.
void reset(const ResetType type)
Reset the solver manager.
static int GetNumberVecs(const MV &mv)
Obtain the number of vectors in mv.
A factory class for generating StatusTestOutput objects.
Traits class which defines basic operations on multivectors.
Belos::StatusTest for logically combining several status tests.
MinresSolMgrLinearProblemFailure(const std::string &what_arg)
A Belos::StatusTest class for specifying a maximum number of iterations.
static Teuchos::RCP< MV > CloneViewNonConst(MV &mv, const std::vector< int > &index)
Creates a new MV that shares the selected contents of mv (shallow copy).
ResetType
How to reset the solver.
Definition: BelosTypes.hpp:200
This subclass of std::exception may be thrown from the MinresSolMgr::solve() method.
Pure virtual base class which describes the basic interface for a solver manager. ...
MINRES linear solver solution manager.
MINRES iteration implementation.
A linear system to solve, and its associated information.
Class which describes the linear problem to be solved by the iterative solver.
Structure to contain pointers to MinresIteration state variables.
Teuchos::RCP< const Teuchos::ParameterList > getCurrentParameters() const
Return the list of current parameters for this object.
bool isLOADetected() const
Whether a loss of accuracy was detected in the solver.
MagnitudeType achievedTol() const
Tolerance achieved by the last solve() invocation.
ReturnType
Whether the Belos solve converged for all linear systems.
Definition: BelosTypes.hpp:149
The Belos::SolverManager is a templated virtual base class that defines the basic interface that any ...
std::string description() const
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.
Class which defines basic traits for the operator type.
Parent class to all Belos exceptions.
Definition: BelosTypes.hpp:60
int getNumIters() const
Get the iteration count for the most recent call to solve().
Belos header file which uses auto-configuration information to include necessary C++ headers...
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const
Return the list of default parameters for this object.
const LinearProblem< ScalarType, MV, OP > & getProblem() const
Return the linear problem to be solved.
void setParameters(const Teuchos::RCP< Teuchos::ParameterList > &params)
Set the parameters to use when solving the linear problem.