https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Private Types | Private Member Functions | Private Attributes | List of all members
Moose::Kokkos::MaterialPropertyStorage Class Reference

The Kokkos class responsible for allocating and storing Kokkos material properties. More...

#include <KokkosMaterialPropertyStorage.h>

Inheritance diagram for Moose::Kokkos::MaterialPropertyStorage:
[legend]

Public Member Functions

 MaterialPropertyStorage (MaterialPropertyRegistry &registry, FEProblemBase &problem)
 Constructor.
 
MaterialPropertyBaseaddKokkosProperty (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.
 
MaterialPropertyBaseaddKokkosPropertyState (const std::string &prop_name, const unsigned int state, std::shared_ptr< MaterialPropertyBase > shell)
 Add an old/older material property.
 
MaterialPropertyBasedeclareKokkosProperty (const std::string &prop_name, const std::type_info &type, const ::MaterialBase *declarer, const std::vector< unsigned int > &dims, const bool bnd, const bool on_demand, const PropertyConstantOption constant_option, std::shared_ptr< MaterialPropertyBase > shell)
 Declare a material property.
 
MaterialPropertyBasegetKokkosProperty (std::string prop_name, unsigned int state=0)
 Get a material property.
 
bool haveKokkosProperty (std::string prop_name, unsigned int state=0)
 Get whether a material property exists.
 
void registerLoadStore (std::type_index type, PropertyStore store, PropertyLoad load)
 Register the load/store functions.
 
void allocateKokkosProperties ()
 Allocate all the material property data storages.
 
void shift ()
 Shift current, old, and older material property data storages.
 
void copy ()
 Copy current material properties to old and older.
 

Static Public Member Functions

static MaterialPropertyStoragecast (::MaterialPropertyStorage &storage)
 Cast the reference of a Kokkos material property storage from the base type to the actual type.
 

Protected Types

typedef HashMap< const Elem *, HashMap< unsigned int, MaterialProperties > > PropsType
 Accessible type of the stored material property data.
 

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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
void swap (const THREAD_ID tid, const Elem &elem, unsigned int side)
 Swap (shallow copy) material properties in MaterialData and MaterialPropertyStorage Thread safe.
 
void swapBack (const THREAD_ID tid, const Elem &elem, unsigned int side)
 Swap (shallow copy) material properties in MaterialPropertyStorage and MaterialDat Thread safe.
 
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)
 
const std::vector< unsigned int > & statefulProps () const
 
const MaterialPropertyRegistrygetMaterialPropertyRegistry () 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.
 
unsigned int maxState () const
 
unsigned int numStates () const
 
libMesh::IntRange< unsigned intstateIndexRange () const
 
libMesh::IntRange< unsigned intstatefulIndexRange () const
 
const MaterialDatagetMaterialData (const THREAD_ID tid) const
 
MaterialDatagetMaterialData (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.
 
void setRecovering ()
 Sets the loading of stateful material properties to recover.
 
void setRestartInPlace ()
 Sets the loading of stateful material properties in place.
 
const PropRecordgetPropRecord (const unsigned int id) const
 Get the property record associated with the material with id id.
 
bool isRestoredProperty (const std::string &name) const
 
void sizeProps (MaterialProperties &mp, unsigned int size)
 
const PropsTypeprops (const unsigned int state=0) const
 Access methods to the stored material property data with the given state state.
 
const MaterialPropertiesprops (const Elem *elem, unsigned int side, const unsigned int state=0) const
 
MaterialPropertiessetProps (const Elem *elem, unsigned int side, const unsigned int state=0)
 

Protected Attributes

FEProblemBase_problem
 Reference to the problem.
 
std::array< PropsType, MaterialData::max_state+1 > _storage
 The actual storage.
 
std::vector< std::optional< PropRecord > > _prop_records
 Property records indexed by property id (may be null)
 
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)
 
std::map< Moose::MaterialDataType, std::set< const MooseObject * > > _consumers
 The consumers of this storage.
 

Private Types

typedef std::unordered_map< std::pair< const Elem *, unsigned int >, std::map< unsigned int, std::vector< std::stringstream > > > RestartableMapType
 

Private Member Functions

friend void::dataStore (std::ostream &, MaterialPropertyStorage &, void *)
 
friend void::dataLoad (std::istream &, MaterialPropertyStorage &, void *)
 
PropsTypesetProps (const unsigned int state)
 
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.
 
MaterialPropertiesinitProps (const THREAD_ID tid, const unsigned int state, const Elem *elem, unsigned int side, unsigned int n_qpoints)
 Initializes just one hashmap's entries.
 
