#include <deal.II/trilinos/nox.h>
template<typename VectorType>
class TrilinosWrappers::NOXSolver< VectorType >
Wrapper around the nonlinear solver from the NOX package (https://docs.trilinos.org/dev/packages/nox/doc/html/index.html), targeting deal.II data structures.
The following code shows the steps how to use this class:
const Teuchos::RCP<Teuchos::ParameterList>
parameters =
Teuchos::rcp(new Teuchos::ParameterList);
parameters->set(
"Nonlinear Solver",
"Line Search Based");
parameters->sublist(
"Line Search").set(
"Method",
"Full Step");
parameters->sublist(
"Direction").set(
"Method",
"Newton")
solver.residual = [](
const auto &u,
auto &
F) {...};
solver.setup_jacobian = [](const auto &u) {...};
solver.solve_with_jacobian =
[](
const auto &u,
auto &
F,
const auto) {...};
solver.solve(solution);
AdditionalData additional_data
const Teuchos::RCP< Teuchos::ParameterList > parameters
Tensor< 2, dim, Number > F(const Tensor< 2, dim, Number > &Grad_u)
The functions used in NOX are nearly identical to the functions in SUNDIALS::KINSOL with a few exceptions (for example, SUNDIALS::KINSOL requires a reinit() function where NOX does not). So check the SUNDIALS::KINSOL documentation for more precise details on how these functions are implemented.
Definition at line 88 of file nox.h.
◆ NOXSolver()
template<typename VectorType >
◆ ~NOXSolver()
template<typename VectorType >
◆ clear()
template<typename VectorType >
Clear the internal state.
◆ solve()
template<typename VectorType >
Solve the nonlinear problem and return the number of nonlinear iterations executed.
◆ residual
template<typename VectorType >
A function object that users should supply and that is intended to compute the residual \(F(u)\).
- Note
- This variable represents a user provided callback. See there for a description of how to deal with errors and other requirements and conventions. NOX can not deal with "recoverable" errors, so if a callback throws an exception of type RecoverableUserCallbackError, then this exception is treated like any other exception.
Definition at line 205 of file nox.h.
◆ setup_jacobian
template<typename VectorType >
A user function that sets up the Jacobian, based on the current solution current_u
.
- Note
- This variable represents a user provided callback. See there for a description of how to deal with errors and other requirements and conventions. NOX can not deal with "recoverable" errors, so if a callback throws an exception of type RecoverableUserCallbackError, then this exception is treated like any other exception.
Definition at line 219 of file nox.h.
◆ setup_preconditioner
template<typename VectorType >
A user function that sets up the preconditioner for inverting the Jacobian, based on the current solution current_u
.
- Note
- This function is optional and is used when setup_jacobian is called and the preconditioner needs to be updated (see update_preconditioner_predicate and AdditionalData::threshold_nonlinear_iterations).
-
This variable represents a user provided callback. See there for a description of how to deal with errors and other requirements and conventions. NOX can not deal with "recoverable" errors, so if a callback throws an exception of type RecoverableUserCallbackError, then this exception is treated like any other exception.
Definition at line 238 of file nox.h.
◆ apply_jacobian
template<typename VectorType >
A user function that applies the Jacobian \(\nabla_u F(u)\) to x
and writes the result in y
. The Jacobian to be used (i.e., more precisely: the linearization point \(u\) above) is the one computed when the setup_jacobian
function was last called.
- Note
- This function is optional and is used in the case of certain configurations. For instance, this function is required if the polynomial line search (
NOX::LineSearch::Polynomial
) is chosen, whereas for the full step case (NOX::LineSearch::FullStep
) it won't be called.
-
This variable represents a user provided callback. See there for a description of how to deal with errors and other requirements and conventions. NOX can not deal with "recoverable" errors, so if a callback throws an exception of type RecoverableUserCallbackError, then this exception is treated like any other exception.
Definition at line 260 of file nox.h.
◆ solve_with_jacobian
template<typename VectorType >
A user function that applies the inverse of the Jacobian \([\nabla_u F(u)]^{-1}\) to y
and writes the result in x
. The parameter tolerance
specifies the error reduction if an iterative solver is used in applying the inverse matrix. The Jacobian to be used (i.e., more precisely: the linearization point \(u\) above) is the one computed when the setup_jacobian
function was last called.
- Note
- This function is optional and is used in the case of certain configurations.
-
This variable represents a user provided callback. See there for a description of how to deal with errors and other requirements and conventions. NOX can not deal with "recoverable" errors, so if a callback throws an exception of type RecoverableUserCallbackError, then this exception is treated like any other exception.
Definition at line 284 of file nox.h.
◆ solve_with_jacobian_and_track_n_linear_iterations
template<typename VectorType >
std::function< int(const VectorType &y, VectorType &x, const double tolerance)> TrilinosWrappers::NOXSolver< VectorType >::solve_with_jacobian_and_track_n_linear_iterations |
A user function that applies the inverse of the Jacobian \([\nabla_u F(u)]^{-1}\) to y
, writes the result in x
and returns the number of linear iterations the linear solver needed. The parameter tolerance
species the error reduction if an iterative solver is used. The Jacobian to be used (i.e., more precisely: the linearization point \(u\) above) is the one computed when the setup_jacobian
function was last called.
- Note
- This function is used if
solve_with_jacobian
is not provided. Its return value is compared again AdditionalFlags::threshold_n_linear_iterations; if it is larger, the preconditioner will be built before the next linear system is solved. The use of this approach is predicated on the idea that one can keep using a preconditioner built earlier as long as it is a good preconditioner for the matrix currently in use – where "good" is defined as leading to a number of iterations to solve linear systems less than the threshold given by the current variable.
-
This variable represents a user provided callback. See there for a description of how to deal with errors and other requirements and conventions. NOX can not deal with "recoverable" errors, so if a callback throws an exception of type RecoverableUserCallbackError, then this exception is treated like any other exception.
Definition at line 317 of file nox.h.
◆ check_iteration_status
template<typename VectorType >
A user function that allows to check convergence in addition to ones checking the l2-norm and the number of iterations (see AdditionalData). It is run after each nonlinear iteration.
The input are the current iteration number i
, the l2-norm norm_f
of the residual vector, the current solution current_u
, and the current residual vector f
.
- Note
- This function is optional.
-
This variable represents a user provided callback. See there for a description of how to deal with errors and other requirements and conventions. NOX can not deal with "recoverable" errors, so if a callback throws an exception of type RecoverableUserCallbackError, then this exception is treated like any other exception.
Definition at line 342 of file nox.h.
◆ update_preconditioner_predicate
template<typename VectorType >
A user function that, in addition to AdditionalData::threshold_nonlinear_iterations, allows to force to update the preconditioner. A reason for wanting to update the preconditioner is when the expected number of linear iterations is exceeded.
- Note
- This function is optional. If no function is attached, this means implicitly a return value of
false
.
-
This variable represents a user provided callback. See there for a description of how to deal with errors and other requirements and conventions. NOX can not deal with "recoverable" errors, so if a callback throws an exception of type RecoverableUserCallbackError, then this exception is treated like any other exception.
Definition at line 362 of file nox.h.
◆ additional_data
template<typename VectorType >
Additional data with basic settings.
Definition at line 368 of file nox.h.
◆ parameters
template<typename VectorType >
◆ n_residual_evaluations
template<typename VectorType >
A counter for the number of (accumulated) residual evaluations.
Definition at line 380 of file nox.h.
◆ n_jacobian_applications
template<typename VectorType >
A counter for the number of (accumulated) Jacobi applications.
Definition at line 385 of file nox.h.
◆ n_nonlinear_iterations
template<typename VectorType >
A counter for the number of (accumulated) nonlinear iterations.
Definition at line 390 of file nox.h.
◆ n_last_linear_iterations
template<typename VectorType >
The number of linear iterations of the last Jacobian solve.
Definition at line 395 of file nox.h.
◆ pending_exception
template<typename VectorType >
A pointer to any exception that may have been thrown in user-defined call-backs and that we have to deal after the KINSOL function we call has returned.
Definition at line 402 of file nox.h.
The documentation for this class was generated from the following file:
- include/deal.II/trilinos/nox.h