sixDoFRigidBodyMotionI.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-2018 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 
28 inline Foam::tensor Foam::sixDoFRigidBodyMotion::rotationTensorX
29 (
30  scalar phi
31 ) const
32 {
33  return tensor
34  (
35  1, 0, 0,
36  0, Foam::cos(phi), -Foam::sin(phi),
37  0, Foam::sin(phi), Foam::cos(phi)
38  );
39 }
40 
41 
42 inline Foam::tensor Foam::sixDoFRigidBodyMotion::rotationTensorY
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 
56 inline Foam::tensor Foam::sixDoFRigidBodyMotion::rotationTensorZ
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 
71 Foam::sixDoFRigidBodyMotion::rotate
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 
107 Foam::sixDoFRigidBodyMotion::restraints() const
108 {
109  return restraints_;
110 }
111 
112 
114 Foam::sixDoFRigidBodyMotion::constraints() const
115 {
116  return constraints_;
117 }
118 
119 
120 inline const Foam::point&
121 Foam::sixDoFRigidBodyMotion::initialCentreOfRotation() const
122 {
123  return initialCentreOfRotation_;
124 }
125 
126 
127 inline const Foam::tensor&
128 Foam::sixDoFRigidBodyMotion::initialQ() const
129 {
130  return initialQ_;
131 }
132 
133 
134 inline const Foam::tensor& Foam::sixDoFRigidBodyMotion::Q() const
135 {
136  return motionState_.Q();
137 }
138 
139 
140 inline const Foam::vector& Foam::sixDoFRigidBodyMotion::v() const
141 {
142  return motionState_.v();
143 }
144 
145 
146 inline const Foam::vector& Foam::sixDoFRigidBodyMotion::a() const
147 {
148  return motionState_.a();
149 }
150 
151 
152 inline const Foam::vector& Foam::sixDoFRigidBodyMotion::pi() const
153 {
154  return motionState_.pi();
155 }
156 
157 
158 inline const Foam::vector& Foam::sixDoFRigidBodyMotion::tau() const
159 {
160  return motionState_.tau();
161 }
162 
163 
164 inline Foam::point& Foam::sixDoFRigidBodyMotion::initialCentreOfRotation()
165 {
166  return initialCentreOfRotation_;
167 }
168 
169 
170 inline Foam::tensor& Foam::sixDoFRigidBodyMotion::initialQ()
171 {
172  return initialQ_;
173 }
174 
175 
176 inline Foam::tensor& Foam::sixDoFRigidBodyMotion::Q()
177 {
178  return motionState_.Q();
179 }
180 
181 
182 inline Foam::vector& Foam::sixDoFRigidBodyMotion::v()
183 {
184  return motionState_.v();
185 }
186 
187 
188 inline Foam::vector& Foam::sixDoFRigidBodyMotion::a()
189 {
190  return motionState_.a();
191 }
192 
193 
194 inline Foam::vector& Foam::sixDoFRigidBodyMotion::pi()
195 {
196  return motionState_.pi();
197 }
198 
199 
200 inline Foam::vector& Foam::sixDoFRigidBodyMotion::tau()
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  (
301  + (Q() & initialQ_.T() & (initialPoint - initialCentreOfRotation_))
302  );
303 }
304 
305 // ************************************************************************* //
const Cmpt & xx() const
Definition: DiagTensorI.H:78
bool report() const
Return the report Switch.
const Cmpt & yy() const
Definition: DiagTensorI.H:84
const vector & a() const
Return access to acceleration.
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.
dimensionedSphericalTensor inv(const dimensionedSphericalTensor &dt)
Tensor< Cmpt > T() const
Return transpose.
Definition: TensorI.H:331
const Cmpt & zz() const
Definition: DiagTensorI.H:90
point transform(const point &initialPoints) const
Transform the given initial state point by the current motion.
const vector & v() const
Return access to velocity.
Vector< scalar > vector
A scalar version of the templated Vector.
Definition: vector.H:49
const vector & tau() const
Return access to torque.
const sixDoFRigidBodyMotionState & state() const
Return the motion state.
dimensionedScalar cos(const dimensionedScalar &ds)
const point & centreOfRotation() const
Return access to the centre of mass.
const diagTensor & momentOfInertia() const
Return the inertia tensor.
vector omega() const
Return the angular velocity in the global frame.
const vector & pi() const
Return access to angular momentum.
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.
dimensionedScalar sin(const dimensionedScalar &ds)
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.
#define R(A, B, C, D, E, F, K, M)
const tensor & Q() const
Return access to the orientation.
scalar mass() const
Return the mass.
Tensor< scalar > tensor
Tensor of scalars.
Definition: tensor.H:51
const point & initialCentreOfMass() const
Return the initial centre of mass.