Skip to content

Commit 420c8c4

Browse files
committed
Advance step on device (idaholab#32198)
1 parent 610beb6 commit 420c8c4

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

framework/include/neml2/userobjects/NEML2ModelExecutor.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class NEML2ModelExecutor : public NEML2ModelInterface<GeneralUserObject>
4141
void finalize() override;
4242

4343
void initialSetup() override;
44+
void timestepSetup() override;
4445

4546
/// Get the batch index for the given element ID
4647
std::size_t getBatchIndex(dof_id_type elem_id) const;

framework/src/neml2/userobjects/NEML2ModelExecutor.C

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ NEML2ModelExecutor::actionParams()
3131
"List of NEML2 variables to skip error checking when setting up the model input. If an "
3232
"input variable is skipped, its value will stay zero. If a required input variable is "
3333
"not skipped, an error will be raised.");
34+
params.addParam<bool>(
35+
"advance_step_on_device",
36+
false,
37+
"Keep state and forces on the device and advance it to old_state and old_forces without a "
38+
"roundtrip through MOOSE materials. This is only recommended for explicit time integration "
39+
"or when absolutely no restepping occurs (e.g. failed timesteps).");
3440
return params;
3541
}
3642

@@ -167,6 +173,20 @@ NEML2ModelExecutor::initialSetup()
167173
"those called `NEML2To*MOOSEMaterialProperty`.");
168174
}
169175

176+
void
177+
NEML2ModelExecutor::timestepSetup()
178+
{
179+
if (_advance_step_on_device && _t_step > 0)
180+
{
181+
// Set old state variables and old forces
182+
if (model().input_axis().has_subaxis("old_state") && model().output_axis().has_subaxis("state"))
183+
_in.slice("old_state").fill(_out.slice("state"));
184+
if (model().input_axis().has_subaxis("old_forces") &&
185+
model().input_axis().has_subaxis("forces"))
186+
_in.slice("old_forces").fill(_in.slice("forces"));
187+
}
188+
}
189+
170190
std::size_t
171191
NEML2ModelExecutor::getBatchIndex(dof_id_type elem_id) const
172192
{

0 commit comments

Comments
 (0)