NEML2 2.1.0
Loading...
Searching...
No Matches
NonlinearSystem Class Reference

Definition of a nonlinear system of equations, r(u) = 0. More...

Detailed Description

Definition of a nonlinear system of equations, r(u) = 0.

Instead of directly defining a nonlinear system, we define the linearized system via its residual and Jacobian, evaluated at a given state u with given variables g, the linearized system is usually expressed as dr(u; g)/du * du = -r(u; g). Rewriting this in the more familiar form Au = b, we have A := dr(u; g)/du and b := -r(u; g).

Practically, this means that whenever u or g changes, we need to invalidate the system matrix A and RHS b, and recompute them when requested.

#include <NonlinearSystem.h>

Inheritance diagram for NonlinearSystem:

Public Member Functions

void u_changed () override
 Trigger when unknown variables changed.
 LinearSystem ()=default
 LinearSystem (const LinearSystem &)=default
 LinearSystem (LinearSystem &&) noexcept=default
Public Member Functions inherited from LinearSystem
 LinearSystem ()=default
 LinearSystem (const LinearSystem &)=default
 LinearSystem (LinearSystem &&) noexcept=default
LinearSystemoperator= (const LinearSystem &)=default
LinearSystemoperator= (LinearSystem &&) noexcept=default
virtual ~LinearSystem ()=default
virtual void init ()
std::size_t m () const
 Number of rows in the matrix.
std::size_t n () const
 Number of columns in the matrix.
std::size_t p () const
 Number of columns in the auxiliary matrix.
virtual void set_u (const SparseTensorList &)=0
 Set the unknown u.
virtual void set_g (const SparseTensorList &)=0
 Set the given variables g from the current step.
virtual SparseTensorList u () const =0
 Get the unknown u.
virtual SparseTensorList g () const =0
 Get the given variables g from the current step.
virtual void g_changed ()
 Trigger when given variables changed.
SparseTensorList A ()
 Assemble and return the operator, A.
SparseTensorList b ()
 Assemble and return the right-hand side, b.
std::tuple< SparseTensorList, SparseTensorListA_and_b ()
 Assemble and return the right-hand side and operator.
std::tuple< SparseTensorList, SparseTensorListA_and_B ()
 Assemble the auxiliary matrix B = dr/dg along with A.
std::tuple< SparseTensorList, SparseTensorList, SparseTensorListA_and_B_and_b ()
 Assemble the auxiliary matrix B = dr/dg along with A and b.
const std::vector< LabeledAxisAccessor > & umap () const
 Get the ID-to-unknown mapping for assembly.
const std::vector< TensorShape > & intmd_ulayout () const
 Get the ID-to-unknown-intermediate-shape mapping for assembly.
const std::vector< TensorShape > & ulayout () const
 Get the ID-to-unknown-base-shape mapping for assembly.
const std::vector< LabeledAxisAccessor > & gmap () const
 Get the ID-to-prescribed-variable mapping for assembly.
const std::vector< TensorShape > & intmd_glayout () const
 Get the ID-to-prescribed-variable-intermediate-shape mapping for assembly.
const std::vector< TensorShape > & glayout () const
 Get the ID-to-prescribed-variable-base-shape mapping for assembly.
const std::vector< LabeledAxisAccessor > & bmap () const
 Get the ID-to-RHS mapping for assembly.
const std::vector< TensorShape > & intmd_blayout () const
 Get the ID-to-RHS-intermediate-shape mapping for assembly.
const std::vector< TensorShape > & blayout () const
 Get the ID-to-RHS-base-shape mapping for assembly.

Additional Inherited Members

Protected Member Functions inherited from LinearSystem
virtual std::vector< LabeledAxisAccessorsetup_umap ()=0
 Setup the unknown map.
virtual std::vector< TensorShapesetup_intmd_ulayout ()=0
 Setup the unknown intermediate layout.
virtual std::vector< TensorShapesetup_ulayout ()=0
 Setup the unknown layout.
virtual std::vector< LabeledAxisAccessorsetup_gmap ()=0
 Setup the given variable map.
virtual std::vector< TensorShapesetup_intmd_glayout ()=0
 Setup the given variable intermediate layout.
virtual std::vector< TensorShapesetup_glayout ()=0
 Setup the given variable base layout.
virtual std::vector< LabeledAxisAccessorsetup_bmap ()=0
 Setup the RHS map.
virtual std::vector< TensorShapesetup_intmd_blayout ()=0
 Setup the RHS intermediate layout.
virtual std::vector< TensorShapesetup_blayout ()=0
 Setup the RHS layout.
virtual void assemble (SparseTensorList *A, SparseTensorList *B, SparseTensorList *b)=0
 Compute the operator and right-hand side.
virtual void pre_assemble (bool A, bool B, bool b)
 Callback before assembly to perform.
virtual void post_assemble (bool A, bool B, bool b)
 Callback after assembly to perform.
Protected Attributes inherited from LinearSystem
bool _A_up_to_date = false
 Flag indicating if the system matrix is up to date. Setters invalidate this.
bool _B_up_to_date = false
 Flag indicating if the auxiliary matrix is up to date. Setters invalidate this.
bool _b_up_to_date = false
 Flag indicating if the system RHS is up to date. Setters invalidate this.
std::vector< LabeledAxisAccessor_umap
 The ID-to-unknown mapping.
std::optional< std::vector< TensorShape > > _intmd_ulayout
 ID-to-unknown intermediate shape mapping.
std::vector< TensorShape_ulayout
 ID-to-unknown base shape mapping.
std::vector< LabeledAxisAccessor_gmap
 The ID-to-given-variable mapping.
std::optional< std::vector< TensorShape > > _intmd_glayout
 ID-to-given intermediate shape mapping.
std::vector< TensorShape_glayout
 ID-to-given base shape mapping.
std::vector< LabeledAxisAccessor_bmap
 The ID-to-RHS mapping.
std::optional< std::vector< TensorShape > > _intmd_blayout
 ID-to-RHS intermediate shape mapping.
std::vector< TensorShape_blayout
 ID-to-RHS shape mapping.

Member Function Documentation

◆ LinearSystem() [1/3]

LinearSystem ( )
default

◆ LinearSystem() [2/3]

LinearSystem ( const LinearSystem & )
default

◆ LinearSystem() [3/3]

LinearSystem ( LinearSystem && )
defaultnoexcept

◆ u_changed()

void u_changed ( )
overridevirtual

Trigger when unknown variables changed.

Reimplemented from LinearSystem.