1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
27 #include "addToRunTimeSelectionTable.H"
28 #include "mathematicalConstants.H"
30 using namespace Foam::constant::mathematical;
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
36 namespace solidBodyMotionFunctions
38 defineTypeNameAndDebug(SDA, 0);
39 addToRunTimeSelectionTable(solidBodyMotionFunction, SDA, dictionary);
44 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
46 Foam::solidBodyMotionFunctions::SDA::SDA
48 const dictionary& SBMFCoeffs,
52 solidBodyMotionFunction(SBMFCoeffs, runTime),
53 CofG_(SBMFCoeffs_.lookup("CofG"))
59 // * * * * * * * * * * * * * * * * Destructors * * * * * * * * * * * * * * * //
61 Foam::solidBodyMotionFunctions::SDA::~SDA()
65 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
67 Foam::septernion Foam::solidBodyMotionFunctions::SDA::transformation() const
69 scalar time = time_.value();
71 scalar Tpi = Tp_ + dTp_*(time/dTi_); // Current roll period [sec]
72 scalar wr = twoPi/Tpi; // Current Freq [/sec]
74 // Current Phase for roll [rad]
76 scalar u = Tp_ + r*time;
77 scalar phr = twoPi*((Tp_/u - 1) + log(mag(u)) - log(Tp_))/r;
79 // Current Phase for Sway [rad]
80 scalar phs = phr + pi;
82 // Current Phase for Heave [rad]
83 scalar phh = phr + piByTwo;
85 scalar rollA = max(rollAmax_*exp(-sqr(Tpi - Tpn_)/(2*Q_)), rollAmin_);
90 swayA_*(sin(wr*time + phs) - sin(phs)),
91 heaveA_*(sin(wr*time + phh) - sin(phh))
93 quaternion R(rollA*sin(wr*time + phr), 0, 0);
94 septernion TR(septernion(CofG_ + T)*R*septernion(-CofG_));
96 Info<< "solidBodyMotionFunctions::SDA::transformation(): "
97 << "Time = " << time << " transformation: " << TR << endl;
103 bool Foam::solidBodyMotionFunctions::SDA::read(const dictionary& SBMFCoeffs)
105 solidBodyMotionFunction::read(SBMFCoeffs);
107 SBMFCoeffs_.lookup("CofG") >> CofG_;
108 SBMFCoeffs_.lookup("lamda") >> lamda_;
109 SBMFCoeffs_.lookup("rollAmax") >> rollAmax_;
110 SBMFCoeffs_.lookup("rollAmin") >> rollAmin_;
111 SBMFCoeffs_.lookup("heaveA") >> heaveA_;
112 SBMFCoeffs_.lookup("swayA") >> swayA_;
113 SBMFCoeffs_.lookup("Q") >> Q_;
114 SBMFCoeffs_.lookup("Tp") >> Tp_;
115 SBMFCoeffs_.lookup("Tpn") >> Tpn_;
116 SBMFCoeffs_.lookup("dTi") >> dTi_;
117 SBMFCoeffs_.lookup("dTp") >> dTp_;
119 // Rescale parameters according to the given scale parameter
120 if (lamda_ > 1 + SMALL)
125 Tpn_ /= sqrt(lamda_);
126 dTi_ /= sqrt(lamda_);
127 dTp_ /= sqrt(lamda_);
134 // ************************************************************************* //