www.mooseframework.org
Public Types | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
FunctionMaterialPropertyDescriptor< is_ad > Class Template Reference

Material properties get fully described using this structure, including their dependent variables and derivation state. More...

#include <FunctionMaterialPropertyDescriptor.h>

Inheritance diagram for FunctionMaterialPropertyDescriptor< is_ad >:
[legend]

Public Types

typedef std::string SymbolName
 

Public Member Functions

 FunctionMaterialPropertyDescriptor (const std::string &, MooseObject *, bool required=false)
 
 FunctionMaterialPropertyDescriptor ()=delete
 no default constructor More...
 
 FunctionMaterialPropertyDescriptor (const FunctionMaterialPropertyDescriptor &)
 copy constructor More...
 
 FunctionMaterialPropertyDescriptor (const FunctionMaterialPropertyDescriptor &, MooseObject *)
 copy constructor assigning new parent More...
 
FunctionMaterialPropertyDescriptoroperator= (const FunctionMaterialPropertyDescriptor &)=default
 
const std::string & getSymbolName () const
 get the fparser symbol name More...
 
void setSymbolName (const std::string &n)
 set the fparser symbol name More...
 
const std::string & getPropertyName () const
 get the property name More...
 
GenericReal< is_ad > value (unsigned int qp=libMesh::invalid_uint) const
 get the property value at the given quadrature point More...
 
void addDerivative (const SymbolName &symbol)
 take another derivative More...
 
bool dependsOn (const SymbolName &symbol) const
 Check if a material property depends on a given FParser symbol. More...
 
std::vector< SymbolNamegetDependentSymbols ()
 builds a list of dependent symbols (exactly all symbols for which depends on returns true) More...
 
void printDebug ()
 output the internal state of this descriptor for debugging purposes More...
 
void updatePropertyName ()
 update the cached _property_name member More...
 
const MaterialPropertyName derivativePropertyName (const MaterialPropertyName &base, const std::vector< SymbolName > &c) const
 Helper functions to generate the material property names for the arbitrary derivatives. More...
 
const MaterialPropertyName derivativePropertyNameFirst (const MaterialPropertyName &base, const SymbolName &c1) const
 Helper functions to generate the material property names for the first derivatives. More...
 
const MaterialPropertyName derivativePropertyNameSecond (const MaterialPropertyName &base, const SymbolName &c1, const SymbolName &c2) const
 Helper functions to generate the material property names for the second derivatives. More...
 
const MaterialPropertyName derivativePropertyNameThird (const MaterialPropertyName &base, const SymbolName &c1, const SymbolName &c2, const SymbolName &c3) const
 Helper functions to generate the material property names for the third derivatives. More...
 
const MaterialPropertyName propertyName (const MaterialPropertyName &base, const std::vector< SymbolName > &c) const
 aliases for the deprecated old function names More...
 
const MaterialPropertyName propertyNameFirst (const MaterialPropertyName &base, const SymbolName &c1) const
 
const MaterialPropertyName propertyNameSecond (const MaterialPropertyName &base, const SymbolName &c1, const SymbolName &c2) const
 
const MaterialPropertyName propertyNameThird (const MaterialPropertyName &base, const SymbolName &c1, const SymbolName &c2, const SymbolName &c3) const
 

Static Public Member Functions

static std::vector< FunctionMaterialPropertyDescriptorparseVector (const std::vector< std::string > &, MooseObject *)
 construct a vector of FunctionMaterialPropertyDescriptors from a vector of strings More...
 

Private Types

enum  PropertyState { PropertyState::CURRENT, PropertyState::OLD, PropertyState::OLDER }
 property state More...
 

Private Member Functions

void parseDerivative (const std::string &)
 
void parseDependentSymbols (const std::string &)
 

Private Attributes

enum FunctionMaterialPropertyDescriptor::PropertyState _state
 
std::string _fparser_name
 name used in function expression More...
 
