Stores the stateful material properties computed by materials. More...
#include <MaterialPropertyStorage.h>
Classes | |
struct | PropRecord |
Basic structure for storing information about a property. More... | |
Public Types | |
typedef HashMap< const Elem *, HashMap< unsigned int, MaterialProperties > > | PropsType |
Accessible type of the stored material property data. More... | |
Public Member Functions | |
MaterialPropertyStorage (MaterialPropertyRegistry ®istry) | |
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. More... | |
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) the stateful material property data. More... | |
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. More... | |
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. More... | |
void | shift () |
Shift the material properties in time. More... | |
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. More... | |
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. More... | |
void | swap (const THREAD_ID tid, const Elem &elem, unsigned int side) |
Swap (shallow copy) material properties in MaterialData and MaterialPropertyStorage Thread safe. More... | |
void | swapBack (const THREAD_ID tid, const Elem &elem, unsigned int side) |
Swap (shallow copy) material properties in MaterialPropertyStorage and MaterialDat Thread safe. More... | |
bool | hasStatefulProperties () const |
bool | hasOlderProperties () const |
bool | hasProperty (const std::string &prop_name) 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, etc) More... | |
const std::vector< unsigned int > & | statefulProps () const |
const MaterialPropertyRegistry & | getMaterialPropertyRegistry () const |
std::optional< std::string > | queryStatefulPropName (const unsigned int id) const |
void | eraseProperty (const Elem *elem) |
Remove the property storage and element pointer from internal data structures Use this when elements are deleted so we don't end up with invalid elem pointers (for e.g. More... | |
unsigned int | maxState () const |
unsigned int | numStates () const |
IntRange< unsigned int > | stateIndexRange () const |
IntRange< unsigned int > | statefulIndexRange () const |
MaterialData & | getMaterialData (const THREAD_ID tid) |
void | setRecovering () |
Sets the loading of stateful material properties to recover. More... | |
void | setRestartInPlace () |
Sets the loading of stateful material properties in place. More... | |
const PropRecord & | getPropRecord (const unsigned int id) const |
Get the property record associated with the material with id id . More... | |
bool | isRestoredProperty (const std::string &name) const |
const PropsType & | props (const unsigned int state=0) const |
Access methods to the stored material property data with the given state state . More... | |
const MaterialProperties & | props (const Elem *elem, unsigned int side, const unsigned int state=0) const |
MaterialProperties & | setProps (const Elem *elem, unsigned int side, const unsigned int state=0) |
Protected Member Functions | |
void | sizeProps (MaterialProperties &mp, unsigned int size) |
Protected Attributes | |
std::array< PropsType, MaterialData::max_state+1 > | _storage |
The actual storage. More... | |
std::vector< std::optional< PropRecord > > | _prop_records |
Property records indexed by property id (may be null) More... | |
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) More... | |
Private Types | |
typedef std::unordered_map< std::pair< const Elem *, unsigned int >, std::map< unsigned int, std::vector< std::stringstream > > > | RestartableMapType |
Private Member Functions | |
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. More... | |
MaterialProperties & | initProps (const THREAD_ID tid, const unsigned int state, const Elem *elem, unsigned int side, unsigned int n_qpoints) |
Initializes just one hashmap's entries. More... | |
PropsType & | setProps (const unsigned int state) |
MaterialProperties & | initAndSetProps (const Elem *elem, const unsigned int side, const unsigned int state) |
Static Private Member Functions | |
static void | shallowSwapData (const std::vector< unsigned int > &stateful_prop_ids, MaterialProperties &data, MaterialProperties &data_from) |
Shallow copies of material properties. More... | |
static void | shallowSwapDataBack (const std::vector< unsigned int > &stateful_prop_ids, MaterialProperties &data, MaterialProperties &data_from) |
Private Attributes | |
unsigned int | _max_state |
The maximum state (0 = current, 1 = old, 2 = older) More... | |
libMesh::Threads::spin_mutex & | _spin_mtx |
MaterialPropertyRegistry & | _registry |
Shared registry (across storage objects) for property names and IDs. More... | |
std::vector< MaterialData > | _material_data |
The threaded material data. More... | |
RestartableMapType | _restartable_map |
The restartable data to be loaded in initStatefulProps() later. More... | |
bool | _restart_in_place |
Whether or not we want to restart stateful properties in place. More... | |
bool | _recovering |
Whether or not we're recovering; enforces a one-to-one mapping of stateful properties. More... | |
Friends | |
class | ProjectMaterialProperties |
class | RedistributeProperties |
void | dataLoad (std::istream &, MaterialPropertyStorage &, void *) |
void | dataStore (std::ostream &, MaterialPropertyStorage &, void *) |
Stores the stateful material properties computed by materials.
Thread-safe
Definition at line 42 of file MaterialPropertyStorage.h.
typedef HashMap<const Elem *, HashMap<unsigned int, MaterialProperties> > MaterialPropertyStorage::PropsType |
Accessible type of the stored material property data.
This probably should have been returned as a proxy class; only access it via foo[elem][side] and maybe we'll be able to refactor it in the future without breaking your code.
Definition at line 254 of file MaterialPropertyStorage.h.
|
private |
Definition at line 428 of file MaterialPropertyStorage.h.
MaterialPropertyStorage::MaterialPropertyStorage | ( | MaterialPropertyRegistry & | registry | ) |
Definition at line 23 of file MaterialPropertyStorage.C.
unsigned int MaterialPropertyStorage::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, etc)
This is idempotent - calling multiple times with the same name will provide the same id and works fine.
declarer
should be specified by the object declaring the property if it is being declared.
Definition at line 478 of file MaterialPropertyStorage.C.
Referenced by MaterialData::addPropertyHelper().
void MaterialPropertyStorage::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.
Thread safe.
WARNING: This is not capable of copying material data to/from elements on other processors. It only works if both elem_to and elem_from are both on the local processor. We can't currently check to ensure that they're on processor here because this isn't a ParallelObject.
tid | The thread ID |
elem_to | Element to copy data to |
elem_from | Element to copy data from |
side | Side number (elemental material properties have this equal to zero) |
n_qpoints | number of quadrature points to work with |
Definition at line 421 of file MaterialPropertyStorage.C.
Referenced by MaterialData::copy().
void MaterialPropertyStorage::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.
Similar to the other method but using pointers to elements instead of references.
tid | The thread ID |
elem_to | Pointer to the element to copy data to |
elem_from | Pointer to the element to copy data from |
side | Side number (elemental material properties have this equal to zero) |
n_qpoints | number of quadrature points to work with |
Definition at line 431 of file MaterialPropertyStorage.C.
void MaterialPropertyStorage::eraseProperty | ( | const Elem * | elem | ) |
Remove the property storage and element pointer from internal data structures Use this when elements are deleted so we don't end up with invalid elem pointers (for e.g.
stateful properties) hanging around in our data structures
Definition at line 74 of file MaterialPropertyStorage.C.
Referenced by MaterialData::eraseProperty(), and FEProblemBase::meshChangedHelper().
|
inline |
tid
Definition at line 327 of file MaterialPropertyStorage.h.
Referenced by FEProblemBase::getMaterialData(), initProps(), ComputeMaterialsObjectThread::onBoundary(), ComputeMaterialsObjectThread::onElement(), ComputeMaterialsObjectThread::onInterface(), ComputeMaterialsObjectThread::onInternalSide(), prolongStatefulProps(), FEProblemBase::reinitMaterials(), FEProblemBase::reinitMaterialsBoundary(), FEProblemBase::reinitMaterialsFace(), FEProblemBase::reinitMaterialsInterface(), FEProblemBase::reinitMaterialsNeighbor(), swap(), swapBack(), FEProblemBase::swapBackMaterials(), FEProblemBase::swapBackMaterialsFace(), FEProblemBase::swapBackMaterialsNeighbor(), and updateStatefulPropsForPRefinement().
|
inline |
Definition at line 284 of file MaterialPropertyStorage.h.
Referenced by dataLoad(), dataStore(), and MaterialData::getPropertyId().
const MaterialPropertyStorage::PropRecord & MaterialPropertyStorage::getPropRecord | ( | const unsigned int | id | ) | const |
Get the property record associated with the material with id id
.
Definition at line 88 of file MaterialPropertyStorage.C.
Referenced by dataLoad(), MaterialData::getMaxStateRequested(), initStatefulProps(), and isRestoredProperty().
|
inline |
Definition at line 245 of file MaterialPropertyStorage.h.
|
inline |
Definition at line 266 of file MaterialPropertyStorage.h.
Referenced by MaterialData::hasProperty().
|
inline |
Definition at line 240 of file MaterialPropertyStorage.h.
Referenced by FEProblemBase::addAnyRedistributers(), FEProblemBase::advanceState(), FEProblemBase::checkProblemIntegrity(), FEProblemBase::initialSetup(), FEProblemBase::meshChangedHelper(), ProjectMaterialProperties::onBoundary(), shift(), MaterialData::swap(), and MaterialData::swapBack().
|
inlineprivate |
elem
, side side
, and state state
.Similar to setProps, but will initialize (default construct) the entry if it does not exist.
Definition at line 473 of file MaterialPropertyStorage.h.
Referenced by initProps(), and swap().
|
private |
Initializes hashmap entries for element and side to proper qpoint and property count sizes.
Definition at line 522 of file MaterialPropertyStorage.C.
Referenced by copy(), initStatefulProps(), prolongStatefulProps(), restrictStatefulProps(), and updateStatefulPropsForPRefinement().
|
private |
Initializes just one hashmap's entries.
Definition at line 534 of file MaterialPropertyStorage.C.
void MaterialPropertyStorage::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.
tid | The thread ID |
mats | Materials that will compute the initial values |
n_qpoints | Number of quadrature points |
elem | Element we are on |
side | Side of the element 'elem' (0 for volumetric material properties) |
If restartable stateful information is available, this will load from restart instead of calling initStatefulProperties()
Definition at line 270 of file MaterialPropertyStorage.C.
Referenced by ComputeMaterialsObjectThread::onBoundary(), ComputeMaterialsObjectThread::onElement(), ComputeMaterialsObjectThread::onInterface(), and ComputeMaterialsObjectThread::onInternalSide().
bool MaterialPropertyStorage::isRestoredProperty | ( | const std::string & | name | ) | const |
name
was restored Definition at line 97 of file MaterialPropertyStorage.C.
Referenced by dataLoad().
|
inline |
Definition at line 301 of file MaterialPropertyStorage.h.
Referenced by addProperty(), hasOlderProperties(), hasStatefulProperties(), numStates(), and shift().
|
inline |
Definition at line 309 of file MaterialPropertyStorage.h.
Referenced by dataLoad(), dataStore(), initProps(), statefulIndexRange(), and stateIndexRange().
void MaterialPropertyStorage::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.
Also, copies values from the parent qps to the new children.
Note - call this on the MaterialPropertyStorage object for the children that you want to project to. ie, if you are trying to project to the sides of the children, then call this on the boundary MaterialPropertyStorage. Pass in the parent MaterialPropertyStorage you are projecting from. ie the volume one if you are projecting to "internal" child element faces.
There are 3 cases here:
pid | - processor id of children to prolong to |
refinement_map | - 2D array of QpMap objects |
qrule | The current quadrature rule |
qrule_face | The current face qrule |
parent_material_props | The place to pull parent material property values from |
tid | The thread ID |
elem | The parent element that was just refined |
input_parent_side | - the side of the parent for which material properties are prolonged |
input_child | - the number of the child |
input_child_side | - the side on the child where material properties will be prolonged |
Definition at line 151 of file MaterialPropertyStorage.C.
Referenced by ProjectMaterialProperties::onBoundary(), ProjectMaterialProperties::onElement(), and ProjectMaterialProperties::onInternalSide().
|
inline |
Access methods to the stored material property data with the given state state
.
Definition at line 450 of file MaterialPropertyStorage.h.
Referenced by copy(), initProps(), initStatefulProps(), prolongStatefulProps(), props(), restrictStatefulProps(), swap(), and swapBack().
|
inline |
Definition at line 457 of file MaterialPropertyStorage.h.
std::optional< std::string > MaterialPropertyStorage::queryStatefulPropName | ( | const unsigned int | id | ) | const |
id
, if any. Definition at line 66 of file MaterialPropertyStorage.C.
Referenced by FEProblemBase::checkDependMaterialsHelper().
void MaterialPropertyStorage::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.
Also, copies values from the children to the parent.
coarsening_map | - map from unsigned ints to QpMap's |
coarsened_element_children | - a pointer to a vector of coarsened element children |
qrule | The current quadrature rule |
qrule_face | The current face qrule |
tid | The thread ID |
elem | The parent element that was just refined |
input_side | Side of the element 'elem' (0 for volumetric material properties) |
Definition at line 221 of file MaterialPropertyStorage.C.
Referenced by ProjectMaterialProperties::onBoundary(), and ProjectMaterialProperties::onElement().
|
inline |
Definition at line 467 of file MaterialPropertyStorage.h.
Referenced by dataLoad(), dataStore(), eraseProperty(), initAndSetProps(), shift(), and swapBack().
|
inlineprivate |
state
. Definition at line 481 of file MaterialPropertyStorage.h.
|
inline |
Sets the loading of stateful material properties to recover.
This enforces the requirement of one-to-one stateful material properties, disabling advanced restart of stateful properties
Definition at line 335 of file MaterialPropertyStorage.h.
void MaterialPropertyStorage::setRestartInPlace | ( | ) |
Sets the loading of stateful material properties in place.
On init, this cannot be set because we must first call initProps() to properly initialize the dynamic types within _storage. After the first sweep through with initProps(), we can then load the stateful props directly in place into _storage
Also clears _restartable_map, as it should no longer be needed
Definition at line 81 of file MaterialPropertyStorage.C.
|
staticprivate |
Shallow copies of material properties.
Definition at line 36 of file MaterialPropertyStorage.C.
Referenced by swap().
|
staticprivate |
Definition at line 51 of file MaterialPropertyStorage.C.
Referenced by swapBack().
void MaterialPropertyStorage::shift | ( | ) |
Shift the material properties in time.
Old material properties become older, current material properties become old. Older material properties are reused for computing current properties. This is called when solve succeeded.
Shift properties back in time and reuse older data for current (save reallocations etc.) With current, old, and older this can be accomplished by two swaps: older <-> old old <-> current
Definition at line 406 of file MaterialPropertyStorage.C.
Referenced by FEProblemBase::advanceState().
|
protected |
|
inline |
Will be an empty range if there are no stateful states
Definition at line 319 of file MaterialPropertyStorage.h.
Referenced by initStatefulProps().
|
inline |
Definition at line 282 of file MaterialPropertyStorage.h.
|
inline |
Definition at line 313 of file MaterialPropertyStorage.h.
Referenced by copy(), dataStore(), eraseProperty(), initProps(), prolongStatefulProps(), MaterialData::resize(), restrictStatefulProps(), swap(), swapBack(), and updateStatefulPropsForPRefinement().
Swap (shallow copy) material properties in MaterialData and MaterialPropertyStorage Thread safe.
tid | The thread id |
elem | Element id |
side | Side number (elemental material properties have this equal to zero) |
Definition at line 449 of file MaterialPropertyStorage.C.
Referenced by initStatefulProps(), and MaterialData::swap().
void MaterialPropertyStorage::swapBack | ( | const THREAD_ID | tid, |
const Elem & | elem, | ||
unsigned int | side | ||
) |
Swap (shallow copy) material properties in MaterialPropertyStorage and MaterialDat Thread safe.
tid | The thread id |
elem | Element id |
side | Side number (elemental material properties have this equal to zero) |
Definition at line 461 of file MaterialPropertyStorage.C.
Referenced by initStatefulProps(), and MaterialData::swapBack().
void MaterialPropertyStorage::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) the stateful material property data.
pid | The rank returned by the mesh. This is used to assert that we are only prolonging/restricting for elements that our process owns |
p_refinement_map | A map that describes, for each quadrature point on the current level which quadrature point on the previous level it is closest to |
qrule | The volumetric quadrature rule |
qrule_face | The face quadrature rule |
tid | The thread ID |
elem | The element that was just p-refined or coarsened that we are performing material property prolongation/restriction for |
input_side | Which element side we are performing material property prolongation/restriction for. Pass in -1 for doing volumetric prolongation/restriction |
Definition at line 106 of file MaterialPropertyStorage.C.
Referenced by ProjectMaterialProperties::onBoundary(), and ProjectMaterialProperties::onElement().
|
friend |
Definition at line 629 of file MaterialPropertyStorage.C.
Referenced by initStatefulProps().
|
friend |
Definition at line 566 of file MaterialPropertyStorage.C.
|
friend |
Definition at line 439 of file MaterialPropertyStorage.h.
|
friend |
Definition at line 442 of file MaterialPropertyStorage.h.
|
private |
The threaded material data.
Definition at line 424 of file MaterialPropertyStorage.h.
Referenced by getMaterialData(), and MaterialPropertyStorage().
|
private |
The maximum state (0 = current, 1 = old, 2 = older)
Definition at line 413 of file MaterialPropertyStorage.h.
Referenced by addProperty(), and maxState().
|
protected |
Property records indexed by property id (may be null)
Definition at line 364 of file MaterialPropertyStorage.h.
Referenced by addProperty(), dataLoad(), dataStore(), getPropRecord(), and queryStatefulPropName().
|
private |
Whether or not we're recovering; enforces a one-to-one mapping of stateful properties.
Definition at line 436 of file MaterialPropertyStorage.h.
Referenced by dataLoad(), and setRecovering().
|
private |
Shared registry (across storage objects) for property names and IDs.
Definition at line 421 of file MaterialPropertyStorage.h.
Referenced by addProperty(), getMaterialPropertyRegistry(), hasProperty(), initStatefulProps(), isRestoredProperty(), and queryStatefulPropName().
|
private |
Whether or not we want to restart stateful properties in place.
Definition at line 434 of file MaterialPropertyStorage.h.
Referenced by dataLoad(), and setRestartInPlace().
|
private |
The restartable data to be loaded in initStatefulProps() later.
Definition at line 431 of file MaterialPropertyStorage.h.
Referenced by dataLoad(), initStatefulProps(), and setRestartInPlace().
|
private |
Definition at line 418 of file MaterialPropertyStorage.h.
Referenced by swap(), and swapBack().
|
protected |
the vector of stateful property ids (the vector index is the map to stateful prop_id)
Definition at line 367 of file MaterialPropertyStorage.h.
Referenced by addProperty(), copy(), dataLoad(), dataStore(), initProps(), prolongStatefulProps(), restrictStatefulProps(), statefulProps(), swap(), swapBack(), and updateStatefulPropsForPRefinement().
|
protected |
The actual storage.
Definition at line 361 of file MaterialPropertyStorage.h.
Referenced by maxState(), and props().