sixDoFRigidBodyMotion.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) 2011-2015 OpenFOAM Foundation
9 Copyright (C) 2016-2019 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27Class
28 Foam::sixDoFRigidBodyMotion
29
30Description
31 Six degree of freedom motion for a rigid body.
32
33 Angular momentum stored in body fixed reference frame. Reference
34 orientation of the body (where Q = I) must align with the cartesian axes
35 such that the Inertia tensor is in principle component form. Can add
36 restraints (e.g. a spring) and constraints (e.g. motion may only be on a
37 plane).
38
39 The time-integrator for the motion is run-time selectable with options for
40 symplectic (explicit), Crank-Nicolson and Newmark schemes.
41
42SourceFiles
43 sixDoFRigidBodyMotionI.H
44 sixDoFRigidBodyMotion.C
45 sixDoFRigidBodyMotionIO.C
46
47\*---------------------------------------------------------------------------*/
48
49#ifndef sixDoFRigidBodyMotion_H
50#define sixDoFRigidBodyMotion_H
51
53#include "pointField.H"
56#include "Tuple2.H"
57
58// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
59
60namespace Foam
61{
62
63// Forward declarations
64class sixDoFSolver;
65
66/*---------------------------------------------------------------------------*\
67 Class sixDoFRigidBodyMotion Declaration
68\*---------------------------------------------------------------------------*/
72 friend class sixDoFSolver;
73
74 // Private data
75
76 //- Reference to time database
77 const Time& time_;
78
79 //- Motion state data object
80 sixDoFRigidBodyMotionState motionState_;
81
82 //- Motion state data object for previous time-step
83 sixDoFRigidBodyMotionState motionState0_;
84
85 //- Motion restraints
87
88 //- Motion constraints
90
91 //- Translational constraint tensor
92 tensor tConstraints_;
93
94 //- Rotational constraint tensor
95 tensor rConstraints_;
96
97 //- Centre of mass of initial state
98 point initialCentreOfMass_;
99
100 //- Centre of rotation of initial state
101 point initialCentreOfRotation_;
102
103 //- Orientation of initial state
104 tensor initialQ_;
105
106 //- Mass of the body
107 scalar mass_;
108
109 //- Moment of inertia of the body in reference configuration
110 // (Q = I)
111 diagTensor momentOfInertia_;
112
113 //- Acceleration relaxation coefficient
114 scalar aRelax_;
115
116 //- Acceleration damping coefficient (for steady-state simulations)
117 scalar aDamp_;
118
119 //- Reporting of motion data (on or off)
120 bool report_;
121
122 //- Motion solver
123 autoPtr<sixDoFSolver> solver_;
124
125
126 // Private Member Functions
127
128 //- Calculate the rotation tensor around the body reference
129 // frame x-axis by the given angle
130 inline tensor rotationTensorX(scalar deltaT) const;
131
132 //- Calculate the rotation tensor around the body reference
133 // frame y-axis by the given angle
134 inline tensor rotationTensorY(scalar deltaT) const;
135
136 //- Calculate the rotation tensor around the body reference
137 // frame z-axis by the given angle
138 inline tensor rotationTensorZ(scalar deltaT) const;
139
140 //- Apply rotation tensors to Q0 for the given torque (pi) and deltaT
141 // and return the rotated Q and pi as a tuple
142 inline Tuple2<tensor, vector> rotate
143 (
144 const tensor& Q0,
145 const vector& pi,
146 const scalar deltaT
147 ) const;
148
149 //- Apply the restraints to the object
150 void applyRestraints();
151
152 //- Update and relax accelerations from the force and torque
153 void updateAcceleration(const vector& fGlobal, const vector& tauGlobal);
154
155
156 // Access functions retained as private because of the risk of
157 // confusion over what is a body local frame vector and what is global
158
159 // Access
160
161 //- Return the restraints
163 restraints() const;
164
165 //- Return the constraints
167 constraints() const;
168
169 //- Return the initial centre of rotation
170 inline const point& initialCentreOfRotation() const;
171
172 //- Return the initial orientation
173 inline const tensor& initialQ() const;
174
175 //- Return the orientation
176 inline const tensor& Q() const;
177
178 //- Return the current acceleration
179 inline const vector& a() const;
180
181 //- Return the current angular momentum
182 inline const vector& pi() const;
183
184 //- Return the current torque
185 inline const vector& tau() const;
186
187
188 // Edit
189
190 //- Return the centre of rotation
191 inline point& initialCentreOfRotation();
192
193 //- Return initial orientation
194 inline tensor& initialQ();
195
196 //- Return non-const access to the orientation
197 inline tensor& Q();
198
199 //- Return non-const access to acceleration
200 inline vector& a();
201
202 //- Return non-const access to angular momentum
203 inline vector& pi();
204
205 //- Return non-const access to torque
206 inline vector& tau();
207
208
209public:
210
211 // Constructors
212
213 //- Construct null
215
216 //- Construct from constant and state dictionaries
218 (
219 const dictionary& dict,
220 const dictionary& stateDict,
221 const Time& time
222 );
223
224 //- Construct as copy
226
227
228 //- Destructor
230
231
232 // Member Functions
233
234 // Access
235
236 //- Return the mass
237 inline scalar mass() const;
238
239 //- Return the inertia tensor
240 inline const diagTensor& momentOfInertia() const;
241
242 //- Return the motion state
243 inline const sixDoFRigidBodyMotionState& state() const;
244
245 //- Return the current centre of rotation
246 inline const point& centreOfRotation() const;
247
248 //- Return the initial centre of mass
249 inline const point& initialCentreOfMass() const;
250
251 //- Return the current centre of mass
252 inline point centreOfMass() const;
253
254 //- Return the orientation tensor, Q.
255 // globalVector = Q & bodyLocalVector
256 // bodyLocalVector = Q.T() & globalVector
257 inline const tensor& orientation() const;
258
259 //- Return the angular velocity in the global frame
260 inline vector omega() const;
261
262 //- Return the current velocity
263 inline const vector& v() const;
264
265 //- Return non-const access to vector
266 inline vector& v();
267
268 //- Return the current momentArm
269 inline vector momentArm() const;
270
271 //- Return the report Switch
272 inline bool report() const;
273
274 //- Return time
275 inline const Time& time() const;
276
277
278 // Edit
279
280 //- Store the motion state at the beginning of the time-step
281 inline void newTime();
282
283 //- Return non-const access to the centre of rotation
284 inline point& centreOfRotation();
285
286
287 // Constraints and Restraints
288
289 //- Add restraints to the motion, public to allow external
290 // addition of restraints after construction
291 void addRestraints(const dictionary& dict);
292
293 //- Add restraints to the motion, public to allow external
294 // addition of restraints after construction
295 void addConstraints(const dictionary& dict);
296
297
298 // Update state
299
300 //- Symplectic integration of velocities, orientation and position.
301 // Changes to Crank-Nicolson integration for subsequent iterations.
302 void update
303 (
304 bool firstIter,
305 const vector& fGlobal,
306 const vector& tauGlobal,
307 scalar deltaT,
308 scalar deltaT0
309 );
310
311 //- Report the status of the motion
312 void status() const;
313
314
315 // Transformations
316
317 //- Return the velocity of a position
318 inline point velocity(const point& pt) const;
319
320 //- Transform the given initial state point by the current motion
321 // state
322 inline point transform(const point& initialPoints) const;
323
324 //- Transform the given initial state pointField by the current
325 // motion state
326 tmp<pointField> transform(const pointField& initialPoints) const;
327
328 //- Transform the given initial state pointField by the current
329 // motion state scaled by the given scale
331 (
332 const pointField& initialPoints,
333 const scalarField& scale
334 ) const;
335
336
337 //- Write
338 void write(Ostream&) const;
339
340 //- Read coefficients dictionary and update system parameters,
341 // constraints and restraints but not the current state
342 bool read(const dictionary& dict);
343};
344
345
346// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
347
348} // End namespace Foam
349
350// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
351
353
354// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
355
356#endif
357
358// ************************************************************************* //
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: PtrList.H:73
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:80
A 2-tuple for storing two objects of dissimilar types. The container is similar in purpose to std::pa...
Definition: Tuple2.H:58
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
Holds the motion state of sixDoF object. Wrapped up together to allow rapid scatter to other processo...
Six degree of freedom motion for a rigid body.
point centreOfMass() const
Return the current centre of mass.
const diagTensor & momentOfInertia() const
Return the inertia tensor.
void newTime()
Store the motion state at the beginning of the time-step.
const vector & v() const
Return the current velocity.
const point & initialCentreOfMass() const
Return the initial centre of mass.
bool report() const
Return the report Switch.
const Time & time() const
Return time.
void status() const
Report the status of the motion.
const tensor & orientation() const
Return the orientation tensor, Q.
void addConstraints(const dictionary &dict)
Add restraints to the motion, public to allow external.
point transform(const point &initialPoints) const
Transform the given initial state point by the current motion.
vector momentArm() const
Return the current momentArm.
bool read(const dictionary &dict)
Read coefficients dictionary and update system parameters,.
vector omega() const
Return the angular velocity in the global frame.
scalar mass() const
Return the mass.
void addRestraints(const dictionary &dict)
Add restraints to the motion, public to allow external.
point velocity(const point &pt) const
Return the velocity of a position.
const point & centreOfRotation() const
Return the current centre of rotation.
const sixDoFRigidBodyMotionState & state() const
Return the motion state.
A class for managing temporary objects.
Definition: tmp.H:65
mesh update()
Namespace for OpenFOAM.
runTime write()
dictionary dict