1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 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, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
28 #include <OpenFOAM/addToRunTimeSelectionTable.H>
29 #include <OpenFOAM/mathematicalConstants.H>
31 using namespace Foam::mathematicalConstant;
33 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
37 namespace solidBodyMotionFunctions
39 defineTypeNameAndDebug(SDA, 0);
40 addToRunTimeSelectionTable(solidBodyMotionFunction, SDA, dictionary);
45 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
47 Foam::solidBodyMotionFunctions::SDA::SDA
49 const dictionary& SBMFCoeffs,
53 solidBodyMotionFunction(SBMFCoeffs, runTime),
54 CofG_(SBMFCoeffs_.lookup("CofG"))
60 // * * * * * * * * * * * * * * * * Destructors * * * * * * * * * * * * * * * //
62 Foam::solidBodyMotionFunctions::SDA::~SDA()
66 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
68 Foam::septernion Foam::solidBodyMotionFunctions::SDA::transformation() const
70 scalar time = time_.value();
72 scalar Tpi = Tp_ + dTp_*(time/dTi_); // Current roll period [sec]
73 scalar wr = 2*pi/Tpi; // Current Freq [/sec]
75 // Current Phase for roll [rad]
77 scalar u = Tp_ + r*time;
78 scalar phr = 2*pi*((Tp_/u - 1) + log(mag(u)) - log(Tp_))/r;
80 // Current Phase for Sway [rad]
81 scalar phs = phr + pi;
83 // Current Phase for Heave [rad]
84 scalar phh = phr + pi/2;
86 scalar rollA = max(rollAmax_*exp(-sqr(Tpi - Tpn_)/(2*Q_)), rollAmin_);
91 swayA_*(sin(wr*time + phs) - sin(phs)),
92 heaveA_*(sin(wr*time + phh) - sin(phh))
94 quaternion R(rollA*sin(wr*time + phr), 0, 0);
95 septernion TR(septernion(CofG_ + T)*R*septernion(-CofG_));
97 Info<< "solidBodyMotionFunctions::SDA::transformation(): "
98 << "Time = " << time << " transformation: " << TR << endl;
104 bool Foam::solidBodyMotionFunctions::SDA::read(const dictionary& SBMFCoeffs)
106 solidBodyMotionFunction::read(SBMFCoeffs);
108 SBMFCoeffs_.lookup("CofG") >> CofG_;
109 SBMFCoeffs_.lookup("lamda") >> lamda_;
110 SBMFCoeffs_.lookup("rollAmax") >> rollAmax_;
111 SBMFCoeffs_.lookup("rollAmin") >> rollAmin_;
112 SBMFCoeffs_.lookup("heaveA") >> heaveA_;
113 SBMFCoeffs_.lookup("swayA") >> swayA_;
114 SBMFCoeffs_.lookup("Q") >> Q_;
115 SBMFCoeffs_.lookup("Tp") >> Tp_;
116 SBMFCoeffs_.lookup("Tpn") >> Tpn_;
117 SBMFCoeffs_.lookup("dTi") >> dTi_;
118 SBMFCoeffs_.lookup("dTp") >> dTp_;
120 // Rescale parameters according to the given scale parameter
121 if (lamda_ > 1 + SMALL)
126 Tpn_ /= sqrt(lamda_);
127 dTi_ /= sqrt(lamda_);
128 dTp_ /= sqrt(lamda_);
135 // ************************ vim: set sw=4 sts=4 et: ************************ //