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

Material class to compute the elastic free energy and its derivatives. More...

#include <ElasticEnergyMaterial.h>

Inheritance diagram for ElasticEnergyMaterial:
[legend]

Public Member Functions

 ElasticEnergyMaterial (const InputParameters &parameters)
 
virtual void initialSetup () override
 Check if we got the right number of components in the 'args' coupled variable vector. More...
 

Protected Member Functions

virtual Real computeF () override
 Override this method to provide the free energy function. More...
 
virtual Real computeDF (unsigned int i_var) override
 Override this method for calculating the first derivatives. More...
 
virtual Real computeD2F (unsigned int i_var, unsigned int j_var) override
 Override this method to calculate the second derivatives. More...
 
virtual void computeProperties ()
 
virtual Real computeD3F (unsigned int, unsigned int, unsigned int)
 Override this method to calculate the third derivatives. More...
 
unsigned int argIndex (unsigned int i_var) const
 FunctionMaterialBase keeps an internal list of all the variables the derivatives are taken w.r.t. More...
 

Protected Attributes

std::string _base_name
 
const MaterialProperty< RankTwoTensor > & _stress
 Stress tensor. More...
 
bool _third_derivatives
 Calculate (and allocate memory for) the third derivatives of the free energy. More...
 
std::vector< MaterialProperty< Real > * > _prop_dF
 Material properties to store the derivatives of f with respect to arg[i]. More...
 
std::vector< std::vector< MaterialProperty< Real > * > > _prop_d2F
 Material properties to store the second derivatives. More...
 
std::vector< std::vector< std::vector< MaterialProperty< Real > * > > > _prop_d3F
 Material properties to store the third derivatives. More...
 
std::vector< const VariableValue * > _args
 Coupled variables for function arguments. More...
 
std::string _F_name
 Name of the function value material property and used as a base name to concatenate the material property names for the derivatives. More...
 
bool _mapping_is_unique
 Flag that indicates if exactly one linear variable is coupled per input file coupling parameter. More...
 
unsigned int _nargs
 Number of coupled arguments. More...
 
std::vector< std::string > _arg_names
 String vector of all argument names. More...
 
std::vector< unsigned int > _arg_numbers
 Vector of all argument MOOSE variable numbers. More...
 
std::vector< std::string > _arg_param_names
 String vector of the input file coupling parameter name for each argument. More...
 
std::vector< std::string > _arg_constant_defaults
 coupled variables with default values More...
 
MaterialProperty< Real > * _prop_F
 Material property to store the function value. More...
 
const MaterialProperty< RankFourTensor > & _elasticity_tensor
 Elasticity tensor derivatives. More...
 
std::vector< const MaterialProperty< RankFourTensor > * > _delasticity_tensor
 
std::vector< std::vector< const MaterialProperty< RankFourTensor > * > > _d2elasticity_tensor
 
const MaterialProperty< RankTwoTensor > & _strain
 Strain and derivatives. More...
 
std::vector< const MaterialProperty< RankTwoTensor > * > _dstrain
 
std::vector< std::vector< const MaterialProperty< RankTwoTensor > * > > _d2strain
 

Detailed Description

Material class to compute the elastic free energy and its derivatives.

Definition at line 23 of file ElasticEnergyMaterial.h.

Constructor & Destructor Documentation

ElasticEnergyMaterial::ElasticEnergyMaterial ( const InputParameters &  parameters)

Definition at line 26 of file ElasticEnergyMaterial.C.

