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

#include <StressDivergenceRZ.h>

Inheritance diagram for StressDivergenceRZ:
[legend]

Public Member Functions

 StressDivergenceRZ (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
 
Real calculateJacobian (unsigned int ivar, unsigned int jvar)
 

Protected Attributes

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

Private Attributes

const unsigned int _component
 
const bool _rdisp_coupled
 
const bool _zdisp_coupled
 
const bool _temp_coupled
 
const unsigned int _rdisp_var
 
const unsigned int _zdisp_var
 
const unsigned int _temp_var
 
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 23 of file StressDivergenceRZ.h.

Constructor & Destructor Documentation

◆ StressDivergenceRZ()

StressDivergenceRZ::StressDivergenceRZ ( const InputParameters &  parameters)

Definition at line 49 of file StressDivergenceRZ.C.

50  : Kernel(parameters),
51  _stress(getMaterialProperty<SymmTensor>("stress")),
52  _Jacobian_mult(getMaterialProperty<SymmElasticityTensor>("Jacobian_mult")),
53  _d_stress_dT(getMaterialProperty<SymmTensor>("d_stress_dT")),
54  _component(getParam<unsigned int>("component")),
55  _rdisp_coupled(isCoupled("disp_r")),
56  _zdisp_coupled(isCoupled("disp_z")),
57  _temp_coupled(isCoupled("temp")),
58  _rdisp_var(_rdisp_coupled ? coupled("disp_r") : 0),
59  _zdisp_var(_zdisp_coupled ? coupled("disp_z") : 0),
60  _temp_var(_temp_coupled ? coupled("temp") : 0),
61  _avg_grad_test(_test.size(), std::vector<Real>(3, 0.0)),
62  _avg_grad_phi(_phi.size(), std::vector<Real>(3, 0.0)),
63  _volumetric_locking_correction(getParam<bool>("volumetric_locking_correction"))
64 {
65 }
std::vector< std::vector< Real > > _avg_grad_test
const MaterialProperty< SymmTensor > & _d_stress_dT
std::vector< std::vector< Real > > _avg_grad_phi
const unsigned int _component
const MaterialProperty< SymmElasticityTensor > & _Jacobian_mult
const MaterialProperty< SymmTensor > & _stress
const unsigned int _temp_var
const unsigned int _zdisp_var
const unsigned int _rdisp_var

Member Function Documentation

◆ calculateJacobian()

Real StressDivergenceRZ::calculateJacobian ( unsigned int  ivar,
unsigned int  jvar 
)
protected

Definition at line 224 of file StressDivergenceRZ.C.

Referenced by computeQpJacobian(), and computeQpOffDiagJacobian().

225 {
226  // B^T_i * C * B_j
227  SymmTensor test, phi;
228  if (ivar == 0)
229  {
230  test.xx() = _grad_test[_i][_qp](0);
231  test.xy() = 0.5 * _grad_test[_i][_qp](1);
232  test.zz() = _test[_i][_qp] / _q_point[_qp](0);
233  }
234  else
235  {
236  test.xy() = 0.5 * _grad_test[_i][_qp](0);
237  test.yy() = _grad_test[_i][_qp](1);
238  }
239  if (jvar == 0)
240  {
241  phi.xx() = _grad_phi[_j][_qp](0);
242  phi.xy() = 0.5 * _grad_phi[_j][_qp](1);
243  phi.zz() = _phi[_j][_qp] / _q_point[_qp](0);
244  }
245  else
246  {
247  phi.xy() = 0.5 * _grad_phi[_j][_qp](0);
248  phi.yy() = _grad_phi[_j][_qp](1);
249  }
250 
251  SymmTensor tmp(_Jacobian_mult[_qp] * phi);
252  Real first_term(test.doubleContraction(tmp));
253  Real val = 0.0;
254  // volumetric locking correction
255  // K = Bbar^T_i * C * Bbar^T_j where Bbar = B + Bvol
256  // K = B^T_i * C * B_j + Bvol^T_i * C * Bvol_j + B^T_i * C * Bvol_j + Bvol^T_i * C * B_j
258  {
259  RealGradient new_test(2, 0.0);
260  RealGradient new_phi(2, 0.0);
261 
262  new_test(0) = _grad_test[_i][_qp](0) + _test[_i][_qp] / _q_point[_qp](0);
263  new_test(1) = _grad_test[_i][_qp](1);
264  new_phi(0) = _grad_phi[_j][_qp](0) + _phi[_j][_qp] / _q_point[_qp](0);
265  new_phi(1) = _grad_phi[_j][_qp](1);
266 
267  // Bvol^T_i * C * Bvol_j
268  val += _Jacobian_mult[_qp].sum_3x3() * (_avg_grad_test[_i][ivar] - new_test(ivar)) *
269  (_avg_grad_phi[_j][jvar] - new_phi(jvar)) / 3.0;
270 
271  // B^T_i * C * Bvol_j
272  RealGradient sum_3x1 = _Jacobian_mult[_qp].sum_3x1();
273  if (ivar == 0 && jvar == 0)
274  val +=
275  (sum_3x1(0) * test.xx() + sum_3x1(2) * test.zz()) * (_avg_grad_phi[_j][0] - new_phi(0));
276  else if (ivar == 0 && jvar == 1)
277  val +=
278  (sum_3x1(0) * test.xx() + sum_3x1(2) * test.zz()) * (_avg_grad_phi[_j][1] - new_phi(1));
279  else if (ivar == 1 && jvar == 0)
280  val += sum_3x1(1) * test.yy() * (_avg_grad_phi[_j][0] - new_phi(0));
281  else
282  val += sum_3x1(1) * test.yy() * (_avg_grad_phi[_j][1] - new_phi(1));
283 
284  // Bvol^T_i * C * B_j
285  // tmp = C * B_j from above
286  if (ivar == 0)
287  val += (tmp.xx() + tmp.yy() + tmp.zz()) * (_avg_grad_test[_i][0] - new_test(0));
288  else
289  val += (tmp.xx() + tmp.yy() + tmp.zz()) * (_avg_grad_test[_i][1] - new_test(1));
290  }
291  return val / 3.0 + first_term;
292 }
std::vector< std::vector< Real > > _avg_grad_test
std::vector< std::vector< Real > > _avg_grad_phi
const MaterialProperty< SymmElasticityTensor > & _Jacobian_mult
Real yy() const
Definition: SymmTensor.h:133
Real xx() const
Definition: SymmTensor.h:132
Real doubleContraction(const SymmTensor &rhs) const
Definition: SymmTensor.h:260
Real xy() const
Definition: SymmTensor.h:135
Real zz() const
Definition: SymmTensor.h:134

◆ computeJacobian()

void StressDivergenceRZ::computeJacobian ( )
overrideprotectedvirtual

Definition at line 148 of file StressDivergenceRZ.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(2);
161  _avg_grad_test[_i][_component] = 0.0;
162  for (_qp = 0; _qp < _qrule->n_points(); _qp++)
163  {
164  if (_component == 0)
165  _avg_grad_test[_i][_component] +=
166  (_grad_test[_i][_qp](_component) + _test[_i][_qp] / _q_point[_qp](0)) * _JxW[_qp] *
167  _coord[_qp];
168  else
169  _avg_grad_test[_i][_component] +=
170  _grad_test[_i][_qp](_component) * _JxW[_qp] * _coord[_qp];
171  }
172  _avg_grad_test[_i][_component] /= _current_elem_volume;
173  }
174 
175  _avg_grad_phi.resize(_phi.size());
176  for (_i = 0; _i < _phi.size(); _i++)
177  {
178  _avg_grad_phi[_i].resize(2);
179  for (unsigned int component = 0; component < 2; component++)
180  {
181  _avg_grad_phi[_i][component] = 0.0;
182  for (_qp = 0; _qp < _qrule->n_points(); _qp++)
183  {
184  if (component == 0)
185  _avg_grad_phi[_i][component] +=
186  (_grad_phi[_i][_qp](component) + _phi[_i][_qp] / _q_point[_qp](0)) * _JxW[_qp] *
187  _coord[_qp];
188  else
189  _avg_grad_phi[_i][component] += _grad_phi[_i][_qp](component) * _JxW[_qp] * _coord[_qp];
190  }
191 
192  _avg_grad_phi[_i][component] /= _current_elem_volume;
193  }
194  }
195  }
196 
197  for (_i = 0; _i < _test.size(); _i++)
198  for (_j = 0; _j < _phi.size(); _j++)
199  for (_qp = 0; _qp < _qrule->n_points(); _qp++)
200  _local_ke(_i, _j) += _JxW[_qp] * _coord[_qp] * computeQpJacobian();
201 
202  ke += _local_ke;
203 
204  if (_has_diag_save_in)
205  {
206  unsigned int rows = ke.m();
207  DenseVector<Number> diag(rows);
208  for (unsigned int i = 0; i < rows; i++)
209  diag(i) = _local_ke(i, i);
210 
211  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
212  for (const auto & var : _diag_save_in)
213  var->sys().solution().add_vector(diag, var->dofIndices());
214  }
215 }
std::vector< std::vector< Real > > _avg_grad_test
Real component(const SymmTensor &symm_tensor, unsigned int index)
std::vector< std::vector< Real > > _avg_grad_phi
const unsigned int _component
virtual Real computeQpJacobian() override

