https://mooseframework.inl.gov
Loading...
Searching...
No Matches
TorqueReaction.C
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://mooseframework.inl.gov
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
16registerMooseObject("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
51void
53{
54 _sum = 0.0;
55}
56
57void
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 =
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
88Real
90{
91 return _sum;
92}
93
94void
99
100void
102{
103 const auto & pps = static_cast<const TorqueReaction &>(y);
104 _sum += pps._sum;
105}
const std::vector< double > y
registerMooseObject("SolidMechanicsApp", TorqueReaction)
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
T & set(const std::string &name, bool quiet_mode=false)
static InputParameters validParams()
const unsigned int _qp
MooseVariableFE< T > & getFieldVariable(THREAD_ID tid, const std::string &var_name)
virtual void finalize() override
virtual void initialize() override
static InputParameters validParams()
std::vector< const VariableValue * > _react
AuxiliarySystem & _aux
void threadJoin(const UserObject &y) override
const Point _axis_origin
TorqueReaction(const InputParameters &parameters)
const Point _direction_vector
virtual void execute() override
virtual Real getValue() const override
unsigned int _nrt
void gatherSum(T &value)
const THREAD_ID _tid
auto norm_sq() const
TypeVector< typename CompareTypes< T, T2 >::supertype > cross(const TypeVector< T2 > &v) const