27  : DerivativeFunctionMaterialBase(parameters),
28  _base_name(isParamValid("base_name") ? getParam<std::string>("base_name") + "_" : ""),
29  _stress(getMaterialPropertyByName<RankTwoTensor>(_base_name + "stress")),
30  _elasticity_tensor(getMaterialPropertyByName<RankFourTensor>(_base_name + "elasticity_tensor")),
31  _strain(getMaterialPropertyByName<RankTwoTensor>(_base_name + "elastic_strain"))
32 {
33  _dstrain.resize(_nargs);
34  _d2strain.resize(_nargs);
37 
38  // fetch stress and elasticity tensor derivatives (in simple eigenstrain models this is is only
39  // w.r.t. 'c')
40  for (unsigned int i = 0; i < _nargs; ++i)
41  {
42  _dstrain[i] = &getMaterialPropertyDerivativeByName<RankTwoTensor>(_base_name + "elastic_strain",
43  _arg_names[i]);
44  _delasticity_tensor[i] = &getMaterialPropertyDerivativeByName<RankFourTensor>(
45  _base_name + "elasticity_tensor", _arg_names[i]);
46 
47  _d2strain[i].resize(_nargs);
48  _d2elasticity_tensor[i].resize(_nargs);
49 
50  for (unsigned int j = 0; j < _nargs; ++j)
51  {
52  _d2strain[i][j] = &getMaterialPropertyDerivativeByName<RankTwoTensor>(
53  _base_name + "elastic_strain", _arg_names[i], _arg_names[j]);
54  _d2elasticity_tensor[i][j] = &getMaterialPropertyDerivativeByName<RankFourTensor>(
55  _base_name + "elasticity_tensor", _arg_names[i], _arg_names[j]);
56  }
57  }
58 }
DerivativeFunctionMaterialBase(const InputParameters &parameters)
const MaterialProperty< RankTwoTensor > & _stress
Stress tensor.
std::vector< std::vector< const MaterialProperty< RankTwoTensor > * > > _d2strain
const MaterialProperty< RankFourTensor > & _elasticity_tensor
Elasticity tensor derivatives.
unsigned int _nargs
Number of coupled arguments.
std::vector< const MaterialProperty< RankTwoTensor > * > _dstrain
const MaterialProperty< RankTwoTensor > & _strain
Strain and derivatives.
std::vector< std::vector< const MaterialProperty< RankFourTensor > * > > _d2elasticity_tensor
std::vector< std::string > _arg_names
String vector of all argument names.
std::vector< const MaterialProperty< RankFourTensor > * > _delasticity_tensor

Member Function Documentation

unsigned int FunctionMaterialBase::argIndex ( unsigned int  i_var) const
inlineprotectedinherited

FunctionMaterialBase keeps an internal list of all the variables the derivatives are taken w.r.t.

We provide the MOOSE variable bames in _arg_names, the libMesh variable numbers in _arg_numbers, and the input file parameter names in _arg_param_names. All are indexed by the argument index. This method returns the argument index for a given the libMesh variable number.

This mapping is necessary for internal classes which maintain lists of derivatives indexed by argument index and need to pull from those lists from the computeDF, computeD2F, and computeD3F methods, which receive libMesh variable numbers as parameters.

Definition at line 43 of file FunctionMaterialBase.h.

Referenced by DerivativeMultiPhaseMaterial::computeD2F(), computeD2F(), DerivativeTwoPhaseMaterial::computeD2F(), DerivativeMultiPhaseMaterial::computeD3F(), DerivativeTwoPhaseMaterial::computeD3F(), DerivativeMultiPhaseMaterial::computeDF(), computeDF(), DerivativeTwoPhaseMaterial::computeDF(), DerivativeMultiPhaseBase::DerivativeMultiPhaseBase(), and DiscreteNucleation::DiscreteNucleation().

44  {
45  const unsigned int idx = libMeshVarNumberRemap(i_var);
46  mooseAssert(idx < _arg_index.size() && _arg_numbers[_arg_index[idx]] == i_var,
47  "Requesting argIndex() for a derivative w.r.t. a variable not coupled to.");
48  return _arg_index[idx];
49  }
std::vector< unsigned int > _arg_index
Vector to look up the internal coupled variable index into arg* through the libMesh variable number...
unsigned int libMeshVarNumberRemap(unsigned int var) const
map the variable numbers to an even/odd interspersed pattern
std::vector< unsigned int > _arg_numbers
Vector of all argument MOOSE variable numbers.
Real ElasticEnergyMaterial::computeD2F ( unsigned int  arg1,
unsigned int  arg2 
)
overrideprotectedvirtual

Override this method to calculate the second derivatives.

