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