11 #include "RankTwoTensor.h"
12 #include "libmesh/quadrature.h"
18 template <ComputeStage compute_stage>
23 params.addClassDescription(
"Stress divergence kernel with automatic differentiation for the "
24 "Cartesian coordinate system");
25 params.addRequiredParam<
unsigned int>(
"component",
26 "An integer corresponding to the direction "
27 "the variable this kernel acts in. (0 for x, "
29 params.addRequiredCoupledVar(
"displacements",
30 "The string of displacements suitable for the problem statement");
31 params.addParam<std::string>(
"base_name",
"Material property base name");
32 params.set<
bool>(
"use_displaced_mesh") =
false;
33 params.addParam<
bool>(
"volumetric_locking_correction",
35 "Set to false to turn off volumetric locking correction");
39 template <ComputeStage compute_stage>
41 const InputParameters & parameters)
42 : ADKernel<compute_stage>(parameters),
43 _base_name(isParamValid(
"base_name") ? getParam<std::string>(
"base_name") +
"_" :
""),
44 _stress(getADMaterialProperty<
RankTwoTensor>(_base_name +
"stress")),
45 _component(getParam<unsigned int>(
"component")),
46 _ndisp(coupledComponents(
"displacements")),
49 _volumetric_locking_correction(getParam<bool>(
"volumetric_locking_correction"))
51 for (
unsigned int i = 0; i <
_ndisp; ++i)
54 _disp_var[i] = Coupleable::coupled(
"displacements", i);
58 mooseError(
"Volumetric locking correction should be set to false for 1-D problems.");
61 template <ComputeStage compute_stage>
65 if (getBlockCoordSystem() != Moose::COORD_XYZ)
67 "The coordinate system in the Problem block must be set to XYZ for cartesian geometries.");
70 template <ComputeStage compute_stage>
74 ADReal residual = _stress[_qp].row(_component) * _grad_test[_i][_qp];
77 if (_volumetric_locking_correction)
78 residual += (_avg_grad_test[_i] - _grad_test[_i][_qp](_component)) / 3.0 * _stress[_qp].trace();
83 template <ComputeStage compute_stage>
87 if (!_volumetric_locking_correction)
90 ADReal ad_current_elem_volume = 0.0;
91 for (
unsigned int qp = 0; qp < _qrule->n_points(); qp++)
92 ad_current_elem_volume += _ad_JxW[qp] * _ad_coord[qp];
95 _avg_grad_test.resize(_test.size());
96 for (_i = 0; _i < _test.size(); ++_i)
98 _avg_grad_test[_i] = 0.0;
99 for (_qp = 0; _qp < _qrule->n_points(); ++_qp)
100 _avg_grad_test[_i] += _grad_test[_i][_qp](_component) * _ad_JxW[_qp] * _ad_coord[_qp];
102 _avg_grad_test[_i] /= ad_current_elem_volume;