SDA.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2011-2015 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(rollA*sin(wr*time + phr), 0, 0);
94  septernion TR(septernion(CofG_ + T)*R*septernion(-CofG_));
95 
96  Info<< "solidBodyMotionFunctions::SDA::transformation(): "
97  << "Time = " << time << " transformation: " << TR << endl;
98 
99  return TR;
100 }
101 
102 
104 {
105  solidBodyMotionFunction::read(SBMFCoeffs);
106 
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_;
118 
119  // Rescale parameters according to the given scale parameter
120  if (lamda_ > 1 + SMALL)
121  {
122  heaveA_ /= lamda_;
123  swayA_ /= lamda_;
124  Tp_ /= sqrt(lamda_);
125  Tpn_ /= sqrt(lamda_);
126  dTi_ /= sqrt(lamda_);
127  dTp_ /= sqrt(lamda_);
128  }
129 
130  return true;
131 }
132 
133 
134 // ************************************************************************* //
mathematicalConstants.H
Foam::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:68
Foam::septernion
Septernion class used to perform translations and rotations in 3D space.
Definition: septernion.H:64
Foam::addToRunTimeSelectionTable
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
Foam::sin
dimensionedScalar sin(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:255
Foam::read
bool read(const char *, int32_t &)
Definition: int32IO.C:87
SDA.H
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::exp
dimensionedScalar exp(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:252
Foam::constant::mathematical::twoPi
const scalar twoPi(2 *pi)
Foam::mag
dimensioned< scalar > mag(const dimensioned< Type > &)
Foam::solidBodyMotionFunctions::SDA::transformation
virtual septernion transformation() const
Return the solid-body motion transformation septernion.
Definition: SDA.C:67
Foam::quaternion
Quaternion class used to perform rotations in 3D space.
Definition: quaternion.H:60
Foam::constant::mathematical::piByTwo
const scalar piByTwo(0.5 *pi)
R
#define R(A, B, C, D, E, F, K, M)
Foam::Info
messageStream Info
Foam::T
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
Definition: FieldFieldFunctions.C:55
Foam::solidBodyMotionFunction
Base class for defining solid-body motions.
Definition: solidBodyMotionFunction.H:60
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam::log
dimensionedScalar log(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:253
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::solidBodyMotionFunction::read
virtual bool read(const dictionary &SBMFCoeffs)=0
Update properties from given dictionary.
Definition: solidBodyMotionFunction.C:65
Foam::solidBodyMotionFunctions::SDA::~SDA
virtual ~SDA()
Destructor.
Definition: SDA.C:61
Foam::max
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
Foam::sqr
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Definition: dimensionedSymmTensor.C:49
Foam::constant::mathematical
mathematical constants.
Foam::solidBodyMotionFunctions::SDA::SDA
SDA(const SDA &)
Disallow copy construct.
Foam::Vector< scalar >
Foam::sqrt
dimensionedScalar sqrt(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:142
Foam::constant::mathematical::pi
const scalar pi(M_PI)
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
Foam::solidBodyMotionFunctions::SDA::read
virtual bool read(const dictionary &SBMFCoeffs)
Update properties from given dictionary.
Definition: SDA.C:103