Rotating motion. Inno Gatin
This commit is contained in:
parent
03b0fe773b
commit
fc987f2576
3 changed files with 246 additions and 0 deletions
|
@ -3,6 +3,7 @@ solidBodyMotionFunction/newSolidBodyMotionFunction.C
|
|||
|
||||
translation/translation.C
|
||||
linearOscillation/linearOscillation.C
|
||||
rotatingOscillation/rotatingOscillation.C
|
||||
SDA/SDA.C
|
||||
SKA/SKA.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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#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;
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
|
@ -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<solidBodyMotionFunction> clone() const
|
||||
{
|
||||
return autoPtr<solidBodyMotionFunction>
|
||||
(
|
||||
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
|
||||
|
||||
// ************************************************************************* //
|
Reference in a new issue