www.mooseframework.org
ElasticEnergyMaterial.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
3 /* */
4 /* All contents are licensed under LGPL V2.1 */
5 /* See LICENSE for full restrictions */
6 /****************************************************************/
8 #include "RankTwoTensor.h"
9 #include "RankFourTensor.h"
10 
11 template <>
12 InputParameters
14 {
15  InputParameters params = validParams<DerivativeFunctionMaterialBase>();
16  params.addClassDescription("Free energy material for the elastic energy contributions.");
17  params.addParam<std::string>("base_name", "Material property base name");
18  params.addRequiredCoupledVar("args", "Arguments of F() - use vector coupling");
19  params.addCoupledVar("displacement_gradients",
20  "Vector of displacement gradient variables (see "
21  "Modules/PhaseField/DisplacementGradients "
22  "action)");
23  return params;
24 }
25 
26 ElasticEnergyMaterial::ElasticEnergyMaterial(const InputParameters & parameters)
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 }
59 
60 void
62 {
63  validateCoupling<RankTwoTensor>(_base_name + "elastic_strain");
64  validateCoupling<RankFourTensor>(_base_name + "elasticity_tensor");
65 }
66 
67 Real
69 {
70  return 0.5 * _stress[_qp].doubleContraction(_strain[_qp]);
71 }
72 
73 Real
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 }
82 
83 Real
84 ElasticEnergyMaterial::computeD2F(unsigned int i_var, unsigned int j_var)
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 }
virtual void initialSetup() override
Check if we got the right number of components in the &#39;args&#39; coupled variable vector.
const MaterialProperty< RankTwoTensor > & _stress
Stress tensor.
InputParameters validParams< DerivativeFunctionMaterialBase >()
std::vector< std::vector< const MaterialProperty< RankTwoTensor > * > > _d2strain
const MaterialProperty< RankFourTensor > & _elasticity_tensor
Elasticity tensor derivatives.
virtual Real computeF() override
Override this method to provide the free energy function.
Material base class central to compute the a phase free energy and its derivatives.
unsigned int _nargs
Number of coupled arguments.
ElasticEnergyMaterial(const InputParameters &parameters)
virtual Real computeDF(unsigned int i_var) override
Override this method for calculating the first derivatives.
std::vector< const MaterialProperty< RankTwoTensor > * > _dstrain
const MaterialProperty< RankTwoTensor > & _strain
Strain and derivatives.
std::vector< std::vector< const MaterialProperty< RankFourTensor > * > > _d2elasticity_tensor
InputParameters validParams< ElasticEnergyMaterial >()
std::vector< std::string > _arg_names
String vector of all argument names.
std::vector< const MaterialProperty< RankFourTensor > * > _delasticity_tensor
virtual Real computeD2F(unsigned int i_var, unsigned int j_var) override
Override this method to calculate the second derivatives.
unsigned int argIndex(unsigned int i_var) const
FunctionMaterialBase keeps an internal list of all the variables the derivatives are taken w...