www.mooseframework.org
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 Member Functions

 CompositeTensorBase (const InputParameters &parameters)
 
const MaterialProperty< U > & getDefaultMaterialProperty (const std::string &name)
 Fetch a material property if it exists, otherwise return getZeroMaterialProperty. More...
 
const MaterialProperty< U > & 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 propertyName (const MaterialPropertyName &base, const std::vector< VariableName > &c) const
 Helper functions to generate the material property names for the arbitrary derivatives. More...
 
const MaterialPropertyName propertyNameFirst (const MaterialPropertyName &base, const VariableName &c1) const
 Helper functions to generate the material property names for the first derivatives. More...
 
const MaterialPropertyName propertyNameSecond (const MaterialPropertyName &base, const VariableName &c1, const VariableName &c2) const
 Helper functions to generate the material property names for the second derivatives. More...
 
const MaterialPropertyName propertyNameThird (const MaterialPropertyName &base, const VariableName &c1, const VariableName &c2, const VariableName &c3) const
 Helper functions to generate the material property names for the third derivatives. More...
 
MaterialProperty< U > & declarePropertyDerivative (const std::string &base, const std::vector< VariableName > &c)
 Methods for declaring derivative material properties. More...
 
MaterialProperty< U > & declarePropertyDerivative (const std::string &base, const VariableName &c1, const VariableName &c2="", const VariableName &c3="")
 
const MaterialProperty< U > & getMaterialPropertyDerivative (const std::string &base, const std::vector< VariableName > &c)
 Methods for retreiving derivative material properties. More...
 
const MaterialProperty< U > & getMaterialPropertyDerivative (const std::string &base, const VariableName &c1, const VariableName &c2="", const VariableName &c3="")
 
const MaterialProperty< U > & getMaterialPropertyDerivativeByName (const MaterialPropertyName &base, const std::vector< VariableName > &c)
 Methods for retreiving derivative material properties. More...
 
const MaterialProperty< U > & getMaterialPropertyDerivativeByName (const MaterialPropertyName &base, const VariableName &c1, const VariableName &c2="", const VariableName &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="")
 

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 25 of file CompositeTensorBase.h.

Constructor & Destructor Documentation

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

Definition at line 79 of file CompositeTensorBase.h.