std::string _base_name
 function material property base name More...
 
std::vector< SymbolName_dependent_symbols
 
std::vector< SymbolName_derivative_symbols
 
const GenericMaterialProperty< Real, is_ad > * _value
 material property value (this is lazily updated and cached when read through value()) More...
 
const MaterialProperty< Real > * _old_older_value
 old/older material property value (this is lazily updated and cached when read through value()) More...
 
MooseObject_parent
 material object that owns this descriptor More...
 
std::string _property_name
 cache the final property name of the derivative More...
 
bool _required
 is this a property that was directly specified by the user? Then it must exist. More...
 

Detailed Description

template<bool is_ad>
class FunctionMaterialPropertyDescriptor< is_ad >

Material properties get fully described using this structure, including their dependent variables and derivation state.

Definition at line 25 of file FunctionMaterialPropertyDescriptor.h.

Member Typedef Documentation

◆ SymbolName

Definition at line 25 of file DerivativeMaterialPropertyNameInterface.h.

Member Enumeration Documentation

◆ PropertyState

template<bool is_ad>
enum FunctionMaterialPropertyDescriptor::PropertyState
strongprivate

property state

Enumerator
CURRENT 
OLD 
OLDER 

Definition at line 97 of file FunctionMaterialPropertyDescriptor.h.

98  {
99  CURRENT,
100  OLD,
101  OLDER
102  } _state;
enum FunctionMaterialPropertyDescriptor::PropertyState _state

Constructor & Destructor Documentation

◆ FunctionMaterialPropertyDescriptor() [1/4]

template<bool is_ad>
FunctionMaterialPropertyDescriptor< is_ad >::FunctionMaterialPropertyDescriptor ( const std::string &  expression,
MooseObject parent,
bool  required = false 
)

Definition at line 17 of file FunctionMaterialPropertyDescriptor.C.

22  _value(nullptr),
23  _old_older_value(nullptr),
24  _parent(parent),
25  _required(required)
26 {
27  auto define = expression.find_last_of(":=");
28 
29  // expression contains a ':='
30  if (define != std::string::npos)
31  {
32  // section before ':=' is the name used in the function expression
33  _fparser_name = expression.substr(0, define - 1);
34 
35  // parse right hand side
36  parseDerivative(expression.substr(define + 1));
37  }
38  else
39  {
40  // parse entire expression and use natural material property base name
41  // for D(x(t),t,t) this would simply be 'x'!
42  parseDerivative(expression);
44  }
45 
47 }
bool _required
is this a property that was directly specified by the user? Then it must exist.
std::string _base_name
function material property base name
enum FunctionMaterialPropertyDescriptor::PropertyState _state
std::string _fparser_name
name used in function expression
const MaterialProperty< Real > * _old_older_value
old/older material property value (this is lazily updated and cached when read through value()) ...
void updatePropertyName()
update the cached _property_name member
MooseObject * _parent
material object that owns this descriptor
const GenericMaterialProperty< Real, is_ad > * _value
material property value (this is lazily updated and cached when read through value()) ...

◆ FunctionMaterialPropertyDescriptor() [2/4]

no default constructor

◆ FunctionMaterialPropertyDescriptor() [3/4]

copy constructor

Definition at line 50 of file FunctionMaterialPropertyDescriptor.C.

52  : _state(rhs._state),
57  _value(nullptr),
58  _old_older_value(nullptr),
59  _parent(rhs._parent),
61  _required(false)
62 {
63 }
bool _required
is this a property that was directly specified by the user? Then it must exist.
std::string _base_name
function material property base name
std::string _property_name
cache the final property name of the derivative
enum FunctionMaterialPropertyDescriptor::PropertyState _state
std::string _fparser_name
name used in function expression
const MaterialProperty< Real > * _old_older_value
old/older material property value (this is lazily updated and cached when read through value()) ...
MooseObject * _parent
material object that owns this descriptor
const GenericMaterialProperty< Real, is_ad > * _value
material property value (this is lazily updated and cached when read through value()) ...

