1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "rotatingOscillation.H"
27 #include "addToRunTimeSelectionTable.H"
28 #include "mathematicalConstants.H"
30 using namespace Foam::mathematicalConstant;
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
36 namespace solidBodyMotionFunctions
38 defineTypeNameAndDebug(rotatingOscillation, 0);
39 addToRunTimeSelectionTable
41 solidBodyMotionFunction,
48 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
51 Foam::solidBodyMotionFunctions::rotatingOscillation::calcPosition
56 return amplitude_*sin(2*pi*t/period_);
61 Foam::solidBodyMotionFunctions::rotatingOscillation::calcTransformation
66 vector eulerAngles = amplitude_*sin(2*pi*t/period_);
68 // Convert the rotational motion from deg to rad
69 eulerAngles *= pi/180.0;
71 const quaternion R(eulerAngles.x(), eulerAngles.y(), eulerAngles.z());
72 const septernion TR(septernion(origin_)*R*septernion(-origin_));
78 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
80 Foam::solidBodyMotionFunctions::rotatingOscillation::
83 const dictionary& SBMFCoeffs,
87 solidBodyMotionFunction(SBMFCoeffs, runTime)
93 // * * * * * * * * * * * * * * * * Destructors * * * * * * * * * * * * * * * //
95 Foam::solidBodyMotionFunctions::rotatingOscillation::
96 ~rotatingOscillation()
100 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
103 Foam::solidBodyMotionFunctions::rotatingOscillation::
104 transformation() const
106 scalar t = time_.value();
108 const septernion TR = calcTransformation(t);
110 Info<< "solidBodyMotionFunctions::rotatingOscillation::"
111 << "transformation(): "
112 << "Time = " << t << " transformation: " << TR << endl;
119 Foam::solidBodyMotionFunctions::rotatingOscillation::velocity() const
121 scalar t = time_.value();
122 scalar dt = time_.deltaT().value();
124 const septernion velocity
126 (calcTransformation(t).t() - calcTransformation(t - dt).t())/dt,
127 (calcTransformation(t).r()/calcTransformation(t - dt).r())/dt
134 bool Foam::solidBodyMotionFunctions::rotatingOscillation::read
136 const dictionary& SBMFCoeffs
139 solidBodyMotionFunction::read(SBMFCoeffs);
141 SBMFCoeffs_.lookup("origin") >> origin_;
142 SBMFCoeffs_.lookup("amplitude") >> amplitude_;
143 SBMFCoeffs_.lookup("period") >> period_;
149 // ************************************************************************* //