FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

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-2010 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
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your 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, see <http://www.gnu.org/licenses/>.
00023 
00024 \*---------------------------------------------------------------------------*/
00025 
00026 #include "SDA.H"
00027 #include <OpenFOAM/addToRunTimeSelectionTable.H>
00028 #include <OpenFOAM/mathematicalConstants.H>
00029 
00030 using namespace Foam::mathematicalConstant;
00031 
00032 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
00033 
00034 namespace Foam
00035 {
00036 namespace solidBodyMotionFunctions
00037 {
00038     defineTypeNameAndDebug(SDA, 0);
00039     addToRunTimeSelectionTable(solidBodyMotionFunction, SDA, dictionary);
00040 };
00041 };
00042 
00043 
00044 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00045 
00046 Foam::solidBodyMotionFunctions::SDA::SDA
00047 (
00048     const dictionary& SBMFCoeffs,
00049     const Time& runTime
00050 )
00051 :
00052     solidBodyMotionFunction(SBMFCoeffs, runTime),
00053     CofG_(SBMFCoeffs_.lookup("CofG"))
00054 {
00055     read(SBMFCoeffs);
00056 }
00057 
00058 
00059 // * * * * * * * * * * * * * * * * Destructors * * * * * * * * * * * * * * * //
00060 
00061 Foam::solidBodyMotionFunctions::SDA::~SDA()
00062 {}
00063 
00064 
00065 // * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * * //
00066 
00067 Foam::septernion Foam::solidBodyMotionFunctions::SDA::transformation() const
00068 {
00069     scalar time = time_.value();
00070 
00071     scalar Tpi = Tp_ + dTp_*(time/dTi_);   // Current roll period [sec]
00072     scalar wr = 2*pi/Tpi; // Current Freq [/sec]
00073 
00074     // Current Phase for roll [rad]
00075     scalar r = dTp_/dTi_;
00076     scalar u = Tp_ + r*time;
00077     scalar phr = 2*pi*((Tp_/u - 1) + log(mag(u)) - log(Tp_))/r;
00078 
00079     // Current Phase for Sway [rad]
00080     scalar phs = phr + pi;
00081 
00082     // Current Phase for Heave [rad]
00083     scalar phh = phr + pi/2;
00084 
00085     scalar rollA = max(rollAmax_*exp(-sqr(Tpi - Tpn_)/(2*Q_)), rollAmin_);
00086 
00087     vector T
00088     (
00089         0,
00090         swayA_*(sin(wr*time + phs) - sin(phs)),
00091         heaveA_*(sin(wr*time + phh) - sin(phh))
00092     );
00093     quaternion R(rollA*sin(wr*time + phr), 0, 0);
00094     septernion TR(septernion(CofG_ + T)*R*septernion(-CofG_));
00095 
00096     Info<< "solidBodyMotionFunctions::SDA::transformation(): "
00097         << "Time = " << time << " transformation: " << TR << endl;
00098 
00099     return TR;
00100 }
00101 
00102 
00103 bool Foam::solidBodyMotionFunctions::SDA::read(const dictionary& SBMFCoeffs)
00104 {
00105     solidBodyMotionFunction::read(SBMFCoeffs);
00106 
00107     SBMFCoeffs_.lookup("CofG") >> CofG_;
00108     SBMFCoeffs_.lookup("lamda") >> lamda_;
00109     SBMFCoeffs_.lookup("rollAmax") >> rollAmax_;
00110     SBMFCoeffs_.lookup("rollAmin") >> rollAmin_;
00111     SBMFCoeffs_.lookup("heaveA") >> heaveA_;
00112     SBMFCoeffs_.lookup("swayA") >> swayA_;
00113     SBMFCoeffs_.lookup("Q") >> Q_;
00114     SBMFCoeffs_.lookup("Tp") >> Tp_;
00115     SBMFCoeffs_.lookup("Tpn") >> Tpn_;
00116     SBMFCoeffs_.lookup("dTi") >> dTi_;
00117     SBMFCoeffs_.lookup("dTp") >> dTp_;
00118 
00119     // Rescale parameters according to the given scale parameter
00120     if (lamda_ > 1 + SMALL)
00121     {
00122         heaveA_ /= lamda_;
00123         swayA_ /= lamda_;
00124         Tp_ /= sqrt(lamda_);
00125         Tpn_ /= sqrt(lamda_);
00126         dTi_ /= sqrt(lamda_);
00127         dTp_ /= sqrt(lamda_);
00128     }
00129 
00130     return true;
00131 }
00132 
00133 
00134 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines