https://mooseframework.inl.gov
Public Member Functions | Protected Attributes | List of all members
Moose::Kokkos::MaterialPropertyBase Class Referenceabstract

The base class for Kokkos material properties. More...

#include <KokkosMaterialPropertyDecl.h>

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

Public Member Functions

 MaterialPropertyBase ()=default
 Default constructor. More...
 
virtual ~MaterialPropertyBase ()
 Desturctor. More...
 
unsigned int id () const
 Get the property ID. More...
 
const std::string & name () const
 Get the property name. More...
 
const std::string & type () const
 Get the data type. More...
 
unsigned int dim () const
 Get the dimension. More...
 
unsigned int dimSize (SubdomainID subdomain, unsigned int i) const
 Get the size of a dimension. More...
 
virtual std::type_index propertyType ()=0
 Get the property type index for load/store functions. More...
 
virtual void init (const PropRecord &record, const StorageKey &)
 Initialize this property. More...
 
virtual void allocate (const Mesh &mesh, const Assembly &assembly, const std::set< SubdomainID > &subdomains, const bool bnd, StorageKey)=0
 Allocate the data storage. More...
 
virtual void copy (const MaterialPropertyBase &prop, StorageKey)=0
 Deep copy another property. More...
 
virtual void swap (MaterialPropertyBase &prop, StorageKey)=0
 Swap with another property. More...
 

Protected Attributes

const PropRecord_record = nullptr
 Pointer to the record of this property. More...
 
unsigned int _id = libMesh::invalid_uint
 Property ID. More...
 
bool _default = false
 Flag whether this property has a default value. More...
 
Array< PropertyConstantOption_constant_option
 Whether this property is constant over element or subdomain in each subdomain. More...
 

Detailed Description

The base class for Kokkos material properties.

Definition at line 92 of file KokkosMaterialPropertyDecl.h.

Constructor & Destructor Documentation

◆ MaterialPropertyBase()

Moose::Kokkos::MaterialPropertyBase::MaterialPropertyBase ( )
default

Default constructor.

◆ ~MaterialPropertyBase()

virtual Moose::Kokkos::MaterialPropertyBase::~MaterialPropertyBase ( )
inlinevirtual

Desturctor.

Definition at line 102 of file KokkosMaterialPropertyDecl.h.

102 {}

Member Function Documentation

◆ allocate()

virtual void Moose::Kokkos::MaterialPropertyBase::allocate ( const Mesh mesh,
const Assembly assembly,
const std::set< SubdomainID > &  subdomains,
const bool  bnd,
StorageKey   
)
pure virtual

Allocate the data storage.

Parameters
meshThe Kokkos mesh
assemblyThe Kokkos assembly
subdomainsThe MOOSE subdomain IDs
bndWhether this property is a face property

Implemented in Moose::Kokkos::MaterialProperty< T, dimension >, and Moose::Kokkos::MaterialProperty< Real >.

◆ copy()

virtual void Moose::Kokkos::MaterialPropertyBase::copy ( const MaterialPropertyBase prop,
StorageKey   
)
pure virtual

Deep copy another property.

Parameters
propThe property to copy

Implemented in Moose::Kokkos::MaterialProperty< T, dimension >, and Moose::Kokkos::MaterialProperty< Real >.

◆ dim()

unsigned int MaterialPropertyBase< T, is_ad >::dim ( ) const
inline

Get the dimension.

Returns
The dimension

Definition at line 205 of file KokkosMaterialPropertyDecl.h.

Referenced by dimSize().

206 {
207  if (!_record || !_record->dims.size())
208  mooseError("Cannot get the dimension of an uninitialized or default material property.");
209  else
210  return _record->dims.begin()->second.size();
211 }
const PropRecord * _record
Pointer to the record of this property.
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311
std::unordered_map< SubdomainID, std::vector< unsigned int > > dims
Size of each dimension of each subdomain.

◆ dimSize()

unsigned int MaterialPropertyBase< T, is_ad >::dimSize ( SubdomainID  subdomain,
unsigned int  i 
) const
inline

Get the size of a dimension.

Parameters
subdomainThe MOOSE subdomain ID
iThe dimension index
Returns
The size of the dimension

Definition at line 214 of file KokkosMaterialPropertyDecl.h.

