https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
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("coupled_variables",
23 "Vector of variable arguments of the free energy function");
24 params.addCoupledVar("displacement_gradients",
25 "Vector of displacement gradient variables (see "
26 "Modules/PhaseField/DisplacementGradients "
27 "action)");
28 return params;
29}
30
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);
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
65void
67{
68 validateCoupling<RankTwoTensor>(_base_name + "elastic_strain");
69 validateCoupling<RankFourTensor>(_base_name + "elasticity_tensor");
70}
71
72Real
74{
75 return 0.5 * _stress[_qp].doubleContraction(_strain[_qp]);
76}
77
78Real
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
88Real
89ElasticEnergyMaterial::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]) +
103 .doubleContraction((*_dstrain[j])[_qp])
104
105 + ( // dstress/dj
108 .doubleContraction((*_dstrain[i])[_qp]) +
109 _stress[_qp].doubleContraction((*_d2strain[i][j])[_qp]));
110}
registerMooseObject("PhaseFieldApp", ElasticEnergyMaterial)
static InputParameters validParams()
Material class to compute the elastic free energy and its derivatives.
const MaterialProperty< RankTwoTensor > & _stress
Stress tensor.
const MaterialProperty< RankFourTensor > & _elasticity_tensor
Elasticity tensor derivatives.
virtual Real computeD2F(unsigned int i_var, unsigned int j_var) override
std::vector< std::vector< const MaterialProperty< RankTwoTensor > * > > _d2strain
std::vector< const MaterialProperty< RankTwoTensor > * > _dstrain
virtual Real computeDF(unsigned int i_var) override
std::vector< std::vector< const MaterialProperty< RankFourTensor > * > > _d2elasticity_tensor
ElasticEnergyMaterial(const InputParameters &parameters)
std::vector< const MaterialProperty< RankFourTensor > * > _delasticity_tensor
virtual Real computeF() override
const MaterialProperty< RankTwoTensor > & _strain
Strain and derivatives.
static InputParameters validParams()
virtual void initialSetup() override
std::vector< std::string > _arg_names
unsigned int argIndex(unsigned int i_var) const
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
void addCoupledVar(const std::string &name, const std::string &doc_string)