www.mooseframework.org
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
CompositeTensorBase< T, U > Class Template Reference

CompositeTensorBase computes a simple T type MaterialProperty \( \bar T\) that is summed up from a list of other T objects (tensors) \( T_i \) with associated weights \( w_i \). More...

#include <CompositeTensorBase.h>

Inheritance diagram for CompositeTensorBase< T, U >:
[legend]

Public Types

typedef DerivativeMaterialPropertyNameInterface::SymbolName SymbolName
 

Public Member Functions

 CompositeTensorBase (const InputParameters &parameters)
 
const GenericMaterialProperty< U, is_ad > & getDefaultMaterialProperty (const std::string &name)
 Fetch a material property if it exists, otherwise return getZeroMaterialProperty. More...
 
const GenericMaterialProperty< U, is_ad > & getDefaultMaterialPropertyByName (const std::string &name)
 Fetch a material property by name if it exists, otherwise return getZeroMaterialProperty. More...
 
void validateDerivativeMaterialPropertyBase (const std::string &base)
 Check if the material property base exists. 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...
 
GenericMaterialProperty< U, is_ad > & declarePropertyDerivative (const std::string &base, const std::vector< VariableName > &c)
 Methods for declaring derivative material properties. More...
 
GenericMaterialProperty< U, is_ad > & declarePropertyDerivative (const std::string &base, const std::vector< SymbolName > &c)
 
GenericMaterialProperty< U, is_ad > & declarePropertyDerivative (const std::string &base, const SymbolName &c1, const SymbolName &c2="", const SymbolName &c3="")
 
const GenericMaterialProperty< U, is_ad > & getMaterialPropertyDerivative (const std::string &base, const std::vector< VariableName > &c)
 Methods for retrieving derivative material properties. More...
 
const GenericMaterialProperty< U, is_ad > & getMaterialPropertyDerivative (const std::string &base, const std::vector< SymbolName > &c)
 
const GenericMaterialProperty< U, is_ad > & getMaterialPropertyDerivative (const std::string &base, const SymbolName &c1, const SymbolName &c2="", const SymbolName &c3="")
 
const GenericMaterialProperty< U, is_ad > & getMaterialPropertyDerivative (const std::string &base, const SymbolName &c1, unsigned int v2, unsigned int v3=libMesh::invalid_uint)
 Convenience methods for retrieving derivative material properties based on a mix of variable names c and indices v into the _coupled_standard_moose_vars vector. More...
 
const GenericMaterialProperty< U, is_ad > & getMaterialPropertyDerivative (const std::string &base, unsigned int v1, unsigned int v2=libMesh::invalid_uint, unsigned int v3=libMesh::invalid_uint)
 
const GenericMaterialProperty< U, is_ad > & getMaterialPropertyDerivativeByName (const MaterialPropertyName &base, const std::vector< VariableName > &c)
 Methods for retrieving derivative material properties. More...
 
const GenericMaterialProperty< U, is_ad > & getMaterialPropertyDerivativeByName (const MaterialPropertyName &base, const std::vector< SymbolName > &c)
 
const GenericMaterialProperty< U, is_ad > & getMaterialPropertyDerivativeByName (const MaterialPropertyName &base, const SymbolName &c1, const SymbolName &c2="", const SymbolName &c3="")
 
void validateCoupling (const MaterialPropertyName &base, const std::vector< VariableName > &c, bool validate_aux=true)
 check if derivatives of the passed in material property exist w.r.t a variable that is not coupled in to the current object More...
 
void validateCoupling (const MaterialPropertyName &base, const VariableName &c1="", const VariableName &c2="", const VariableName &c3="")
 
void validateNonlinearCoupling (const MaterialPropertyName &base, const VariableName &c1="", const VariableName &c2="", const VariableName &c3="")
 
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 InputParameters validParams ()
 

Protected Member Functions

void initializeDerivativeProperties (const std::string name)
 Output material properties are initialized here so that derived classes can modify the name. More...
 
virtual void computeQpTensorProperties (MaterialProperty< T > &M, Real derivative_prefactor=1.0)
 Fill in the. More...
 

Protected Attributes

std::vector< MaterialPropertyName > _tensor_names
 component tensor names More...
 