◆ computeOffDiagJacobian()

void StressDivergenceRZ::computeOffDiagJacobian ( MooseVariableFEBase &  jvar)
overrideprotectedvirtual

Definition at line 295 of file StressDivergenceRZ.C.

296 {
297  size_t jvar_num = jvar.number();
298  if (jvar_num == _var.number())
299  computeJacobian();
300  else
301  {
303  {
304  // calculate volume averaged value of shape function derivative
305  _avg_grad_test.resize(_test.size());
306  for (_i = 0; _i < _test.size(); _i++)
307  {
308  _avg_grad_test[_i].resize(2);
309  _avg_grad_test[_i][_component] = 0.0;
310  for (_qp = 0; _qp < _qrule->n_points(); _qp++)
311  {
312  if (_component == 0)
313  _avg_grad_test[_i][_component] +=
314  (_grad_test[_i][_qp](_component) + _test[_i][_qp] / _q_point[_qp](0)) * _JxW[_qp] *
315  _coord[_qp];
316  else
317  _avg_grad_test[_i][_component] +=
318  _grad_test[_i][_qp](_component) * _JxW[_qp] * _coord[_qp];
319  }
320  _avg_grad_test[_i][_component] /= _current_elem_volume;
321  }
322 
323  _avg_grad_phi.resize(jvar.phiSize());
324  for (_i = 0; _i < jvar.phiSize(); _i++)
325  {
326  _avg_grad_phi[_i].resize(3);
327  for (unsigned int component = 0; component < 2; component++)
328  {
329  _avg_grad_phi[_i][component] = 0.0;
330  for (_qp = 0; _qp < _qrule->n_points(); _qp++)
331  {
332  if (component == 0)
333  _avg_grad_phi[_i][component] +=
334  (_grad_phi[_i][_qp](component) + _phi[_i][_qp] / _q_point[_qp](0)) * _JxW[_qp] *
335  _coord[_qp];
336  else
337  _avg_grad_phi[_i][component] +=
338  _grad_phi[_i][_qp](component) * _JxW[_qp] * _coord[_qp];
339  }
340 
341  _avg_grad_phi[_i][component] /= _current_elem_volume;
342  }
343  }
344  }
345 
346  DenseMatrix<Number> & ke = _assembly.jacobianBlock(_var.number(), jvar_num);
347 
348  for (_i = 0; _i < _test.size(); _i++)
349  for (_j = 0; _j < jvar.phiSize(); _j++)
350  for (_qp = 0; _qp < _qrule->n_points(); _qp++)
351  ke(_i, _j) += _JxW[_qp] * _coord[_qp] * computeQpOffDiagJacobian(jvar_num);
352  }
353 }
std::vector< std::vector< Real > > _avg_grad_test
Real component(const SymmTensor &symm_tensor, unsigned int index)
virtual Real computeQpOffDiagJacobian(unsigned int jvar) override
std::vector< std::vector< Real > > _avg_grad_phi
const unsigned int _component
virtual void computeJacobian() override

