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
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.
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.
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.