MaterialPropertiesinitAndSetProps (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.
 
static void shallowSwapDataBack (const std::vector< unsigned int > &stateful_prop_ids, MaterialProperties &data, MaterialProperties &data_from)
 

Private Attributes

std::unordered_map< std::string, std::shared_ptr< MaterialPropertyBase > > _kokkos_props [MaterialData::max_state+1]
 Material properties.
 
std::unordered_map< std::string, Moose::Kokkos::PropRecord_kokkos_prop_records
 Record of each material property.
 
unsigned int _max_state
 The maximum state (0 = current, 1 = old, 2 = older)
 
libMesh::Threads::spin_mutex_spin_mtx
 
MaterialPropertyRegistry_registry
 Shared registry (across storage objects) for property names and IDs.
 
std::vector< MaterialData_material_data
 The threaded material data.
 
RestartableMapType _restartable_map
 The restartable data to be loaded in initStatefulProps() later.
 
bool _restart_in_place
 Whether or not we want to restart stateful properties in place.
 
bool _recovering
 Whether or not we're recovering; enforces a one-to-one mapping of stateful properties.
 

Static Private Attributes

static std::unordered_map< std::type_index, PropertyStore_store_functions
 Function pointer maps for load/store.
 
static std::unordered_map< std::type_index, PropertyLoad_load_functions
 

Detailed Description

The Kokkos class responsible for allocating and storing Kokkos material properties.

Definition at line 27 of file KokkosMaterialPropertyStorage.h.

Member Typedef Documentation

◆ PropsType

typedef HashMap<const Elem *, HashMap<unsigned int, MaterialProperties> > MaterialPropertyStorage::PropsType
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.

◆ RestartableMapType

typedef std::unordered_map<std::pair<const Elem *, unsigned int>, std::map<unsigned int, std::vector<std::stringstream> > > MaterialPropertyStorage::RestartableMapType
privateinherited

Definition at line 452 of file MaterialPropertyStorage.h.

Constructor & Destructor Documentation

◆ MaterialPropertyStorage()

Moose::Kokkos::MaterialPropertyStorage::MaterialPropertyStorage ( MaterialPropertyRegistry registry,
FEProblemBase problem 
)

Constructor.

Member Function Documentation

◆ addConsumer()

void MaterialPropertyStorage::addConsumer ( Moose::MaterialDataType  type,
const MooseObject object 
)
inlineinherited

Add object as the consumer of storage of type type.

Definition at line 342 of file MaterialPropertyStorage.h.

343 {
344 _consumers[type].insert(object);
345 }
std::map< Moose::MaterialDataType, std::set< const MooseObject * > > _consumers
The consumers of this storage.

Referenced by FEProblemBase::getMaterialData().

◆ addKokkosProperty()

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.

Parameters
prop_nameThe property name
typeThe property data type
stateThe property state
declarerThe Kokkos material declaring the property, nullptr if simply reserving the property
shellThe managed pointer containing the instance of the property
Returns
The material property

◆ addKokkosPropertyState()

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.

Parameters
prop_nameThe property name
stateThe property state
shellThe managed pointer containing the
Returns
The material property

◆ addProperty()

unsigned int MaterialPropertyStorage::addProperty ( const std::string &  prop_name,
const std::type_info &  type,
const unsigned int  state,
const MaterialBase *const  declarer 
)
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.

497{
498 if (state > MaterialData::max_state)
499 mooseError("Material property state of ",
500 state,
501 " is not supported. Max state supported: ",
503
504 // Increment state as needed
505 if (maxState() < state)
506 _max_state = state;
507
508 // Register the property
509 const auto prop_id = _registry.addOrGetID(prop_name, {});
510
511 // Instantiate the record if needed
512 if (_prop_records.size() < _registry.size())
513 _prop_records.resize(_registry.size());
514 if (!_prop_records[prop_id])
515 _prop_records[prop_id] = PropRecord();
516
517 // Fill the record
518 auto & record = *_prop_records[prop_id];
519 record.type = type.name();
520 if (declarer)
521 record.declarers.emplace(declarer->typeAndName());
522 record.state = std::max(state, record.state);
523
524 // Keep track of stateful props by quick access
525 if (state > 0 && std::find(_stateful_prop_id_to_prop_id.begin(),
527 prop_id) == _stateful_prop_id_to_prop_id.end())
528 {
529 _stateful_prop_id_to_prop_id.push_back(prop_id);
530 record.stateful_id = _stateful_prop_id_to_prop_id.size() - 1;
531 }
532
533 return prop_id;
534}
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
static constexpr unsigned int max_state
The max time state supported (2 = older)
unsigned int addOrGetID(const std::string &name, const WriteKey)
MaterialPropertyRegistry & _registry
Shared registry (across storage objects) for property names and IDs.
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)
std::vector< std::optional< PropRecord > > _prop_records
Property records indexed by property id (may be null)
unsigned int _max_state
The maximum state (0 = current, 1 = old, 2 = older)
std::string typeAndName() const
Get the class's combined type and name; useful in error handling.
Definition MooseBase.C:57

Referenced by MaterialData::addPropertyHelper().

◆ allocateKokkosProperties()

void Moose::Kokkos::MaterialPropertyStorage::allocateKokkosProperties ( )

Allocate all the material property data storages.

◆ cast()

static MaterialPropertyStorage & Moose::Kokkos::MaterialPropertyStorage::cast ( ::MaterialPropertyStorage storage)
static

Cast the reference of a Kokkos material property storage from the base type to the actual type.

Parameters
storageThe Kokkos material property storage as the reference of the base type
Returns
The Kokkos material property storage as the reference of the actual type

◆ copy() [1/3]

void Moose::Kokkos::MaterialPropertyStorage::copy ( )

Copy current material properties to old and older.

◆ copy() [2/3]

void MaterialPropertyStorage::copy ( const THREAD_ID  tid,
const Elem &  elem_to,
const Elem &  elem_from,
unsigned int  side,
unsigned int  n_qpoints 
)
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.

Parameters
tidThe thread ID
elem_toElement to copy data to
elem_fromElement to copy data from
sideSide number (elemental material properties have this equal to zero)
n_qpointsnumber of quadrature points to work with

Definition at line 436 of file MaterialPropertyStorage.C.

441{
442 copy(tid, &elem_to, &elem_from, side, n_qpoints);
443}
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.

Referenced by MaterialData::copy(), and MaterialPropertyStorage::copy().

◆ copy() [3/3]

void MaterialPropertyStorage::copy ( const THREAD_ID  tid,
const Elem *  elem_to,
const Elem *  elem_from,
unsigned int  side,
unsigned int  n_qpoints 
)
inherited

Copy material properties from elem_from to elem_to.

Similar to the other method but using pointers to elements instead of references.

Parameters
tidThe thread ID
elem_toPointer to the element to copy data to
elem_fromPointer to the element to copy data from
sideSide number (elemental material properties have this equal to zero)
n_qpointsnumber of quadrature points to work with

Definition at line 446 of file MaterialPropertyStorage.C.

451{
452 auto to_props = initProps(tid, elem_to, side, n_qpoints);
453
454 for (const auto state : stateIndexRange())
455 {
456 const auto & from_props = props(elem_from, side, state);
457 for (const auto i : index_range(_stateful_prop_id_to_prop_id))
458 for (const auto qp : make_range(n_qpoints))
459 (*to_props[state])[i].qpCopy(qp, from_props[i], qp);
460 }
461}
for(PetscInt i=0;i< nvars;++i)
const PropsType & props(const unsigned int state=0) const
Access methods to the stored material property data with the given state state.
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.
libMesh::IntRange< unsigned int > stateIndexRange() const
auto index_range(const T &sizable)
IntRange< T > make_range(T beg, T end)

◆ declareKokkosProperty()

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,
const bool  on_demand,
const PropertyConstantOption  constant_option,
std::shared_ptr< MaterialPropertyBase shell 
)

