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("TensorMechanicsApp", WeakPlaneStress);
19 
21 
22 InputParameters
24 {
25  InputParameters params = Kernel::validParams();
26  params.addClassDescription("Plane stress kernel to provide out-of-plane strain contribution.");
27  params.addCoupledVar("displacements",
28  "The string of displacements suitable for the problem statement");
29  params.addCoupledVar("temperature",
30  "The name of the temperature variable used in the "
31  "ComputeThermalExpansionEigenstrain. (Not required for "
32  "simulations without temperature coupling.)");
33  params.addParam<std::string>(
34  "thermal_eigenstrain_name",
35  "thermal_eigenstrain",
36  "The eigenstrain_name used in the ComputeThermalExpansionEigenstrain.");
37  params.addParam<std::string>("base_name", "Material property base name");
38 
39  MooseEnum direction("x y z", "z");
40  params.addDeprecatedParam<MooseEnum>(
41  "direction",
42  direction,
43  "The direction of the out-of-plane strain variable",
44  "Use the new parameter name 'out_of_plane_strain_direction'");
45  params.addParam<MooseEnum>("out_of_plane_strain_direction",
46  direction,
47  "The direction of the out-of-plane strain variable");
48 
49  params.set<bool>("use_displaced_mesh") = false;
50 
51  return params;
52 }
53 
54 WeakPlaneStress::WeakPlaneStress(const InputParameters & parameters)
55  : DerivativeMaterialInterface<Kernel>(parameters),
56  _base_name(isParamValid("base_name") ? getParam<std::string>("base_name") + "_" : ""),
57  _stress(getMaterialProperty<RankTwoTensor>(_base_name + "stress")),
58  _Jacobian_mult(getMaterialProperty<RankFourTensor>(_base_name + "Jacobian_mult")),
59  _direction(parameters.isParamSetByUser("direction")
60  ? getParam<MooseEnum>("direction")
61  : getParam<MooseEnum>("out_of_plane_strain_direction")),
62  _disp_coupled(isCoupled("displacements")),
63  _ndisp(_disp_coupled ? coupledComponents("displacements") : 0),
64  _disp_var(_ndisp),
65  _temp_coupled(isCoupled("temperature")),
66  _temp_var(_temp_coupled ? coupled("temperature") : 0),
67  _deigenstrain_dT(_temp_coupled ? &getMaterialPropertyDerivative<RankTwoTensor>(
68  getParam<std::string>("thermal_eigenstrain_name"),
69  getVar("temperature", 0)->name())
70  : nullptr)
71 {
72  if (_disp_coupled)
73  for (unsigned int i = 0; i < _ndisp; ++i)
74  _disp_var[i] = coupled("displacements", i);
75 
76  if (parameters.isParamSetByUser("direction") &&
77  parameters.isParamSetByUser("out_of_plane_strain_direction"))
78  mooseError("Cannot specify both 'direction' and 'out_of_plane_strain_direction'! Use "
79  "'out_of_plane_strain_direction'.");
80 
81  // Checking for consistency between mesh size and length of the provided displacements vector
82  if (_disp_coupled && _ndisp != _mesh.dimension())
83  mooseError("The number of displacement variables supplied must match the mesh dimension.");
84 }
85 
86 Real
88 {
89  return _stress[_qp](_direction, _direction) * _test[_i][_qp];
90 }
91 
92 Real
94 {
95  return _Jacobian_mult[_qp](_direction, _direction, _direction, _direction) * _test[_i][_qp] *
96  _phi[_j][_qp];
97 }
98 
99 Real
101 {
102  Real val = 0.0;
103 
104  // off-diagonal Jacobian with respect to a coupled displacement component
105  if (_disp_coupled)
106  {
107  for (unsigned int coupled_direction = 0; coupled_direction < _ndisp; ++coupled_direction)
108  {
109  if (jvar == _disp_var[coupled_direction])
110  {
111  unsigned int coupled_direction_index = 0;
112  switch (_direction)
113  {
114  case 0: // x
115  {
116  if (coupled_direction == 0)
117  coupled_direction_index = 1;
118  else
119  coupled_direction_index = 2;
120  break;
121  }
122  case 1: // y
123  {
124  if (coupled_direction == 0)
125  coupled_direction_index = 0;
126  else
127  coupled_direction_index = 2;
128  break;
129  }
130  default: // z
131  {
132  coupled_direction_index = coupled_direction;
133  break;
134  }
135  }
136 
137  val = _Jacobian_mult[_qp](
138  _direction, _direction, coupled_direction_index, coupled_direction_index) *
139  _test[_i][_qp] * _grad_phi[_j][_qp](coupled_direction_index);
140  }
141  }
142  }
143 
144  // off-diagonal Jacobian with respect to a coupled temperature variable
145  if (_temp_coupled && jvar == _temp_var)
146  {
147  Real sum = 0.0;
148  for (unsigned int i = 0; i < 3; ++i)
149  sum += _Jacobian_mult[_qp](_direction, _direction, i, i) * (*_deigenstrain_dT)[_qp](i, i);
150 
151  val = -sum * _test[_i][_qp] * _phi[_j][_qp];
152  }
153 
154  return val;
155 }
WeakPlaneStress.h
WeakPlaneStress::_disp_coupled
const bool _disp_coupled
Coupled displacement variables.
Definition: WeakPlaneStress.h:46
WeakPlaneStress
Definition: WeakPlaneStress.h:26
WeakPlaneStress::computeQpJacobian
virtual Real computeQpJacobian() override
Definition: WeakPlaneStress.C:93
WeakPlaneStress::_temp_coupled
const bool _temp_coupled
Definition: WeakPlaneStress.h:50
WeakPlaneStress::_ndisp
unsigned int _ndisp
Definition: WeakPlaneStress.h:47
WeakPlaneStress::computeQpResidual
virtual Real computeQpResidual() override
Definition: WeakPlaneStress.C:87
WeakPlaneStress::_disp_var
std::vector< unsigned int > _disp_var
Definition: WeakPlaneStress.h:48
WeakPlaneStress::_temp_var
const unsigned int _temp_var
Definition: WeakPlaneStress.h:51
WeakPlaneStress::WeakPlaneStress
WeakPlaneStress(const InputParameters &parameters)
Definition: WeakPlaneStress.C:54
validParams
InputParameters validParams()
name
const std::string name
Definition: Setup.h:21
WeakPlaneStress::_Jacobian_mult
const MaterialProperty< RankFourTensor > & _Jacobian_mult
Definition: WeakPlaneStress.h:41
RankFourTensorTempl< Real >
registerMooseObject
registerMooseObject("TensorMechanicsApp", WeakPlaneStress)
defineLegacyParams
defineLegacyParams(WeakPlaneStress)
WeakPlaneStress::_direction
const unsigned int _direction
Definition: WeakPlaneStress.h:43
WeakPlaneStress::_stress
const MaterialProperty< RankTwoTensor > & _stress
Definition: WeakPlaneStress.h:40
RankTwoTensorTempl< Real >
WeakPlaneStress::validParams
static InputParameters validParams()
Definition: WeakPlaneStress.C:23
WeakPlaneStress::computeQpOffDiagJacobian
virtual Real computeQpOffDiagJacobian(unsigned int jvar) override
Definition: WeakPlaneStress.C:100