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 | Copyright (C) 2011-2015 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 constaints
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  // Constructors
209 
210  //- Construct null
212 
213  //- Construct from constant and state dictionaries
215  (
216  const dictionary& dict,
217  const dictionary& stateDict
218  );
219 
220  //- Construct as copy
222 
223 
224  //- Destructor
226 
227 
228  // Member Functions
229 
230  // Access
231 
232  //- Return the mass
233  inline scalar mass() const;
234 
235  //- Return the inertia tensor
236  inline const diagTensor& momentOfInertia() const;
237 
238  //- Return the motion state
239  inline const sixDoFRigidBodyMotionState& state() const;
240 
241  //- Return the current centre of rotation
242  inline const point& centreOfRotation() const;
243 
244  //- Return the initial centre of mass
245  inline const point& initialCentreOfMass() const;
246 
247  //- Return the current centre of mass
248  inline point centreOfMass() const;
249 
250  //- Return the orientation tensor, Q.
251  // globalVector = Q & bodyLocalVector
252  // bodyLocalVector = Q.T() & globalVector
253  inline const tensor& orientation() const;
254 
255  //- Return the angular velocity in the global frame
256  inline vector omega() const;
257 
258  //- Return the current velocity
259  inline const vector& v() const;
260 
261  inline vector momentArm() const;
262 
263  //- Return the report Switch
264  inline bool report() const;
265 
266 
267  // Edit
268 
269  //- Store the motion state at the beginning of the time-step
270  inline void newTime();
271 
272  //- Return non-const access to the centre of rotation
273  inline point& centreOfRotation();
274 
275 
276  // Constraints and Restraints
277 
278  //- Add restraints to the motion, public to allow external
279  // addition of restraints after construction
280  void addRestraints(const dictionary& dict);
281 
282  //- Add restraints to the motion, public to allow external
283  // addition of restraints after construction
284  void addConstraints(const dictionary& dict);
285 
286 
287  // Update state
288 
289  //- Symplectic integration of velocities, orientation and position.
290  // Changes to Crank-Nicolson integration for subsequent iterations.
291  void update
292  (
293  bool firstIter,
294  const vector& fGlobal,
295  const vector& tauGlobal,
296  scalar deltaT,
297  scalar deltaT0
298  );
299 
300  //- Report the status of the motion
301  void status() const;
302 
303 
304  // Transformations
305 
306  //- Return the velocity of a position
307  inline point velocity(const point& pt) const;
308 
309  //- Transform the given initial state point by the current motion
310  // state
311  inline point transform(const point& initialPoints) const;
312 
313  //- Transform the given initial state pointField by the current
314  // motion state
315  tmp<pointField> transform(const pointField& initialPoints) const;
316 
317  //- Transform the given initial state pointField by the current
318  // motion state scaled by the given scale
320  (
321  const pointField& initialPoints,
322  const scalarField& scale
323  ) 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 // ************************************************************************* //
Six degree of freedom motion for a rigid body.
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
point centreOfMass() const
Return the current centre of mass.
bool report() const
Return the report Switch.
point velocity(const point &pt) const
Return the velocity of a position.
const diagTensor & momentOfInertia() const
Return the inertia tensor.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
A 2-tuple for storing two objects of different types.
Definition: Tuple2.H:47
scalar mass() const
Return the mass.
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.
Definition: Switch.H:60
point transform(const point &initialPoints) const
Transform the given initial state point by the current motion.
const tensor & orientation() const
Return the orientation tensor, Q.
vector omega() const
Return the angular velocity in the global frame.
sixDoFRigidBodyMotion()
Construct null.
const point & initialCentreOfMass() const
Return the initial centre of mass.
const sixDoFRigidBodyMotionState & state() const
Return the motion state.
Holds the motion state of sixDoF object. Wrapped up together to allow rapid scatter to other processo...
const point & centreOfRotation() const
Return the current centre of rotation.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
void newTime()
Store the motion state at the beginning of the time-step.
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: List.H:62
void write(Ostream &) const
Write.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:53
A class for managing temporary objects.
Definition: PtrList.H:54
void update(bool firstIter, const vector &fGlobal, const vector &tauGlobal, scalar deltaT, scalar deltaT0)
Symplectic integration of velocities, orientation and position.
void addRestraints(const dictionary &dict)
Add restraints to the motion, public to allow external.
Namespace for OpenFOAM.
void status() const
Report the status of the motion.