Declare a material property.

Parameters
prop_nameThe property name
typeThe property data type
declarerThe Kokkos material declaring the property, nullptr if simply reserving the
dimsThe vector containing the size of each dimension
bndWhether the property is a face property
on_demandWhether the property is an on-demand property
constant_optionWhether the property is constant on element or subdomain
shellThe managed pointer containing the instance of the property
Returns
The material property

◆ eraseProperty()

void MaterialPropertyStorage::eraseProperty ( const Elem *  elem)
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.

77{
78 for (const auto state : stateIndexRange())
79 setProps(state).erase(elem);
80}
MaterialProperties & setProps(const Elem *elem, unsigned int side, const unsigned int state=0)

Referenced by MaterialData::eraseProperty(), and FEProblemBase::meshChanged().

◆ getConsumers()

const std::set< const MooseObject * > & MaterialPropertyStorage::getConsumers ( Moose::MaterialDataType  type) const
inherited
Returns
The consumers of storage of type type

Definition at line 108 of file MaterialPropertyStorage.C.

109{
110 static const std::set<const MooseObject *> empty;
111
112 const auto it = _consumers.find(type);
113
114 if (it != _consumers.end())
115 return it->second;
116
117 return empty;
118}

Referenced by FEProblemBase::getMaterialPropertyStorageConsumers().

◆ getKokkosProperty()

MaterialPropertyBase & Moose::Kokkos::MaterialPropertyStorage::getKokkosProperty ( std::string  prop_name,
unsigned int  state = 0 
)

Get a material property.

Parameters
prop_nameThe property name
stateThe property state
Returns
The material property

◆ getMaterialData() [1/2]

MaterialData & MaterialPropertyStorage::getMaterialData ( const THREAD_ID  tid)
inlineinherited

Definition at line 332 of file MaterialPropertyStorage.h.

332{ return _material_data[tid]; }
std::vector< MaterialData > _material_data
The threaded material data.

◆ getMaterialData() [2/2]

const MaterialData & MaterialPropertyStorage::getMaterialData ( const THREAD_ID  tid) const
inlineinherited

◆ getMaterialPropertyRegistry()

const MaterialPropertyRegistry & MaterialPropertyStorage::getMaterialPropertyRegistry ( ) const
inlineinherited

Definition at line 285 of file MaterialPropertyStorage.h.

285{ return _registry; }

Referenced by MaterialData::getPropertyId().

◆ getPropRecord()

const MaterialPropertyStorage::PropRecord & MaterialPropertyStorage::getPropRecord ( const unsigned int  id) const
inherited

Get the property record associated with the material with id id.

Definition at line 90 of file MaterialPropertyStorage.C.

91{
92 mooseAssert(_prop_records.size() > id, "Invalid ID");
93 auto & prop_record_ptr = _prop_records[id];
94 mooseAssert(prop_record_ptr, "Not initialized");
95 return *prop_record_ptr;
96}

Referenced by MaterialData::getMaxStateRequested(), MaterialBase::initStatefulProperties(), MaterialPropertyStorage::initStatefulProps(), and MaterialPropertyStorage::isRestoredProperty().

◆ hasOlderProperties()

bool MaterialPropertyStorage::hasOlderProperties ( ) const
inlineinherited
Returns
a Boolean indicating whether or not this material has older properties declared

Definition at line 246 of file MaterialPropertyStorage.h.

246{ return maxState() > 1; }

◆ hasProperty()

bool MaterialPropertyStorage::hasProperty ( const std::string &  prop_name) const
inlineinherited

Definition at line 267 of file MaterialPropertyStorage.h.

267{ return _registry.hasProperty(prop_name); }
bool hasProperty(const std::string &name) const

Referenced by MaterialData::hasProperty().

◆ hasStatefulProperties()

bool MaterialPropertyStorage::hasStatefulProperties ( ) const
inlineinherited

◆ haveKokkosProperty()

bool Moose::Kokkos::MaterialPropertyStorage::haveKokkosProperty ( std::string  prop_name,
unsigned int  state = 0 
)

Get whether a material property exists.

Parameters
prop_nameThe property name
stateThe property state
Returns
Whether the material property exists

◆ initAndSetProps()

MaterialProperties & MaterialPropertyStorage::initAndSetProps ( const Elem *  elem,
const unsigned int  side,
const unsigned int  state 
)
inlineprivateinherited
Returns
A writeable reference to the properties for elem elem, side side, and state state.

Similar to setProps, but will initialize (default construct) the entry if it does not exist.

Definition at line 497 of file MaterialPropertyStorage.h.

500{
501 return setProps(state)[elem][side];
502}

Referenced by MaterialPropertyStorage::initProps(), and MaterialPropertyStorage::swap().

◆ initProps() [1/2]

std::vector< MaterialProperties * > MaterialPropertyStorage::initProps ( const THREAD_ID  tid,
const Elem *  elem,
unsigned int  side,
unsigned int  n_qpoints 
)
privateinherited

Initializes hashmap entries for element and side to proper qpoint and property count sizes.

Definition at line 537 of file MaterialPropertyStorage.C.

541{
542 std::vector<MaterialProperties *> props(numStates());
543 for (const auto state : stateIndexRange())
544 props[state] = &this->initProps(tid, state, elem, side, n_qpoints);
545 return props;
546}