\( \frac{d^2F}{dc_{arg1} dc_{arg2}} \)

Parameters
arg1The variable the first derivative is taken of
arg2The variable the second derivative is taken of

Reimplemented from DerivativeFunctionMaterialBase.

Definition at line 84 of file ElasticEnergyMaterial.C.

85 {
86  unsigned int i = argIndex(i_var);
87  unsigned int j = argIndex(j_var);
88 
89  // product rule d/dj computeDF
90  // TODO: simplify because doubleContraction commutes
91  return 0.5 * (((*_d2elasticity_tensor[i][j])[_qp] * _strain[_qp] +
92  (*_delasticity_tensor[i])[_qp] * (*_dstrain[j])[_qp] +
93  (*_delasticity_tensor[j])[_qp] * (*_dstrain[i])[_qp] +
94  _elasticity_tensor[_qp] * (*_d2strain[i][j])[_qp])
95  .doubleContraction(_strain[_qp]) +
96  ((*_delasticity_tensor[i])[_qp] * _strain[_qp] +
97  _elasticity_tensor[_qp] * (*_dstrain[i])[_qp])
98  .doubleContraction((*_dstrain[j])[_qp])
99 
100  +
101  ( // dstress/dj
102  (*_delasticity_tensor[j])[_qp] * _strain[_qp] +
103  _elasticity_tensor[_qp] * (*_dstrain[j])[_qp])
104  .doubleContraction((*_dstrain[i])[_qp]) +
105  _stress[_qp].doubleContraction((*_d2strain[i][j])[_qp]));
106 }
const MaterialProperty< RankTwoTensor > & _stress
Stress tensor.
std::vector< std::vector< const MaterialProperty< RankTwoTensor > * > > _d2strain
const MaterialProperty< RankFourTensor > & _elasticity_tensor
Elasticity tensor derivatives.
std::vector< const MaterialProperty< RankTwoTensor > * > _dstrain
const MaterialProperty< RankTwoTensor > & _strain
Strain and derivatives.
std::vector< std::vector< const MaterialProperty< RankFourTensor > * > > _d2elasticity_tensor
std::vector< const MaterialProperty< RankFourTensor > * > _delasticity_tensor
unsigned int argIndex(unsigned int i_var) const
FunctionMaterialBase keeps an internal list of all the variables the derivatives are taken w...
virtual Real DerivativeFunctionMaterialBase::computeD3F ( unsigned int  ,
unsigned int  ,
unsigned int   
)
inlineprotectedvirtualinherited

Override this method to calculate the third derivatives.

Note
The implementation of this method is optional. It is only evaluated when the 'third_derivatives' parameter is set to true.

Reimplemented in DerivativeTwoPhaseMaterial, MathFreeEnergy, and DerivativeMultiPhaseMaterial.

Definition at line 95 of file DerivativeFunctionMaterialBase.h.

Referenced by DerivativeFunctionMaterialBase::computeProperties().

95 { return 0.0; }
Real ElasticEnergyMaterial::computeDF ( unsigned int  arg)
overrideprotectedvirtual

Override this method for calculating the first derivatives.

The parameter is the libMesh variable number of the coupled variable. These numbers can be obtained using the coupled() method for each coupled variable.

Parameters
argThe index of the function argument the derivative is taken of

Reimplemented from DerivativeFunctionMaterialBase.

Definition at line 74 of file ElasticEnergyMaterial.C.

75 {
76  unsigned int i = argIndex(i_var);
77 
78  // product rule d/di computeF (doubleContraction commutes)
79  return 0.5 * ((*_delasticity_tensor[i])[_qp] * _strain[_qp]).doubleContraction(_strain[_qp]) +
80  (_elasticity_tensor[_qp] * (*_dstrain[i])[_qp]).doubleContraction(_strain[_qp]);
81 }
const MaterialProperty< RankFourTensor > & _elasticity_tensor
Elasticity tensor derivatives.
std::vector< const MaterialProperty< RankTwoTensor > * > _dstrain
const MaterialProperty< RankTwoTensor > & _strain
Strain and derivatives.
std::vector< const MaterialProperty< RankFourTensor > * > _delasticity_tensor
unsigned int argIndex(unsigned int i_var) const
FunctionMaterialBase keeps an internal list of all the variables the derivatives are taken w...
Real ElasticEnergyMaterial::computeF ( )
overrideprotectedvirtual

