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-2019 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 
55 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
56 
57 namespace Foam
58 {
59 
60 // Forward declarations
61 class sixDoFSolver;
62 
63 /*---------------------------------------------------------------------------*\
64  Class sixDoFRigidBodyMotion Declaration
65 \*---------------------------------------------------------------------------*/
66 
68 {
69  friend class sixDoFSolver;
70 
71  // Private Data
72 
73  //- Motion state data object
74  sixDoFRigidBodyMotionState motionState_;
75 
76  //- Motion state data object for previous time-step
77  sixDoFRigidBodyMotionState motionState0_;
78 
79  //- Motion restraints
81 
82  //- Motion constraints
84 
85  //- Translational constraint tensor
86  tensor tConstraints_;
87 
88  //- Rotational constraint tensor
89  tensor rConstraints_;
90 
91  //- Centre of mass of initial state
92  point initialCentreOfMass_;
93 
94  //- Centre of rotation of initial state
95  point initialCentreOfRotation_;
96 
97  //- Orientation of initial state
98  tensor initialQ_;
99 
100  //- Mass of the body
101  scalar mass_;
102 
103  //- Moment of inertia of the body in reference configuration
104  // (Q = I)
105  diagTensor momentOfInertia_;
106 
107  //- Acceleration relaxation coefficient
108  scalar aRelax_;
109 
110  //- Acceleration damping coefficient (for steady-state simulations)
111  scalar aDamp_;
112 
113  //- Switch to turn reporting of motion data on and off
114  Switch report_;
115 
116  //- Motion solver
117  autoPtr<sixDoFSolver> solver_;
118 
119 
120  // Private Member Functions
121 
122  //- Calculate the rotation tensor around the body reference
123  // frame x-axis by the given angle
124  inline tensor rotationTensorX(scalar deltaT) const;
125 
126  //- Calculate the rotation tensor around the body reference
127  // frame y-axis by the given angle
128  inline tensor rotationTensorY(scalar deltaT) const;
129 
130  //- Calculate the rotation tensor around the body reference
131  // frame z-axis by the given angle
132  inline tensor rotationTensorZ(scalar deltaT) const;
133 
134  //- Apply rotation tensors to Q0 for the given torque (pi) and deltaT
135  // and return the rotated Q and pi as a tuple
136  inline Tuple2<tensor, vector> rotate
137  (
138  const tensor& Q0,
139  const vector& pi,
140  const scalar deltaT
141  ) const;
142 
143  //- Apply the restraints to the object
144  void applyRestraints();
145 
146  //- Update and relax accelerations from the force and torque
147  void updateAcceleration(const vector& fGlobal, const vector& tauGlobal);
148 
149 
150  // Access functions retained as private because of the risk of
151  // confusion over what is a body local frame vector and what is global
152 
153  // Access
154 
155  //- Return the restraints
157  restraints() const;
158 
159  //- Return the constraints
161  constraints() const;
162 
163  //- Return the initial centre of rotation
164  inline const point& initialCentreOfRotation() const;
165 
166  //- Return the initial orientation
167  inline const tensor& initialQ() const;
168 
169  //- Return the orientation
170  inline const tensor& Q() const;
171 
172  //- Return the current acceleration
173  inline const vector& a() const;
174 
175  //- Return the current angular momentum
176  inline const vector& pi() const;
177 
178  //- Return the current torque
179  inline const vector& tau() const;
180 
181 
182  // Edit
183 
184  //- Return the centre of rotation
185  inline point& initialCentreOfRotation();
186 
187  //- Return initial orientation
188  inline tensor& initialQ();
189 
190  //- Return non-const access to the orientation
191  inline tensor& Q();
192 
193  //- Return non-const access to vector
194  inline vector& v();
195 
196  //- Return non-const access to acceleration
197  inline vector& a();
198 
199  //- Return non-const access to angular momentum
200  inline vector& pi();
201 
202  //- Return non-const access to torque
203  inline vector& tau();
204 
205 
206 public:
207 
208  //- Runtime type information
209  TypeName("sixDoFRigidBodyMotion");
210 
211 
212  // Constructors
213 
214  //- Construct null
216 
217  //- Construct from constant and state dictionaries
219  (
220  const dictionary& dict,
221  const dictionary& stateDict
222  );
223 
224  //- Copy constructor
226 
227 
228  //- Destructor
229  virtual ~sixDoFRigidBodyMotion();
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  inline vector momentArm() const;
266 
267  //- Return the report Switch
268  inline bool report() const;
269 
270 
271  // Edit
272 
273  //- Store the motion state at the beginning of the time-step
274  inline void newTime();
275 
276  //- Return non-const access to the centre of rotation
277  inline point& centreOfRotation();
278 
279 
280  // Constraints and Restraints
281 
282  //- Add restraints to the motion, public to allow external
283  // addition of restraints after construction
284  void addRestraints(const dictionary& dict);
285 
286  //- Add restraints to the motion, public to allow external
287  // addition of restraints after construction
288  void addConstraints(const dictionary& dict);
289 
290 
291  // Update state
292 
293  //- Symplectic integration of velocities, orientation and position.
294  // Changes to Crank-Nicolson integration for subsequent iterations.
295  void update
296  (
297  bool firstIter,
298  const vector& fGlobal,
299  const vector& tauGlobal,
300  scalar deltaT,
301  scalar deltaT0
302  );
303 
304  //- Report the status of the motion
305  void status() const;
306 
307 
308  // Transformations
309 
310  //- Return the velocity of a position
311  inline point velocity(const point& pt) const;
312 
313  //- Transform the given initial state point by the current motion
314  // state
315  inline point transform(const point& initialPoints) const;
316 
317  //- Transform the given initial state pointField by the current
318  // motion state
319  tmp<pointField> transform(const pointField& initialPoints) const;
320 
321  //- Transform the given initial state pointField by the current
322  // motion state scaled by the given scale
324  (
325  const pointField& initialPoints,
326  const scalarField& scale
327  ) const;
328 
329 
330  //- Write
331  void write(Ostream&) const;
332 
333  //- Read coefficients dictionary and update system parameters,
334  // constraints and restraints but not the current state
335  bool read(const dictionary& dict);
336 };
337 
338 
339 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
340 
341 } // End namespace Foam
342 
343 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
344 
345 #include "sixDoFRigidBodyMotionI.H"
346 
347 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
348 
349 #endif
350 
351 // ************************************************************************* //
Six degree of freedom motion for a rigid body.
virtual ~sixDoFRigidBodyMotion()
Destructor.
void addConstraints(const dictionary &dict)
Add restraints to the motion, public to allow external.
bool read(const dictionary &dict)
Read coefficients dictionary and update system parameters,.
dictionary dict
bool report() const
Return the report Switch.
void write(Ostream &) const
Write.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
A 2-tuple for storing two objects of different types.
Definition: HashTable.H:65
point centreOfMass() const
Return the current centre of mass.
const point & centreOfRotation() const
Return the current centre of rotation.
A simple wrapper around bool so that it can be read as a word: true/false, on/off, yes/no, y/n, t/f, or none/any.
Definition: Switch.H:60
point transform(const point &initialPoints) const
Transform the given initial state point by the current motion.
const sixDoFRigidBodyMotionState & state() const
Return the motion state.
const diagTensor & momentOfInertia() const
Return the inertia tensor.
vector omega() const
Return the angular velocity in the global frame.
sixDoFRigidBodyMotion()
Construct null.
Holds the motion state of sixDoF object. Wrapped up together to allow rapid scatter to other processo...
const tensor & orientation() const
Return the orientation tensor, Q.
void status() const
Report the status of the motion.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
void newTime()
Store the motion state at the beginning of the time-step.
point velocity(const point &pt) const
Return the velocity of a position.
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: List.H:70
TypeName("sixDoFRigidBodyMotion")
Runtime type information.
scalar mass() const
Return the mass.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
A class for managing temporary objects.
Definition: PtrList.H:53
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.
void addRestraints(const dictionary &dict)
Add restraints to the motion, public to allow external.
Namespace for OpenFOAM.