Belos  Version of the Day
BelosSolverManager.hpp
Go to the documentation of this file.
1 
2 //@HEADER
3 // ************************************************************************
4 //
5 // Belos: Block Linear Solvers Package
6 // Copyright 2004 Sandia Corporation
7 //
8 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9 // the U.S. Government retains certain rights in this software.
10 //
11 // Redistribution and use in source and binary forms, with or without
12 // modification, are permitted provided that the following conditions are
13 // met:
14 //
15 // 1. Redistributions of source code must retain the above copyright
16 // notice, this list of conditions and the following disclaimer.
17 //
18 // 2. Redistributions in binary form must reproduce the above copyright
19 // notice, this list of conditions and the following disclaimer in the
20 // documentation and/or other materials provided with the distribution.
21 //
22 // 3. Neither the name of the Corporation nor the names of the
23 // contributors may be used to endorse or promote products derived from
24 // this software without specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 //
38 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
39 //
40 // ************************************************************************
41 //@HEADER
42 
43 #ifndef BELOS_SOLVERMANAGER_HPP
44 #define BELOS_SOLVERMANAGER_HPP
45 
50 #include "BelosConfigDefs.hpp"
51 #include "BelosTypes.hpp"
52 #include "BelosLinearProblem.hpp"
53 
54 #include "Teuchos_ParameterList.hpp"
55 #include "Teuchos_RCP.hpp"
56 #include "Teuchos_Describable.hpp"
57 
63 namespace Belos {
64 
65 
66 template <class ScalarType, class MV, class OP>
67 class StatusTest;
68 
69 
70 template<class ScalarType, class MV, class OP>
71 class SolverManager : virtual public Teuchos::Describable {
72 
73  public:
74 
76 
77 
80 
82  virtual ~SolverManager() {};
84 
86 
87 
89  virtual const LinearProblem<ScalarType,MV,OP>& getProblem() const = 0;
90 
92  virtual Teuchos::RCP<const Teuchos::ParameterList> getValidParameters() const = 0;
93 
95  virtual Teuchos::RCP<const Teuchos::ParameterList> getCurrentParameters() const = 0;
96 
108  virtual typename Teuchos::ScalarTraits<ScalarType>::magnitudeType achievedTol() const {
109  TEUCHOS_TEST_FOR_EXCEPTION(true, std::runtime_error, "achievedTol() not implemented");
110  }
111 
113  virtual int getNumIters() const = 0;
114 
118  virtual bool isLOADetected() const = 0;
119 
121 
123 
124 
126  virtual void setProblem( const Teuchos::RCP<LinearProblem<ScalarType,MV,OP> > &problem ) = 0;
127 
138  virtual void setParameters( const Teuchos::RCP<Teuchos::ParameterList> &params ) = 0;
139 
141  virtual void setUserConvStatusTest(
142  const Teuchos::RCP<StatusTest<ScalarType,MV,OP> > &userConvStatusTest
143  )
144  {
145  TEUCHOS_TEST_FOR_EXCEPT_MSG(true, "Error, the function setUserConvStatusTest() has not been"
146  << " overridden for the class" << this->description() << " yet!");
147  }
148 
150 
152 
153 
160  virtual void reset( const ResetType type ) = 0;
162 
164 
165 
167  //
178  virtual ReturnType solve() = 0;
180 
181 };
182 
183 } // end Belos namespace
184 
185 #endif /* BELOS_SOLVERMANAGER_HPP */
Collection of types and exceptions used within the Belos solvers.
virtual void setProblem(const Teuchos::RCP< LinearProblem< ScalarType, MV, OP > > &problem)=0
Set the linear problem that needs to be solved.
virtual Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const =0
Return the valid parameters for this solver manager.
SolverManager()
Empty constructor.
virtual ReturnType solve()=0
Iterate until the status test tells us to stop.
virtual void reset(const ResetType type)=0
Reset the solver manager.
virtual Teuchos::RCP< const Teuchos::ParameterList > getCurrentParameters() const =0
Return the current parameters being used for this solver manager.
A pure virtual class for defining the status tests for the Belos iterative solvers.
virtual void setUserConvStatusTest(const Teuchos::RCP< StatusTest< ScalarType, MV, OP > > &userConvStatusTest)
Set user-defined convergence status test.
virtual const LinearProblem< ScalarType, MV, OP > & getProblem() const =0
Return a reference to the linear problem being solved by this solver manager.
virtual Teuchos::ScalarTraits< ScalarType >::magnitudeType achievedTol() const
Tolerance achieved by the last solve() invocation.
ResetType
How to reset the solver.
Definition: BelosTypes.hpp:200
A linear system to solve, and its associated information.
Class which describes the linear problem to be solved by the iterative solver.
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 ...
virtual void setParameters(const Teuchos::RCP< Teuchos::ParameterList > &params)=0
Set the parameters to use when solving the linear problem.
virtual bool isLOADetected() const =0
Returns whether a loss of accuracy was detected in the solver.
Belos header file which uses auto-configuration information to include necessary C++ headers...
virtual int getNumIters() const =0
Get the iteration count for the most recent call to solve().
virtual ~SolverManager()
Destructor.