27#include "neml2/drivers/Driver.h"
28#include "neml2/tensors/tensors.h"
31#include <torch/nn/modules/container/moduledict.h>
32#include <torch/serialize.h>
63 virtual torch::nn::ModuleDict
result()
const;
89 virtual void output()
const;
144 void output_pt(
const std::filesystem::path &
out)
const;
146 template <
typename T>
147 void set_IC(
const std::vector<VariableName> &
ic_names,
The wrapper (decorator) for cross-referencing unresolved values at parse time.
Definition CrossRef.h:52
The Driver drives the execution of a NEML2 Model.
Definition Driver.h:40
The accessor containing all the information needed to access an item in a LabeledAxis.
Definition LabeledAxisAccessor.h:44
void set(const BatchTensorBase< T > &value, S &&... names)
Set and interpret the input as an object.
Definition LabeledTensor.h:193
A single-batched, logically 1D LabeledTensor.
Definition LabeledVector.h:38
The base class for all constitutive models.
Definition Model.h:53
A custom map-like data structure. The keys are strings, and the values can be nonhomogeneously typed.
Definition OptionSet.h:59
The (logical) scalar.
Definition Scalar.h:38
The driver for a transient initial-value problem.
Definition TransientDriver.h:41
virtual bool solve()
Solve the initial value problem.
Definition TransientDriver.cxx:173
const torch::Device _device
The device on which to evaluate the model.
Definition TransientDriver.h:94
virtual void advance_step()
Advance in time: the state becomes old state, and forces become old forces.
Definition TransientDriver.cxx:208
LabeledVector _result_in
Inputs from all time steps.
Definition TransientDriver.h:123
const bool _show_input
Set to true to show model's input axis at the beginning.
Definition TransientDriver.h:118
Model & _model
The model which the driver uses to perform constitutive updates.
Definition TransientDriver.h:92
const bool _show_output
Set to true to show model's output axis at the beginning.
Definition TransientDriver.h:120
std::vector< VariableName > _ic_rot_names
Names for the Rot initial conditions.
Definition TransientDriver.h:132
TransientDriver(const OptionSet &options)
Construct a new TransientDriver object.
Definition TransientDriver.cxx:101
virtual void update_forces()
Update the driving forces for the current time step.
Definition TransientDriver.cxx:218
LabeledVector _result_out
Outputs from all time steps.
Definition TransientDriver.h:125
bool run() override
Let the driver run, return true upon successful completion, and return false otherwise.
Definition TransientDriver.cxx:150
const bool _show_params
Set to true to list all the model parameters at the beginning.
Definition TransientDriver.h:116
Scalar _time
The current time.
Definition TransientDriver.h:97
virtual std::string save_as_path() const
The destination file/path to save the results.
Definition TransientDriver.cxx:300
virtual void apply_predictor()
Apply the predictor to calculate the initial guess for the current time step.
Definition TransientDriver.cxx:233
virtual void store_input()
Save the input of the current time step.
Definition TransientDriver.cxx:288
std::vector< CrossRef< SR2 > > _ic_sr2_values
Values for the SR2 initial conditions.
Definition TransientDriver.h:138
virtual torch::nn::ModuleDict result() const
The results (input and output) from all time steps.
Definition TransientDriver.cxx:306
std::vector< CrossRef< Scalar > > _ic_scalar_values
Values for the scalar initial conditions.
Definition TransientDriver.h:130
std::vector< CrossRef< Rot > > _ic_rot_values
Values for the Rot initial conditions.
Definition TransientDriver.h:134
virtual void check_integrity() const override
Check the integrity of the set up.
Definition TransientDriver.cxx:135
std::vector< VariableName > _ic_sr2_names
Names for the SR2 initial conditions.
Definition TransientDriver.h:136
std::string _save_as
The destination file name or file path.
Definition TransientDriver.h:114
TorchSize _nbatch
The batch size.
Definition TransientDriver.h:105
LabeledVector & _in
The input to the constitutive model.
Definition TransientDriver.h:107
std::vector< VariableName > _ic_scalar_names
Names for scalar initial conditions.
Definition TransientDriver.h:128
LabeledVector & _out
The output of the constitutive model.
Definition TransientDriver.h:109
TorchSize _nsteps
Total number of steps.
Definition TransientDriver.h:103
virtual void output() const
Save the results into the destination file/path.
Definition TransientDriver.cxx:328
VariableName _time_name
VariableName for the time.
Definition TransientDriver.h:101
static OptionSet expected_options()
Definition TransientDriver.cxx:34
TorchSize _step_count
The current step count.
Definition TransientDriver.h:99
std::string _predictor
The predictor used to set the initial guess.
Definition TransientDriver.h:112
virtual void store_output()
Save the output of the current time step.
Definition TransientDriver.cxx:294
virtual void apply_ic()
Apply the initial conditions.
Definition TransientDriver.cxx:225
Real _cp_elastic_scale
Scale value for initial cp predictor.
Definition TransientDriver.h:141
virtual void solve_step()
Perform the constitutive update for the current time step.
Definition TransientDriver.cxx:282
Definition CrossRef.cxx:32