Skip to content

Commit

Permalink
Add test for changing types
Browse files Browse the repository at this point in the history
  • Loading branch information
loganharbour committed Feb 28, 2024
1 parent 9259b37 commit 869f641
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
6 changes: 1 addition & 5 deletions framework/src/materials/MaterialPropertyStorage.C
Original file line number Diff line number Diff line change
Expand Up @@ -648,11 +648,7 @@ dataLoad(std::istream & stream, MaterialPropertyStorage & storage, void * contex
if (from_record.type != to_record.type)
mooseError("The type for the restarted stateful material property '",
name,
"' does not match.\n\n",
"Checkpointed type: ",
from_record.type,
"\nCurrent type: ",
to_record.type);
"' in does not match");
if (from_record.state != to_record.state)
mooseError("The number of states for the restarted stateful material property '",
name,
Expand Down
7 changes: 7 additions & 0 deletions test/src/materials/RestartStatefulMaterial.C
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ RestartStatefulMaterial::validParams()
"real_values", {}, "The values to set for the real properties");
params.addParam<std::vector<std::string>>(
"real_stateful_names", {}, "The name of the real properties to request as stateful");
params.addParam<std::vector<std::string>>(
"int_names", {}, "The name of the int properties to declare");
return params;
}

Expand All @@ -35,6 +37,11 @@ RestartStatefulMaterial::RestartStatefulMaterial(const InputParameters & paramet
declareProperty<Real>(name);
for (const auto & name : getParam<std::vector<std::string>>("real_stateful_names"))
getMaterialPropertyOld<Real>(name);
for (const auto & name : getParam<std::vector<std::string>>("int_names"))
{
declareProperty<int>(name);
getMaterialPropertyOld<int>(name);
}
}

void
Expand Down
10 changes: 10 additions & 0 deletions test/tests/restart/advanced_stateful_material/tests
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,15 @@
prereq = checkpoint
detail = 'a stateful object changed names'
[]
[different_type]
type = RunException
input = 'advanced_stateful_material_restart.i'
cli_args = "Materials/test/real_names='a'
Materials/test/real_stateful_names='a'
Materials/test/int_names='b'"
expect_err = 'The type for the restarted stateful material property \'b\' in does not match'
prereq = checkpoint
detail = 'the type of a restored stateful property has changed'
[]
[]
[]

0 comments on commit 869f641

Please sign in to comment.