The Kokkos class responsible for allocating and storing Kokkos material properties. More...
#include <KokkosMaterialPropertyStorage.h>
Public Member Functions | |
MaterialPropertyStorage (MaterialPropertyRegistry ®istry, FEProblemBase &problem) | |
Constructor. More... | |
MaterialPropertyBase & | addKokkosProperty (const std::string &prop_name, const std::type_info &type, const unsigned int state, const ::MaterialBase *declarer, std::shared_ptr< MaterialPropertyBase > shell) |
Add a material property. More... | |
MaterialPropertyBase & | addKokkosPropertyState (const std::string &prop_name, const unsigned int state, std::shared_ptr< MaterialPropertyBase > shell) |
Add an old/older material property. More... | |
MaterialPropertyBase & | declareKokkosProperty (const std::string &prop_name, const std::type_info &type, const ::MaterialBase *declarer, const std::vector< unsigned int > &dims, const bool bnd, std::shared_ptr< MaterialPropertyBase > shell) |
Declare a material property. More... | |
MaterialPropertyBase & | getKokkosProperty (std::string prop_name, unsigned int state=0) |
Get a material property. More... | |
bool | haveKokkosProperty (std::string prop_name, unsigned int state=0) |
Get whether a material property exists. More... | |
void | registerLoadStore (std::type_index type, PropertyStore store, PropertyLoad load) |
Register the load/store functions. More... | |
void | allocateKokkosProperties () |
Allocate all the material property data storages. More... | |
void | shift () |
Shift current, old, and older material property data storages. More... | |
void | copy () |
Copy current material properties to old and older. More... | |
Static Public Member Functions | |
static MaterialPropertyStorage & | cast (::MaterialPropertyStorage &storage) |
Cast the reference of a Kokkos material property storage from the base type to the actual type. More... | |
Protected Types | |
typedef HashMap< const Elem *, HashMap< unsigned int, MaterialProperties > > | PropsType |
Accessible type of the stored material property data. More... | |
Protected Member Functions | |
void | prolongStatefulProps (processor_id_type pid, const std::vector< std::vector< QpMap >> &refinement_map, const libMesh::QBase &qrule, const libMesh::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 libMesh::QBase &qrule, const libMesh::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 libMesh::QBase &qrule, const libMesh::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 | 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 |
libMesh::IntRange< unsigned int > | stateIndexRange () const |
libMesh::IntRange< unsigned int > | statefulIndexRange () const |
const MaterialData & | getMaterialData (const THREAD_ID tid) const |
MaterialData & | getMaterialData (const THREAD_ID tid) |
const std::set< const MooseObject * > & | getConsumers (Moose::MaterialDataType type) const |
void | addConsumer (Moose::MaterialDataType type, const MooseObject *object) |
Add object as the consumer of storage of type type . More... | |
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 |
void | sizeProps (MaterialProperties &mp, unsigned int size) |
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 Attributes | |
FEProblemBase & | _problem |
Reference to the problem. More... | |
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... | |
std::map< Moose::MaterialDataType, std::set< const MooseObject * > > | _consumers |
The consumers of this storage. More... | |
Private Member Functions | |
friend | void ::dataStore (std::ostream &, MaterialPropertyStorage &, void *) |
friend | void ::dataLoad (std::istream &, MaterialPropertyStorage &, void *) |
Private Attributes | |
std::unordered_map< std::string, std::shared_ptr< MaterialPropertyBase > > | _kokkos_props [MaterialData::max_state+1] |
Material properties. More... | |
std::unordered_map< std::string, Moose::Kokkos::PropRecord > | _kokkos_prop_records |
Record of each material property. More... | |
Static Private Attributes | |
static std::unordered_map< std::type_index, PropertyStore > | _store_functions |
Function pointer maps for load/store. More... | |
static std::unordered_map< std::type_index, PropertyLoad > | _load_functions |
The Kokkos class responsible for allocating and storing Kokkos material properties.
Definition at line 29 of file KokkosMaterialPropertyStorage.h.
|
inherited |
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 255 of file MaterialPropertyStorage.h.
Moose::Kokkos::MaterialPropertyStorage::MaterialPropertyStorage | ( | MaterialPropertyRegistry & | registry, |
FEProblemBase & | problem | ||
) |
Constructor.
|
inlineinherited |
Add object
as the consumer of storage of type type
.
Definition at line 342 of file MaterialPropertyStorage.h.
Referenced by FEProblemBase::getMaterialData().
MaterialPropertyBase& Moose::Kokkos::MaterialPropertyStorage::addKokkosProperty | ( | const std::string & | prop_name, |
const std::type_info & | type, | ||
const unsigned int | state, | ||
const ::MaterialBase * | declarer, | ||
std::shared_ptr< MaterialPropertyBase > | shell | ||
) |
Add a material property.
prop_name | The property name |
type | The property data type |
state | The property state |
declarer | The Kokkos material declaring the property, nullptr if simply reserving the property |
shell | The managed pointer containing the instance of the property |
MaterialPropertyBase& Moose::Kokkos::MaterialPropertyStorage::addKokkosPropertyState | ( | const std::string & | prop_name, |
const unsigned int | state, | ||
std::shared_ptr< MaterialPropertyBase > | shell | ||
) |
Add an old/older material property.
prop_name | The property name |
state | The property state |
shell | The managed pointer containing the |
|
inherited |
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 493 of file MaterialPropertyStorage.C.
Referenced by MaterialData::addPropertyHelper().
void Moose::Kokkos::MaterialPropertyStorage::allocateKokkosProperties | ( | ) |
Allocate all the material property data storages.
|
static |
void Moose::Kokkos::MaterialPropertyStorage::copy | ( | ) |
Copy current material properties to old and older.
|
inherited |
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 436 of file MaterialPropertyStorage.C.
Referenced by MaterialData::copy().
|
inherited |
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 446 of file MaterialPropertyStorage.C.
MaterialPropertyBase& Moose::Kokkos::MaterialPropertyStorage::declareKokkosProperty | ( | const std::string & | prop_name, |
const std::type_info & | type, | ||
const ::MaterialBase * | declarer, | ||
const std::vector< unsigned int > & | dims, | ||
const bool | bnd, | ||
std::shared_ptr< MaterialPropertyBase > | shell | ||
) |
Declare a material property.
prop_name | The property name |
type | The property data type |
declarer | The Kokkos material declaring the property, nullptr if simply reserving the |
dims | The vector containing the size of each dimension |
bnd | Whether the property is a face property |
shell | The managed pointer containing the instance of the property |
|
inherited |
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 76 of file MaterialPropertyStorage.C.
Referenced by MaterialData::eraseProperty(), and FEProblemBase::meshChanged().
|
inherited |
type
Definition at line 108 of file MaterialPropertyStorage.C.
Referenced by FEProblemBase::getMaterialPropertyStorageConsumers().
MaterialPropertyBase& Moose::Kokkos::MaterialPropertyStorage::getKokkosProperty | ( | std::string | prop_name, |
unsigned int | state = 0 |
||
) |
Get a material property.
prop_name | The property name |
state | The property state |
|
inlineinherited |
tid
Definition at line 331 of file MaterialPropertyStorage.h.
Referenced by FEProblemBase::getMaterialData(), ComputeMaterialsObjectThread::onBoundary(), ComputeMaterialsObjectThread::onElement(), ComputeMaterialsObjectThread::onInterface(), ComputeMaterialsObjectThread::onInternalSide(), FEProblemBase::reinitMaterials(), FEProblemBase::reinitMaterialsBoundary(), FEProblemBase::reinitMaterialsFace(), FEProblemBase::reinitMaterialsInterface(), FEProblemBase::reinitMaterialsNeighbor(), FEProblemBase::swapBackMaterials(), FEProblemBase::swapBackMaterialsFace(), and FEProblemBase::swapBackMaterialsNeighbor().
|
inlineinherited |
Definition at line 332 of file MaterialPropertyStorage.h.
|
inlineinherited |
Definition at line 285 of file MaterialPropertyStorage.h.
Referenced by dataLoad(), dataStore(), and MaterialData::getPropertyId().
|
inherited |
Get the property record associated with the material with id id
.
Definition at line 90 of file MaterialPropertyStorage.C.
Referenced by dataLoad(), MaterialData::getMaxStateRequested(), MaterialPropertyStorage::initStatefulProps(), and MaterialPropertyStorage::isRestoredProperty().
|
inlineinherited |
Definition at line 246 of file MaterialPropertyStorage.h.
|
inlineinherited |
Definition at line 267 of file MaterialPropertyStorage.h.
Referenced by MaterialData::hasProperty().
|
inlineinherited |
Definition at line 241 of file MaterialPropertyStorage.h.
Referenced by FEProblemBase::addAnyRedistributers(), FEProblemBase::advanceState(), FEProblemBase::checkProblemIntegrity(), FEProblemBase::initialSetup(), FEProblemBase::meshChanged(), ProjectMaterialProperties::onBoundary(), MaterialPropertyStorage::shift(), MaterialData::swap(), and MaterialData::swapBack().
bool Moose::Kokkos::MaterialPropertyStorage::haveKokkosProperty | ( | std::string | prop_name, |
unsigned int | state = 0 |
||
) |
Get whether a material property exists.
prop_name | The property name |
state | The property state |
|
inherited |
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 285 of file MaterialPropertyStorage.C.
Referenced by ComputeMaterialsObjectThread::onBoundary(), ComputeMaterialsObjectThread::onElement(), ComputeMaterialsObjectThread::onInterface(), and ComputeMaterialsObjectThread::onInternalSide().
|
inherited |
name
was restored Definition at line 99 of file MaterialPropertyStorage.C.
Referenced by dataLoad().
|
inlineinherited |
Definition at line 302 of file MaterialPropertyStorage.h.
Referenced by MaterialPropertyStorage::addProperty(), MaterialPropertyStorage::hasOlderProperties(), MaterialPropertyStorage::hasStatefulProperties(), MaterialPropertyStorage::numStates(), and MaterialPropertyStorage::shift().
|
inlineinherited |
Definition at line 310 of file MaterialPropertyStorage.h.
Referenced by dataLoad(), dataStore(), MaterialPropertyStorage::initProps(), MaterialPropertyStorage::statefulIndexRange(), and MaterialPropertyStorage::stateIndexRange().
|
inherited |
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 166 of file MaterialPropertyStorage.C.
Referenced by ProjectMaterialProperties::onBoundary(), ProjectMaterialProperties::onElement(), and ProjectMaterialProperties::onInternalSide().
|
inlineinherited |
Access methods to the stored material property data with the given state state
.
Definition at line 474 of file MaterialPropertyStorage.h.
Referenced by MaterialPropertyStorage::copy(), MaterialPropertyStorage::initProps(), MaterialPropertyStorage::initStatefulProps(), MaterialPropertyStorage::prolongStatefulProps(), MaterialPropertyStorage::props(), MaterialPropertyStorage::restrictStatefulProps(), MaterialPropertyStorage::swap(), and MaterialPropertyStorage::swapBack().
|
inlineinherited |
Definition at line 481 of file MaterialPropertyStorage.h.
|
inherited |
id
, if any. Definition at line 68 of file MaterialPropertyStorage.C.
void Moose::Kokkos::MaterialPropertyStorage::registerLoadStore | ( | std::type_index | type, |
PropertyStore | store, | ||
PropertyLoad | load | ||
) |
Register the load/store functions.
type | The property type index |
store | The function pointer to the store function |
load | The function pointer to the load function |
|
inherited |
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 236 of file MaterialPropertyStorage.C.
Referenced by ProjectMaterialProperties::onBoundary(), and ProjectMaterialProperties::onElement().
|
inlineinherited |
Definition at line 491 of file MaterialPropertyStorage.h.
Referenced by dataLoad(), dataStore(), MaterialPropertyStorage::eraseProperty(), MaterialPropertyStorage::initAndSetProps(), MaterialPropertyStorage::shift(), and MaterialPropertyStorage::swapBack().
|
inlineinherited |
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 353 of file MaterialPropertyStorage.h.
|
inherited |
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 83 of file MaterialPropertyStorage.C.
void Moose::Kokkos::MaterialPropertyStorage::shift | ( | ) |
Shift current, old, and older material property data storages.
Referenced by FEProblemBase::advanceState().
|
protectedinherited |
|
inlineinherited |
Will be an empty range if there are no stateful states
Definition at line 323 of file MaterialPropertyStorage.h.
Referenced by MaterialPropertyStorage::initStatefulProps().
|
inlineinherited |
Definition at line 283 of file MaterialPropertyStorage.h.
|
inlineinherited |
Definition at line 314 of file MaterialPropertyStorage.h.
Referenced by MaterialPropertyStorage::copy(), dataStore(), MaterialPropertyStorage::eraseProperty(), MaterialPropertyStorage::initProps(), MaterialPropertyStorage::prolongStatefulProps(), MaterialData::resize(), MaterialPropertyStorage::restrictStatefulProps(), MaterialPropertyStorage::swap(), MaterialPropertyStorage::swapBack(), and MaterialPropertyStorage::updateStatefulPropsForPRefinement().
|
inherited |
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 464 of file MaterialPropertyStorage.C.
Referenced by MaterialPropertyStorage::initStatefulProps(), and MaterialData::swap().
|
inherited |
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 476 of file MaterialPropertyStorage.C.
Referenced by MaterialPropertyStorage::initStatefulProps(), and MaterialData::swapBack().
|
inherited |
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 121 of file MaterialPropertyStorage.C.
Referenced by ProjectMaterialProperties::onBoundary(), and ProjectMaterialProperties::onElement().
|
private |
|
private |
|
protectedinherited |
The consumers of this storage.
Definition at line 391 of file MaterialPropertyStorage.h.
Referenced by MaterialPropertyStorage::addConsumer(), and MaterialPropertyStorage::getConsumers().
|
private |
Record of each material property.
Definition at line 141 of file KokkosMaterialPropertyStorage.h.
|
private |
Material properties.
Definition at line 137 of file KokkosMaterialPropertyStorage.h.
|
staticprivate |
Definition at line 147 of file KokkosMaterialPropertyStorage.h.
|
protectedinherited |
Reference to the problem.
Definition at line 379 of file MaterialPropertyStorage.h.
|
protectedinherited |
Property records indexed by property id (may be null)
Definition at line 385 of file MaterialPropertyStorage.h.
Referenced by MaterialPropertyStorage::addProperty(), dataLoad(), dataStore(), MaterialPropertyStorage::getPropRecord(), and MaterialPropertyStorage::queryStatefulPropName().
|
protectedinherited |
the vector of stateful property ids (the vector index is the map to stateful prop_id)
Definition at line 388 of file MaterialPropertyStorage.h.
Referenced by MaterialPropertyStorage::addProperty(), MaterialPropertyStorage::copy(), dataLoad(), dataStore(), MaterialPropertyStorage::initProps(), MaterialPropertyStorage::prolongStatefulProps(), MaterialPropertyStorage::restrictStatefulProps(), MaterialPropertyStorage::statefulProps(), MaterialPropertyStorage::swap(), MaterialPropertyStorage::swapBack(), and MaterialPropertyStorage::updateStatefulPropsForPRefinement().
|
protectedinherited |
The actual storage.
Definition at line 382 of file MaterialPropertyStorage.h.
Referenced by MaterialPropertyStorage::maxState(), and MaterialPropertyStorage::props().
|
staticprivate |
Function pointer maps for load/store.
{@
Definition at line 146 of file KokkosMaterialPropertyStorage.h.