www.mooseframework.org
ComputeEigenstrainFromInitialStress.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 /****************************************************************/
7 
9 #include "RankTwoTensor.h"
10 #include "Function.h"
11 
12 template <>
13 InputParameters
15 {
16  InputParameters params = validParams<ComputeEigenstrainBase>();
17  params.addClassDescription("Computes an eigenstrain from an initial stress");
18  params.addRequiredParam<std::vector<FunctionName>>(
19  "initial_stress",
20  "A list of functions describing the initial stress. If provided, there "
21  "must be 9 of these, corresponding to the xx, yx, zx, xy, yy, zy, xz, yz, "
22  "zz components respectively. To compute the eigenstrain correctly, your "
23  "elasticity tensor should not be time-varying in the first timestep");
24  params.addParam<std::string>("base_name",
25  "The base_name for the elasticity tensor that will be "
26  "used to compute strain from stress. Do not provide "
27  "any base_name if your elasticity tensor does not use "
28  "one.");
29  params.set<bool>("incremental_form") = true;
30  return params;
31 }
32 
34  const InputParameters & parameters)
35  : ComputeEigenstrainBase(parameters),
36  _base_name(isParamValid("base_name") ? getParam<std::string>("base_name") + "_" : ""),
37  _elasticity_tensor(getMaterialPropertyByName<RankFourTensor>(_base_name + "elasticity_tensor"))
38 {
39  if (_incremental_form == false)
40  mooseError("ComputeEigenstrainFromInitialStress: incremental_form must be set to true");
41 
42  const std::vector<FunctionName> & fcn_names(
43  getParam<std::vector<FunctionName>>("initial_stress"));
44  const unsigned num = fcn_names.size();
45 
46  if (num != LIBMESH_DIM * LIBMESH_DIM)
47  mooseError("ComputeEigenstrainFromInitialStress: ",
48  LIBMESH_DIM * LIBMESH_DIM,
49  " initial stress functions must be provided. You supplied ",
50  num,
51  "\n");
52 
53  _initial_stress_fcn.resize(num);
54  for (unsigned i = 0; i < num; ++i)
55  _initial_stress_fcn[i] = &getFunctionByName(fcn_names[i]);
56 }
57 
58 void
60 {
61  if (_t_step == 1)
62  {
63  RankTwoTensor initial_stress;
64  for (unsigned i = 0; i < LIBMESH_DIM; ++i)
65  for (unsigned j = 0; j < LIBMESH_DIM; ++j)
66  initial_stress(i, j) = _initial_stress_fcn[i * LIBMESH_DIM + j]->value(_t, _q_point[_qp]);
67 
68  _eigenstrain[_qp] = -_elasticity_tensor[_qp].invSymm() * initial_stress;
69  }
70  else
71  _eigenstrain[_qp] = (*_eigenstrain_old)[_qp];
72 }
std::vector< Function * > _initial_stress_fcn
initial stress components
InputParameters validParams< ComputeEigenstrainBase >()
ComputeEigenstrainFromInitialStress(const InputParameters &parameters)
MaterialProperty< RankTwoTensor > & _eigenstrain
Stores the current total eigenstrain.
InputParameters validParams< ComputeEigenstrainFromInitialStress >()
bool _incremental_form
Whether the eigenstrain model should compute the total or incremental eigenstrain.
const MaterialProperty< RankFourTensor > & _elasticity_tensor
elasticity tensor used to convert stress to strain
virtual void computeQpEigenstrain() override
Compute the eigenstrain and store in _eigenstrain.
ComputeEigenstrainBase is the base class for eigenstrain tensors.