FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

sixDoFRigidBodyMotionI.H

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 2009-2010 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software: you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
00023 
00024 \*---------------------------------------------------------------------------*/
00025 
00026 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
00027 
00028 inline Foam::tensor
00029 Foam::sixDoFRigidBodyMotion::rotationTensorX(scalar phi) const
00030 {
00031     return tensor
00032     (
00033         1, 0, 0,
00034         0, Foam::cos(phi), -Foam::sin(phi),
00035         0, Foam::sin(phi), Foam::cos(phi)
00036     );
00037 }
00038 
00039 
00040 inline Foam::tensor
00041 Foam::sixDoFRigidBodyMotion::rotationTensorY(scalar phi) const
00042 {
00043     return tensor
00044     (
00045         Foam::cos(phi), 0, Foam::sin(phi),
00046         0, 1, 0,
00047         -Foam::sin(phi), 0, Foam::cos(phi)
00048     );
00049 }
00050 
00051 
00052 inline Foam::tensor
00053 Foam::sixDoFRigidBodyMotion::rotationTensorZ(scalar phi) const
00054 {
00055     return tensor
00056     (
00057         Foam::cos(phi), -Foam::sin(phi), 0,
00058         Foam::sin(phi), Foam::cos(phi), 0,
00059         0, 0, 1
00060     );
00061 }
00062 
00063 
00064 inline void Foam::sixDoFRigidBodyMotion::rotate
00065 (
00066     tensor& Q,
00067     vector& pi,
00068     scalar deltaT
00069 ) const
00070 {
00071     tensor R;
00072 
00073     R = rotationTensorX(0.5*deltaT*pi.x()/momentOfInertia_.xx());
00074     pi = pi & R;
00075     Q = Q & R;
00076 
00077     R = rotationTensorY(0.5*deltaT*pi.y()/momentOfInertia_.yy());
00078     pi = pi & R;
00079     Q = Q & R;
00080 
00081     R = rotationTensorZ(deltaT*pi.z()/momentOfInertia_.zz());
00082     pi = pi & R;
00083     Q = Q & R;
00084 
00085     R = rotationTensorY(0.5*deltaT*pi.y()/momentOfInertia_.yy());
00086     pi = pi & R;
00087     Q = Q & R;
00088 
00089     R = rotationTensorX(0.5*deltaT*pi.x()/momentOfInertia_.xx());
00090     pi = pi & R;
00091     Q = Q & R;
00092 }
00093 
00094 
00095 inline const Foam::sixDoFRigidBodyMotionState&
00096 Foam::sixDoFRigidBodyMotion::motionState() const
00097 {
00098     return motionState_;
00099 }
00100 
00101 
00102 inline const Foam::PtrList<Foam::sixDoFRigidBodyMotionRestraint>&
00103 Foam::sixDoFRigidBodyMotion::restraints() const
00104 {
00105     return restraints_;
00106 }
00107 
00108 
00109 inline const Foam::wordList& Foam::sixDoFRigidBodyMotion::restraintNames() const
00110 {
00111     return restraintNames_;
00112 }
00113 
00114 
00115 inline const Foam::PtrList<Foam::sixDoFRigidBodyMotionConstraint>&
00116 Foam::sixDoFRigidBodyMotion::constraints() const
00117 {
00118     return constraints_;
00119 }
00120 
00121 
00122 inline const Foam::wordList&
00123 Foam::sixDoFRigidBodyMotion::constraintNames() const
00124 {
00125     return constraintNames_;
00126 }
00127 
00128 
00129 inline Foam::label Foam::sixDoFRigidBodyMotion::maxConstraintIterations() const
00130 {
00131     return maxConstraintIterations_;
00132 }
00133 
00134 
00135 inline const Foam::point&
00136 Foam::sixDoFRigidBodyMotion::initialCentreOfMass() const
00137 {
00138     return initialCentreOfMass_;
00139 }
00140 
00141 
00142 inline const Foam::tensor&
00143 Foam::sixDoFRigidBodyMotion::initialQ() const
00144 {
00145     return initialQ_;
00146 }
00147 
00148 
00149 inline const Foam::tensor& Foam::sixDoFRigidBodyMotion::Q() const
00150 {
00151     return motionState_.Q();
00152 }
00153 
00154 
00155 inline const Foam::vector& Foam::sixDoFRigidBodyMotion::v() const
00156 {
00157     return motionState_.v();
00158 }
00159 
00160 
00161 inline const Foam::vector& Foam::sixDoFRigidBodyMotion::a() const
00162 {
00163     return motionState_.a();
00164 }
00165 
00166 
00167 inline const Foam::vector& Foam::sixDoFRigidBodyMotion::pi() const
00168 {
00169     return motionState_.pi();
00170 }
00171 
00172 
00173 inline const Foam::vector& Foam::sixDoFRigidBodyMotion::tau() const
00174 {
00175     return motionState_.tau();
00176 }
00177 
00178 
00179 inline Foam::point& Foam::sixDoFRigidBodyMotion::initialCentreOfMass()
00180 {
00181     return initialCentreOfMass_;
00182 }
00183 
00184 
00185 inline Foam::tensor& Foam::sixDoFRigidBodyMotion::initialQ()
00186 {
00187     return initialQ_;
00188 }
00189 
00190 
00191 inline Foam::tensor& Foam::sixDoFRigidBodyMotion::Q()
00192 {
00193     return motionState_.Q();
00194 }
00195 
00196 
00197 inline Foam::vector& Foam::sixDoFRigidBodyMotion::v()
00198 {
00199     return motionState_.v();
00200 }
00201 
00202 
00203 inline Foam::vector& Foam::sixDoFRigidBodyMotion::a()
00204 {
00205     return motionState_.a();
00206 }
00207 
00208 
00209 inline Foam::vector& Foam::sixDoFRigidBodyMotion::pi()
00210 {
00211     return motionState_.pi();
00212 }
00213 
00214 
00215 inline Foam::vector& Foam::sixDoFRigidBodyMotion::tau()
00216 {
00217     return motionState_.tau();
00218 }
00219 
00220 
00221 // * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * * //
00222 
00223 inline Foam::tmp<Foam::pointField>
00224 Foam::sixDoFRigidBodyMotion::currentPosition(const pointField& pInitial) const
00225 {
00226     return
00227     (
00228         centreOfMass()
00229       + (Q() & initialQ_.T() & (pInitial - initialCentreOfMass_)))
00230     ;
00231 }
00232 
00233 
00234 inline Foam::point Foam::sixDoFRigidBodyMotion::currentPosition
00235 (
00236     const point& pInitial
00237 ) const
00238 {
00239     return
00240     (
00241         centreOfMass()
00242       + (Q() & initialQ_.T() & (pInitial - initialCentreOfMass_))
00243     );
00244 }
00245 
00246 
00247 inline Foam::vector Foam::sixDoFRigidBodyMotion::currentOrientation
00248 (
00249     const vector& vInitial
00250 ) const
00251 {
00252     return (Q() & initialQ_.T() & vInitial);
00253 }
00254 
00255 
00256 inline const Foam::tensor&
00257 Foam::sixDoFRigidBodyMotion::orientation() const
00258 {
00259     return Q();
00260 }
00261 
00262 
00263 inline Foam::vector Foam::sixDoFRigidBodyMotion::omega() const
00264 {
00265     return  Q() & (inv(momentOfInertia_) & pi());
00266 }
00267 
00268 
00269 inline Foam::point Foam::sixDoFRigidBodyMotion::currentVelocity
00270 (
00271     const point& pt
00272 ) const
00273 {
00274     return (omega() ^ (pt - centreOfMass())) + v();
00275 }
00276 
00277 
00278 inline const Foam::point& Foam::sixDoFRigidBodyMotion::centreOfMass() const
00279 {
00280     return motionState_.centreOfMass();
00281 }
00282 
00283 
00284 inline const Foam::diagTensor&
00285 Foam::sixDoFRigidBodyMotion::momentOfInertia() const
00286 {
00287     return momentOfInertia_;
00288 }
00289 
00290 
00291 inline Foam::scalar Foam::sixDoFRigidBodyMotion::mass() const
00292 {
00293     return mass_;
00294 }
00295 
00296 
00297 inline bool Foam::sixDoFRigidBodyMotion::report() const
00298 {
00299     return report_;
00300 }
00301 
00302 
00303 inline Foam::point& Foam::sixDoFRigidBodyMotion::centreOfMass()
00304 {
00305     return motionState_.centreOfMass();
00306 }
00307 
00308 
00309 inline Foam::diagTensor& Foam::sixDoFRigidBodyMotion::momentOfInertia()
00310 {
00311     return momentOfInertia_;
00312 }
00313 
00314 
00315 inline Foam::scalar& Foam::sixDoFRigidBodyMotion::mass()
00316 {
00317     return mass_;
00318 }
00319 
00320 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines