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 "linearOscillation.H"
27 #include "addToRunTimeSelectionTable.H"
28 #include "mathematicalConstants.H"
30 using namespace Foam::mathematicalConstant;
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
36 namespace solidBodyMotionFunctions
38 defineTypeNameAndDebug(linearOscillation, 0);
39 addToRunTimeSelectionTable
41 solidBodyMotionFunction,
49 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
52 Foam::solidBodyMotionFunctions::linearOscillation::calcPosition
57 return amplitude_*sin(2*pi*t/period_);
61 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
63 Foam::solidBodyMotionFunctions::linearOscillation::linearOscillation
65 const dictionary& SBMFCoeffs,
69 solidBodyMotionFunction(SBMFCoeffs, runTime),
70 amplitude_(SBMFCoeffs_.lookup("amplitude")),
71 period_(readScalar(SBMFCoeffs_.lookup("period")))
75 // * * * * * * * * * * * * * * * * Destructors * * * * * * * * * * * * * * * //
77 Foam::solidBodyMotionFunctions::linearOscillation::~linearOscillation()
81 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
84 Foam::solidBodyMotionFunctions::linearOscillation::transformation() const
86 scalar t = time_.value();
88 septernion TR(calcPosition(t), quaternion::I);
90 Info<< "solidBodyMotionFunctions::linearOscillation::transformation(): "
91 << "Time = " << t << " transformation: " << TR << endl;
98 Foam::solidBodyMotionFunctions::linearOscillation::velocity() const
100 scalar t = time_.value();
101 scalar dt = time_.deltaT().value();
105 (calcPosition(t) - calcPosition(t - dt))/dt,
113 bool Foam::solidBodyMotionFunctions::linearOscillation::read
115 const dictionary& SBMFCoeffs
118 solidBodyMotionFunction::read(SBMFCoeffs);
120 SBMFCoeffs_.lookup("amplitude") >> amplitude_;
121 SBMFCoeffs_.lookup("amplitude") >> period_;
127 // ************************************************************************* //