◆ FunctionMaterialPropertyDescriptor() [4/4]

template<bool is_ad>
FunctionMaterialPropertyDescriptor< is_ad >::FunctionMaterialPropertyDescriptor ( const FunctionMaterialPropertyDescriptor< is_ad > &  rhs,
MooseObject parent 
)

copy constructor assigning new parent

Definition at line 66 of file FunctionMaterialPropertyDescriptor.C.

68  : _state(rhs._state),
73  _value(nullptr),
74  _old_older_value(nullptr),
75  _parent(parent),
77  _required(false)
78 {
79 }
bool _required
is this a property that was directly specified by the user? Then it must exist.
std::string _base_name
function material property base name
std::string _property_name
cache the final property name of the derivative
enum FunctionMaterialPropertyDescriptor::PropertyState _state
std::string _fparser_name
name used in function expression
const MaterialProperty< Real > * _old_older_value
old/older material property value (this is lazily updated and cached when read through value()) ...
MooseObject * _parent
material object that owns this descriptor
const GenericMaterialProperty< Real, is_ad > * _value
material property value (this is lazily updated and cached when read through value()) ...

Member Function Documentation

◆ addDerivative()

template<bool is_ad>
void FunctionMaterialPropertyDescriptor< is_ad >::addDerivative ( const SymbolName symbol)

take another derivative

Definition at line 94 of file FunctionMaterialPropertyDescriptor.C.

Referenced by DerivativeParsedMaterialHelperTempl< is_ad >::recurseMatProps().

95 {
96  _derivative_symbols.push_back(var);
97  _value = nullptr;
99 }
void updatePropertyName()
update the cached _property_name member
const GenericMaterialProperty< Real, is_ad > * _value
material property value (this is lazily updated and cached when read through value()) ...

◆ dependsOn()

template<bool is_ad>
bool FunctionMaterialPropertyDescriptor< is_ad >::dependsOn ( const SymbolName symbol) const

Check if a material property depends on a given FParser symbol.

A dependency is indicated by either directly specifying it, or by requesting a derivative w.r.t. that symbol using the D[x,a] syntax

Definition at line 103 of file FunctionMaterialPropertyDescriptor.C.

104 {
105  return std::find(_dependent_symbols.begin(), _dependent_symbols.end(), var) !=
106  _dependent_symbols.end() ||
107  std::find(_derivative_symbols.begin(), _derivative_symbols.end(), var) !=
108  _derivative_symbols.end();
109 }

◆ derivativePropertyName()

const MaterialPropertyName DerivativeMaterialPropertyNameInterface::derivativePropertyName ( const MaterialPropertyName &  base,
const std::vector< SymbolName > &  c 
) const
inherited

Helper functions to generate the material property names for the arbitrary derivatives.

Definition at line 16 of file DerivativeMaterialPropertyNameInterface.C.

Referenced by DerivativeMaterialPropertyNameInterface::derivativePropertyNameSecond(), DerivativeMaterialPropertyNameInterface::derivativePropertyNameThird(), and DerivativeMaterialPropertyNameInterface::propertyName().

18 {
19  // to obtain well defined names we sort alphabetically
20  std::vector<SymbolName> a(c);
21  std::sort(a.begin(), a.end());
22 
23  // derivative order
24  unsigned int order = a.size();
25  if (order == 0)
26  return base;
27 
28  // build the property name as a stringstream
29  std::stringstream name;
30 
31  // build numerator
32  name << 'd';
33  if (order > 1)
34  name << '^' << order;
35  name << base << '/';
36 
37  // build denominator with 'pretty' names using exponents rather than repeat multiplication
38  unsigned int exponent = 1;
39  for (unsigned i = 1; i <= order; ++i)
40  {
41  if (i == order || a[i - 1] != a[i])
42  {
43  name << 'd' << a[i - 1];
44  if (exponent > 1)
45  name << '^' << exponent;
46  exponent = 1;
47  }
48  else
49  exponent++;
50  }
51 
52  return name.str();
53 }
std::string name(const ElemQuality q)

