rigidBody.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::rigidBody
26 
27 Description
28 
29 SourceFiles
30  rigidBodyI.H
31 
32 \*---------------------------------------------------------------------------*/
33 
34 #ifndef RBD_rigidBody_H
35 #define RBD_rigidBody_H
36 
37 #include "rigidBodyInertia.H"
38 #include "dictionary.H"
39 #include "runTimeSelectionTables.H"
40 
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 
43 namespace Foam
44 {
45 namespace RBD
46 {
47 
48 // Forward declaration of classes
49 class subBody;
50 
51 // Forward declaration of friend functions and operators
52 class rigidBody;
53 
54 inline Ostream& operator<<(Ostream&, const rigidBody&);
55 
56 
57 /*---------------------------------------------------------------------------*\
58  Class rigidBody Declaration
59 \*---------------------------------------------------------------------------*/
60 
61 class rigidBody
62 :
63  public rigidBodyInertia
64 {
65  // Private Data
66 
67  //- Name of body
68  word name_;
69 
70 
71 public:
72 
73  //- Runtime type information
74  TypeName("rigidBody");
75 
76 
77  // Declare run-time constructor selection table
78 
80  (
81  autoPtr,
82  rigidBody,
83  dictionary,
84  (const word& name, const dictionary& dict),
85  (name, dict)
86  );
87 
88 
89  // Constructors
90 
91  //- Construct from mass, centre of mass and moment of inertia tensor
92  // about the centre of mass
93  inline rigidBody
94  (
95  const word& name,
96  const scalar& m,
97  const vector& c,
98  const symmTensor& Ic
99  );
100 
101  //- Construct from with the given rigidBodyInertia
102  inline rigidBody
103  (
104  const word& name,
105  const rigidBodyInertia& rbi
106  );
107 
108  //- Construct from dictionary
109  inline rigidBody
110  (
111  const word& name,
112  const dictionary& dict
113  );
114 
115  //- Return clone of this rigidBody
116  virtual autoPtr<rigidBody> clone() const;
117 
118 
119  // Selectors
120 
121  //- Select constructed from components
122  static autoPtr<rigidBody> New
123  (
124  const word& name,
125  const scalar& m,
126  const vector& c,
127  const symmTensor& Ic
128  );
129 
130  //- Select constructed from name and dictionary
131  static autoPtr<rigidBody> New
132  (
133  const word& name,
134  const dictionary& dict
135  );
136 
137 
138  //- Destructor
139  virtual ~rigidBody();
140 
141 
142  // Member Functions
143 
144  //- Return name
145  inline const word& name() const;
146 
147  //- Return false as this body is not massless
148  virtual bool massless() const;
149 
150  //- Merge a body into this parent body
151  void merge(const subBody&);
152 
153  //- Write
154  virtual void write(Ostream&) const;
155 
156 
157  // Ostream Operator
158 
159  friend Ostream& operator<<(Ostream&, const rigidBody&);
160 };
161 
162 
163 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
164 
165 } // End namespace RBD
166 } // End namespace Foam
167 
168 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
169 
170 #include "rigidBodyI.H"
171 
172 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
173 
174 #endif
175 
176 // ************************************************************************* //
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 ...
const vector & c() const
Return the centre of mass of the rigid-body.
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.
static autoPtr< rigidBody > New(const word &name, const scalar &m, const vector &c, const symmTensor &Ic)
Select constructed from components.
Definition: rigidBody.C:60
virtual void write(Ostream &) const
Write.
Definition: rigidBody.C:120
virtual bool massless() const
Return false as this body is not massless.
Definition: rigidBody.C:104
void merge(const subBody &)
Merge a body into this parent body.
Definition: rigidBody.C:110
rigidBody(const word &name, const scalar &m, const vector &c, const symmTensor &Ic)
Construct from mass, centre of mass and moment of inertia tensor.
Definition: rigidBodyI.H:29
virtual ~rigidBody()
Destructor.
Definition: rigidBody.C:98
friend Ostream & operator<<(Ostream &, const rigidBody &)
virtual autoPtr< rigidBody > clone() const
Return clone of this rigidBody.
Definition: rigidBody.C:51
declareRunTimeSelectionTable(autoPtr, rigidBody, dictionary,(const word &name, const dictionary &dict),(name, dict))
TypeName("rigidBody")
Runtime type information.
const word & name() const
Return name.
Definition: rigidBodyI.H:65
This specialised rigidBody holds the original body after it has been merged into a master.
Definition: subBody.H:53
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
A class for handling words, derived from string.
Definition: word.H:62
Ostream & operator<<(Ostream &, const rigidBody &)
Definition: rigidBodyI.H:73
Namespace for OpenFOAM.
Macros to ease declaration of run-time selection tables.
dictionary dict