rotating.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2018-2026 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "rotating.H"
27 #include "rigidBodyModelState.H"
29 
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34 namespace RBD
35 {
36 namespace joints
37 {
39 
41  (
42  joint,
43  rotating,
45  );
46 }
47 }
48 }
49 
50 
51 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
52 
54 (
55  const rigidBodyModel& model,
56  const dictionary& dict
57 )
58 :
59  joint(model, 0),
60  omega_
61  (
62  Function1<vector>::New("omega", dimTime, units::radians/dimTime, dict)
63  )
64 {}
65 
66 
68 {
69  return autoPtr<joint>(new rotating(*this));
70 }
71 
72 
73 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
74 
76 {}
77 
78 
79 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
80 
82 (
83  joint::XSvc& J,
84  const rigidBodyModelState& state
85 ) const
86 {
87  const scalar t = state.t(), deltaT = state.deltaT();
88 
89  if (t < vSmall || deltaT < vSmall)
90  {
91  return;
92  }
93 
94  const vector omega = omega_->value(t);
95  const vector omegaDot = (omega - omega_->value(t - deltaT))/deltaT;
96  const vector theta = omega_->integral(0, t);
97  const scalar magTheta = mag(theta);
98  const tensor R =
99  magTheta > vSmall ? quaternion(theta, magTheta).R() : tensor::I;
100 
101  J.X = spatialTransform(R, Zero);
102  J.S = Zero;
103  J.S1 = Zero;
104  J.v = spatialVector(omega, Zero);
105  J.c = - spatialVector(omegaDot, Zero);
106 }
107 
108 
109 // ************************************************************************* //
Macros for easy insertion into run-time selection tables.
Run-time selectable general function of one variable.
Definition: Function1.H:62
Joint state returned by jcalc.
Definition: joint.H:124
spatialVector c
The constrained joint acceleration correction.
Definition: joint.H:141
compactSpatialTensor S
The joint motion sub-space (3-DoF)
Definition: joint.H:131
spatialVector v
The constrained joint velocity.
Definition: joint.H:137
spatialVector S1
The joint motion sub-space (1-DoF)
Definition: joint.H:134
spatialTransform X
The joint transformation.
Definition: joint.H:128
Abstract base-class for all rigid-body joints.
Definition: joint.H:81
Joint with a specified rotational speed.
Definition: rotating.H:64
virtual autoPtr< joint > clone() const
Clone this joint.
Definition: rotating.C:67
rotating(const rigidBodyModel &model, const dictionary &dict)
Construct for given model from dictionary.
Definition: rotating.C:54
virtual ~rotating()
Destructor.
Definition: rotating.C:75
virtual void jcalc(joint::XSvc &J, const rigidBodyModelState &state) const
Update the model state for this joint.
Definition: rotating.C:82
Holds the motion state of rigid-body model.
scalar t() const
Return access to the time.
scalar deltaT() const
Return access to the time-step.
Basic rigid-body model representing a system of rigid-bodies connected by 1-6 DoF joints.
static const Tensor I
Definition: Tensor.H:83
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
const Type & value() const
Return const reference to value.
Convenience class to handle the input of constant rotational speed. Reads an omega entry with default...
Definition: omega.H:54
Quaternion class used to perform rotations in 3D space.
Definition: quaternion.H:61
tensor R() const
The rotation tensor corresponding the quaternion.
Definition: quaternionI.H:323
Compact representation of the Plücker spatial transformation tensor in terms of the rotation tensor E...
defineTypeNameAndDebug(composite, 0)
addToRunTimeSelectionTable(joint, composite, dictionary)
const unitSet radians
Namespace for OpenFOAM.
static const zero Zero
Definition: zero.H:97
const dimensionSet & dimTime
Definition: dimensions.C:142
SpatialVector< scalar > spatialVector
SpatialVector of scalars.
Definition: spatialVector.H:47
static scalar R(const scalar a, const scalar x)
Definition: invIncGamma.C:102
tmp< DimensionedField< scalar, GeoMesh, Field > > mag(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
tmp< DimensionedField< TypeR, GeoMesh, Field > > New(const tmp< DimensionedField< TypeR, GeoMesh, Field >> &tdf1, const word &name, const dimensionSet &dimensions)
dictionary dict