◆ derivativePropertyNameFirst()

const MaterialPropertyName DerivativeMaterialPropertyNameInterface::derivativePropertyNameFirst ( const MaterialPropertyName &  base,
const SymbolName c1 
) const
inherited

Helper functions to generate the material property names for the first derivatives.

Definition at line 56 of file DerivativeMaterialPropertyNameInterface.C.

Referenced by DerivativeMaterialPropertyNameInterface::propertyNameFirst().

58 {
59  return "d" + base + "/d" + c1;
60 }

◆ derivativePropertyNameSecond()

const MaterialPropertyName DerivativeMaterialPropertyNameInterface::derivativePropertyNameSecond ( const MaterialPropertyName &  base,
const SymbolName c1,
const SymbolName c2 
) const
inherited

Helper functions to generate the material property names for the second derivatives.

Definition at line 63 of file DerivativeMaterialPropertyNameInterface.C.

Referenced by DerivativeMaterialPropertyNameInterface::propertyNameSecond().

65 {
66  return derivativePropertyName(base, {c1, c2});
67 }
const MaterialPropertyName derivativePropertyName(const MaterialPropertyName &base, const std::vector< SymbolName > &c) const
Helper functions to generate the material property names for the arbitrary derivatives.

◆ derivativePropertyNameThird()

const MaterialPropertyName DerivativeMaterialPropertyNameInterface::derivativePropertyNameThird ( const MaterialPropertyName &  base,
const SymbolName c1,
const SymbolName c2,
const SymbolName c3 
) const
inherited

Helper functions to generate the material property names for the third derivatives.

Definition at line 70 of file DerivativeMaterialPropertyNameInterface.C.

Referenced by DerivativeMaterialPropertyNameInterface::propertyNameThird().

75 {
76  return derivativePropertyName(base, {c1, c2, c3});
77 }
const MaterialPropertyName derivativePropertyName(const MaterialPropertyName &base, const std::vector< SymbolName > &c) const
Helper functions to generate the material property names for the arbitrary derivatives.

◆ getDependentSymbols()

template<bool is_ad>
std::vector< DerivativeMaterialPropertyNameInterface::SymbolName > FunctionMaterialPropertyDescriptor< is_ad >::getDependentSymbols ( )

builds a list of dependent symbols (exactly all symbols for which depends on returns true)

Definition at line 113 of file FunctionMaterialPropertyDescriptor.C.

114 {
115  std::set<SymbolName> all(_dependent_symbols.begin(), _dependent_symbols.end());
116  all.insert(_derivative_symbols.begin(), _derivative_symbols.end());
117 
118  return std::vector<SymbolName>(all.begin(), all.end());
119 }

◆ getPropertyName()

template<bool is_ad>
const std::string& FunctionMaterialPropertyDescriptor< is_ad >::getPropertyName ( ) const
inline

get the property name

Definition at line 68 of file FunctionMaterialPropertyDescriptor.h.

68 { return _property_name; };
std::string _property_name
cache the final property name of the derivative

◆ getSymbolName()

template<bool is_ad>
const std::string& FunctionMaterialPropertyDescriptor< is_ad >::getSymbolName ( ) const
inline

get the fparser symbol name

Definition at line 62 of file FunctionMaterialPropertyDescriptor.h.

62 { return _fparser_name; };
std::string _fparser_name
name used in function expression

◆ operator=()

template<bool is_ad>
FunctionMaterialPropertyDescriptor& FunctionMaterialPropertyDescriptor< is_ad >::operator= ( const FunctionMaterialPropertyDescriptor< is_ad > &  )
default

◆ parseDependentSymbols()

