www.mooseframework.org
Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes | List of all members
StressDivergence Class Reference

#include <StressDivergence.h>

Inheritance diagram for StressDivergence:
[legend]

Public Member Functions

 StressDivergence (const InputParameters &parameters)
 

Protected Member Functions

virtual void computeResidual () override
 
virtual void computeJacobian () override
 
virtual void computeOffDiagJacobian (MooseVariableFEBase &jvar) override
 
virtual Real computeQpResidual () override
 
virtual Real computeQpJacobian () override
 
virtual Real computeQpOffDiagJacobian (unsigned int jvar) override
 

Protected Attributes

const MaterialProperty< SymmTensor > & _stress_older
 
const MaterialProperty< SymmTensor > & _stress_old
 
const MaterialProperty< SymmTensor > & _stress
 
const MaterialProperty< SymmElasticityTensor > & _Jacobian_mult
 
const MaterialProperty< SymmTensor > & _d_stress_dT
 

Private Attributes

const unsigned int _component
 
const bool _xdisp_coupled
 
const bool _ydisp_coupled
 
const bool _zdisp_coupled
 
const bool _temp_coupled
 
const unsigned int _xdisp_var
 
const unsigned int _ydisp_var
 
const unsigned int _zdisp_var
 
const unsigned int _temp_var
 
const Real _zeta
 
const Real _alpha
 
std::vector< std::vector< Real > > _avg_grad_test
 
std::vector< std::vector< Real > > _avg_grad_phi
 
bool _volumetric_locking_correction
 

Detailed Description

Definition at line 24 of file StressDivergence.h.

Constructor & Destructor Documentation

◆ StressDivergence()

StressDivergence::StressDivergence ( const InputParameters &  parameters)

Definition at line 50 of file StressDivergence.C.

