13 #include "libmesh/quadrature.h" 18 template <
typename R2>
23 params.
addClassDescription(
"Stress divergence kernel with automatic differentiation for the " 24 "Cartesian coordinate system");
26 "An integer corresponding to the direction " 27 "the variable this kernel acts in. (0 for x, " 30 "The string of displacements suitable for the problem statement");
31 params.
addParam<std::string>(
"base_name",
"Material property base name");
33 "The name of the out_of_plane_strain variable used in the " 34 "WeakPlaneStress kernel.");
35 params.
set<
bool>(
"use_displaced_mesh") =
false;
36 params.
addParam<
bool>(
"volumetric_locking_correction",
38 "Set to false to turn off volumetric locking correction");
42 template <
typename R2>
46 _base_name(isParamValid(
"base_name") ? getParam<
std::string>(
"base_name") +
"_" :
""),
47 _stress(getADMaterialProperty<R2>(_base_name +
"stress")),
48 _component(getParam<unsigned
int>(
"component")),
49 _ndisp(coupledComponents(
"displacements")),
52 _out_of_plane_strain_coupled(isCoupled(
"out_of_plane_strain")),
53 _out_of_plane_strain(_out_of_plane_strain_coupled ? &adCoupledValue(
"out_of_plane_strain")
55 _volumetric_locking_correction(getParam<bool>(
"volumetric_locking_correction"))
57 for (
unsigned int i = 0; i <
_ndisp; ++i)
64 mooseError(
"Volumetric locking correction should be set to false for 1-D problems.");
67 template <
typename R2>
73 "The coordinate system in the Problem block must be set to XYZ for cartesian geometries.");
76 template <
typename R2>
80 ADReal residual = _stress[_qp].row(_component) * _grad_test[_i][_qp];
83 if (_volumetric_locking_correction)
84 residual += (_avg_grad_test[_i] - _grad_test[_i][_qp](_component)) / 3.0 * _stress[_qp].trace();
86 if (_ndisp != 3 && _out_of_plane_strain_coupled && _use_displaced_mesh)
88 const ADReal out_of_plane_thickness = std::exp((*_out_of_plane_strain)[_qp]);
89 residual *= out_of_plane_thickness;
95 template <
typename R2>
99 if (!_volumetric_locking_correction)
102 ADReal ad_current_elem_volume = 0.0;
103 for (
unsigned int qp = 0; qp < _qrule->n_points(); qp++)
104 ad_current_elem_volume += _ad_JxW[qp] * _ad_coord[qp];
107 _avg_grad_test.resize(_test.size());
108 for (_i = 0; _i < _test.size(); ++_i)
110 _avg_grad_test[_i] = 0.0;
111 for (_qp = 0; _qp < _qrule->n_points(); ++_qp)
112 _avg_grad_test[_i] += _grad_test[_i][_qp](_component) * _ad_JxW[_qp] * _ad_coord[_qp];
114 _avg_grad_test[_i] /= ad_current_elem_volume;
virtual unsigned int coupled(const std::string &var_name, unsigned int comp=0) const
ADStressDivergenceTensorsTempl(const InputParameters ¶meters)
void mooseError(Args &&... args)
std::vector< unsigned int > _disp_var
Coupled displacement variable IDs.
void precalculateResidual() override
DualNumber< Real, DNDerivativeType, true > ADReal
const unsigned int _ndisp
Number of coupled displacement variables.
static InputParameters validParams()
static InputParameters validParams()
registerMooseObject("SolidMechanicsApp", ADStressDivergenceTensors)
void initialSetup() override
const bool _volumetric_locking_correction
Flag for volumetric locking correction.
void mooseError(Args &&... args) const
ADStressDivergenceTensors is the automatic differentiation version of StressDivergenceTensors.
ADReal computeQpResidual() override
void ErrorVector unsigned int