Override this method to provide the free energy function.

Reimplemented from DerivativeFunctionMaterialBase.

Definition at line 68 of file ElasticEnergyMaterial.C.

69 {
70  return 0.5 * _stress[_qp].doubleContraction(_strain[_qp]);
71 }
const MaterialProperty< RankTwoTensor > & _stress
Stress tensor.
const MaterialProperty< RankTwoTensor > & _strain
Strain and derivatives.
void DerivativeFunctionMaterialBase::computeProperties ( )
protectedvirtualinherited

Reimplemented in DiscreteNucleation, and DerivativeSumMaterial.

Definition at line 124 of file DerivativeFunctionMaterialBase.C.

125 {
126  for (_qp = 0; _qp < _qrule->n_points(); _qp++)
127  {
128  // set function value
129  if (_prop_F)
130  (*_prop_F)[_qp] = computeF();
131 
132  for (unsigned int i = 0; i < _nargs; ++i)
133  {
134  // set first derivatives
135  if (_prop_dF[i])
136  (*_prop_dF[i])[_qp] = computeDF(_arg_numbers[i]);
137 
138  // second derivatives
139  for (unsigned int j = i; j < _nargs; ++j)
140  {
141  if (_prop_d2F[i][j])
142  (*_prop_d2F[i][j])[_qp] = computeD2F(_arg_numbers[i], _arg_numbers[j]);
143 
144  // third derivatives
145  if (_third_derivatives)
146  {
147  for (unsigned int k = j; k < _nargs; ++k)
148  if (_prop_d3F[i][j][k])
149  (*_prop_d3F[i][j][k])[_qp] =
151  }
152  }
153  }
154  }
155 }
std::vector< std::vector< MaterialProperty< Real > * > > _prop_d2F
Material properties to store the second derivatives.
virtual Real computeD2F(unsigned int arg1, unsigned int arg2)
Override this method to calculate the second derivatives.
std::vector< std::vector< std::vector< MaterialProperty< Real > * > > > _prop_d3F
Material properties to store the third derivatives.
MaterialProperty< Real > * _prop_F
Material property to store the function value.
virtual Real computeD3F(unsigned int, unsigned int, unsigned int)
Override this method to calculate the third derivatives.
virtual Real computeF()
Override this method to provide the free energy function.
bool _third_derivatives
Calculate (and allocate memory for) the third derivatives of the free energy.
unsigned int _nargs
Number of coupled arguments.
std::vector< MaterialProperty< Real > * > _prop_dF
Material properties to store the derivatives of f with respect to arg[i].
virtual Real computeDF(unsigned int arg)
Override this method for calculating the first derivatives.
std::vector< unsigned int > _arg_numbers
Vector of all argument MOOSE variable numbers.
void ElasticEnergyMaterial::initialSetup ( )
overridevirtual

Check if we got the right number of components in the 'args' coupled variable vector.

Reimplemented from DerivativeFunctionMaterialBase.

Definition at line 61 of file ElasticEnergyMaterial.C.

62 {
63  validateCoupling<RankTwoTensor>(_base_name + "elastic_strain");
64  validateCoupling<RankFourTensor>(_base_name + "elasticity_tensor");
65 }

Member Data Documentation

std::vector<std::string> FunctionMaterialBase::_arg_constant_defaults
protectedinherited

coupled variables with default values

Definition at line 76 of file FunctionMaterialBase.h.

Referenced by FunctionMaterialBase::FunctionMaterialBase(), and ParsedMaterialHelper::functionParse().

std::vector<std::string> FunctionMaterialBase::_arg_names
protectedinherited
std::vector<unsigned int> FunctionMaterialBase::_arg_numbers
protectedinherited

Vector of all argument MOOSE variable numbers.