215 {
216  const unsigned int D = dim();
217 
218  if (i >= D)
219  mooseError("Cannot get the size of ",
220  i,
221  "-th dimension for the ",
222  D,
223  "D material property '",
224  name(),
225  "'.");
226 
227  return libmesh_map_find(_record->dims, subdomain)[i];
228 }
const PropRecord * _record
Pointer to the record of this property.
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311
std::unordered_map< SubdomainID, std::vector< unsigned int > > dims
Size of each dimension of each subdomain.
unsigned int dim() const
Get the dimension.
const std::string & name() const
Get the property name.

◆ id()

unsigned int Moose::Kokkos::MaterialPropertyBase::id ( ) const
inline

Get the property ID.

Returns
The property ID assigned by the MOOSE registry

Definition at line 108 of file KokkosMaterialPropertyDecl.h.

108 { return _id; }

◆ init()

void MaterialPropertyBase< T, is_ad >::init ( const PropRecord record,
const StorageKey  
)
inlinevirtual

Initialize this property.

Parameters
recordThe record of this property

Reimplemented in Moose::Kokkos::MaterialProperty< T, dimension >, and Moose::Kokkos::MaterialProperty< Real >.

Definition at line 25 of file KokkosMaterialProperty.h.

Referenced by Moose::Kokkos::MaterialProperty< Real >::init().

26 {
27  _record = &record;
28  _id = record.id;
29 }
const PropRecord * _record
Pointer to the record of this property.

◆ name()

const std::string & MaterialPropertyBase< T, is_ad >::name ( ) const
inline

Get the property name.

Returns
The property name

Definition at line 187 of file KokkosMaterialPropertyDecl.h.

Referenced by dimSize().

188 {
189  if (!_record)
190  mooseError("Cannot get the name of an uninitialized or default material property.");
191  else
192  return _record->name;
193 }
const PropRecord * _record
Pointer to the record of this property.
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311
std::string name
Property name.

◆ propertyType()

virtual std::type_index Moose::Kokkos::MaterialPropertyBase::propertyType ( )
pure virtual

Get the property type index for load/store functions.

Returns
The property type index for the load/store function pointer map lookup

Implemented in Moose::Kokkos::MaterialProperty< T, dimension >, and Moose::Kokkos::MaterialProperty< Real >.

◆ swap()

virtual void Moose::Kokkos::MaterialPropertyBase::swap ( MaterialPropertyBase prop,
StorageKey   
)
pure virtual

Swap with another property.

Parameters
propThe property to swap

Implemented in Moose::Kokkos::MaterialProperty< T, dimension >, and Moose::Kokkos::MaterialProperty< Real >.

◆ type()

const std::string & MaterialPropertyBase< T, is_ad >::type ( ) const
inline

Get the data type.

Returns
The demangled data type name

Definition at line 196 of file KokkosMaterialPropertyDecl.h.

Referenced by Moose::Kokkos::MaterialProperty< Real >::propertyType().

197 {
198  if (!_record)
199  mooseError("Cannot get the type of an uninitialized or default material property.");
200  else
201  return _record->type;
202 }
const PropRecord * _record
Pointer to the record of this property.
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311
std::string type
Demangled data type name.

Member Data Documentation

◆ _constant_option

Array<PropertyConstantOption> Moose::Kokkos::MaterialPropertyBase::_constant_option
protected

Whether this property is constant over element or subdomain in each subdomain.

Definition at line 183 of file KokkosMaterialPropertyDecl.h.

◆ _default

bool Moose::Kokkos::MaterialPropertyBase::_default = false
protected

Flag whether this property has a default value.

Definition at line 179 of file KokkosMaterialPropertyDecl.h.

Referenced by Moose::Kokkos::MaterialProperty< Real >::operator bool().

◆ _id

unsigned int Moose::Kokkos::MaterialPropertyBase::_id = libMesh::invalid_uint
protected

Property ID.

Definition at line 175 of file KokkosMaterialPropertyDecl.h.

Referenced by id(), and init().

◆ _record

const PropRecord* Moose::Kokkos::MaterialPropertyBase::_record = nullptr
protected

Pointer to the record of this property.

Definition at line 171 of file KokkosMaterialPropertyDecl.h.

Referenced by dim(), dimSize(), init(), name(), and type().


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