template<bool is_ad>
void FunctionMaterialPropertyDescriptor< is_ad >::parseDependentSymbols ( const std::string &  expression)
private

Definition at line 190 of file FunctionMaterialPropertyDescriptor.C.

191 {
192  auto open = expression.find_first_of("(");
193  auto close = expression.find_last_of(")");
194 
195  if (open == std::string::npos && close == std::string::npos)
196  {
197  // material property name without arguments
198  _base_name = expression;
199  }
200  else if (open != std::string::npos && close != std::string::npos)
201  {
202  // take material property name before bracket
203  _base_name = expression.substr(0, open);
204 
205  // parse argument list
206  MooseUtils::tokenize(expression.substr(open + 1, close - open - 1), _dependent_symbols, 0, ",");
207 
208  // remove duplicates from dependent variable list
209  std::sort(_dependent_symbols.begin(), _dependent_symbols.end());
210  _dependent_symbols.erase(std::unique(_dependent_symbols.begin(), _dependent_symbols.end()),
211  _dependent_symbols.end());
212  }
213  else
214  mooseError("Malformed material_properties expression '", expression, "'");
215 }
void tokenize(const std::string &str, std::vector< T > &elements, unsigned int min_len=1, const std::string &delims="/")
This function will split the passed in string on a set of delimiters appending the substrings to the ...
Definition: MooseUtils.h:779
std::string _base_name
function material property base name
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:284

◆ parseDerivative()

template<bool is_ad>
void FunctionMaterialPropertyDescriptor< is_ad >::parseDerivative ( const std::string &  expression)
private

Definition at line 123 of file FunctionMaterialPropertyDescriptor.C.

Referenced by FunctionMaterialPropertyDescriptor< is_ad >::FunctionMaterialPropertyDescriptor().

124 {
125  auto open = expression.find_first_of("[");
126  auto close = expression.find_last_of("]");
127 
128  if (open == std::string::npos && close == std::string::npos)
129  {
130  // no derivative requested
131  parseDependentSymbols(expression);
132 
133  return;
134  }
135  if (open != std::string::npos && close != std::string::npos)
136  {
137  if (expression.substr(0, open) == "Old")
138  {
139  _base_name = expression.substr(open + 1, close - open - 1);
140  _dependent_symbols.clear();
142  return;
143  }
144  if (expression.substr(0, open) == "Older")
145  {
146  _base_name = expression.substr(open + 1, close - open - 1);
147  _dependent_symbols.clear();
149  return;
150  }
151  else if (expression.substr(0, open) == "D")
152  {
153  auto arguments = expression.substr(open + 1, close - open - 1);
154  auto close2 = arguments.find_last_of(")");
155 
156  if (close2 == std::string::npos)
157  {
158  // rest of argument list 0 is the function and 1,.. are the variable to take the derivative
159  // w.r.t.
160  MooseUtils::tokenize(arguments, _derivative_symbols, 0, ",");
161 
162  // check for empty [] brackets
163  if (_derivative_symbols.size() > 0)
164  {
165  // parse argument zero of D[] as the function material property
167 
168  // remove function from the _derivative_symbols vector
171 
172  return;
173  }
174  }
175  else
176  {
177  parseDependentSymbols(arguments.substr(0, close2 + 1));
178  MooseUtils::tokenize(arguments.substr(close2 + 2), _derivative_symbols, 0, ",");
180  return;
181  }
182  }
183  }
184 
185  mooseError("Malformed material_properties expression '", expression, "'");
186 }
void tokenize(const std::string &str, std::vector< T > &elements, unsigned int min_len=1, const std::string &delims="/")
This function will split the passed in string on a set of delimiters appending the substrings to the ...
Definition: MooseUtils.h:779
std::string _base_name
function material property base name
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:284
enum FunctionMaterialPropertyDescriptor::PropertyState _state
void updatePropertyName()
update the cached _property_name member

◆ parseVector()

