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