www.mooseframework.org
Public Member Functions | Protected Attributes | Private Member Functions | List of all members
MaterialProperty< T > Class Template Reference

Concrete definition of a parameter value for a specified type. More...

#include <DerivativeMaterialInterface.h>

Inheritance diagram for MaterialProperty< T >:
[legend]

Public Member Functions

 MaterialProperty (bool use_ad=false)
 Explicitly declare a public constructor because we made the copy constructor private. More...
 
virtual ~MaterialProperty ()
 
const std::vector< MooseADWrapper< T > > & get () const
 
std::vector< MooseADWrapper< T > > & set ()
 
virtual std::string type () override
 String identifying the type of parameter stored. More...
 
virtual PropertyValueinit (int size) override
 Clone this value. More...
 
virtual void resize (int n) override
 Resizes the property to the size n. More...
 
virtual unsigned int size () const override
 
T & operator[] (const unsigned int i)
 Get element i out of the array as a writeable reference. More...
 
const T & operator[] (const unsigned int i) const
 Get element i out of the array as a ready-only reference. More...
 
virtual void swap (PropertyValue *rhs) override
 
virtual void qpCopy (const unsigned int to_qp, PropertyValue *rhs, const unsigned int from_qp) override
 Copy the value of a Property from one specific to a specific qp in this Property. More...
 
virtual void store (std::ostream &stream) override
 Store the property into a binary stream. More...
 
virtual void load (std::istream &stream) override
 Load the property from a binary stream. More...
 
void copyDualNumberToValue (const unsigned int i) override
 copy the value portion (not the derivatives) of the DualNumber<Real> version of the material property to the Real version for the specified quadrature point More...
 
void markAD (bool use_ad) override
 Mark whether this property is in AD mode. This method is necessary for switching the state after swapping material properties during stateful material calculations. More...
 

Protected Attributes

bool _use_ad
 Whether this property was declared as AD. More...
 
std::vector< MooseADWrapper< T > > _value
 Stored parameter value. More...
 

Private Member Functions

 MaterialProperty (const MaterialProperty< T > &)
 private copy constructor to avoid shallow copying of material properties More...
 
MaterialProperty< T > & operator= (const MaterialProperty< T > &)
 private assignment operator to avoid shallow copying of material properties More...
 

Detailed Description

template<typename T>
class MaterialProperty< T >

Concrete definition of a parameter value for a specified type.

Definition at line 26 of file DerivativeMaterialInterface.h.

Constructor & Destructor Documentation

◆ MaterialProperty() [1/2]

template<typename T>
MaterialProperty< T >::MaterialProperty ( bool  use_ad = false)
inline

Explicitly declare a public constructor because we made the copy constructor private.

Definition at line 106 of file MaterialProperty.h.

106  : PropertyValue(), _use_ad(use_ad)
107  { /* */
108  }
bool _use_ad
Whether this property was declared as AD.
Abstract definition of a property value.

◆ ~MaterialProperty()

template<typename T>
virtual MaterialProperty< T >::~MaterialProperty ( )
inlinevirtual

Definition at line 110 of file MaterialProperty.h.

110 {}

◆ MaterialProperty() [2/2]

template<typename T>
MaterialProperty< T >::MaterialProperty ( const MaterialProperty< T > &  )
inlineprivate

private copy constructor to avoid shallow copying of material properties

Definition at line 184 of file MaterialProperty.h.

185  {
186  mooseError("Material properties must be assigned to references (missing '&')");
187  }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208

Member Function Documentation

◆ copyDualNumberToValue()

template<typename T>
void MaterialProperty< T >::copyDualNumberToValue ( const unsigned int  i)
inlineoverridevirtual

copy the value portion (not the derivatives) of the DualNumber<Real> version of the material property to the Real version for the specified quadrature point

Implements PropertyValue.

Definition at line 178 of file MaterialProperty.h.

178 { _value[i].copyDualNumberToValue(); }
std::vector< MooseADWrapper< T > > _value
Stored parameter value.

◆ get()

template<typename T>
const std::vector<MooseADWrapper<T> >& MaterialProperty< T >::get ( ) const
inline
Returns
a read-only reference to the parameter value.

Definition at line 115 of file MaterialProperty.h.

115 { return _value; }
std::vector< MooseADWrapper< T > > _value
Stored parameter value.

◆ init()

template<typename T >
PropertyValue * MaterialProperty< T >::init ( int  size)
inlineoverridevirtual

Clone this value.

Useful in copy-construction.

Implements PropertyValue.

Definition at line 223 of file MaterialProperty.h.

224 {
225  return _init_helper(size, this, static_cast<T *>(0), _use_ad);
226 }
bool _use_ad
Whether this property was declared as AD.
virtual unsigned int size() const override
PropertyValue * _init_helper(int size, PropertyValue *prop, const P *the_type, bool use_ad)
Scalar Init helper routine so that specialization isn&#39;t needed for basic scalar MaterialProperty type...

◆ load()

template<typename T >
void MaterialProperty< T >::load ( std::istream &  stream)
inlineoverridevirtual

Load the property from a binary stream.

Implements PropertyValue.

Definition at line 268 of file MaterialProperty.h.

269 {
270  for (unsigned int i = 0; i < size(); i++)
271  loadHelper(stream, _value[i], NULL);
272 }
std::vector< MooseADWrapper< T > > _value
Stored parameter value.
virtual unsigned int size() const override
void loadHelper(std::istream &stream, P &data, void *context)
Scalar helper routine.
Definition: DataIO.h:742

◆ markAD()

template<typename T >
void MaterialProperty< T >::markAD ( bool  use_ad)
inlineoverridevirtual

