sixDoFRigidBodyMotionI.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 \*---------------------------------------------------------------------------*/
25 
26 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
27 
29 (
30  scalar phi
31 ) const
32 {
33  return tensor
34  (
35  1, 0, 0,
36  0, Foam::cos(phi), -Foam::sin(phi),
38  );
39 }
40 
41 
43 (
44  scalar phi
45 ) const
46 {
47  return tensor
48  (
49  Foam::cos(phi), 0, Foam::sin(phi),
50  0, 1, 0,
51  -Foam::sin(phi), 0, Foam::cos(phi)
52  );
53 }
54 
55 
57 (
58  scalar phi
59 ) const
60 {
61  return tensor
62  (
63  Foam::cos(phi), -Foam::sin(phi), 0,
64  Foam::sin(phi), Foam::cos(phi), 0,
65  0, 0, 1
66  );
67 }
68 
69 
72 (
73  const tensor& Q0,
74  const vector& pi0,
75  const scalar deltaT
76 ) const
77 {
78  Tuple2<tensor, vector> Qpi(Q0, pi0);
79  tensor& Q = Qpi.first();
80  vector& pi = Qpi.second();
81 
82  tensor R = rotationTensorX(0.5*deltaT*pi.x()/momentOfInertia_.xx());
83  pi = pi & R;
84  Q = Q & R;
85 
86  R = rotationTensorY(0.5*deltaT*pi.y()/momentOfInertia_.yy());
87  pi = pi & R;
88  Q = Q & R;
89 
90  R = rotationTensorZ(deltaT*pi.z()/momentOfInertia_.zz());
91  pi = pi & R;
92  Q = Q & R;
93 
94  R = rotationTensorY(0.5*deltaT*pi.y()/momentOfInertia_.yy());
95  pi = pi & R;
96  Q = Q & R;
97 
98  R = rotationTensorX(0.5*deltaT*pi.x()/momentOfInertia_.xx());
99  pi = pi & R;
100  Q = Q & R;
101 
102  return Qpi;
103 }
104 
105 
108 {
109  return restraints_;
110 }
111 
112 
115 {
116  return constraints_;
117 }
118 
119 
120 inline const Foam::point&
122 {
123  return initialCentreOfRotation_;
124 }
125 
126 
127 inline const Foam::tensor&
129 {
130  return initialQ_;
131 }
132 
133 
135 {
136  return motionState_.Q();
137 }
138 
139 
141 {
142  return motionState_.v();
143 }
144 
145 
147 {
148  return motionState_.a();
149 }
150 
151 
153 {
154  return motionState_.pi();
155 }
156 
157 
159 {
160  return motionState_.tau();
161 }
162 
163 
165 {
166  return initialCentreOfRotation_;
167 }
168 
169 
171 {
172  return initialQ_;
173 }
174 
175 
177 {
178  return motionState_.Q();
179 }
180 
181 
183 {
184  return motionState_.v();
185 }
186 
187 
189 {
190  return motionState_.a();
191 }
192 
193 
195 {
196  return motionState_.pi();
197 }
198 
199 
201 {
202  return motionState_.tau();
203 }
204 
205 
206 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
207 
208 inline Foam::scalar Foam::sixDoFRigidBodyMotion::mass() const
209 {
210  return mass_;
211 }
212 
213 
214 inline const Foam::diagTensor&
216 {
217  return momentOfInertia_;
218 }
219 
220 
223 {
224  return motionState_;
225 }
226 
227 
229 {
230  return motionState_.centreOfRotation();
231 }
232 
233 
234 inline const Foam::point&
236 {
237  return initialCentreOfMass_;
238 }
239 
240 
242 {
243  return transform(initialCentreOfMass_);
244 }
245 
246 
248 {
249  return centreOfMass() - motionState_.centreOfRotation();
250 }
251 
252 
253 inline const Foam::tensor&
255 {
256  return Q();
257 }
258 
259 
261 {
262  return Q() & (inv(momentOfInertia_) & pi());
263 }
264 
265 
267 {
268  return report_;
269 }
270 
271 
273 {
274  motionState0_ = motionState_;
275 }
276 
277 
279 {
280  return motionState_.centreOfRotation();
281 }
282 
283 
285 (
286  const point& pt
287 ) const
288 {
289  return (omega() ^ (pt - centreOfRotation())) + v();
290 }
291 
292 
294 (
295  const point& initialPoint
296 ) const
297 {
298  return
299  (
300  centreOfRotation()
301  + (Q() & initialQ_.T() & (initialPoint - initialCentreOfRotation_))
302  );
303 }
304 
305 // ************************************************************************* //
Foam::sixDoFRigidBodyMotion::newTime
void newTime()
Store the motion state at the beginning of the time-step.
Definition: sixDoFRigidBodyMotionI.H:272
Foam::Tensor
Templated 3D tensor derived from VectorSpace adding construction from 9 components,...
Definition: complexI.H:224
Foam::sixDoFRigidBodyMotion::rotationTensorZ
tensor rotationTensorZ(scalar deltaT) const
Calculate the rotation tensor around the body reference.
Definition: sixDoFRigidBodyMotionI.H:57
Foam::DiagTensor< scalar >
Foam::sixDoFRigidBodyMotion::mass
scalar mass() const
Return the mass.
Definition: sixDoFRigidBodyMotionI.H:208
Foam::sixDoFRigidBodyMotion::rotate
Tuple2< tensor, vector > rotate(const tensor &Q0, const vector &pi, const scalar deltaT) const
Apply rotation tensors to Q0 for the given torque (pi) and deltaT.
Definition: sixDoFRigidBodyMotionI.H:72
Foam::sixDoFRigidBodyMotion::Q
const tensor & Q() const
Return the orientation.
Definition: sixDoFRigidBodyMotionI.H:134
Foam::Tuple2::second
const Type2 & second() const
Return second.
Definition: Tuple2.H:106
Foam::sixDoFRigidBodyMotion::v
vector & v()
Return non-const access to vector.
Definition: sixDoFRigidBodyMotionI.H:140
Foam::sixDoFRigidBodyMotion::orientation
const tensor & orientation() const
Return the orientation tensor, Q.
Definition: sixDoFRigidBodyMotionI.H:254
phi
surfaceScalarField & phi
Definition: setRegionFluidFields.H:8
Foam::sin
dimensionedScalar sin(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:255
Foam::tensor
Tensor< scalar > tensor
Tensor of scalars.
Definition: tensor.H:51
Foam::sixDoFRigidBodyMotion::velocity
point velocity(const point &pt) const
Return the velocity of a position.
Definition: sixDoFRigidBodyMotionI.H:285
Foam::Tuple2::first
const Type1 & first() const
Return first.
Definition: Tuple2.H:94
Foam::sixDoFRigidBodyMotion::rotationTensorY
tensor rotationTensorY(scalar deltaT) const
Calculate the rotation tensor around the body reference.
Definition: sixDoFRigidBodyMotionI.H:43
Foam::sixDoFRigidBodyMotion::constraints
const PtrList< sixDoFRigidBodyMotionConstraint > & constraints() const
Return the constraints.
Definition: sixDoFRigidBodyMotionI.H:114
Foam::sixDoFRigidBodyMotion::restraints_
PtrList< sixDoFRigidBodyMotionRestraint > restraints_
Motion restraints.
Definition: sixDoFRigidBodyMotion.H:79
Foam::transform
dimensionSet transform(const dimensionSet &)
Definition: dimensionSet.C:465
Foam::Q
This function object calculates and outputs the second invariant of the velocity gradient tensor [1/s...
Definition: Q.H:119
R
#define R(A, B, C, D, E, F, K, M)
Foam::inv
dimensionedSphericalTensor inv(const dimensionedSphericalTensor &dt)
Definition: dimensionedSphericalTensor.C:71
Foam::PtrList< Foam::sixDoFRigidBodyMotionRestraint >
Foam::sixDoFRigidBodyMotionState
Holds the motion state of sixDoF object. Wrapped up together to allow rapid scatter to other processo...
Definition: sixDoFRigidBodyMotionState.H:66
Foam::sixDoFRigidBodyMotion::initialCentreOfMass
const point & initialCentreOfMass() const
Return the initial centre of mass.
Definition: sixDoFRigidBodyMotionI.H:235
Foam::sixDoFRigidBodyMotion::transform
point transform(const point &initialPoints) const
Transform the given initial state point by the current motion.
Definition: sixDoFRigidBodyMotionI.H:294
Foam::Vector< scalar >
Foam::sixDoFRigidBodyMotion::initialCentreOfRotation
const point & initialCentreOfRotation() const
Return the initial centre of rotation.
Definition: sixDoFRigidBodyMotionI.H:121
Foam::sixDoFRigidBodyMotion::momentArm
vector momentArm() const
Definition: sixDoFRigidBodyMotionI.H:247
Foam::sixDoFRigidBodyMotion::report
bool report() const
Return the report Switch.
Definition: sixDoFRigidBodyMotionI.H:266
Foam::sixDoFRigidBodyMotion::a
const vector & a() const
Return the current acceleration.
Definition: sixDoFRigidBodyMotionI.H:146
Foam::constant::mathematical::pi
const scalar pi(M_PI)
Foam::sixDoFRigidBodyMotion::pi
const vector & pi() const
Return the current angular momentum.
Definition: sixDoFRigidBodyMotionI.H:152
Foam::sixDoFRigidBodyMotion::restraints
const PtrList< sixDoFRigidBodyMotionRestraint > & restraints() const
Return the restraints.
Definition: sixDoFRigidBodyMotionI.H:107
Foam::Tuple2
A 2-tuple for storing two objects of different types.
Definition: Tuple2.H:47
Foam::sixDoFRigidBodyMotion::omega
vector omega() const
Return the angular velocity in the global frame.
Definition: sixDoFRigidBodyMotionI.H:260
Foam::sixDoFRigidBodyMotion::centreOfRotation
const point & centreOfRotation() const
Return the current centre of rotation.
Definition: sixDoFRigidBodyMotionI.H:228
Foam::sixDoFRigidBodyMotion::centreOfMass
point centreOfMass() const
Return the current centre of mass.
Definition: sixDoFRigidBodyMotionI.H:241
Foam::sixDoFRigidBodyMotion::momentOfInertia
const diagTensor & momentOfInertia() const
Return the inertia tensor.
Definition: sixDoFRigidBodyMotionI.H:215
Foam::sixDoFRigidBodyMotion::rotationTensorX
tensor rotationTensorX(scalar deltaT) const
Calculate the rotation tensor around the body reference.
Definition: sixDoFRigidBodyMotionI.H:29
Foam::sixDoFRigidBodyMotion::tau
const vector & tau() const
Return the current torque.
Definition: sixDoFRigidBodyMotionI.H:158
Foam::sixDoFRigidBodyMotion::state
const sixDoFRigidBodyMotionState & state() const
Return the motion state.
Definition: sixDoFRigidBodyMotionI.H:222
Foam::cos
dimensionedScalar cos(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:256
Foam::sixDoFRigidBodyMotion::initialQ
const tensor & initialQ() const
Return the initial orientation.
Definition: sixDoFRigidBodyMotionI.H:128