std::vector< MaterialPropertyName > _weight_names
 component weight names More...
 
unsigned int _num_args
 number of dependent variables More...
 
unsigned int _num_comp
 number of compomemt tensors and weights More...
 
std::vector< MaterialProperty< T > * > _dM
 Composed tensor and its derivatives. More...
 
std::vector< std::vector< MaterialProperty< T > * > > _d2M
 
std::vector< const MaterialProperty< T > * > _tensors
 component tensors and their derivatives w.r.t. the args More...
 
std::vector< std::vector< const MaterialProperty< T > * > > _dtensors
 
std::vector< std::vector< std::vector< const MaterialProperty< T > * > > > _d2tensors
 
std::vector< const MaterialProperty< Real > * > _weights
 component weights and their derivatives w.r.t. the args More...
 
std::vector< std::vector< const MaterialProperty< Real > * > > _dweights
 
std::vector< std::vector< std::vector< const MaterialProperty< Real > * > > > _d2weights
 

Detailed Description

template<class T, class U>
class CompositeTensorBase< T, U >

CompositeTensorBase computes a simple T type MaterialProperty \( \bar T\) that is summed up from a list of other T objects (tensors) \( T_i \) with associated weights \( w_i \).

\( \bar T = \sum_i T_i\cdot w_i \) Derivatives w.r.t. variables are computed accordingly. This base class is used by the CompositeMobilityTensor and CompositeElasticityTensor classes.

Template Parameters
TThe type of the objects to sum together

Definition at line 27 of file CompositeTensorBase.h.

Member Typedef Documentation

◆ SymbolName

Definition at line 35 of file DerivativeMaterialInterface.h.

Constructor & Destructor Documentation

◆ CompositeTensorBase()

template<class T , class U >
CompositeTensorBase< T, U >::CompositeTensorBase ( const InputParameters parameters)

Definition at line 81 of file CompositeTensorBase.h.

82  : DerivativeMaterialInterface<U>(parameters),
83  _tensor_names(this->template getParam<std::vector<MaterialPropertyName>>("tensors")),
84  _weight_names(this->template getParam<std::vector<MaterialPropertyName>>("weights")),
87  : this->DerivativeMaterialInterface<U>::coupledComponents("coupled_variables")),
88  _num_comp(_tensor_names.size()),
89  _dM(_num_args),
90  _d2M(_num_args),
97 {
98  if (_num_comp != _weight_names.size())
99  mooseError("The number of supplied 'tensors' and 'weights' must match.");
100 }
std::vector< const MaterialProperty< Real > * > _weights
component weights and their derivatives w.r.t. the args
std::vector< MaterialProperty< T > * > _dM
Composed tensor and its derivatives.
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:284
std::vector< MaterialPropertyName > _weight_names
component weight names
std::vector< std::vector< std::vector< const MaterialProperty< Real > * > > > _d2weights
std::vector< const MaterialProperty< T > * > _tensors
component tensors and their derivatives w.r.t. the args
std::vector< std::vector< const MaterialProperty< T > * > > _dtensors
unsigned int _num_comp
number of compomemt tensors and weights
std::vector< std::vector< const MaterialProperty< Real > * > > _dweights
unsigned int _num_args
number of dependent variables
std::vector< std::vector< MaterialProperty< T > * > > _d2M
std::vector< MaterialPropertyName > _tensor_names
component tensor names
std::vector< std::vector< std::vector< const MaterialProperty< T > * > > > _d2tensors

Member Function Documentation

◆ computeQpTensorProperties()

template<class T , class U >
void CompositeTensorBase< T, U >::computeQpTensorProperties ( MaterialProperty< T > &  M,
Real  derivative_prefactor = 1.0 
)
protectedvirtual

Fill in the.

  • main tensor property given by M
  • derivatives, set up by initializeDerivativeProperties

The root_property is kept separate from the derivatives to allow the application of this template to the Eigenstrain calculation, which contributes derivatives to a different material property (and uses a derivative_prefactor of -1).

Definition at line 175 of file CompositeTensorBase.h.

