FreeFOAM The Cross-Platform CFD Toolkit
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) 2009-2010 OpenCFD Ltd.
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
29 Foam::sixDoFRigidBodyMotion::rotationTensorX(scalar phi) const
30 {
31  return tensor
32  (
33  1, 0, 0,
34  0, Foam::cos(phi), -Foam::sin(phi),
35  0, Foam::sin(phi), Foam::cos(phi)
36  );
37 }
38 
39 
40 inline Foam::tensor
41 Foam::sixDoFRigidBodyMotion::rotationTensorY(scalar phi) const
42 {
43  return tensor
44  (
45  Foam::cos(phi), 0, Foam::sin(phi),
46  0, 1, 0,
47  -Foam::sin(phi), 0, Foam::cos(phi)
48  );
49 }
50 
51 
52 inline Foam::tensor
53 Foam::sixDoFRigidBodyMotion::rotationTensorZ(scalar phi) const
54 {
55  return tensor
56  (
57  Foam::cos(phi), -Foam::sin(phi), 0,
58  Foam::sin(phi), Foam::cos(phi), 0,
59  0, 0, 1
60  );
61 }
62 
63 
64 inline void Foam::sixDoFRigidBodyMotion::rotate
65 (
66  tensor& Q,
67  vector& pi,
68  scalar deltaT
69 ) const
70 {
71  tensor R;
72 
73  R = rotationTensorX(0.5*deltaT*pi.x()/momentOfInertia_.xx());
74  pi = pi & R;
75  Q = Q & R;
76 
77  R = rotationTensorY(0.5*deltaT*pi.y()/momentOfInertia_.yy());
78  pi = pi & R;
79  Q = Q & R;
80 
81  R = rotationTensorZ(deltaT*pi.z()/momentOfInertia_.zz());
82  pi = pi & R;
83  Q = Q & R;
84 
85  R = rotationTensorY(0.5*deltaT*pi.y()/momentOfInertia_.yy());
86  pi = pi & R;
87  Q = Q & R;
88 
89  R = rotationTensorX(0.5*deltaT*pi.x()/momentOfInertia_.xx());
90  pi = pi & R;
91  Q = Q & R;
92 }
93 
94 
96 Foam::sixDoFRigidBodyMotion::motionState() const
97 {
98  return motionState_;
99 }
100 
101 
103 Foam::sixDoFRigidBodyMotion::restraints() const
104 {
105  return restraints_;
106 }
107 
108 
109 inline const Foam::wordList& Foam::sixDoFRigidBodyMotion::restraintNames() const
110 {
111  return restraintNames_;
112 }
113 
114 
116 Foam::sixDoFRigidBodyMotion::constraints() const
117 {
118  return constraints_;
119 }
120 
121 
122 inline const Foam::wordList&
123 Foam::sixDoFRigidBodyMotion::constraintNames() const
124 {
125  return constraintNames_;
126 }
127 
128 
129 inline Foam::label Foam::sixDoFRigidBodyMotion::maxConstraintIterations() const
130 {
131  return maxConstraintIterations_;
132 }
133 
134 
135 inline const Foam::point&
136 Foam::sixDoFRigidBodyMotion::initialCentreOfMass() const
137 {
138  return initialCentreOfMass_;
139 }
140 
141 
142 inline const Foam::tensor&
143 Foam::sixDoFRigidBodyMotion::initialQ() const
144 {
145  return initialQ_;
146 }
147 
148 
149 inline const Foam::tensor& Foam::sixDoFRigidBodyMotion::Q() const
150 {
151  return motionState_.Q();
152 }
153 
154 
155 inline const Foam::vector& Foam::sixDoFRigidBodyMotion::v() const
156 {
157  return motionState_.v();
158 }
159 
160 
161 inline const Foam::vector& Foam::sixDoFRigidBodyMotion::a() const
162 {
163  return motionState_.a();
164 }
165 
166 
167 inline const Foam::vector& Foam::sixDoFRigidBodyMotion::pi() const
168 {
169  return motionState_.pi();
170 }
171 
172 
173 inline const Foam::vector& Foam::sixDoFRigidBodyMotion::tau() const
174 {
175  return motionState_.tau();
176 }
177 
178 
179 inline Foam::point& Foam::sixDoFRigidBodyMotion::initialCentreOfMass()
180 {
181  return initialCentreOfMass_;
182 }
183 
184 
185 inline Foam::tensor& Foam::sixDoFRigidBodyMotion::initialQ()
186 {
187  return initialQ_;
188 }
189 
190 
191 inline Foam::tensor& Foam::sixDoFRigidBodyMotion::Q()
192 {
193  return motionState_.Q();
194 }
195 
196 
197 inline Foam::vector& Foam::sixDoFRigidBodyMotion::v()
198 {
199  return motionState_.v();
200 }
201 
202 
203 inline Foam::vector& Foam::sixDoFRigidBodyMotion::a()
204 {
205  return motionState_.a();
206 }
207 
208 
210 {
211  return motionState_.pi();
212 }
213 
214 
215 inline Foam::vector& Foam::sixDoFRigidBodyMotion::tau()
216 {
217  return motionState_.tau();
218 }
219 
220 
221 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
222 
225 {
226  return
227  (
228  centreOfMass()
229  + (Q() & initialQ_.T() & (pInitial - initialCentreOfMass_)))
230  ;
231 }
232 
233 
235 (
236  const point& pInitial
237 ) const
238 {
239  return
240  (
241  centreOfMass()
242  + (Q() & initialQ_.T() & (pInitial - initialCentreOfMass_))
243  );
244 }
245 
246 
248 (
249  const vector& vInitial
250 ) const
251 {
252  return (Q() & initialQ_.T() & vInitial);
253 }
254 
255 
256 inline const Foam::tensor&
258 {
259  return Q();
260 }
261 
262 
264 {
265  return Q() & (inv(momentOfInertia_) & pi());
266 }
267 
268 
270 (
271  const point& pt
272 ) const
273 {
274  return (omega() ^ (pt - centreOfMass())) + v();
275 }
276 
277 
279 {
280  return motionState_.centreOfMass();
281 }
282 
283 
284 inline const Foam::diagTensor&
286 {
287  return momentOfInertia_;
288 }
289 
290 
291 inline Foam::scalar Foam::sixDoFRigidBodyMotion::mass() const
292 {
293  return mass_;
294 }
295 
296 
298 {
299  return report_;
300 }
301 
302 
304 {
305  return motionState_.centreOfMass();
306 }
307 
308 
310 {
311  return momentOfInertia_;
312 }
313 
314 
315 inline Foam::scalar& Foam::sixDoFRigidBodyMotion::mass()
316 {
317  return mass_;
318 }
319 
320 // ************************ vim: set sw=4 sts=4 et: ************************ //