rigidBodyInertia.H
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) 2016-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 Class
25  Foam::RBD::rigidBodyInertia
26 
27 Description
28  This class represents the linear and angular inertia of a rigid body
29  by the mass, centre of mass and moment of inertia tensor about the
30  centre of mass.
31 
32  Reference:
33  \verbatim
34  Featherstone, R. (2008).
35  Rigid body dynamics algorithms.
36  Springer.
37  \endverbatim
38 
39 SourceFiles
40  rigidBodyInertiaI.H
41  rigidBodyInertia.C
42  rigidBodyInertiaIO.C
43 
44 \*---------------------------------------------------------------------------*/
45 
46 #ifndef RBD_rigidBodyInertia_H
47 #define RBD_rigidBodyInertia_H
48 
49 #include "vector.H"
50 #include "symmTensor.H"
51 #include "spatialVector.H"
52 #include "spatialTensor.H"
53 
54 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
55 
56 namespace Foam
57 {
58 
59 // Forward declaration of classes
60 class Istream;
61 class Ostream;
62 
63 namespace RBD
64 {
65 
66 // Forward declaration of friend functions and operators
67 class rigidBodyInertia;
68 Istream& operator>>(Istream&, rigidBodyInertia&);
69 Ostream& operator<<(Ostream&, const rigidBodyInertia&);
70 
71 
72 /*---------------------------------------------------------------------------*\
73  Class rigidBodyInertia Declaration
74 \*---------------------------------------------------------------------------*/
75 
76 class rigidBodyInertia
77 {
78  // Private Data
79 
80  //- Mass of the rigid-body
81  scalar m_;
82 
83  //- Centre of mass of the rigid-body
84  vector c_;
85 
86  //- Inertia tensor about the centre of mass
87  symmTensor Ic_;
88 
89 
90 public:
91 
92  // Static member functions
93 
94  //- Return the difference between the inertia tensor of the rigid-body
95  // about the origin - about the centre of mass
96  // for the given mass and centre of mass
97  inline static symmTensor Ioc(const scalar m, const vector& c);
98 
99 
100  // Constructors
101 
102  //- Null constructor, initialises to zero
103  inline rigidBodyInertia();
104 
105  //- Construct from mass, centre of mass and moment of inertia tensor
106  // about the centre of mass
107  inline rigidBodyInertia
108  (
109  const scalar m,
110  const vector& c,
111  const symmTensor& Ic
112  );
113 
114  //- Construct from dictionary
115  inline rigidBodyInertia(const dictionary& dict);
116 
117  //- Construct from the components of a spatial tensor
118  inline explicit rigidBodyInertia(const spatialTensor& st);
119 
120  //- Construct from Istream
121  inline explicit rigidBodyInertia(Istream& is);
122 
123 
124  // Member Functions
125 
126  //- Return the mass of the rigid-body
127  inline scalar m() const;
128 
129  //- Return the centre of mass of the rigid-body
130  inline const vector& c() const;
131 
132  //- Return the inertia tensor of the rigid-body about the centre of mass
133  inline const symmTensor& Ic() const;
134 
135  //- Return the difference between the inertia tensor of the rigid-body
136  // about the origin - about the centre of mass
137  inline symmTensor Ioc() const;
138 
139  //- Return the difference between the inertia tensor of the rigid-body
140  // about the a new centre of mass - about the current centre of mass
141  inline symmTensor Icc(const vector& c) const;
142 
143  //- Return the inertia tensor of the rigid-body about the origin
144  inline symmTensor Io() const;
145 
146  //- Return the kinetic energy of the body with the given velocity
147  inline scalar kineticEnergy(const spatialVector& v);
148 
149 
150  // Member Operators
151 
152  //- Conversion to spatial tensor
153  inline operator spatialTensor() const;
154 
155  inline void operator+=(const rigidBodyInertia&);
156 
157 
158  // IOstream Operators
159 
161  friend Ostream& operator<<(Ostream&, const rigidBodyInertia&);
162 };
163 
164 
165 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
166 
167 } // End namespace RBD
168 } // End namespace Foam
169 
170 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
171 
172 #include "rigidBodyInertiaI.H"
173 
174 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
175 
176 #endif
177 
178 // ************************************************************************* //
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:60
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
This class represents the linear and angular inertia of a rigid body by the mass, centre of mass and ...
symmTensor Icc(const vector &c) const
Return the difference between the inertia tensor of the rigid-body.
scalar kineticEnergy(const spatialVector &v)
Return the kinetic energy of the body with the given velocity.
const vector & c() const
Return the centre of mass of the rigid-body.
void operator+=(const rigidBodyInertia &)
friend Ostream & operator<<(Ostream &, const rigidBodyInertia &)
rigidBodyInertia()
Null constructor, initialises to zero.
symmTensor Io() const
Return the inertia tensor of the rigid-body about the origin.
symmTensor Ioc() const
Return the difference between the inertia tensor of the rigid-body.
friend Istream & operator>>(Istream &, rigidBodyInertia &)
scalar m() const
Return the mass of the rigid-body.
const symmTensor & Ic() const
Return the inertia tensor of the rigid-body about the centre of mass.
Templated 3D spatial tensor derived from MatrixSpace used to represent transformations of spatial vec...
Definition: SpatialTensor.H:67
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
Ostream & operator<<(Ostream &, const rigidBody &)
Definition: rigidBodyI.H:73
Istream & operator>>(Istream &, rigidBodyInertia &)
Namespace for OpenFOAM.
SpatialTensor< scalar > spatialTensor
SpatialTensor of scalars.
Definition: spatialTensor.H:47
dictionary dict