177 {
178  const unsigned int qp = this->DerivativeMaterialInterface<U>::_qp;
179 
180  M[qp].zero();
181  for (unsigned int i = 0; i < _num_comp; ++i)
182  {
183  M[qp] += (*_tensors[i])[qp] * (*_weights[i])[qp];
184 
185  for (unsigned int j = 0; j < _num_args; ++j)
186  {
187  if (i == 0)
188  (*_dM[j])[qp].zero();
189 
190  (*_dM[j])[qp] += derivative_prefactor * ((*_tensors[i])[qp] * (*_dweights[i][j])[qp] +
191  (*_dtensors[i][j])[qp] * (*_weights[i])[qp]);
192 
193  for (unsigned int k = 0; k <= j; ++k)
194  {
195  if (i == 0)
196  (*_d2M[j][k])[qp].zero();
197 
198  (*_d2M[j][k])[qp] +=
199  derivative_prefactor * (2.0 * (*_dtensors[i][j])[qp] * (*_dweights[i][j])[qp] +
200  (*_tensors[i])[qp] * (*_d2weights[i][j][k])[qp] +
201  (*_d2tensors[i][j][k])[qp] * (*_weights[i])[qp]);
202  }
203  }
204  }
205 }
std::vector< const MaterialProperty< Real > * > _weights
component weights and their derivatives w.r.t. the args
std::vector< MaterialProperty< T > * > _dM
Composed tensor and its derivatives.
const Number zero
std::vector< std::vector< std::vector< const MaterialProperty< Real > * > > > _d2weights
std::vector< const MaterialProperty< T > * > _tensors
component tensors and their derivatives w.r.t. the args
std::vector< std::vector< const MaterialProperty< T > * > > _dtensors
unsigned int _num_comp
number of compomemt tensors and weights
Interface class ("Veneer") to provide generator methods for derivative material property names...
std::vector< std::vector< const MaterialProperty< Real > * > > _dweights
unsigned int _num_args
number of dependent variables
std::vector< std::vector< MaterialProperty< T > * > > _d2M
std::vector< std::vector< std::vector< const MaterialProperty< T > * > > > _d2tensors

◆ declarePropertyDerivative() [1/3]

GenericMaterialProperty< U, is_ad > & DerivativeMaterialInterface< U >::declarePropertyDerivative ( const std::string &  base,
const std::vector< VariableName > &  c 
)
inherited

Methods for declaring derivative material properties.

Template Parameters
UThe material property type
Parameters
baseThe name of the property to take the derivative of
cThe variable(s) to take the derivatives with respect to

Definition at line 258 of file DerivativeMaterialInterface.h.

260 {
261  std::vector<SymbolName> symbol_vector(c.begin(), c.end());
262  return declarePropertyDerivative<U, is_ad>(base, symbol_vector);
263 }

◆ declarePropertyDerivative() [2/3]

GenericMaterialProperty< U, is_ad > & DerivativeMaterialInterface< U >::declarePropertyDerivative ( const std::string &  base,
const std::vector< SymbolName > &  c 
)
inherited

Definition at line 268 of file DerivativeMaterialInterface.h.

270 {
271  return this->template declareGenericProperty<U, is_ad>(derivativePropertyName(base, c));
272 }
const MaterialPropertyName derivativePropertyName(const MaterialPropertyName &base, const std::vector< SymbolName > &c) const
Helper functions to generate the material property names for the arbitrary derivatives.

◆ declarePropertyDerivative() [3/3]

GenericMaterialProperty< U, is_ad > & DerivativeMaterialInterface< U >::declarePropertyDerivative ( const std::string &  base,
const SymbolName c1,
const SymbolName c2 = "",
const SymbolName c3 = "" 
)
inherited

Definition at line 277 of file DerivativeMaterialInterface.h.

281 {
282  if (c3 != "")
283  return this->template declareGenericProperty<U, is_ad>(
284  derivativePropertyNameThird(base, c1, c2, c3));
285  if (c2 != "")
286  return this->template declareGenericProperty<U, is_ad>(
287  derivativePropertyNameSecond(base, c1, c2));
288  return this->template declareGenericProperty<U, is_ad>(derivativePropertyNameFirst(base, c1));
289 }
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.
const MaterialPropertyName derivativePropertyNameFirst(const MaterialPropertyName &base, const SymbolName &c1) const
Helper functions to generate the material property names for the first derivatives.
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.