80  : DerivativeMaterialInterface<U>(parameters),
81  _tensor_names(this->template getParam<std::vector<MaterialPropertyName>>("tensors")),
82  _weight_names(this->template getParam<std::vector<MaterialPropertyName>>("weights")),
84  _num_comp(_tensor_names.size()),
85  _dM(_num_args),
86  _d2M(_num_args),
93 {
94  if (_num_comp != _weight_names.size())
95  mooseError("The number of supplied 'tensors' and 'weights' must match.");
96 }
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
void mooseError(Args &&...args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:182
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

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 166 of file CompositeTensorBase.h.

168 {
169  const unsigned int qp = this->DerivativeMaterialInterface<U>::_qp;
170 
171  M[qp].zero();
172  for (unsigned int i = 0; i < _num_comp; ++i)
173  {
174  M[qp] += (*_tensors[i])[qp] * (*_weights[i])[qp];
175 
176  for (unsigned int j = 0; j < _num_args; ++j)
177  {
178  if (i == 0)
179  (*_dM[j])[qp].zero();
180 
181  (*_dM[j])[qp] += derivative_prefactor * ((*_tensors[i])[qp] * (*_dweights[i][j])[qp] +
182  (*_dtensors[i][j])[qp] * (*_weights[i])[qp]);
183 
184  for (unsigned int k = 0; k <= j; ++k)
185  {
186  if (i == 0)
187  (*_d2M[j][k])[qp].zero();
188 
189  (*_d2M[j][k])[qp] +=
190  derivative_prefactor * (2.0 * (*_dtensors[i][j])[qp] * (*_dweights[i][j])[qp] +
191  (*_tensors[i])[qp] * (*_d2weights[i][j][k])[qp] +
192  (*_d2tensors[i][j][k])[qp] * (*_weights[i])[qp]);
193  }
194  }
195  }
196 }
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< 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
MaterialProperty<U>& 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
MaterialProperty<U>& DerivativeMaterialInterface< U >::declarePropertyDerivative ( const std::string &  base,
const VariableName &  c1,
const VariableName &  c2 = "",
const VariableName &  c3 = "" 
)
inherited
const MaterialProperty<U>& 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
const MaterialProperty<U>& DerivativeMaterialInterface< U >::getDefaultMaterialPropertyByName ( const std::string &  name)
inherited

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

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

Methods for retreiving 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
const MaterialProperty<U>& DerivativeMaterialInterface< U >::getMaterialPropertyDerivative ( const std::string &  base,
const VariableName &  c1,
const VariableName &  c2 = "",
const VariableName &  c3 = "" 
)
inherited
const MaterialProperty<U>& DerivativeMaterialInterface< U >::getMaterialPropertyDerivativeByName ( const MaterialPropertyName &  base,
const std::vector< VariableName > &  c 
)
inherited

Methods for retreiving 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
const MaterialProperty<U>& DerivativeMaterialInterface< U >::getMaterialPropertyDerivativeByName ( const MaterialPropertyName &  base,
const VariableName &  c1,
const VariableName &  c2 = "",
const VariableName &  c3 = "" 
)
inherited
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 111 of file CompositeTensorBase.h.

112 {
113  // setup output composite tensor and derivatives
114  for (unsigned int j = 0; j < _num_args; ++j)
115  {
116  const VariableName & jname = this->DerivativeMaterialInterface<U>::getVar("args", j)->name();
117  _dM[j] = &this->template declarePropertyDerivative<T>(name, jname);
118  _d2M[j].resize(j + 1);
119 
120  for (unsigned int k = 0; k <= j; ++k)
121  {
122  const VariableName & kname = this->DerivativeMaterialInterface<U>::getVar("args", k)->name();
123  _d2M[j][k] = &this->template declarePropertyDerivative<T>(name, jname, kname);
124  }
125  }
126 
127  // setup input components and its derivatives
128  for (unsigned int i = 0; i < _num_comp; ++i)
129  {
130  _tensors[i] = &this->template getMaterialPropertyByName<T>(_tensor_names[i]);
131  _weights[i] = &this->template getMaterialPropertyByName<Real>(_weight_names[i]);
132 
133  _dtensors[i].resize(_num_args);
134  _dweights[i].resize(_num_args);
135  _d2tensors[i].resize(_num_args);
136  _d2weights[i].resize(_num_args);
137 
138  for (unsigned int j = 0; j < _num_args; ++j)
139  {
140  const VariableName & jname = this->DerivativeMaterialInterface<U>::getVar("args", j)->name();
141 
142  _dtensors[i][j] =
143  &this->template getMaterialPropertyDerivativeByName<T>(_tensor_names[i], jname);
144  _dweights[i][j] =
145  &this->template getMaterialPropertyDerivativeByName<Real>(_weight_names[i], jname);
146 
147  _d2tensors[i][j].resize(j + 1);
148  _d2weights[i][j].resize(j + 1);
149 
150  for (unsigned int k = 0; k <= j; ++k)
151  {
152  const VariableName & kname =
153  this->DerivativeMaterialInterface<U>::getVar("args", k)->name();
154 
155  _d2tensors[i][j][k] =
156  &this->template getMaterialPropertyDerivativeByName<T>(_tensor_names[i], jname, kname);
157  _d2weights[i][j][k] = &this->template getMaterialPropertyDerivativeByName<Real>(
158  _weight_names[i], jname, kname);
159  }
160  }
161  }
162 }
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
const MaterialPropertyName DerivativeMaterialPropertyNameInterface::propertyName ( const MaterialPropertyName &  base,
const std::vector< VariableName > &  c 
) const
inherited

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

Definition at line 7 of file DerivativeMaterialPropertyNameInterface.C.

Referenced by DerivativeMaterialInterface< T >::declarePropertyDerivative(), DerivativeMaterialInterface< T >::getMaterialPropertyDerivative(), DerivativeMaterialInterface< T >::getMaterialPropertyDerivativeByName(), MaterialDerivativeTestAction::MaterialDerivativeTestAction(), DerivativeMaterialPropertyNameInterface::propertyNameSecond(), DerivativeMaterialPropertyNameInterface::propertyNameThird(), and DerivativeMaterialInterface< T >::validateCouplingHelper().

9 {
10  // to obtain well defined names we sort alphabetically
11  std::vector<VariableName> a(c);
12  std::sort(a.begin(), a.end());
13 
14  // derivative order
15  unsigned int order = a.size();
16  if (order == 0)
17  return base;
18 
19  // build the property name as a stringstream
20  std::stringstream name;
21 
22  // build numerator
23  name << 'd';
24  if (order > 1)
25  name << '^' << order;
26  name << base << '/';
27 
28  // build denominator with 'pretty' names using exponents rather than repeat multiplication
29  unsigned int exponent = 1;
30  for (unsigned i = 1; i <= order; ++i)
31  {
32  if (i == order || a[i - 1] != a[i])
33  {
34  name << 'd' << a[i - 1];
35  if (exponent > 1)
36  name << '^' << exponent;
37  exponent = 1;
38  }
39  else
40  exponent++;
41  }
42 
43  return name.str();
44 }
const MaterialPropertyName DerivativeMaterialPropertyNameInterface::propertyNameFirst ( const MaterialPropertyName &  base,
const VariableName &  c1 
) const
inherited

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

Definition at line 47 of file DerivativeMaterialPropertyNameInterface.C.

Referenced by DerivativeMaterialInterface< T >::declarePropertyDerivative(), DerivativeMaterialInterface< T >::getMaterialPropertyDerivative(), and DerivativeMaterialInterface< T >::getMaterialPropertyDerivativeByName().

49 {
50  return "d" + base + "/d" + c1;
51 }
const MaterialPropertyName DerivativeMaterialPropertyNameInterface::propertyNameSecond ( const MaterialPropertyName &  base,
const VariableName &  c1,
const VariableName &  c2 
) const
inherited

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

Definition at line 54 of file DerivativeMaterialPropertyNameInterface.C.

Referenced by DerivativeMaterialInterface< T >::declarePropertyDerivative(), DerivativeMaterialInterface< T >::getMaterialPropertyDerivative(), and DerivativeMaterialInterface< T >::getMaterialPropertyDerivativeByName().

57 {
58  return propertyName(base, {c1, c2});
59 }
const MaterialPropertyName propertyName(const MaterialPropertyName &base, const std::vector< VariableName > &c) const
Helper functions to generate the material property names for the arbitrary derivatives.
const MaterialPropertyName DerivativeMaterialPropertyNameInterface::propertyNameThird ( const MaterialPropertyName &  base,
const VariableName &  c1,
const VariableName &  c2,
const VariableName &  c3 
) const
inherited

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

Definition at line 62 of file DerivativeMaterialPropertyNameInterface.C.

Referenced by DerivativeMaterialInterface< T >::declarePropertyDerivative(), DerivativeMaterialInterface< T >::getMaterialPropertyDerivative(), and DerivativeMaterialInterface< T >::getMaterialPropertyDerivativeByName().

66 {
67  return propertyName(base, {c1, c2, c3});
68 }
const MaterialPropertyName propertyName(const MaterialPropertyName &base, const std::vector< VariableName > &c) const
Helper functions to generate the material property names for the arbitrary derivatives.
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

void DerivativeMaterialInterface< U >::validateCoupling ( const MaterialPropertyName &  base,
const VariableName &  c1 = "",
const VariableName &  c2 = "",
const VariableName &  c3 = "" 
)
inherited
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.

void DerivativeMaterialInterface< U >::validateNonlinearCoupling ( const MaterialPropertyName &  base,
const VariableName &  c1 = "",
const VariableName &  c2 = "",
const VariableName &  c3 = "" 
)
inherited
template<class T , class U >
InputParameters CompositeTensorBase< T, U >::validParams ( )
static

Definition at line 100 of file CompositeTensorBase.h.

101 {
102  InputParameters params = ::validParams<U>();
103  params.addRequiredParam<std::vector<MaterialPropertyName>>("tensors", "Component tensors");
104  params.addRequiredParam<std::vector<MaterialPropertyName>>("weights", "Component weights");
105  params.addRequiredCoupledVar("args", "variable dependencies for the prefactor");
106  return params;
107 }
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
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 addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
This method adds a coupled variable name pair.

Member Data Documentation

template<class T , class U >
std::vector<std::vector<MaterialProperty<T> *> > CompositeTensorBase< T, U >::_d2M
protected
template<class T , class U >
std::vector<std::vector<std::vector<const MaterialProperty<T> *> > > CompositeTensorBase< T, U >::_d2tensors
protected
template<class T , class U >
std::vector<std::vector<std::vector<const MaterialProperty<Real> *> > > CompositeTensorBase< T, U >::_d2weights
protected
template<class T , class U >
std::vector<MaterialProperty<T> *> CompositeTensorBase< T, U >::_dM
protected
template<class T , class U >
std::vector<std::vector<const MaterialProperty<T> *> > CompositeTensorBase< T, U >::_dtensors
protected
template<class T , class U >
std::vector<std::vector<const MaterialProperty<Real> *> > CompositeTensorBase< T, U >::_dweights
protected
template<class T , class U >
unsigned int CompositeTensorBase< T, U >::_num_args
protected
template<class T , class U >
unsigned int CompositeTensorBase< T, U >::_num_comp
protected
template<class T , class U >
std::vector<MaterialPropertyName> CompositeTensorBase< T, U >::_tensor_names
protected

component tensor names

Definition at line 51 of file CompositeTensorBase.h.

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

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 66 of file CompositeTensorBase.h.

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

template<class T , class U >
std::vector<MaterialPropertyName> CompositeTensorBase< T, U >::_weight_names
protected
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 72 of file CompositeTensorBase.h.

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


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