51  : Kernel(parameters),
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"))),
58  _Jacobian_mult(getMaterialProperty<SymmElasticityTensor>(
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"))
76 {
77 }
const bool _temp_coupled
const bool _xdisp_coupled
const unsigned int _zdisp_var
std::vector< std::vector< Real > > _avg_grad_test
const MaterialProperty< SymmTensor > & _d_stress_dT
const unsigned int _xdisp_var
std::vector< std::vector< Real > > _avg_grad_phi
const bool _ydisp_coupled
const MaterialProperty< SymmTensor > & _stress
const unsigned int _ydisp_var
bool _volumetric_locking_correction
const MaterialProperty< SymmTensor > & _stress_old
const unsigned int _temp_var
const bool _zdisp_coupled
const MaterialProperty< SymmElasticityTensor > & _Jacobian_mult
const MaterialProperty< SymmTensor > & _stress_older
const unsigned int _component

Member Function Documentation

◆ computeJacobian()

void StressDivergence::computeJacobian ( )
overrideprotectedvirtual

Definition at line 148 of file StressDivergence.C.

Referenced by computeOffDiagJacobian().

149 {
150  DenseMatrix<Number> & ke = _assembly.jacobianBlock(_var.number(), _var.number());
151  _local_ke.resize(ke.m(), ke.n());
152  _local_ke.zero();
153 
155  {
156  // calculate volume averaged value of shape function derivative
157  _avg_grad_test.resize(_test.size());
158  for (_i = 0; _i < _test.size(); _i++)
159  {
160  _avg_grad_test[_i].resize(3);
161  _avg_grad_test[_i][_component] = 0.0;
162  for (_qp = 0; _qp < _qrule->n_points(); _qp++)
163  _avg_grad_test[_i][_component] += _grad_test[_i][_qp](_component) * _JxW[_qp] * _coord[_qp];
164 
165  _avg_grad_test[_i][_component] /= _current_elem_volume;
166  }
167 
168  _avg_grad_phi.resize(_phi.size());
169  for (_i = 0; _i < _phi.size(); _i++)
170  {
171  _avg_grad_phi[_i].resize(3);
172  for (unsigned int component = 0; component < _mesh.dimension(); component++)
173  {
174  _avg_grad_phi[_i][component] = 0.0;
175  for (_qp = 0; _qp < _qrule->n_points(); _qp++)
176  _avg_grad_phi[_i][component] += _grad_phi[_i][_qp](component) * _JxW[_qp] * _coord[_qp];
177 
178  _avg_grad_phi[_i][component] /= _current_elem_volume;
179  }
180  }
181  }
182 
183  for (_i = 0; _i < _test.size(); _i++)
184  for (_j = 0; _j < _phi.size(); _j++)
185  for (_qp = 0; _qp < _qrule->n_points(); _qp++)
186  _local_ke(_i, _j) += _JxW[_qp] * _coord[_qp] * computeQpJacobian();
187 
188  ke += _local_ke;
189 
190  if (_has_diag_save_in)
191  {
192  unsigned int rows = ke.m();
193  DenseVector<Number> diag(rows);
194  for (unsigned int i = 0; i < rows; i++)
195  diag(i) = _local_ke(i, i);
196 
197  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
198  for (const auto & var : _diag_save_in)
199  var->sys().solution().add_vector(diag, var->dofIndices());
200  }
201 }
Real component(const SymmTensor &symm_tensor, unsigned int index)
std::vector< std::vector< Real > > _avg_grad_test
std::vector< std::vector< Real > > _avg_grad_phi
bool _volumetric_locking_correction
virtual Real computeQpJacobian() override
const unsigned int _component

◆ computeOffDiagJacobian()

void StressDivergence::computeOffDiagJacobian ( MooseVariableFEBase &  jvar)
overrideprotectedvirtual

Definition at line 261 of file StressDivergence.C.

262 {
263  size_t jvar_num = jvar.number();
264  if (jvar_num == _var.number())
265  computeJacobian();
266  else
267  {
269  {
270  // calculate volume averaged value of shape function derivative
271  _avg_grad_test.resize(_test.size());
272  for (_i = 0; _i < _test.size(); _i++)
273  {
274  _avg_grad_test[_i].resize(3);
275  _avg_grad_test[_i][_component] = 0.0;
276  for (_qp = 0; _qp < _qrule->n_points(); _qp++)
277  _avg_grad_test[_i][_component] +=
278  _grad_test[_i][_qp](_component) * _JxW[_qp] * _coord[_qp];
279 
280  _avg_grad_test[_i][_component] /= _current_elem_volume;
281  }
282 
283  _avg_grad_phi.resize(jvar.phiSize());
284  for (_i = 0; _i < jvar.phiSize(); _i++)
285  {
286  _avg_grad_phi[_i].resize(3);
287  for (unsigned int component = 0; component < _mesh.dimension(); component++)
288  {
289  _avg_grad_phi[_i][component] = 0.0;
290  for (_qp = 0; _qp < _qrule->n_points(); _qp++)
291  _avg_grad_phi[_i][component] += _grad_phi[_i][_qp](component) * _JxW[_qp] * _coord[_qp];
292 
293  _avg_grad_phi[_i][component] /= _current_elem_volume;
294  }
295  }
296  }
297 
298  DenseMatrix<Number> & ke = _assembly.jacobianBlock(_var.number(), jvar_num);
299 
300  for (_i = 0; _i < _test.size(); _i++)
301  for (_j = 0; _j < jvar.phiSize(); _j++)
302  for (_qp = 0; _qp < _qrule->n_points(); _qp++)
303  ke(_i, _j) += _JxW[_qp] * _coord[_qp] * computeQpOffDiagJacobian(jvar_num);
304  }
305 }
virtual Real computeQpOffDiagJacobian(unsigned int jvar) override
Real component(const SymmTensor &symm_tensor, unsigned int index)
std::vector< std::vector< Real > > _avg_grad_test
std::vector< std::vector< Real > > _avg_grad_phi
bool _volumetric_locking_correction
virtual void computeJacobian() override
const unsigned int _component

◆ computeQpJacobian()

Real StressDivergence::computeQpJacobian ( )
overrideprotectedvirtual

Definition at line 204 of file StressDivergence.C.

Referenced by computeJacobian().

205 {
206  Real sum_C3x3 = _Jacobian_mult[_qp].sum_3x3();
207  RealGradient sum_C3x1 = _Jacobian_mult[_qp].sum_3x1();
208 
209  Real jacobian = 0.0;
210  // B^T_i * C * B_j
211  jacobian += _Jacobian_mult[_qp].stiffness(
212  _component, _component, _grad_test[_i][_qp], _grad_phi[_j][_qp]); // B^T_i * C *B_j
213 
215  {
216  // jacobian = Bbar^T_i * C * Bbar_j where Bbar = B + Bvol
217  // jacobian = B^T_i * C * B_j + Bvol^T_i * C * Bvol_j + Bvol^T_i * C * B_j + B^T_i * C * Bvol_j
218 
219  // Bvol^T_i * C * Bvol_j
220  jacobian += sum_C3x3 * (_avg_grad_test[_i][_component] - _grad_test[_i][_qp](_component)) *
221  (_avg_grad_phi[_j][_component] - _grad_phi[_j][_qp](_component)) / 9.0;
222 
223  // B^T_i * C * Bvol_j
224  jacobian += sum_C3x1(_component) * _grad_test[_i][_qp](_component) *
225  (_avg_grad_phi[_j][_component] - _grad_phi[_j][_qp](_component)) / 3.0;
226 
227  // Bvol^T_i * C * B_j
228  SymmTensor phi;
229  if (_component == 0)
230  {
231  phi.xx() = _grad_phi[_j][_qp](0);
232  phi.xy() = _grad_phi[_j][_qp](1);
233  phi.xz() = _grad_phi[_j][_qp](2);
234  }
235  else if (_component == 1)
236  {
237  phi.yy() = _grad_phi[_j][_qp](1);
238  phi.xy() = _grad_phi[_j][_qp](0);
239  phi.yz() = _grad_phi[_j][_qp](2);
240  }
241  else if (_component == 2)
242  {
243  phi.zz() = _grad_phi[_j][_qp](2);
244  phi.xz() = _grad_phi[_j][_qp](0);
245  phi.yz() = _grad_phi[_j][_qp](1);
246  }
247 
248  SymmTensor tmp(_Jacobian_mult[_qp] * phi);
249 
250  jacobian += (tmp.xx() + tmp.yy() + tmp.zz()) *
251  (_avg_grad_test[_i][_component] - _grad_test[_i][_qp](_component)) / 3.0;
252  }
253 
254  if (_dt > 0)
255  return jacobian * (1 + _alpha + _zeta / _dt);
256  else
257  return jacobian;
258 }
std::vector< std::vector< Real > > _avg_grad_test
std::vector< std::vector< Real > > _avg_grad_phi
Real xx() const
Definition: SymmTensor.h:132
bool _volumetric_locking_correction
const MaterialProperty< SymmElasticityTensor > & _Jacobian_mult
const unsigned int _component

◆ computeQpOffDiagJacobian()

Real StressDivergence::computeQpOffDiagJacobian ( unsigned int  jvar)
overrideprotectedvirtual

Definition at line 308 of file StressDivergence.C.

Referenced by computeOffDiagJacobian().

309 {
310  unsigned int coupled_component = 0;
311 
312  bool active = false;
313 
314  if (_xdisp_coupled && jvar == _xdisp_var)
315  {
316  coupled_component = 0;
317  active = true;
318  }
319  else if (_ydisp_coupled && jvar == _ydisp_var)
320  {
321  coupled_component = 1;
322  active = true;
323  }
324  else if (_zdisp_coupled && jvar == _zdisp_var)
325  {
326  coupled_component = 2;
327  active = true;
328  }
329 
330  if (active)
331  {
332  Real sum_C3x3 = _Jacobian_mult[_qp].sum_3x3();
333  RealGradient sum_C3x1 = _Jacobian_mult[_qp].sum_3x1();
334  Real jacobian = 0.0;
335  jacobian += _Jacobian_mult[_qp].stiffness(
336  _component, coupled_component, _grad_test[_i][_qp], _grad_phi[_j][_qp]); // B^T_i * C *B_j
337 
339  {
340  // jacobian = Bbar^T_i * C * Bbar_j where Bbar = B + Bvol
341  // jacobian = B^T_i * C * B_j + Bvol^T_i * C * Bvol_j + Bvol^T_i * C * B_j + B^T_i * C *
342  // Bvol_j
343 
344  // Bvol^T_i * C * Bvol_j
345  jacobian += sum_C3x3 * (_avg_grad_test[_i][_component] - _grad_test[_i][_qp](_component)) *
346  (_avg_grad_phi[_j][coupled_component] - _grad_phi[_j][_qp](coupled_component)) /
347  9.0;
348 
349  // B^T_i * C * Bvol_j
350  jacobian += sum_C3x1(_component) * _grad_test[_i][_qp](_component) *
351  (_avg_grad_phi[_j][coupled_component] - _grad_phi[_j][_qp](coupled_component)) /
352  3.0;
353 
354  // Bvol^T_i * C * B_i
355  SymmTensor phi;
356  if (coupled_component == 0)
357  {
358  phi.xx() = _grad_phi[_j][_qp](0);
359  phi.xy() = _grad_phi[_j][_qp](1);
360  phi.xz() = _grad_phi[_j][_qp](2);
361  }
362  else if (coupled_component == 1)
363  {
364  phi.yy() = _grad_phi[_j][_qp](1);
365  phi.xy() = _grad_phi[_j][_qp](0);
366  phi.yz() = _grad_phi[_j][_qp](2);
367  }
368  else if (coupled_component == 2)
369  {
370  phi.zz() = _grad_phi[_j][_qp](2);
371  phi.xz() = _grad_phi[_j][_qp](0);
372  phi.yz() = _grad_phi[_j][_qp](1);
373  }
374 
375  SymmTensor tmp(_Jacobian_mult[_qp] * phi);
376 
377  jacobian += (tmp.xx() + tmp.yy() + tmp.zz()) *
378  (_avg_grad_test[_i][_component] - _grad_test[_i][_qp](_component)) / 3.0;
379  }
380 
381  if (_dt > 0)
382  return jacobian * (1 + _alpha + _zeta / _dt);
383  else
384  return jacobian;
385  }
386 
387  if (_temp_coupled && jvar == _temp_var)
388  return _d_stress_dT[_qp].rowDot(_component, _grad_test[_i][_qp]) * _phi[_j][_qp];
389 
390  return 0;
391 }
const bool _temp_coupled
const bool _xdisp_coupled
const unsigned int _zdisp_var
std::vector< std::vector< Real > > _avg_grad_test
const MaterialProperty< SymmTensor > & _d_stress_dT
const unsigned int _xdisp_var
std::vector< std::vector< Real > > _avg_grad_phi
const bool _ydisp_coupled
const unsigned int _ydisp_var
Real xx() const
Definition: SymmTensor.h:132
bool _volumetric_locking_correction
const unsigned int _temp_var
const bool _zdisp_coupled
const MaterialProperty< SymmElasticityTensor > & _Jacobian_mult
const unsigned int _component

◆ computeQpResidual()

Real StressDivergence::computeQpResidual ( )
overrideprotectedvirtual

Definition at line 117 of file StressDivergence.C.

Referenced by computeResidual().

118 {
119  Real residual = 0.0;
120  if ((_dt > 0) && ((_zeta != 0) || (_alpha != 0)))
121  {
122  residual = _stress[_qp].rowDot(_component, _grad_test[_i][_qp]) *
123  (1 + _alpha + (1 + _alpha) * _zeta / _dt) -
124  (_alpha + (1 + 2 * _alpha) * _zeta / _dt) *
125  _stress_old[_qp].rowDot(_component, _grad_test[_i][_qp]) +
126  (_alpha * _zeta / _dt) * _stress_older[_qp].rowDot(_component, _grad_test[_i][_qp]);
127 
128  // volumetric locking correction
130  residual += (_stress[_qp].trace() * (1 + _alpha + (1 + _alpha) * _zeta / _dt) -
131  (_alpha + (1 + 2 * _alpha) * _zeta / _dt) * _stress_old[_qp].trace() +
132  (_alpha * _zeta / _dt) * _stress_older[_qp].trace()) /
133  3.0 * (_avg_grad_test[_i][_component] - _grad_test[_i][_qp](_component));
134  }
135  else
136  {
137  residual += _stress[_qp].rowDot(_component, _grad_test[_i][_qp]);
138 
139  // volumetric locking correction
141  residual += _stress[_qp].trace() / 3.0 *
142  (_avg_grad_test[_i][_component] - _grad_test[_i][_qp](_component));
143  }
144  return residual;
145 }
std::vector< std::vector< Real > > _avg_grad_test
const MaterialProperty< SymmTensor > & _stress
bool _volumetric_locking_correction
const MaterialProperty< SymmTensor > & _stress_old
const MaterialProperty< SymmTensor > & _stress_older
const unsigned int _component

◆ computeResidual()

void StressDivergence::computeResidual ( )
overrideprotectedvirtual

Definition at line 80 of file StressDivergence.C.

81 {
82  DenseVector<Number> & re = _assembly.residualBlock(_var.number());
83  _local_re.resize(re.size());
84  _local_re.zero();
85 
87  {
88  // calculate volume averaged value of shape function derivative
89  _avg_grad_test.resize(_test.size());
90  for (_i = 0; _i < _test.size(); _i++)
91  {
92  _avg_grad_test[_i].resize(3);
93  _avg_grad_test[_i][_component] = 0.0;
94  for (_qp = 0; _qp < _qrule->n_points(); _qp++)
95  _avg_grad_test[_i][_component] += _grad_test[_i][_qp](_component) * _JxW[_qp] * _coord[_qp];
96 
97  _avg_grad_test[_i][_component] /= _current_elem_volume;
98  }
99  }
100 
101  precalculateResidual();
102  for (_i = 0; _i < _test.size(); _i++)
103  for (_qp = 0; _qp < _qrule->n_points(); _qp++)
104  _local_re(_i) += _JxW[_qp] * _coord[_qp] * computeQpResidual();
105 
106  re += _local_re;
107 
108  if (_has_save_in)
109  {
110  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
111  for (const auto & var : _save_in)
112  var->sys().solution().add_vector(_local_re, var->dofIndices());
113  }
114 }
std::vector< std::vector< Real > > _avg_grad_test
virtual Real computeQpResidual() override
bool _volumetric_locking_correction
const unsigned int _component

Member Data Documentation

◆ _alpha

const Real StressDivergence::_alpha
private

◆ _avg_grad_phi

std::vector<std::vector<Real> > StressDivergence::_avg_grad_phi
private

◆ _avg_grad_test

std::vector<std::vector<Real> > StressDivergence::_avg_grad_test
private

◆ _component

const unsigned int StressDivergence::_component
private

◆ _d_stress_dT

const MaterialProperty<SymmTensor>& StressDivergence::_d_stress_dT
protected

Definition at line 45 of file StressDivergence.h.

Referenced by computeQpOffDiagJacobian().

◆ _Jacobian_mult

const MaterialProperty<SymmElasticityTensor>& StressDivergence::_Jacobian_mult
protected

Definition at line 44 of file StressDivergence.h.

Referenced by computeQpJacobian(), and computeQpOffDiagJacobian().

◆ _stress

const MaterialProperty<SymmTensor>& StressDivergence::_stress
protected

Definition at line 43 of file StressDivergence.h.

Referenced by computeQpResidual().

◆ _stress_old

const MaterialProperty<SymmTensor>& StressDivergence::_stress_old
protected

Definition at line 42 of file StressDivergence.h.

Referenced by computeQpResidual().

◆ _stress_older

const MaterialProperty<SymmTensor>& StressDivergence::_stress_older
protected

Definition at line 41 of file StressDivergence.h.

Referenced by computeQpResidual().

◆ _temp_coupled

const bool StressDivergence::_temp_coupled
private

Definition at line 53 of file StressDivergence.h.

Referenced by computeQpOffDiagJacobian().

◆ _temp_var

const unsigned int StressDivergence::_temp_var
private

Definition at line 58 of file StressDivergence.h.

Referenced by computeQpOffDiagJacobian().

◆ _volumetric_locking_correction

bool StressDivergence::_volumetric_locking_correction
private

◆ _xdisp_coupled

const bool StressDivergence::_xdisp_coupled
private

Definition at line 50 of file StressDivergence.h.

Referenced by computeQpOffDiagJacobian().

◆ _xdisp_var

const unsigned int StressDivergence::_xdisp_var
private

Definition at line 55 of file StressDivergence.h.

Referenced by computeQpOffDiagJacobian().

◆ _ydisp_coupled

const bool StressDivergence::_ydisp_coupled
private

Definition at line 51 of file StressDivergence.h.

Referenced by computeQpOffDiagJacobian().

◆ _ydisp_var

const unsigned int StressDivergence::_ydisp_var
private

Definition at line 56 of file StressDivergence.h.

Referenced by computeQpOffDiagJacobian().

◆ _zdisp_coupled

const bool StressDivergence::_zdisp_coupled
private

Definition at line 52 of file StressDivergence.h.

Referenced by computeQpOffDiagJacobian().

◆ _zdisp_var

const unsigned int StressDivergence::_zdisp_var
private

Definition at line 57 of file StressDivergence.h.

Referenced by computeQpOffDiagJacobian().

◆ _zeta

const Real StressDivergence::_zeta
private

The documentation for this class was generated from the following files: