NEML2 2.0.0
|
Definition of a nonlinear system of equations. More...
Definition of a nonlinear system of equations.
#include <NonlinearSystem.h>
Classes | |
struct | Jac |
struct | Res |
struct | Sol |
Public Member Functions | |
NonlinearSystem (const NonlinearSystem &)=default | |
NonlinearSystem (NonlinearSystem &&) noexcept=default | |
NonlinearSystem & | operator= (const NonlinearSystem &)=delete |
NonlinearSystem & | operator= (NonlinearSystem &&)=delete |
virtual | ~NonlinearSystem ()=default |
NonlinearSystem (const OptionSet &options) | |
virtual void | init_scaling (const Sol< false > &x, const bool verbose=false) |
Compute algebraic Jacobian-based automatic scaling following https://cs.stanford.edu/people/paulliu/files/cs517-project.pdf. | |
Res< true > | scale (const Res< false > &r) const |
Apply scaling to the residual. | |
Res< false > | unscale (const Res< true > &r) const |
Remove scaling to the residual. | |
Jac< true > | scale (const Jac< false > &J) const |
Apply scaling to the Jacobian. | |
Jac< false > | unscale (const Jac< true > &J) const |
Remove scaling to the Jacobian. | |
Sol< true > | scale (const Sol< false > &u) const |
Apply scaling to the solution. | |
Sol< false > | unscale (const Sol< true > &u) const |
Remove scaling to the solution. | |
void | set_guess (const Sol< true > &x) |
Set the current guess. | |
virtual void | set_guess (const Sol< false > &x)=0 |
Set the unscaled current guess. | |
template<bool scaled> | |
Res< scaled > | residual () |
Assemble and return the residual. | |
template<bool scaled> | |
Res< scaled > | residual (const Sol< scaled > &x) |
Convenient shortcut to set the current guess, assemble and return the residual. | |
template<bool scaled> | |
Jac< scaled > | Jacobian () |
Assemble and return the Jacobian. | |
template<bool scaled> | |
Jac< scaled > | Jacobian (const Sol< scaled > &x) |
Convenient shortcut to set the current guess, assemble and return the Jacobian. | |
template<bool scaled> | |
std::tuple< Res< scaled >, Jac< scaled > > | residual_and_Jacobian () |
Assemble and return the residual and Jacobian. | |
template<bool scaled> | |
std::tuple< Res< scaled >, Jac< scaled > > | residual_and_Jacobian (const Sol< scaled > &x) |
Convenient shortcut to set the current guess, assemble and return the residual and Jacobian. | |
Static Public Member Functions | |
static OptionSet | expected_options () |
static void | disable_automatic_scaling (OptionSet &options) |
static void | enable_automatic_scaling (OptionSet &options) |
Protected Member Functions | |
virtual void | assemble (Res< false > *r, Jac< false > *J)=0 |
Compute the unscaled residual and Jacobian. | |
Protected Attributes | |
const bool | _autoscale |
If true, do automatic scaling. | |
const Real | _autoscale_tol |
Tolerance for convergence check of the iterative automatic scaling algorithm. | |
const unsigned int | _autoscale_miter |
Maximum number of iterations allowed for the iterative automatic scaling algorithm. | |
bool | _scaling_matrices_initialized = false |
Flag to indicate whether scaling matrices have been computed. | |
Tensor | _row_scaling |
Row scaling "matrix" – since it's a batched diagonal matrix, we are only storing its diagonals. | |
Tensor | _col_scaling |
Column scaling "matrix" – since it's a batched diagonal matrix, we are only storing its diagonals. | |
|
default |
|
defaultnoexcept |
|
virtualdefault |
NonlinearSystem | ( | const OptionSet & | options | ) |
Compute the unscaled residual and Jacobian.
r | Pointer to the residual vector – nullptr if not requested |
J | Pointer to the Jacobian matrix – nullptr if not requested |
Implemented in Model, and TrustRegionSubProblem.
|
static |
|
static |
|
static |
|
virtual |
Compute algebraic Jacobian-based automatic scaling following https://cs.stanford.edu/people/paulliu/files/cs517-project.pdf.
In a nutshell, given the original linearized system
Instead of solving for
where
which is equivalent to
where
x | Unscaled initial guess used to compute the initial unscaled residual and Jacobian |
verbose | Print automatic scaling convergence information |
NonlinearSystem::Jac< scaled > Jacobian | ( | ) |
Assemble and return the Jacobian.
NonlinearSystem::Jac< scaled > Jacobian | ( | const Sol< scaled > & | x | ) |
Convenient shortcut to set the current guess, assemble and return the Jacobian.
|
delete |
|
delete |
NonlinearSystem::Res< scaled > residual | ( | ) |
Assemble and return the residual.
NonlinearSystem::Res< scaled > residual | ( | const Sol< scaled > & | x | ) |
Convenient shortcut to set the current guess, assemble and return the residual.
std::tuple< NonlinearSystem::Res< scaled >, NonlinearSystem::Jac< scaled > > residual_and_Jacobian | ( | ) |
Assemble and return the residual and Jacobian.
std::tuple< NonlinearSystem::Res< scaled >, NonlinearSystem::Jac< scaled > > residual_and_Jacobian | ( | const Sol< scaled > & | x | ) |
Convenient shortcut to set the current guess, assemble and return the residual and Jacobian.
NonlinearSystem::Jac< true > scale | ( | const Jac< false > & | J | ) | const |
Apply scaling to the Jacobian.
NonlinearSystem::Res< true > scale | ( | const Res< false > & | r | ) | const |
Apply scaling to the residual.
NonlinearSystem::Sol< true > scale | ( | const Sol< false > & | u | ) | const |
Apply scaling to the solution.
|
pure virtual |
Set the unscaled current guess.
Implemented in Model, and TrustRegionSubProblem.
void set_guess | ( | const Sol< true > & | x | ) |
Set the current guess.
NonlinearSystem::Jac< false > unscale | ( | const Jac< true > & | J | ) | const |
Remove scaling to the Jacobian.
NonlinearSystem::Res< false > unscale | ( | const Res< true > & | r | ) | const |
Remove scaling to the residual.
NonlinearSystem::Sol< false > unscale | ( | const Sol< true > & | u | ) | const |
Remove scaling to the solution.
|
protected |
If true, do automatic scaling.
|
protected |
Maximum number of iterations allowed for the iterative automatic scaling algorithm.
|
protected |
Tolerance for convergence check of the iterative automatic scaling algorithm.
|
protected |
Column scaling "matrix" – since it's a batched diagonal matrix, we are only storing its diagonals.
|
protected |
Row scaling "matrix" – since it's a batched diagonal matrix, we are only storing its diagonals.
|
protected |
Flag to indicate whether scaling matrices have been computed.