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 ()
 
virtual void computeJacobian ()
 
virtual void computeOffDiagJacobian (unsigned int jvar)
 
virtual Real computeQpResidual ()
 
virtual Real computeQpJacobian ()
 
virtual Real computeQpOffDiagJacobian (unsigned int jvar)
 

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 21 of file StressDivergence.h.

Constructor & Destructor Documentation

StressDivergence::StressDivergence ( const InputParameters &  parameters)

Definition at line 45 of file StressDivergence.C.

46  : Kernel(parameters),
47  _stress_older(getMaterialPropertyOlder<SymmTensor>(
48  "stress" + getParam<std::string>("appended_property_name"))),
49  _stress_old(getMaterialPropertyOld<SymmTensor>(
50  "stress" + getParam<std::string>("appended_property_name"))),
51  _stress(getMaterialProperty<SymmTensor>("stress" +
52  getParam<std::string>("appended_property_name"))),
53  _Jacobian_mult(getMaterialProperty<SymmElasticityTensor>(
54  "Jacobian_mult" + getParam<std::string>("appended_property_name"))),
55  _d_stress_dT(getMaterialProperty<SymmTensor>("d_stress_dT" +
56  getParam<std::string>("appended_property_name"))),
57  _component(getParam<unsigned int>("component")),
58  _xdisp_coupled(isCoupled("disp_x")),
59  _ydisp_coupled(isCoupled("disp_y")),
60  _zdisp_coupled(isCoupled("disp_z")),
61  _temp_coupled(isCoupled("temp")),
62  _xdisp_var(_xdisp_coupled ? coupled("disp_x") : 0),
63  _ydisp_var(_ydisp_coupled ? coupled("disp_y") : 0),
64  _zdisp_var(_zdisp_coupled ? coupled("disp_z") : 0),
65  _temp_var(_temp_coupled ? coupled("temp") : 0),
66  _zeta(getParam<Real>("zeta")),
67  _alpha(getParam<Real>("alpha")),
68  _avg_grad_test(_test.size(), std::vector<Real>(3, 0.0)),
69  _avg_grad_phi(_phi.size(), std::vector<Real>(3, 0.0)),
70  _volumetric_locking_correction(getParam<bool>("volumetric_locking_correction"))
71 {
72 }
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

void StressDivergence::computeJacobian ( )
protectedvirtual

Definition at line 143 of file StressDivergence.C.

Referenced by computeOffDiagJacobian().

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

Definition at line 256 of file StressDivergence.C.

257 {
258  if (jvar == _var.number())
259  computeJacobian();
260  else
261  {
263  {
264  // calculate volume averaged value of shape function derivative
265  _avg_grad_test.resize(_test.size());
266  for (_i = 0; _i < _test.size(); _i++)
267  {
268  _avg_grad_test[_i].resize(3);
269  _avg_grad_test[_i][_component] = 0.0;
270  for (_qp = 0; _qp < _qrule->n_points(); _qp++)
271  _avg_grad_test[_i][_component] +=
272  _grad_test[_i][_qp](_component) * _JxW[_qp] * _coord[_qp];
273 
274  _avg_grad_test[_i][_component] /= _current_elem_volume;
275  }
276 
277  _avg_grad_phi.resize(_phi.size());
278  for (_i = 0; _i < _phi.size(); _i++)
279  {
280  _avg_grad_phi[_i].resize(3);
281  for (unsigned int component = 0; component < _mesh.dimension(); component++)
282  {
283  _avg_grad_phi[_i][component] = 0.0;
284  for (_qp = 0; _qp < _qrule->n_points(); _qp++)
285  _avg_grad_phi[_i][component] += _grad_phi[_i][_qp](component) * _JxW[_qp] * _coord[_qp];
286 
287  _avg_grad_phi[_i][component] /= _current_elem_volume;
288  }
289  }
290  }
291 
292  DenseMatrix<Number> & ke = _assembly.jacobianBlock(_var.number(), jvar);
293 
294  for (_i = 0; _i < _test.size(); _i++)
295  for (_j = 0; _j < _phi.size(); _j++)
296  for (_qp = 0; _qp < _qrule->n_points(); _qp++)
297  ke(_i, _j) += _JxW[_qp] * _coord[_qp] * computeQpOffDiagJacobian(jvar);
298  }
299 }
virtual void computeJacobian()
virtual Real computeQpOffDiagJacobian(unsigned int jvar)
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
const unsigned int _component
Real StressDivergence::computeQpJacobian ( )
protectedvirtual

