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-2026 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 "primitiveFieldsFwd.H"
40 #include "runTimeSelectionTables.H"
41 
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 
44 namespace Foam
45 {
46 namespace RBD
47 {
48 
49 // Forward declaration of classes
50 class subBody;
51 class rigidBody;
52 
53 // Forward declaration of friend functions and operators
54 inline Ostream& operator<<(Ostream&, const rigidBody&);
55 
56 /*---------------------------------------------------------------------------*\
57  Class rigidBody Declaration
58 \*---------------------------------------------------------------------------*/
59 
60 class rigidBody
61 :
62  public rigidBodyInertia
63 {
64  // Private Data
65 
66  //- Name of body
67  word name_;
68 
69 
70 public:
71 
72  //- Runtime type information
73  TypeName("rigidBody");
74 
75 
76  // Declare run-time constructor selection table
77 
79  (
80  autoPtr,
81  rigidBody,
82  dictionary,
83  (const word& name, const dictionary& dict),
84  (name, dict)
85  );
86 
87 
88  // Constructors
89 
90  //- Construct from mass, centre of mass and moment of inertia tensor
91  // about the centre of mass
92  inline rigidBody
93  (
94  const word& name,
95  const scalar& m,
96  const vector& c,
97  const symmTensor& Ic
98  );
99 
100  //- Construct from with the given rigidBodyInertia
101  inline rigidBody
102  (
103  const word& name,
104  const rigidBodyInertia& rbi
105  );
106 
107  //- Construct from dictionary
108  inline rigidBody
109  (
110  const word& name,
111  const dictionary& dict
112  );
113 
114  //- Return clone of this rigidBody
115  virtual autoPtr<rigidBody> clone() const;
116 
117 
118  // Selectors
119 
120  //- Select constructed from components
121  static autoPtr<rigidBody> New
122  (
123  const word& name,
124  const scalar& m,
125  const vector& c,
126  const symmTensor& Ic
127  );
128 
129  //- Select constructed from name and dictionary
130  static autoPtr<rigidBody> New
131  (
132  const word& name,
133  const dictionary& dict
134  );
135 
136 
137  //- Destructor
138  virtual ~rigidBody();
139 
140 
141  // Member Functions
142 
143  //- Return name
144  inline const word& name() const;
145 
146  //- Return false as this body is not massless
147  virtual bool massless() const;
148 
149  //- Merge a body into this parent body
150  void merge(const subBody&);
151 
152  //- Return the zeroth moments of the sections of the body between
153  // planes defined by distances along the given axis
155  (
156  const direction axis,
157  const scalarField& distances
158  ) const;
159 
160  //- Return the first moments of the sections of the body between
161  // planes defined by distances along the given axis
163  (
164  const direction axis,
165  const scalarField& distances
166  ) const;
167 
168  //- Return the second moments of the sections of the body between
169  // planes defined by distances along the given axis
171  (
172  const direction axis,
173  const scalarField& distances
174  ) const;
175 
176  //- Write
177  virtual void write(Ostream&) const;
178 
179 
180  // Ostream Operator
181 
182  friend Ostream& operator<<(Ostream&, const rigidBody&);
183 };
184 
185 
186 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
187 
188 } // End namespace RBD
189 } // End namespace Foam
190 
191 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
192 
193 #include "rigidBodyI.H"
194 
195 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
196 
197 #endif
198 
199 // ************************************************************************* //
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:55
virtual tmp< vectorField > sectionMu1s(const direction axis, const scalarField &distances) const
Return the first moments of the sections of the body between.
Definition: rigidBody.C:130
virtual void write(Ostream &) const
Write.
Definition: rigidBody.C:151
virtual bool massless() const
Return false as this body is not massless.
Definition: rigidBody.C:99
void merge(const subBody &)
Merge a body into this parent body.
Definition: rigidBody.C:105
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:93
virtual tmp< symmTensorField > sectionMu2s(const direction axis, const scalarField &distances) const
Return the second moments of the sections of the body between.
Definition: rigidBody.C:141
friend Ostream & operator<<(Ostream &, const rigidBody &)
virtual autoPtr< rigidBody > clone() const
Return clone of this rigidBody.
Definition: rigidBody.C:46
declareRunTimeSelectionTable(autoPtr, rigidBody, dictionary,(const word &name, const dictionary &dict),(name, dict))
TypeName("rigidBody")
Runtime type information.
virtual tmp< scalarField > sectionMu0s(const direction axis, const scalarField &distances) const
Return the zeroth moments of the sections of the body between.
Definition: rigidBody.C:116
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 keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
A class for managing temporary objects.
Definition: tmp.H:55
A class for handling words, derived from string.
Definition: word.H:63
Ostream & operator<<(Ostream &, const rigidBody &)
Definition: rigidBodyI.H:73
Namespace for OpenFOAM.
uint8_t direction
Definition: direction.H:45
Forward declarations of the specialisations of Field<T> for scalar, vector and tensor.
Macros to ease declaration of run-time selection tables.
dictionary dict