https://mooseframework.inl.gov
ElasticEnergyMaterial.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 #include "ElasticEnergyMaterial.h"
11 #include "RankTwoTensor.h"
12 #include "RankFourTensor.h"
13 
15 
18 {
20  params.addClassDescription("Free energy material for the elastic energy contributions.");
21  params.addParam<std::string>("base_name", "Material property base name");
22  params.addCoupledVar("args", "Vector of variable arguments of the free energy function");
23  params.deprecateCoupledVar("args", "coupled_variables", "02/27/2024");
24  params.addCoupledVar("displacement_gradients",
25  "Vector of displacement gradient variables (see "
26  "Modules/PhaseField/DisplacementGradients "
27  "action)");
28  return params;
29 }
30 
32  : DerivativeFunctionMaterialBase(parameters),
33  _base_name(isParamValid("base_name") ? getParam<std::string>("base_name") + "_" : ""),
34  _stress(getMaterialPropertyByName<RankTwoTensor>(_base_name + "stress")),
35  _elasticity_tensor(getMaterialPropertyByName<RankFourTensor>(_base_name + "elasticity_tensor")),
36  _strain(getMaterialPropertyByName<RankTwoTensor>(_base_name + "elastic_strain"))
37 {
38  _dstrain.resize(_nargs);
39  _d2strain.resize(_nargs);
42 
43  // fetch stress and elasticity tensor derivatives (in simple eigenstrain models this is is only
44  // w.r.t. 'c')
45  for (unsigned int i = 0; i < _nargs; ++i)
46  {
47  _dstrain[i] = &getMaterialPropertyDerivativeByName<RankTwoTensor>(_base_name + "elastic_strain",
48  _arg_names[i]);
49  _delasticity_tensor[i] = &getMaterialPropertyDerivativeByName<RankFourTensor>(
50  _base_name + "elasticity_tensor", _arg_names[i]);
51 
52  _d2strain[i].resize(_nargs);
53  _d2elasticity_tensor[i].resize(_nargs);
54 
55  for (unsigned int j = 0; j < _nargs; ++j)
56  {
57  _d2strain[i][j] = &getMaterialPropertyDerivativeByName<RankTwoTensor>(
58  _base_name + "elastic_strain", _arg_names[i], _arg_names[j]);
59  _d2elasticity_tensor[i][j] = &getMaterialPropertyDerivativeByName<RankFourTensor>(
60  _base_name + "elasticity_tensor", _arg_names[i], _arg_names[j]);
61  }
62  }
63 }
64 
65 void
67 {
68  validateCoupling<RankTwoTensor>(_base_name + "elastic_strain");
69  validateCoupling<RankFourTensor>(_base_name + "elasticity_tensor");
70 }
71 
72 Real
74 {
75  return 0.5 * _stress[_qp].doubleContraction(_strain[_qp]);
76 }
77 
78 Real
80 {
81  unsigned int i = argIndex(i_var);
82 
83  // product rule d/di computeF (doubleContraction commutes)
84  return 0.5 * ((*_delasticity_tensor[i])[_qp] * _strain[_qp]).doubleContraction(_strain[_qp]) +
85  (_elasticity_tensor[_qp] * (*_dstrain[i])[_qp]).doubleContraction(_strain[_qp]);
86 }
87 
88 Real
89 ElasticEnergyMaterial::computeD2F(unsigned int i_var, unsigned int j_var)
90 {
91  unsigned int i = argIndex(i_var);
92  unsigned int j = argIndex(j_var);
93 
94  // product rule d/dj computeDF
95  // TODO: simplify because doubleContraction commutes
96  return 0.5 * (((*_d2elasticity_tensor[i][j])[_qp] * _strain[_qp] +
97  (*_delasticity_tensor[i])[_qp] * (*_dstrain[j])[_qp] +
98  (*_delasticity_tensor[j])[_qp] * (*_dstrain[i])[_qp] +
100  .doubleContraction(_strain[_qp]) +
101  ((*_delasticity_tensor[i])[_qp] * _strain[_qp] +
103  .doubleContraction((*_dstrain[j])[_qp])
104 
105  + ( // dstress/dj
108  .doubleContraction((*_dstrain[i])[_qp]) +
109  _stress[_qp].doubleContraction((*_d2strain[i][j])[_qp]));
110 }
Material class to compute the elastic free energy and its derivatives.
virtual void initialSetup() override
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
const MaterialProperty< RankTwoTensor > & _stress
Stress tensor.
std::vector< std::vector< const MaterialProperty< RankTwoTensor > * > > _d2strain
const std::string _base_name
static InputParameters validParams()
std::vector< std::string > _arg_names
const MaterialProperty< RankFourTensor > & _elasticity_tensor
Elasticity tensor derivatives.
virtual Real computeF() override
registerMooseObject("PhaseFieldApp", ElasticEnergyMaterial)
ElasticEnergyMaterial(const InputParameters &parameters)
virtual Real computeDF(unsigned int i_var) override
void deprecateCoupledVar(const std::string &old_name, const std::string &new_name, const std::string &removal_date)
std::vector< const MaterialProperty< RankTwoTensor > * > _dstrain
const MaterialProperty< RankTwoTensor > & _strain
Strain and derivatives.
unsigned int argIndex(unsigned int i_var) const
void addCoupledVar(const std::string &name, const std::string &doc_string)
std::vector< std::vector< const MaterialProperty< RankFourTensor > * > > _d2elasticity_tensor
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void addClassDescription(const std::string &doc_string)
static const std::complex< double > j(0, 1)
Complex number "j" (also known as "i")
std::vector< const MaterialProperty< RankFourTensor > * > _delasticity_tensor
virtual Real computeD2F(unsigned int i_var, unsigned int j_var) override
static InputParameters validParams()