www.mooseframework.org
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | List of all members
MaterialData Class Reference

Proxy for accessing MaterialPropertyStorage. More...

#include <MaterialData.h>

Public Member Functions

 MaterialData (MaterialPropertyStorage &storage)
 
virtual ~MaterialData ()
 
void release ()
 Calls the destroy() methods for the properties currently stored. More...
 
void resize (unsigned int n_qpoints)
 Resize the data to hold properties for n_qpoints quadrature points. More...
 
unsigned int nQPoints ()
 Returns the number of quadrature points the material properties support/hold. More...
 
template<typename T >
MaterialProperty< T > & declareProperty (const std::string &prop_name)
 Declare the Real valued property named "name". More...
 
template<typename T >
MaterialProperty< T > & declarePropertyOld (const std::string &prop_name)
 Declare the Real valued property prop_name. More...
 
template<typename T >
MaterialProperty< T > & declarePropertyOlder (const std::string &prop_name)
 Declare the Real valued property named prop_name. More...
 
template<typename T >
ADMaterialPropertyObject< T > & declareADProperty (const std::string &prop_name)
 Declare the AD property named "name". More...
 
void copy (const Elem &elem_to, const Elem &elem_from, unsigned int side)
 copy material properties from one element to another More...
 
void swap (const Elem &elem, unsigned int side=0)
 material properties for given element (and possible side) More...
 
void reinit (const std::vector< std::shared_ptr< Material >> &mats)
 Reinit material properties for given element (and possible side) More...
 
void reset (const std::vector< std::shared_ptr< Material >> &mats)
 Calls the reset method of Materials to ensure that they are in a proper state. More...
 
void swapBack (const Elem &elem, unsigned int side=0)
 material properties for given element (and possible side) More...
 
template<typename T >
bool haveProperty (const std::string &prop_name) const
 Returns true if the property exists - defined by any material (i.e. More...
 
bool isSwapped ()
 Returns true if the stateful material is in a swapped state. More...
 
const MaterialPropertyStoragegetMaterialPropertyStorage () const
 Provide read-only access to the underlying MaterialPropertyStorage object. More...
 
unsigned int getPropertyId (const std::string &prop_name) const
 Wrapper for MaterialStorage::getPropertyId. More...
 
template<typename T >
MaterialProperty< T > & declareHelper (MaterialProperties &props, const std::string &libmesh_dbg_var(prop_name), unsigned int prop_id)
 
template<typename T >
ADMaterialPropertyObject< T > & declareADHelper (MaterialProperties &props, const std::string &libmesh_dbg_var(prop_name), unsigned int prop_id)
 
MaterialPropertiesprops ()
 Methods for retrieving MaterialProperties object. More...
 
MaterialPropertiespropsOld ()
 
MaterialPropertiespropsOlder ()
 
template<typename T >
MaterialProperty< T > & getProperty (const std::string &prop_name)
 Methods for retieving a MaterialProperty object. More...
 
template<typename T >
ADMaterialPropertyObject< T > & getADProperty (const std::string &prop_name)
 
template<typename T >
MaterialProperty< T > & getPropertyOld (const std::string &prop_name)
 
template<typename T >
MaterialProperty< T > & getPropertyOlder (const std::string &prop_name)
 

Protected Member Functions

template<typename T >
void resizeProps (unsigned int size)
 Calls resizeProps helper function for regular material properties. More...
 

Protected Attributes

MaterialPropertyStorage_storage
 Reference to the MaterialStorage class. More...
 
unsigned int _n_qpoints
 Number of quadrature points. More...
 
bool _swapped
 Status of storage swapping (calling swap sets this to true; swapBack sets it to false) More...
 
MaterialProperties _props
 
MaterialProperties _props_old
 
MaterialProperties _props_older
 

Private Member Functions

template<typename T >
MaterialProperty< T > & declareHelper (MaterialProperties &props, const std::string &prop_name, unsigned int prop_id)
 
template<typename T >
ADMaterialPropertyObject< T > & declareADHelper (MaterialProperties &props, const std::string &prop_name, unsigned int prop_id)
 

Detailed Description

Proxy for accessing MaterialPropertyStorage.

MaterialData stores the values associated with a particular material object

Definition at line 28 of file MaterialData.h.

Constructor & Destructor Documentation

◆ MaterialData()

MaterialData::MaterialData ( MaterialPropertyStorage storage)

Definition at line 13 of file MaterialData.C.

14  : _storage(storage), _n_qpoints(0), _swapped(false)
15 {
16 }
MaterialPropertyStorage & _storage
Reference to the MaterialStorage class.
Definition: MaterialData.h:152
unsigned int _n_qpoints
Number of quadrature points.
Definition: MaterialData.h:155
bool _swapped
Status of storage swapping (calling swap sets this to true; swapBack sets it to false) ...
Definition: MaterialData.h:171

◆ ~MaterialData()

MaterialData::~MaterialData ( )
virtual

Definition at line 18 of file MaterialData.C.

18 { release(); }
void release()
Calls the destroy() methods for the properties currently stored.
Definition: MaterialData.C:21

Member Function Documentation

◆ 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 51 of file MaterialData.C.

52 {
53  _storage.copy(*this, elem_to, elem_from, side, _n_qpoints);
54 }
MaterialPropertyStorage & _storage
Reference to the MaterialStorage class.
Definition: MaterialData.h:152
void copy(MaterialData &material_data, const Elem &elem_to, const Elem &elem_from, unsigned int side, unsigned int n_qpoints)
Copy material properties from elem_from to elem_to.
unsigned int _n_qpoints
Number of quadrature points.
Definition: MaterialData.h:155

◆ declareADHelper() [1/2]

template<typename T >
ADMaterialPropertyObject<T>& MaterialData::declareADHelper ( MaterialProperties props,
const std::string &  prop_name,
unsigned int  prop_id 
)
private

◆ declareADHelper() [2/2]

template<typename T >
ADMaterialPropertyObject<T>& MaterialData::declareADHelper ( MaterialProperties props,
const std::string &  libmesh_dbg_varprop_name,
unsigned int  prop_id 
)

Definition at line 276 of file MaterialData.h.

279 {
280  resizeProps<T>(prop_id);
281  auto prop = dynamic_cast<ADMaterialPropertyObject<T> *>(props[prop_id]);
282  mooseAssert(prop != nullptr, "Internal error in declaring material property: " + prop_name);
283  return *prop;
284 }
MaterialProperties & props()
Methods for retrieving MaterialProperties object.
Definition: MaterialData.h:101

◆ declareADProperty()

template<typename T >
ADMaterialPropertyObject< T > & MaterialData::declareADProperty ( const std::string &  prop_name)

Declare the AD property named "name".

Calling any of the declareProperty functions multiple times with the same property name is okay and will result in a single identical reference returned every time.

Definition at line 241 of file MaterialData.h.

242 {
243  return declareADHelper<T>(_props, prop_name, _storage.addProperty(prop_name));
244 }
unsigned int addProperty(const std::string &prop_name)
The addProperty functions are idempotent - calling multiple times with the same name will provide the...
MaterialPropertyStorage & _storage
Reference to the MaterialStorage class.
Definition: MaterialData.h:152
MaterialProperties _props
Definition: MaterialData.h:159

◆ declareHelper() [1/2]

template<typename T >
MaterialProperty<T>& MaterialData::declareHelper ( MaterialProperties props,
const std::string &  prop_name,
unsigned int  prop_id 
)
private

◆ declareHelper() [2/2]

template<typename T >
MaterialProperty<T>& MaterialData::declareHelper ( MaterialProperties props,
const std::string &  libmesh_dbg_varprop_name,
unsigned int  prop_id 
)

Definition at line 264 of file MaterialData.h.

267 {
268  resizeProps<T>(prop_id);
269  auto prop = dynamic_cast<MaterialProperty<T> *>(props[prop_id]);
270  mooseAssert(prop != nullptr, "Internal error in declaring material property: " + prop_name);
271  return *prop;
272 }
Concrete definition of a parameter value for a specified type.
MaterialProperties & props()
Methods for retrieving MaterialProperties object.
Definition: MaterialData.h:101

◆ declareProperty()

template<typename T >
MaterialProperty< T > & MaterialData::declareProperty ( const std::string &  prop_name)

Declare the Real valued property named "name".

Calling any of the declareProperty functions multiple times with the same property name is okay and will result in a single identical reference returned every time.

Definition at line 234 of file MaterialData.h.

235 {
236  return declareHelper<T>(_props, prop_name, _storage.addProperty(prop_name));
237 }
unsigned int addProperty(const std::string &prop_name)
The addProperty functions are idempotent - calling multiple times with the same name will provide the...
MaterialPropertyStorage & _storage
Reference to the MaterialStorage class.
Definition: MaterialData.h:152
MaterialProperties _props
Definition: MaterialData.h:159

◆ declarePropertyOld()

template<typename T >
MaterialProperty< T > & MaterialData::declarePropertyOld ( const std::string &  prop_name)

Declare the Real valued property prop_name.

Definition at line 248 of file MaterialData.h.

249 {
250  // TODO: add mooseDeprecated("'declarePropertyOld' is deprecated an no longer necessary");
251  return getPropertyOld<T>(prop_name);
252 }

◆ declarePropertyOlder()

template<typename T >
MaterialProperty< T > & MaterialData::declarePropertyOlder ( const std::string &  prop_name)

Declare the Real valued property named prop_name.

Definition at line 256 of file MaterialData.h.

257 {
258  // TODO: add mooseDeprecated("'declarePropertyOlder' is deprecated an no longer necessary");
259  return getPropertyOlder<T>(prop_name);
260 }

◆ getADProperty()

template<typename T >
ADMaterialPropertyObject< T > & MaterialData::getADProperty ( const std::string &  prop_name)

Definition at line 300 of file MaterialData.h.

301 {
302  auto prop_id = getPropertyId(name);
303  resizeProps<T>(prop_id);
304  auto prop = dynamic_cast<ADMaterialPropertyObject<T> *>(_props[prop_id]);
305  if (!prop)
306  mooseError("Material has no property named: " + name);
307  return *prop;
308 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208
unsigned int getPropertyId(const std::string &prop_name) const
Wrapper for MaterialStorage::getPropertyId.
Definition: MaterialData.h:145
MaterialProperties _props
Definition: MaterialData.h:159

◆ getMaterialPropertyStorage()

const MaterialPropertyStorage& MaterialData::getMaterialPropertyStorage ( ) const
inline

Provide read-only access to the underlying MaterialPropertyStorage object.

Definition at line 136 of file MaterialData.h.

136 { return _storage; }
MaterialPropertyStorage & _storage
Reference to the MaterialStorage class.
Definition: MaterialData.h:152

◆ getProperty()

template<typename T >
MaterialProperty< T > & MaterialData::getProperty ( const std::string &  prop_name)

Methods for retieving a MaterialProperty object.

Template Parameters
TThe type of the property
Parameters
prop_nameThe name of the property
Returns
The property for the supplied type and name

Definition at line 288 of file MaterialData.h.

289 {
290  auto prop_id = getPropertyId(name);
291  resizeProps<T>(prop_id);
292  auto prop = dynamic_cast<MaterialProperty<T> *>(_props[prop_id]);
293  if (!prop)
294  mooseError("Material has no property named: " + name);
295  return *prop;
296 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208
unsigned int getPropertyId(const std::string &prop_name) const
Wrapper for MaterialStorage::getPropertyId.
Definition: MaterialData.h:145
MaterialProperties _props
Definition: MaterialData.h:159
Concrete definition of a parameter value for a specified type.

◆ getPropertyId()

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

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 145 of file MaterialData.h.

Referenced by getADProperty(), getProperty(), and haveProperty().

146  {
147  return _storage.getPropertyId(prop_name);
148  }
MaterialPropertyStorage & _storage
Reference to the MaterialStorage class.
Definition: MaterialData.h:152
unsigned int getPropertyId(const std::string &prop_name)
Returns the property ID for the given prop_name, adding the property and creating a new ID if it hasn...

◆ getPropertyOld()

template<typename T >
MaterialProperty< T > & MaterialData::getPropertyOld ( const std::string &  prop_name)

Definition at line 312 of file MaterialData.h.

313 {
314  return declareHelper<T>(_props_old, name, _storage.addPropertyOld(name));
315 }
MaterialPropertyStorage & _storage
Reference to the MaterialStorage class.
Definition: MaterialData.h:152
unsigned int addPropertyOld(const std::string &prop_name)
MaterialProperties _props_old
Definition: MaterialData.h:160

◆ getPropertyOlder()

template<typename T >
MaterialProperty< T > & MaterialData::getPropertyOlder ( const std::string &  prop_name)

Definition at line 319 of file MaterialData.h.

320 {
321  return declareHelper<T>(_props_older, name, _storage.addPropertyOlder(name));
322 }
MaterialPropertyStorage & _storage
Reference to the MaterialStorage class.
Definition: MaterialData.h:152
MaterialProperties _props_older
Definition: MaterialData.h:161
unsigned int addPropertyOlder(const std::string &prop_name)

◆ haveProperty()

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

Returns true if the property exists - defined by any material (i.e.

not necessarily just this one).

Definition at line 199 of file MaterialData.h.

200 {
201  if (!_storage.hasProperty(prop_name))
202  return false;
203 
204  unsigned int prop_id = getPropertyId(prop_name);
205  if (prop_id >= _props.size())
206  return false; // the property id exists, but the property was not created in this instance of
207  // the material type
208 
209  return dynamic_cast<const MaterialProperty<T> *>(_props[prop_id]) != nullptr;
210 }
MaterialPropertyStorage & _storage
Reference to the MaterialStorage class.
Definition: MaterialData.h:152
unsigned int getPropertyId(const std::string &prop_name) const
Wrapper for MaterialStorage::getPropertyId.
Definition: MaterialData.h:145
MaterialProperties _props
Definition: MaterialData.h:159
bool hasProperty(const std::string &prop_name) const
Concrete definition of a parameter value for a specified type.

◆ isSwapped()

bool MaterialData::isSwapped ( )

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

Definition at line 91 of file MaterialData.C.

92 {
93  return _swapped;
94 }
bool _swapped
Status of storage swapping (calling swap sets this to true; swapBack sets it to false) ...
Definition: MaterialData.h:171

◆ nQPoints()

unsigned int MaterialData::nQPoints ( )

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

Definition at line 45 of file MaterialData.C.

46 {
47  return _n_qpoints;
48 }
unsigned int _n_qpoints
Number of quadrature points.
Definition: MaterialData.h:155

◆ props()

MaterialProperties& MaterialData::props ( )
inline

Methods for retrieving MaterialProperties object.

These functions should NEVER be used to modify the sizes of the MaterialProperties objects.

Definition at line 101 of file MaterialData.h.

Referenced by declareADHelper(), declareHelper(), MaterialPropertyStorage::initProps(), MaterialPropertyStorage::swap(), and MaterialPropertyStorage::swapBack().

101 { return _props; }
MaterialProperties _props
Definition: MaterialData.h:159

◆ propsOld()

MaterialProperties& MaterialData::propsOld ( )
inline

Definition at line 102 of file MaterialData.h.

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

102 { return _props_old; }
MaterialProperties _props_old
Definition: MaterialData.h:160

◆ propsOlder()

MaterialProperties& MaterialData::propsOlder ( )
inline

◆ reinit()

void MaterialData::reinit ( const std::vector< std::shared_ptr< Material >> &  mats)

Reinit material properties for given element (and possible side)

Definition at line 67 of file MaterialData.C.

68 {
69  for (const auto & mat : mats)
70  mat->computeProperties();
71 }

◆ release()

void MaterialData::release ( )

Calls the destroy() methods for the properties currently stored.

Definition at line 21 of file MaterialData.C.

Referenced by ~MaterialData().

22 {
23  _props.destroy();
26 }
MaterialProperties _props_old
Definition: MaterialData.h:160
MaterialProperties _props_older
Definition: MaterialData.h:161
MaterialProperties _props
Definition: MaterialData.h:159
void destroy()
Deallocates the memory.

◆ reset()

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

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

Definition at line 74 of file MaterialData.C.

75 {
76  for (const auto & mat : mats)
77  mat->resetProperties();
78 }

◆ resize()

void MaterialData::resize ( unsigned int  n_qpoints)

Resize the data to hold properties for n_qpoints quadrature points.

Definition at line 29 of file MaterialData.C.

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

30 {
31  if (n_qpoints == _n_qpoints)
32  return;
33 
34  _props.resizeItems(n_qpoints);
35  // if there are stateful material properties in the system, also resize
36  // storage for old and older material properties
38  _props_old.resizeItems(n_qpoints);
40  _props_older.resizeItems(n_qpoints);
41  _n_qpoints = n_qpoints;
42 }
MaterialPropertyStorage & _storage
Reference to the MaterialStorage class.
Definition: MaterialData.h:152
MaterialProperties _props_old
Definition: MaterialData.h:160
MaterialProperties _props_older
Definition: MaterialData.h:161
unsigned int _n_qpoints
Number of quadrature points.
Definition: MaterialData.h:155
void resizeItems(unsigned int n_qpoints)
Resize items in this array, i.e.
MaterialProperties _props
Definition: MaterialData.h:159

◆ resizeProps()

template<typename T >
void MaterialData::resizeProps ( unsigned int  size)
protected

Calls resizeProps helper function for regular material properties.

Definition at line 214 of file MaterialData.h.

215 {
216  auto n = size + 1;
217  if (_props.size() < n)
218  _props.resize(n, nullptr);
219  if (_props_old.size() < n)
220  _props_old.resize(n, nullptr);
221  if (_props_older.size() < n)
222  _props_older.resize(n, nullptr);
223 
224  if (_props[size] == nullptr)
226  if (_props_old[size] == nullptr)
228  if (_props_older[size] == nullptr)
230 }
MaterialProperties _props_old
Definition: MaterialData.h:160
MaterialProperties _props_older
Definition: MaterialData.h:161
MaterialProperties _props
Definition: MaterialData.h:159
PetscInt n

◆ swap()

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

material properties for given element (and possible side)

Definition at line 57 of file MaterialData.C.

58 {
60  return;
61 
62  _storage.swap(*this, elem, side);
63  _swapped = true;
64 }
MaterialPropertyStorage & _storage
Reference to the MaterialStorage class.
Definition: MaterialData.h:152
void swap(MaterialData &material_data, const Elem &elem, unsigned int side)
Swap (shallow copy) material properties in MaterialData and MaterialPropertyStorage Thread safe...
bool _swapped
Status of storage swapping (calling swap sets this to true; swapBack sets it to false) ...
Definition: MaterialData.h:171

◆ swapBack()

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

material properties for given element (and possible side)

Definition at line 81 of file MaterialData.C.

82 {
84  {
85  _storage.swapBack(*this, elem, side);
86  _swapped = false;
87  }
88 }
MaterialPropertyStorage & _storage
Reference to the MaterialStorage class.
Definition: MaterialData.h:152
void swapBack(MaterialData &material_data, const Elem &elem, unsigned int side)
Swap (shallow copy) material properties in MaterialPropertyStorage and MaterialDat Thread safe...
bool _swapped
Status of storage swapping (calling swap sets this to true; swapBack sets it to false) ...
Definition: MaterialData.h:171

Member Data Documentation

◆ _n_qpoints

unsigned int MaterialData::_n_qpoints
protected

Number of quadrature points.

Definition at line 155 of file MaterialData.h.

Referenced by copy(), nQPoints(), and resize().

◆ _props

MaterialProperties MaterialData::_props
protected

Holds material properties for currently selected element (and possibly a side), they are being copied from _storage

Definition at line 159 of file MaterialData.h.

Referenced by declareADProperty(), declareProperty(), getADProperty(), getProperty(), haveProperty(), props(), release(), resize(), and resizeProps().

◆ _props_old

MaterialProperties MaterialData::_props_old
protected

Definition at line 160 of file MaterialData.h.

Referenced by getPropertyOld(), propsOld(), release(), resize(), and resizeProps().

◆ _props_older

MaterialProperties MaterialData::_props_older
protected

Definition at line 161 of file MaterialData.h.

Referenced by getPropertyOlder(), propsOlder(), release(), resize(), and resizeProps().

◆ _storage

MaterialPropertyStorage& MaterialData::_storage
protected

◆ _swapped

bool MaterialData::_swapped
protected

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

Definition at line 171 of file MaterialData.h.

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


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