Referenced by MaterialPropertyStorage::copy(), MaterialPropertyStorage::initProps(), MaterialPropertyStorage::initStatefulProps(), MaterialPropertyStorage::prolongStatefulProps(), MaterialPropertyStorage::restrictStatefulProps(), and MaterialPropertyStorage::updateStatefulPropsForPRefinement().

◆ initProps() [2/2]

MaterialProperties & MaterialPropertyStorage::initProps ( const THREAD_ID  tid,
const unsigned int  state,
const Elem *  elem,
unsigned int  side,
unsigned int  n_qpoints 
)
privateinherited

Initializes just one hashmap's entries.

Definition at line 549 of file MaterialPropertyStorage.C.

554{
555 auto & material_data = _material_data[tid];
556 material_data.resize(n_qpoints);
557
558 auto & mat_props = initAndSetProps(elem, side, state);
559
560 // In some special cases, material_data might be larger than n_qpoints
561 if (material_data.isOnlyResizeIfSmaller())
562 n_qpoints = material_data.nQPoints();
563
564 const auto n_props = _stateful_prop_id_to_prop_id.size();
565 if (mat_props.size() < n_props)
566 mat_props.resize(n_props, {});
567
568 // init properties (allocate memory. etc)
569 for (const auto i : index_range(_stateful_prop_id_to_prop_id))
570 if (!mat_props.hasValue(i))
571 {
572 const auto prop_id = _stateful_prop_id_to_prop_id[i];
573 mat_props.setPointer(i, material_data.props(0)[prop_id].clone(n_qpoints), {});
574 mooseAssert(mat_props[i].id() == prop_id, "Inconsistent id");
575 }
576
577 return mat_props;
578}
if(!dmm->_nl) SETERRQ(PETSC_COMM_WORLD
MaterialProperties & initAndSetProps(const Elem *elem, const unsigned int side, const unsigned int state)

◆ initStatefulProps()

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 
)
inherited

Initialize stateful material properties.

Parameters
tidThe thread ID
matsMaterials that will compute the initial values
n_qpointsNumber of quadrature points
elemElement we are on
sideSide 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.

290{
291 // Material -> stateful properties that need to be restarted for said material
292 // We need this because we need to initialize everything in dependency the dependency ordering
293 // as given in mats, which means that we can't just do these all up front
294 std::unordered_map<const MaterialBase *,
295 std::vector<std::pair<unsigned int, std::vector<std::stringstream> *>>>
296 materials_to_restart;
297 // Find the entry in the restartable data (binary data waiting to be restarted)
298 // for this [elem, side], if any
299 RestartableMapType::mapped_type * restartable_entry = nullptr;
300 if (_restartable_map.size())
301 if (auto it = _restartable_map.find(std::make_pair(&elem, side)); it != _restartable_map.end())
302 restartable_entry = &it->second;
303
304 // The stateful objects that we're going to initialize. This is needed for materials that are
305 // passed in as mat that are not stateful, who we don't want to call initStatefulProperties() on.
306 // We unfortunately can only determine this here due to block/boundary restriction, which is
307 // not known without mapping property -> material
308 std::vector<MaterialBase *> stateful_mats;
309 // The stateful IDs that we need to copy back
310 std::vector<unsigned int> stateful_ids_to_copy;
311
312#ifndef NDEBUG
313 // All of the stateful IDs; used to make sure that we're not supplying one property
314 // across multiple materials
315 std::set<unsigned int> stateful_ids;
316#endif
317
318 // Work through all of the materials that we were passed to figure out which ones are stateful
319 // that we need to initialize, and also to figure out which ones we need to restart
320 for (const auto & mat : mats)
321 {
322 // For keeping track of this material in stateful_mats
323 bool stateful = false;
324
325 // Check each material that was declared
326 for (const auto id : mat->getSuppliedPropIDs())
327 {
328 const auto & record = getPropRecord(id);
329 if (record.stateful())
330 {
331 const auto stateful_id = record.stateful_id;
332 stateful = true;
333
334#ifndef NDEBUG
335 const auto it_inserted_pair = stateful_ids.insert(stateful_id);
336 mooseAssert(it_inserted_pair.second,
337 "Material property '" + _registry.getName(id) +
338 "' supplied by multiple materials at the same point");
339#endif
340
341 bool restarting = false;
342 // We have restartable data for this [elem, side]; see if we have it for this prop
343 if (restartable_entry)
344 {
345 if (auto id_datum_pair_it = restartable_entry->find(stateful_id);
346 id_datum_pair_it != restartable_entry->end())
347 {
348 restarting = true;
349 materials_to_restart[mat.get()].emplace_back(stateful_id, &id_datum_pair_it->second);
350 }
351 }
352
353 if (!restarting)
354 stateful_ids_to_copy.push_back(record.stateful_id);
355 }
356 }
357
358 if (stateful || mat->forceStatefulInit())
359 stateful_mats.push_back(mat.get());
360 }
361
362 // This currently initializes all of the stateful properties for this [elem, side],
363 // even though we didn't necessarily need to init all of them. Future work?
364 auto props = initProps(tid, &elem, side, n_qpoints);
365
366 // Whether or not we have swapped material data from _storage to _material_data
367 // When we're initializing from initStatefulProperties, the MaterialBase objects
368 // need to be able to access the data in _material_data. When we're initalizing
369 // from restart, we need to be able to access from _storage.
370 bool swapped = false;
371
372 // Initialize properties
373 for (auto mat : stateful_mats)
374 {
375 const auto materials_to_restart_find = materials_to_restart.find(mat);
376 const bool restart = materials_to_restart_find != materials_to_restart.end();
377
378 if (!restart || mat->forceStatefulInit())
379 {
380 // Need stateful _material_data in the material to store
381 if (!swapped)
382 {
383 swap(tid, elem, side);
384 swapped = true;
385 }
386
387 mat->initStatefulProperties(n_qpoints);
388 }
389
390 if (restart)
391 {
392 // Need data in _storage
393 if (swapped)
394 {
395 swapBack(tid, elem, side);
396 swapped = false;
397 }
398
399 // Load from the cached binary backup into place
400 for (auto & [stateful_id, datum_ptr] : materials_to_restart_find->second)
401 for (const auto state : index_range(*datum_ptr))
402 {
403 (*datum_ptr)[state].seekg(0, std::ios::beg);
404 dataLoad((*datum_ptr)[state], (*props[state])[stateful_id], nullptr);
405 }
406 }
407 }
408
409 // Done with accessing from _material_data
410 if (swapped)
411 swapBack(tid, elem, side);
412
413 // Copy to older states as needed, only for non-restarted data
414 for (const auto stateful_id : stateful_ids_to_copy)
415 for (const auto state : statefulIndexRange())
416 for (const auto qp : make_range(n_qpoints))
417 (*props[state])[stateful_id].qpCopy(qp, (*props[0])[stateful_id], qp);
418}
MaterialBases compute MaterialProperties.
const std::string & getName(const unsigned int id) const
friend void dataLoad(std::istream &, MaterialPropertyStorage &, void *)
void swapBack(const THREAD_ID tid, const Elem &elem, unsigned int side)
Swap (shallow copy) material properties in MaterialPropertyStorage and MaterialDat Thread safe.
void swap(const THREAD_ID tid, const Elem &elem, unsigned int side)
Swap (shallow copy) material properties in MaterialData and MaterialPropertyStorage Thread safe.
libMesh::IntRange< unsigned int > statefulIndexRange() const
const PropRecord & getPropRecord(const unsigned int id) const
Get the property record associated with the material with id id.
RestartableMapType _restartable_map
The restartable data to be loaded in initStatefulProps() later.

