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

A monolith nonlinear system defined by a Model. More...

Detailed Description

A monolith nonlinear system defined by a Model.

#include <ModelNonlinearSystem.h>

Inheritance diagram for ModelNonlinearSystem:

Public Member Functions

 ModelNonlinearSystem (const OptionSet &options)
const std::shared_ptr< Model > & model_ptr () const
const Modelmodel () const
Modelmodel ()
void setup () override
 Setup this object.
void to (const TensorOptions &) override
 Change the device and dtype of the equation system's internal data.
void set_u (const SparseTensorList &) override
 Set the unknown u.
void set_g (const SparseTensorList &) override
 Set the given variables g from the current step.
SparseTensorList u () const override
 Get the unknown u.
SparseTensorList g () const override
 Get the given variables g from the current step.
Public Member Functions inherited from EquationSystem
 EquationSystem (const OptionSet &options)
Public Member Functions inherited from NEML2Object
 NEML2Object ()=delete
 NEML2Object (NEML2Object &&)=delete
 NEML2Object (const NEML2Object &)=delete
NEML2Objectoperator= (NEML2Object &&)=delete
NEML2Objectoperator= (const NEML2Object &)=delete
virtual ~NEML2Object ()=default
 NEML2Object (const OptionSet &options)
 Construct a new NEML2Object object.
const OptionSetinput_options () const
const std::string & name () const
 A readonly reference to the object's name.
const std::string & type () const
 A readonly reference to the object's type.
const std::string & path () const
 A readonly reference to the object's path.
const std::string & doc () const
 A readonly reference to the object's docstring.
Factoryfactory () const
 Get the factory that created this object.
const Settingssettings () const
 Settings.
template<typename T = NEML2Object>
const T * host () const
 Get a readonly pointer to the host.
template<typename T = NEML2Object>
T * host ()
 Get a writable pointer to the host.
template<typename T>
const T & resolve_tensor (const std::string &name)
 Resolve a TensorName to a Tensor.
template<class T>
std::shared_ptr< T > get_object (const std::string &section, const std::string &name)
template<class T = EquationSystem>
std::shared_ptr< T > get_es (const std::string &name)
 Get an equation system from the factory.
template<class T = Solver>
std::shared_ptr< T > get_solver (const std::string &name)
 Get a solver from the factory.
template<class T = Data>
std::shared_ptr< T > get_data (const std::string &name)
 Get a data from the factory.
template<class T = Model>
std::shared_ptr< T > get_model (const std::string &name)
 Get a model from the factory.
template<class T = Driver>
std::shared_ptr< T > get_driver (const std::string &name)
 Get a driver from the factory.
template<class T = WorkScheduler>
std::shared_ptr< T > get_scheduler (const std::string &name)
 Get a scheduler from the factory.
Public Member Functions inherited from NonlinearSystem
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 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.
Public Member Functions inherited from ParameterStore
 ParameterStore (NEML2Object *object)
 ParameterStore (const ParameterStore &)=delete
 ParameterStore (ParameterStore &&)=delete
ParameterStoreoperator= (const ParameterStore &)=delete
ParameterStoreoperator= (ParameterStore &&)=delete
virtual ~ParameterStore ()=default
const std::map< std::string, std::unique_ptr< TensorValueBase > > & named_parameters () const
std::map< std::string, std::unique_ptr< TensorValueBase > > & named_parameters ()
const TensorValueBaseget_parameter (const std::string &name) const
 }@
TensorValueBaseget_parameter (const std::string &name)
 Get a writable reference of a parameter.
void set_parameter (const std::string &, const Tensor &)
 Set the value for a parameter.
void set_parameters (const std::map< std::string, Tensor > &)
 Set values for parameters.
Public Member Functions inherited from BufferStore
 BufferStore (NEML2Object *object)
 BufferStore (const BufferStore &)=delete
 BufferStore (BufferStore &&)=delete
BufferStoreoperator= (const BufferStore &)=delete
BufferStoreoperator= (BufferStore &&)=delete
virtual ~BufferStore ()=default
const std::map< std::string, std::unique_ptr< TensorValueBase > > & named_buffers () const
std::map< std::string, std::unique_ptr< TensorValueBase > > & named_buffers ()
const TensorValueBaseget_buffer (const std::string &name) const
 }@
TensorValueBaseget_buffer (const std::string &name)
 Get a writable reference of a buffer.

Static Public Member Functions

static OptionSet expected_options ()
Static Public Member Functions inherited from EquationSystem
static OptionSet expected_options ()
Static Public Member Functions inherited from NEML2Object
static OptionSet expected_options ()

Protected Member Functions

std::vector< LabeledAxisAccessorsetup_umap () override
 Setup the unknown map.
std::vector< TensorShapesetup_intmd_ulayout () override
 Setup the unknown intermediate layout.
std::vector< TensorShapesetup_ulayout () override
 Setup the unknown layout.
std::vector< LabeledAxisAccessorsetup_bmap () override
 Setup the RHS map.
std::vector< TensorShapesetup_intmd_blayout () override
 Setup the RHS intermediate layout.
std::vector< TensorShapesetup_blayout () override
 Setup the RHS layout.
std::vector< LabeledAxisAccessorsetup_gmap () override
 Setup the given variable map.
std::vector< TensorShapesetup_intmd_glayout () override
 Setup the given variable intermediate layout.
std::vector< TensorShapesetup_glayout () override
 Setup the given variable base layout.
void assemble (SparseTensorList *A, SparseTensorList *B, SparseTensorList *b) override
 Compute the operator and right-hand side.
