1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
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
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "constantVelocity.H"
28 #include "addToRunTimeSelectionTable.H"
29 #include "mathematicalConstants.H"
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 namespace solidBodyMotionFunctions
38 defineTypeNameAndDebug(constantVelocity, 0);
39 addToRunTimeSelectionTable
41 solidBodyMotionFunction,
49 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
52 Foam::solidBodyMotionFunctions::constantVelocity::calcTransformation
57 const vector translation = transVelocity_*(t - startMotionTime_);
58 const vector rotation = rotVelocity_*(t - startMotionTime_);
60 const quaternion R(rotation.x(), rotation.y(), rotation.z());
63 septernion(origin_ + translation)*R*septernion(-origin_)
69 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
71 Foam::solidBodyMotionFunctions::constantVelocity::constantVelocity
73 const dictionary& SBMFCoeffs,
77 solidBodyMotionFunction(SBMFCoeffs, runTime)
82 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
85 Foam::solidBodyMotionFunctions::constantVelocity::transformation() const
87 const scalar t = time_.value();
89 const septernion TR = calcTransformation(t);
91 Info<< "solidBodyMotionFunctions::constantVelocity::transformation(): "
92 << "Time = " << t << " transformation: " << TR << endl;
99 Foam::solidBodyMotionFunctions::constantVelocity::velocity() const
101 const scalar t = time_.value();
102 const scalar dt = time_.deltaT().value();
104 const septernion velocity
106 (calcTransformation(t).t() - calcTransformation(t - dt).t())/dt,
107 (calcTransformation(t).r()/calcTransformation(t - dt).r())/dt
114 bool Foam::solidBodyMotionFunctions::constantVelocity::read
116 const dictionary& SBMFCoeffs
119 solidBodyMotionFunction::read(SBMFCoeffs);
121 SBMFCoeffs_.lookup("origin") >> origin_;
122 SBMFCoeffs_.lookup("translationalVelocity") >> transVelocity_;
123 SBMFCoeffs_.lookup("rotationalVelocity") >> rotVelocity_;
124 SBMFCoeffs_.lookup("startMotionTime") >> startMotionTime_;
125 SBMFCoeffs_.lookup("inDegrees") >> inDegrees_;
127 // Convert to radians if necessary
128 rotVelocity_ *= inDegrees_ ? mathematicalConstant::pi/180.0 : 1;
133 // ************************************************************************* //