◆ 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.

◆ getDefaultMaterialProperty()

const GenericMaterialProperty< U, is_ad > & DerivativeMaterialInterface< U >::getDefaultMaterialProperty ( const std::string &  name)
inherited

Fetch a material property if it exists, otherwise return getZeroMaterialProperty.

Parameters
nameThe input parameter key of type MaterialPropertyName

Definition at line 231 of file DerivativeMaterialInterface.h.

232 {
233  // get the base property name
234  std::string prop_name = this->getMaterialPropertyName(name);
235 
236  // Check if it's just a constant
237  const auto * default_property =
238  this->template defaultGenericMaterialProperty<U, is_ad>(prop_name);
239  if (default_property)
240  return *default_property;
241 
242  // if found return the requested property
243  return this->template getGenericZeroMaterialPropertyByName<U, is_ad>(prop_name);
244 }

◆ getDefaultMaterialPropertyByName()

const GenericMaterialProperty< U, is_ad > & DerivativeMaterialInterface< U >::getDefaultMaterialPropertyByName ( const std::string &  name)
inherited

Fetch a material property by name if it exists, otherwise return getZeroMaterialProperty.

Definition at line 249 of file DerivativeMaterialInterface.h.

250 {
251  // TODO: deprecate this
252  return this->template getGenericZeroMaterialPropertyByName<U, is_ad>(prop_name);
253 }

◆ getMaterialPropertyDerivative() [1/5]

const GenericMaterialProperty< U, is_ad > & DerivativeMaterialInterface< U >::getMaterialPropertyDerivative ( const std::string &  base,
const std::vector< VariableName > &  c 
)
inherited

Methods for retrieving derivative material properties.

Template Parameters
UThe material property type
Parameters
baseThe name of the property to take the derivative of
cThe variable(s) to take the derivatives with respect to

Definition at line 294 of file DerivativeMaterialInterface.h.

296 {
297  std::vector<SymbolName> symbol_vector(c.begin(), c.end());
298  return getMaterialPropertyDerivative(base, symbol_vector);
299 }
const GenericMaterialProperty< U, is_ad > & getMaterialPropertyDerivative(const std::string &base, const std::vector< VariableName > &c)
Methods for retrieving derivative material properties.

◆ getMaterialPropertyDerivative() [2/5]

const GenericMaterialProperty< U, is_ad > & DerivativeMaterialInterface< U >::getMaterialPropertyDerivative ( const std::string &  base,
const std::vector< SymbolName > &  c 
)
inherited

Check if base is a default property and shortcut to returning zero, as derivatives of constants are zero.

Definition at line 304 of file DerivativeMaterialInterface.h.

306 {
307  // get the base property name
308  std::string prop_name = this->getMaterialPropertyName(base);
309 
314  if (this->template defaultGenericMaterialProperty<U, is_ad>(prop_name))
315  return this->template getGenericZeroMaterialProperty<U, is_ad>();
316 
317  return this->template getGenericZeroMaterialPropertyByName<U, is_ad>(
318  derivativePropertyName(prop_name, c));
319 }
const MaterialPropertyName derivativePropertyName(const MaterialPropertyName &base, const std::vector< SymbolName > &c) const
Helper functions to generate the material property names for the arbitrary derivatives.

◆ getMaterialPropertyDerivative() [3/5]

const GenericMaterialProperty< U, is_ad > & DerivativeMaterialInterface< U >::getMaterialPropertyDerivative ( const std::string &  base,
const SymbolName c1,
const SymbolName c2 = "",
const SymbolName c3 = "" 
)
inherited

Check if base is a default property and shortcut to returning zero, as derivatives of constants are zero.

Definition at line 324 of file DerivativeMaterialInterface.h.

328 {
329  // get the base property name
330  std::string prop_name = this->getMaterialPropertyName(base);
331 
336  if (this->template defaultGenericMaterialProperty<U, is_ad>(prop_name))
337  return this->template getGenericZeroMaterialProperty<U, is_ad>();
338 
339  if (c3 != "")
340  return this->template getGenericZeroMaterialPropertyByName<U, is_ad>(
341  derivativePropertyNameThird(prop_name, c1, c2, c3));
342  if (c2 != "")
343  return this->template getGenericZeroMaterialPropertyByName<U, is_ad>(
344  derivativePropertyNameSecond(prop_name, c1, c2));
345  return this->template getGenericZeroMaterialPropertyByName<U, is_ad>(
346  derivativePropertyNameFirst(prop_name, c1));
347 }
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.
const MaterialPropertyName derivativePropertyNameFirst(const MaterialPropertyName &base, const SymbolName &c1) const
Helper functions to generate the material property names for the first derivatives.
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.

◆ getMaterialPropertyDerivative() [4/5]

const GenericMaterialProperty< U, is_ad > & DerivativeMaterialInterface< U >::getMaterialPropertyDerivative ( const std::string &  base,
const SymbolName c1,
unsigned int  v2,
unsigned int  v3 = libMesh::invalid_uint 
)
inherited

Convenience methods for retrieving derivative material properties based on a mix of variable names c and indices v into the _coupled_standard_moose_vars vector.

Definition at line 352 of file DerivativeMaterialInterface.h.

356 {
357  return getMaterialPropertyDerivative<U, is_ad>(
358  base,
359  c1,
360  this->_coupled_standard_moose_vars[v2]->name(),
361  v3 == libMesh::invalid_uint ? "" : this->_coupled_standard_moose_vars[v3]->name());
362 }
const unsigned int invalid_uint

◆ getMaterialPropertyDerivative() [5/5]

const GenericMaterialProperty< U, is_ad > & DerivativeMaterialInterface< U >::getMaterialPropertyDerivative ( const std::string &  base,
unsigned int  v1,
unsigned int  v2 = libMesh::invalid_uint,
unsigned int  v3 = libMesh::invalid_uint 
)
inherited

Definition at line 367 of file DerivativeMaterialInterface.h.

371 {
372  return getMaterialPropertyDerivative<U, is_ad>(
373  base,
374  this->_coupled_standard_moose_vars[v1]->name(),
375  v2 == libMesh::invalid_uint ? "" : this->_coupled_standard_moose_vars[v2]->name(),
376  v3 == libMesh::invalid_uint ? "" : this->_coupled_standard_moose_vars[v3]->name());
377 }
const unsigned int invalid_uint

◆ getMaterialPropertyDerivativeByName() [1/3]

const GenericMaterialProperty< U, is_ad > & DerivativeMaterialInterface< U >::getMaterialPropertyDerivativeByName ( const MaterialPropertyName &  base,
const std::vector< VariableName > &  c 
)
inherited

Methods for retrieving derivative material properties.

Template Parameters
UThe material property type
Parameters
baseThe name of the property to take the derivative of
cThe variable(s) to take the derivatives with respect to

Definition at line 382 of file DerivativeMaterialInterface.h.

384 {
385  std::vector<SymbolName> symbol_vector(c.begin(), c.end());
386  return getMaterialPropertyDerivativeByName(base, symbol_vector);
387 }
const GenericMaterialProperty< U, is_ad > & getMaterialPropertyDerivativeByName(const MaterialPropertyName &base, const std::vector< VariableName > &c)
Methods for retrieving derivative material properties.

◆ getMaterialPropertyDerivativeByName() [2/3]

const GenericMaterialProperty< U, is_ad > & DerivativeMaterialInterface< U >::getMaterialPropertyDerivativeByName ( const MaterialPropertyName &  base,
const std::vector< SymbolName > &  c 
)
inherited

Definition at line 392 of file DerivativeMaterialInterface.h.

394 {
395  return this->template getGenericZeroMaterialPropertyByName<U, is_ad>(
396  derivativePropertyName(base, c));
397 }
const MaterialPropertyName derivativePropertyName(const MaterialPropertyName &base, const std::vector< SymbolName > &c) const
Helper functions to generate the material property names for the arbitrary derivatives.

◆ getMaterialPropertyDerivativeByName() [3/3]

const GenericMaterialProperty< U, is_ad > & DerivativeMaterialInterface< U >::getMaterialPropertyDerivativeByName ( const MaterialPropertyName &  base,
const SymbolName c1,
const SymbolName c2 = "",
const SymbolName c3 = "" 
)
inherited

Definition at line 402 of file DerivativeMaterialInterface.h.