Referenced by ComputeMaterialsObjectThread::onBoundary(), ComputeMaterialsObjectThread::onElement(), ComputeMaterialsObjectThread::onInterface(), and ComputeMaterialsObjectThread::onInternalSide().

◆ isRestoredProperty()

bool MaterialPropertyStorage::isRestoredProperty ( const std::string &  name) const
inherited
Returns
Whether or not the material property with name name was restored

Definition at line 99 of file MaterialPropertyStorage.C.

100{
101 const auto & record = getPropRecord(_registry.getID(name));
102 if (!record.stateful())
103 mooseAssert(!record.restored, "Stateful properties should not be restored");
104 return record.restored;
105}
unsigned int getID(const std::string &name) const

Referenced by MaterialBase::hasRestoredProperties().

◆ maxState()

unsigned int MaterialPropertyStorage::maxState ( ) const
inlineinherited
Returns
The current maximum stored state (0 = none, 1 = old, 2 = older)

Definition at line 302 of file MaterialPropertyStorage.h.

303 {
304 mooseAssert(_max_state < _storage.size(), "Too big");
305 return _max_state;
306 }
std::array< PropsType, MaterialData::max_state+1 > _storage
The actual storage.

Referenced by MaterialPropertyStorage::addProperty(), MaterialPropertyStorage::hasOlderProperties(), MaterialPropertyStorage::hasStatefulProperties(), MaterialPropertyStorage::numStates(), and MaterialPropertyStorage::shift().

◆ numStates()

unsigned int MaterialPropertyStorage::numStates ( ) const
inlineinherited
Returns
The number of stored states (2 = up to old, 3 = up to older)

Definition at line 310 of file MaterialPropertyStorage.h.

310{ return maxState() + 1; }

Referenced by MaterialPropertyStorage::initProps(), MaterialPropertyStorage::statefulIndexRange(), and MaterialPropertyStorage::stateIndexRange().

◆ prolongStatefulProps()

void MaterialPropertyStorage::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 
)
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:

  1. Volume to volume (parent_side = -1, child = -1, child_side = -1) Call on volume MaterialPropertyStorage and pass volume MaterialPropertyStorage for parent_material_props
  2. Parent side to child side (parent_side = 0+, child = -1, child_side = 0+) where parent_side == child_side Call on boundary MaterialPropertyStorage and pass boundary MaterialPropertyStorage for parent_material_props
  3. Child side to parent volume (parent_side = -1, child = 0+, child_side = 0+) Call on boundary MaterialPropertyStorage and pass volume MaterialPropertyStorage for parent_material_props
Parameters
pid- processor id of children to prolong to
refinement_map- 2D array of QpMap objects
qruleThe current quadrature rule
qrule_faceThe current face qrule
parent_material_propsThe place to pull parent material property values from
tidThe thread ID
elemThe 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.

177{
178 mooseAssert(input_child != -1 || input_parent_side == input_child_side, "Invalid inputs!");
179
180 unsigned int n_qpoints = 0;
181
182 // If we passed in -1 for these then we really need to store properties at 0
183 unsigned int parent_side = input_parent_side == -1 ? 0 : input_parent_side;
184 unsigned int child_side = input_child_side == -1 ? 0 : input_child_side;
185
186 if (input_child_side == -1) // Not doing side projection (ie, doing volume projection)
187 n_qpoints = qrule.n_points();
188 else
189 n_qpoints = qrule_face.n_points();
190
191 _material_data[tid].resize(n_qpoints);
192
193 unsigned int n_children = elem.n_children();
194
195 std::vector<unsigned int> children;
196
197 if (input_child != -1) // Passed in a child explicitly
198 children.push_back(input_child);
199 else
200 {
201 children.resize(n_children);
202 for (unsigned int child = 0; child < n_children; child++)
203 children[child] = child;
204 }
205
206 for (const auto & child : children)
207 {
208 // If we're not projecting an internal child side, but we are projecting sides, see if this
209 // child is on that side
210 if (input_child == -1 && input_child_side != -1 && !elem.is_child_on_side(child, parent_side))
211 continue;
212
213 const Elem * child_elem = elem.child_ptr(child);
214
215 // If it's not a local child then it'll be prolonged where it is
216 // local
217 if (child_elem->processor_id() != pid)
218 continue;
219
220 mooseAssert(child < refinement_map.size(), "Refinement_map vector not initialized");
221 const std::vector<QpMap> & child_map = refinement_map[child];
222
223 auto child_props = initProps(tid, child_elem, child_side, n_qpoints);
224
225 for (const auto state : stateIndexRange())
226 {
227 const auto & parent_props = parent_material_props.props(&elem, parent_side, state);
228 for (const auto i : index_range(_stateful_prop_id_to_prop_id))
229 for (const auto qp : index_range(refinement_map[child]))
230 (*child_props[state])[i].qpCopy(qp, parent_props[i], child_map[qp]._to);
231 }
232 }
233}
unsigned int n_points() const

