NEML2 2.0.0
All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
Model Class Referenceabstract

The base class for all constitutive models. More...

Detailed Description

The base class for all constitutive models.

A model maps some input to output. The forward operator (and its derivative) is defined in the method Model::set_value. All concrete models must provide the implementation of the forward operator by overriding the Model::set_value method.

#include <Model.h>

Inherits enable_shared_from_this< Model >, Data, ParameterStore, VariableStore, NonlinearSystem, DependencyDefinition< VariableName >, and DiagnosticsInterface.

Inherited by BackwardEulerTimeIntegration< Scalar >, BackwardEulerTimeIntegration< Vec >, BackwardEulerTimeIntegration< SR2 >, CrystalMean< SR2 >, ElasticityInterface< Model, 3 >, ElasticityInterface< Model, 2 >, ForwardEulerTimeIntegration< Scalar >, ForwardEulerTimeIntegration< Vec >, ForwardEulerTimeIntegration< SR2 >, IncrementToRate< Scalar >, IncrementToRate< Vec >, IncrementToRate< SR2 >, IncrementToRate< R2 >, LinearCombination< Scalar >, LinearCombination< Vec >, LinearCombination< SR2 >, TwoStageThermalAnnealing< Scalar >, TwoStageThermalAnnealing< SR2 >, VariableRate< Scalar >, VariableRate< Vec >, VariableRate< SR2 >, ArrheniusParameter, AssociativeJ2FlowDirection, BackwardEulerTimeIntegration< T >, ComposedModel, ConstantParameter< T >, CopyVariable< T >, CrystalMean< T >, DiffusionLimitedReaction, Eigenstrain, ElasticStrainRate, Elasticity, FischerBurmeister, FixOrientation, FlowRule, ForwardEulerTimeIntegration< T >, GTNYieldFunction, GursonCavitation, HermiteSmoothStep, ImplicitUpdate, IncrementToRate< T >, InputParameter< T >, Interpolation< T >, IsotropicHardening, IsotropicHardeningStaticRecovery, KinematicHardening, KinematicHardeningStaticRecovery, KocksMeckingActivationEnergy, KocksMeckingFlowSwitch, KocksMeckingFlowViscosity, KocksMeckingIntercept, KocksMeckingRateSensitivity, KocksMeckingYieldStress, LinearCombination< T >, MandelStress, MixedControlSetup, Normality, OlevskySinteringStress, OrientationRate, PlasticDeformationRate, PlasticFlowRate, PlasticVorticity, ProductGeometry, ProjectileAcceleration, ProjectileAcceleration, ProjectileAcceleration, ProjectileAcceleration, PyrolysisConversionAmount, PyrolysisKinetics, R2toSR2, R2toWR2, RateIndependentPlasticFlowConstraint, ReactionMechanism, ResolvedShear, RotationMatrix, SR2Invariant, SR2toR2, ScalarVariableMultiplication, SingleSlipHardeningRule, SlipRule, SlipStrengthMap, SumSlipRates, TwoStageThermalAnnealing< T >, VariableRate< T >, WR2ExplicitExponentialTimeIntegration, WR2ImplicitExponentialTimeIntegration, and YieldFunction.

Classes

struct  TraceSchema
 Schema for the traced forward operators. More...
 

Public Member Functions

 Model (const OptionSet &options)
 Construct a new Model object.
 
void setup () override
 Setup this object.
 
void diagnose () const override
 Check for common problems.
 
virtual bool defines_values () const
 Whether this model defines output values.
 
virtual bool defines_derivatives () const
 Whether this model defines first derivatives.
 
virtual bool defines_second_derivatives () const
 Whether this model defines second derivatives.
 
virtual bool is_nonlinear_system () const
 Whether this model defines one or more nonlinear equations to be solved.
 
virtual bool is_jit_enabled () const
 Whether JIT is enabled.
 
