15 #include "MooseMesh.h"
16 #include "MooseVariable.h"
18 #include "SystemBase.h"
20 #include "libmesh/quadrature.h"
28 InputParameters params = validParams<Kernel>();
29 params.addRequiredParam<
unsigned int>(
"component",
30 "An integer corresponding to the direction "
31 "the variable this kernel acts in. (0 for x, "
33 params.addCoupledVar(
"disp_x",
"The x displacement");
34 params.addCoupledVar(
"disp_y",
"The y displacement");
35 params.addCoupledVar(
"disp_z",
"The z displacement");
36 params.addCoupledVar(
"temp",
"The temperature");
37 params.addParam<Real>(
"zeta", 0.0,
"Stiffness dependent Rayleigh damping coefficient");
38 params.addParam<Real>(
"alpha", 0.0,
"alpha parameter required for HHT time integration");
39 params.addParam<std::string>(
40 "appended_property_name",
"",
"Name appended to material properties to make them unique");
41 params.addParam<
bool>(
"volumetric_locking_correction",
43 "Set to false to turn off volumetric locking correction");
45 params.set<
bool>(
"use_displaced_mesh") =
true;
52 _stress_older(getMaterialPropertyOlder<
SymmTensor>(
53 "stress" + getParam<std::string>(
"appended_property_name"))),
54 _stress_old(getMaterialPropertyOld<
SymmTensor>(
55 "stress" + getParam<std::string>(
"appended_property_name"))),
56 _stress(getMaterialProperty<
SymmTensor>(
"stress" +
57 getParam<std::string>(
"appended_property_name"))),
59 "Jacobian_mult" + getParam<std::string>(
"appended_property_name"))),
60 _d_stress_dT(getMaterialProperty<
SymmTensor>(
"d_stress_dT" +
61 getParam<std::string>(
"appended_property_name"))),
62 _component(getParam<unsigned int>(
"component")),
63 _xdisp_coupled(isCoupled(
"disp_x")),
64 _ydisp_coupled(isCoupled(
"disp_y")),
65 _zdisp_coupled(isCoupled(
"disp_z")),
66 _temp_coupled(isCoupled(
"temp")),
67 _xdisp_var(_xdisp_coupled ? coupled(
"disp_x") : 0),
68 _ydisp_var(_ydisp_coupled ? coupled(
"disp_y") : 0),
69 _zdisp_var(_zdisp_coupled ? coupled(
"disp_z") : 0),
70 _temp_var(_temp_coupled ? coupled(
"temp") : 0),
71 _zeta(getParam<Real>(
"zeta")),
72 _alpha(getParam<Real>(
"alpha")),
73 _avg_grad_test(_test.size(), std::vector<Real>(3, 0.0)),
74 _avg_grad_phi(_phi.size(), std::vector<Real>(3, 0.0)),
75 _volumetric_locking_correction(getParam<bool>(
"volumetric_locking_correction"))
77 mooseDeprecated(
name(),
": StressDivergence is deprecated.\n\
78 The solid_mechanics module will be removed from MOOSE on July 31, 2020.\n\
79 Please update your input files to utilize the tensor_mechanics equivalents of\n\
80 models based on solid_mechanics. A detailed migration guide that was developed\n\
81 for BISON, but which is generally applicable to any MOOSE model is available at:\n\
82 https://mooseframework.org/bison/tutorials/mechanics_conversion/overview.html");
88 prepareVectorTag(_assembly, _var.number());
94 for (_i = 0; _i < _test.size(); _i++)
98 for (_qp = 0; _qp < _qrule->n_points(); _qp++)
105 precalculateResidual();
106 for (_i = 0; _i < _test.size(); _i++)
107 for (_qp = 0; _qp < _qrule->n_points(); _qp++)
110 accumulateTaggedLocalResidual();
114 Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
115 for (
const auto & var : _save_in)
116 var->sys().solution().add_vector(_local_re, var->dofIndices());
145 residual +=
_stress[_qp].trace() / 3.0 *
154 prepareMatrixTag(_assembly, _var.number(), _var.number());
160 for (_i = 0; _i < _test.size(); _i++)
164 for (_qp = 0; _qp < _qrule->n_points(); _qp++)
171 for (_i = 0; _i < _phi.size(); _i++)
177 for (_qp = 0; _qp < _qrule->n_points(); _qp++)
185 for (_i = 0; _i < _test.size(); _i++)
186 for (_j = 0; _j < _phi.size(); _j++)
187 for (_qp = 0; _qp < _qrule->n_points(); _qp++)
190 accumulateTaggedLocalMatrix();
192 if (_has_diag_save_in)
194 unsigned int rows = _local_ke.m();
195 DenseVector<Number> diag(rows);
196 for (
unsigned int i = 0; i < rows; i++)
197 diag(i) = _local_ke(i, i);
199 Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
200 for (
const auto & var : _diag_save_in)
201 var->sys().solution().add_vector(diag, var->dofIndices());
233 phi.
xx() = _grad_phi[_j][_qp](0);
234 phi.xy() = _grad_phi[_j][_qp](1);
235 phi.xz() = _grad_phi[_j][_qp](2);
239 phi.yy() = _grad_phi[_j][_qp](1);
240 phi.xy() = _grad_phi[_j][_qp](0);
241 phi.yz() = _grad_phi[_j][_qp](2);
245 phi.zz() = _grad_phi[_j][_qp](2);
246 phi.xz() = _grad_phi[_j][_qp](0);
247 phi.yz() = _grad_phi[_j][_qp](1);
252 jacobian += (tmp.
xx() + tmp.
yy() + tmp.
zz()) *
265 size_t jvar_num = jvar.number();
266 if (jvar_num == _var.number())
272 auto phi_size = _sys.getVariable(_tid, jvar.number()).dofIndices().size();
278 for (_i = 0; _i < _test.size(); _i++)
282 for (_qp = 0; _qp < _qrule->n_points(); _qp++)
284 _grad_test[_i][_qp](
_component) * _JxW[_qp] * _coord[_qp];
290 for (_i = 0; _i < phi_size; _i++)
296 for (_qp = 0; _qp < _qrule->n_points(); _qp++)
304 prepareMatrixTag(_assembly, _var.number(), jvar_num);
306 for (_i = 0; _i < _test.size(); _i++)
307 for (_j = 0; _j < phi_size; _j++)
308 for (_qp = 0; _qp < _qrule->n_points(); _qp++)
311 accumulateTaggedLocalMatrix();
318 unsigned int coupled_component = 0;
324 coupled_component = 0;
329 coupled_component = 1;
334 coupled_component = 2;
344 _component, coupled_component, _grad_test[_i][_qp], _grad_phi[_j][_qp]);
354 (
_avg_grad_phi[_j][coupled_component] - _grad_phi[_j][_qp](coupled_component)) /
359 (
_avg_grad_phi[_j][coupled_component] - _grad_phi[_j][_qp](coupled_component)) /
364 if (coupled_component == 0)
366 phi.
xx() = _grad_phi[_j][_qp](0);
367 phi.xy() = _grad_phi[_j][_qp](1);
368 phi.xz() = _grad_phi[_j][_qp](2);
370 else if (coupled_component == 1)
372 phi.yy() = _grad_phi[_j][_qp](1);
373 phi.xy() = _grad_phi[_j][_qp](0);
374 phi.yz() = _grad_phi[_j][_qp](2);
376 else if (coupled_component == 2)
378 phi.zz() = _grad_phi[_j][_qp](2);
379 phi.xz() = _grad_phi[_j][_qp](0);
380 phi.yz() = _grad_phi[_j][_qp](1);
385 jacobian += (tmp.
xx() + tmp.
yy() + tmp.
zz()) *