SKA.C
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include "SKA.H"
00028 #include "addToRunTimeSelectionTable.H"
00029 #include "Tuple2.H"
00030 #include "IFstream.H"
00031 #include "interpolateXY.H"
00032 #include "mathematicalConstants.H"
00033
00034 using namespace Foam::mathematicalConstant;
00035
00036
00037
00038 namespace Foam
00039 {
00040 namespace solidBodyMotionFunctions
00041 {
00042 defineTypeNameAndDebug(SKA, 0);
00043 addToRunTimeSelectionTable(solidBodyMotionFunction, SKA, dictionary);
00044 };
00045 };
00046
00047
00048
00049
00050 Foam::solidBodyMotionFunctions::SKA::SKA
00051 (
00052 const dictionary& SBMFCoeffs,
00053 const Time& runTime
00054 )
00055 :
00056 solidBodyMotionFunction(SBMFCoeffs, runTime)
00057 {
00058 read(SBMFCoeffs);
00059 }
00060
00061
00062
00063
00064 Foam::solidBodyMotionFunctions::SKA::~SKA()
00065 {}
00066
00067
00068
00069
00070 Foam::septernion Foam::solidBodyMotionFunctions::SKA::transformation() const
00071 {
00072 scalar t = time_.value();
00073
00074 if (t < times_[0])
00075 {
00076 FatalErrorIn
00077 (
00078 "solidBodyMotionFunctions::SKA::transformation()"
00079 ) << "current time (" << t
00080 << ") is less than the minimum in the data table ("
00081 << times_[0] << ')'
00082 << exit(FatalError);
00083 }
00084
00085 if (t > times_[times_.size()-1])
00086 {
00087 FatalErrorIn
00088 (
00089 "solidBodyMotionFunctions::SKA::transformation()"
00090 ) << "current time (" << t
00091 << ") is greater than the maximum in the data table ("
00092 << times_[times_.size()-1] << ')'
00093 << exit(FatalError);
00094 }
00095
00096 translationRotationVectors TRV = interpolateXY
00097 (
00098 t,
00099 times_,
00100 values_
00101 );
00102
00103
00104 TRV[1] *= pi/180.0;
00105
00106 quaternion R(TRV[1].x(), TRV[1].y(), TRV[1].z());
00107 septernion TR(septernion(CofG_ + TRV[0])*R*septernion(-CofG_));
00108
00109 Info<< "solidBodyMotionFunctions::SKA::transformation(): "
00110 << "Time = " << t << " transformation: " << TR << endl;
00111
00112 return TR;
00113 }
00114
00115
00116 bool Foam::solidBodyMotionFunctions::SKA::read(const dictionary& SBMFCoeffs)
00117 {
00118 solidBodyMotionFunction::read(SBMFCoeffs);
00119
00120
00121
00122 fileName newTimeDataFileName(SBMFCoeffs_.lookup("timeDataFileName"));
00123
00124 if (newTimeDataFileName != timeDataFileName_)
00125 {
00126 timeDataFileName_ = newTimeDataFileName;
00127
00128 IFstream dataStream(timeDataFileName_);
00129
00130 if (dataStream.good())
00131 {
00132 List<Tuple2<scalar, translationRotationVectors> > timeValues
00133 (
00134 dataStream
00135 );
00136
00137 times_.setSize(timeValues.size());
00138 values_.setSize(timeValues.size());
00139
00140 forAll(timeValues, i)
00141 {
00142 times_[i] = timeValues[i].first();
00143 values_[i] = timeValues[i].second();
00144 }
00145 }
00146 else
00147 {
00148 FatalErrorIn
00149 (
00150 "solidBodyMotionFunctions::SKA::read(const dictionary&)"
00151 ) << "Cannot open time data file " << timeDataFileName_
00152 << exit(FatalError);
00153 }
00154 }
00155
00156 SBMFCoeffs_.lookup("CofG") >> CofG_;
00157
00158 return true;
00159 }
00160
00161
00162
Copyright © 2000-2009 OpenCFD Ltd