407 {
408  if (c3 != "")
409  return this->template getGenericZeroMaterialPropertyByName<U, is_ad>(
410  derivativePropertyNameThird(base, c1, c2, c3));
411  if (c2 != "")
412  return this->template getGenericZeroMaterialPropertyByName<U, is_ad>(
413  derivativePropertyNameSecond(base, c1, c2));
414  return this->template getGenericZeroMaterialPropertyByName<U, is_ad>(
415  derivativePropertyNameFirst(base, c1));
416 }
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.
const MaterialPropertyName derivativePropertyNameFirst(const MaterialPropertyName &base, const SymbolName &c1) const
Helper functions to generate the material property names for the first derivatives.
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.

◆ initializeDerivativeProperties()

template<class T , class U >
void CompositeTensorBase< T, U >::initializeDerivativeProperties ( const std::string  name)
protected

Output material properties are initialized here so that derived classes can modify the name.

Definition at line 116 of file CompositeTensorBase.h.

117 {
118  // setup output composite tensor and derivatives
119  for (unsigned int j = 0; j < _num_args; ++j)
120  {
121  const VariableName & jname =
122  this->DerivativeMaterialInterface<U>::getVar("coupled_variables", j)->name();
123  _dM[j] = &this->template declarePropertyDerivative<T>(name, jname);
124  _d2M[j].resize(j + 1);
125 
126  for (unsigned int k = 0; k <= j; ++k)
127  {
128  const VariableName & kname =
129  this->DerivativeMaterialInterface<U>::getVar("coupled_variables", k)->name();
130 
131  _d2M[j][k] = &this->template declarePropertyDerivative<T>(name, jname, kname);
132  }
133  }
134 
135  // setup input components and its derivatives
136  for (unsigned int i = 0; i < _num_comp; ++i)
137  {
138  _tensors[i] = &this->template getMaterialPropertyByName<T>(_tensor_names[i]);
139  _weights[i] = &this->template getMaterialPropertyByName<Real>(_weight_names[i]);
140 
141  _dtensors[i].resize(_num_args);
142  _dweights[i].resize(_num_args);
143  _d2tensors[i].resize(_num_args);
144  _d2weights[i].resize(_num_args);
145 
146  for (unsigned int j = 0; j < _num_args; ++j)
147  {
148  const VariableName & jname =
149  this->DerivativeMaterialInterface<U>::getVar("coupled_variables", j)->name();
150 
151  _dtensors[i][j] =
152  &this->template getMaterialPropertyDerivativeByName<T>(_tensor_names[i], jname);
153  _dweights[i][j] =
154  &this->template getMaterialPropertyDerivativeByName<Real>(_weight_names[i], jname);
155 
156  _d2tensors[i][j].resize(j + 1);
157  _d2weights[i][j].resize(j + 1);
158 
159  for (unsigned int k = 0; k <= j; ++k)
160  {
161  const VariableName & kname =
162  this->DerivativeMaterialInterface<U>::getVar("coupled_variables", k)->name();
163 
164  _d2tensors[i][j][k] =
165  &this->template getMaterialPropertyDerivativeByName<T>(_tensor_names[i], jname, kname);
166  _d2weights[i][j][k] = &this->template getMaterialPropertyDerivativeByName<Real>(
167  _weight_names[i], jname, kname);
168  }
169  }
170  }
171 }
std::string name(const ElemQuality q)
std::vector< const MaterialProperty< Real > * > _weights
component weights and their derivatives w.r.t. the args
std::vector< MaterialProperty< T > * > _dM
Composed tensor and its derivatives.
std::vector< MaterialPropertyName > _weight_names
component weight names
std::vector< std::vector< std::vector< const MaterialProperty< Real > * > > > _d2weights
std::vector< const MaterialProperty< T > * > _tensors
component tensors and their derivatives w.r.t. the args
std::vector< std::vector< const MaterialProperty< T > * > > _dtensors
unsigned int _num_comp
number of compomemt tensors and weights
Interface class ("Veneer") to provide generator methods for derivative material property names...
std::vector< std::vector< const MaterialProperty< Real > * > > _dweights
unsigned int _num_args
number of dependent variables
std::vector< std::vector< MaterialProperty< T > * > > _d2M
std::vector< MaterialPropertyName > _tensor_names
component tensor names
std::vector< std::vector< std::vector< const MaterialProperty< T > * > > > _d2tensors

