Loading...
Searching...
No Matches
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-2023 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;
66/*---------------------------------------------------------------------------*\
67 Class sixDoFRigidBodyMotion Declaration
68\*---------------------------------------------------------------------------*/
69
71{
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 //- Flag to enable time-variant constraints
123 bool updateConstraints_;
124
125 //- Motion solver
126 autoPtr<sixDoFSolver> solver_;
127
128
129 // Private Member Functions
130
131 //- Calculate the rotation tensor around the body reference
132 // frame x-axis by the given angle
133 inline tensor rotationTensorX(scalar deltaT) const;
134
135 //- Calculate the rotation tensor around the body reference
136 // frame y-axis by the given angle
137 inline tensor rotationTensorY(scalar deltaT) const;
138
139 //- Calculate the rotation tensor around the body reference
140 // frame z-axis by the given angle
141 inline tensor rotationTensorZ(scalar deltaT) const;
142
143 //- Apply rotation tensors to Q0 for the given torque (pi) and deltaT
144 // and return the rotated Q and pi as a tuple
145 inline Tuple2<tensor, vector> rotate
146 (
147 const tensor& Q0,
148 const vector& pi,
149 const scalar deltaT
150 ) const;
151
152 //- Apply the restraints to the object
153 void applyRestraints();
154
155 //- Update and relax accelerations from the force and torque
156 void updateAcceleration(const vector& fGlobal, const vector& tauGlobal);
157
158 //- Update the constraints to the object
159 void updateConstraints();
160
161
162 // Access functions retained as private because of the risk of
163 // confusion over what is a body local frame vector and what is global
164
165 // Access
166
167 //- Return the restraints
169 restraints() const;
170
171 //- Return the constraints
173 constraints() const;
174
175 //- Return the initial centre of rotation
176 inline const point& initialCentreOfRotation() const;
177
178 //- Return the initial orientation
179 inline const tensor& initialQ() const;
180
181 //- Return the orientation
182 inline const tensor& Q() const;
183
184 //- Return the current acceleration
185 inline const vector& a() const;
186
187 //- Return the current angular momentum
188 inline const vector& pi() const;
189
190 //- Return the current torque
191 inline const vector& tau() const;
192
193
194 // Edit
195
196 //- Return the centre of rotation
197 inline point& initialCentreOfRotation();
198
199 //- Return initial orientation
200 inline tensor& initialQ();
201
202 //- Return non-const access to the orientation
203 inline tensor& Q();
204
205 //- Return non-const access to acceleration
206 inline vector& a();
207
208 //- Return non-const access to angular momentum
209 inline vector& pi();
210
211 //- Return non-const access to torque
212 inline vector& tau();
213
214
215public:
216
217 // Constructors
218
219 //- Construct null
221
222 //- Construct from constant and state dictionaries
224 (
225 const dictionary& dict,
226 const dictionary& stateDict,
227 const Time& time
228 );
229
230 //- Construct as copy
232
233
234 //- Destructor
236
237
238 // Member Functions
239
240 // Access
241
242 //- Return the mass
243 inline scalar mass() const;
244
245 //- Return the inertia tensor
246 inline const diagTensor& momentOfInertia() const;
247
248 //- Return the motion state
249 inline const sixDoFRigidBodyMotionState& state() const;
250
251 //- Return the current centre of rotation
252 inline const point& centreOfRotation() const;
253
254 //- Return the initial centre of mass
255 inline const point& initialCentreOfMass() const;
256
257 //- Return the current centre of mass
258 inline point centreOfMass() const;
259
260 //- Return the orientation tensor, Q.
261 // globalVector = Q & bodyLocalVector
262 // bodyLocalVector = Q.T() & globalVector
263 inline const tensor& orientation() const;
264
265 //- Return the angular velocity in the global frame
266 inline vector omega() const;
267
268 //- Return the current velocity
269 inline const vector& v() const;
270
271 //- Return non-const access to vector
272 inline vector& v();
273
274 //- Return the current momentArm
275 inline vector momentArm() const;
276
277 //- Return the report Switch
278 inline bool report() const;
279
280 //- Return the update-constraints flag
281 inline bool updateConstraints() const;
282
283 //- Return time
284 inline const Time& time() const;
285
286
287 // Edit
288
289 //- Store the motion state at the beginning of the time-step
290 inline void newTime();
291
292 //- Return non-const access to the centre of rotation
293 inline point& centreOfRotation();
294
295
296 // Constraints and Restraints
297
298 //- Add restraints to the motion, public to allow external
299 // addition of restraints after construction
300 void addRestraints(const dictionary& dict);
301
302 //- Add restraints to the motion, public to allow external
303 // addition of restraints after construction
304 void addConstraints(const dictionary& dict);
305
306
307 // Update state
308
309 //- Symplectic integration of velocities, orientation and position.
310 // Changes to Crank-Nicolson integration for subsequent iterations.
311 void update
312 (
313 bool firstIter,
314 const vector& fGlobal,
315 const vector& tauGlobal,
316 scalar deltaT,
317 scalar deltaT0
318 );
319
320 //- Report the status of the motion
321 void status() const;
322
323
324 // Transformations
325
326 //- Return the velocity of a position
327 inline point velocity(const point& pt) const;
328
329 //- Transform the given initial state point by the current motion
330 // state
331 inline point transform(const point& initialPoints) const;
332
333 //- Transform the given initial state pointField by the current
334 // motion state
335 tmp<pointField> transform(const pointField& initialPoints) const;
336
337 //- Transform the given initial state pointField by the current
338 // motion state scaled by the given scale
340 (
341 const pointField& initialPoints,
342 const scalarField& scale
343 ) const;
344
345
346 //- Write
347 void write(Ostream&) const;
348
349 //- Read coefficients dictionary and update system parameters,
350 // constraints and restraints but not the current state
351 bool read(const dictionary& dict);
352};
353
354
355// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
356
357} // End namespace Foam
358
359// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
360
362
363// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
364
365#endif
366
367// ************************************************************************* //
constexpr scalar pi(M_PI)
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition PtrList.H:67
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition Time.H:75
A 2-tuple for storing two objects of dissimilar types. The container is similar in purpose to std::pa...
Definition Tuple2.H:51
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
Holds the motion state of sixDoF object. Wrapped up together to allow rapid scatter to other processo...
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.
bool updateConstraints() const
Return the update-constraints flag.
sixDoFRigidBodyMotion(const Time &)
Construct null.
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:75
mesh update()
Namespace for OpenFOAM.
DiagTensor< scalar > diagTensor
DiagTensor of scalars, i.e. DiagTensor<scalar>.
Definition diagTensor.H:49
Tensor< scalar > tensor
Definition symmTensor.H:57
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
vector point
Point is a vector.
Definition point.H:37
vectorField pointField
pointField is a vectorField.
Vector< scalar > vector
Definition vector.H:57
runTime write()
dictionary dict