joint.H
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2016 OpenFOAM Foundation
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26Namespace
27 Foam::RBD::joints
28
29Group
30 grpRigidBodyDynamicsJoints
31
32Description
33 Namespace for rigid-body joints
34
35Class
36 Foam::RBD::joint
37
38Description
39 Abstract base-class for all rigid-body joints.
40
41 Reference:
42 \verbatim
43 Featherstone, R. (2008).
44 Rigid body dynamics algorithms.
45 Springer.
46 Chapter 4.
47 \endverbatim
48
49SourceFiles
50 jointI.H
51 joint.C
52
53\*---------------------------------------------------------------------------*/
54
55#ifndef RBD_joint_H
56#define RBD_joint_H
57
58#include "List.H"
59#include "spatialVector.H"
62#include "spatialTransform.H"
63#include "quaternion.H"
64#include "scalarField.H"
66
67namespace Foam
68{
69namespace RBD
70{
71
72// Forward declaration of classes
73class rigidBodyModel;
74
75// Forward declaration of friend functions and operators
76class joint;
77
78inline Ostream& operator<<(Ostream&, const joint&);
79
80
81/*---------------------------------------------------------------------------*\
82 Class joint Declaration
83\*---------------------------------------------------------------------------*/
85class joint
86{
87
88protected:
89
90 // Protected data
91
92 //- Joint motion sub-space
94
95 //- Index of this joint in the rigidBodyModel
96 label index_;
97
98 //- Index of this joints data in the rigidBodyModel state
99 label qIndex_;
100
101
102private:
103
104 // Private member functions to be used by rigidBodyModel
105
106 //- Allow the rigidBodyModel to set the index for this joint
107 label& index()
108 {
109 return index_;
110 }
111
112 //- Allow the rigidBodyModel to set the qIndex for this joint
113 label& qIndex()
114 {
115 return qIndex_;
116 }
117
118
119public:
120
121 //- Allow the rigidBodyModel class to set the joint indices
122 friend class rigidBodyModel;
123
124 //- Joint state returned by jcalc
125 class XSvc
126 {
127 public:
128
129 //- The joint transformation
131
132 //- The joint motion sub-space (3-DoF)
134
135 //- The joint motion sub-space (1-DoF)
137
138 //- The constrained joint velocity
140
141 //- The constrained joint acceleration correction
142 // due to changes in the motion sub-space S
144
145 //- Null constructor
146 XSvc()
147 :
148 X(),
149 v(Zero),
150 c(Zero)
151 {}
152 };
153
154
155public:
156
157 //- Runtime type information
158 TypeName("joint");
159
160
161 // Declare run-time constructor selection table
164 (
165 autoPtr,
166 joint,
168 (const dictionary& dict),
169 (dict)
170 );
171
172
173 // Constructors
174
175 //- Construct joint setting the size of the motion sub-space
176 // to the given degrees of freedom of the joint
177 inline joint(const label nDoF);
178
179 //- Clone this joint (needed by PtrList)
180 virtual autoPtr<joint> clone() const = 0;
182 class iNew
183 {
184
185 public:
187 iNew()
188 {}
189
190 inline autoPtr<joint> operator()(Istream& is) const;
191 };
192
193
194 //- Destructor
195 virtual ~joint();
196
197
198 // Selectors
199
200 //- Simple selector to return an autoPtr<joint> of the given joint*
201 static autoPtr<joint> New(joint* jointPtr);
202
203 //- Select from dictionary
204 static autoPtr<joint> New(const dictionary& dict);
205
206
207 // Member Functions
208
209 //- Return the number of degrees of freedom in this joint
210 inline label nDoF() const;
211
212 //- Return true if this joint describes rotation using a quaternion
213 inline virtual bool unitQuaternion() const;
214
215 //- Return the index of this joint in the model
216 inline label index() const;
217
218 //- Return start index for the state variables for this joint
219 // in the rigidBodyModel state fields
220 inline label qIndex() const;
221
222 //- Return the joint motion sub-space
223 inline const List<spatialVector>& S() const;
224
225 //- Update the rigidBodyModel state for the joint given
226 // the joint state q, w and velocity qDot
227 virtual void jcalc
228 (
229 XSvc& J,
230 const scalarField& q,
231 const scalarField& qDot
232 ) const = 0;
233
234 //- Write
235 virtual void write(Ostream&) const;
236
237
238 // Member Operators
239
240 //- Return the unit quaternion for this joint
241 // if it uses a quaternion representation for rotation
243 (
244 const scalarField& q
245 ) const;
246
247 //- Set the unit quaternion for this joint
248 // if it uses a quaternion representation for rotation
249 inline void unitQuaternion
250 (
251 const quaternion& quat,
252 scalarField& q
253 ) const;
254
255
256 // Ostream Operator
258 friend Ostream& operator<<(Ostream&, const joint&);
259};
260
261
262// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
263
264} // End namespace RBD
265} // End namespace Foam
266
267// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
268
269#include "jointI.H"
270
271// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
272
273#endif
274
275// ************************************************************************* //
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:64
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: List.H:77
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
Joint state returned by jcalc.
Definition: joint.H:125
spatialVector c
The constrained joint acceleration correction.
Definition: joint.H:142
XSvc()
Null constructor.
Definition: joint.H:145
compactSpatialTensor S
The joint motion sub-space (3-DoF)
Definition: joint.H:132
spatialVector v
The constrained joint velocity.
Definition: joint.H:138
spatialVector S1
The joint motion sub-space (1-DoF)
Definition: joint.H:135
spatialTransform X
The joint transformation.
Definition: joint.H:129
autoPtr< joint > operator()(Istream &is) const
Definition: jointI.H:104
Abstract base-class for all rigid-body joints.
Definition: joint.H:85
virtual autoPtr< joint > clone() const =0
Clone this joint (needed by PtrList)
static autoPtr< joint > New(joint *jointPtr)
Simple selector to return an autoPtr<joint> of the given joint*.
Definition: joint.C:46
List< spatialVector > S_
Joint motion sub-space.
Definition: joint.H:92
label qIndex_
Index of this joints data in the rigidBodyModel state.
Definition: joint.H:98
label nDoF() const
Return the number of degrees of freedom in this joint.
Definition: jointI.H:40
declareRunTimeSelectionTable(autoPtr, joint, dictionary,(const dictionary &dict),(dict))
const List< spatialVector > & S() const
Return the joint motion sub-space.
Definition: jointI.H:60
virtual bool unitQuaternion() const
Return true if this joint describes rotation using a quaternion.
Definition: jointI.H:45
label index_
Index of this joint in the rigidBodyModel.
Definition: joint.H:95
friend Ostream & operator<<(Ostream &, const joint &)
TypeName("joint")
Runtime type information.
virtual ~joint()
Destructor.
Definition: joint.C:78
virtual void jcalc(XSvc &J, const scalarField &q, const scalarField &qDot) const =0
Update the rigidBodyModel state for the joint given.
Basic rigid-body model representing a system of rigid-bodies connected by 1-6 DoF joints.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
Quaternion class used to perform rotations in 3D space.
Definition: quaternion.H:58
Compact representation of the Pl├╝cker spatial transformation tensor in terms of the rotation tensor E...
Ostream & operator<<(Ostream &, const rigidBody &)
Definition: rigidBodyI.H:75
Namespace for OpenFOAM.
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
runTime write()
Macros to ease declaration of run-time selection tables.
#define declareRunTimeSelectionTable(ptrWrapper, baseType, argNames, argList, parList)
Declare a run-time selection (variables and adder classes)
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73