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-2024 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_(Function1<vector>::New("omega", dimTime, unitRadians/dimTime, dict))
61 {}
62 
63 
65 {
66  return autoPtr<joint>(new rotating(*this));
67 }
68 
69 
70 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
71 
73 {}
74 
75 
76 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
77 
79 (
80  joint::XSvc& J,
81  const rigidBodyModelState& state
82 ) const
83 {
84  const scalar t = state.t(), deltaT = state.deltaT();
85 
86  if (t < vSmall || deltaT < vSmall)
87  {
88  return;
89  }
90 
91  const vector omega = omega_->value(t);
92  const vector omegaDot = (omega - omega_->value(t - deltaT))/deltaT;
93  const vector theta = omega_->integral(0, t);
94  const scalar magTheta = mag(theta);
95  const tensor R =
96  magTheta > vSmall ? quaternion(theta, magTheta).R() : tensor::I;
97 
98  J.X = spatialTransform(R, Zero);
99  J.S = Zero;
100  J.S1 = Zero;
101  J.v = spatialVector(omega, Zero);
102  J.c = - spatialVector(omegaDot, Zero);
103 }
104 
105 
106 // ************************************************************************* //
Macros for easy insertion into run-time selection tables.
Run-time selectable general function of one variable.
Definition: Function1.H:125
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:64
rotating(const rigidBodyModel &model, const dictionary &dict)
Construct for given model from dictionary.
Definition: rotating.C:54
virtual ~rotating()
Destructor.
Definition: rotating.C:72
virtual void jcalc(joint::XSvc &J, const rigidBodyModelState &state) const
Update the model state for this joint.
Definition: rotating.C:79
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 keyword definitions, which are a keyword followed by any number of values (e....
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)
autoPtr< CompressibleMomentumTransportModel > New(const volScalarField &rho, const volVectorField &U, const surfaceScalarField &phi, const viscosity &viscosity)
Namespace for OpenFOAM.
static const zero Zero
Definition: zero.H:97
const dimensionSet dimTime
SpatialVector< scalar > spatialVector
SpatialVector of scalars.
Definition: spatialVector.H:47
dimensioned< scalar > mag(const dimensioned< Type > &)
static scalar R(const scalar a, const scalar x)
Definition: invIncGamma.C:102
const unitConversion unitRadians
dictionary dict