sixDoFRigidBodyMotion.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) 2011-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::sixDoFRigidBodyMotion
26 
27 Description
28  Six degree of freedom motion for a rigid body.
29 
30  Angular momentum stored in body fixed reference frame. Reference
31  orientation of the body (where Q = I) must align with the cartesian axes
32  such that the Inertia tensor is in principle component form. Can add
33  restraints (e.g. a spring) and constraints (e.g. motion may only be on a
34  plane).
35 
36  The time-integrator for the motion is run-time selectable with options for
37  symplectic (explicit), Crank-Nicolson and Newmark schemes.
38 
39 SourceFiles
40  sixDoFRigidBodyMotionI.H
41  sixDoFRigidBodyMotion.C
42  sixDoFRigidBodyMotionIO.C
43 
44 \*---------------------------------------------------------------------------*/
45 
46 #ifndef sixDoFRigidBodyMotion_H
47 #define sixDoFRigidBodyMotion_H
48 
50 #include "pointField.H"
53 #include "Tuple2.H"
54 #include "septernion.H"
55 
56 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
57 
58 namespace Foam
59 {
60 
61 // Forward declarations
62 class sixDoFSolver;
63 
64 /*---------------------------------------------------------------------------*\
65  Class sixDoFRigidBodyMotion Declaration
66 \*---------------------------------------------------------------------------*/
67 
69 {
70  friend class sixDoFSolver;
71 
72  // Private Data
73 
74  //- Motion state data object
75  sixDoFRigidBodyMotionState motionState_;
76 
77  //- Motion state data object for previous time-step
78  sixDoFRigidBodyMotionState motionState0_;
79 
80  //- Motion restraints
82 
83  //- Motion constraints
85 
86  //- Translational constraint tensor
87  tensor tConstraints_;
88 
89  //- Rotational constraint tensor
90  tensor rConstraints_;
91 
92  //- Centre of mass of initial state
93  point initialCentreOfMass_;
94 
95  //- Centre of rotation of initial state
96  point initialCentreOfRotation_;
97 
98  //- Orientation of initial state
99  tensor initialQ_;
100 
101  //- Mass of the body
102  scalar mass_;
103 
104  //- Moment of inertia of the body in reference configuration
105  // (Q = I)
106  diagTensor momentOfInertia_;
107 
108  //- Acceleration relaxation coefficient
109  scalar aRelax_;
110 
111  //- Acceleration damping coefficient (for steady-state simulations)
112  scalar aDamp_;
113 
114  //- Switch to turn reporting of motion data on and off
115  Switch report_;
116 
117  //- Motion solver
118  autoPtr<sixDoFSolver> solver_;
119 
120 
121  // Private Member Functions
122 
123  //- Calculate the rotation tensor around the body reference
124  // frame x-axis by the given angle
125  inline tensor rotationTensorX(scalar deltaT) const;
126 
127  //- Calculate the rotation tensor around the body reference
128  // frame y-axis by the given angle
129  inline tensor rotationTensorY(scalar deltaT) const;
130 
131  //- Calculate the rotation tensor around the body reference
132  // frame z-axis by the given angle
133  inline tensor rotationTensorZ(scalar deltaT) const;
134 
135  //- Apply rotation tensors to Q0 for the given torque (pi) and deltaT
136  // and return the rotated Q and pi as a tuple
138  (
139  const tensor& Q0,
140  const vector& pi,
141  const scalar deltaT
142  ) const;
143 
144  //- Apply the restraints to the object
145  void applyRestraints();
146 
147  //- Update and relax accelerations from the force and torque
148  void updateAcceleration(const vector& fGlobal, const vector& tauGlobal);
149 
150 
151  // Access functions retained as private because of the risk of
152  // confusion over what is a body local frame vector and what is global
153 
154  // Access
155 
156  //- Return the restraints
158  restraints() const;
159 
160  //- Return the constraints
162  constraints() const;
163 
164  //- Return the initial centre of rotation
165  inline const point& initialCentreOfRotation() const;
166 
167  //- Return the initial orientation
168  inline const tensor& initialQ() const;
169 
170  //- Return the orientation
171  inline const tensor& Q() const;
172 
173  //- Return the current acceleration
174  inline const vector& a() const;
175 
176  //- Return the current angular momentum
177  inline const vector& pi() const;
178 
179  //- Return the current torque
180  inline const vector& tau() const;
181 
182 
183  // Edit
184 
185  //- Return the centre of rotation
186  inline point& initialCentreOfRotation();
187 
188  //- Return initial orientation
189  inline tensor& initialQ();
190 
191  //- Return non-const access to the orientation
192  inline tensor& Q();
193 
194  //- Return non-const access to vector
195  inline vector& v();
196 
197  //- Return non-const access to acceleration
198  inline vector& a();
199 
200  //- Return non-const access to angular momentum
201  inline vector& pi();
202 
203  //- Return non-const access to torque
204  inline vector& tau();
205 
206 
207 public:
208 
209  //- Runtime type information
210  TypeName("sixDoFRigidBodyMotion");
211 
212 
213  // Constructors
214 
215  //- Construct null
217 
218  //- Construct from constant and state dictionaries
220  (
221  const dictionary& dict,
222  const dictionary& stateDict
223  );
224 
225  //- Copy constructor
227 
228 
229  //- Destructor
230  virtual ~sixDoFRigidBodyMotion();
231 
232 
233  // Member Functions
234 
235  // Access
236 
237  //- Return the mass
238  inline scalar mass() const;
239 
240  //- Return the inertia tensor
241  inline const diagTensor& momentOfInertia() const;
242 
243  //- Return the motion state
244  inline const sixDoFRigidBodyMotionState& state() const;
245 
246  //- Return the current centre of rotation
247  inline const point& centreOfRotation() const;
248 
249  //- Return the initial centre of mass
250  inline const point& initialCentreOfMass() const;
251 
252  //- Return the current centre of mass
253  inline point centreOfMass() const;
254 
255  //- Return the orientation tensor, Q.
256  // globalVector = Q & bodyLocalVector
257  // bodyLocalVector = Q.T() & globalVector
258  inline const tensor& orientation() const;
259 
260  //- Return the angular velocity in the global frame
261  inline vector omega() const;
262 
263  //- Return the current velocity
264  inline const vector& v() const;
265 
266  inline vector momentArm() const;
267 
268  //- Return the report Switch
269  inline bool report() const;
270 
271 
272  // Edit
273 
274  //- Store the motion state at the beginning of the time-step
275  inline void newTime();
276 
277  //- Return non-const access to the centre of rotation
278  inline point& centreOfRotation();
279 
280 
281  // Constraints and Restraints
282 
283  //- Add restraints to the motion, public to allow external
284  // addition of restraints after construction
285  void addRestraints(const dictionary& dict);
286 
287  //- Add restraints to the motion, public to allow external
288  // addition of restraints after construction
289  void addConstraints(const dictionary& dict);
290 
291 
292  // Update state
293 
294  //- Symplectic integration of velocities, orientation and position.
295  // Changes to Crank-Nicolson integration for subsequent iterations.
296  void update
297  (
298  bool firstIter,
299  const vector& fGlobal,
300  const vector& tauGlobal,
301  scalar deltaT,
302  scalar deltaT0
303  );
304 
305  //- Report the status of the motion
306  void status() const;
307 
308 
309  // Transformations
310 
311  //- Return the velocity of a position
312  inline point velocity(const point& pt) const;
313 
314  //- Return the transformation relative to the initial time
315  inline septernion transform0() const;
316 
317  //- Transform the given initial state point by the current motion
318  // state
319  inline point transform(const point& initialPoint) const;
320 
321  //- Transform the given initial state pointField by the current
322  // motion state
323  tmp<pointField> transform(const pointField& initialPoints) const;
324 
325 
326  //- Write
327  void write(Ostream&) const;
328 
329  //- Read coefficients dictionary and update system parameters,
330  // constraints and restraints but not the current state
331  bool read(const dictionary& dict);
332 };
333 
334 
335 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
336 
337 } // End namespace Foam
338 
339 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
340 
341 #include "sixDoFRigidBodyMotionI.H"
342 
343 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
344 
345 #endif
346 
347 // ************************************************************************* //
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: PtrList.H:75
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Definition: Switch.H:61
A 2-tuple for storing two objects of different types.
Definition: Tuple2.H:66
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
Septernion class used to perform translations and rotations in 3D space.
Definition: septernion.H:66
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.
void update(bool firstIter, const vector &fGlobal, const vector &tauGlobal, scalar deltaT, scalar deltaT0)
Symplectic integration of velocities, orientation and position.
const point & initialCentreOfMass() const
Return the initial centre of mass.
bool report() const
Return the report Switch.
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.
void write(Ostream &) const
Write.
septernion transform0() const
Return the transformation relative to the initial time.
virtual ~sixDoFRigidBodyMotion()
Destructor.
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.
TypeName("sixDoFRigidBodyMotion")
Runtime type information.
point transform(const point &initialPoint) const
Transform the given initial state point by the current motion.
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:55
const vector tau
void rotate(const bool reverse, barycentric &coordinates)
Rotation transform. Corrects the coordinates when the track moves.
Definition: tracking.C:1033
Namespace for OpenFOAM.
dictionary dict