104 const std::vector<std::vector<QpMap>> & refinement_map,
106 const QBase & qrule_face,
110 const int input_parent_side,
111 const int input_child,
112 const int input_child_side);
130 const std::vector<QpMap> & p_refinement_map,
132 const QBase & qrule_face,
135 const int input_side);
150 const std::vector<const Elem *> & coarsened_element_children,
152 const QBase & qrule_face,
155 int input_side = -1);
169 const std::vector<std::shared_ptr<MaterialBase>> & mats,
170 const unsigned int n_qpoints,
172 const unsigned int side = 0);
198 const Elem & elem_to,
199 const Elem & elem_from,
201 unsigned int n_qpoints);
214 const Elem * elem_to,
215 const Elem * elem_from,
217 unsigned int n_qpoints);
226 void swap(
const THREAD_ID tid,
const Elem & elem,
unsigned int side);
262 props(
const Elem * elem,
unsigned int side,
const unsigned int state = 0)
const;
277 unsigned int addProperty(
const std::string & prop_name,
278 const std::type_info & type,
279 const unsigned int state,
321 return IntRange<unsigned int>(1,
numStates());
352 const PropRecord &
getPropRecord(
const unsigned int id)
const;
361 std::array<PropsType, MaterialData::max_state + 1>
_storage;
374 std::vector<MaterialProperties *>
375 initProps(
const THREAD_ID tid,
const Elem * elem,
unsigned int side,
unsigned int n_qpoints);
379 const unsigned int state,
382 unsigned int n_qpoints);
389 static void shallowSwapData(
const std::vector<unsigned int> & stateful_prop_ids,
410 initAndSetProps(
const Elem * elem,
const unsigned int side,
const unsigned int state);
426 typedef std::unordered_map<std::pair<const Elem *, unsigned int>,
427 std::map<unsigned int, std::vector<std::stringstream>>>
452 mooseAssert(state <
_storage.size(),
"Invalid material property state " + std::to_string(state));
459 const auto find_elem =
props(state).
find(elem);
460 mooseAssert(find_elem !=
props(state).end(),
"Material property does not have elem entry");
461 const auto find_side = find_elem->second.find(side);
462 mooseAssert(find_side != find_elem->second.end(),
"Material property does not have side entry");
463 return find_side->second;
469 return const_cast<MaterialProperties &
>(std::as_const(*this).props(elem, side, state));
475 const unsigned int state)
MaterialProperties & setProps(const Elem *elem, unsigned int side, const unsigned int state=0)
void shift()
Shift the material properties in time.
friend void dataStore(std::ostream &, MaterialPropertyStorage &, void *)
HashMap< const Elem *, HashMap< unsigned int, MaterialProperties > > PropsType
Accessible type of the stored material property data.
std::vector< MaterialData > _material_data
The threaded material data.
const unsigned int invalid_uint
void prolongStatefulProps(processor_id_type pid, const std::vector< std::vector< QpMap >> &refinement_map, const QBase &qrule, const QBase &qrule_face, MaterialPropertyStorage &parent_material_props, const THREAD_ID tid, const Elem &elem, const int input_parent_side, const int input_child, const int input_child_side)
Creates storage for newly created elements from mesh Adaptivity.
HashMap is an abstraction for dictionary data type, we make it thread-safe by locking inserts...
void restrictStatefulProps(const std::vector< std::pair< unsigned int, QpMap >> &coarsening_map, const std::vector< const Elem *> &coarsened_element_children, const QBase &qrule, const QBase &qrule_face, const THREAD_ID tid, const Elem &elem, int input_side=-1)
Creates storage for newly created elements from mesh Adaptivity.
Registry class for material property IDs and names.
void eraseProperty(const Elem *elem)
Remove the property storage and element pointer from internal data structures Use this when elements ...
Stores the stateful material properties computed by materials.
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
Helper object for holding qp mapping info.
void sizeProps(MaterialProperties &mp, unsigned int size)
IntRange< unsigned int > stateIndexRange() const
bool hasProperty(const std::string &name) const
libMesh::Threads::spin_mutex & _spin_mtx
std::vector< std::optional< PropRecord > > _prop_records
Property records indexed by property id (may be null)
IntRange< unsigned int > statefulIndexRange() const
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...
iterator find(const Key &k)
unsigned int maxState() const
bool restored
Whether or not this property was restored (stateful only)
static void shallowSwapData(const std::vector< unsigned int > &stateful_prop_ids, MaterialProperties &data, MaterialProperties &data_from)
Shallow copies of material properties.
static void shallowSwapDataBack(const std::vector< unsigned int > &stateful_prop_ids, MaterialProperties &data, MaterialProperties &data_from)
MaterialPropertyStorage(MaterialPropertyRegistry ®istry)
const std::vector< unsigned int > & statefulProps() const
void dataLoad(std::istream &stream, MaterialPropertyStorage &storage, void *context)
uint8_t processor_id_type
void setRestartInPlace()
Sets the loading of stateful material properties in place.
void swapBack(const THREAD_ID tid, const Elem &elem, unsigned int side)
Swap (shallow copy) material properties in MaterialPropertyStorage and MaterialDat Thread safe...
std::optional< std::string > queryStatefulPropName(const unsigned int id) const
bool isRestoredProperty(const std::string &name) const
bool _recovering
Whether or not we're recovering; enforces a one-to-one mapping of stateful properties.
unsigned int numStates() const
unsigned int addProperty(const std::string &prop_name, const std::type_info &type, const unsigned int state, const MaterialBase *const declarer)
Adds a property with the name prop_name, type type, and state state (0 = current, 1 = old...
void updateStatefulPropsForPRefinement(const processor_id_type pid, const std::vector< QpMap > &p_refinement_map, const QBase &qrule, const QBase &qrule_face, const THREAD_ID tid, const Elem &elem, const int input_side)
Based on the p-refinement flag of elem, either prolong (for refinement) or restrict (for coarsening) ...
unsigned int state
The max state requrested for this property (0 = current, 1 = old, ...)
std::vector< MaterialProperties * > initProps(const THREAD_ID tid, const Elem *elem, unsigned int side, unsigned int n_qpoints)
Initializes hashmap entries for element and side to proper qpoint and property count sizes...
bool hasStatefulProperties() const
RestartableMapType _restartable_map
The restartable data to be loaded in initStatefulProps() later.
Basic structure for storing information about a property.
const PropsType & props(const unsigned int state=0) const
Access methods to the stored material property data with the given state state.
std::unordered_map< std::pair< const Elem *, unsigned int >, std::map< unsigned int, std::vector< std::stringstream > > > RestartableMapType
bool hasOlderProperties() const
bool hasProperty(const std::string &prop_name) const
MaterialData & getMaterialData(const THREAD_ID tid)
Proxy for accessing MaterialPropertyStorage.
std::array< PropsType, MaterialData::max_state+1 > _storage
The actual storage.
MaterialPropertyRegistry & _registry
Shared registry (across storage objects) for property names and IDs.
friend void dataLoad(std::istream &, MaterialPropertyStorage &, void *)
void swap(const THREAD_ID tid, const Elem &elem, unsigned int side)
Swap (shallow copy) material properties in MaterialData and MaterialPropertyStorage Thread safe...
void initStatefulProps(const THREAD_ID tid, const std::vector< std::shared_ptr< MaterialBase >> &mats, const unsigned int n_qpoints, const Elem &elem, const unsigned int side=0)
Initialize stateful material properties.
bool stateful() const
Whether or not this property is stateful.
bool _restart_in_place
Whether or not we want to restart stateful properties in place.
void copy(const THREAD_ID tid, const Elem &elem_to, const Elem &elem_from, unsigned int side, unsigned int n_qpoints)
Copy material properties from elem_from to elem_to.
const PropRecord & getPropRecord(const unsigned int id) const
Get the property record associated with the material with id id.
void setRecovering()
Sets the loading of stateful material properties to recover.
MaterialBases compute MaterialProperties.
unsigned int _max_state
The maximum state (0 = current, 1 = old, 2 = older)
void dataStore(std::ostream &stream, MaterialPropertyStorage &storage, void *context)
unsigned int stateful_id
The stateful id in _storage used for this property, if any.
RedistributeProperties is used for its redistribute() callback, which ensures that any stateful prope...
std::set< std::string > declarers
The material (type,name) that have declared this property.
MaterialProperties & initAndSetProps(const Elem *elem, const unsigned int side, const unsigned int state)
std::string type
The type of this property.