NEML2 2.1.0
Loading...
Searching...
No Matches

Definition of a linear system of equations, Au = b. More...

Detailed Description

Definition of a linear system of equations, Au = b.

#include <LinearSystem.h>

Inheritance diagram for LinearSystem:

Public Member Functions

 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 u_changed ()
 Trigger when unknown variables changed.
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.

Protected Member Functions

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

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.

Constructor & Destructor Documentation

◆ LinearSystem() [1/3]

LinearSystem ( )
default

◆ LinearSystem() [2/3]

LinearSystem ( const LinearSystem & )
default

◆ LinearSystem() [3/3]

LinearSystem ( LinearSystem && )
defaultnoexcept

◆ ~LinearSystem()

virtual ~LinearSystem ( )
virtualdefault

Member Function Documentation

◆ A()

Assemble and return the operator, A.

◆ A_and_B()

std::tuple< SparseTensorList, SparseTensorList > A_and_B ( )

Assemble the auxiliary matrix B = dr/dg along with A.

◆ A_and_b()

std::tuple< SparseTensorList, SparseTensorList > A_and_b ( )

Assemble and return the right-hand side and operator.

◆ A_and_B_and_b()

std::tuple< SparseTensorList, SparseTensorList, SparseTensorList > A_and_B_and_b ( )

Assemble the auxiliary matrix B = dr/dg along with A and b.

◆ assemble()

virtual void assemble ( SparseTensorList * A,
SparseTensorList * B,
SparseTensorList * b )
protectedpure virtual

Compute the operator and right-hand side.

Parameters
APointer to the operator matrix – nullptr if not requested
BPointer to the auxiliary matrix – nullptr if not requested
bPointer to the RHS vector – nullptr if not requested

Implemented in ModelNonlinearSystem.

◆ b()

Assemble and return the right-hand side, b.

◆ blayout()

const std::vector< TensorShape > & blayout ( ) const

Get the ID-to-RHS-base-shape mapping for assembly.

◆ bmap()

const std::vector< LabeledAxisAccessor > & bmap ( ) const

Get the ID-to-RHS mapping for assembly.

◆ g()

virtual SparseTensorList g ( ) const
pure virtual

Get the given variables g from the current step.

Implemented in ModelNonlinearSystem.

◆ g_changed()

virtual void g_changed ( )
virtual

Trigger when given variables changed.

◆ glayout()

const std::vector< TensorShape > & glayout ( ) const

Get the ID-to-prescribed-variable-base-shape mapping for assembly.

◆ gmap()

const std::vector< LabeledAxisAccessor > & gmap ( ) const

Get the ID-to-prescribed-variable mapping for assembly.

◆ init()

virtual void init ( )
virtual

◆ intmd_blayout()

const std::vector< TensorShape > & intmd_blayout ( ) const

Get the ID-to-RHS-intermediate-shape mapping for assembly.

◆ intmd_glayout()

const std::vector< TensorShape > & intmd_glayout ( ) const

Get the ID-to-prescribed-variable-intermediate-shape mapping for assembly.

◆ intmd_ulayout()

const std::vector< TensorShape > & intmd_ulayout ( ) const

Get the ID-to-unknown-intermediate-shape mapping for assembly.

◆ m()

std::size_t m ( ) const

Number of rows in the matrix.

◆ n()

std::size_t n ( ) const

Number of columns in the matrix.

◆ operator=() [1/2]

LinearSystem & operator= ( const LinearSystem & )
default

◆ operator=() [2/2]

LinearSystem & operator= ( LinearSystem && )
defaultnoexcept

◆ p()

std::size_t p ( ) const

Number of columns in the auxiliary matrix.

◆ post_assemble()

virtual void post_assemble ( bool A,
bool B,
bool b )
protectedvirtual

Callback after assembly to perform.

This is useful, for example, to collect information that isn't available after the first assembly

Parameters
AWhether the operator matrix was assembled
BWhether the auxiliary matrix was assembled
bWhether the RHS vector was assembled

Reimplemented in ModelNonlinearSystem.

◆ pre_assemble()

virtual void pre_assemble ( bool A,
bool B,
bool b )
protectedvirtual

Callback before assembly to perform.

This is useful, for example, to clear obsolete data structures

Parameters
AWhether the operator matrix was assembled
BWhether the auxiliary matrix was assembled
bWhether the RHS vector was assembled

Reimplemented in ModelNonlinearSystem.

◆ set_g()

