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 
61 // Forward declaration of classes
62 class Istream;
63 class Ostream;
64 
65 namespace RBD
66 {
67 
68 // Forward declaration of friend functions and operators
69 class rigidBodyInertia;
70 Istream& operator>>(Istream&, rigidBodyInertia&);
71 Ostream& operator<<(Ostream&, const rigidBodyInertia&);
72 
73 
74 /*---------------------------------------------------------------------------*\
75  Class rigidBodyInertia Declaration
76 \*---------------------------------------------------------------------------*/
77 
78 class rigidBodyInertia
79 {
80  // Private data
81 
82  //- Mass of the rigid-body
83  scalar m_;
84 
85  //- Centre of mass of the rigid-body
86  vector c_;
87 
88  //- Inertia tensor about the centre of mass
89  symmTensor Ic_;
90 
91 
92 public:
93 
94  // Static member functions
95 
96  //- Return the difference between the inertia tensor of the rigid-body
97  // about the origin - about the centre of mass
98  // for the given mass and centre of mass
99  inline static symmTensor Ioc(const scalar m, const vector& c);
100 
101 
102  // Constructors
103 
104  //- Null constructor, initializes to zero
105  inline rigidBodyInertia();
106 
107  //- Construct from mass, centre of mass and moment of inertia tensor
108  // about the centre of mass
109  inline rigidBodyInertia
110  (
111  const scalar m,
112  const vector& c,
113  const symmTensor& Ic
114  );
115 
116  //- Construct from dictionary
117  inline rigidBodyInertia(const dictionary& dict);
118 
119  //- Construct from the components of a spatial tensor
120  inline explicit rigidBodyInertia(const spatialTensor& st);
121 
122  //- Construct from Istream
123  inline explicit rigidBodyInertia(Istream& is);
124 
125 
126  // Member Functions
127 
128  //- Return the mass of the rigid-body
129  inline scalar m() const;
130 
131  //- Return the centre of mass of the rigid-body
132  inline const vector& c() const;
133 
134  //- Return the inertia tensor of the rigid-body about the centre of mass
135  inline const symmTensor& Ic() const;
136 
137  //- Return the difference between the inertia tensor of the rigid-body
138  // about the origin - about the centre of mass
139  inline symmTensor Ioc() const;
140 
141  //- Return the difference between the inertia tensor of the rigid-body
142  // about the a new centre of mass - about the current centre of mass
143  inline symmTensor Icc(const vector& c) const;
144 
145  //- Return the inertia tensor of the rigid-body about the origin
146  inline symmTensor Io() const;
147 
148  //- Return the kinetic energy of the body with the given velocity
149  inline scalar kineticEnergy(const spatialVector& v);
150 
151 
152  // Member Operators
153 
154  //- Conversion to spatial tensor
155  inline operator spatialTensor() const;
156 
157  inline void operator+=(const rigidBodyInertia&);
158 
159 
160  // IOstream Operators
161 
163  friend Ostream& operator<<(Ostream&, const rigidBodyInertia&);
164 };
165 
166 
167 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
168 
169 } // End namespace RBD
170 } // End namespace Foam
171 
172 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
173 
174 #include "rigidBodyInertiaI.H"
175 
176 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
177 
178 #endif
179 
180 // ************************************************************************* //
Foam::SymmTensor< scalar >
Foam::RBD::operator>>
Istream & operator>>(Istream &, rigidBodyInertia &)
Definition: rigidBodyInertiaI.H:142
rigidBodyInertia
This class represents the linear and angular inertia of a rigid body by the mass, centre of mass and ...
spatialTensor.H
Foam::RBD::rigidBodyInertia::Ioc
symmTensor Ioc() const
Return the difference between the inertia tensor of the rigid-body.
Definition: rigidBodyInertiaI.H:109
Foam::SpatialTensor
Templated 3D spatial tensor derived from MatrixSpace used to represent transformations of spatial vec...
Definition: SpatialTensor.H:67
spatialVector.H
Foam::RBD::operator<<
Ostream & operator<<(Ostream &, const rigidBody &)
Definition: rigidBodyI.H:75
symmTensor.H
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Foam::RBD::rigidBodyInertia::rigidBodyInertia
rigidBodyInertia()
Null constructor, initializes to zero.
Definition: rigidBodyInertiaI.H:47
Foam::SpatialVector< scalar >
Foam::RBD::rigidBodyInertia::operator+=
void operator+=(const rigidBodyInertia &)
Definition: rigidBodyInertiaI.H:247
Foam::RBD::rigidBodyInertia::m
scalar m() const
Return the mass of the rigid-body.
Definition: rigidBodyInertiaI.H:94
Foam::RBD::rigidBodyInertia::operator>>
friend Istream & operator>>(Istream &, rigidBodyInertia &)
dict
dictionary dict
Definition: searchingEngine.H:14
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::rigidBodyInertia::Icc
symmTensor Icc(const vector &c) const
Return the difference between the inertia tensor of the rigid-body.
Definition: rigidBodyInertiaI.H:114
Foam::spatialTensor
SpatialTensor< scalar > spatialTensor
SpatialTensor of scalars.
Definition: spatialTensor.H:50
Foam::Vector< scalar >
Foam::RBD::rigidBodyInertia::Ic
const symmTensor & Ic() const
Return the inertia tensor of the rigid-body about the centre of mass.
Definition: rigidBodyInertiaI.H:104
vector.H
Foam::RBD::rigidBodyInertia::operator<<
friend Ostream & operator<<(Ostream &, const rigidBodyInertia &)
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::RBD::rigidBodyInertia::kineticEnergy
scalar kineticEnergy(const spatialVector &v)
Return the kinetic energy of the body with the given velocity.
Definition: rigidBodyInertiaI.H:236
Foam::RBD::rigidBodyInertia::Io
symmTensor Io() const
Return the inertia tensor of the rigid-body about the origin.
Definition: rigidBodyInertiaI.H:119
rigidBodyInertiaI.H
Foam::RBD::rigidBodyInertia
Definition: rigidBodyInertia.H:77
Foam::RBD::rigidBodyInertia::c
const vector & c() const
Return the centre of mass of the rigid-body.
Definition: rigidBodyInertiaI.H:99