Referenced by ProjectMaterialProperties::onBoundary(), ProjectMaterialProperties::onElement(), and ProjectMaterialProperties::onInternalSide().

◆ props() [1/2]

const MaterialProperties & MaterialPropertyStorage::props ( const Elem *  elem,
unsigned int  side,
const unsigned int  state = 0 
) const
inlineinherited

Definition at line 481 of file MaterialPropertyStorage.h.

482{
483 const auto find_elem = props(state).find(elem);
484 mooseAssert(find_elem != props(state).end(), "Material property does not have elem entry");
485 const auto find_side = find_elem->second.find(side);
486 mooseAssert(find_side != find_elem->second.end(), "Material property does not have side entry");
487 return find_side->second;
488}
iterator find(const Key &k)
Definition HashMap.h:36

◆ props() [2/2]

const MaterialPropertyStorage::PropsType & MaterialPropertyStorage::props ( const unsigned int  state = 0) const
inlineinherited

Access methods to the stored material property data with the given state state.

Definition at line 474 of file MaterialPropertyStorage.h.

475{
476 mooseAssert(state < _storage.size(), "Invalid material property state " + std::to_string(state));
477 return _storage[state];
478}

Referenced by MaterialPropertyStorage::copy(), MaterialPropertyStorage::initProps(), MaterialPropertyStorage::initStatefulProps(), MaterialPropertyStorage::prolongStatefulProps(), MaterialPropertyStorage::props(), MaterialPropertyStorage::restrictStatefulProps(), MaterialPropertyStorage::swap(), and MaterialPropertyStorage::swapBack().

◆ queryStatefulPropName()

std::optional< std::string > MaterialPropertyStorage::queryStatefulPropName ( const unsigned int  id) const
inherited
Returns
The name of the stateful property with id id, if any.

Definition at line 68 of file MaterialPropertyStorage.C.

69{
70 if (_prop_records.size() > id && _prop_records[id] && _prop_records[id]->stateful())
71 return _registry.getName(id);
72 return {};
73}

◆ registerLoadStore()

void Moose::Kokkos::MaterialPropertyStorage::registerLoadStore ( std::type_index  type,
PropertyStore  store,
PropertyLoad  load 
)

Register the load/store functions.

Parameters
typeThe property type index
storeThe function pointer to the store function
loadThe function pointer to the load function

◆ restrictStatefulProps()

void MaterialPropertyStorage::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 
)
inherited

Creates storage for newly created elements from mesh Adaptivity.

Also, copies values from the children to the parent.

Parameters
coarsening_map- map from unsigned ints to QpMap's
coarsened_element_children- a pointer to a vector of coarsened element children
qruleThe current quadrature rule
qrule_faceThe current face qrule
tidThe thread ID
elemThe parent element that was just refined
input_sideSide of the element 'elem' (0 for volumetric material properties)

Definition at line 236 of file MaterialPropertyStorage.C.

244{
245 unsigned int side;
246
247 bool doing_a_side = input_side != -1;
248
249 unsigned int n_qpoints = 0;
250
251 if (!doing_a_side)
252 {
253 side = 0; // Use 0 for the elem
254 n_qpoints = qrule.n_points();
255 }
256 else
257 {
258 side = input_side;
259 n_qpoints = qrule_face.n_points();
260 }
261
262 auto parent_props = initProps(tid, &elem, side, n_qpoints);
263
264 // Copy from the child stateful properties
265 for (const auto qp : index_range(coarsening_map))
266 {
267 const std::pair<unsigned int, QpMap> & qp_pair = coarsening_map[qp];
268 unsigned int child = qp_pair.first;
269
270 mooseAssert(child < coarsened_element_children.size(),
271 "Coarsened element children vector not initialized");
272 const Elem * child_elem = coarsened_element_children[child];
273 const QpMap & qp_map = qp_pair.second;
274
275 for (const auto state : stateIndexRange())
276 {
277 const auto & child_props = props(child_elem, side, state);
278 for (const auto i : index_range(_stateful_prop_id_to_prop_id))
279 (*parent_props[state])[i].qpCopy(qp, child_props[i], qp_map._to);
280 }
281 }
282}
Helper object for holding qp mapping info.
Definition MooseMesh.h:76

Referenced by ProjectMaterialProperties::onBoundary(), and ProjectMaterialProperties::onElement().

◆ setProps() [1/2]

MaterialProperties & MaterialPropertyStorage::setProps ( const Elem *  elem,
unsigned int  side,
const unsigned int  state = 0 
)
inlineinherited

◆ setProps() [2/2]

MaterialPropertyStorage::PropsType & MaterialPropertyStorage::setProps ( const unsigned int  state)
inlineprivateinherited
Returns
A writeable reference to the properties at state state.

Definition at line 505 of file MaterialPropertyStorage.h.

506{
507 return const_cast<MaterialPropertyStorage::PropsType &>(std::as_const(*this).props(state));
508}
HashMap is an abstraction for dictionary data type, we make it thread-safe by locking inserts.
Definition HashMap.h:19

◆ setRecovering()

void MaterialPropertyStorage::setRecovering ( )
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.

353{ _recovering = true; }
bool _recovering
Whether or not we're recovering; enforces a one-to-one mapping of stateful properties.

◆ setRestartInPlace()

