Thyra Version of the Day
Loading...
Searching...
No Matches
Thyra_NonlinearSolverBase.hpp
1// @HEADER
2// ***********************************************************************
3//
4// Thyra: Interfaces and Support for Abstract Numerical Algorithms
5// Copyright (2004) Sandia Corporation
6//
7// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8// license for use of this work by or on behalf of the U.S. Government.
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 Roscoe A. Bartlett (bartlettra@ornl.gov)
38//
39// ***********************************************************************
40// @HEADER
41
42#ifndef THYRA_NONLINEAR_SOLVER_BASE_HPP
43#define THYRA_NONLINEAR_SOLVER_BASE_HPP
44
45#include "Thyra_LinearOpWithSolveBase.hpp"
46#include "Thyra_ModelEvaluator.hpp"
47#include "Teuchos_Describable.hpp"
48#include "Teuchos_VerboseObject.hpp"
49#include "Teuchos_ParameterListAcceptor.hpp"
50
51
52namespace Thyra {
53
54
74template <class Scalar>
76 : virtual public Teuchos::Describable
77 , virtual public Teuchos::VerboseObject<NonlinearSolverBase<Scalar> >
78 , virtual public Teuchos::ParameterListAcceptor
79{
80public:
81
84
92 virtual void setModel(
93 const RCP<const ModelEvaluator<Scalar> > &model
94 ) = 0;
95
98
120 const SolveCriteria<Scalar> *solveCriteria = NULL,
121 VectorBase<Scalar> *delta = NULL
122 ) = 0;
123
125
128
133 virtual bool supportsCloning() const;
134
156
163
169 virtual bool is_W_current() const;
170
187 get_nonconst_W( const bool forceUpToDate = false );
188
197
207 virtual void set_W_is_current(bool W_is_current);
208
210
211private:
212
213 // Not defined and not to be called
215 operator=(const NonlinearSolverBase<Scalar>&);
216
217};
218
219
224template <class Scalar>
226 NonlinearSolverBase<Scalar> &nonlinearSolver,
228 const SolveCriteria<Scalar> *solveCriteria = NULL,
229 VectorBase<Scalar> *delta = NULL
230 )
231{
232 return nonlinearSolver.solve(x,solveCriteria,delta);
233}
234
235
236// ///////////////////////////////
237// Implementations
238
239template <class Scalar>
241{
242 return false;
243}
244
245template <class Scalar>
251
252template <class Scalar>
258
259template <class Scalar>
261{
262 return false;
263}
264
265template <class Scalar>
268{
269 return Teuchos::null;
270}
271
272template <class Scalar>
278
279template <class Scalar>
281{
283 true, std::logic_error,
284 "Error, the subclass object described as " << this->description() << " did not"
285 " override this function!"
286 );
287}
288
289
290} // namespace Thyra
291
292
293#endif // THYRA_NONLINEAR_SOLVER_BASE_HPP
Pure abstract base interface for evaluating a stateless "model" that can be mapped into a number of d...
Base class for all nonlinear equation solvers.
virtual void set_W_is_current(bool W_is_current)
Set if *get_W() is current with respect to *get_current_x().
virtual RCP< const VectorBase< Scalar > > get_current_x() const
Return the current value of the solution x as computed in the last solve() operation if supported.
virtual RCP< NonlinearSolverBase< Scalar > > cloneNonlinearSolver() const
Clone the solver algorithm if supported.
virtual RCP< const ModelEvaluator< Scalar > > getModel() const =0
Get the model that defines the nonlinear equations.
virtual SolveStatus< Scalar > solve(VectorBase< Scalar > *x, const SolveCriteria< Scalar > *solveCriteria=NULL, VectorBase< Scalar > *delta=NULL)=0
Solve a set of nonlinear equations from a given starting point.
const SolveStatus< Scalar > solve(NonlinearSolverBase< Scalar > &nonlinearSolver, VectorBase< Scalar > *x, const SolveCriteria< Scalar > *solveCriteria=NULL, VectorBase< Scalar > *delta=NULL)
virtual RCP< LinearOpWithSolveBase< Scalar > > get_nonconst_W(const bool forceUpToDate=false)
Get a nonconst RCP to the Jacobian if available.
virtual RCP< const LinearOpWithSolveBase< Scalar > > get_W() const
Get a const RCP to the Jacobian if available.
virtual void setModel(const RCP< const ModelEvaluator< Scalar > > &model)=0
Set the model that defines the nonlinear equations.
virtual bool is_W_current() const
Returns true if *get_W() is current with respect to *get_current_x().
virtual bool supportsCloning() const
Return if this solver object supports cloning or not.
Abstract interface for finite-dimensional dense vectors.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
T_To & dyn_cast(T_From &from)
Simple struct that defines the requested solution criteria for a solve.
Simple struct for the return status from a solve.