www.mooseframework.org
TorqueReaction.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 "TorqueReaction.h"
11 
12 // MOOSE includes
13 #include "AuxiliarySystem.h"
14 #include "MooseVariable.h"
15 
16 registerMooseObject("SolidMechanicsApp", TorqueReaction);
17 
20 {
22  params.addClassDescription("TorqueReaction calculates the torque in 2D and 3D"
23  "about a user-specified axis of rotation centered"
24  "at a user-specified origin.");
25  params.addRequiredParam<std::vector<AuxVariableName>>("reaction_force_variables",
26  "The reaction variables");
27  params.addParam<RealVectorValue>(
28  "axis_origin", Point(), "Origin of the axis of rotation used to calculate the torque");
29  params.addRequiredParam<RealVectorValue>("direction_vector",
30  "The direction vector of the axis "
31  "of rotation about which the "
32  "calculated torque is calculated");
33  params.set<bool>("use_displaced_mesh") = true;
34  return params;
35 }
36 
38  : NodalPostprocessor(parameters),
39  _aux(_fe_problem.getAuxiliarySystem()),
40  _axis_origin(getParam<RealVectorValue>("axis_origin")),
41  _direction_vector(getParam<RealVectorValue>("direction_vector"))
42 {
43  std::vector<AuxVariableName> reacts =
44  getParam<std::vector<AuxVariableName>>("reaction_force_variables");
45  _nrt = reacts.size();
46 
47  for (unsigned int i = 0; i < _nrt; ++i)
48  _react.push_back(&_aux.getFieldVariable<Real>(_tid, reacts[i]).dofValues());
49 }
50 
51 void
53 {
54  _sum = 0.0;
55 }
56 
57 void
59 {
60  // Tranform the node coordinates into the coordinate system specified by the user
61  Point position = (*_current_node) - _axis_origin;
62 
63  // Determine the component of the vector in the direction of the rotation direction vector
64  Point normal_position_component =
65  position - (position * _direction_vector) / _direction_vector.norm_sq() * _direction_vector;
66 
67  // Define the force vector from the reaction force/ residuals from the stress divergence kernel
68  Real _rz;
69  if (_nrt == 3)
70  _rz = (*_react[2])[_qp];
71  else
72  _rz = 0.0;
73 
74  Point force((*_react[0])[_qp], (*_react[1])[_qp], _rz);
75 
76  // Cross the normal component of the position vector with the force
77  RealVectorValue torque = normal_position_component.cross(force);
78 
79  // Find the component of the torque vector acting along the given axis of rotation direction
80  // vector
81  RealVectorValue parallel_torque_component =
82  (torque * _direction_vector) / _direction_vector.norm_sq() * _direction_vector;
83 
84  // Add the magnitude of the parallel torque component to the sum of the acting torques
85  _sum += parallel_torque_component.norm();
86 }
87 
88 Real
90 {
91  return _sum;
92 }
93 
94 void
96 {
97  gatherSum(_sum);
98 }
99 
100 void
102 {
103  const auto & pps = static_cast<const TorqueReaction &>(y);
104  _sum += pps._sum;
105 }
static InputParameters validParams()
virtual Real getValue() const override
auto norm() const -> decltype(std::norm(Real()))
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
const Point _axis_origin
T & set(const std::string &name, bool quiet_mode=false)
void threadJoin(const UserObject &y) override
const std::vector< double > y
TorqueReaction(const InputParameters &parameters)
void addRequiredParam(const std::string &name, const std::string &doc_string)
unsigned int _nrt
void gatherSum(T &value)
static InputParameters validParams()
virtual void initialize() override
const unsigned int _qp
TypeVector< typename CompareTypes< Real, T2 >::supertype > cross(const TypeVector< T2 > &v) const
AuxiliarySystem & _aux
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
MooseVariableFE< T > & getFieldVariable(THREAD_ID tid, const std::string &var_name)
const THREAD_ID _tid
virtual void finalize() override
void addClassDescription(const std::string &doc_string)
virtual void execute() override
registerMooseObject("SolidMechanicsApp", TorqueReaction)
std::vector< const VariableValue * > _react
const Point _direction_vector