void MaterialPropertyStorage::setRestartInPlace ( )
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.

84{
85 _restart_in_place = true;
86 _restartable_map.clear();
87}
bool _restart_in_place
Whether or not we want to restart stateful properties in place.

◆ shallowSwapData()

void MaterialPropertyStorage::shallowSwapData ( const std::vector< unsigned int > &  stateful_prop_ids,
MaterialProperties data,
MaterialProperties data_from 
)
staticprivateinherited

Shallow copies of material properties.

Definition at line 38 of file MaterialPropertyStorage.C.

41{
42 for (const auto i : make_range(std::min(stateful_prop_ids.size(), data_from.size())))
43 if (stateful_prop_ids[i] < data.size() && data.hasValue(stateful_prop_ids[i]) &&
44 data_from.hasValue(i))
45 {
46 auto & prop = data[stateful_prop_ids[i]];
47 auto & prop_from = data_from[i];
48 prop.swap(prop_from);
49 }
50}
auto min(const L &left, const R &right)

Referenced by MaterialPropertyStorage::swap().

◆ shallowSwapDataBack()

void MaterialPropertyStorage::shallowSwapDataBack ( const std::vector< unsigned int > &  stateful_prop_ids,
MaterialProperties data,
MaterialProperties data_from 
)
staticprivateinherited

Definition at line 53 of file MaterialPropertyStorage.C.

56{
57 for (const auto i : make_range(std::min(stateful_prop_ids.size(), data.size())))
58 if (stateful_prop_ids[i] < data_from.size() && data.hasValue(i) &&
59 data_from.hasValue(stateful_prop_ids[i]))
60 {
61 auto & prop = data[i];
62 auto & prop_from = data_from[stateful_prop_ids[i]];
63 prop.swap(prop_from);
64 }
65}

Referenced by MaterialPropertyStorage::swapBack().

◆ shift()

void Moose::Kokkos::MaterialPropertyStorage::shift ( )

Shift current, old, and older material property data storages.

Referenced by FEProblemBase::advanceState().

◆ sizeProps()

void MaterialPropertyStorage::sizeProps ( MaterialProperties mp,
unsigned int  size 
)
protectedinherited

◆ statefulIndexRange()

libMesh::IntRange< unsigned int > MaterialPropertyStorage::statefulIndexRange ( ) const
inlineinherited
Returns
A range over stateful states to be used in range-based for loops

Will be an empty range if there are no stateful states

Definition at line 323 of file MaterialPropertyStorage.h.

Referenced by MaterialPropertyStorage::initStatefulProps().

◆ statefulProps()

const std::vector< unsigned int > & MaterialPropertyStorage::statefulProps ( ) const
inlineinherited

Definition at line 283 of file MaterialPropertyStorage.h.

◆ stateIndexRange()

libMesh::IntRange< unsigned int > MaterialPropertyStorage::stateIndexRange ( ) const
inlineinherited

◆ swap()

void MaterialPropertyStorage::swap ( const THREAD_ID  tid,
const Elem &  elem,
unsigned int  side 
)
inherited

Swap (shallow copy) material properties in MaterialData and MaterialPropertyStorage Thread safe.

Parameters
tidThe thread id
elemElement id
sideSide number (elemental material properties have this equal to zero)

Definition at line 464 of file MaterialPropertyStorage.C.

465{
466 Threads::spin_mutex::scoped_lock lock(this->_spin_mtx);
467
468 for (const auto state : stateIndexRange())
470 _material_data[tid].props(state),
471 // Would be nice to make this setProps()
472 initAndSetProps(&elem, side, state));
473}
libMesh::Threads::spin_mutex & _spin_mtx
static void shallowSwapData(const std::vector< unsigned int > &stateful_prop_ids, MaterialProperties &data, MaterialProperties &data_from)
Shallow copies of material properties.

Referenced by MaterialPropertyStorage::initStatefulProps(), and MaterialData::swap().

◆ swapBack()

void MaterialPropertyStorage::swapBack ( const THREAD_ID  tid,
const Elem &  elem,
unsigned int  side 
)
inherited

Swap (shallow copy) material properties in MaterialPropertyStorage and MaterialDat Thread safe.

Parameters
tidThe thread id
elemElement id
sideSide number (elemental material properties have this equal to zero)

Definition at line 476 of file MaterialPropertyStorage.C.

477{
478 Threads::spin_mutex::scoped_lock lock(this->_spin_mtx);
479
480 for (const auto state : stateIndexRange())
482 setProps(&elem, side, state),
483 _material_data[tid].props(state));
484
485 // Workaround for MOOSE difficulties in keeping materialless
486 // elements (e.g. Lower D elements in Mortar code) materials
487 for (const auto state : stateIndexRange())
488 if (props(&elem, side, state).empty())
489 setProps(state)[&elem].erase(side);
490}
static void shallowSwapDataBack(const std::vector< unsigned int > &stateful_prop_ids, MaterialProperties &data, MaterialProperties &data_from)

Referenced by MaterialPropertyStorage::initStatefulProps(), and MaterialData::swapBack().

◆ updateStatefulPropsForPRefinement()

void MaterialPropertyStorage::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 
)
inherited

Based on the p-refinement flag of elem, either prolong (for refinement) or restrict (for coarsening) the stateful material property data.

Parameters
pidThe rank returned by the mesh. This is used to assert that we are only prolonging/restricting for elements that our process owns
p_refinement_mapA map that describes, for each quadrature point on the current level which quadrature point on the previous level it is closest to
qruleThe volumetric quadrature rule
qrule_faceThe face quadrature rule
tidThe thread ID
elemThe element that was just p-refined or coarsened that we are performing material property prolongation/restriction for
input_sideWhich 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.

