www.mooseframework.org
NodalRotationalInertia.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 "NodalRotationalInertia.h"
11 #include "MooseVariable.h"
12 #include "AuxiliarySystem.h"
13 #include "MooseMesh.h"
14 
15 registerMooseObject("TensorMechanicsApp", NodalRotationalInertia);
16 
18 
19 InputParameters
21 {
22  InputParameters params = TimeNodalKernel::validParams();
23  params.addClassDescription("Calculates the inertial torques and inertia proportional damping "
24  "corresponding to the nodal rotational inertia.");
25  params.addCoupledVar("rotations", "rotational displacement variables");
26  params.addCoupledVar("rotational_velocities", "rotational velocity variables");
27  params.addCoupledVar("rotational_accelerations", "rotational acceleration variables");
28  params.addRangeCheckedParam<Real>(
29  "beta", "beta>0.0", "beta parameter for Newmark Time integration");
30  params.addRangeCheckedParam<Real>(
31  "gamma", "gamma>0.0", "gamma parameter for Newmark Time integration");
32  params.addRangeCheckedParam<Real>("eta",
33  0.0,
34  "eta>=0.0",
35  "Constant real number defining the eta parameter for"
36  "Rayleigh damping.");
37  params.addRangeCheckedParam<Real>("alpha",
38  0.0,
39  "alpha >= -0.3333 & alpha <= 0.0",
40  "Alpha parameter for mass dependent numerical damping induced "
41  "by HHT time integration scheme");
42  params.addRequiredRangeCheckedParam<Real>(
43  "Ixx", "Ixx>0.0", "Moment of inertia in the x direction.");
44  params.addRequiredRangeCheckedParam<Real>(
45  "Iyy", "Iyy>0.0", "Moment of inertia in the y direction.");
46  params.addRequiredRangeCheckedParam<Real>(
47  "Izz", "Izz>0.0", "Moment of inertia in the z direction.");
48  params.addParam<Real>("Ixy", 0.0, "Moment of inertia in the xy direction.");
49  params.addParam<Real>("Ixz", 0.0, "Moment of inertia in the xz direction.");
50  params.addParam<Real>("Iyz", 0.0, "Moment of inertia in the yz direction.");
51  params.addParam<RealGradient>(
52  "x_orientation", "Unit vector along the x direction if different from global x direction.");
53  params.addParam<RealGradient>(
54  "y_orientation", "Unit vector along the y direction if different from global y direction.");
55  params.addRequiredRangeCheckedParam<unsigned int>(
56  "component",
57  "component<3",
58  "An integer corresponding to the direction "
59  "the variable this nodalkernel acts in. (0 for rot_x, "
60  "1 for rot_y, and 2 for rot_z).");
61  return params;
62 }
63 
64 NodalRotationalInertia::NodalRotationalInertia(const InputParameters & parameters)
65  : TimeNodalKernel(parameters),
66  _has_beta(isParamValid("beta")),
67  _has_gamma(isParamValid("gamma")),
68  _has_rot_velocities(isParamValid("rotational_velocities")),
69  _has_rot_accelerations(isParamValid("rotational_accelerations")),
70  _has_x_orientation(isParamValid("x_orientation")),
71  _has_y_orientation(isParamValid("y_orientation")),
72  _nrot(coupledComponents("rotations")),
73  _rot(_nrot),
74  _rot_old(_nrot),
75  _rot_vel_num(_nrot),
76  _rot_accel_num(_nrot),
77  _rot_variables(_nrot),
78  _rot_accel(_nrot),
79  _rot_vel(_nrot),
80  _rot_vel_old(_nrot),
81  _beta(_has_beta ? getParam<Real>("beta") : 0.1),
82  _gamma(_has_gamma ? getParam<Real>("gamma") : 0.1),
83  _eta(getParam<Real>("eta")),
84  _alpha(getParam<Real>("alpha")),
85  _component(getParam<unsigned int>("component")),
86  _rot_vel_value(_nrot),
87  _rot_vel_old_value(_nrot),
88  _rot_accel_value(_nrot)
89 {
91  {
92  _aux_sys = &(_fe_problem.getAuxiliarySystem());
93  if (coupledComponents("rotational_velocities") != _nrot ||
94  coupledComponents("rotational_accelerations") != _nrot)
95  mooseError(
96  "NodalRotationalInertia: rotational_velocities and rotational_accelerations should "
97  "be same size "
98  "as rotations.");
99 
100  for (unsigned int i = 0; i < _nrot; ++i)
101  {
102  MooseVariable * rot_var = getVar("rotations", i);
103  MooseVariable * rot_vel_var = getVar("rotational_velocities", i);
104  MooseVariable * rot_accel_var = getVar("rotational_accelerations", i);
105 
106  _rot[i] = &rot_var->dofValues();
107  _rot_old[i] = &rot_var->dofValuesOld();
108 
109  _rot_vel_num[i] = rot_vel_var->number();
110  _rot_accel_num[i] = rot_accel_var->number();
111 
112  _rot_variables[i] = coupled("rotations", i);
113  }
114  }
116  {
117  for (unsigned int i = 0; i < _nrot; ++i)
118  {
119  MooseVariable * rot_var = getVar("rotations", i);
120  _rot_vel_value[i] = &rot_var->dofValuesDot();
121  _rot_vel_old_value[i] = &rot_var->dofValuesDotOld();
122  _rot_accel_value[i] = &rot_var->dofValuesDotDot();
123 
124  if (i == 0)
125  {
126  _du_dot_du = &rot_var->dofValuesDuDotDu();
127  _du_dotdot_du = &rot_var->dofValuesDuDotDotDu();
128  }
129  }
130  }
131  else
132  mooseError("NodalRotationalInertia: Either all or none of `beta`, `gamma`, "
133  "`rotational_velocities` and `rotational_accelerations` should be provided as "
134  "input.");
135 
136  // Store inertia values in inertia tensor
137  _inertia.zero();
138  _inertia(0, 0) = getParam<Real>("Ixx");
139  _inertia(0, 1) = getParam<Real>("Ixy");
140  _inertia(0, 2) = getParam<Real>("Ixz");
141  _inertia(1, 0) = _inertia(0, 1);
142  _inertia(1, 1) = getParam<Real>("Iyy");
143  _inertia(1, 2) = getParam<Real>("Iyz");
144  _inertia(2, 0) = _inertia(0, 2);
145  _inertia(2, 1) = _inertia(1, 2);
146  _inertia(2, 2) = getParam<Real>("Izz");
147 
148  // Check for positive definiteness of matrix using Sylvester's criterion.
149  const Real det1 = _inertia(0, 0);
150  const Real det2 = _inertia(0, 0) * _inertia(1, 1) - _inertia(0, 1) * _inertia(1, 0);
151  const Real det3 = _inertia.det();
152 
153  if (det1 < 1e-6 || det2 < 1e-6 || det3 < 1e-6)
154  mooseError("NodalRotationalInertia: The moment of inertia tensor should be positive definite.");
156  {
157  const RealGradient x_orientation = getParam<RealGradient>("x_orientation");
158  const RealGradient y_orientation = getParam<RealGradient>("y_orientation");
159 
160  if (std::abs(x_orientation.norm() - 1.0) > 1e-6 || std::abs(y_orientation.norm() - 1.0) > 1e-6)
161  mooseError("NodalRotationalInertia: x_orientation and y_orientation must be unit vectors.");
162 
163  Real sum = x_orientation(0) * y_orientation(0) + x_orientation(1) * y_orientation(1) +
164  x_orientation(2) * y_orientation(2);
165 
166  if (std::abs(sum) > 1e-4)
167  mooseError("NodalRotationalInertia: x_orientation and y_orientation should be perpendicular "
168  "to each other.");
169 
170  // Calculate z orientation as a cross product of the x and y orientations
171  RealGradient z_orientation;
172  z_orientation(0) = (x_orientation(1) * y_orientation(2) - x_orientation(2) * y_orientation(1));
173  z_orientation(1) = (x_orientation(2) * y_orientation(0) - x_orientation(0) * y_orientation(2));
174  z_orientation(2) = (x_orientation(0) * y_orientation(1) - x_orientation(1) * y_orientation(0));
175 
176  // Rotation matrix from global to original beam local configuration
177  RankTwoTensor orientation;
178  orientation(0, 0) = x_orientation(0);
179  orientation(0, 1) = x_orientation(1);
180  orientation(0, 2) = x_orientation(2);
181  orientation(1, 0) = y_orientation(0);
182  orientation(1, 1) = y_orientation(1);
183  orientation(1, 2) = y_orientation(2);
184  orientation(2, 0) = z_orientation(0);
185  orientation(2, 1) = z_orientation(1);
186  orientation(2, 2) = z_orientation(2);
187 
188  RankTwoTensor global_inertia = orientation.transpose() * _inertia * orientation;
189  _inertia = global_inertia;
190  }
191  else if ((_has_x_orientation && !_has_y_orientation) ||
193  mooseError("NodalRotationalInertia: Both x_orientation and y_orientation should be provided if "
194  "x_orientation or "
195  "y_orientation is different from global x or y direction, respectively.");
196 }
197 
198 Real
200 {
201  if (_dt == 0)
202  return 0;
203  else
204  {
205  if (_has_beta)
206  {
207  mooseAssert(_beta > 0.0, "NodalRotationalInertia: Beta parameter should be positive.");
208 
209  const NumericVector<Number> & aux_sol_old = _aux_sys->solutionOld();
210 
211  for (unsigned int i = 0; i < _nrot; ++i)
212  {
213  _rot_vel_old[i] =
214  aux_sol_old(_current_node->dof_number(_aux_sys->number(), _rot_vel_num[i], 0));
215  const Real rot_accel_old =
216  aux_sol_old(_current_node->dof_number(_aux_sys->number(), _rot_accel_num[i], 0));
217 
218  _rot_accel[i] = 1.0 / _beta *
219  ((((*_rot[i])[_qp] - (*_rot_old[i])[_qp]) / (_dt * _dt)) -
220  _rot_vel_old[i] / _dt - rot_accel_old * (0.5 - _beta));
221  _rot_vel[i] =
222  _rot_vel_old[i] + (_dt * (1.0 - _gamma)) * rot_accel_old + _gamma * _dt * _rot_accel[i];
223  }
224 
225  Real res = 0.0;
226  for (unsigned int i = 0; i < _nrot; ++i)
227  res += _inertia(_component, i) * (_rot_accel[i] + _rot_vel[i] * _eta * (1.0 + _alpha) -
228  _alpha * _eta * _rot_vel_old[i]);
229 
230  return res;
231  }
232  else
233  {
234  Real res = 0.0;
235  for (unsigned int i = 0; i < _nrot; ++i)
236  res += _inertia(_component, i) *
237  ((*_rot_accel_value[i])[_qp] + (*_rot_vel_value[i])[_qp] * _eta * (1.0 + _alpha) -
238  _alpha * _eta * (*_rot_vel_old_value[i])[_qp]);
239 
240  return res;
241  }
242  }
243 }
244 
245 Real
247 {
248  mooseAssert(_beta > 0.0, "NodalRotationalInertia: Beta parameter should be positive.");
249 
250  if (_dt == 0)
251  return 0.0;
252  else
253  {
254  if (_has_beta)
255  return _inertia(_component, _component) / (_beta * _dt * _dt) +
256  _eta * (1.0 + _alpha) * _inertia(_component, _component) * _gamma / _beta / _dt;
257  else
258  return _inertia(_component, _component) * (*_du_dotdot_du)[_qp] +
259  _eta * (1.0 + _alpha) * _inertia(_component, _component) * (*_du_dot_du)[_qp];
260  }
261 }
262 
263 Real
265 {
266  unsigned int coupled_component = 0;
267  bool rot_coupled = false;
268 
269  mooseAssert(_beta > 0.0, "NodalRotationalInertia: Beta parameter should be positive.");
270 
271  for (unsigned int i = 0; i < _nrot; ++i)
272  {
273  if (jvar == _rot_variables[i])
274  {
275  coupled_component = i;
276  rot_coupled = true;
277  break;
278  }
279  }
280 
281  if (_dt == 0)
282  return 0.0;
283  else if (rot_coupled)
284  {
285  if (_has_beta)
286  return _inertia(_component, coupled_component) / (_beta * _dt * _dt) +
287  _eta * (1.0 + _alpha) * _inertia(_component, coupled_component) * _gamma / _beta / _dt;
288  else
289  return _inertia(_component, coupled_component) * (*_du_dotdot_du)[_qp] +
290  _eta * (1.0 + _alpha) * _inertia(_component, coupled_component) * (*_du_dot_du)[_qp];
291  }
292  else
293  return 0.0;
294 }
NodalRotationalInertia::_beta
const Real _beta
Newmark time integration parameter.
Definition: NodalRotationalInertia.h:78
NodalRotationalInertia::_nrot
unsigned int _nrot
Number of coupled rotational variables.
Definition: NodalRotationalInertia.h:51
defineLegacyParams
defineLegacyParams(NodalRotationalInertia)
NodalRotationalInertia::_alpha
const Real & _alpha
HHT time integration parameter.
Definition: NodalRotationalInertia.h:87
NodalRotationalInertia::_du_dotdot_du
const VariableValue * _du_dotdot_du
du_dotdot_du value
Definition: NodalRotationalInertia.h:108
NodalRotationalInertia::_has_rot_velocities
const bool _has_rot_velocities
Definition: NodalRotationalInertia.h:42
libMesh::RealGradient
VectorValue< Real > RealGradient
Definition: GrainForceAndTorqueInterface.h:17
NodalRotationalInertia::_rot
std::vector< const VariableValue * > _rot
Value of rotational displacements.
Definition: NodalRotationalInertia.h:54
NodalRotationalInertia::_has_beta
const bool _has_beta
Booleans for validity of params.
Definition: NodalRotationalInertia.h:40
NodalRotationalInertia::_rot_accel_num
std::vector< unsigned int > _rot_accel_num
Variable numbers for rotational acceleration aux variables.
Definition: NodalRotationalInertia.h:63
NodalRotationalInertia.h
NodalRotationalInertia::_has_gamma
const bool _has_gamma
Definition: NodalRotationalInertia.h:41
NodalRotationalInertia::_rot_old
std::vector< const VariableValue * > _rot_old
Old value of rotational displacements.
Definition: NodalRotationalInertia.h:57
NodalRotationalInertia::validParams
static InputParameters validParams()
Definition: NodalRotationalInertia.C:20
NodalRotationalInertia::_rot_vel_value
std::vector< const VariableValue * > _rot_vel_value
Velocity value.
Definition: NodalRotationalInertia.h:96
NodalRotationalInertia::_has_rot_accelerations
const bool _has_rot_accelerations
Definition: NodalRotationalInertia.h:43
NodalRotationalInertia::_has_y_orientation
const bool _has_y_orientation
Definition: NodalRotationalInertia.h:45
NodalRotationalInertia::_eta
const Real & _eta
Mass proportional Rayliegh damping.
Definition: NodalRotationalInertia.h:84
NodalRotationalInertia::_rot_accel_value
std::vector< const VariableValue * > _rot_accel_value
Acceleration value.
Definition: NodalRotationalInertia.h:102
NodalRotationalInertia::_du_dot_du
const VariableValue * _du_dot_du
du_dot_du value
Definition: NodalRotationalInertia.h:105
NodalRotationalInertia::_rot_vel
std::vector< Real > _rot_vel
Current velocity of the node.
Definition: NodalRotationalInertia.h:72
NodalRotationalInertia::computeQpJacobian
virtual Real computeQpJacobian() override
Definition: NodalRotationalInertia.C:246
validParams
InputParameters validParams()
NodalRotationalInertia::_has_x_orientation
const bool _has_x_orientation
Definition: NodalRotationalInertia.h:44
registerMooseObject
registerMooseObject("TensorMechanicsApp", NodalRotationalInertia)
NodalRotationalInertia::computeQpResidual
virtual Real computeQpResidual() override
Definition: NodalRotationalInertia.C:199
NodalRotationalInertia
Calculates the inertial torque and inertia proportional damping for nodal rotational inertia.
Definition: NodalRotationalInertia.h:25
NodalRotationalInertia::_component
const unsigned int _component
Component along which torque is applied.
Definition: NodalRotationalInertia.h:90
NodalRotationalInertia::_aux_sys
AuxiliarySystem * _aux_sys
Auxiliary system object.
Definition: NodalRotationalInertia.h:48
NodalRotationalInertia::_rot_vel_old
std::vector< Real > _rot_vel_old
Old velocity of the node.
Definition: NodalRotationalInertia.h:75
NodalRotationalInertia::computeQpOffDiagJacobian
virtual Real computeQpOffDiagJacobian(unsigned int jvar) override
Definition: NodalRotationalInertia.C:264
NodalRotationalInertia::_rot_variables
std::vector< unsigned int > _rot_variables
Variable numbers for rotational variables.
Definition: NodalRotationalInertia.h:66
RankTwoTensorTempl< Real >
NodalRotationalInertia::_rot_vel_old_value
std::vector< const VariableValue * > _rot_vel_old_value
Old velocity value.
Definition: NodalRotationalInertia.h:99
NodalRotationalInertia::_rot_vel_num
std::vector< unsigned int > _rot_vel_num
Variable numbers for rotational velocity aux variables.
Definition: NodalRotationalInertia.h:60
NodalRotationalInertia::_rot_accel
std::vector< Real > _rot_accel
Current acceleration of the node.
Definition: NodalRotationalInertia.h:69
NodalRotationalInertia::_inertia
RankTwoTensor _inertia
Moment of inertia tensor in global coordinate system.
Definition: NodalRotationalInertia.h:93
NodalRotationalInertia::NodalRotationalInertia
NodalRotationalInertia(const InputParameters &parameters)
Definition: NodalRotationalInertia.C:64
NodalRotationalInertia::_gamma
const Real _gamma
Newmark time integration parameter.
Definition: NodalRotationalInertia.h:81