◆ computeQpJacobian()

Real StressDivergenceRZ::computeQpJacobian ( )
overrideprotectedvirtual

Definition at line 218 of file StressDivergenceRZ.C.

Referenced by computeJacobian().

219 {
221 }
Real calculateJacobian(unsigned int ivar, unsigned int jvar)
const unsigned int _component

◆ computeQpOffDiagJacobian()

Real StressDivergenceRZ::computeQpOffDiagJacobian ( unsigned int  jvar)
overrideprotectedvirtual

Definition at line 356 of file StressDivergenceRZ.C.

Referenced by computeOffDiagJacobian().

357 {
358 
359  if (_rdisp_coupled && jvar == _rdisp_var)
360  {
361  return calculateJacobian(_component, 0);
362  }
363  else if (_zdisp_coupled && jvar == _zdisp_var)
364  {
365  return calculateJacobian(_component, 1);
366  }
367  else if (_temp_coupled && jvar == _temp_var)
368  {
369  SymmTensor test;
370  if (_component == 0)
371  {
372  test.xx() = _grad_test[_i][_qp](0);
373  test.xy() = 0.5 * _grad_test[_i][_qp](1);
374  test.zz() = _test[_i][_qp] / _q_point[_qp](0);
375  }
376  else
377  {
378  test.xy() = 0.5 * _grad_test[_i][_qp](0);
379  test.yy() = _grad_test[_i][_qp](1);
380  }
381  return _d_stress_dT[_qp].doubleContraction(test) * _phi[_j][_qp];
382  }
383 
384  return 0;
385 }
const MaterialProperty< SymmTensor > & _d_stress_dT
Real calculateJacobian(unsigned int ivar, unsigned int jvar)
const unsigned int _component
Real yy() const
Definition: SymmTensor.h:133
const unsigned int _temp_var
Real xx() const
Definition: SymmTensor.h:132
const unsigned int _zdisp_var
Real xy() const
Definition: SymmTensor.h:135
Real zz() const
Definition: SymmTensor.h:134
const unsigned int _rdisp_var

