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 AssembledVector &) override
 Set the unknown u.
void set_g (const AssembledVector &) override
 Set the given variables g from the current step.
AssembledVector u () const override
 Get the unknown u.
AssembledVector 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.
std::string type () const
 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 ()
 Setup axis layouts.
virtual void g_changed ()
 Trigger when given variables changed.
AssembledMatrix A ()
 Assemble and return the operator, A.
AssembledVector b ()
 Assemble and return the right-hand side, b.
std::tuple< AssembledMatrix, AssembledVectorA_and_b ()
 Assemble and return the right-hand side and operator.
std::tuple< AssembledMatrix, AssembledMatrixA_and_B ()
 Assemble the auxiliary matrix B = dr/dg along with A.
std::tuple< AssembledMatrix, AssembledMatrix, AssembledVectorA_and_B_and_b ()
 Assemble the auxiliary matrix B = dr/dg along with A and b.
AxisLayout ulayout () const
 Get the unknown-variable layout.
AxisLayout glayout () const
 Get the given-variable layout.
AxisLayout blayout () const
 Get the RHS variable layout.
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::shared_ptr< AxisLayoutsetup_ulayout () override
 Setup the unknown layout, partitioned by variable group.
std::shared_ptr< AxisLayoutsetup_glayout () override
 Setup the given variable layout.
std::shared_ptr< AxisLayoutsetup_blayout () override
 Setup the RHS variable layout.
void assemble (AssembledMatrix *A, AssembledMatrix *B, AssembledVector *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.
Protected Member Functions inherited from NEML2Object
VariableName history_name (const VariableName &var, std::size_t nstep) const
 Helper method to wrap a variable name into its history form.
VariableName rate_name (const VariableName &var) const
 Helper method to wrap a variable name into its rate form.
VariableName residual_name (const VariableName &var) const
 Helper method to wrap a variable name into its residual form.
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::shared_ptr< AxisLayout_ulayout
 Layout of unknowns, partitioned by variable groups.
std::shared_ptr< AxisLayout_glayout
 Layout of given variables.
std::shared_ptr< AxisLayout_blayout
 Layout of RHS variables, partitioned by variable groups.

Constructor & Destructor Documentation

◆ ModelNonlinearSystem()

ModelNonlinearSystem ( const OptionSet & options)

Member Function Documentation

◆ assemble()

void assemble ( AssembledMatrix * A,
AssembledMatrix * B,
AssembledVector * 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()

AssembledVector 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 AssembledVector & )
overridevirtual

Set the given variables g from the current step.

Implements LinearSystem.

◆ set_u()

void set_u ( const AssembledVector & )
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::shared_ptr< AxisLayout > setup_blayout ( )
overrideprotectedvirtual

Setup the RHS variable layout.

Implements LinearSystem.

◆ setup_glayout()

std::shared_ptr< AxisLayout > setup_glayout ( )
overrideprotectedvirtual

Setup the given variable layout.

Implements LinearSystem.

◆ setup_ulayout()

std::shared_ptr< AxisLayout > setup_ulayout ( )
overrideprotectedvirtual

Setup the unknown layout, partitioned by variable group.

Implements LinearSystem.

◆ to()

void to ( const TensorOptions & )
overridevirtual

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

Reimplemented from EquationSystem.

◆ u()

AssembledVector u ( ) const
overridevirtual

Get the unknown u.

Implements LinearSystem.