www.mooseframework.org
TorqueReaction.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
3 /* */
4 /* All contents are licensed under LGPL V2.1 */
5 /* See LICENSE for full restrictions */
6 /****************************************************************/
7 
8 #include "TorqueReaction.h"
9 
10 // MOOSE includes
11 #include "AuxiliarySystem.h"
12 #include "MooseVariable.h"
13 
14 template <>
15 InputParameters
17 {
18  InputParameters params = validParams<NodalPostprocessor>();
19  params.addRequiredParam<std::vector<AuxVariableName>>("react", "The reaction variables");
20  params.addParam<RealVectorValue>(
21  "axis_origin", Point(), "Origin of the axis of rotation used to calculate the torque");
22  params.addRequiredParam<RealVectorValue>("direction_vector",
23  "The direction vector of the axis "
24  "of rotation about which the "
25  "calculated torque is calculated");
26  params.set<bool>("use_displaced_mesh") = true;
27  return params;
28 }
29 
30 TorqueReaction::TorqueReaction(const InputParameters & parameters)
31  : NodalPostprocessor(parameters),
32  _aux(_fe_problem.getAuxiliarySystem()),
33  _axis_origin(getParam<RealVectorValue>("axis_origin")),
34  _direction_vector(getParam<RealVectorValue>("direction_vector"))
35 {
36  std::vector<AuxVariableName> reacts = getParam<std::vector<AuxVariableName>>("react");
37  _nrt = reacts.size();
38 
39  for (unsigned int i = 0; i < _nrt; ++i)
40  _react.push_back(&_aux.getVariable(_tid, reacts[i]).nodalSln());
41 }
42 
43 void
45 {
46  _sum = 0.0;
47 }
48 
49 void
51 {
52  // Tranform the node coordinates into the coordinate system specified by the user
53  Point position = (*_current_node) - _axis_origin;
54 
55  // Determine the component of the vector in the direction of the rotation direction vector
56  Point normal_position_component =
57  position - (position * _direction_vector) / _direction_vector.norm_sq() * _direction_vector;
58 
59  // Define the force vector from the reaction force/ residuals from the stress divergence kernel
60  Real _rz;
61  if (_nrt == 3)
62  _rz = (*_react[2])[_qp];
63  else
64  _rz = 0.0;
65 
66  Point force((*_react[0])[_qp], (*_react[1])[_qp], _rz);
67 
68  // Cross the normal component of the position vector with the force
69  RealVectorValue torque = normal_position_component.cross(force);
70 
71  // Find the component of the torque vector acting along the given axis of rotation direction
72  // vector
73  RealVectorValue parallel_torque_component =
74  (torque * _direction_vector) / _direction_vector.norm_sq() * _direction_vector;
75 
76  // Add the magnitude of the parallel torque component to the sum of the acting torques
77  _sum += parallel_torque_component.norm();
78 }
79 
80 Real
82 {
83  gatherSum(_sum);
84 
85  return _sum;
86 }
87 
88 void
89 TorqueReaction::threadJoin(const UserObject & y)
90 {
91  const TorqueReaction & pps = static_cast<const TorqueReaction &>(y);
92  _sum += pps._sum;
93 }
void threadJoin(const UserObject &y)
const Point _axis_origin
virtual void initialize()
InputParameters validParams< TorqueReaction >()
TorqueReaction(const InputParameters &parameters)
unsigned int _nrt
virtual void execute()
AuxiliarySystem & _aux
virtual Real getValue()
std::vector< const VariableValue * > _react
const Point _direction_vector