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
// Thyra: Interfaces and Support for Abstract Numerical Algorithms
4
//
5
// Copyright 2004 NTESS and the Thyra contributors.
6
// SPDX-License-Identifier: BSD-3-Clause
7
// *****************************************************************************
8
// @HEADER
9
10
#ifndef THYRA_NONLINEAR_SOLVER_BASE_HPP
11
#define THYRA_NONLINEAR_SOLVER_BASE_HPP
12
13
#include "Thyra_LinearOpWithSolveBase.hpp"
14
#include "Thyra_ModelEvaluator.hpp"
15
#include "Teuchos_Describable.hpp"
16
#include "Teuchos_VerboseObject.hpp"
17
#include "Teuchos_ParameterListAcceptor.hpp"
18
19
20
namespace
Thyra {
21
22
42
template
<
class
Scalar>
43
class
NonlinearSolverBase
44
:
virtual
public
Teuchos::Describable
45
,
virtual
public
Teuchos::VerboseObject
<NonlinearSolverBase<Scalar> >
46
,
virtual
public
Teuchos::ParameterListAcceptor
47
{
48
public
:
49
52
60
virtual
void
setModel
(
61
const
RCP
<
const
ModelEvaluator<Scalar>
> &model
62
) = 0;
63
65
virtual
RCP<const ModelEvaluator<Scalar>
>
getModel
()
const
= 0;
66
86
virtual
SolveStatus<Scalar>
solve
(
87
VectorBase<Scalar>
*x,
88
const
SolveCriteria<Scalar>
*solveCriteria = NULL,
89
VectorBase<Scalar>
*delta = NULL
90
) = 0;
91
93
96
101
virtual
bool
supportsCloning
()
const
;
102
123
virtual
RCP<NonlinearSolverBase<Scalar>
>
cloneNonlinearSolver
()
const
;
124
130
virtual
RCP<const VectorBase<Scalar>
>
get_current_x
()
const
;
131
137
virtual
bool
is_W_current
()
const
;
138
154
virtual
RCP<LinearOpWithSolveBase<Scalar>
>
155
get_nonconst_W
(
const
bool
forceUpToDate =
false
);
156
164
virtual
RCP<const LinearOpWithSolveBase<Scalar>
>
get_W
()
const
;
165
175
virtual
void
set_W_is_current
(
bool
W_is_current);
176
178
179
private
:
180
181
// Not defined and not to be called
182
NonlinearSolverBase<Scalar>
&
183
operator=(
const
NonlinearSolverBase<Scalar>
&);
184
185
};
186
187
192
template
<
class
Scalar>
193
const
SolveStatus<Scalar>
solve
(
194
NonlinearSolverBase<Scalar>
&nonlinearSolver,
195
VectorBase<Scalar>
*x,
196
const
SolveCriteria<Scalar>
*solveCriteria = NULL,
197
VectorBase<Scalar>
*delta = NULL
198
)
199
{
200
return
nonlinearSolver.
solve
(x,solveCriteria,delta);
201
}
202
203
204
// ///////////////////////////////
205
// Implementations
206
207
template
<
class
Scalar>
208
bool
NonlinearSolverBase<Scalar>::supportsCloning
()
const
209
{
210
return
false
;
211
}
212
213
template
<
class
Scalar>
214
RCP<NonlinearSolverBase<Scalar>
>
215
NonlinearSolverBase<Scalar>::cloneNonlinearSolver
()
const
216
{
217
return
Teuchos::null;
218
}
219
220
template
<
class
Scalar>
221
RCP<const VectorBase<Scalar>
>
222
NonlinearSolverBase<Scalar>::get_current_x
()
const
223
{
224
return
Teuchos::null;
225
}
226
227
template
<
class
Scalar>
228
bool
NonlinearSolverBase<Scalar>::is_W_current
()
const
229
{
230
return
false
;
231
}
232
233
template
<
class
Scalar>
234
RCP<LinearOpWithSolveBase<Scalar>
>
235
NonlinearSolverBase<Scalar>::get_nonconst_W
(
const
bool
forceUpToDate)
236
{
237
return
Teuchos::null;
238
}
239
240
template
<
class
Scalar>
241
RCP<const LinearOpWithSolveBase<Scalar>
>
242
NonlinearSolverBase<Scalar>::get_W
()
const
243
{
244
return
Teuchos::null;
245
}
246
247
template
<
class
Scalar>
248
void
NonlinearSolverBase<Scalar>::set_W_is_current
(
bool
W_is_current)
249
{
250
TEUCHOS_TEST_FOR_EXCEPTION
(
251
true
, std::logic_error,
252
"Error, the subclass object described as "
<< this->
description
() <<
" did not"
253
" override this function!"
254
);
255
}
256
257
258
}
// namespace Thyra
259
260
261
#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:741
Thyra::NonlinearSolverBase
Base class for all nonlinear equation solvers.
Definition
Thyra_NonlinearSolverBase.hpp:47
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:248
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:222
Thyra::NonlinearSolverBase::cloneNonlinearSolver
virtual RCP< NonlinearSolverBase< Scalar > > cloneNonlinearSolver() const
Clone the solver algorithm if supported.
Definition
Thyra_NonlinearSolverBase.hpp:215
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:193
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:235
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:242
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:228
Thyra::NonlinearSolverBase::supportsCloning
virtual bool supportsCloning() const
Return if this solver object supports cloning or not.
Definition
Thyra_NonlinearSolverBase.hpp:208
Thyra::VectorBase
Abstract interface for finite-dimensional dense vectors.
Definition
Thyra_VectorBase.hpp:115
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:280
Thyra::SolveStatus
Simple struct for the return status from a solve.
Definition
Thyra_SolveSupportTypes.hpp:391
Generated by
1.17.0