virtual void set_g ( const SparseTensorList & )
pure virtual

Set the given variables g from the current step.

Implemented in ModelNonlinearSystem.

◆ set_u()

virtual void set_u ( const SparseTensorList & )
pure virtual

Set the unknown u.

Implemented in ModelNonlinearSystem.

◆ setup_blayout()

virtual std::vector< TensorShape > setup_blayout ( )
protectedpure virtual

Setup the RHS layout.

Implemented in ModelNonlinearSystem.

◆ setup_bmap()

virtual std::vector< LabeledAxisAccessor > setup_bmap ( )
protectedpure virtual

Setup the RHS map.

Implemented in ModelNonlinearSystem.

◆ setup_glayout()

virtual std::vector< TensorShape > setup_glayout ( )
protectedpure virtual

Setup the given variable base layout.

Implemented in ModelNonlinearSystem.

◆ setup_gmap()

virtual std::vector< LabeledAxisAccessor > setup_gmap ( )
protectedpure virtual

Setup the given variable map.

Implemented in ModelNonlinearSystem.

◆ setup_intmd_blayout()

virtual std::vector< TensorShape > setup_intmd_blayout ( )
protectedpure virtual

Setup the RHS intermediate layout.

Implemented in ModelNonlinearSystem.

◆ setup_intmd_glayout()

virtual std::vector< TensorShape > setup_intmd_glayout ( )
protectedpure virtual

Setup the given variable intermediate layout.

Implemented in ModelNonlinearSystem.

◆ setup_intmd_ulayout()

virtual std::vector< TensorShape > setup_intmd_ulayout ( )
protectedpure virtual

Setup the unknown intermediate layout.

Implemented in ModelNonlinearSystem.

◆ setup_ulayout()

virtual std::vector< TensorShape > setup_ulayout ( )
protectedpure virtual

Setup the unknown layout.

Implemented in ModelNonlinearSystem.

◆ setup_umap()

virtual std::vector< LabeledAxisAccessor > setup_umap ( )
protectedpure virtual

Setup the unknown map.

Implemented in ModelNonlinearSystem.

◆ u()

virtual SparseTensorList u ( ) const
pure virtual

Get the unknown u.

Implemented in ModelNonlinearSystem.

◆ u_changed()

virtual void u_changed ( )
virtual

Trigger when unknown variables changed.

Reimplemented in NonlinearSystem.

◆ ulayout()

const std::vector< TensorShape > & ulayout ( ) const

Get the ID-to-unknown-base-shape mapping for assembly.

◆ umap()

const std::vector< LabeledAxisAccessor > & umap ( ) const

Get the ID-to-unknown mapping for assembly.

Member Data Documentation

◆ _A_up_to_date

bool _A_up_to_date = false
protected

Flag indicating if the system matrix is up to date. Setters invalidate this.

◆ _B_up_to_date

bool _B_up_to_date = false
protected

Flag indicating if the auxiliary matrix is up to date. Setters invalidate this.

◆ _b_up_to_date

bool _b_up_to_date = false
protected

Flag indicating if the system RHS is up to date. Setters invalidate this.

◆ _blayout

std::vector<TensorShape> _blayout
protected

ID-to-RHS shape mapping.

◆ _bmap

std::vector<LabeledAxisAccessor> _bmap
protected

The ID-to-RHS mapping.

The RHS is ordered according to this mapping. This mapping is used by assemble() to collect values in a consistent order.

◆ _glayout

std::vector<TensorShape> _glayout
protected

ID-to-given base shape mapping.

◆ _gmap

std::vector<LabeledAxisAccessor> _gmap
protected

The ID-to-given-variable mapping.

The vector of given variables is ordered according to this mapping.

◆ _intmd_blayout

std::optional<std::vector<TensorShape> > _intmd_blayout
protected

ID-to-RHS intermediate shape mapping.

◆ _intmd_glayout

std::optional<std::vector<TensorShape> > _intmd_glayout
protected

ID-to-given intermediate shape mapping.

◆ _intmd_ulayout

std::optional<std::vector<TensorShape> > _intmd_ulayout
protected

ID-to-unknown intermediate shape mapping.

◆ _ulayout

std::vector<TensorShape> _ulayout
protected

ID-to-unknown base shape mapping.

◆ _umap

std::vector<LabeledAxisAccessor> _umap
protected

The ID-to-unknown mapping.

The solution vector is ordered according to this mapping. This mapping is used by assemble() to collect values in a consistent order.