Hotfix: traslation bug fixes

This commit is contained in:
Hrvoje Jasak 2016-03-18 11:41:22 +00:00
parent 4ce6afa3b5
commit 77225f292d

View file

@ -48,24 +48,24 @@ namespace solidBodyMotionFunctions
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
Foam::scalar Foam::solidBodyMotionFunctions::translation::rampFactor() const Foam::scalar
Foam::solidBodyMotionFunctions::translation::rampFactor() const
{ {
if (rampTime_ > 0) const scalar t = time_.value();
{
// Calculate ramp-up factor
const scalar t = time_.value();
return sin(2*pi/(4*rampTime_)*Foam::min(rampTime_, t)); if (t < rampTime_)
{
// Ramping region
return sin(pi/(2*rampTime_)*t);
} }
else else
{ {
// Past ramping region
return 1; return 1;
} }
} }
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::solidBodyMotionFunctions::translation::translation Foam::solidBodyMotionFunctions::translation::translation
@ -77,7 +77,17 @@ Foam::solidBodyMotionFunctions::translation::translation
solidBodyMotionFunction(SBMFCoeffs, runTime), solidBodyMotionFunction(SBMFCoeffs, runTime),
velocity_(SBMFCoeffs_.lookup("velocity")), velocity_(SBMFCoeffs_.lookup("velocity")),
rampTime_(readScalar(SBMFCoeffs_.lookup("rampTime"))) rampTime_(readScalar(SBMFCoeffs_.lookup("rampTime")))
{} {
if (rampTime_ < 0)
{
FatalIOErrorIn
(
"solidBodyMotionFunctions::translation::translation",
SBMFCoeffs_
) << "Negative rampTime not allowed."
<< abort(FatalIOError);
}
}
// * * * * * * * * * * * * * * * * Destructors * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructors * * * * * * * * * * * * * * * //
@ -91,12 +101,39 @@ Foam::solidBodyMotionFunctions::translation::~translation()
Foam::septernion Foam::septernion
Foam::solidBodyMotionFunctions::translation::transformation() const Foam::solidBodyMotionFunctions::translation::transformation() const
{ {
scalar time = time_.value(); const scalar t = time_.value();
septernion TR(rampFactor()*velocity_*time, quaternion::I); septernion TR;
if (t < rampTime_)
{
// Ramping region
// Account for ramping using analytical integration from ramped velocity
// distribution in this region
TR = septernion
(
velocity_*2*rampTime_/pi*(1 - cos(pi/(2*rampTime_)*t)),
quaternion::I
);
}
else
{
// Past ramping region
TR = septernion
(
velocity_*
(
// Displacement during the ramping region
2*rampTime_/pi
// Displacement during constant velocity after ramping region
+ (t - rampTime_)
),
quaternion::I
);
}
Info<< "solidBodyMotionFunctions::translation::transformation(): " Info<< "solidBodyMotionFunctions::translation::transformation(): "
<< "Time = " << time << " velocity = " << rampFactor()*velocity_ << "Time = " << t << " velocity = " << rampFactor()*velocity_
<< " transformation = " << TR << " transformation = " << TR
<< endl; << endl;
@ -107,12 +144,14 @@ Foam::solidBodyMotionFunctions::translation::transformation() const
Foam::septernion Foam::septernion
Foam::solidBodyMotionFunctions::translation::velocity() const Foam::solidBodyMotionFunctions::translation::velocity() const
{ {
scalar time = time_.value(); septernion TV
(
septernion TV(rampFactor()*velocity_, quaternion::zero); rampFactor()*velocity_,
quaternion::I/time_.deltaT().value()
);
Info<< "solidBodyMotionFunctions::translation::transformation(): " Info<< "solidBodyMotionFunctions::translation::transformation(): "
<< "Time = " << time << " velocity: " << TV << endl; << "Time = " << time_.value() << " velocity: " << TV << endl;
return TV; return TV;
} }