template<bool is_ad>
std::vector< FunctionMaterialPropertyDescriptor< is_ad > > FunctionMaterialPropertyDescriptor< is_ad >::parseVector ( const std::vector< std::string > &  expression_list,
MooseObject parent 
)
static

construct a vector of FunctionMaterialPropertyDescriptors from a vector of strings

Definition at line 83 of file FunctionMaterialPropertyDescriptor.C.

85 {
86  std::vector<FunctionMaterialPropertyDescriptor> fmpds;
87  for (auto & ex : expression_list)
88  fmpds.push_back(FunctionMaterialPropertyDescriptor(ex, parent));
89  return fmpds;
90 }
FunctionMaterialPropertyDescriptor()=delete
no default constructor

◆ printDebug()

template<bool is_ad>
void FunctionMaterialPropertyDescriptor< is_ad >::printDebug ( )

output the internal state of this descriptor for debugging purposes

Definition at line 219 of file FunctionMaterialPropertyDescriptor.C.

220 {
221  Moose::out << "MPD: " << _fparser_name << ' ' << _base_name << " deriv = [";
222  for (auto & dv : _derivative_symbols)
223  Moose::out << dv << ' ';
224  Moose::out << "] dep = [";
225  for (auto & dv : _dependent_symbols)
226  Moose::out << dv << ' ';
227  Moose::out << "] " << getPropertyName() << '\n';
228 }
std::string _base_name
function material property base name
std::string _fparser_name
name used in function expression
const std::string & getPropertyName() const
get the property name

◆ propertyName()

const MaterialPropertyName DerivativeMaterialPropertyNameInterface::propertyName ( const MaterialPropertyName &  base,
const std::vector< SymbolName > &  c 
) const
inlineinherited

aliases for the deprecated old function names

Definition at line 59 of file DerivativeMaterialPropertyNameInterface.h.

61  {
62  mooseDeprecated("This function was renamed to 'derivativePropertyName'");
63  return derivativePropertyName(base, c);
64  }
const MaterialPropertyName derivativePropertyName(const MaterialPropertyName &base, const std::vector< SymbolName > &c) const
Helper functions to generate the material property names for the arbitrary derivatives.
void mooseDeprecated(Args &&... args)
Emit a deprecated code/feature message with the given stringified, concatenated args.
Definition: MooseError.h:313

◆ propertyNameFirst()

const MaterialPropertyName DerivativeMaterialPropertyNameInterface::propertyNameFirst ( const MaterialPropertyName &  base,
const SymbolName c1 
) const
inlineinherited

Definition at line 65 of file DerivativeMaterialPropertyNameInterface.h.

67  {
68  mooseDeprecated("This function was renamed to 'derivativePropertyNameFirst'");
69  return derivativePropertyNameFirst(base, c1);
70  }
const MaterialPropertyName derivativePropertyNameFirst(const MaterialPropertyName &base, const SymbolName &c1) const
Helper functions to generate the material property names for the first derivatives.
void mooseDeprecated(Args &&... args)
Emit a deprecated code/feature message with the given stringified, concatenated args.
Definition: MooseError.h:313

◆ propertyNameSecond()

const MaterialPropertyName DerivativeMaterialPropertyNameInterface::propertyNameSecond ( const MaterialPropertyName &  base,
const SymbolName c1,
const SymbolName c2 
) const
inlineinherited

Definition at line 71 of file DerivativeMaterialPropertyNameInterface.h.

74  {
75  mooseDeprecated("This function was renamed to 'derivativePropertyNameSecond'");
76  return derivativePropertyNameSecond(base, c1, c2);
77  }
const MaterialPropertyName derivativePropertyNameSecond(const MaterialPropertyName &base, const SymbolName &c1, const SymbolName &c2) const
Helper functions to generate the material property names for the second derivatives.
void mooseDeprecated(Args &&... args)
Emit a deprecated code/feature message with the given stringified, concatenated args.
Definition: MooseError.h:313

