Skip to content

Commit

Permalink
Fix older state (idaholab#26053)
Browse files Browse the repository at this point in the history
  • Loading branch information
dschwen committed Dec 5, 2023
1 parent 1d81b38 commit b13b27d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
7 changes: 7 additions & 0 deletions framework/include/interfaces/Coupleable.h
Expand Up @@ -551,6 +551,13 @@ class Coupleable
virtual const VariableValue & coupledValueOlder(const std::string & var_name,
unsigned int comp = 0) const;

/**
* Returns the older values for all of a coupled variable's components
* @param var_name Name of coupled variable
* @return Vector of VariableValue pointers for each component of \p var_name
*/
std::vector<const VariableValue *> coupledValuesOlder(const std::string & var_name) const;

/**
* Returns value of previous Newton iterate of a coupled variable
* @param var_name Name of coupled variable
Expand Down
7 changes: 7 additions & 0 deletions framework/src/interfaces/Coupleable.C
Expand Up @@ -2544,6 +2544,13 @@ Coupleable::coupledValuesOld(const std::string & var_name) const
return coupledVectorHelper<const VariableValue *>(var_name, func);
}

std::vector<const VariableValue *>
Coupleable::coupledValuesOlder(const std::string & var_name) const
{
auto func = [this, &var_name](unsigned int comp) { return &coupledValueOlder(var_name, comp); };
return coupledVectorHelper<const VariableValue *>(var_name, func);
}

std::vector<const VariableGradient *>
Coupleable::coupledGradients(const std::string & var_name) const
{
Expand Down
6 changes: 4 additions & 2 deletions framework/src/materials/InterpolatedStatefulMaterial.C
Expand Up @@ -31,14 +31,16 @@ InterpolatedStatefulMaterialTempl<T>::InterpolatedStatefulMaterialTempl(
const InputParameters & parameters)
: Material(parameters),
_old_state(coupledValuesOld("old_state")),
_older_state(coupledValuesOld("old_state")), // older is missing
_older_state(coupledValuesOlder("old_state")),
_size(Moose::SerialAccess<T>::size()),
_prop_name(getParam<MaterialPropertyName>("prop_name")),
_prop_old(declareProperty<T>(_prop_name + "_interpolated_old")),
_prop_older(declareProperty<T>(_prop_name + "_interpolated_older"))
{
if (_old_state.size() != _size)
paramError("old_state", "Wrong number of compoet AuxVariables passed in.");
paramError("old_state", "Wrong number of component AuxVariables passed in.");
mooseAssert(_old_state.size() == _older_state.size(),
"Internal error. Old and older coupled variable vectors should have the same size.");
}

template <typename T>
Expand Down

0 comments on commit b13b27d

Please sign in to comment.