1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend 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 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "translation.H"
27 #include "addToRunTimeSelectionTable.H"
28 #include "mathematicalConstants.H"
30 using namespace Foam::mathematicalConstant;
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
36 namespace solidBodyMotionFunctions
38 defineTypeNameAndDebug(translation, 0);
39 addToRunTimeSelectionTable
41 solidBodyMotionFunction,
49 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
52 Foam::solidBodyMotionFunctions::translation::rampFactor() const
54 const scalar t = time_.value();
59 return sin(pi/(2*rampTime_)*t);
63 // Past ramping region
69 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
71 Foam::solidBodyMotionFunctions::translation::translation
73 const dictionary& SBMFCoeffs,
77 solidBodyMotionFunction(SBMFCoeffs, runTime),
78 velocity_(SBMFCoeffs_.lookup("velocity")),
79 rampTime_(readScalar(SBMFCoeffs_.lookup("rampTime")))
85 "solidBodyMotionFunctions::translation::translation",
87 ) << "Negative rampTime not allowed."
88 << abort(FatalIOError);
93 // * * * * * * * * * * * * * * * * Destructors * * * * * * * * * * * * * * * //
95 Foam::solidBodyMotionFunctions::translation::~translation()
99 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
102 Foam::solidBodyMotionFunctions::translation::transformation() const
104 const scalar t = time_.value();
111 // Account for ramping using analytical integration from ramped velocity
112 // distribution in this region
115 velocity_*2*rampTime_/pi*(1 - cos(pi/(2*rampTime_)*t)),
121 // Past ramping region
126 // Displacement during the ramping region
128 // Displacement during constant velocity after ramping region
135 Info<< "solidBodyMotionFunctions::translation::transformation(): "
136 << "Time = " << t << " velocity = " << rampFactor()*velocity_
137 << " transformation = " << TR
145 Foam::solidBodyMotionFunctions::translation::velocity() const
149 rampFactor()*velocity_,
150 quaternion::I/time_.deltaT().value()
153 Info<< "solidBodyMotionFunctions::translation::transformation(): "
154 << "Time = " << time_.value() << " velocity: " << TV << endl;
160 bool Foam::solidBodyMotionFunctions::translation::read
162 const dictionary& SBMFCoeffs
165 solidBodyMotionFunction::read(SBMFCoeffs);
167 rampTime_ = readScalar(SBMFCoeffs_.lookup("rampTime"));
173 // ************************************************************************* //