12 #include "libmesh/quadrature.h"
16 template <ComputeStage compute_stage>
21 params.addClassDescription(
"Compute a small strain in a plane strain configuration.");
22 MooseEnum outOfPlaneDirection(
"x y z",
"z");
23 params.addParam<MooseEnum>(
24 "out_of_plane_direction", outOfPlaneDirection,
"The direction of the out-of-plane strain.");
28 template <ComputeStage compute_stage>
31 _out_of_plane_direction(getParam<MooseEnum>(
"out_of_plane_direction"))
35 template <ComputeStage compute_stage>
39 displacementIntegrityCheck();
40 for (
unsigned int i = 0; i < 3; ++i)
42 if (_out_of_plane_direction == i)
44 _disp[i] = &adZeroValue();
45 _grad_disp[i] = &adZeroGradient();
49 _disp[i] = &adCoupledValue(
"displacements", i);
50 _grad_disp[i] = &adCoupledGradient(
"displacements", i);
55 template <ComputeStage compute_stage>
59 const auto o0 = _out_of_plane_direction;
60 const auto o1 = (_out_of_plane_direction + 1) % 3;
61 const auto o2 = (_out_of_plane_direction + 2) % 3;
63 ADReal volumetric_strain = 0.0;
64 for (_qp = 0; _qp < _qrule->n_points(); ++_qp)
66 _total_strain[_qp](o0, o0) = computeOutOfPlaneStrain();
67 _total_strain[_qp](o1, o1) = (*_grad_disp[o1])[_qp](o1);
68 _total_strain[_qp](o2, o2) = (*_grad_disp[o2])[_qp](o2);
69 _total_strain[_qp](o1, o2) = ((*_grad_disp[o1])[_qp](o2) + (*_grad_disp[o2])[_qp](o1)) / 2.0;
70 _total_strain[_qp](o2, o1) = _total_strain[_qp](o1, o2);
72 if (_volumetric_locking_correction)
73 volumetric_strain += _total_strain[_qp].trace() * _JxW[_qp] * _coord[_qp];
76 if (_volumetric_locking_correction)
77 volumetric_strain /= _current_elem_volume;
79 for (_qp = 0; _qp < _qrule->n_points(); ++_qp)
81 if (_volumetric_locking_correction)
83 const ADReal correction = (volumetric_strain - _total_strain[_qp].trace()) / 3.0;
84 _total_strain[_qp](0, 0) += correction;
85 _total_strain[_qp](1, 1) += correction;
86 _total_strain[_qp](2, 2) += correction;
89 _mechanical_strain[_qp] = _total_strain[_qp];
92 for (
const auto es : _eigenstrains)
93 _mechanical_strain[_qp] -= (*es)[_qp];
96 copyDualNumbersToValues();
99 template <ComputeStage compute_stage>
103 if (_out_of_plane_direction != 2 && _ndisp != 3)
104 mooseError(
"For 2D simulations where the out-of-plane direction is x or y the number of "
105 "supplied displacements must be three.");
106 else if (_out_of_plane_direction == 2 && _ndisp != 2)
107 mooseError(
"For 2D simulations where the out-of-plane direction is z the number of supplied "
108 "displacements must be two.");