◆ 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.

◆ validateCoupling() [1/2]

void DerivativeMaterialInterface< U >::validateCoupling ( const MaterialPropertyName &  base,
const std::vector< VariableName > &  c,
bool  validate_aux = true 
)
inherited

check if derivatives of the passed in material property exist w.r.t a variable that is not coupled in to the current object

Definition at line 461 of file DerivativeMaterialInterface.h.

464 {
465  // get the base property name
466  std::string prop_name = this->getMaterialPropertyName(base);
467  // list of potentially missing coupled variables
468  std::vector<VariableName> missing;
469 
470  // iterate over all variables in the both the non-linear and auxiliary system (optional)
471  validateCouplingHelper<U, is_ad>(
472  prop_name, c, _dmi_fe_problem.getNonlinearSystemBase(/*nl_sys=*/0).system(), missing);
473  if (validate_aux)
474  validateCouplingHelper<U, is_ad>(
475  prop_name, c, _dmi_fe_problem.getAuxiliarySystem().system(), missing);
476 
477  if (missing.size() > 0)
478  {
479  // join list of missing variable names
480  std::string list = missing[0];
481  for (unsigned int i = 1; i < missing.size(); ++i)
482  list += ", " + missing[i];
483 
484  mooseWarning("Missing coupled variables {",
485  list,
486  "} (add them to coupled_variables parameter of ",
487  this->name(),
488  ")");
489  }
490 }
std::string name(const ElemQuality q)
void mooseWarning(Args &&... args)
Emit a warning message with the given stringified, concatenated args.
Definition: MooseError.h:296
FEProblemBase & _dmi_fe_problem
Reference to FEProblemBase.
NonlinearSystemBase & getNonlinearSystemBase(const unsigned int sys_num)
AuxiliarySystem & getAuxiliarySystem()
virtual System & system() override
Get the reference to the libMesh system.
virtual System & system() override
Get the reference to the libMesh system.

◆ validateCoupling() [2/2]

void DerivativeMaterialInterface< U >::validateCoupling ( const MaterialPropertyName &  base,
const VariableName &  c1 = "",
const VariableName &  c2 = "",
const VariableName &  c3 = "" 
)
inherited

Definition at line 515 of file DerivativeMaterialInterface.h.

519 {
520  validateCoupling<U, is_ad>(base, buildVariableVector(c1, c2, c3), true);
521 }
std::vector< VariableName > buildVariableVector(const VariableName &c1, const VariableName &c2, const VariableName &c3)
helper method to combine multiple VariableNames into a vector (if they are != "") ...

◆ validateDerivativeMaterialPropertyBase()

void DerivativeMaterialInterface< U >::validateDerivativeMaterialPropertyBase ( const std::string &  base)
inherited

Check if the material property base exists.

Print a warning if it doesn't. This is useful in materials that pull in only derivative properties, which are optional. If the base property name has a typo all derivatives will be set to zero without the user ever knowing.

Definition at line 537 of file DerivativeMaterialInterface.h.

538 {
539  // resolve the input parameter name base to the actual material property name
540  const MaterialPropertyName prop_name = this->template getParam<MaterialPropertyName>(base);
541 
542  // check if the material property does not exist on the blocks of the current object,
543  // and check if it is not a plain number in the input file
544  if (!haveMaterialProperty<U, is_ad>(prop_name) &&
545  this->template defaultGenericMaterialProperty<U, is_ad>(prop_name) == 0)
546  mooseWarning("The material property '",
547  prop_name,
548  "' does not exist. The kernel '",
549  this->name(),
550  "' only needs its derivatives, but this may indicate a typo in the input file.");
551 }
std::string name(const ElemQuality q)
void mooseWarning(Args &&... args)
Emit a warning message with the given stringified, concatenated args.
Definition: MooseError.h:296

◆ validateNonlinearCoupling()

void DerivativeMaterialInterface< U >::validateNonlinearCoupling ( const MaterialPropertyName &  base,
const VariableName &  c1 = "",
const VariableName &  c2 = "",
const VariableName &  c3 = "" 
)
inherited