virtual void to (const TensorOptions &options)
 Send model to a different device or dtype.
 
const std::vector< Model * > & registered_models () const
 The models that may be used during the evaluation of this model.
 
Modelregistered_model (const std::string &name) const
 Get a registered model by its name.
 
void register_nonlinear_parameter (const std::string &pname, const NonlinearParameter &param)
 Register a nonlinear parameter.
 
bool has_nl_param (bool recursive=false) const
 Whether this parameter store has any nonlinear parameter.
 
const VariableBasenl_param (const std::string &) const
 Query the existence of a nonlinear parameter.
 
virtual std::map< std::string, NonlinearParameternamed_nonlinear_parameters (bool recursive=false) const
 Get all nonlinear parameters.
 
std::set< VariableNameconsumed_items () const override
 The variables that this model depends on.
 
std::set< VariableNameprovided_items () const override
 The variables that this model defines as part of its output.
 
void request_AD (VariableBase &y, const VariableBase &u)
 Request to use AD to compute the first derivative of a variable.
 
void request_AD (VariableBase &y, const VariableBase &u1, const VariableBase &u2)
 Request to use AD to compute the second derivative of a variable.
 
void forward (bool out, bool dout, bool d2out)
 Forward operator without jit.
 
void forward_maybe_jit (bool out, bool dout, bool d2out)
 Forward operator with jit.
 
std::string variable_name_lookup (const ATensor &var)
 Look up the name of a variable in the traced graph.
 
virtual ValueMap value (const ValueMap &in)
 Convenient shortcut to construct and return the model value.
 
virtual ValueMap value (ValueMap &&in)
 
virtual std::tuple< ValueMap, DerivMapvalue_and_dvalue (const ValueMap &in)
 Convenient shortcut to construct and return the model value and its derivative.
 
virtual std::tuple< ValueMap, DerivMapvalue_and_dvalue (ValueMap &&in)
 
virtual DerivMap dvalue (const ValueMap &in)
 Convenient shortcut to construct and return the derivative.
 
virtual DerivMap dvalue (ValueMap &&in)
 
virtual std::tuple< ValueMap, DerivMap, SecDerivMapvalue_and_dvalue_and_d2value (const ValueMap &in)
 Convenient shortcut to construct and return the model's value, first and second derivative.
 
virtual std::tuple< ValueMap, DerivMap, SecDerivMapvalue_and_dvalue_and_d2value (ValueMap &&in)
 
virtual SecDerivMap d2value (const ValueMap &in)
 Convenient shortcut to construct and return the model's second derivative.
 
virtual SecDerivMap d2value (ValueMap &&in)
 
virtual std::tuple< DerivMap, SecDerivMapdvalue_and_d2value (const ValueMap &in)
 Convenient shortcut to construct and return the model's first and second derivative.
 
virtual std::tuple< DerivMap, SecDerivMapdvalue_and_d2value (ValueMap &&in)
 
- Public Member Functions inherited from Data
 Data (const OptionSet &options)
 Construct a new Data object.
 
const std::vector< Data * > & registered_data () const
 All the registered data objects.
 
- 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.
 
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.
 
- 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.
 
- Public Member Functions inherited from ParameterStore
 ParameterStore (Model *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 VariableStore
 VariableStore (Model *object)
 
 VariableStore (const VariableStore &)=delete
 
 VariableStore (VariableStore &&)=delete
 
VariableStoreoperator= (const VariableStore &)=delete
 
VariableStoreoperator= (VariableStore &&)=delete
 
virtual ~VariableStore ()=default
 
LabeledAxisdeclare_axis (const std::string &name)
 
virtual void setup_layout ()
 Setup the layout of all the registered axes.
 
const TensorOptionsvariable_options () const
 Current tensor options for variables.
 
LabeledAxisinput_axis ()
 
const LabeledAxisinput_axis () const
 
LabeledAxisoutput_axis ()
 
const LabeledAxisoutput_axis () const
 
VariableStorageinput_variables ()
 
const VariableStorageinput_variables () const
 
VariableStorageoutput_variables ()
 
const VariableStorageoutput_variables () const
 
VariableBaseinput_variable (const VariableName &)
 
const VariableBaseinput_variable (const VariableName &) const
 
VariableBaseoutput_variable (const VariableName &)
 
const VariableBaseoutput_variable (const VariableName &) const
 
void assign_input (const ValueMap &vals)
 
void assign_input (ValueMap &&vals)
 Assign input variable values.
 
void assign_output (const ValueMap &vals)
 Assign output variable values.
 
void assign_output_derivatives (const DerivMap &derivs)
 Assign variable derivatives.
 
ValueMap collect_input () const
 
ValueMap collect_output () const
 
DerivMap collect_output_derivatives () const
 Collect variable derivatives.
 
SecDerivMap collect_output_second_derivatives () const
 Collect variable second derivatives.
 
- Public Member Functions inherited from NonlinearSystem
 NonlinearSystem (const NonlinearSystem &)=default
 
 NonlinearSystem (NonlinearSystem &&) noexcept=default
 
NonlinearSystemoperator= (const NonlinearSystem &)=delete
 
NonlinearSystemoperator= (NonlinearSystem &&)=delete
 
virtual ~NonlinearSystem ()=default
 
 NonlinearSystem (const OptionSet &options)
 
virtual void init_scaling (const Sol< false > &x, const bool verbose=false)
 Compute algebraic Jacobian-based automatic scaling following https://cs.stanford.edu/people/paulliu/files/cs517-project.pdf.
 
Res< true > scale (const Res< false > &r) const
 Apply scaling to the residual.
 
Res< false > unscale (const Res< true > &r) const
 Remove scaling to the residual.
 
Jac< true > scale (const Jac< false > &J) const
 Apply scaling to the Jacobian.
 
Jac< false > unscale (const Jac< true > &J) const
 Remove scaling to the Jacobian.
 
Sol< true > scale (const Sol< false > &u) const
 Apply scaling to the solution.
 
Sol< false > unscale (const Sol< true > &u) const
 Remove scaling to the solution.
 
void set_guess (const Sol< true > &x)
 Set the current guess.
 
template<bool scaled>
Res< scaled > residual ()
 Assemble and return the residual.
 
template<bool scaled>
Res< scaled > residual (const Sol< scaled > &x)
 Convenient shortcut to set the current guess, assemble and return the residual.
 
template<bool scaled>
Jac< scaled > Jacobian ()
 Assemble and return the Jacobian.
 
template<bool scaled>
Jac< scaled > Jacobian (const Sol< scaled > &x)
 Convenient shortcut to set the current guess, assemble and return the Jacobian.
 
template<bool scaled>
std::tuple< Res< scaled >, Jac< scaled > > residual_and_Jacobian ()
 Assemble and return the residual and Jacobian.
 
template<bool scaled>
std::tuple< Res< scaled >, Jac< scaled > > residual_and_Jacobian (const Sol< scaled > &x)
 Convenient shortcut to set the current guess, assemble and return the residual and Jacobian.
 
- Public Member Functions inherited from DependencyDefinition< VariableName >
 DependencyDefinition ()=default
 
 DependencyDefinition (DependencyDefinition &&)=delete
 
 DependencyDefinition (const DependencyDefinition &)=delete
 
DependencyDefinitionoperator= (const DependencyDefinition &)=delete
 
DependencyDefinitionoperator= (DependencyDefinition &&)=delete
 
virtual ~DependencyDefinition ()=default
 
- Public Member Functions inherited from DiagnosticsInterface
 DiagnosticsInterface ()=delete
 
 DiagnosticsInterface (NEML2Object *object)
 
 DiagnosticsInterface (DiagnosticsInterface &&)=delete
 
 DiagnosticsInterface (const DiagnosticsInterface &)=delete
 
DiagnosticsInterfaceoperator= (const DiagnosticsInterface &)=delete
 
DiagnosticsInterfaceoperator= (DiagnosticsInterface &&)=delete
 
virtual ~DiagnosticsInterface ()=default
 
const NEML2Objectobject () const
 Get the object.
 

Static Public Member Functions

static OptionSet expected_options ()
 
- Static Public Member Functions inherited from Data
static OptionSet expected_options ()
 
- Static Public Member Functions inherited from NEML2Object
static OptionSet expected_options ()
 
- Static Public Member Functions inherited from NonlinearSystem
static OptionSet expected_options ()
 
static void disable_automatic_scaling (OptionSet &options)
 
static void enable_automatic_scaling (OptionSet &options)
 

Protected Member Functions

void diagnostic_assert_state (const VariableBase &v) const
 
void diagnostic_assert_old_state (const VariableBase &v) const
 
void diagnostic_assert_force (const VariableBase &v) const
 
void diagnostic_assert_old_force (const VariableBase &v) const
 
void diagnostic_assert_residual (const VariableBase &v) const
 
void diagnostic_check_input_variable (const VariableBase &v) const
 
void diagnostic_check_output_variable (const VariableBase &v) const
 
void diagnose_nl_sys () const
 Additional diagnostics for a nonlinear system.
 
virtual void link_input_variables ()
 
virtual void link_input_variables (Model *submodel)
 
virtual void link_output_variables ()
 
virtual void link_output_variables (Model *submodel)
 
void clear_input () override
 
void clear_output () override
 
void zero_input () override
 
void zero_output () override
 
virtual void request_AD ()
 
virtual void set_value (bool out, bool dout_din, bool d2out_din2)=0
 The map between input -> output, and optionally its derivatives.
 
template<typename T = Model, typename = typename std::enable_if_t<std::is_base_of_v<Model, T>>>
T & register_model (const std::string &name, bool nonlinear=false, bool merge_input=true)
 Register a model that the current model may use during its evaluation.
 
void assign_input_stack (jit::Stack &stack)
 
jit::Stack collect_input_stack () const
 
void set_guess (const Sol< false > &) override
 Set the unscaled current guess.
 
void assemble (Res< false > *, Jac< false > *) override
 Compute the unscaled residual and Jacobian.
 
- Protected Member Functions inherited from Data
template<typename T, typename = typename std::enable_if_t<std::is_base_of_v<Data, T>>>
T & register_data (const std::string &name)
 
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.
 
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.
 
- Protected Member Functions inherited from VariableStore
virtual void send_variables_to (const TensorOptions &options)
 Send padding variables to options.
 
template<typename T>
const Variable< T > & declare_input_variable (const char *name, TensorShapeRef list_shape={})
 Declare an input variable.
 
template<typename T>
const Variable< T > & declare_input_variable (const VariableName &name, TensorShapeRef list_shape={})
 Declare an input variable.
 
template<typename T>
Variable< T > & declare_output_variable (const char *name, TensorShapeRef list_shape={})
 Declare an output variable.
 
template<typename T>
Variable< T > & declare_output_variable (const VariableName &name, TensorShapeRef list_shape={})
 Declare an output variable.
 
const VariableBaseclone_input_variable (const VariableBase &var, const VariableName &new_name={})
 Clone a variable and put it on the input axis.
 
VariableBaseclone_output_variable (const VariableBase &var, const VariableName &new_name={})
 Clone a variable and put it on the output axis.
 
void assign_input_stack (jit::Stack &stack)
 Assign stack to input variables.
 
void assign_output_stack (jit::Stack &stack, bool out, bool dout, bool d2out)
 Assign stack to output variables and derivatives.
 
jit::Stack collect_input_stack () const
 Collect stack from input variables.
 
jit::Stack collect_output_stack (bool out, bool dout, bool d2out) const
 Collect stack from output variables and derivatives.
 

Protected Attributes

std::vector< Model * > _registered_models
 Models this model may use during its evaluation.
 
- Protected Attributes inherited from Data
std::vector< Data * > _registered_data
 Registered Data objects.
 
- Protected Attributes inherited from NonlinearSystem
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 = false
 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.
 

Friends

class ParameterStore
 Declaration of nonlinear parameters may require manipulation of input.
 
class ComposedModel
 ComposedModel's set_value need to call submodel's set_value.
 

Additional Inherited Members

- Public Types inherited from VariableStore
using VariableStorage = std::map<VariableName, std::unique_ptr<VariableBase>>
 

Constructor & Destructor Documentation

◆ Model()

Model ( const OptionSet & options)

Construct a new Model object.

Parameters
optionsThe options extracted from the input file

Member Function Documentation

◆ assemble()

void assemble ( Res< false > * r,
Jac< false > * J )
overrideprotectedvirtual

Compute the unscaled residual and Jacobian.

Parameters
rPointer to the residual vector – nullptr if not requested
JPointer to the Jacobian matrix – nullptr if not requested

Implements NonlinearSystem.

◆ assign_input_stack()

void assign_input_stack ( jit::Stack & stack)
protected

◆ clear_input()

void clear_input ( )
overrideprotectedvirtual

Release allocated tensor

Reimplemented from VariableStore.

◆ clear_output()

void clear_output ( )
overrideprotectedvirtual

Reimplemented from VariableStore.

◆ collect_input_stack()

jit::Stack collect_input_stack ( ) const
protected

◆ consumed_items()

std::set< VariableName > consumed_items ( ) const
overridevirtual

The variables that this model depends on.

Implements DependencyDefinition< VariableName >.

◆ d2value() [1/2]

SecDerivMap d2value ( const ValueMap & in)
virtual

Convenient shortcut to construct and return the model's second derivative.

◆ d2value() [2/2]

SecDerivMap d2value ( ValueMap && in)
virtual

◆ defines_derivatives()

virtual bool defines_derivatives ( ) const
inlinevirtual

Whether this model defines first derivatives.

Reimplemented in ComposedModel.

◆ defines_second_derivatives()

virtual bool defines_second_derivatives ( ) const
inlinevirtual

Whether this model defines second derivatives.

Reimplemented in ComposedModel.

◆ defines_values()

virtual bool defines_values ( ) const
inlinevirtual

Whether this model defines output values.

Reimplemented in ComposedModel.

◆ diagnose()

void diagnose ( ) const
overridevirtual

Check for common problems.

This method serves as the entry point for diagnosing common problems in object setup. The idea behind this method is that while some errors could be detected at construction time, i.e., when the object's constructor is called, it doesn't hinder other objects' creation. We therefore would like to defer the detection of errors until after all objects have been created, collect all errors at once, and present the user with a complete understanding of all errors encountered.

Note, however, if an error could interfere with other objects' creation, it should be raised right away inside the constructor, instead of inside this method.

Implements DiagnosticsInterface.

Reimplemented in VariableRate< T >, VariableRate< Scalar >, VariableRate< Scalar >, VariableRate< SR2 >, VariableRate< SR2 >, VariableRate< Vec >, VariableRate< Vec >, WR2ExplicitExponentialTimeIntegration, and WR2ImplicitExponentialTimeIntegration.

◆ diagnose_nl_sys()

void diagnose_nl_sys ( ) const
protected

Additional diagnostics for a nonlinear system.

◆ diagnostic_assert_force()

void diagnostic_assert_force ( const VariableBase & v) const
protected

◆ diagnostic_assert_old_force()

void diagnostic_assert_old_force ( const VariableBase & v) const
protected

◆ diagnostic_assert_old_state()

void diagnostic_assert_old_state ( const VariableBase & v) const
protected

◆ diagnostic_assert_residual()

void diagnostic_assert_residual ( const VariableBase & v) const
protected

◆ diagnostic_assert_state()

void diagnostic_assert_state ( const VariableBase & v) const
protected

◆ diagnostic_check_input_variable()

void diagnostic_check_input_variable ( const VariableBase & v) const
protected

◆ diagnostic_check_output_variable()

void diagnostic_check_output_variable ( const VariableBase & v) const
protected

◆ dvalue() [1/2]

DerivMap dvalue ( const ValueMap & in)
virtual

Convenient shortcut to construct and return the derivative.

◆ dvalue() [2/2]

DerivMap dvalue ( ValueMap && in)
virtual

◆ dvalue_and_d2value() [1/2]

std::tuple< DerivMap, SecDerivMap > dvalue_and_d2value ( const ValueMap & in)
virtual

Convenient shortcut to construct and return the model's first and second derivative.

◆ dvalue_and_d2value() [2/2]

std::tuple< DerivMap, SecDerivMap > dvalue_and_d2value ( ValueMap && in)
virtual

◆ expected_options()

OptionSet expected_options ( )
static

◆ forward()

void forward ( bool out,
bool dout,
bool d2out )

Forward operator without jit.

◆ forward_maybe_jit()

void forward_maybe_jit ( bool out,
bool dout,
bool d2out )

Forward operator with jit.

If _jit is false, this falls back to the non-jit version.

If _jit is true, it will use the corresponding traced graph as the forward operator, and if the corresponding traced graph does not exists, it will create one.

◆ has_nl_param()

bool has_nl_param ( bool recursive = false) const

Whether this parameter store has any nonlinear parameter.

◆ is_jit_enabled()

virtual bool is_jit_enabled ( ) const
inlinevirtual

Whether JIT is enabled.

Reimplemented in ComposedModel.

◆ is_nonlinear_system()

virtual bool is_nonlinear_system ( ) const
inlinevirtual

Whether this model defines one or more nonlinear equations to be solved.

◆ link_input_variables() [1/2]

void link_input_variables ( )
protectedvirtual

◆ link_input_variables() [2/2]

void link_input_variables ( Model * submodel)
protectedvirtual

Reimplemented in ComposedModel.

◆ link_output_variables() [1/2]

void link_output_variables ( )
protectedvirtual

Reimplemented in ImplicitUpdate.

◆ link_output_variables() [2/2]

void link_output_variables ( Model * submodel)
protectedvirtual

Reimplemented in ComposedModel.

◆ named_nonlinear_parameters()

std::map< std::string, NonlinearParameter > named_nonlinear_parameters ( bool recursive = false) const
virtual

Get all nonlinear parameters.

Reimplemented in ComposedModel.

◆ nl_param()

const VariableBase * nl_param ( const std::string & name) const

Query the existence of a nonlinear parameter.

Returns
const VariableBase* Pointer to the VariableBase if the parameter associated with the given parameter name is nonlinear. Returns nullptr otherwise.

◆ provided_items()

std::set< VariableName > provided_items ( ) const
overridevirtual

The variables that this model defines as part of its output.

Implements DependencyDefinition< VariableName >.

◆ register_model()

template<typename T = Model, typename = typename std::enable_if_t<std::is_base_of_v<Model, T>>>
T & register_model ( const std::string & name,
bool nonlinear = false,
bool merge_input = true )
inlineprotected

Register a model that the current model may use during its evaluation.

If merge_input is set to true, this model will also consume the consumed variables of model, which will affect dependency resolution inside a ComposedModel.

Parameters
nameThe model to register
nonlinearSet to true if the registered model defines a nonlinear system to be solved
merge_inputWhether to merge the input axis of the registered model into this model's input axis. This will make sure that the input variables of the registered model are "ready" by the time this model is evaluated.

◆ register_nonlinear_parameter()

void register_nonlinear_parameter ( const std::string & pname,
const NonlinearParameter & param )

Register a nonlinear parameter.

◆ registered_model()

Model * registered_model ( const std::string & name) const

Get a registered model by its name.

◆ registered_models()

const std::vector< Model * > & registered_models ( ) const
inline

The models that may be used during the evaluation of this model.

◆ request_AD() [1/3]

virtual void request_AD ( )
inlineprotectedvirtual

Request the use of automatic differentiation to compute variable derivatives

Model implementations which require automatic differentiation to compute variable derivatives shall override this method and mark variable derivatives. Variable derivatives are marked as,

// To request first derivative of foo with respect to bar
request_AD(foo, bar);
// To request second derivative of foo with respect to bar and baz
request_AD(foo, bar, baz);
virtual void request_AD()
Definition Model.h:259

◆ request_AD() [2/3]

void request_AD ( VariableBase & y,
const VariableBase & u )

Request to use AD to compute the first derivative of a variable.

◆ request_AD() [3/3]

void request_AD ( VariableBase & y,
const VariableBase & u1,
const VariableBase & u2 )

Request to use AD to compute the second derivative of a variable.

◆ set_guess()

void set_guess ( const Sol< false > & x)
overrideprotectedvirtual

Set the unscaled current guess.

Implements NonlinearSystem.

◆ set_value()

virtual void set_value ( bool out,
bool dout_din,
bool d2out_din2 )
protectedpure virtual

The map between input -> output, and optionally its derivatives.

Implemented in ArrheniusParameter, AssociativeIsotropicPlasticHardening, AssociativeJ2FlowDirection, AssociativeKinematicPlasticHardening, AssociativePlasticFlow, AvramiErofeevNucleation, BackwardEulerTimeIntegration< T >, BackwardEulerTimeIntegration< Scalar >, BackwardEulerTimeIntegration< Scalar >, BackwardEulerTimeIntegration< SR2 >, BackwardEulerTimeIntegration< SR2 >, BackwardEulerTimeIntegration< Vec >, BackwardEulerTimeIntegration< Vec >, ChabochePlasticHardening, ChemicalReactionMechanism, ComposedModel, ConstantParameter< T >, CopyVariable< T >, CrystalMean< T >, CrystalMean< SR2 >, CrystalMean< SR2 >, CubicElasticityTensor, DiffusionLimitedReaction, ElasticStrainRate, FischerBurmeister, FixOrientation, ForwardEulerTimeIntegration< T >, ForwardEulerTimeIntegration< Scalar >, ForwardEulerTimeIntegration< Scalar >, ForwardEulerTimeIntegration< SR2 >, ForwardEulerTimeIntegration< SR2 >, ForwardEulerTimeIntegration< Vec >, ForwardEulerTimeIntegration< Vec >, FredrickArmstrongPlasticHardening, GeneralElasticity, GTNYieldFunction, GursonCavitation, HermiteSmoothStep, ImplicitUpdate, IncrementToRate< T >, IncrementToRate< R2 >, IncrementToRate< R2 >, IncrementToRate< Scalar >, IncrementToRate< Scalar >, IncrementToRate< SR2 >, IncrementToRate< SR2 >, IncrementToRate< Vec >, IncrementToRate< Vec >, InputParameter< T >, IsotropicElasticityTensor, IsotropicMandelStress, KocksMeckingActivationEnergy, KocksMeckingFlowSwitch, KocksMeckingFlowViscosity, KocksMeckingIntercept, KocksMeckingRateSensitivity, KocksMeckingYieldStress, LinearCombination< T >, LinearCombination< Scalar >, LinearCombination< Scalar >, LinearCombination< SR2 >, LinearCombination< SR2 >, LinearCombination< Vec >, LinearCombination< Vec >, LinearInterpolation< T >, LinearInterpolation< Scalar >, LinearInterpolation< Scalar >, LinearInterpolation< SR2 >, LinearInterpolation< SR2 >, LinearInterpolation< Vec >, LinearInterpolation< Vec >, LinearIsotropicElasticity, LinearIsotropicElasticJ2TrialStressUpdate, LinearIsotropicHardening, LinearKinematicHardening, LinearSingleSlipHardeningRule, MixedControlSetup, Normality, OlevskySinteringStress, OrientationRate, PerzynaPlasticFlowRate, PhaseTransformationEigenstrain, PlasticDeformationRate, PlasticVorticity, PowerLawIsotropicHardeningStaticRecovery, PowerLawKinematicHardeningStaticRecovery, PowerLawSlipRule, ProductGeometry, ProjectileAcceleration, ProjectileAcceleration, ProjectileAcceleration, ProjectileAcceleration, PyrolysisConversionAmount, PyrolysisKinetics, R2toSR2, R2toWR2, RateIndependentPlasticFlowConstraint, ResolvedShear, RotationMatrix, ScalarVariableMultiplication, SingleSlipStrengthMap, SlopeSaturationVoceIsotropicHardening, SR2Invariant, SR2toR2, SumSlipRates, ThermalEigenstrain, TwoStageThermalAnnealing< T >, TwoStageThermalAnnealing< Scalar >, TwoStageThermalAnnealing< Scalar >, TwoStageThermalAnnealing< SR2 >, TwoStageThermalAnnealing< SR2 >, VariableRate< T >, VariableRate< Scalar >, VariableRate< Scalar >, VariableRate< SR2 >, VariableRate< SR2 >, VariableRate< Vec >, VariableRate< Vec >, VoceIsotropicHardening, VoceSingleSlipHardeningRule, VolumeChangeEigenstrain, WR2ExplicitExponentialTimeIntegration, WR2ImplicitExponentialTimeIntegration, and YieldFunction.

◆ setup()

void setup ( )
overridevirtual

Setup this object.

This method is called automatically if you use the Factory method get_object or get_object_ptr, 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.

◆ to()

void to ( const TensorOptions & options)
virtual

Send model to a different device or dtype.

◆ value() [1/2]

ValueMap value ( const ValueMap & in)
virtual

Convenient shortcut to construct and return the model value.

◆ value() [2/2]

ValueMap value ( ValueMap && in)
virtual

◆ value_and_dvalue() [1/2]

std::tuple< ValueMap, DerivMap > value_and_dvalue ( const ValueMap & in)
virtual

Convenient shortcut to construct and return the model value and its derivative.

◆ value_and_dvalue() [2/2]

std::tuple< ValueMap, DerivMap > value_and_dvalue ( ValueMap && in)
virtual

◆ value_and_dvalue_and_d2value() [1/2]

std::tuple< ValueMap, DerivMap, SecDerivMap > value_and_dvalue_and_d2value ( const ValueMap & in)
virtual

Convenient shortcut to construct and return the model's value, first and second derivative.

◆ value_and_dvalue_and_d2value() [2/2]

std::tuple< ValueMap, DerivMap, SecDerivMap > value_and_dvalue_and_d2value ( ValueMap && in)
virtual

◆ variable_name_lookup()

std::string variable_name_lookup ( const ATensor & var)

Look up the name of a variable in the traced graph.

◆ zero_input()

void zero_input ( )
overrideprotectedvirtual

Zero variable values

Reimplemented from VariableStore.

◆ zero_output()

void zero_output ( )
overrideprotectedvirtual

Reimplemented from VariableStore.

Friends And Related Symbol Documentation

◆ ComposedModel

friend class ComposedModel
friend

ComposedModel's set_value need to call submodel's set_value.

◆ ParameterStore

friend class ParameterStore
friend

Declaration of nonlinear parameters may require manipulation of input.

Member Data Documentation

◆ _registered_models

std::vector<Model *> _registered_models
protected

Models this model may use during its evaluation.