From fc987f25762968c1dfcb6885569e2d10f86db398 Mon Sep 17 00:00:00 2001 From: Hrvoje Jasak Date: Wed, 25 Nov 2015 02:44:15 +0000 Subject: [PATCH] Rotating motion. Inno Gatin --- .../meshMotion/solidBodyMotion/Make/files | 1 + .../rotatingOscillation/rotatingOscillation.C | 140 ++++++++++++++++++ .../rotatingOscillation/rotatingOscillation.H | 105 +++++++++++++ 3 files changed, 246 insertions(+) create mode 100644 src/dynamicMesh/meshMotion/solidBodyMotion/rotatingOscillation/rotatingOscillation.C create mode 100644 src/dynamicMesh/meshMotion/solidBodyMotion/rotatingOscillation/rotatingOscillation.H diff --git a/src/dynamicMesh/meshMotion/solidBodyMotion/Make/files b/src/dynamicMesh/meshMotion/solidBodyMotion/Make/files index 2dedc285e..2d8de31b9 100644 --- a/src/dynamicMesh/meshMotion/solidBodyMotion/Make/files +++ b/src/dynamicMesh/meshMotion/solidBodyMotion/Make/files @@ -3,6 +3,7 @@ solidBodyMotionFunction/newSolidBodyMotionFunction.C translation/translation.C linearOscillation/linearOscillation.C +rotatingOscillation/rotatingOscillation.C SDA/SDA.C SKA/SKA.C diff --git a/src/dynamicMesh/meshMotion/solidBodyMotion/rotatingOscillation/rotatingOscillation.C b/src/dynamicMesh/meshMotion/solidBodyMotion/rotatingOscillation/rotatingOscillation.C new file mode 100644 index 000000000..f221dd2a3 --- /dev/null +++ b/src/dynamicMesh/meshMotion/solidBodyMotion/rotatingOscillation/rotatingOscillation.C @@ -0,0 +1,140 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "rotatingOscillation.H" +#include "addToRunTimeSelectionTable.H" +#include "mathematicalConstants.H" + +using namespace Foam::mathematicalConstant; + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ +namespace solidBodyMotionFunctions +{ + defineTypeNameAndDebug(rotatingOscillation, 0); + addToRunTimeSelectionTable + ( + solidBodyMotionFunction, + rotatingOscillation, + dictionary + ); +} +} + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +Foam::vector +Foam::solidBodyMotionFunctions::rotatingOscillation::calcPosition +( + const scalar t +) const +{ + return amplitude_*sin(2*pi*t/period_); +} + + +Foam::septernion +Foam::solidBodyMotionFunctions::rotatingOscillation::calcTransformation +( + const scalar t +) const +{ + vector eulerAngles = amplitude_*sin(2*pi*t/period_); + + // Convert the rotational motion from deg to rad + eulerAngles *= pi/180.0; + + const quaternion R(eulerAngles.x(), eulerAngles.y(), eulerAngles.z()); + const septernion TR(septernion(origin_)*R*septernion(-origin_)); + + return TR; +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::solidBodyMotionFunctions::rotatingOscillation:: +rotatingOscillation +( + const dictionary& SBMFCoeffs, + const Time& runTime +) +: + solidBodyMotionFunction(SBMFCoeffs, runTime) +{ + read(SBMFCoeffs); +} + + +// * * * * * * * * * * * * * * * * Destructors * * * * * * * * * * * * * * * // + +Foam::solidBodyMotionFunctions::rotatingOscillation:: +~rotatingOscillation() +{} + + +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + +Foam::septernion +Foam::solidBodyMotionFunctions::rotatingOscillation:: +transformation() const +{ + scalar t = time_.value(); + + const septernion TR = calcTransformation(t); + + Info<< "solidBodyMotionFunctions::rotatingOscillation::" + << "transformation(): " + << "Time = " << t << " transformation: " << TR << endl; + + return TR; +} + +Foam::septernion +Foam::solidBodyMotionFunctions::rotatingOscillation::velocity() const +{ + scalar t = time_.value(); + scalar dt = time_.deltaT().value(); + + return (calcTransformation(t + dt) - calcTransformation(t))/dt; +} + +bool Foam::solidBodyMotionFunctions::rotatingOscillation::read +( + const dictionary& SBMFCoeffs +) +{ + solidBodyMotionFunction::read(SBMFCoeffs); + + SBMFCoeffs_.lookup("origin") >> origin_; + SBMFCoeffs_.lookup("amplitude") >> amplitude_; + SBMFCoeffs_.lookup("period") >> period_; + + return true; +} + +// ************************************************************************* // diff --git a/src/dynamicMesh/meshMotion/solidBodyMotion/rotatingOscillation/rotatingOscillation.H b/src/dynamicMesh/meshMotion/solidBodyMotion/rotatingOscillation/rotatingOscillation.H new file mode 100644 index 000000000..80ac1c932 --- /dev/null +++ b/src/dynamicMesh/meshMotion/solidBodyMotion/rotatingOscillation/rotatingOscillation.H @@ -0,0 +1,105 @@ +#ifndef rotatingOscillation_H +#define rotatingOscillation_H + +#include "solidBodyMotionFunction.H" +#include "primitiveFields.H" +#include "point.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace solidBodyMotionFunctions +{ + +/*---------------------------------------------------------------------------*\ + Class rotatingOscillation Declaration +\*---------------------------------------------------------------------------*/ + +class rotatingOscillation +: + public solidBodyMotionFunction +{ + // Private data + + //- Centre of gravity + point origin_; + + //- Amplitude + vector amplitude_; + + //- Motion period + scalar period_; + + + // Private Member Functions + + //- Disallow copy construct + rotatingOscillation(const rotatingOscillation&); + + //- Disallow default bitwise assignment + void operator=(const rotatingOscillation&); + + //- Calculate position + vector calcPosition(const scalar t) const; + + //- Calculate tranformation + septernion calcTransformation(const scalar t) const; + + +public: + + //- Runtime type information + TypeName("rotatingOscillation"); + + + // Constructors + + //- Construct from components + rotatingOscillation + ( + const dictionary& SBMFCoeffs, + const Time& runTime + ); + + /* //- Construct and return a clone + virtual autoPtr clone() const + { + return autoPtr + ( + new rotatingOscillation + ( + SBMFCoeffs_, + time_ + ) + ); + } +*/ + + //- Destructor + virtual ~rotatingOscillation(); + + + // Member Functions + + //- Return the solid-body motion transformation septernion + virtual septernion transformation() const; + + //- Return the solid-body motion velocity + virtual septernion velocity() const; + + //- Update properties from given dictionary + virtual bool read(const dictionary& SBMFCoeffs); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace solidBodyMotionFunctions +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* //