1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2010 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
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 \*---------------------------------------------------------------------------*/
27 #include "addToRunTimeSelectionTable.H"
30 #include "interpolateXY.H"
31 #include "mathematicalConstants.H"
33 using namespace Foam::mathematicalConstant;
35 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
39 namespace solidBodyMotionFunctions
41 defineTypeNameAndDebug(SKA, 0);
42 addToRunTimeSelectionTable(solidBodyMotionFunction, SKA, dictionary);
47 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
49 Foam::solidBodyMotionFunctions::SKA::SKA
51 const dictionary& SBMFCoeffs,
55 solidBodyMotionFunction(SBMFCoeffs, runTime)
61 // * * * * * * * * * * * * * * * * Destructors * * * * * * * * * * * * * * * //
63 Foam::solidBodyMotionFunctions::SKA::~SKA()
67 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
69 Foam::septernion Foam::solidBodyMotionFunctions::SKA::transformation() const
71 scalar t = time_.value();
77 "solidBodyMotionFunctions::SKA::transformation()"
78 ) << "current time (" << t
79 << ") is less than the minimum in the data table ("
84 if (t > times_[times_.size()-1])
88 "solidBodyMotionFunctions::SKA::transformation()"
89 ) << "current time (" << t
90 << ") is greater than the maximum in the data table ("
91 << times_[times_.size()-1] << ')'
95 translationRotationVectors TRV = interpolateXY
102 // Convert the rotational motion from deg to rad
105 quaternion R(TRV[1].x(), TRV[1].y(), TRV[1].z());
106 septernion TR(septernion(CofG_ + TRV[0])*R*septernion(-CofG_));
108 Info<< "solidBodyMotionFunctions::SKA::transformation(): "
109 << "Time = " << t << " transformation: " << TR << endl;
115 bool Foam::solidBodyMotionFunctions::SKA::read(const dictionary& SBMFCoeffs)
117 solidBodyMotionFunction::read(SBMFCoeffs);
119 // If the timeDataFileName has changed read the file
121 fileName newTimeDataFileName
123 fileName(SBMFCoeffs_.lookup("timeDataFileName")).expand()
126 if (newTimeDataFileName != timeDataFileName_)
128 timeDataFileName_ = newTimeDataFileName;
130 IFstream dataStream(timeDataFileName_);
132 if (dataStream.good())
134 List<Tuple2<scalar, translationRotationVectors> > timeValues
139 times_.setSize(timeValues.size());
140 values_.setSize(timeValues.size());
142 forAll(timeValues, i)
144 times_[i] = timeValues[i].first();
145 values_[i] = timeValues[i].second();
152 "solidBodyMotionFunctions::SKA::read(const dictionary&)"
153 ) << "Cannot open time data file " << timeDataFileName_
158 SBMFCoeffs_.lookup("CofG") >> CofG_;
164 // ************************************************************************* //