www.mooseframework.org
ComputeStressBase.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 
8 #include "ComputeStressBase.h"
10 #include "Function.h"
11 
12 template <>
13 InputParameters
15 {
16  InputParameters params = validParams<Material>();
17  params.addDeprecatedParam<std::vector<FunctionName>>(
18  "initial_stress",
19  "A list of functions describing the initial stress. If provided, there "
20  "must be 9 of these, corresponding to the xx, yx, zx, xy, yy, zy, xz, yz, "
21  "zz components respectively. If not provided, all components of the "
22  "initial stress will be zero",
23  "This functionality was deprecated on 12 October 2017 and is set to be"
24  "removed on 12 March 2018. Please use ComputeEigenstrainFromInitialStress"
25  "instead");
26  params.addParam<std::string>("base_name",
27  "Optional parameter that allows the user to define "
28  "multiple mechanics material systems on the same "
29  "block, i.e. for multiple phases");
30  params.addParam<bool>("store_stress_old",
31  false,
32  "Parameter which indicates whether the old "
33  "stress state, required for the HHT time "
34  "integration scheme and Rayleigh damping, needs "
35  "to be stored");
36  params.suppressParameter<bool>("use_displaced_mesh");
37  return params;
38 }
39 
40 ComputeStressBase::ComputeStressBase(const InputParameters & parameters)
41  : DerivativeMaterialInterface<Material>(parameters),
42  _base_name(isParamValid("base_name") ? getParam<std::string>("base_name") + "_" : ""),
43  _elasticity_tensor_name(_base_name + "elasticity_tensor"),
44  _mechanical_strain(getMaterialPropertyByName<RankTwoTensor>(_base_name + "mechanical_strain")),
45  _stress(declareProperty<RankTwoTensor>(_base_name + "stress")),
46  _elastic_strain(declareProperty<RankTwoTensor>(_base_name + "elastic_strain")),
47  _elasticity_tensor(getMaterialPropertyByName<RankFourTensor>(_elasticity_tensor_name)),
48  _extra_stress(getDefaultMaterialProperty<RankTwoTensor>(_base_name + "extra_stress")),
49  _Jacobian_mult(declareProperty<RankFourTensor>(_base_name + "Jacobian_mult")),
50  _store_stress_old(getParam<bool>("store_stress_old")),
51  // InitialStress Deprecation: remove the following
52  _initial_stress_provided(getParam<std::vector<FunctionName>>("initial_stress").size() ==
53  LIBMESH_DIM * LIBMESH_DIM),
54  _initial_stress(_initial_stress_provided
55  ? &declareProperty<RankTwoTensor>(_base_name + "initial_stress")
56  : nullptr),
57  _initial_stress_old(_initial_stress_provided
58  ? &getMaterialPropertyOld<RankTwoTensor>(_base_name + "initial_stress")
59  : nullptr)
60 {
61 
62  if (getParam<bool>("use_displaced_mesh"))
63  mooseError("The stress calculator needs to run on the undisplaced mesh.");
64 
65  // InitialStress Deprecation: remove following initial stress stuff
66  const std::vector<FunctionName> & fcn_names(
67  getParam<std::vector<FunctionName>>("initial_stress"));
68  const unsigned num = fcn_names.size();
69 
70  if (!(num == 0 || num == LIBMESH_DIM * LIBMESH_DIM))
71  mooseError("Either zero or ",
72  LIBMESH_DIM * LIBMESH_DIM,
73  " initial stress functions must be provided. You supplied ",
74  num,
75  "\n");
76 
77  _initial_stress_fcn.resize(num);
78  for (unsigned i = 0; i < num; ++i)
79  _initial_stress_fcn[i] = &getFunctionByName(fcn_names[i]);
80 }
81 
82 void
84 {
85  _elastic_strain[_qp].zero();
86  _stress[_qp].zero();
87  // InitialStress Deprecation: remove the following
89  {
90  for (unsigned i = 0; i < LIBMESH_DIM; ++i)
91  for (unsigned j = 0; j < LIBMESH_DIM; ++j)
92  (*_initial_stress)[_qp](i, j) =
93  _initial_stress_fcn[i * LIBMESH_DIM + j]->value(_t, _q_point[_qp]);
94  }
96 }
97 
98 void
100 {
101  // InitialStress Deprecation: remove the following 2 lines
103  (*_initial_stress)[_qp] = (*_initial_stress_old)[_qp];
104 
105  computeQpStress();
106 
107  // Add in extra stress
108  _stress[_qp] += _extra_stress[_qp];
109 }
110 
111 void
113 {
115  _stress[_qp] += (*_initial_stress)[_qp];
116 }
virtual void computeQpStress()=0
std::vector< Function * > _initial_stress_fcn
initial stress components
MaterialProperty< RankTwoTensor > & _stress
void addQpInitialStress()
InitialStress Deprecation: remove this method.
virtual void computeQpProperties() override
ComputeStressBase(const InputParameters &parameters)
InputParameters validParams< ComputeStressBase >()
const bool _initial_stress_provided
Whether initial stress was provided. InitialStress Deprecation: remove this.
virtual void initQpStatefulProperties() override
MaterialProperty< RankTwoTensor > & _elastic_strain
const MaterialProperty< RankTwoTensor > & _extra_stress
Extra stress tensor.
MaterialProperty< RankTwoTensor > * _initial_stress
Initial stress, if provided. InitialStress Deprecation: remove this.