1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
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 \*---------------------------------------------------------------------------*/
28 #include "addToRunTimeSelectionTable.H"
31 #include "interpolateXY.H"
32 #include "mathematicalConstants.H"
34 using namespace Foam::mathematicalConstant;
36 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
40 namespace solidBodyMotionFunctions
42 defineTypeNameAndDebug(SKA, 0);
43 addToRunTimeSelectionTable(solidBodyMotionFunction, SKA, dictionary);
48 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
50 Foam::solidBodyMotionFunctions::SKA::SKA
52 const dictionary& SBMFCoeffs,
56 solidBodyMotionFunction(SBMFCoeffs, runTime)
62 // * * * * * * * * * * * * * * * * Destructors * * * * * * * * * * * * * * * //
64 Foam::solidBodyMotionFunctions::SKA::~SKA()
68 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
70 Foam::septernion Foam::solidBodyMotionFunctions::SKA::transformation() const
72 scalar t = time_.value();
78 "solidBodyMotionFunctions::SKA::transformation()"
79 ) << "current time (" << t
80 << ") is less than the minimum in the data table ("
85 if (t > times_[times_.size()-1])
89 "solidBodyMotionFunctions::SKA::transformation()"
90 ) << "current time (" << t
91 << ") is greater than the maximum in the data table ("
92 << times_[times_.size()-1] << ')'
96 translationRotationVectors TRV = interpolateXY
103 // Convert the rotational motion from deg to rad
106 quaternion R(TRV[1].x(), TRV[1].y(), TRV[1].z());
107 septernion TR(septernion(CofG_ + TRV[0])*R*septernion(-CofG_));
109 Info<< "solidBodyMotionFunctions::SKA::transformation(): "
110 << "Time = " << t << " transformation: " << TR << endl;
116 bool Foam::solidBodyMotionFunctions::SKA::read(const dictionary& SBMFCoeffs)
118 solidBodyMotionFunction::read(SBMFCoeffs);
120 // If the timeDataFileName has changed read the file
122 fileName newTimeDataFileName(SBMFCoeffs_.lookup("timeDataFileName"));
124 if (newTimeDataFileName != timeDataFileName_)
126 timeDataFileName_ = newTimeDataFileName;
128 IFstream dataStream(timeDataFileName_);
130 if (dataStream.good())
132 List<Tuple2<scalar, translationRotationVectors> > timeValues
137 times_.setSize(timeValues.size());
138 values_.setSize(timeValues.size());
140 forAll(timeValues, i)
142 times_[i] = timeValues[i].first();
143 values_[i] = timeValues[i].second();
150 "solidBodyMotionFunctions::SKA::read(const dictionary&)"
151 ) << "Cannot open time data file " << timeDataFileName_
156 SBMFCoeffs_.lookup("CofG") >> CofG_;
162 // ************************************************************************* //