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 {
38  defineTypeNameAndDebug(rotating, 0);
39 
41  (
42  joint,
43  rotating,
44  dictionary
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", 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_->integrate(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 // ************************************************************************* //
Abstract base-class for all rigid-body joints.
Definition: joint.H:81
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
dictionary dict
tensor R() const
The rotation tensor corresponding to the quaternion.
Definition: quaternionI.H:352
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
spatialVector v
The constrained joint velocity.
Definition: joint.H:157
spatialVector S1
The joint motion sub-space (1-DoF)
Definition: joint.H:152
compactSpatialTensor S
The joint motion sub-space (3-DoF)
Definition: joint.H:147
defineTypeNameAndDebug(composite, 0)
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
addToRunTimeSelectionTable(joint, composite, dictionary)
spatialVector c
The constrained joint acceleration correction.
Definition: joint.H:164
Macros for easy insertion into run-time selection tables.
Holds the motion state of rigid-body model.
Joint state returned by jcalc.
Definition: joint.H:135
static const Identity< scalar > I
Definition: Identity.H:100
scalar t() const
Return access to the time.
SpatialVector< scalar > spatialVector
SpatialVector of scalars.
Definition: spatialVector.H:46
Quaternion class used to perform rotations in 3D space.
Definition: quaternion.H:53
Joint with a specified rotational speed.
Definition: rotating.H:57
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
virtual ~rotating()
Destructor.
Definition: rotating.C:65
scalar deltaT() const
Return access to the time-step.
rotating(const rigidBodyModel &model, const dictionary &dict)
Construct for given model from dictionary.
Definition: rotating.C:47
spatialTransform X
The joint transformation.
Definition: joint.H:142
#define R(A, B, C, D, E, F, K, M)
virtual void jcalc(joint::XSvc &J, const rigidBodyModelState &state) const
Update the model state for this joint.
Definition: rotating.C:72
Compact representation of the Plücker spatial transformation tensor in terms of the rotation tensor E...
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
Basic rigid-body model representing a system of rigid-bodies connected by 1-6 DoF joints...
Tensor of scalars, i.e. Tensor<scalar>.
virtual autoPtr< joint > clone() const
Clone this joint.
Definition: rotating.C:57
Namespace for OpenFOAM.
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:127