◆ computeQpResidual()

Real StressDivergenceRZ::computeQpResidual ( )
overrideprotectedvirtual

Definition at line 112 of file StressDivergenceRZ.C.

Referenced by computeResidual().

113 {
114  Real div(0);
115  if (_component == 0)
116  {
117  div = _grad_test[_i][_qp](0) * _stress[_qp].xx() +
118  // 0 * _stress[_qp].yy() +
119  +_test[_i][_qp] / _q_point[_qp](0) * _stress[_qp].zz() +
120  +_grad_test[_i][_qp](1) * _stress[_qp].xy();
121 
122  // volumetric locking correction
124  div += (_avg_grad_test[_i][0] - _grad_test[_i][_qp](0) - _test[_i][_qp] / _q_point[_qp](0)) *
125  (_stress[_qp].trace()) / 3.0;
126  }
127  else if (_component == 1)
128  {
129  div =
130  // 0 * _stress[_qp].xx() +
131  _grad_test[_i][_qp](1) * _stress[_qp].yy() +
132  // 0 * _stress[_qp].zz() +
133  _grad_test[_i][_qp](0) * _stress[_qp].xy();
134 
135  // volumetric locking correction
137  div += (_avg_grad_test[_i][1] - _grad_test[_i][_qp](1)) * (_stress[_qp].trace()) / 3.0;
138  }
139  else
140  {
141  mooseError("Invalid component");
142  }
143 
144  return div;
145 }
std::vector< std::vector< Real > > _avg_grad_test
const unsigned int _component
const MaterialProperty< SymmTensor > & _stress