Mark whether this property is in AD mode. This method is necessary for switching the state after swapping material properties during stateful material calculations.

Implements PropertyValue.

Definition at line 207 of file MaterialProperty.h.

208 {
209  _use_ad = use_ad;
210  for (auto && moose_wrapper : _value)
211  moose_wrapper.markAD(use_ad);
212 }
bool _use_ad
Whether this property was declared as AD.
std::vector< MooseADWrapper< T > > _value
Stored parameter value.

◆ operator=()

template<typename T>
MaterialProperty<T>& MaterialProperty< T >::operator= ( const MaterialProperty< T > &  )
inlineprivate

private assignment operator to avoid shallow copying of material properties

Definition at line 190 of file MaterialProperty.h.

191  {
192  mooseError("Material properties must be assigned to references (missing '&')");
193  }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208

◆ operator[]() [1/2]

template<typename T>
T& MaterialProperty< T >::operator[] ( const unsigned int  i)
inline

Get element i out of the array as a writeable reference.

Definition at line 142 of file MaterialProperty.h.

142 { return _value[i].value(); }
std::vector< MooseADWrapper< T > > _value
Stored parameter value.

◆ operator[]() [2/2]

template<typename T>
const T& MaterialProperty< T >::operator[] ( const unsigned int  i) const
inline

Get element i out of the array as a ready-only reference.

Definition at line 147 of file MaterialProperty.h.

147 { return _value[i].value(); }
std::vector< MooseADWrapper< T > > _value
Stored parameter value.

◆ qpCopy()

template<typename T >
void MaterialProperty< T >::qpCopy ( const unsigned int  to_qp,
PropertyValue rhs,
const unsigned int  from_qp 
)
inlineoverridevirtual

Copy the value of a Property from one specific to a specific qp in this Property.

Parameters
to_qpThe quadrature point in this Property that you want to copy to.
rhsThe Property you want to copy from.
from_qpThe quadrature point in rhs you want to copy from.

Implements PropertyValue.

Definition at line 250 of file MaterialProperty.h.

253 {
254  mooseAssert(rhs != NULL, "Assigning NULL?");
255  _value[to_qp] = cast_ptr<const MaterialProperty<T> *>(rhs)->_value[from_qp];
256 }
std::vector< MooseADWrapper< T > > _value
Stored parameter value.

◆ resize()

template<typename T >
void MaterialProperty< T >::resize ( int  n)
inlineoverridevirtual

Resizes the property to the size n.

Implements PropertyValue.

Definition at line 230 of file MaterialProperty.h.

Referenced by _init_helper(), MaterialPropertyInterface::getZeroMaterialProperty(), and Material::getZeroMaterialProperty().

231 {
232  auto diff = n - static_cast<int>(_value.size());
233  if (diff < 0)
234  _value.erase(_value.end() + diff, _value.end());
235  else
236  for (decltype(diff) i = 0; i < diff; ++i)
237  _value.emplace_back(MooseADWrapper<T>(_use_ad));
238 }
bool _use_ad
Whether this property was declared as AD.
std::vector< MooseADWrapper< T > > _value
Stored parameter value.
PetscInt n

◆ set()

template<typename T>
std::vector<MooseADWrapper<T> >& MaterialProperty< T >::set ( )
inline
Returns
a writable reference to the parameter value.

Definition at line 120 of file MaterialProperty.h.

120 { return _value; }
std::vector< MooseADWrapper< T > > _value
Stored parameter value.

◆ size()

template<typename T>
virtual unsigned int MaterialProperty< T >::size ( ) const
inlineoverridevirtual

Implements PropertyValue.

Definition at line 137 of file MaterialProperty.h.

Referenced by MaterialPropertyInterface::getZeroMaterialProperty(), Material::getZeroMaterialProperty(), and MooseUtils::MaterialPropertyStorageDump().

137 { return _value.size(); }
std::vector< MooseADWrapper< T > > _value
Stored parameter value.

◆ store()

template<typename T >
void MaterialProperty< T >::store ( std::ostream &  stream)
inlineoverridevirtual

Store the property into a binary stream.

Implements PropertyValue.

Definition at line 260 of file MaterialProperty.h.

261 {
262  for (unsigned int i = 0; i < size(); i++)
263  storeHelper(stream, _value[i], NULL);
264 }
void storeHelper(std::ostream &stream, P &data, void *context)
Scalar helper routine.
Definition: DataIO.h:678
std::vector< MooseADWrapper< T > > _value
Stored parameter value.
virtual unsigned int size() const override

◆ swap()

template<typename T >
void MaterialProperty< T >::swap ( PropertyValue rhs)
inlineoverridevirtual

Implements PropertyValue.

Definition at line 242 of file MaterialProperty.h.

243 {
244  mooseAssert(rhs != NULL, "Assigning NULL?");
245  _value.swap(cast_ptr<MaterialProperty<T> *>(rhs)->_value);
246 }
std::vector< MooseADWrapper< T > > _value
Stored parameter value.
Concrete definition of a parameter value for a specified type.

◆ type()

template<typename T >
std::string MaterialProperty< T >::type ( )
inlineoverridevirtual

String identifying the type of parameter stored.

Implements PropertyValue.

Definition at line 216 of file MaterialProperty.h.

217 {
218  return typeid(T).name();
219 }

Member Data Documentation

◆ _use_ad

template<typename T>
bool MaterialProperty< T >::_use_ad
protected

Whether this property was declared as AD.

Definition at line 197 of file MaterialProperty.h.

◆ _value

template<typename T>
std::vector<MooseADWrapper<T> > MaterialProperty< T >::_value
protected

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