NEML2 1.4.0
Loading...
Searching...
No Matches
NonlinearSystem Class Referenceabstract

Definition of a nonlinear system of equations. More...

Detailed Description

Definition of a nonlinear system of equations.

#include <NonlinearSystem.h>

Inheritance diagram for NonlinearSystem:

Public Member Functions

 NonlinearSystem (const OptionSet &options)
 
virtual void init_scaling (const bool verbose=false)
 Compute algebraic Jacobian-based automatic scaling following https://cs.stanford.edu/people/paulliu/files/cs517-project.pdf.
 
Tensor scale_residual (const Tensor &r) const
 Apply scaling to the residual.
 
Tensor scale_Jacobian (const Tensor &J) const
 Apply scaling to the Jacobian.
 
Tensor scale_direction (const Tensor &p) const
 Remove scaling from the search direction, i.e. \( J^{-1} r \).
 
virtual void set_solution (const Tensor &x)
 Set the solution vector.
 
virtual Tensor solution () const
 Get the solution vector.
 
Tensor residual (const Tensor &x)
 Convenient shortcut to set the current solution, assemble and return the system residual.
 
void residual ()
 Convenient shortcut to assemble and return the system residual.
 
Tensor Jacobian (const Tensor &x)
 Convenient shortcut to set the current solution, assemble and return the system Jacobian.
 
void Jacobian ()
 Convenient shortcut to assemble and return the system Jacobian.
 
std::tuple< Tensor, Tensorresidual_and_Jacobian (const Tensor &x)
 Convenient shortcut to set the current solution, assemble and return the system residual and Jacobian.
 
void residual_and_Jacobian ()
 Convenient shortcut to assemble and return the system residual and Jacobian.
 
const Tensorget_residual () const
 
const Tensorget_Jacobian () const
 
Tensor residual_norm () const
 The residual norm.
 
virtual bool is_AD_enabled () const
 Whether AD is enabled.
 
virtual bool is_AD_disabled () const final
 Whether AD is disabled.
 

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 (bool residual, bool Jacobian)=0
 Compute the residual and Jacobian.
 

Protected Attributes

Size _ndof
 Number of degrees of freedom.
 
Tensor _solution
 View for the solution of this nonlinear system.
 
Tensor _residual
 View for the residual of this nonlinear system.
 
Tensor _Jacobian
 View for the Jacobian of this nonlinear system.
 
Tensor _scaled_residual
 
Tensor _scaled_Jacobian
 
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.
 

Constructor & Destructor Documentation

◆ NonlinearSystem()

Member Function Documentation

◆ assemble()

virtual void assemble ( bool residual,
bool Jacobian )
protectedpure virtual

Compute the residual and Jacobian.

Parameters
residualWhether residual is requested
JacobianWhether Jacobian is requested

Implemented in Model, and TrustRegionSubProblem.

◆ disable_automatic_scaling()

void disable_automatic_scaling ( OptionSet & options)
static

◆ enable_automatic_scaling()

void enable_automatic_scaling ( OptionSet & options)
static

◆ expected_options()

OptionSet expected_options ( )
static

◆ get_Jacobian()

const Tensor & get_Jacobian ( ) const
inline

◆ get_residual()

const Tensor & get_residual ( ) const
inline

◆ init_scaling()

void init_scaling ( const bool verbose = false)
virtual

Compute algebraic Jacobian-based automatic scaling following https://cs.stanford.edu/people/paulliu/files/cs517-project.pdf.

Parameters
verbosePrint automatic scaling convergence information

◆ is_AD_disabled()

virtual bool is_AD_disabled ( ) const
inlinefinalvirtual

Whether AD is disabled.

◆ is_AD_enabled()

virtual bool is_AD_enabled ( ) const
inlinevirtual

Whether AD is enabled.

Reimplemented in Model.

◆ Jacobian() [1/2]

void Jacobian ( )

Convenient shortcut to assemble and return the system Jacobian.

◆ Jacobian() [2/2]

Tensor Jacobian ( const Tensor & x)

Convenient shortcut to set the current solution, assemble and return the system Jacobian.

◆ residual() [1/2]

void residual ( )

Convenient shortcut to assemble and return the system residual.

◆ residual() [2/2]

Tensor residual ( const Tensor & x)

Convenient shortcut to set the current solution, assemble and return the system residual.

◆ residual_and_Jacobian() [1/2]

void residual_and_Jacobian ( )

Convenient shortcut to assemble and return the system residual and Jacobian.

◆ residual_and_Jacobian() [2/2]

std::tuple< Tensor, Tensor > residual_and_Jacobian ( const Tensor & x)

Convenient shortcut to set the current solution, assemble and return the system residual and Jacobian.

◆ residual_norm()

Tensor residual_norm ( ) const

The residual norm.

◆ scale_direction()

Tensor scale_direction ( const Tensor & p) const

Remove scaling from the search direction, i.e. \( J^{-1} r \).

◆ scale_Jacobian()

Tensor scale_Jacobian ( const Tensor & J) const

Apply scaling to the Jacobian.

◆ scale_residual()

Tensor scale_residual ( const Tensor & r) const

Apply scaling to the residual.

◆ set_solution()

void set_solution ( const Tensor & x)
virtual

Set the solution vector.

Reimplemented in Model.

◆ solution()

virtual Tensor solution ( ) const
inlinevirtual

Get the solution vector.

Member Data Documentation

◆ _autoscale

const bool _autoscale
protected

If true, do automatic scaling.

◆ _autoscale_miter

const unsigned int _autoscale_miter
protected

Maximum number of iterations allowed for the iterative automatic scaling algorithm.

◆ _autoscale_tol

const Real _autoscale_tol
protected

Tolerance for convergence check of the iterative automatic scaling algorithm.

◆ _col_scaling

Tensor _col_scaling
protected

Column scaling "matrix" – since it's a batched diagonal matrix, we are only storing its diagonals.

◆ _Jacobian

Tensor _Jacobian
protected

View for the Jacobian of this nonlinear system.

◆ _ndof

Size _ndof
protected

Number of degrees of freedom.

◆ _residual

Tensor _residual
protected

View for the residual of this nonlinear system.

◆ _row_scaling

Tensor _row_scaling
protected

Row scaling "matrix" – since it's a batched diagonal matrix, we are only storing its diagonals.

◆ _scaled_Jacobian

Tensor _scaled_Jacobian
protected

◆ _scaled_residual

Tensor _scaled_residual
protected

◆ _scaling_matrices_initialized

bool _scaling_matrices_initialized
protected

Flag to indicate whether scaling matrices have been computed.

◆ _solution

Tensor _solution
protected

View for the solution of this nonlinear system.