129{
130 unsigned int n_qpoints = 0;
131
132 // If we passed in -1 for these then we really need to store properties at 0
133 unsigned int side = input_side == -1 ? 0 : input_side;
134
135 if (input_side == -1) // Not doing side projection (ie, doing volume projection)
136 n_qpoints = qrule.n_points();
137 else
138 n_qpoints = qrule_face.n_points();
139
140 _material_data[tid].resize(n_qpoints);
141
142 mooseAssert(elem.active(), "We should be doing p-refinement on active elements only");
143 mooseAssert(elem.processor_id() == pid, "Prolongation should be occurring locally");
144 mooseAssert(p_refinement_map.size() == n_qpoints, "Refinement map not proper size");
145
146 auto current_p_level_props = initProps(tid, &elem, side, n_qpoints);
147
148 for (const auto state : stateIndexRange())
150 {
151 auto & current_p_level_prop = (*current_p_level_props[state])[i];
152 // We need to clone this property in order to not overwrite the values we're going to be
153 // reading from
154 auto previous_p_level_prop = current_p_level_prop.clone(current_p_level_prop.size());
155 // Cloning, despite its name, does not copy the data. Luckily since we are about to overwrite
156 // all of the current_p_level_prop data, we can just swap its data over to our
157 // previous_p_level_prop
158 previous_p_level_prop->swap(current_p_level_prop);
159 current_p_level_prop.resize(n_qpoints);
160 for (const auto qp : index_range(p_refinement_map))
161 current_p_level_prop.qpCopy(qp, *previous_p_level_prop, p_refinement_map[qp]._to);
162 }
163}

Referenced by ProjectMaterialProperties::onBoundary(), and ProjectMaterialProperties::onElement().

◆ void::dataLoad()

Moose::Kokkos::MaterialPropertyStorage::void::dataLoad ( std::istream &  ,
MaterialPropertyStorage ,
void *   
)
private

◆ void::dataStore()

Moose::Kokkos::MaterialPropertyStorage::void::dataStore ( std::ostream &  ,
MaterialPropertyStorage ,
void *   
)
private

Member Data Documentation

◆ _consumers

std::map<Moose::MaterialDataType, std::set<const MooseObject *> > MaterialPropertyStorage::_consumers
protectedinherited

The consumers of this storage.

Definition at line 391 of file MaterialPropertyStorage.h.

Referenced by MaterialPropertyStorage::addConsumer(), and MaterialPropertyStorage::getConsumers().

◆ _kokkos_prop_records

std::unordered_map<std::string, Moose::Kokkos::PropRecord> Moose::Kokkos::MaterialPropertyStorage::_kokkos_prop_records
private

Record of each material property.

Definition at line 143 of file KokkosMaterialPropertyStorage.h.

◆ _kokkos_props

std::unordered_map<std::string, std::shared_ptr<MaterialPropertyBase> > Moose::Kokkos::MaterialPropertyStorage::_kokkos_props[MaterialData::max_state+1]
private

Material properties.

Definition at line 139 of file KokkosMaterialPropertyStorage.h.

◆ _load_functions

std::unordered_map<std::type_index, PropertyLoad> Moose::Kokkos::MaterialPropertyStorage::_load_functions
staticprivate

Definition at line 149 of file KokkosMaterialPropertyStorage.h.

◆ _material_data

std::vector<MaterialData> MaterialPropertyStorage::_material_data
privateinherited

◆ _max_state

unsigned int MaterialPropertyStorage::_max_state
privateinherited

The maximum state (0 = current, 1 = old, 2 = older)

Definition at line 437 of file MaterialPropertyStorage.h.

Referenced by MaterialPropertyStorage::addProperty(), and MaterialPropertyStorage::maxState().

◆ _problem

FEProblemBase& MaterialPropertyStorage::_problem
protectedinherited

Reference to the problem.

Definition at line 379 of file MaterialPropertyStorage.h.

◆ _prop_records

std::vector<std::optional<PropRecord> > MaterialPropertyStorage::_prop_records
protectedinherited

Property records indexed by property id (may be null)

Definition at line 385 of file MaterialPropertyStorage.h.

Referenced by MaterialPropertyStorage::addProperty(), MaterialPropertyStorage::getPropRecord(), and MaterialPropertyStorage::queryStatefulPropName().

◆ _recovering

bool MaterialPropertyStorage::_recovering
privateinherited

Whether or not we're recovering; enforces a one-to-one mapping of stateful properties.

Definition at line 460 of file MaterialPropertyStorage.h.

Referenced by MaterialPropertyStorage::setRecovering().

◆ _registry

MaterialPropertyRegistry& MaterialPropertyStorage::_registry
privateinherited

◆ _restart_in_place

bool MaterialPropertyStorage::_restart_in_place
privateinherited

Whether or not we want to restart stateful properties in place.

Definition at line 458 of file MaterialPropertyStorage.h.

Referenced by MaterialPropertyStorage::setRestartInPlace().

◆ _restartable_map

RestartableMapType MaterialPropertyStorage::_restartable_map
privateinherited

The restartable data to be loaded in initStatefulProps() later.

Definition at line 455 of file MaterialPropertyStorage.h.

Referenced by MaterialPropertyStorage::initStatefulProps(), and MaterialPropertyStorage::setRestartInPlace().

◆ _spin_mtx

libMesh::Threads::spin_mutex& MaterialPropertyStorage::_spin_mtx
privateinherited

◆ _stateful_prop_id_to_prop_id

std::vector<unsigned int> MaterialPropertyStorage::_stateful_prop_id_to_prop_id
protectedinherited

◆ _storage

std::array<PropsType, MaterialData::max_state + 1> MaterialPropertyStorage::_storage
protectedinherited

The actual storage.

Definition at line 382 of file MaterialPropertyStorage.h.

Referenced by MaterialPropertyStorage::maxState(), and MaterialPropertyStorage::props().

◆ _store_functions

std::unordered_map<std::type_index, PropertyStore> Moose::Kokkos::MaterialPropertyStorage::_store_functions
staticprivate

Function pointer maps for load/store.

Definition at line 148 of file KokkosMaterialPropertyStorage.h.


The documentation for this class was generated from the following file: