650   std::vector<std::string> from_prop_ids_to_names;
   651   dataLoad(stream, from_prop_ids_to_names, 
nullptr);
   654   dataLoad(stream, from_stateful_prop_id_to_prop_id, 
nullptr);
   656   decltype(storage._prop_records) from_prop_records;
   657   dataLoad(stream, from_prop_records, 
nullptr);
   659   decltype(storage.numStates()) num_states;
   660   dataLoad(stream, num_states, 
nullptr);
   664     const auto build_maps = [](
const auto & prop_records, 
const auto & ids_to_names)
   666       std::map<std::string, std::set<std::string>> object_to_props, prop_to_objects;
   668         if (prop_records[i] && prop_records[i]->stateful())
   670           const auto & prop = ids_to_names[i];
   671           for (
const auto & declarer : (*prop_records[i]).declarers)
   673             object_to_props[declarer].insert(prop);
   674             prop_to_objects[prop].insert(declarer);
   678       return std::make_pair(std::move(object_to_props), std::move(prop_to_objects));
   681     const std::vector<std::string> prop_ids_to_names(
registry.idsToNamesBegin(),
   683     const auto [object_to_props, prop_to_objects] =
   686     const auto [from_object_to_props, from_prop_to_objects] =
   687         build_maps(from_prop_records, from_prop_ids_to_names);
   690     for (
const auto & [
object, props] : object_to_props)
   692       const auto find_from_object = from_object_to_props.find(
object);
   698       if (find_from_object != from_object_to_props.end())
   700         const auto & from_props = find_from_object->second;
   701         if (props != from_props)
   703           std::stringstream error;
   704           error << 
"The stateful material properties in " << 
object   705                 << 
" that are being restarted do not match the stored properties in the same "   706                    "material object from the checkpoint.\n\n";
   707           error << 
"Checkpointed stateful properties:\n";
   708           for (
const auto & prop : from_props)
   709             error << 
" - " << prop << 
"\n";
   710           error << 
"\nCurrent stateful properties:\n";
   711           for (
const auto & prop : props)
   712             error << 
" - " << prop << 
"\n";
   722                    " was stored in restart but no longer exists. This is not supported when "   723                    "recovering stateful material properties.");
   732     for (
const auto & [from_prop, from_objects] : from_prop_to_objects)
   733       if (
const auto find_objects = prop_to_objects.find(from_prop);
   734           find_objects != prop_to_objects.end())
   735         for (
const auto & 
object : find_objects->second)
   736           if (!from_objects.count(
object))
   738                 "The stateful material property '",
   740                 "' was declared in ",
   742                 " but was not declared in that object on checkpoint.\n\nThis is not currently "   743                 "supported due to ambiguity.\n\nPlease contact the development team on "   744                 "GitHub if you desire this capability.");
   747   std::vector<std::optional<unsigned int>> to_stateful_ids(from_stateful_prop_id_to_prop_id.size());
   752   for (
auto & record_ptr : to_prop_records)
   754       record_ptr->restored = 
false;
   757   for (
const auto from_stateful_id : 
index_range(from_stateful_prop_id_to_prop_id))
   759     const auto from_prop_id = from_stateful_prop_id_to_prop_id[from_stateful_id];
   761     mooseAssert(from_prop_id < from_prop_records.size(), 
"Invalid record map");
   762     mooseAssert(from_prop_records[from_prop_id], 
"Not set");
   763     const auto & from_record = *from_prop_records[from_prop_id];
   764     mooseAssert(from_record.stateful(), 
"Not stateful");
   766     mooseAssert(from_prop_id < from_prop_ids_to_names.size(), 
"Invalid ID map");
   767     const auto & 
name = from_prop_ids_to_names[from_prop_id];
   769     if (
const auto query_to_prop_id = 
registry.queryID(name))
   771       const auto to_prop_id = *query_to_prop_id;
   773       mooseAssert(to_prop_id < to_prop_records.size(), 
"Invalid record map");
   774       mooseAssert(to_prop_records[to_prop_id], 
"Not set");
   775       auto & to_record = *to_prop_records[to_prop_id];
   777       if (to_record.stateful())
   779         if (from_record.type != to_record.type)
   781               "The type for the restarted stateful material property '", name, 
"' does not match");
   786         if (from_record.state != to_record.state)
   787           mooseError(
"The number of states for the restarted stateful material property '",
   789                      "' do not match.\n\n",
   790                      "Checkpointed states: ",
   792                      "\nCurrent states: ",
   796         mooseAssert(to_stateful_id != invalid_uint, 
"Not stateful");
   798         to_stateful_ids[from_stateful_id] = to_stateful_id;
   801         to_record.restored = 
true;
   805           mooseAssert(from_stateful_id == to_stateful_id, 
"Does not have direct mapping");
   811   for (
const auto state : 
make_range(num_states))
   813     std::size_t num_elems;
   814     dataLoad(stream, num_elems, 
nullptr);
   816     for (std::size_t i_elem = 0; i_elem < num_elems; ++i_elem)
   820       mooseAssert(elem, 
"Null element");
   822       std::size_t num_sides;
   823       dataLoad(stream, num_sides, 
nullptr);
   825       for (std::size_t i_side = 0; i_side < num_sides; ++i_side)
   830         std::size_t num_props;
   831         dataLoad(stream, num_props, 
nullptr);
   832         mooseAssert(num_props <= to_stateful_ids.size(), 
"Missized map");
   834         std::size_t num_q_points;
   835         dataLoad(stream, num_q_points, 
nullptr);
   838         MaterialPropertyStorage::RestartableMapType::mapped_type * restart_entry = 
nullptr;
   842         for (
const auto from_stateful_id : 
make_range(num_props))
   846           std::stringstream data;
   848           data.seekg(0, std::ios::beg);
   851           if (
const auto to_stateful_id_ptr = to_stateful_ids[from_stateful_id])
   853             const auto to_stateful_id = *to_stateful_id_ptr;
   859                 in_place_entry = &storage.
setProps(elem, side, state);
   861               dataLoad(data, (*in_place_entry)[to_stateful_id], 
nullptr);
   870               auto & mat_entry = (*restart_entry)[to_stateful_id];
   871               if (state >= mat_entry.size())
   872                 mat_entry.resize(state + 1);
   874               mat_entry[state] = std::move(data);
 std::string name(const ElemQuality q)
MaterialProperties & setProps(const Elem *elem, unsigned int side, const unsigned int state=0)
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
static Moose::ParameterRegistry & registry
std::vector< unsigned int > _stateful_prop_id_to_prop_id
the vector of stateful property ids (the vector index is the map to stateful prop_id) ...
const MaterialPropertyRegistry & getMaterialPropertyRegistry() const
std::vector< std::optional< PropRecord > > _prop_records
Property records indexed by property id (may be null) 
bool isRestoredProperty(const std::string &name) const
bool _recovering
Whether or not we're recovering; enforces a one-to-one mapping of stateful properties. 
RestartableMapType _restartable_map
The restartable data to be loaded in initStatefulProps() later. 
IntRange< T > make_range(T beg, T end)
void dataLoad(std::istream &stream, MaterialPropertyStorage &storage, void *context)
bool _restart_in_place
Whether or not we want to restart stateful properties in place. 
const PropRecord & getPropRecord(const unsigned int id) const
Get the property record associated with the material with id id. 
auto index_range(const T &sizable)
unsigned int stateful_id
The stateful id in _storage used for this property, if any.