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 -------------------------------------------------------------------------------
10 License
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 
26 Namespace
27  Foam::RBD::joints
28 
29 Group
30  grpRigidBodyDynamicsJoints
31 
32 Description
33  Namespace for rigid-body joints
34 
35 Class
36  Foam::RBD::joint
37 
38 Description
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 
49 SourceFiles
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"
60 #include "compactSpatialTensor.H"
61 #include "CompactSpatialTensorT.H"
62 #include "spatialTransform.H"
63 #include "quaternion.H"
64 #include "scalarField.H"
65 #include "runTimeSelectionTables.H"
66 
67 namespace Foam
68 {
69 namespace RBD
70 {
71 
72 // Forward declaration of classes
73 class rigidBodyModel;
74 
75 // Forward declaration of friend functions and operators
76 class joint;
77 
78 inline Ostream& operator<<(Ostream&, const joint&);
79 
80 
81 /*---------------------------------------------------------------------------*\
82  Class joint Declaration
83 \*---------------------------------------------------------------------------*/
84 
85 class joint
86 {
87 
88 protected:
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 
102 private:
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 
119 public:
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 
155 public:
156 
157  //- Runtime type information
158  TypeName("joint");
159 
160 
161  // Declare run-time constructor selection table
162 
164  (
165  autoPtr,
166  joint,
167  dictionary,
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;
181 
182  class iNew
183  {
184 
185  public:
186 
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
257 
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 // ************************************************************************* //
Foam::RBD::joint::write
virtual void write(Ostream &) const
Write.
Definition: joint.C:84
Foam::RBD::joint::New
static autoPtr< joint > New(joint *jointPtr)
Simple selector to return an autoPtr<joint> of the given joint*.
Definition: joint.C:46
Foam::RBD::joint::qIndex_
label qIndex_
Index of this joints data in the rigidBodyModel state.
Definition: joint.H:98
Foam::RBD::joint::nDoF
label nDoF() const
Return the number of degrees of freedom in this joint.
Definition: jointI.H:40
List.H
Foam::RBD::joint::index_
label index_
Index of this joint in the rigidBodyModel.
Definition: joint.H:95
Foam::spatialTransform
Compact representation of the Pl├╝cker spatial transformation tensor in terms of the rotation tensor E...
Definition: spatialTransform.H:70
Foam::Zero
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
scalarField.H
Foam::RBD::joint::~joint
virtual ~joint()
Destructor.
Definition: joint.C:78
quaternion.H
Foam::RBD::joint::joint
joint(const label nDoF)
Construct joint setting the size of the motion sub-space.
Definition: jointI.H:30
jointI.H
Foam::RBD::joint::operator<<
friend Ostream & operator<<(Ostream &, const joint &)
spatialVector.H
Foam::RBD::joint::XSvc
Joint state returned by jcalc.
Definition: joint.H:124
Foam::RBD::operator<<
Ostream & operator<<(Ostream &, const rigidBody &)
Definition: rigidBodyI.H:75
Foam::RBD::joint::iNew::iNew
iNew()
Definition: joint.H:186
Foam::RBD::joint::TypeName
TypeName("joint")
Runtime type information.
Foam::quaternion
Quaternion class used to perform rotations in 3D space.
Definition: quaternion.H:56
Foam::RBD::joint::XSvc::c
spatialVector c
The constrained joint acceleration correction.
Definition: joint.H:142
Foam::Field< scalar >
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Foam::RBD::joint::XSvc::X
spatialTransform X
The joint transformation.
Definition: joint.H:129
Foam::SpatialVector< scalar >
Foam::RBD::joint::declareRunTimeSelectionTable
declareRunTimeSelectionTable(autoPtr, joint, dictionary,(const dictionary &dict),(dict))
Foam::RBD::joint::iNew::operator()
autoPtr< joint > operator()(Istream &is) const
Definition: jointI.H:104
compactSpatialTensor.H
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::RBD::rigidBodyModel
Basic rigid-body model representing a system of rigid-bodies connected by 1-6 DoF joints.
Definition: rigidBodyModel.H:83
Foam::CompactSpatialTensor< scalar >
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::RBD::joint::XSvc::XSvc
XSvc()
Null constructor.
Definition: joint.H:145
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::RBD::joint::clone
virtual autoPtr< joint > clone() const =0
Clone this joint (needed by PtrList)
runTimeSelectionTables.H
Macros to ease declaration of run-time selection tables.
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:63
spatialTransform.H
Foam::RBD::joint::S_
List< spatialVector > S_
Joint motion sub-space.
Definition: joint.H:92
Foam::RBD::joint
Abstract base-class for all rigid-body joints.
Definition: joint.H:84
Foam::RBD::joint::jcalc
virtual void jcalc(XSvc &J, const scalarField &q, const scalarField &qDot) const =0
Update the rigidBodyModel state for the joint given.
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::RBD::joint::XSvc::S1
spatialVector S1
The joint motion sub-space (1-DoF)
Definition: joint.H:135
Foam::RBD::joint::XSvc::S
compactSpatialTensor S
The joint motion sub-space (3-DoF)
Definition: joint.H:132
Foam::RBD::joint::XSvc::v
spatialVector v
The constrained joint velocity.
Definition: joint.H:138
Foam::RBD::joint::S
const List< spatialVector > & S() const
Return the joint motion sub-space.
Definition: jointI.H:60
Foam::RBD::joint::unitQuaternion
virtual bool unitQuaternion() const
Return true if this joint describes rotation using a quaternion.
Definition: jointI.H:45
CompactSpatialTensorT.H
Foam::RBD::joint::iNew
Definition: joint.H:181