SDA.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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
19  for more details.
20 
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/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "SDA.H"
28 #include "mathematicalConstants.H"
29 
30 using namespace Foam::constant::mathematical;
31 
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36 namespace solidBodyMotionFunctions
37 {
38  defineTypeNameAndDebug(SDA, 0);
39  addToRunTimeSelectionTable(solidBodyMotionFunction, SDA, dictionary);
40 }
41 }
42 
43 
44 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
45 
47 (
48  const dictionary& SBMFCoeffs,
49  const Time& runTime
50 )
51 :
52  solidBodyMotionFunction(SBMFCoeffs, runTime),
53  CofG_(SBMFCoeffs_.lookup("CofG"))
54 {
55  read(SBMFCoeffs);
56 }
57 
58 
59 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
60 
62 {}
63 
64 
65 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
66 
68 {
69  scalar time = time_.value();
70 
71  scalar Tpi = Tp_ + dTp_*(time/dTi_); // Current roll period [sec]
72  scalar wr = twoPi/Tpi; // Current Freq [/sec]
73 
74  // Current Phase for roll [rad]
75  scalar r = dTp_/dTi_;
76  scalar u = Tp_ + r*time;
77  scalar phr = twoPi*((Tp_/u - 1) + log(mag(u)) - log(Tp_))/r;
78 
79  // Current Phase for Sway [rad]
80  scalar phs = phr + pi;
81 
82  // Current Phase for Heave [rad]
83  scalar phh = phr + piByTwo;
84 
85  scalar rollA = max(rollAmax_*exp(-sqr(Tpi - Tpn_)/(2*Q_)), rollAmin_);
86 
87  vector T
88  (
89  0,
90  swayA_*(sin(wr*time + phs) - sin(phs)),
91  heaveA_*(sin(wr*time + phh) - sin(phh))
92  );
93  quaternion R(quaternion::XYZ, vector(rollA*sin(wr*time + phr), 0, 0));
94  septernion TR(septernion(-CofG_ - T)*R*septernion(CofG_));
95 
96  DebugInFunction << "Time = " << time << " transformation: " << TR << endl;
97 
98  return TR;
99 }
100 
101 
103 {
104  solidBodyMotionFunction::read(SBMFCoeffs);
105 
106  SBMFCoeffs_.lookup("CofG") >> CofG_;
107  SBMFCoeffs_.lookup("lamda") >> lamda_;
108  SBMFCoeffs_.lookup("rollAmax") >> rollAmax_;
109  SBMFCoeffs_.lookup("rollAmin") >> rollAmin_;
110  SBMFCoeffs_.lookup("heaveA") >> heaveA_;
111  SBMFCoeffs_.lookup("swayA") >> swayA_;
112  SBMFCoeffs_.lookup("Q") >> Q_;
113  SBMFCoeffs_.lookup("Tp") >> Tp_;
114  SBMFCoeffs_.lookup("Tpn") >> Tpn_;
115  SBMFCoeffs_.lookup("dTi") >> dTi_;
116  SBMFCoeffs_.lookup("dTp") >> dTp_;
117 
118  // Rescale parameters according to the given scale parameter
119  if (lamda_ > 1 + small)
120  {
121  heaveA_ /= lamda_;
122  swayA_ /= lamda_;
123  Tp_ /= sqrt(lamda_);
124  Tpn_ /= sqrt(lamda_);
125  dTi_ /= sqrt(lamda_);
126  dTp_ /= sqrt(lamda_);
127  }
128 
129  return true;
130 }
131 
132 
133 // ************************************************************************* //
dimensionedScalar log(const dimensionedScalar &ds)
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
virtual ~SDA()
Destructor.
Definition: SDA.C:61
dimensionedSymmTensor sqr(const dimensionedVector &dv)
dimensionedScalar sqrt(const dimensionedScalar &ds)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Vector< scalar > vector
A scalar version of the templated Vector.
Definition: vector.H:49
Septernion class used to perform translations and rotations in 3D space.
Definition: septernion.H:65
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:68
Macros for easy insertion into run-time selection tables.
bool read(const char *, int32_t &)
Definition: int32IO.C:85
dimensionedScalar exp(const dimensionedScalar &ds)
Base class for defining solid-body motions.
mathematical constants.
#define DebugInFunction
Report an information message using Foam::Info.
virtual bool read(const dictionary &SBMFCoeffs)
Update properties from given dictionary.
Definition: SDA.C:102
virtual bool read(const dictionary &SBMFCoeffs)=0
Update properties from given dictionary.
Quaternion class used to perform rotations in 3D space.
Definition: quaternion.H:60
const scalar twoPi(2 *pi)
dimensionedScalar sin(const dimensionedScalar &ds)
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
defineTypeNameAndDebug(combustionModel, 0)
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
SDA(const dictionary &SBMFCoeffs, const Time &runTime)
Construct from components.
Definition: SDA.C:47
#define R(A, B, C, D, E, F, K, M)
virtual septernion transformation() const
Return the solid-body motion transformation septernion.
Definition: SDA.C:67
dimensioned< scalar > mag(const dimensioned< Type > &)
const scalar piByTwo(0.5 *pi)
Namespace for OpenFOAM.