◆ computeResidual()

void StressDivergenceRZ::computeResidual ( )
overrideprotectedvirtual

Definition at line 68 of file StressDivergenceRZ.C.

69 {
70  DenseVector<Number> & re = _assembly.residualBlock(_var.number());
71  _local_re.resize(re.size());
72  _local_re.zero();
73 
75  {
76  // calculate volume averaged value of shape function derivative
77  _avg_grad_test.resize(_test.size());
78  for (_i = 0; _i < _test.size(); _i++)
79  {
80  _avg_grad_test[_i].resize(2);
81  _avg_grad_test[_i][_component] = 0.0;
82  for (_qp = 0; _qp < _qrule->n_points(); _qp++)
83  {
84  if (_component == 0)
86  (_grad_test[_i][_qp](_component) + _test[_i][_qp] / _q_point[_qp](0)) * _JxW[_qp] *
87  _coord[_qp];
88  else
90  _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() override
const unsigned int _component

Member Data Documentation

◆ _avg_grad_phi

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

Definition at line 56 of file StressDivergenceRZ.h.

Referenced by calculateJacobian(), computeJacobian(), and computeOffDiagJacobian().

◆ _avg_grad_test

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

◆ _component

const unsigned int StressDivergenceRZ::_component
private

◆ _d_stress_dT

const MaterialProperty<SymmTensor>& StressDivergenceRZ::_d_stress_dT
protected

Definition at line 44 of file StressDivergenceRZ.h.

Referenced by computeQpOffDiagJacobian().

◆ _Jacobian_mult

const MaterialProperty<SymmElasticityTensor>& StressDivergenceRZ::_Jacobian_mult
protected

Definition at line 43 of file StressDivergenceRZ.h.

Referenced by calculateJacobian().

◆ _rdisp_coupled

const bool StressDivergenceRZ::_rdisp_coupled
private

Definition at line 49 of file StressDivergenceRZ.h.

Referenced by computeQpOffDiagJacobian().

◆ _rdisp_var

const unsigned int StressDivergenceRZ::_rdisp_var
private

Definition at line 52 of file StressDivergenceRZ.h.

Referenced by computeQpOffDiagJacobian().

◆ _stress

const MaterialProperty<SymmTensor>& StressDivergenceRZ::_stress
protected

Definition at line 42 of file StressDivergenceRZ.h.

Referenced by computeQpResidual().

◆ _temp_coupled

const bool StressDivergenceRZ::_temp_coupled
private

Definition at line 51 of file StressDivergenceRZ.h.

Referenced by computeQpOffDiagJacobian().

◆ _temp_var

const unsigned int StressDivergenceRZ::_temp_var
private

Definition at line 54 of file StressDivergenceRZ.h.

Referenced by computeQpOffDiagJacobian().

◆ _volumetric_locking_correction

bool StressDivergenceRZ::_volumetric_locking_correction
private

◆ _zdisp_coupled

const bool StressDivergenceRZ::_zdisp_coupled
private

Definition at line 50 of file StressDivergenceRZ.h.

Referenced by computeQpOffDiagJacobian().

◆ _zdisp_var

const unsigned int StressDivergenceRZ::_zdisp_var
private

Definition at line 53 of file StressDivergenceRZ.h.

Referenced by computeQpOffDiagJacobian().


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