◆ propertyNameThird()

const MaterialPropertyName DerivativeMaterialPropertyNameInterface::propertyNameThird ( const MaterialPropertyName &  base,
const SymbolName c1,
const SymbolName c2,
const SymbolName c3 
) const
inlineinherited

Definition at line 78 of file DerivativeMaterialPropertyNameInterface.h.

82  {
83  mooseDeprecated("This function was renamed to 'derivativePropertyNameThird'");
84  return derivativePropertyNameThird(base, c1, c2, c3);
85  }
void mooseDeprecated(Args &&... args)
Emit a deprecated code/feature message with the given stringified, concatenated args.
Definition: MooseError.h:313
const MaterialPropertyName derivativePropertyNameThird(const MaterialPropertyName &base, const SymbolName &c1, const SymbolName &c2, const SymbolName &c3) const
Helper functions to generate the material property names for the third derivatives.

◆ setSymbolName()

template<bool is_ad>
void FunctionMaterialPropertyDescriptor< is_ad >::setSymbolName ( const std::string &  n)
inline

set the fparser symbol name

Definition at line 65 of file FunctionMaterialPropertyDescriptor.h.

Referenced by DerivativeParsedMaterialHelperTempl< is_ad >::recurseMatProps().

65 { _fparser_name = n; };
std::string _fparser_name
name used in function expression

◆ updatePropertyName()

template<bool is_ad>
void FunctionMaterialPropertyDescriptor< is_ad >::updatePropertyName ( )

update the cached _property_name member

Definition at line 291 of file FunctionMaterialPropertyDescriptor.C.

Referenced by FunctionMaterialPropertyDescriptor< is_ad >::FunctionMaterialPropertyDescriptor().

292 {
294 }
std::string _base_name
function material property base name
std::string _property_name
cache the final property name of the derivative
const MaterialPropertyName derivativePropertyName(const MaterialPropertyName &base, const std::vector< SymbolName > &c) const
Helper functions to generate the material property names for the arbitrary derivatives.

◆ value()

template<bool is_ad>
GenericReal< is_ad > FunctionMaterialPropertyDescriptor< is_ad >::value ( unsigned int  qp = libMesh::invalid_uint) const

get the property value at the given quadrature point

Definition at line 232 of file FunctionMaterialPropertyDescriptor.C.

233 {
234  // current property
236  {
237  if (_value == nullptr)
238  {
239  DerivativeMaterialInterface<Material> * _material_parent =
241  DerivativeMaterialInterface<Kernel> * _kernel_parent =
243 
244  // property name
246 
247  // get the material property reference
248  if (_material_parent)
249  _value = _required ? &(_material_parent->getGenericMaterialProperty<Real, is_ad>(name))
250  : &(_material_parent->getGenericZeroMaterialProperty<Real, is_ad>(name));
251  else if (_kernel_parent)
252  _value = _required ? &(_kernel_parent->getGenericMaterialProperty<Real, is_ad>(name))
253  : &(_kernel_parent->getGenericZeroMaterialProperty<Real, is_ad>(name));
254  else
255  mooseError("A FunctionMaterialPropertyDescriptor must be owned by either a Material or a "
256  "Kernel object.");
257  }
258 
259  return qp != libMesh::invalid_uint ? (*_value)[qp] : 0.0;
260  }
261 
262  // old or older property
263  if (_old_older_value == nullptr)
264  {
265  mooseAssert(_derivative_symbols.empty(), "Don't take derivatives of old/older properties.");
266 
267  DerivativeMaterialInterface<Material> * _material_parent =
269  DerivativeMaterialInterface<Kernel> * _kernel_parent =
271 
272  // get the material property reference
273  if (_material_parent)
275  ? &(_material_parent->getMaterialPropertyOld<Real>(_base_name))
276  : &(_material_parent->getMaterialPropertyOlder<Real>(_base_name));
277  else if (_kernel_parent)
279  ? &(_kernel_parent->getMaterialPropertyOld<Real>(_base_name))
280  : &(_kernel_parent->getMaterialPropertyOlder<Real>(_base_name));
281  else
282  mooseError("A FunctionMaterialPropertyDescriptor must be owned by either a Material or a "
283  "Kernel object.");
284  }
285 
286  return qp != libMesh::invalid_uint ? (*_old_older_value)[qp] : 0.0;
287 }
std::string name(const ElemQuality q)
bool _required
is this a property that was directly specified by the user? Then it must exist.
std::string _base_name
function material property base name
const unsigned int invalid_uint
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:284
const MaterialPropertyName derivativePropertyName(const MaterialPropertyName &base, const std::vector< SymbolName > &c) const
Helper functions to generate the material property names for the arbitrary derivatives.
enum FunctionMaterialPropertyDescriptor::PropertyState _state
const MaterialProperty< Real > * _old_older_value
old/older material property value (this is lazily updated and cached when read through value()) ...
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
MooseObject * _parent
material object that owns this descriptor
const GenericMaterialProperty< Real, is_ad > * _value
material property value (this is lazily updated and cached when read through value()) ...
const GenericMaterialProperty< T, is_ad > & getGenericMaterialProperty(const std::string &name, const unsigned int state=0)
Retrieve the property through a given input parameter key with a fallback to getting it by name...
Definition: Material.h:263

