https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Classes | Public Member Functions | Static Public Attributes | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
MaterialData Class Reference

Proxy for accessing MaterialPropertyStorage. More...

#include <MaterialData.h>

Classes

class  XFEMKey
 Key that provides access to only the XFEM class. More...
 

Public Member Functions

 MaterialData (MaterialPropertyStorage &storage, const THREAD_ID tid)
 
void resize (unsigned int n_qpoints)
 Resize the data to hold properties for n_qpoints quadrature points.
 
unsigned int nQPoints () const
 Returns the number of quadrature points the material properties support/hold.
 
void copy (const Elem &elem_to, const Elem &elem_from, unsigned int side)
 copy material properties from one element to another
 
void swap (const Elem &elem, unsigned int side=0)
 material properties for given element (and possible side)
 
template<typename MatContainer >
void reinit (const MatContainer &mats)
 Reinit material properties for given element (and possible side)
 
void reset (const std::vector< std::shared_ptr< MaterialBase > > &mats)
 Calls the reset method of Materials to ensure that they are in a proper state.
 
void swapBack (const Elem &elem, unsigned int side=0)
 material properties for given element (and possible side)
 
const MaterialPropertiesprops (const unsigned int state=0) const
 {
 
MaterialPropertiesprops (const unsigned int state=0)
 
template<typename T , bool is_ad>
bool haveGenericProperty (const std::string &prop_name) const
 
template<typename T >
bool haveProperty (const std::string &prop_name) const
 Returns true if the regular material property exists - defined by any material.
 
template<typename T >
bool haveADProperty (const std::string &prop_name) const
 Returns true if the AD material property exists - defined by any material.
 
template<typename T , unsigned int dimension>
bool haveKokkosProperty (const std::string &prop_name) const
 Get whether a Kokkos material property exists.
 
template<typename T , bool is_ad = false>
GenericMaterialProperty< T, is_ad > & getProperty (const std::string &prop_name, const unsigned int state, const MooseObject &requestor)
 Retrieves a material property.
 
template<typename T , bool is_ad>
GenericMaterialProperty< T, is_ad > & declareProperty (const std::string &prop_name, const MooseObject &requestor)
 Declares a material property.
 
template<typename T , unsigned int dimension, unsigned int state>
Moose::Kokkos::MaterialProperty< T, dimension > getKokkosProperty (const std::string &prop_name)
 Get a Kokkos material property.
 
template<typename T , unsigned int dimension>
Moose::Kokkos::MaterialProperty< T, dimension > declareKokkosProperty (const std::string &prop_name, const std::vector< unsigned int > &dims, const MaterialBase *declarer, const bool bnd, const bool on_demand, const Moose::Kokkos::PropertyConstantOption constant_option)
 Declare a Kokkos material property.
 
bool isSwapped () const
 Returns true if the stateful material is in a swapped state.
 
const MaterialPropertyStoragegetMaterialPropertyStorage () const
 Provide read-only access to the underlying MaterialPropertyStorage object.
 
MaterialPropertyStoragegetMaterialPropertyStorageForXFEM (const XFEMKey)
 Provide write-only access to the underlying MaterialPropertyStorage object JUST FOR XFEM.
 
bool hasProperty (const std::string &prop_name) const
 
unsigned int getPropertyId (const std::string &prop_name) const
 Wrapper for MaterialStorage::getPropertyId.
 
void onlyResizeIfSmaller (bool flag)
 Set _resize_only_if_smaller to perform a non-destructive resize.
 
bool isOnlyResizeIfSmaller () const
 Check value of _resize_only_if_smaller.
 
void eraseProperty (const Elem *elem)
 Remove the property storage and element pointer from MaterialPropertyStorage data structures Use this when elements are deleted so we don't end up with invalid elem pointers (for e.g.
 

Static Public Attributes

static constexpr unsigned int max_state = 2
 The max time state supported (2 = older)
 

Private Member Functions

unsigned int addPropertyHelper (const std::string &prop_name, const std::type_info &type, const unsigned int state, const MaterialBase *const declarer)
 
template<typename T , bool is_ad, bool declare>
GenericMaterialProperty< T, is_ad > & getPropertyHelper (const std::string &prop_name, const unsigned int state, const MooseObject &requestor)
 
Moose::Kokkos::MaterialPropertyBaseaddKokkosPropertyHelper (const std::string &prop_name, const std::type_info &type, const unsigned int state, std::shared_ptr< Moose::Kokkos::MaterialPropertyBase > shell)
 Helper function for adding a Kokkos material property.
 
Moose::Kokkos::MaterialPropertyBasedeclareKokkosPropertyHelper (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 Moose::Kokkos::PropertyConstantOption constant_option, std::shared_ptr< Moose::Kokkos::MaterialPropertyBase > shell)
 Helper function for declaring a Kokkos material property.
 
Moose::Kokkos::MaterialPropertyBasegetKokkosPropertyHelper (const std::string &prop_name, const unsigned int state=0, std::shared_ptr< Moose::Kokkos::MaterialPropertyBase > shell=nullptr) const
 Helper function for getting a Kokkos material property.
 
bool haveKokkosPropertyHelper (const std::string &prop_name) const
 Helper function for checking whether a Kokkos material property exists.
 
void kokkosRegisterLoadStoreHelper (std::type_index type, Moose::Kokkos::PropertyStore store, Moose::Kokkos::PropertyLoad load)
 Helper function to register load/store functions of a Kokkos material property to the Kokkos material property storage.
 
const MaterialBasecastRequestorToDeclarer (const MooseObject &requestor) const
 Helper for casting requestor to a MaterialBase in addPropertyHelper() (templated)
 
unsigned int getMaxStateRequested (const unsigned int prop_id) const
 maximum state id requested for a property
 

Static Private Member Functions

static void mooseErrorHelper (const MooseObject &object, const std::string_view &error)
 

Private Attributes

MaterialPropertyStorage_storage
 Reference to the MaterialStorage class.
 
const THREAD_ID _tid
 The thread id.
 
unsigned int _n_qpoints
 Number of quadrature points.
 
std::array< MaterialProperties, max_state+1 > _props
 The underlying property data.
 
bool _swapped
 Status of storage swapping (calling swap sets this to true; swapBack sets it to false)
 
bool _resize_only_if_smaller
 Use non-destructive resize of material data (calling resize() will not reduce size).
 

Detailed Description

Proxy for accessing MaterialPropertyStorage.

MaterialData stores the values associated with a particular material object

Definition at line 37 of file MaterialData.h.

Constructor & Destructor Documentation

◆ MaterialData()

MaterialData::MaterialData ( MaterialPropertyStorage storage,
const THREAD_ID  tid 
)

Definition at line 15 of file MaterialData.C.

16 : _storage(storage), _tid(tid), _n_qpoints(0), _swapped(false), _resize_only_if_smaller(false)
17{
18}
bool _resize_only_if_smaller
Use non-destructive resize of material data (calling resize() will not reduce size).
const THREAD_ID _tid
The thread id.
unsigned int _n_qpoints
Number of quadrature points.
MaterialPropertyStorage & _storage
Reference to the MaterialStorage class.
bool _swapped
Status of storage swapping (calling swap sets this to true; swapBack sets it to false)

Member Function Documentation

◆ addKokkosPropertyHelper()

Moose::Kokkos::MaterialPropertyBase & MaterialData::addKokkosPropertyHelper ( const std::string &  prop_name,
const std::type_info &  type,
const unsigned int  state,
std::shared_ptr< Moose::Kokkos::MaterialPropertyBase shell 
)
private

Helper function for adding a Kokkos material property.

Parameters
prop_nameThe property name
typeThe property data type
stateThe property state
shellThe managed pointer containing the instance of the property
Returns
The Kokkos material property

Referenced by getKokkosProperty().

◆ addPropertyHelper()

unsigned int MaterialData::addPropertyHelper ( const std::string &  prop_name,
const std::type_info &  type,
const unsigned int  state,
const MaterialBase *const  declarer 
)
private

Definition at line 92 of file MaterialData.C.

96{
97 return _storage.addProperty(prop_name, type, state, declarer);
98}
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,...

Referenced by getPropertyHelper().

◆ castRequestorToDeclarer()

const MaterialBase & MaterialData::castRequestorToDeclarer ( const MooseObject requestor) const
private

Helper for casting requestor to a MaterialBase in addPropertyHelper() (templated)

Definition at line 101 of file MaterialData.C.

102{
103 const auto declarer = dynamic_cast<const MaterialBase *>(&requestor);
104 mooseAssert(declarer, "Not a MaterialBase");
105 return *declarer;
106}
MaterialBases compute MaterialProperties.

Referenced by getPropertyHelper().

◆ copy()

void MaterialData::copy ( const Elem &  elem_to,
const Elem &  elem_from,
unsigned int  side 
)

copy material properties from one element to another

Definition at line 35 of file MaterialData.C.

36{
37 _storage.copy(_tid, &elem_to, &elem_from, side, nQPoints());
38}
unsigned int nQPoints() const
Returns the number of quadrature points the material properties support/hold.
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.

◆ declareKokkosProperty()

template<typename T , unsigned int dimension>
Moose::Kokkos::MaterialProperty< T, dimension > MaterialData::declareKokkosProperty ( const std::string &  prop_name,
const std::vector< unsigned int > &  dims,
const MaterialBase declarer,
const bool  bnd,
const bool  on_demand,
const Moose::Kokkos::PropertyConstantOption  constant_option 
)

Declare a Kokkos material property.

Template Parameters
TThe property data type
dimensionThe property dimension
Parameters
prop_nameThe property name
dimsThe vector containing the size of each dimension
declarerThe Kokkos material declaring the property
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
Returns
The Kokkos material property

Definition at line 503 of file MaterialData.h.

509{
510 auto shell = std::make_shared<Moose::Kokkos::MaterialProperty<T, dimension>>();
511
512 auto & prop_base = declareKokkosPropertyHelper(
513 prop_name, typeid(T), declarer, dims, bnd, on_demand, constant_option, shell);
514 auto prop_cast = dynamic_cast<Moose::Kokkos::MaterialProperty<T, dimension> *>(&prop_base);
515
516 if (!prop_cast)
517 mooseError("The declared ",
518 dimension,
519 "D Kokkos material property '",
520 prop_name,
521 "' of type '",
522 MooseUtils::prettyCppType<T>(),
523 "' was already declared or requested as a ",
524 prop_base.dim(),
525 "D property of type '",
526 prop_base.type(),
527 "'.");
528
529 return *prop_cast;
530}
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
Moose::Kokkos::MaterialPropertyBase & declareKokkosPropertyHelper(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 Moose::Kokkos::PropertyConstantOption constant_option, std::shared_ptr< Moose::Kokkos::MaterialPropertyBase > shell)
Helper function for declaring a Kokkos material property.
The Kokkos material property class.

Referenced by Moose::Kokkos::MaterialBase::declareKokkosPropertyInternal().

◆ declareKokkosPropertyHelper()

Moose::Kokkos::MaterialPropertyBase & MaterialData::declareKokkosPropertyHelper ( 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 Moose::Kokkos::PropertyConstantOption  constant_option,
std::shared_ptr< Moose::Kokkos::MaterialPropertyBase shell 
)
private

Helper function for declaring a Kokkos material property.

Parameters
prop_nameThe property name
typeThe property data type
declarerThe Kokkos material declaring the property
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 Kokkos material property

Referenced by declareKokkosProperty().

◆ declareProperty()

template<typename T , bool is_ad>
GenericMaterialProperty< T, is_ad > & MaterialData::declareProperty ( const std::string &  prop_name,
const MooseObject requestor 
)
inline

Declares a material property.

Template Parameters
TThe type of the property
is_adWhether or not the property is AD
Parameters
prop_nameThe name of the property
requestorThe MooseObject declaring the property
Returns
The property for the supplied type and name

Definition at line 142 of file MaterialData.h.

144 {
145 return getPropertyHelper<T, is_ad, true>(prop_name, 0, requestor);
146 }

Referenced by MaterialBase::declareGenericPropertyByName().

◆ eraseProperty()

void MaterialData::eraseProperty ( const Elem *  elem)

Remove the property storage and element pointer from MaterialPropertyStorage 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 86 of file MaterialData.C.

87{
89}
void eraseProperty(const Elem *elem)
Remove the property storage and element pointer from internal data structures Use this when elements ...

◆ getKokkosProperty()

template<typename T , unsigned int dimension, unsigned int state>
Moose::Kokkos::MaterialProperty< T, dimension > MaterialData::getKokkosProperty ( const std::string &  prop_name)

Get a Kokkos material property.

Template Parameters
TThe property data type
dimensionThe property dimension
stateThe property state
Parameters
prop_nameThe property name
Returns
The Kokkos material property

Definition at line 463 of file MaterialData.h.

464{
465 // Reserve the storages for the property up to the requested state
466 // If the storages were already reserved, it will do nothing
467 for (unsigned int s = 0; s <= state; ++s)
468 {
469 auto shell = std::make_shared<Moose::Kokkos::MaterialProperty<T, dimension>>();
470
471 addKokkosPropertyHelper(prop_name, typeid(T), state, shell);
472
473 // Only instantiate load and store functions for stateful properties to avoid requiring users
474 // to provide custom dataLoad and dataStore for non-trivially-copyable types that are never
475 // used as stateful properties
476 if constexpr (state > 0)
477 kokkosRegisterLoadStoreHelper(shell->propertyType(),
478 Moose::Kokkos::propertyStore<T, dimension>,
479 Moose::Kokkos::propertyLoad<T, dimension>);
480 }
481
482 auto & prop_base = getKokkosPropertyHelper(prop_name, state, nullptr);
483 auto prop_cast = dynamic_cast<Moose::Kokkos::MaterialProperty<T, dimension> *>(&prop_base);
484
485 if (!prop_cast)
486 mooseError("The requested ",
487 dimension,
488 "D Kokkos material property '",
489 prop_name,
490 "' of type '",
491 MooseUtils::prettyCppType<T>(),
492 "' was already declared or requested as a ",
493 prop_base.dim(),
494 "D property of type '",
495 prop_base.type(),
496 "'.");
497
498 return *prop_cast;
499}
Moose::Kokkos::MaterialPropertyBase & getKokkosPropertyHelper(const std::string &prop_name, const unsigned int state=0, std::shared_ptr< Moose::Kokkos::MaterialPropertyBase > shell=nullptr) const
Helper function for getting a Kokkos material property.
void kokkosRegisterLoadStoreHelper(std::type_index type, Moose::Kokkos::PropertyStore store, Moose::Kokkos::PropertyLoad load)
Helper function to register load/store functions of a Kokkos material property to the Kokkos material...
Moose::Kokkos::MaterialPropertyBase & addKokkosPropertyHelper(const std::string &prop_name, const std::type_info &type, const unsigned int state, std::shared_ptr< Moose::Kokkos::MaterialPropertyBase > shell)
Helper function for adding a Kokkos material property.

Referenced by MaterialPropertyInterface::getKokkosBlockMaterialProperty(), and MaterialPropertyInterface::getKokkosMaterialPropertyByName().

◆ getKokkosPropertyHelper()

Moose::Kokkos::MaterialPropertyBase & MaterialData::getKokkosPropertyHelper ( const std::string &  prop_name,
const unsigned int  state = 0,
std::shared_ptr< Moose::Kokkos::MaterialPropertyBase shell = nullptr 
) const
private

Helper function for getting a Kokkos material property.

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

Referenced by getKokkosProperty(), and haveKokkosProperty().

◆ getMaterialPropertyStorage()

const MaterialPropertyStorage & MaterialData::getMaterialPropertyStorage ( ) const
inline

Provide read-only access to the underlying MaterialPropertyStorage object.

Definition at line 190 of file MaterialData.h.

190{ return _storage; }

Referenced by MaterialBase::hasRestoredProperties(), and MaterialBase::initStatefulProperties().

◆ getMaterialPropertyStorageForXFEM()

MaterialPropertyStorage & MaterialData::getMaterialPropertyStorageForXFEM ( const XFEMKey  )
inline

Provide write-only access to the underlying MaterialPropertyStorage object JUST FOR XFEM.

This should be removed. To be clear - you should not ever expect to have write access to this data. It just turned out that XFEM got away with it when we were storing things as pointers instead of smart pointers...

These dirty reasons are why this method is named so egregiously.

Definition at line 211 of file MaterialData.h.

211{ return _storage; }

◆ getMaxStateRequested()

unsigned int MaterialData::getMaxStateRequested ( const unsigned int  prop_id) const
private

maximum state id requested for a property

Definition at line 109 of file MaterialData.C.

110{
111 return _storage.getPropRecord(prop_id).state;
112}
const PropRecord & getPropRecord(const unsigned int id) const
Get the property record associated with the material with id id.
unsigned int state
The max state requrested for this property (0 = current, 1 = old, ...)

Referenced by getPropertyHelper().

◆ getProperty()

template<typename T , bool is_ad = false>
GenericMaterialProperty< T, is_ad > & MaterialData::getProperty ( const std::string &  prop_name,
const unsigned int  state,
const MooseObject requestor 
)
inline

Retrieves a material property.

Template Parameters
TThe type of the property
is_adWhether or not the property is AD
Parameters
prop_nameThe name of the property
stateThe time state (0 = current, 1 = old, etc; defaults to 0)
requestorThe MooseObject requesting the property
Returns
The property for the supplied type and name

Definition at line 127 of file MaterialData.h.

130 {
131 return getPropertyHelper<T, is_ad, false>(prop_name, state, requestor);
132 }

Referenced by MaterialPropertyInterface::getBlockMaterialProperty(), MaterialPropertyInterface::getGenericMaterialPropertyByName(), and MaterialBase::getGenericZeroMaterialPropertyByName().

◆ getPropertyHelper()

template<typename T , bool is_ad, bool declare>
GenericMaterialProperty< T, is_ad > & MaterialData::getPropertyHelper ( const std::string &  prop_name,
const unsigned int  state,
const MooseObject requestor 
)
private

Definition at line 386 of file MaterialData.h.

389{
390 if constexpr (is_ad)
391 mooseAssert(state == 0, "Cannot request/declare AD properties for states other than zero");
392 if constexpr (declare)
393 mooseAssert(state == 0, "Cannot declare properties for states other than zero");
394
395 // Register/get the ID of the property
396 const auto prop_id = addPropertyHelper(
397 prop_name, typeid(T), state, declare ? &castRequestorToDeclarer(requestor) : nullptr);
398 const auto size = prop_id + 1;
399
400 // Initialize the states that we need
401 for (const auto state_i : make_range(getMaxStateRequested(prop_id) + 1))
402 {
403 auto & entry = props(state_i);
404 if (entry.size() < size)
405 entry.resize(size, {});
406 // if we are not declaring the property we initialize only what we need (the requested state)
407 if (!entry.hasValue(prop_id) && (declare || state_i == state))
408 {
409 if (state_i == 0)
410 entry.setPointer(
411 prop_id, std::move(std::make_unique<GenericMaterialProperty<T, is_ad>>(prop_id)), {});
412 else
413 entry.setPointer(prop_id, std::move(std::make_unique<MaterialProperty<T>>(prop_id)), {});
414 }
415 }
416
417 // Should be available now
418 auto & base_prop = props(state)[prop_id];
419
420 // In the event that this property was already declared/requested, make sure
421 // that the types are consistent
422 auto prop = dynamic_cast<GenericMaterialProperty<T, is_ad> *>(&base_prop);
423 if (!prop)
424 {
425 constexpr std::string_view action = declare ? "declared" : "requested";
426 constexpr auto is_ad_to_str = [](const bool is_ad_bool)
427 { return std::string_view(is_ad_bool ? "AD" : "non-AD"); };
428 constexpr std::string_view ad_type = is_ad_to_str(is_ad);
429
430 std::stringstream error;
431 error << "The " << action << " " << ad_type << " "
432 << "material property '" + prop_name + "' of type '" << MooseUtils::prettyCppType<T>()
433 << "'\nis already retrieved or declared as a " << is_ad_to_str(base_prop.isAD())
434 << " property of type '" << base_prop.type() << "'.";
435 mooseErrorHelper(requestor, error.str());
436 }
437
438 return *prop;
439}
typename GenericMaterialPropertyStruct< T, is_ad >::type GenericMaterialProperty
static void mooseErrorHelper(const MooseObject &object, const std::string_view &error)
unsigned int getMaxStateRequested(const unsigned int prop_id) const
maximum state id requested for a property
const MaterialBase & castRequestorToDeclarer(const MooseObject &requestor) const
Helper for casting requestor to a MaterialBase in addPropertyHelper() (templated)
unsigned int addPropertyHelper(const std::string &prop_name, const std::type_info &type, const unsigned int state, const MaterialBase *const declarer)
const MaterialProperties & props(const unsigned int state=0) const
{
IntRange< T > make_range(T beg, T end)

◆ getPropertyId()

unsigned int MaterialData::getPropertyId ( const std::string &  prop_name) const

Wrapper for MaterialStorage::getPropertyId.

Allows classes with a MaterialData object (i.e. MaterialPropertyInterface) to access material property IDs.

Parameters
prop_nameThe name of the material property
Returns
An unsigned int corresponding to the property ID of the passed in prop_name

Definition at line 80 of file MaterialData.C.

81{
82 return _storage.getMaterialPropertyRegistry().getID(prop_name);
83}
unsigned int getID(const std::string &name) const
const MaterialPropertyRegistry & getMaterialPropertyRegistry() const

Referenced by MaterialPropertyInterface::getBlockMaterialProperty(), MaterialPropertyInterface::getGenericMaterialPropertyByName(), MaterialPropertyInterface::getKokkosBlockMaterialProperty(), MaterialPropertyInterface::getKokkosMaterialPropertyByName(), haveGenericProperty(), and MaterialBase::registerPropName().

◆ hasProperty()

bool MaterialData::hasProperty ( const std::string &  prop_name) const
Returns
Whether or not a property exists with the name name

Definition at line 74 of file MaterialData.C.

75{
76 return _storage.hasProperty(prop_name);
77}
bool hasProperty(const std::string &prop_name) const

Referenced by haveGenericProperty().

◆ haveADProperty()

template<typename T >
bool MaterialData::haveADProperty ( const std::string &  prop_name) const
inline

Returns true if the AD material property exists - defined by any material.

Definition at line 100 of file MaterialData.h.

101 {
102 return haveGenericProperty<T, true>(prop_name);
103 }

Referenced by MaterialPropertyInterface::hasADMaterialPropertyByName(), and MaterialOutputAction::hasADProperty().

◆ haveGenericProperty()

template<typename T , bool is_ad>
bool MaterialData::haveGenericProperty ( const std::string &  prop_name) const
inline

Definition at line 370 of file MaterialData.h.

371{
372 if (!hasProperty(prop_name))
373 return false;
374
375 const auto prop_id = getPropertyId(prop_name);
376 // the property id exists, but the property was not created in this instance of the material type
377 if (prop_id >= props(0).size())
378 return false;
379
380 const PropertyValue * const base_prop = props(0).queryValue(prop_id);
381 return dynamic_cast<const GenericMaterialProperty<T, is_ad> *>(base_prop) != nullptr;
382}
bool hasProperty(const std::string &prop_name) const
unsigned int getPropertyId(const std::string &prop_name) const
Wrapper for MaterialStorage::getPropertyId.
Abstract definition of a property value.
const T * queryValue(const std::size_t i) const

Referenced by BlockRestrictable::hasBlockMaterialProperty(), and BoundaryRestrictable::hasBoundaryMaterialProperty().

◆ haveKokkosProperty()

template<typename T , unsigned int dimension>
bool MaterialData::haveKokkosProperty ( const std::string &  prop_name) const

Get whether a Kokkos material property exists.

Template Parameters
TThe property data type
dimensionThe property dimension
Parameters
prop_nameThe property name
Returns
Whether the Kokkos material property exists

Definition at line 452 of file MaterialData.h.

453{
454 if (!haveKokkosPropertyHelper(prop_name))
455 return false;
456
457 auto & prop = getKokkosPropertyHelper(prop_name);
458 return dynamic_cast<Moose::Kokkos::MaterialProperty<T, dimension> *>(&prop) != nullptr;
459}
bool haveKokkosPropertyHelper(const std::string &prop_name) const
Helper function for checking whether a Kokkos material property exists.

Referenced by MaterialPropertyInterface::hasKokkosMaterialPropertyByName().

◆ haveKokkosPropertyHelper()

bool MaterialData::haveKokkosPropertyHelper ( const std::string &  prop_name) const
private

Helper function for checking whether a Kokkos material property exists.

Parameters
prop_nameThe property name
Returns
Whether the Kokkos material property exists

Referenced by haveKokkosProperty().

◆ haveProperty()

template<typename T >
bool MaterialData::haveProperty ( const std::string &  prop_name) const
inline

Returns true if the regular material property exists - defined by any material.

Definition at line 93 of file MaterialData.h.

94 {
95 return haveGenericProperty<T, false>(prop_name);
96 }

Referenced by MaterialPropertyInterface::hasMaterialPropertyByName(), and MaterialOutputAction::hasProperty().

◆ isOnlyResizeIfSmaller()

bool MaterialData::isOnlyResizeIfSmaller ( ) const
inline

Check value of _resize_only_if_smaller.

Definition at line 237 of file MaterialData.h.

237{ return _resize_only_if_smaller; };

◆ isSwapped()

bool MaterialData::isSwapped ( ) const
inline

Returns true if the stateful material is in a swapped state.

Definition at line 185 of file MaterialData.h.

185{ return _swapped; }

Referenced by swap(), and swapBack().

◆ kokkosRegisterLoadStoreHelper()

void MaterialData::kokkosRegisterLoadStoreHelper ( std::type_index  type,
Moose::Kokkos::PropertyStore  store,
Moose::Kokkos::PropertyLoad  load 
)
private

Helper function to register load/store functions of a Kokkos material property to the Kokkos material property storage.

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

Referenced by getKokkosProperty().

◆ mooseErrorHelper()

void MaterialData::mooseErrorHelper ( const MooseObject object,
const std::string_view &  error 
)
staticprivate

Definition at line 68 of file MaterialData.C.

69{
70 object.mooseError(error);
71}

Referenced by getPropertyHelper().

◆ nQPoints()

unsigned int MaterialData::nQPoints ( ) const
inline

Returns the number of quadrature points the material properties support/hold.

Definition at line 54 of file MaterialData.h.

54{ return _n_qpoints; }

Referenced by copy(), and resize().

◆ onlyResizeIfSmaller()

void MaterialData::onlyResizeIfSmaller ( bool  flag)
inline

Set _resize_only_if_smaller to perform a non-destructive resize.

Setting this flag to true means that resize(n) will not decrease the size of _props if n is smaller than the size of the material data object.

Definition at line 232 of file MaterialData.h.

232{ _resize_only_if_smaller = flag; };

◆ props() [1/2]

MaterialProperties & MaterialData::props ( const unsigned int  state = 0)
inline

Definition at line 362 of file MaterialData.h.

363{
364 mooseAssert(_props.size() > state, "Invalid state");
365 return _props[state];
366}
std::array< MaterialProperties, max_state+1 > _props
The underlying property data.

◆ props() [2/2]

const MaterialProperties & MaterialData::props ( const unsigned int  state = 0) const
inline

{

Returns
The properties for the state state (defaults to zero).

This should NEVER be used to modify the size of these objects.

Definition at line 355 of file MaterialData.h.

356{
357 mooseAssert(_props.size() > state, "Invalid state");
358 return _props[state];
359}

Referenced by Material::computeProperties(), getPropertyHelper(), haveGenericProperty(), resize(), and Material::subdomainSetup().

◆ reinit()

template<typename MatContainer >
void MaterialData::reinit ( const MatContainer &  mats)

Reinit material properties for given element (and possible side)

Parameters
matsThe material objects for which to compute properties
execute_statefulWhether to execute material objects that have stateful properties. This should be false when for example executing material objects for mortar contexts in which stateful properties don't make sense

Definition at line 443 of file MaterialData.h.

444{
445 for (const auto & mat : mats)
446 mat->computeProperties();
447}

◆ reset()

void MaterialData::reset ( const std::vector< std::shared_ptr< MaterialBase > > &  mats)

Calls the reset method of Materials to ensure that they are in a proper state.

Definition at line 51 of file MaterialData.C.

52{
53 for (const auto & mat : mats)
54 mat->resetProperties();
55}

◆ resize()

void MaterialData::resize ( unsigned int  n_qpoints)

◆ swap()

void MaterialData::swap ( const Elem &  elem,
unsigned int  side = 0 
)

material properties for given element (and possible side)

Definition at line 41 of file MaterialData.C.

42{
44 return;
45
46 _storage.swap(_tid, elem, side);
47 _swapped = true;
48}
bool isSwapped() const
Returns true if the stateful material is in a swapped state.
void swap(const THREAD_ID tid, const Elem &elem, unsigned int side)
Swap (shallow copy) material properties in MaterialData and MaterialPropertyStorage Thread safe.

◆ swapBack()

void MaterialData::swapBack ( const Elem &  elem,
unsigned int  side = 0 
)

material properties for given element (and possible side)

Definition at line 58 of file MaterialData.C.

59{
61 {
62 _storage.swapBack(_tid, elem, side);
63 _swapped = false;
64 }
65}
void swapBack(const THREAD_ID tid, const Elem &elem, unsigned int side)
Swap (shallow copy) material properties in MaterialPropertyStorage and MaterialDat Thread safe.

Referenced by FEProblemBase::swapBackMaterials(), FEProblemBase::swapBackMaterialsFace(), and FEProblemBase::swapBackMaterialsNeighbor().

Member Data Documentation

◆ _n_qpoints

unsigned int MaterialData::_n_qpoints
private

Number of quadrature points.

Definition at line 254 of file MaterialData.h.

Referenced by nQPoints(), and resize().

◆ _props

std::array<MaterialProperties, max_state + 1> MaterialData::_props
private

The underlying property data.

Definition at line 257 of file MaterialData.h.

Referenced by props(), and props().

◆ _resize_only_if_smaller

bool MaterialData::_resize_only_if_smaller
private

Use non-destructive resize of material data (calling resize() will not reduce size).

Default is false (normal resize behaviour)

Definition at line 348 of file MaterialData.h.

Referenced by isOnlyResizeIfSmaller(), onlyResizeIfSmaller(), and resize().

◆ _storage

MaterialPropertyStorage& MaterialData::_storage
private

◆ _swapped

bool MaterialData::_swapped
private

Status of storage swapping (calling swap sets this to true; swapBack sets it to false)

Definition at line 344 of file MaterialData.h.

Referenced by isSwapped(), swap(), and swapBack().

◆ _tid

const THREAD_ID MaterialData::_tid
private

The thread id.

Definition at line 251 of file MaterialData.h.

Referenced by copy(), swap(), and swapBack().

◆ max_state

constexpr unsigned int MaterialData::max_state = 2
staticconstexpr

The max time state supported (2 = older)

Definition at line 43 of file MaterialData.h.

Referenced by MaterialPropertyStorage::addProperty().


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