49 const at::Tensor &
getOutput(
const std::string & output_name)
const;
53 const std::string & input_name)
const;
57 const std::string & parameter_name)
const;
77 virtual
bool solve(
bool compute_derivative);
Common interface for inserting gathered MOOSE data into the NEML2 material model.
NEML2BatchIndexGenerator iterates over the mesh and generates a map from element ID to batch index wh...
NEML2ModelExecutor executes a NEML2 model.
const bool _dump_inputs_on_failure
Dump the NEML2 input tensors to a per-rank TorchScript file on solve failure, for offline debugging.
std::map< std::string, at::Tensor > _state_vars
Cached stateful variables from the last successful step (for on-device advance)
bool _derivative_valid
Whether the retained input-derivative tensor is consistent with the current batch.
void initialSetup() override
Gets called at the beginning of the simulation before this object is asked to do its job.
std::map< std::string, at::Tensor > _zero_seed_vars
Base-shaped zero tensors for cold-started in-place-updated unknowns (an order-0 NEML2 input that is a...
bool _error
Whether an error was encountered.
void execute() override
Execute method.
std::string _error_message
Error message.
std::map< std::string, std::map< std::string, at::Tensor > > _dout_din
The derivative of the output variables w.r.t. the input variables: J[output][input].
static InputParameters actionParams()
Parameters that can be specified under the NEML2Action common area.
virtual bool solve(bool compute_derivative)
Perform the material update.
std::set< std::string > _gathered_parameter_names
void deviceSynchronize()
Block until all asynchronous device (CUDA) work has completed.
std::map< std::string, at::Tensor > _model_params
Model parameter values gathered from MOOSE (qualified name -> tensor), set on the model before each e...
const at::Tensor & getOutput(const std::string &output_name) const
Get a reference(!) to the requested output view.
bool outputReady() const
check if the output is fully computed and ready to be fetched
std::map< std::string, at::Tensor > _out
The output variables of the material model.
std::vector< const MOOSEToNEML2 * > _param_gatherers
MOOSE data gathering user objects (model parameters)
std::map< std::string, std::map< std::string, at::Tensor > > _retrieved_derivatives
set of derivatives that were retrieved (by other objects)
virtual void checkExecutionStage() const final
Prevent output and derivative retrieval after construction.
static InputParameters validParams()
const bool _manage_state_advance
Advance state on device (rather than via MOOSE material properties)
bool _output_ready
flag that indicates if output data has been fully computed
std::map< std::string, at::Tensor > _in
The input variables of the material model (name -> (batch, *base_shape) tensor)
std::size_t getBatchIndex(dof_id_type elem_id) const
Get the batch index for the given element ID.
const at::Tensor & getOutputDerivative(const std::string &output_name, const std::string &input_name) const
Get a reference(!) to the requested output derivative view.
void advanceState()
Save stateful variables for on-device state advance.
virtual void extractOutputs(bool compute_derivative)
Extract outputs, and their derivatives with respect to the input variables when compute_derivative is...
const at::Tensor & getOutputParameterDerivative(const std::string &output_name, const std::string ¶meter_name) const
Get a reference(!) to the requested output-parameter-derivative view.
std::set< std::string > _gathered_variable_names
void finalize() override
Finalize.
std::string failedInputDumpName(unsigned int count, const std::string &rank_token) const
Build the dump-file name for a failed constitutive update: '<model>_count<count>_rank<rank>....
std::map< std::string, std::map< std::string, at::Tensor > > _dout_dparam
The derivative of the output variables w.r.t. the model parameters: P[output][parameter].
const NEML2BatchIndexGenerator & _batch_index_generator
The NEML2BatchIndexGenerator used to generate the element-to-batch-index map.
unsigned int _num_failed_dumps
Running count of failed constitutive updates dumped on this rank (disambiguates repeated dumps)
void initialize() override
Called before execute() is ever called so that data can be cleared.
virtual void fillInputs()
Fill input variables using the gatherers.
std::map< std::string, at::Tensor > _retrieved_outputs
set of output variables that were retrieved (by other objects)
std::vector< const MOOSEToNEML2 * > _gatherers
MOOSE data gathering user objects (input variables)
virtual void addGatheredParameter(const UserObjectName &, const std::string &)
Register a NEML2 model parameter gathered by a gatherer.
void meshChanged() override
Called on this object when the mesh changes.
std::map< std::string, std::map< std::string, at::Tensor > > _retrieved_parameter_derivatives
set of output-parameter-derivatives that were retrieved (by other objects)
virtual void addGatheredVariable(const UserObjectName &, const std::string &)
Register a NEML2 input variable gathered by a gatherer.
Interface class to provide common input parameters, members, and methods for MOOSEObjects that use NE...