void pre_assemble (bool A, bool B, bool b) override
 Callback before assembly to perform.
void post_assemble (bool A, bool B, bool b) override
 Callback after assembly to perform.
virtual void send_parameters_to (const TensorOptions &options)
 Send parameters to options.
template<typename T, typename = typename std::enable_if_t<std::is_base_of_v<TensorBase<T>, T>>>
const T & declare_parameter (const std::string &name, const T &rawval)
 Declare a parameter.
template<typename T, typename = typename std::enable_if_t<std::is_base_of_v<TensorBase<T>, T>>>
const T & declare_parameter (const std::string &name, const TensorName< T > &tensorname, bool allow_nonlinear)
 Declare a parameter.
template<typename T, typename = typename std::enable_if_t<std::is_base_of_v<TensorBase<T>, T>>>
const T & declare_parameter (const std::string &name, const std::string &input_option_name, bool allow_nonlinear=false)
 Declare a parameter.
void assign_parameter_stack (jit::Stack &stack)
 Assign stack to parameters.
jit::Stack collect_parameter_stack () const
 Collect stack from parameters.
virtual void send_buffers_to (const TensorOptions &options)
 Send all buffers to options.
template<typename T, typename = typename std::enable_if_t<std::is_base_of_v<TensorBase<T>, T>>>
const T & declare_buffer (const std::string &name, const T &rawval)
 Declare a buffer.
template<typename T, typename = typename std::enable_if_t<std::is_base_of_v<TensorBase<T>, T>>>
const T & declare_buffer (const std::string &name, const TensorName< T > &tensorname)
 Declare a buffer.
template<typename T, typename = typename std::enable_if_t<std::is_base_of_v<TensorBase<T>, T>>>
const T & declare_buffer (const std::string &name, const std::string &input_option_name)
 Declare a buffer.
void assign_buffer_stack (jit::Stack &stack)
 Assign stack to buffers.
jit::Stack collect_buffer_stack () const
 Collect stack from buffers.

Additional Inherited Members

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.

Constructor & Destructor Documentation

◆ ModelNonlinearSystem()

ModelNonlinearSystem ( const OptionSet & options)

Member Function Documentation

◆ assemble()

void assemble ( SparseTensorList * A,
SparseTensorList * B,
SparseTensorList * b )
overrideprotectedvirtual

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

Implements LinearSystem.

◆ expected_options()

OptionSet expected_options ( )
static

◆ g()

SparseTensorList g ( ) const
overridevirtual

Get the given variables g from the current step.

Implements LinearSystem.

◆ model() [1/2]

Model & model ( )
inline

◆ model() [2/2]

const Model & model ( ) const
inline

◆ model_ptr()

const std::shared_ptr< Model > & model_ptr ( ) const
inline

◆ post_assemble()

void post_assemble ( bool A,
bool B,
bool b )
overrideprotectedvirtual

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 from LinearSystem.

◆ pre_assemble()

void pre_assemble ( bool A,
bool B,
bool b )
overrideprotectedvirtual

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 from LinearSystem.

◆ set_g()

void set_g ( const SparseTensorList & )
overridevirtual

Set the given variables g from the current step.

Implements LinearSystem.

◆ set_u()

void set_u ( const SparseTensorList & )
overridevirtual

Set the unknown u.

Implements LinearSystem.

◆ setup()

void setup ( )
overridevirtual

Setup this object.

This method is called automatically if you use the Factory method get_object or get_object, right after construction. This serves as the entry point for things that are not convenient/possible to do at construction time, but are necessary before this object can be used (by others).

Reimplemented from NEML2Object.

◆ setup_blayout()

std::vector< TensorShape > setup_blayout ( )
overrideprotectedvirtual

Setup the RHS layout.

Implements LinearSystem.

◆ setup_bmap()

std::vector< LabeledAxisAccessor > setup_bmap ( )
overrideprotectedvirtual

Setup the RHS map.

Implements LinearSystem.

◆ setup_glayout()

std::vector< TensorShape > setup_glayout ( )
overrideprotectedvirtual

Setup the given variable base layout.

Implements LinearSystem.

◆ setup_gmap()

std::vector< LabeledAxisAccessor > setup_gmap ( )
overrideprotectedvirtual

Setup the given variable map.

Implements LinearSystem.

◆ setup_intmd_blayout()

std::vector< TensorShape > setup_intmd_blayout ( )
overrideprotectedvirtual

Setup the RHS intermediate layout.

Implements LinearSystem.

◆ setup_intmd_glayout()

std::vector< TensorShape > setup_intmd_glayout ( )
overrideprotectedvirtual

Setup the given variable intermediate layout.

Implements LinearSystem.

◆ setup_intmd_ulayout()

std::vector< TensorShape > setup_intmd_ulayout ( )
overrideprotectedvirtual

Setup the unknown intermediate layout.

Implements LinearSystem.

◆ setup_ulayout()

std::vector< TensorShape > setup_ulayout ( )
overrideprotectedvirtual

Setup the unknown layout.

Implements LinearSystem.

◆ setup_umap()

std::vector< LabeledAxisAccessor > setup_umap ( )
overrideprotectedvirtual

Setup the unknown map.

Implements LinearSystem.

◆ to()

void to ( const TensorOptions & )
overridevirtual

Change the device and dtype of the equation system's internal data.

Reimplemented from EquationSystem.

◆ u()

SparseTensorList u ( ) const
overridevirtual

Get the unknown u.

Implements LinearSystem.