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. | |
virtual void | set_guess (const Sol< true > &x) final |
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 |
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 |
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
\( \mathrm{J} \Delta \mathrm{x} = -\mathrm{r} \)
Instead of solving for \( \Delta \mathrm{x} \) directly, we solve for a scaled version of it:
\( \mathrm{J} \mathrm{C} \Delta \mathrm{x}' = -\mathrm{r} \)
where \( \mathrm{C} \) is a diagonal matrix, and apparently \( \Delta \mathrm{x} = \mathrm{C} \Delta \mathrm{x}' \). Then, left-multiply both sides by another diagonal matrix \( \mathrm{R} \), we get
\( \mathrm{R} \mathrm{J} \mathrm{C} \Delta \mathrm{x}' = -\mathrm{R} \mathrm{r} \)
which is equivalent to
\( \mathrm{J}' \Delta \mathrm{x}' = -\mathrm{r}' \)
where \( \mathrm{J}' = \mathrm{R} \mathrm{J} \mathrm{C} \) is the scaled Jacobian, and \( \mathrm{r}' = \mathrm{R} \mathrm{r} \) is the scaled residual. The goal of automatic scaling is to find the scaling matrices so that max-norm of the rows and columns of the scaled Jacobian is as close to 1 as possible.
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.
Convenient shortcut to set the current guess, assemble and return the Jacobian.
|
delete |
|
delete |
NonlinearSystem::Res< scaled > residual | ( | ) |
Assemble and return the residual.
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.
Set the unscaled current guess.
Implemented in Model, and TrustRegionSubProblem.
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.
Maximum number of iterations allowed for the iterative automatic scaling algorithm.
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.