OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

SDA.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 \*---------------------------------------------------------------------------*/
00026 
00027 #include "SDA.H"
00028 #include "addToRunTimeSelectionTable.H"
00029 #include "mathematicalConstants.H"
00030 
00031 using namespace Foam::mathematicalConstant;
00032 
00033 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
00034 
00035 namespace Foam
00036 {
00037 namespace solidBodyMotionFunctions
00038 {
00039     defineTypeNameAndDebug(SDA, 0);
00040     addToRunTimeSelectionTable(solidBodyMotionFunction, SDA, dictionary);
00041 };
00042 };
00043 
00044 
00045 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00046 
00047 Foam::solidBodyMotionFunctions::SDA::SDA
00048 (
00049     const dictionary& SBMFCoeffs,
00050     const Time& runTime
00051 )
00052 :
00053     solidBodyMotionFunction(SBMFCoeffs, runTime),
00054     CofG_(SBMFCoeffs_.lookup("CofG"))
00055 {
00056     read(SBMFCoeffs);
00057 }
00058 
00059 
00060 // * * * * * * * * * * * * * * * * Destructors * * * * * * * * * * * * * * * //
00061 
00062 Foam::solidBodyMotionFunctions::SDA::~SDA()
00063 {}
00064 
00065 
00066 // * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * * //
00067 
00068 Foam::septernion Foam::solidBodyMotionFunctions::SDA::transformation() const
00069 {
00070     scalar time = time_.value();
00071 
00072     scalar Tpi = Tp_ + dTp_*(time/dTi_);   // Current roll period [sec]
00073     scalar wr = 2*pi/Tpi; // Current Freq [/sec]
00074 
00075     // Current Phase for roll [rad]
00076     scalar r = dTp_/dTi_;
00077     scalar u = Tp_ + r*time;
00078     scalar phr = 2*pi*((Tp_/u - 1) + log(mag(u)) - log(Tp_))/r;
00079 
00080     // Current Phase for Sway [rad]
00081     scalar phs = phr + pi;
00082 
00083     // Current Phase for Heave [rad]
00084     scalar phh = phr + pi/2;
00085 
00086     scalar rollA = max(rollAmax_*exp(-sqr(Tpi - Tpn_)/(2*Q_)), rollAmin_);
00087 
00088     vector T
00089     (
00090         0,
00091         swayA_*(sin(wr*time + phs) - sin(phs)),
00092         heaveA_*(sin(wr*time + phh) - sin(phh))
00093     );
00094     quaternion R(rollA*sin(wr*time + phr), 0, 0);
00095     septernion TR(septernion(CofG_ + T)*R*septernion(-CofG_));
00096 
00097     Info<< "solidBodyMotionFunctions::SDA::transformation(): "
00098         << "Time = " << time << " transformation: " << TR << endl;
00099 
00100     return TR;
00101 }
00102 
00103 
00104 bool Foam::solidBodyMotionFunctions::SDA::read(const dictionary& SBMFCoeffs)
00105 {
00106     solidBodyMotionFunction::read(SBMFCoeffs);
00107 
00108     SBMFCoeffs_.lookup("CofG") >> CofG_;
00109     SBMFCoeffs_.lookup("lamda") >> lamda_;
00110     SBMFCoeffs_.lookup("rollAmax") >> rollAmax_;
00111     SBMFCoeffs_.lookup("rollAmin") >> rollAmin_;
00112     SBMFCoeffs_.lookup("heaveA") >> heaveA_;
00113     SBMFCoeffs_.lookup("swayA") >> swayA_;
00114     SBMFCoeffs_.lookup("Q") >> Q_;
00115     SBMFCoeffs_.lookup("Tp") >> Tp_;
00116     SBMFCoeffs_.lookup("Tpn") >> Tpn_;
00117     SBMFCoeffs_.lookup("dTi") >> dTi_;
00118     SBMFCoeffs_.lookup("dTp") >> dTp_;
00119 
00120     // Rescale parameters according to the given scale parameter
00121     if (lamda_ > 1 + SMALL)
00122     {
00123         heaveA_ /= lamda_;
00124         swayA_ /= lamda_;
00125         Tp_ /= sqrt(lamda_);
00126         Tpn_ /= sqrt(lamda_);
00127         dTi_ /= sqrt(lamda_);
00128         dTp_ /= sqrt(lamda_);
00129     }
00130 
00131     return true;
00132 }
00133 
00134 
00135 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd