Thyra
Version of the Day
Toggle main menu visibility
Loading...
Searching...
No Matches
core
src
interfaces
nonlinear
solvers
fundamental
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
52
namespace
Thyra {
53
54
74
template
<
class
Scalar>
75
class
NonlinearSolverBase
76
:
virtual
public
Teuchos::Describable
77
,
virtual
public
Teuchos::VerboseObject
<NonlinearSolverBase<Scalar> >
78
,
virtual
public
Teuchos::ParameterListAcceptor
79
{
80
public
:
81
84
92
virtual
void
setModel
(
93
const
RCP
<
const
ModelEvaluator<Scalar>
> &model
94
) = 0;
95
97
virtual
RCP<const ModelEvaluator<Scalar>
>
getModel
()
const
= 0;
98
118
virtual
SolveStatus<Scalar>
solve
(
119
VectorBase<Scalar>
*x,
120
const
SolveCriteria<Scalar>
*solveCriteria = NULL,
121
VectorBase<Scalar>
*delta = NULL
122
) = 0;
123
125
128
133
virtual
bool
supportsCloning
()
const
;
134
155
virtual
RCP<NonlinearSolverBase<Scalar>
>
cloneNonlinearSolver
()
const
;
156
162
virtual
RCP<const VectorBase<Scalar>
>
get_current_x
()
const
;
163
169
virtual
bool
is_W_current
()
const
;
170
186
virtual
RCP<LinearOpWithSolveBase<Scalar>
>
187
get_nonconst_W
(
const
bool
forceUpToDate =
false
);
188
196
virtual
RCP<const LinearOpWithSolveBase<Scalar>
>
get_W
()
const
;
197
207
virtual
void
set_W_is_current
(
bool
W_is_current);
208
210
211
private
:
212
213
// Not defined and not to be called
214
NonlinearSolverBase<Scalar>
&
215
operator=(
const
NonlinearSolverBase<Scalar>
&);
216
217
};
218
219
224
template
<
class
Scalar>
225
const
SolveStatus<Scalar>
solve
(
226
NonlinearSolverBase<Scalar>
&nonlinearSolver,
227
VectorBase<Scalar>
*x,
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
239
template
<
class
Scalar>
240
bool
NonlinearSolverBase<Scalar>::supportsCloning
()
const
241
{
242
return
false
;
243
}
244
245
template
<
class
Scalar>
246
RCP<NonlinearSolverBase<Scalar>
>
247
NonlinearSolverBase<Scalar>::cloneNonlinearSolver
()
const
248
{
249
return
Teuchos::null;
250
}
251
252
template
<
class
Scalar>
253
RCP<const VectorBase<Scalar>
>
254
NonlinearSolverBase<Scalar>::get_current_x
()
const
255
{
256
return
Teuchos::null;
257
}
258
259
template
<
class
Scalar>
260
bool
NonlinearSolverBase<Scalar>::is_W_current
()
const
261
{
262
return
false
;
263
}
264
265
template
<
class
Scalar>
266
RCP<LinearOpWithSolveBase<Scalar>
>
267
NonlinearSolverBase<Scalar>::get_nonconst_W
(
const
bool
forceUpToDate)
268
{
269
return
Teuchos::null;
270
}
271
272
template
<
class
Scalar>
273
RCP<const LinearOpWithSolveBase<Scalar>
>
274
NonlinearSolverBase<Scalar>::get_W
()
const
275
{
276
return
Teuchos::null;
277
}
278
279
template
<
class
Scalar>
280
void
NonlinearSolverBase<Scalar>::set_W_is_current
(
bool
W_is_current)
281
{
282
TEUCHOS_TEST_FOR_EXCEPTION
(
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
Teuchos::Describable
Teuchos::Describable::description
virtual std::string description() const
Teuchos::ParameterListAcceptor
Teuchos::RCP
Teuchos::VerboseObject
Thyra::ModelEvaluator
Pure abstract base interface for evaluating a stateless "model" that can be mapped into a number of d...
Definition
Thyra_ModelEvaluator.hpp:774
Thyra::NonlinearSolverBase
Base class for all nonlinear equation solvers.
Definition
Thyra_NonlinearSolverBase.hpp:79
Thyra::NonlinearSolverBase::set_W_is_current
virtual void set_W_is_current(bool W_is_current)
Set if *get_W() is current with respect to *get_current_x().
Definition
Thyra_NonlinearSolverBase.hpp:280
Thyra::NonlinearSolverBase::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.
Definition
Thyra_NonlinearSolverBase.hpp:254
Thyra::NonlinearSolverBase::cloneNonlinearSolver
virtual RCP< NonlinearSolverBase< Scalar > > cloneNonlinearSolver() const
Clone the solver algorithm if supported.
Definition
Thyra_NonlinearSolverBase.hpp:247
Thyra::NonlinearSolverBase::getModel
virtual RCP< const ModelEvaluator< Scalar > > getModel() const =0
Get the model that defines the nonlinear equations.
Thyra::NonlinearSolverBase::solve
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.
Thyra::NonlinearSolverBase::solve
const SolveStatus< Scalar > solve(NonlinearSolverBase< Scalar > &nonlinearSolver, VectorBase< Scalar > *x, const SolveCriteria< Scalar > *solveCriteria=NULL, VectorBase< Scalar > *delta=NULL)
Definition
Thyra_NonlinearSolverBase.hpp:225
Thyra::NonlinearSolverBase::get_nonconst_W
virtual RCP< LinearOpWithSolveBase< Scalar > > get_nonconst_W(const bool forceUpToDate=false)
Get a nonconst RCP to the Jacobian if available.
Definition
Thyra_NonlinearSolverBase.hpp:267
Thyra::NonlinearSolverBase::get_W
virtual RCP< const LinearOpWithSolveBase< Scalar > > get_W() const
Get a const RCP to the Jacobian if available.
Definition
Thyra_NonlinearSolverBase.hpp:274
Thyra::NonlinearSolverBase::setModel
virtual void setModel(const RCP< const ModelEvaluator< Scalar > > &model)=0
Set the model that defines the nonlinear equations.
Thyra::NonlinearSolverBase::is_W_current
virtual bool is_W_current() const
Returns true if *get_W() is current with respect to *get_current_x().
Definition
Thyra_NonlinearSolverBase.hpp:260
Thyra::NonlinearSolverBase::supportsCloning
virtual bool supportsCloning() const
Return if this solver object supports cloning or not.
Definition
Thyra_NonlinearSolverBase.hpp:240
Thyra::VectorBase
Abstract interface for finite-dimensional dense vectors.
Definition
Thyra_VectorBase.hpp:147
TEUCHOS_TEST_FOR_EXCEPTION
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Thyra::SolveCriteria
Simple struct that defines the requested solution criteria for a solve.
Definition
Thyra_SolveSupportTypes.hpp:312
Thyra::SolveStatus
Simple struct for the return status from a solve.
Definition
Thyra_SolveSupportTypes.hpp:423
Generated by
1.17.0