Definition at line 199 of file StressDivergence.C.

Referenced by computeJacobian().

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

Definition at line 302 of file StressDivergence.C.

Referenced by computeOffDiagJacobian().

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

Definition at line 112 of file StressDivergence.C.

Referenced by computeResidual().

113 {
114  Real residual = 0.0;
115  if ((_dt > 0) && ((_zeta != 0) || (_alpha != 0)))
116  {
117  residual = _stress[_qp].rowDot(_component, _grad_test[_i][_qp]) *
118  (1 + _alpha + (1 + _alpha) * _zeta / _dt) -
119  (_alpha + (1 + 2 * _alpha) * _zeta / _dt) *
120  _stress_old[_qp].rowDot(_component, _grad_test[_i][_qp]) +
121  (_alpha * _zeta / _dt) * _stress_older[_qp].rowDot(_component, _grad_test[_i][_qp]);
122 
123  // volumetric locking correction
125  residual += (_stress[_qp].trace() * (1 + _alpha + (1 + _alpha) * _zeta / _dt) -
126  (_alpha + (1 + 2 * _alpha) * _zeta / _dt) * _stress_old[_qp].trace() +
127  (_alpha * _zeta / _dt) * _stress_older[_qp].trace()) /
128  3.0 * (_avg_grad_test[_i][_component] - _grad_test[_i][_qp](_component));
129  }
130  else
131  {
132  residual += _stress[_qp].rowDot(_component, _grad_test[_i][_qp]);
133 
134  // volumetric locking correction
136  residual += _stress[_qp].trace() / 3.0 *
137  (_avg_grad_test[_i][_component] - _grad_test[_i][_qp](_component));
138  }
139  return residual;
140 }
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
void StressDivergence::computeResidual ( )
protectedvirtual

Definition at line 75 of file StressDivergence.C.

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

Member Data Documentation

const Real StressDivergence::_alpha
private
std::vector<std::vector<Real> > StressDivergence::_avg_grad_phi
private
std::vector<std::vector<Real> > StressDivergence::_avg_grad_test
private
const unsigned int StressDivergence::_component
private
const MaterialProperty<SymmTensor>& StressDivergence::_d_stress_dT
protected

Definition at line 41 of file StressDivergence.h.

Referenced by computeQpOffDiagJacobian().

const MaterialProperty<SymmElasticityTensor>& StressDivergence::_Jacobian_mult
protected

Definition at line 40 of file StressDivergence.h.

Referenced by computeQpJacobian(), and computeQpOffDiagJacobian().

const MaterialProperty<SymmTensor>& StressDivergence::_stress
protected

Definition at line 39 of file StressDivergence.h.

Referenced by computeQpResidual().

const MaterialProperty<SymmTensor>& StressDivergence::_stress_old
protected

Definition at line 38 of file StressDivergence.h.

Referenced by computeQpResidual().

const MaterialProperty<SymmTensor>& StressDivergence::_stress_older
protected

Definition at line 37 of file StressDivergence.h.

Referenced by computeQpResidual().

const bool StressDivergence::_temp_coupled
private

Definition at line 49 of file StressDivergence.h.

Referenced by computeQpOffDiagJacobian().

const unsigned int StressDivergence::_temp_var
private

Definition at line 54 of file StressDivergence.h.

Referenced by computeQpOffDiagJacobian().

bool StressDivergence::_volumetric_locking_correction
private
const bool StressDivergence::_xdisp_coupled
private

Definition at line 46 of file StressDivergence.h.

Referenced by computeQpOffDiagJacobian().

const unsigned int StressDivergence::_xdisp_var
private

Definition at line 51 of file StressDivergence.h.

Referenced by computeQpOffDiagJacobian().

const bool StressDivergence::_ydisp_coupled
private

Definition at line 47 of file StressDivergence.h.

Referenced by computeQpOffDiagJacobian().

const unsigned int StressDivergence::_ydisp_var
private

Definition at line 52 of file StressDivergence.h.

Referenced by computeQpOffDiagJacobian().

const bool StressDivergence::_zdisp_coupled
private

Definition at line 48 of file StressDivergence.h.

Referenced by computeQpOffDiagJacobian().

const unsigned int StressDivergence::_zdisp_var
private

Definition at line 53 of file StressDivergence.h.

Referenced by computeQpOffDiagJacobian().

const Real StressDivergence::_zeta
private

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