www.mooseframework.org
WeakPlaneStress.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 "WeakPlaneStress.h"
11 
12 #include "Material.h"
13 #include "MooseMesh.h"
14 #include "MooseVariable.h"
15 #include "RankTwoTensor.h"
16 #include "RankFourTensor.h"
17 
18 registerMooseObject("SolidMechanicsApp", WeakPlaneStress);
19 
22 {
24  params.addClassDescription("Plane stress kernel to provide out-of-plane strain contribution.");
25  params.addCoupledVar("displacements",
26  "The string of displacements suitable for the problem statement");
27  params.addCoupledVar("temperature",
28  "The name of the temperature variable used in the "
29  "ComputeThermalExpansionEigenstrain. (Not required for "
30  "simulations without temperature coupling.)");
31  params.addParam<std::vector<MaterialPropertyName>>(
32  "eigenstrain_names",
33  {},
34  "List of eigenstrains used in the strain calculation. Used for computing their derivaties "
35  "for off-diagonal Jacobian terms.");
36  params.addParam<std::string>("base_name", "Material property base name");
37 
38  MooseEnum direction("x y z", "z");
39  params.addParam<MooseEnum>("out_of_plane_strain_direction",
40  direction,
41  "The direction of the out-of-plane strain variable");
42 
43  params.set<bool>("use_displaced_mesh") = false;
44 
45  return params;
46 }
47 
49  : DerivativeMaterialInterface<Kernel>(parameters),
50  _base_name(isParamValid("base_name") ? getParam<std::string>("base_name") + "_" : ""),
51  _stress(getMaterialProperty<RankTwoTensor>(_base_name + "stress")),
52  _Jacobian_mult(getMaterialProperty<RankFourTensor>(_base_name + "Jacobian_mult")),
53  _direction(getParam<MooseEnum>("out_of_plane_strain_direction")),
54  _disp_coupled(isCoupled("displacements")),
55  _ndisp(_disp_coupled ? coupledComponents("displacements") : 0),
56  _disp_var(_ndisp),
57  _temp_coupled(isCoupled("temperature")),
58  _temp_var(_temp_coupled ? coupled("temperature") : 0)
59 {
60  if (_disp_coupled)
61  for (unsigned int i = 0; i < _ndisp; ++i)
62  _disp_var[i] = coupled("displacements", i);
63 
64  if (_temp_coupled)
65  {
66  for (auto eigenstrain_name : getParam<std::vector<MaterialPropertyName>>("eigenstrain_names"))
67  _deigenstrain_dT.push_back(&getMaterialPropertyDerivative<RankTwoTensor>(
68  eigenstrain_name, coupledName("temperature", 0)));
69  }
70 
71  // Checking for consistency between mesh size and length of the provided displacements vector
72  if (_disp_coupled && _ndisp != _mesh.dimension())
73  mooseError("The number of displacement variables supplied must match the mesh dimension.");
74 }
75 
76 Real
78 {
79  return _stress[_qp](_direction, _direction) * _test[_i][_qp];
80 }
81 
82 Real
84 {
85  return _Jacobian_mult[_qp](_direction, _direction, _direction, _direction) * _test[_i][_qp] *
86  _phi[_j][_qp];
87 }
88 
89 Real
91 {
92  Real val = 0.0;
93 
94  // off-diagonal Jacobian with respect to a coupled displacement component
95  if (_disp_coupled)
96  {
97  for (unsigned int coupled_direction = 0; coupled_direction < _ndisp; ++coupled_direction)
98  {
99  if (jvar == _disp_var[coupled_direction])
100  {
101  unsigned int coupled_direction_index = 0;
102  switch (_direction)
103  {
104  case 0: // x
105  {
106  if (coupled_direction == 0)
107  coupled_direction_index = 1;
108  else
109  coupled_direction_index = 2;
110  break;
111  }
112  case 1: // y
113  {
114  if (coupled_direction == 0)
115  coupled_direction_index = 0;
116  else
117  coupled_direction_index = 2;
118  break;
119  }
120  default: // z
121  {
122  coupled_direction_index = coupled_direction;
123  break;
124  }
125  }
126 
127  val = _Jacobian_mult[_qp](
128  _direction, _direction, coupled_direction_index, coupled_direction_index) *
129  _test[_i][_qp] * _grad_phi[_j][_qp](coupled_direction_index);
130  }
131  }
132  }
133 
134  // off-diagonal Jacobian with respect to a coupled temperature variable
135  if (_temp_coupled && jvar == _temp_var)
136  {
137  RankTwoTensor total_deigenstrain_dT;
138  for (const auto deigenstrain_dT : _deigenstrain_dT)
139  total_deigenstrain_dT += (*deigenstrain_dT)[_qp];
140 
141  Real sum = 0.0;
142  for (unsigned int i = 0; i < 3; ++i)
143  sum += _Jacobian_mult[_qp](_direction, _direction, i, i) * total_deigenstrain_dT(i, i);
144 
145  val = -sum * _test[_i][_qp] * _phi[_j][_qp];
146  }
147 
148  return val;
149 }
static InputParameters validParams()
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void mooseError(Args &&... args)
virtual Real computeQpJacobian() override
T & set(const std::string &name, bool quiet_mode=false)
const MaterialProperty< RankFourTensor > & _Jacobian_mult
std::vector< const MaterialProperty< RankTwoTensor > * > _deigenstrain_dT
d(strain)/d(temperature), if computed by ComputeThermalExpansionEigenstrain
std::vector< unsigned int > _disp_var
Variable numbers of the displacement variables.
registerMooseObject("SolidMechanicsApp", WeakPlaneStress)
WeakPlaneStress(const InputParameters &parameters)
const unsigned int _temp_var
unsigned int _ndisp
Number of displacement variables.
void addCoupledVar(const std::string &name, const std::string &doc_string)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const MaterialProperty< RankTwoTensor > & _stress
The stress tensor that provides the out-of-plane stress.
const bool _temp_coupled
virtual Real computeQpOffDiagJacobian(unsigned int jvar) override
void addClassDescription(const std::string &doc_string)
const unsigned int _direction
The direction of the out-of-plane strain variable.
const bool _disp_coupled
Coupled displacement variables.
virtual Real computeQpResidual() override
static InputParameters validParams()