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 
183  MinresSolMgr (const Teuchos::RCP<LinearProblem< ScalarType, MV, OP> > &problem,
184  const Teuchos::RCP<Teuchos::ParameterList> &params);
185 
187  virtual ~MinresSolMgr() {};
189 
191 
192 
195  return *problem_;
196  }
197 
199  Teuchos::RCP<const Teuchos::ParameterList> getValidParameters() const {
200  if (defaultParams_.is_null()) {
201  defaultParams_ = defaultParameters ();
202  }
203  return defaultParams_;
204  }
205 
207  Teuchos::RCP<const Teuchos::ParameterList> getCurrentParameters() const {
208  return params_;
209  }
210 
220  Teuchos::Array<Teuchos::RCP<Teuchos::Time> > getTimers() const {
221  return Teuchos::tuple (timerSolve_);
222  }
223 
229  MagnitudeType achievedTol() const {
230  return achievedTol_;
231  }
232 
234  int getNumIters() const {
235  return numIters_;
236  }
237 
243  bool isLOADetected() const { return false; }
244 
246 
248 
249 
250  void
251  setProblem (const Teuchos::RCP<LinearProblem<ScalarType, MV, OP> > &problem)
252  {
253  problem_ = problem;
254  }
255 
256  void
257  setParameters (const Teuchos::RCP<Teuchos::ParameterList>& params);
258 
260 
262 
263 
264  void
265  reset (const ResetType type)
266  {
267  if ((type & Belos::Problem) && ! problem_.is_null()) {
268  problem_->setProblem ();
269  }
270  }
272 
274 
275 
293  ReturnType solve();
294 
296 
299 
300  std::string description() const;
301 
303 
304  private:
306  Teuchos::RCP<LinearProblem<ScalarType,MV,OP> > problem_;
307 
309  Teuchos::RCP<OutputManager<ScalarType> > printer_;
310  Teuchos::RCP<std::ostream> outputStream_;
311 
318  Teuchos::RCP<StatusTest<ScalarType,MV,OP> > sTest_;
319 
323  Teuchos::RCP<StatusTestMaxIters<ScalarType,MV,OP> > maxIterTest_;
324 
328  Teuchos::RCP<StatusTest<ScalarType,MV,OP> > convTest_;
329 
333  Teuchos::RCP<StatusTestGenResNorm<ScalarType,MV,OP> > impConvTest_;
334 
338  Teuchos::RCP<StatusTestGenResNorm<ScalarType,MV,OP> > expConvTest_;
339 
344  Teuchos::RCP<StatusTestOutput<ScalarType,MV,OP> > outputTest_;
345 
349  mutable Teuchos::RCP<const Teuchos::ParameterList> defaultParams_;
350 
352  Teuchos::RCP<Teuchos::ParameterList> params_;
353 
355  MagnitudeType convtol_;
356 
358  MagnitudeType achievedTol_;
359 
361  int maxIters_;
362 
364  int numIters_;
365 
367  int blockSize_;
368 
370  int verbosity_;
371 
373  int outputStyle_;
374 
376  int outputFreq_;
377 
379  std::string label_;
380 
382  Teuchos::RCP<Teuchos::Time> timerSolve_;
383 
385  bool parametersSet_;
386 
392  static void
393  validateProblem (const Teuchos::RCP<LinearProblem<ScalarType, MV, OP> >& problem);
394  };
395 
396 
397  template<class ScalarType, class MV, class OP>
398  Teuchos::RCP<const Teuchos::ParameterList>
400  {
401  using Teuchos::ParameterList;
402  using Teuchos::parameterList;
403  using Teuchos::RCP;
404  using Teuchos::rcp;
405  using Teuchos::rcpFromRef;
406  using Teuchos::EnhancedNumberValidator;
407  typedef MagnitudeType MT;
408  typedef Teuchos::ScalarTraits<MT> MST;
409 
410  // List of parameters accepted by MINRES, and their default values.
411  RCP<ParameterList> pl = parameterList ("MINRES");
412 
413  pl->set ("Convergence Tolerance", MST::squareroot (MST::eps()),
414  "Relative residual tolerance that needs to be achieved by "
415  "the iterative solver, in order for the linear system to be "
416  "declared converged.",
417  rcp (new EnhancedNumberValidator<MT> (MST::zero(), MST::rmax())));
418  pl->set ("Maximum Iterations", static_cast<int>(1000),
419  "Maximum number of iterations allowed for each right-hand "
420  "side solved.",
421  rcp (new EnhancedNumberValidator<int> (0, INT_MAX)));
422  pl->set ("Num Blocks", static_cast<int> (-1),
423  "Ignored, but permitted, for compatibility with other Belos "
424  "solvers.");
425  pl->set ("Block Size", static_cast<int> (1),
426  "Number of vectors in each block. WARNING: The current "
427  "implementation of MINRES only accepts a block size of 1, "
428  "since it can only solve for 1 right-hand side at a time.",
429  rcp (new EnhancedNumberValidator<int> (1, 1)));
430  pl->set ("Verbosity", (int) Belos::Errors,
431  "The type(s) of solver information that should "
432  "be written to the output stream.");
433  pl->set ("Output Style", (int) Belos::General,
434  "What style is used for the solver information written "
435  "to the output stream.");
436  pl->set ("Output Frequency", static_cast<int>(-1),
437  "How often (in terms of number of iterations) intermediate "
438  "convergence information should be written to the output stream."
439  " -1 means never.");
440  pl->set ("Output Stream", rcpFromRef(std::cout),
441  "A reference-counted pointer to the output stream where all "
442  "solver output is sent. The output stream defaults to stdout.");
443  pl->set ("Timer Label", std::string("Belos"),
444  "The string to use as a prefix for the timer labels.");
445  return pl;
446  }
447 
448  //
449  // Empty Constructor
450  //
451  template<class ScalarType, class MV, class OP>
453  convtol_(0.0),
454  achievedTol_(0.0),
455  maxIters_(0),
456  numIters_ (0),
457  blockSize_(0),
458  verbosity_(0),
459  outputStyle_(0),
460  outputFreq_(0),
461  parametersSet_ (false)
462  {}
463 
464  //
465  // Primary constructor (use this one)
466  //
467  template<class ScalarType, class MV, class OP>
469  MinresSolMgr (const Teuchos::RCP<LinearProblem<ScalarType, MV, OP> > &problem,
470  const Teuchos::RCP<Teuchos::ParameterList>& params) :
471  problem_ (problem),
472  numIters_ (0),
473  parametersSet_ (false)
474  {
475  TEUCHOS_TEST_FOR_EXCEPTION(problem_.is_null(), std::invalid_argument,
476  "MinresSolMgr: The version of the constructor "
477  "that takes a LinearProblem to solve was given a "
478  "null LinearProblem.");
479  setParameters (params);
480  }
481 
482  template<class ScalarType, class MV, class OP>
483  void
485  validateProblem (const Teuchos::RCP<LinearProblem<ScalarType, MV, OP> >& problem)
486  {
487  TEUCHOS_TEST_FOR_EXCEPTION(problem.is_null(),
489  "MINRES requires that you have provided a nonnull LinearProblem to the "
490  "solver manager, before you call the solve() method.");
491  TEUCHOS_TEST_FOR_EXCEPTION(problem->getOperator().is_null(),
493  "MINRES requires a LinearProblem object with a non-null operator (the "
494  "matrix A).");
495  TEUCHOS_TEST_FOR_EXCEPTION(problem->getRHS().is_null(),
497  "MINRES requires a LinearProblem object with a non-null right-hand side.");
498  TEUCHOS_TEST_FOR_EXCEPTION( ! problem->isProblemSet(),
500  "MINRES requires that before you give it a LinearProblem to solve, you "
501  "must first call the linear problem's setProblem() method.");
502  }
503 
504  template<class ScalarType, class MV, class OP>
505  void
507  setParameters (const Teuchos::RCP<Teuchos::ParameterList>& params)
508  {
509  using Teuchos::ParameterList;
510  using Teuchos::parameterList;
511  using Teuchos::RCP;
512  using Teuchos::rcp;
513  using Teuchos::rcpFromRef;
514  using Teuchos::null;
515  using Teuchos::is_null;
516  using std::string;
517  using std::ostream;
518  using std::endl;
519 
520  if (params_.is_null()) {
521  params_ = parameterList (*getValidParameters());
522  }
523  RCP<ParameterList> pl = params;
524  pl->validateParametersAndSetDefaults (*params_);
525 
526  //
527  // Read parameters from the parameter list. We have already
528  // populated it with defaults.
529  //
530  blockSize_ = pl->get<int> ("Block Size");
531  verbosity_ = pl->get<int> ("Verbosity");
532  outputStyle_ = pl->get<int> ("Output Style");
533  outputFreq_ = pl->get<int>("Output Frequency");
534  outputStream_ = pl->get<RCP<std::ostream> > ("Output Stream");
535  convtol_ = pl->get<MagnitudeType> ("Convergence Tolerance");
536  maxIters_ = pl->get<int> ("Maximum Iterations");
537  //
538  // All done reading parameters from the parameter list.
539  // Now we know it's valid and we can store it.
540  //
541  params_ = pl;
542 
543  // Change the timer label, and create the timer if necessary.
544  const string newLabel = pl->get<string> ("Timer Label");
545  {
546  if (newLabel != label_ || timerSolve_.is_null()) {
547  label_ = newLabel;
548 #ifdef BELOS_TEUCHOS_TIME_MONITOR
549  const string solveLabel = label_ + ": MinresSolMgr total solve time";
550  // Unregister the old timer before creating a new one.
551  if (! timerSolve_.is_null()) {
552  Teuchos::TimeMonitor::clearCounter (label_);
553  timerSolve_ = Teuchos::null;
554  }
555  timerSolve_ = Teuchos::TimeMonitor::getNewCounter (solveLabel);
556 #endif // BELOS_TEUCHOS_TIME_MONITOR
557  }
558  }
559 
560  // Create output manager, if necessary; otherwise, set its parameters.
561  bool recreatedPrinter = false;
562  if (printer_.is_null()) {
563  printer_ = rcp (new OutputManager<ScalarType> (verbosity_, outputStream_));
564  recreatedPrinter = true;
565  } else {
566  // Set the output stream's verbosity level.
567  printer_->setVerbosity (verbosity_);
568  // Tell the output manager about the new output stream.
569  printer_->setOStream (outputStream_);
570  }
571 
572  //
573  // Set up the convergence tests
574  //
575  typedef StatusTestGenResNorm<ScalarType, MV, OP> res_norm_type;
576  typedef StatusTestCombo<ScalarType, MV, OP> combo_type;
577 
578  // Do we need to allocate at least one of the implicit or explicit
579  // residual norm convergence tests?
580  const bool allocatedConvergenceTests =
581  impConvTest_.is_null() || expConvTest_.is_null();
582 
583  // Allocate or set the tolerance of the implicit residual norm
584  // convergence test.
585  if (impConvTest_.is_null()) {
586  impConvTest_ = rcp (new res_norm_type (convtol_));
587  impConvTest_->defineResForm (res_norm_type::Implicit, TwoNorm);
588  // TODO (mfh 03 Nov 2011) Allow users to define the type of
589  // scaling (or a custom scaling factor).
590  impConvTest_->defineScaleForm (NormOfInitRes, TwoNorm);
591  } else {
592  impConvTest_->setTolerance (convtol_);
593  }
594 
595  // Allocate or set the tolerance of the explicit residual norm
596  // convergence test.
597  if (expConvTest_.is_null()) {
598  expConvTest_ = rcp (new res_norm_type (convtol_));
599  expConvTest_->defineResForm (res_norm_type::Explicit, TwoNorm);
600  // TODO (mfh 03 Nov 2011) Allow users to define the type of
601  // scaling (or a custom scaling factor).
602  expConvTest_->defineScaleForm (NormOfInitRes, TwoNorm);
603  } else {
604  expConvTest_->setTolerance (convtol_);
605  }
606 
607  // Whether we need to recreate the full status test. We only need
608  // to do that if at least one of convTest_ or maxIterTest_ had to
609  // be reallocated.
610  bool needToRecreateFullStatusTest = sTest_.is_null();
611 
612  // Residual status test is a combo of the implicit and explicit
613  // convergence tests.
614  if (convTest_.is_null() || allocatedConvergenceTests) {
615  convTest_ = rcp (new combo_type (combo_type::SEQ, impConvTest_, expConvTest_));
616  needToRecreateFullStatusTest = true;
617  }
618 
619  // Maximum number of iterations status test. It tells the solver to
620  // stop iteration, if the maximum number of iterations has been
621  // exceeded. Initialize it if we haven't yet done so, otherwise
622  // tell it the new maximum number of iterations.
623  if (maxIterTest_.is_null()) {
624  maxIterTest_ = rcp (new StatusTestMaxIters<ScalarType,MV,OP> (maxIters_));
625  needToRecreateFullStatusTest = true;
626  } else {
627  maxIterTest_->setMaxIters (maxIters_);
628  }
629 
630  // Create the full status test if we need to.
631  //
632  // The full status test: the maximum number of iterations have
633  // been reached, OR the residual has converged.
634  //
635  // "If we need to" means either that the status test was never
636  // created before, or that its two component tests had to be
637  // reallocated.
638  if (needToRecreateFullStatusTest) {
639  sTest_ = rcp (new combo_type (combo_type::OR, maxIterTest_, convTest_));
640  }
641 
642  // If necessary, create the status test output class. This class
643  // manages and formats the output from the status test. We have
644  // to recreate the output test if we had to (re)allocate either
645  // printer_ or sTest_.
646  if (outputTest_.is_null() || needToRecreateFullStatusTest || recreatedPrinter) {
647  StatusTestOutputFactory<ScalarType,MV,OP> stoFactory (outputStyle_);
648  outputTest_ = stoFactory.create (printer_, sTest_, outputFreq_,
650  } else {
651  outputTest_->setOutputFrequency (outputFreq_);
652  }
653  // Set the solver string for the output test.
654  // StatusTestOutputFactory has no constructor argument for this.
655  outputTest_->setSolverDesc (std::string (" MINRES "));
656 
657  // Inform the solver manager that the current parameters were set.
658  parametersSet_ = true;
659 
660  if (verbosity_ & Debug) {
661  using std::endl;
662 
663  std::ostream& dbg = printer_->stream (Debug);
664  dbg << "MINRES parameters:" << endl << params_ << endl;
665  }
666  }
667 
668 
669  template<class ScalarType, class MV, class OP>
671  {
672  using Teuchos::RCP;
673  using Teuchos::rcp;
674  using Teuchos::rcp_const_cast;
675  using std::endl;
676 
677  if (! parametersSet_) {
678  setParameters (params_);
679  }
680  std::ostream& dbg = printer_->stream (Debug);
681 
682 #ifdef BELOS_TEUCHOS_TIME_MONITOR
683  Teuchos::TimeMonitor solveTimerMonitor (*timerSolve_);
684 #endif // BELOS_TEUCHOS_TIME_MONITOR
685 
686  // We need a problem to solve, else we can't solve it.
687  validateProblem (problem_);
688 
689  // Reset the status test for this solve.
690  outputTest_->reset();
691 
692  // The linear problem has this many right-hand sides to solve.
693  // MINRES can solve only one at a time, so we solve for each
694  // right-hand side in succession.
695  const int numRHS2Solve = MVT::GetNumberVecs (*(problem_->getRHS()));
696 
697  // Create MINRES iteration object. Pass along the solver
698  // manager's parameters, which have already been validated.
699  typedef MinresIter<ScalarType, MV, OP> iter_type;
700  RCP<iter_type> minres_iter =
701  rcp (new iter_type (problem_, printer_, outputTest_, *params_));
702 
703  // The index/indices of the right-hand sides for which MINRES did
704  // _not_ converge. Hopefully this is empty after the for loop
705  // below! If it is not empty, at least one right-hand side did
706  // not converge.
707  std::vector<int> notConverged;
708  std::vector<int> currentIndices(1);
709 
710  numIters_ = 0;
711 
712  // Solve for each right-hand side in turn.
713  for (int currentRHS = 0; currentRHS < numRHS2Solve; ++currentRHS) {
714  // Inform the linear problem of the right-hand side(s) currently
715  // being solved. MINRES only knows how to solve linear problems
716  // with one right-hand side, so we only include one index, which
717  // is the index of the current right-hand side.
718  currentIndices[0] = currentRHS;
719  problem_->setLSIndex (currentIndices);
720 
721  dbg << "-- Current right-hand side index being solved: "
722  << currentRHS << endl;
723 
724  // Reset the number of iterations.
725  minres_iter->resetNumIters();
726  // Reset the number of calls that the status test output knows about.
727  outputTest_->resetNumCalls();
728  // Set the new state and initialize the solver.
730 
731  // Get the residual vector for the current linear system
732  // (that is, for the current right-hand side).
733  newstate.Y = MVT::CloneViewNonConst (*(rcp_const_cast<MV> (problem_->getInitResVec())), currentIndices);
734  minres_iter->initializeMinres (newstate);
735 
736  // Attempt to solve for the solution corresponding to the
737  // current right-hand side.
738  while (true) {
739  try {
740  minres_iter->iterate();
741 
742  // First check for convergence
743  if (convTest_->getStatus() == Passed) {
744  dbg << "---- Converged after " << maxIterTest_->getNumIters()
745  << " iterations" << endl;
746  break;
747  }
748  // Now check for max # of iterations
749  else if (maxIterTest_->getStatus() == Passed) {
750  dbg << "---- Did not converge after " << maxIterTest_->getNumIters()
751  << " iterations" << endl;
752  // This right-hand side didn't converge!
753  notConverged.push_back (currentRHS);
754  break;
755  } else {
756  // If we get here, we returned from iterate(), but none of
757  // our status tests Passed. Something is wrong, and it is
758  // probably our fault.
759  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
760  "Belos::MinresSolMgr::solve(): iterations neither converged, "
761  "nor reached the maximum number of iterations " << maxIters_
762  << ". That means something went wrong.");
763  }
764  } catch (const std::exception &e) {
765  printer_->stream (Errors)
766  << "Error! Caught std::exception in MinresIter::iterate() at "
767  << "iteration " << minres_iter->getNumIters() << endl
768  << e.what() << endl;
769  throw e;
770  }
771  }
772 
773  // Inform the linear problem that we are finished with the
774  // current right-hand side. It may or may not have converged,
775  // but we don't try again if the first time didn't work.
776  problem_->setCurrLS();
777 
778  // Get iteration information for this solve: total number of
779  // iterations for all right-hand sides.
780  numIters_ += maxIterTest_->getNumIters();
781  }
782 
783  // Print final summary of the solution process
784  sTest_->print (printer_->stream (FinalSummary));
785 
786  // Print timing information, if the corresponding compile-time and
787  // run-time options are enabled.
788 #ifdef BELOS_TEUCHOS_TIME_MONITOR
789  // Calling summarize() can be expensive, so don't call unless the
790  // user wants to print out timing details. summarize() will do all
791  // the work even if it's passed a "black hole" output stream.
792  if (verbosity_ & TimingDetails) {
793  Teuchos::TimeMonitor::summarize (printer_->stream (TimingDetails));
794  }
795 #endif // BELOS_TEUCHOS_TIME_MONITOR
796 
797  // Save the convergence test value ("achieved tolerance") for this
798  // solve. This solver always has two residual norm status tests:
799  // an explicit and an implicit test. The master convergence test
800  // convTest_ is a SEQ combo of the implicit resp. explicit tests.
801  // If the implicit test never passes, then the explicit test won't
802  // ever be executed. This manifests as
803  // expConvTest_->getTestValue()->size() < 1. We deal with this
804  // case by using the values returned by
805  // impConvTest_->getTestValue().
806  {
807  const std::vector<MagnitudeType>* pTestValues = expConvTest_->getTestValue();
808  if (pTestValues == NULL || pTestValues->size() < 1) {
809  pTestValues = impConvTest_->getTestValue();
810  }
811  TEUCHOS_TEST_FOR_EXCEPTION(pTestValues == NULL, std::logic_error,
812  "Belos::MinresSolMgr::solve(): The implicit convergence test's getTestValue() "
813  "method returned NULL. Please report this bug to the Belos developers.");
814  TEUCHOS_TEST_FOR_EXCEPTION(pTestValues->size() < 1, std::logic_error,
815  "Belos::MinresSolMgr::solve(): The implicit convergence test's getTestValue() "
816  "method returned a vector of length zero. Please report this bug to the "
817  "Belos developers.");
818 
819  // FIXME (mfh 12 Dec 2011) Does pTestValues really contain the
820  // achieved tolerances for all vectors in the current solve(), or
821  // just for the vectors from the last deflation?
822  achievedTol_ = *std::max_element (pTestValues->begin(), pTestValues->end());
823  }
824 
825  if (notConverged.size() > 0) {
826  return Unconverged;
827  } else {
828  return Converged;
829  }
830  }
831 
832  // This method requires the solver manager to return a std::string that describes itself.
833  template<class ScalarType, class MV, class OP>
835  {
836  std::ostringstream oss;
837  oss << "Belos::MinresSolMgr< "
838  << Teuchos::ScalarTraits<ScalarType>::name()
839  <<", MV, OP >";
840  // oss << "{";
841  // oss << "Block Size=" << blockSize_;
842  // oss << "}";
843  return oss.str();
844  }
845 
846 } // end Belos namespace
847 
848 #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.

Generated on Thu Jul 21 2016 14:43:57 for Belos by doxygen 1.8.11