Definition at line 526 of file DerivativeMaterialInterface.h.

530 {
531  validateCoupling<U, is_ad>(base, buildVariableVector(c1, c2, c3), false);
532 }
std::vector< VariableName > buildVariableVector(const VariableName &c1, const VariableName &c2, const VariableName &c3)
helper method to combine multiple VariableNames into a vector (if they are != "") ...

◆ validParams()

template<class T , class U >
InputParameters CompositeTensorBase< T, U >::validParams ( )
static

Definition at line 104 of file CompositeTensorBase.h.

105 {
106  InputParameters params = U::validParams();
107  params.addRequiredParam<std::vector<MaterialPropertyName>>("tensors", "Component tensors");
108  params.addRequiredParam<std::vector<MaterialPropertyName>>("weights", "Component weights");
109  params.addRequiredCoupledVar("args", "variable dependencies for the prefactor");
110  params.deprecateCoupledVar("args", "coupled_variables", "02/07/2024");
111  return params;
112 }
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
InputParameters validParams()
void addRequiredParam(const std::string &name, const std::string &doc_string)
This method adds a parameter and documentation string to the InputParameters object that will be extr...
void deprecateCoupledVar(const std::string &old_name, const std::string &new_name, const std::string &removal_date)
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
This method adds a coupled variable name pair.

Member Data Documentation

◆ _d2M

template<class T , class U >
std::vector<std::vector<MaterialProperty<T> *> > CompositeTensorBase< T, U >::_d2M
protected

Definition at line 64 of file CompositeTensorBase.h.

◆ _d2tensors

template<class T , class U >
std::vector<std::vector<std::vector<const MaterialProperty<T> *> > > CompositeTensorBase< T, U >::_d2tensors
protected

Definition at line 70 of file CompositeTensorBase.h.

◆ _d2weights

template<class T , class U >
std::vector<std::vector<std::vector<const MaterialProperty<Real> *> > > CompositeTensorBase< T, U >::_d2weights
protected

Definition at line 76 of file CompositeTensorBase.h.

◆ _dM

template<class T , class U >
std::vector<MaterialProperty<T> *> CompositeTensorBase< T, U >::_dM
protected

Composed tensor and its derivatives.

Definition at line 63 of file CompositeTensorBase.h.

◆ _dtensors

template<class T , class U >
std::vector<std::vector<const MaterialProperty<T> *> > CompositeTensorBase< T, U >::_dtensors
protected

Definition at line 69 of file CompositeTensorBase.h.

◆ _dweights

template<class T , class U >
std::vector<std::vector<const MaterialProperty<Real> *> > CompositeTensorBase< T, U >::_dweights
protected

Definition at line 75 of file CompositeTensorBase.h.

◆ _num_args

template<class T , class U >
unsigned int CompositeTensorBase< T, U >::_num_args
protected

number of dependent variables

Definition at line 58 of file CompositeTensorBase.h.

◆ _num_comp

template<class T , class U >
unsigned int CompositeTensorBase< T, U >::_num_comp
protected

number of compomemt tensors and weights

Definition at line 60 of file CompositeTensorBase.h.

Referenced by CompositeTensorBase< T, U >::CompositeTensorBase().

◆ _tensor_names

template<class T , class U >
std::vector<MaterialPropertyName> CompositeTensorBase< T, U >::_tensor_names
protected

component tensor names

Definition at line 53 of file CompositeTensorBase.h.

◆ _tensors

template<class T , class U >
std::vector<const MaterialProperty<T> *> CompositeTensorBase< T, U >::_tensors
protected

component tensors and their derivatives w.r.t. the args

Definition at line 68 of file CompositeTensorBase.h.

◆ _weight_names

template<class T , class U >
std::vector<MaterialPropertyName> CompositeTensorBase< T, U >::_weight_names
protected

component weight names

Definition at line 55 of file CompositeTensorBase.h.

Referenced by CompositeTensorBase< T, U >::CompositeTensorBase().

◆ _weights

template<class T , class U >
std::vector<const MaterialProperty<Real> *> CompositeTensorBase< T, U >::_weights
protected

component weights and their derivatives w.r.t. the args

Definition at line 74 of file CompositeTensorBase.h.


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