www.mooseframework.org
StressDivergenceBeam.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 #include "StressDivergenceBeam.h"
11 
12 // MOOSE includes
13 #include "Assembly.h"
14 #include "Material.h"
15 #include "MooseVariable.h"
16 #include "SystemBase.h"
17 #include "RankTwoTensor.h"
18 #include "NonlinearSystem.h"
19 #include "MooseMesh.h"
20 
21 #include "libmesh/quadrature.h"
22 
23 registerMooseObject("TensorMechanicsApp", StressDivergenceBeam);
24 
26 
27 InputParameters
29 {
30  InputParameters params = Kernel::validParams();
31  params.addClassDescription("Quasi-static and dynamic stress divergence kernel for Beam element");
32  params.addRequiredParam<unsigned int>(
33  "component",
34  "An integer corresponding to the direction "
35  "the variable this kernel acts in. (0 for disp_x, "
36  "1 for disp_y, 2 for disp_z, 3 for rot_x, 4 for rot_y and 5 for rot_z)");
37  params.addRequiredCoupledVar(
38  "displacements",
39  "The displacements appropriate for the simulation geometry and coordinate system");
40  params.addRequiredCoupledVar(
41  "rotations", "The rotations appropriate for the simulation geometry and coordinate system");
42  params.addParam<MaterialPropertyName>(
43  "zeta",
44  0.0,
45  "Name of material property or a constant real number defining the zeta parameter for the "
46  "Rayleigh damping.");
47  params.addRangeCheckedParam<Real>(
48  "alpha", 0.0, "alpha >= -0.3333 & alpha <= 0.0", "alpha parameter for HHT time integration");
49 
50  params.set<bool>("use_displaced_mesh") = true;
51  return params;
52 }
53 
54 StressDivergenceBeam::StressDivergenceBeam(const InputParameters & parameters)
55  : Kernel(parameters),
56  _component(getParam<unsigned int>("component")),
57  _ndisp(coupledComponents("displacements")),
58  _disp_var(_ndisp),
59  _nrot(coupledComponents("rotations")),
60  _rot_var(_nrot),
61  _force(getMaterialPropertyByName<RealVectorValue>("forces")),
62  _moment(getMaterialPropertyByName<RealVectorValue>("moments")),
63  _K11(getMaterialPropertyByName<RankTwoTensor>("Jacobian_11")),
64  _K22(getMaterialPropertyByName<RankTwoTensor>("Jacobian_22")),
65  _K22_cross(getMaterialPropertyByName<RankTwoTensor>("Jacobian_22_cross")),
66  _K21_cross(getMaterialPropertyByName<RankTwoTensor>("Jacobian_12")),
67  _K21(getMaterialPropertyByName<RankTwoTensor>("Jacobian_21")),
68  _original_length(getMaterialPropertyByName<Real>("original_length")),
69  _total_rotation(getMaterialPropertyByName<RankTwoTensor>("total_rotation")),
70  _zeta(getMaterialProperty<Real>("zeta")),
71  _alpha(getParam<Real>("alpha")),
72  _isDamped(getParam<MaterialPropertyName>("zeta") != "0.0" || std::abs(_alpha) > 0.0),
73  _force_old(_isDamped ? &getMaterialPropertyOld<RealVectorValue>("forces") : nullptr),
74  _moment_old(_isDamped ? &getMaterialPropertyOld<RealVectorValue>("moments") : nullptr),
75  _total_rotation_old(_isDamped ? &getMaterialPropertyOld<RankTwoTensor>("total_rotation")
76  : nullptr),
77  _force_older(std::abs(_alpha) > 0.0 ? &getMaterialPropertyOlder<RealVectorValue>("forces")
78  : nullptr),
79  _moment_older(std::abs(_alpha) > 0.0 ? &getMaterialPropertyOlder<RealVectorValue>("moments")
80  : nullptr),
81  _total_rotation_older(std::abs(_alpha) > 0.0
82  ? &getMaterialPropertyOlder<RankTwoTensor>("total_rotation")
83  : nullptr),
84  _global_force_res(0),
85  _global_moment_res(0),
86  _force_local_t(0),
87  _moment_local_t(0),
88  _local_force_res(0),
89  _local_moment_res(0)
90 {
91  if (_ndisp != _nrot)
92  mooseError(
93  "StressDivergenceBeam: The number of displacement and rotation variables should be same.");
94 
95  for (unsigned int i = 0; i < _ndisp; ++i)
96  _disp_var[i] = coupled("displacements", i);
97 
98  for (unsigned int i = 0; i < _nrot; ++i)
99  _rot_var[i] = coupled("rotations", i);
100 }
101 
102 void
104 {
105  prepareVectorTag(_assembly, _var.number());
106 
107  mooseAssert(_local_re.size() == 2,
108  "StressDivergenceBeam: Beam element must have two nodes only.");
109 
110  _global_force_res.resize(_test.size());
111  _global_moment_res.resize(_test.size());
112 
114 
115  // add contributions from stiffness proportional damping (non-zero _zeta) or HHT time integration
116  // (non-zero _alpha)
117  if (_isDamped && _dt > 0.0)
119 
120  for (_i = 0; _i < _test.size(); ++_i)
121  {
122  if (_component < 3)
123  _local_re(_i) = _global_force_res[_i](_component);
124  else
125  _local_re(_i) = _global_moment_res[_i](_component - 3);
126  }
127 
128  accumulateTaggedLocalResidual();
129 
130  if (_has_save_in)
131  {
132  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
133  for (_i = 0; _i < _save_in.size(); ++_i)
134  _save_in[_i]->sys().solution().add_vector(_local_re, _save_in[_i]->dofIndices());
135  }
136 }
137 
138 void
140 {
141  prepareMatrixTag(_assembly, _var.number(), _var.number());
142 
143  for (unsigned int i = 0; i < _test.size(); ++i)
144  {
145  for (unsigned int j = 0; j < _phi.size(); ++j)
146  {
147  if (_component < 3)
148  _local_ke(i, j) = (i == j ? 1 : -1) * _K11[0](_component, _component);
149  else
150  {
151  if (i == j)
152  _local_ke(i, j) = _K22[0](_component - 3, _component - 3);
153  else
154  _local_ke(i, j) = _K22_cross[0](_component - 3, _component - 3);
155  }
156  }
157  }
158 
159  // scaling factor for Rayliegh damping and HHT time integration
160  if (_isDamped && _dt > 0.0)
161  _local_ke *= (1.0 + _alpha + (1.0 + _alpha) * _zeta[0] / _dt);
162 
163  accumulateTaggedLocalMatrix();
164 
165  if (_has_diag_save_in)
166  {
167  unsigned int rows = _local_ke.m();
168  DenseVector<Number> diag(rows);
169  for (unsigned int i = 0; i < rows; ++i)
170  diag(i) = _local_ke(i, i);
171 
172  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
173  for (unsigned int i = 0; i < _diag_save_in.size(); ++i)
174  _diag_save_in[i]->sys().solution().add_vector(diag, _diag_save_in[i]->dofIndices());
175  }
176 }
177 
178 void
180 {
181  size_t jvar_num = jvar.number();
182  if (jvar_num == _var.number())
183  computeJacobian();
184  else
185  {
186  unsigned int coupled_component = 0;
187  bool disp_coupled = false;
188  bool rot_coupled = false;
189 
190  for (unsigned int i = 0; i < _ndisp; ++i)
191  {
192  if (jvar_num == _disp_var[i])
193  {
194  coupled_component = i;
195  disp_coupled = true;
196  break;
197  }
198  }
199 
200  for (unsigned int i = 0; i < _nrot; ++i)
201  {
202  if (jvar_num == _rot_var[i])
203  {
204  coupled_component = i + 3;
205  rot_coupled = true;
206  break;
207  }
208  }
209 
210  prepareMatrixTag(_assembly, _var.number(), jvar_num);
211 
212  if (disp_coupled || rot_coupled)
213  {
214  for (unsigned int i = 0; i < _test.size(); ++i)
215  {
216  for (unsigned int j = 0; j < _phi.size(); ++j)
217  {
218  if (_component < 3 && coupled_component < 3)
219  _local_ke(i, j) += (i == j ? 1 : -1) * _K11[0](_component, coupled_component);
220  else if (_component < 3 && coupled_component > 2)
221  {
222  if (i == 0)
223  _local_ke(i, j) += _K21[0](coupled_component - 3, _component);
224  else
225  _local_ke(i, j) += _K21_cross[0](coupled_component - 3, _component);
226  }
227  else if (_component > 2 && coupled_component < 3)
228  {
229  if (j == 0)
230  _local_ke(i, j) += _K21[0](_component - 3, coupled_component);
231  else
232  _local_ke(i, j) += _K21_cross[0](_component - 3, coupled_component);
233  }
234  else
235  {
236  if (i == j)
237  _local_ke(i, j) += _K22[0](_component - 3, coupled_component - 3);
238  else
239  _local_ke(i, j) += _K22_cross[0](_component - 3, coupled_component - 3);
240  }
241  }
242  }
243  }
244 
245  // scaling factor for Rayleigh damping and HHT time integration
246  if (_isDamped && _dt > 0.0)
247  _local_ke *= (1.0 + _alpha + (1.0 + _alpha) * _zeta[0] / _dt);
248 
249  accumulateTaggedLocalMatrix();
250  }
251 }
252 
253 void
254 StressDivergenceBeam::computeDynamicTerms(std::vector<RealVectorValue> & global_force_res,
255  std::vector<RealVectorValue> & global_moment_res)
256 {
257  mooseAssert(_zeta[0] >= 0.0, "StressDivergenceBeam: Zeta parameter should be non-negative.");
258  std::vector<RealVectorValue> global_force_res_old(_test.size());
259  std::vector<RealVectorValue> global_moment_res_old(_test.size());
261  _force_old, _moment_old, _total_rotation_old, global_force_res_old, global_moment_res_old);
262 
263  // For HHT calculation, the global force and moment residual from t_older is required
264  std::vector<RealVectorValue> global_force_res_older(_test.size());
265  std::vector<RealVectorValue> global_moment_res_older(_test.size());
266 
267  if (std::abs(_alpha) > 0.0)
271  global_force_res_older,
272  global_moment_res_older);
273 
274  // Update the global_force_res and global_moment_res to include HHT and Rayleigh damping
275  // contributions
276  for (_i = 0; _i < _test.size(); ++_i)
277  {
278  global_force_res[_i] =
279  global_force_res[_i] * (1.0 + _alpha + (1.0 + _alpha) * _zeta[0] / _dt) -
280  global_force_res_old[_i] * (_alpha + (1.0 + 2.0 * _alpha) * _zeta[0] / _dt) +
281  global_force_res_older[_i] * (_alpha * _zeta[0] / _dt);
282  global_moment_res[_i] =
283  global_moment_res[_i] * (1.0 + _alpha + (1.0 + _alpha) * _zeta[0] / _dt) -
284  global_moment_res_old[_i] * (_alpha + (1.0 + 2.0 * _alpha) * _zeta[0] / _dt) +
285  global_moment_res_older[_i] * (_alpha * _zeta[0] / _dt);
286  }
287 }
288 
289 void
290 StressDivergenceBeam::computeGlobalResidual(const MaterialProperty<RealVectorValue> * force,
291  const MaterialProperty<RealVectorValue> * moment,
292  const MaterialProperty<RankTwoTensor> * total_rotation,
293  std::vector<RealVectorValue> & global_force_res,
294  std::vector<RealVectorValue> & global_moment_res)
295 {
296  RealVectorValue a;
297  _force_local_t.resize(_qrule->n_points());
298  _moment_local_t.resize(_qrule->n_points());
299  _local_force_res.resize(_test.size());
300  _local_moment_res.resize(_test.size());
301 
302  // convert forces/moments from global coordinate system to current beam local configuration
303  for (_qp = 0; _qp < _qrule->n_points(); ++_qp)
304  {
305  _force_local_t[_qp] = (*total_rotation)[0] * (*force)[_qp];
306  _moment_local_t[_qp] = (*total_rotation)[0] * (*moment)[_qp];
307  }
308 
309  // residual for displacement variables
310  for (_i = 0; _i < _test.size(); ++_i)
311  {
312  _local_force_res[_i] = a;
313  for (unsigned int component = 0; component < 3; ++component)
314  {
315  for (_qp = 0; _qp < _qrule->n_points(); ++_qp)
317  (_i == 0 ? -1 : 1) * _force_local_t[_qp](component) * 0.5;
318  }
319  }
320 
321  // residual for rotation variables
322  for (_i = 0; _i < _test.size(); ++_i)
323  {
324  _local_moment_res[_i] = a;
325  for (unsigned int component = 3; component < 6; ++component)
326  {
327  for (_qp = 0; _qp < _qrule->n_points(); ++_qp)
328  {
329  if (component == 3)
330  _local_moment_res[_i](component - 3) +=
331  (_i == 0 ? -1 : 1) * _moment_local_t[_qp](0) * 0.5;
332  else if (component == 4)
333  _local_moment_res[_i](component - 3) +=
334  (_i == 0 ? -1 : 1) * _moment_local_t[_qp](1) * 0.5 +
335  _force_local_t[_qp](2) * 0.25 * _original_length[0];
336  else
337  _local_moment_res[_i](component - 3) +=
338  (_i == 0 ? -1 : 1) * -_moment_local_t[_qp](2) * 0.5 -
339  _force_local_t[_qp](1) * 0.25 * _original_length[0];
340  }
341  }
342  }
343 
344  // convert residual for each variable from current beam local configuration to global
345  // configuration
346  for (_i = 0; _i < _test.size(); ++_i)
347  {
348  global_force_res[_i] = (*total_rotation)[0].transpose() * _local_force_res[_i];
349  global_moment_res[_i] = (*total_rotation)[0].transpose() * _local_moment_res[_i];
350  }
351 }
StressDivergenceBeam::_component
const unsigned int _component
Direction along which force/moment is calculated.
Definition: StressDivergenceBeam.h:49
StressDivergenceBeam::computeGlobalResidual
void computeGlobalResidual(const MaterialProperty< RealVectorValue > *force, const MaterialProperty< RealVectorValue > *moment, const MaterialProperty< RankTwoTensor > *total_rotation, std::vector< RealVectorValue > &global_force_res, std::vector< RealVectorValue > &global_moment_res)
Computes the residual corresponding to displacement and rotational variables given the forces and mom...
Definition: StressDivergenceBeam.C:290
StressDivergenceBeam::_local_force_res
std::vector< RealVectorValue > _local_force_res
Residual corresponding to displacement DOFs at the nodes in beam local coordinate system.
Definition: StressDivergenceBeam.h:130
StressDivergenceBeam::_original_length
const MaterialProperty< Real > & _original_length
Initial length of beam.
Definition: StressDivergenceBeam.h:85
StressDivergenceBeam::_global_moment_res
std::vector< RealVectorValue > _global_moment_res
Residual corresponding to rotational DOFs at the nodes in global coordinate system.
Definition: StressDivergenceBeam.h:121
StressDivergenceBeam::_moment_local_t
std::vector< RealVectorValue > _moment_local_t
Moments at each Qp in the beam local configuration.
Definition: StressDivergenceBeam.h:127
StressDivergenceBeam::computeOffDiagJacobian
virtual void computeOffDiagJacobian(MooseVariableFEBase &jvar) override
Definition: StressDivergenceBeam.C:179
StressDivergenceBeam::_zeta
const MaterialProperty< Real > & _zeta
Stiffness proportional Rayleigh damping parameter.
Definition: StressDivergenceBeam.h:91
StressDivergenceBeam::_force_local_t
std::vector< RealVectorValue > _force_local_t
Forces at each Qp in the beam local configuration.
Definition: StressDivergenceBeam.h:124
StressDivergenceBeam::_rot_var
std::vector< unsigned int > _rot_var
Variable numbers corresponding to rotational variables.
Definition: StressDivergenceBeam.h:61
StressDivergenceBeam::_ndisp
unsigned int _ndisp
Number of coupled displacement variables.
Definition: StressDivergenceBeam.h:52
registerMooseObject
registerMooseObject("TensorMechanicsApp", StressDivergenceBeam)
StressDivergenceBeam::_local_moment_res
std::vector< RealVectorValue > _local_moment_res
Residual corresponding to rotational DOFs at the nodes in beam local coordinate system.
Definition: StressDivergenceBeam.h:133
StressDivergenceBeam::_K21_cross
const MaterialProperty< RankTwoTensor > & _K21_cross
Stiffness matrix relating displacement of one node to rotations of another node.
Definition: StressDivergenceBeam.h:79
StressDivergenceBeam::_force
const MaterialProperty< RealVectorValue > & _force
Current force vector in global coordinate system.
Definition: StressDivergenceBeam.h:64
StressDivergenceBeam::_nrot
unsigned int _nrot
Number of coupled rotational variables.
Definition: StressDivergenceBeam.h:58
StressDivergenceBeam::computeDynamicTerms
void computeDynamicTerms(std::vector< RealVectorValue > &global_force_res, std::vector< RealVectorValue > &global_moment_res)
Computes the force and moment due to stiffness proportional damping and HHT time integration.
Definition: StressDivergenceBeam.C:254
StressDivergenceBeam::_global_force_res
std::vector< RealVectorValue > _global_force_res
Residual corresponding to displacement DOFs at the nodes in global coordinate system.
Definition: StressDivergenceBeam.h:118
StressDivergenceBeam.h
StressDivergenceBeam::_disp_var
std::vector< unsigned int > _disp_var
Variable numbers corresponding to displacement variables.
Definition: StressDivergenceBeam.h:55
StressDivergenceBeam::validParams
static InputParameters validParams()
Definition: StressDivergenceBeam.C:28
StressDivergenceBeam::_isDamped
const bool _isDamped
Boolean flag to turn on Rayleigh damping or numerical damping due to HHT time integration.
Definition: StressDivergenceBeam.h:97
StressDivergenceBeam::computeResidual
virtual void computeResidual() override
Definition: StressDivergenceBeam.C:103
StressDivergenceBeam::StressDivergenceBeam
StressDivergenceBeam(const InputParameters &parameters)
Definition: StressDivergenceBeam.C:54
StressDivergenceBeam::_K22
const MaterialProperty< RankTwoTensor > & _K22
Stiffness matrix relating rotational DOFs of same node.
Definition: StressDivergenceBeam.h:73
StressDivergenceBeam::_total_rotation
const MaterialProperty< RankTwoTensor > & _total_rotation
Rotational transformation from global to current beam local coordinate system.
Definition: StressDivergenceBeam.h:88
StressDivergenceBeam::_K11
const MaterialProperty< RankTwoTensor > & _K11
Stiffness matrix relating displacement DOFs of same node or across nodes.
Definition: StressDivergenceBeam.h:70
validParams
InputParameters validParams()
StressDivergenceBeam::_total_rotation_older
const MaterialProperty< RankTwoTensor > * _total_rotation_older
Rotational transformation from global to older beam local coordinate system.
Definition: StressDivergenceBeam.h:115
MaterialTensorCalculatorTools::component
Real component(const SymmTensor &symm_tensor, unsigned int index)
Definition: MaterialTensorCalculatorTools.C:16
StressDivergenceBeam::_moment_older
const MaterialProperty< RealVectorValue > * _moment_older
Older moment vector in global coordinate system.
Definition: StressDivergenceBeam.h:112
StressDivergenceBeam::_alpha
const Real & _alpha
HHT time integration parameter.
Definition: StressDivergenceBeam.h:94
defineLegacyParams
defineLegacyParams(StressDivergenceBeam)
StressDivergenceBeam::_K22_cross
const MaterialProperty< RankTwoTensor > & _K22_cross
Stiffness matrix relating rotational DOFs across nodes.
Definition: StressDivergenceBeam.h:76
StressDivergenceBeam::_moment
const MaterialProperty< RealVectorValue > & _moment
Current moment vector in global coordinate system.
Definition: StressDivergenceBeam.h:67
StressDivergenceBeam::_moment_old
const MaterialProperty< RealVectorValue > * _moment_old
Old moment vector in global coordinate system.
Definition: StressDivergenceBeam.h:103
StressDivergenceBeam::computeJacobian
virtual void computeJacobian() override
Definition: StressDivergenceBeam.C:139
RankTwoTensorTempl< Real >
StressDivergenceBeam::_force_older
const MaterialProperty< RealVectorValue > * _force_older
Older force vector in global coordinate system.
Definition: StressDivergenceBeam.h:109
StressDivergenceBeam::_force_old
const MaterialProperty< RealVectorValue > * _force_old
Old force vector in global coordinate system.
Definition: StressDivergenceBeam.h:100
StressDivergenceBeam::_K21
const MaterialProperty< RankTwoTensor > & _K21
Stiffness matrix relating displacement and rotations of same node.
Definition: StressDivergenceBeam.h:82
StressDivergenceBeam::_total_rotation_old
const MaterialProperty< RankTwoTensor > * _total_rotation_old
Rotational transformation from global to old beam local coordinate system.
Definition: StressDivergenceBeam.h:106
StressDivergenceBeam
Definition: StressDivergenceBeam.h:23