Member Data Documentation

◆ _base_name

template<bool is_ad>
std::string FunctionMaterialPropertyDescriptor< is_ad >::_base_name
private

function material property base name

Definition at line 108 of file FunctionMaterialPropertyDescriptor.h.

Referenced by FunctionMaterialPropertyDescriptor< is_ad >::FunctionMaterialPropertyDescriptor().

◆ _dependent_symbols

template<bool is_ad>
std::vector<SymbolName> FunctionMaterialPropertyDescriptor< is_ad >::_dependent_symbols
private

Definition at line 110 of file FunctionMaterialPropertyDescriptor.h.

◆ _derivative_symbols

template<bool is_ad>
std::vector<SymbolName> FunctionMaterialPropertyDescriptor< is_ad >::_derivative_symbols
private

Definition at line 111 of file FunctionMaterialPropertyDescriptor.h.

◆ _fparser_name

template<bool is_ad>
std::string FunctionMaterialPropertyDescriptor< is_ad >::_fparser_name
private

◆ _old_older_value

template<bool is_ad>
const MaterialProperty<Real>* FunctionMaterialPropertyDescriptor< is_ad >::_old_older_value
mutableprivate

old/older material property value (this is lazily updated and cached when read through value())

Definition at line 117 of file FunctionMaterialPropertyDescriptor.h.

◆ _parent

template<bool is_ad>
MooseObject* FunctionMaterialPropertyDescriptor< is_ad >::_parent
private

material object that owns this descriptor

Definition at line 120 of file FunctionMaterialPropertyDescriptor.h.

◆ _property_name

template<bool is_ad>
std::string FunctionMaterialPropertyDescriptor< is_ad >::_property_name
private

cache the final property name of the derivative

Definition at line 123 of file FunctionMaterialPropertyDescriptor.h.

Referenced by FunctionMaterialPropertyDescriptor< is_ad >::getPropertyName().

◆ _required

template<bool is_ad>
bool FunctionMaterialPropertyDescriptor< is_ad >::_required
private

is this a property that was directly specified by the user? Then it must exist.

Definition at line 126 of file FunctionMaterialPropertyDescriptor.h.

◆ _state

◆ _value

template<bool is_ad>
const GenericMaterialProperty<Real, is_ad>* FunctionMaterialPropertyDescriptor< is_ad >::_value
mutableprivate

material property value (this is lazily updated and cached when read through value())

Definition at line 114 of file FunctionMaterialPropertyDescriptor.h.


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