Definition at line 70 of file FunctionMaterialBase.h.

Referenced by FunctionMaterialBase::argIndex(), DerivativeFunctionMaterialBase::computeProperties(), and FunctionMaterialBase::FunctionMaterialBase().

std::vector<std::string> FunctionMaterialBase::_arg_param_names
protectedinherited

String vector of the input file coupling parameter name for each argument.

Definition at line 73 of file FunctionMaterialBase.h.

Referenced by FunctionMaterialBase::FunctionMaterialBase(), and ParsedMaterialHelper::functionParse().

std::vector<const VariableValue *> FunctionMaterialBase::_args
protectedinherited
std::string ElasticEnergyMaterial::_base_name
protected

Definition at line 35 of file ElasticEnergyMaterial.h.

Referenced by ElasticEnergyMaterial(), and initialSetup().

std::vector<std::vector<const MaterialProperty<RankFourTensor> *> > ElasticEnergyMaterial::_d2elasticity_tensor
protected

Definition at line 45 of file ElasticEnergyMaterial.h.

Referenced by computeD2F(), and ElasticEnergyMaterial().

std::vector<std::vector<const MaterialProperty<RankTwoTensor> *> > ElasticEnergyMaterial::_d2strain
protected

Definition at line 51 of file ElasticEnergyMaterial.h.

Referenced by computeD2F(), and ElasticEnergyMaterial().

std::vector<const MaterialProperty<RankFourTensor> *> ElasticEnergyMaterial::_delasticity_tensor
protected

Definition at line 44 of file ElasticEnergyMaterial.h.

Referenced by computeD2F(), computeDF(), and ElasticEnergyMaterial().

std::vector<const MaterialProperty<RankTwoTensor> *> ElasticEnergyMaterial::_dstrain
protected

Definition at line 50 of file ElasticEnergyMaterial.h.

Referenced by computeD2F(), computeDF(), and ElasticEnergyMaterial().

const MaterialProperty<RankFourTensor>& ElasticEnergyMaterial::_elasticity_tensor
protected

Elasticity tensor derivatives.

Definition at line 43 of file ElasticEnergyMaterial.h.

Referenced by computeD2F(), and computeDF().

std::string FunctionMaterialBase::_F_name
protectedinherited

Name of the function value material property and used as a base name to concatenate the material property names for the derivatives.

Definition at line 58 of file FunctionMaterialBase.h.

Referenced by DerivativeParsedMaterialHelper::assembleDerivatives(), DerivativeFunctionMaterialBase::DerivativeFunctionMaterialBase(), and DerivativeFunctionMaterialBase::initialSetup().

bool FunctionMaterialBase::_mapping_is_unique
protectedinherited

Flag that indicates if exactly one linear variable is coupled per input file coupling parameter.

Definition at line 61 of file FunctionMaterialBase.h.

Referenced by FunctionMaterialBase::FunctionMaterialBase(), and ParsedMaterialHelper::functionParse().

unsigned int FunctionMaterialBase::_nargs
protectedinherited
std::vector<std::vector<MaterialProperty<Real> *> > DerivativeFunctionMaterialBase::_prop_d2F
protectedinherited
std::vector<std::vector<std::vector<MaterialProperty<Real> *> > > DerivativeFunctionMaterialBase::_prop_d3F
protectedinherited
std::vector<MaterialProperty<Real> *> DerivativeFunctionMaterialBase::_prop_dF
protectedinherited
MaterialProperty<Real>* FunctionMaterialBase::_prop_F
protectedinherited
const MaterialProperty<RankTwoTensor>& ElasticEnergyMaterial::_strain
protected

Strain and derivatives.

Definition at line 49 of file ElasticEnergyMaterial.h.

Referenced by computeD2F(), computeDF(), and computeF().

const MaterialProperty<RankTwoTensor>& ElasticEnergyMaterial::_stress
protected

Stress tensor.

Definition at line 38 of file ElasticEnergyMaterial.h.

Referenced by computeD2F(), and computeF().

bool DerivativeFunctionMaterialBase::_third_derivatives
protectedinherited

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