Solid body motion bug fixes. Author: Hrvoje Jasak. Merge: Hrvoje Jasak.

This commit is contained in:
Hrvoje Jasak 2016-03-18 11:33:10 +00:00
commit 0461f02d9b
5 changed files with 223 additions and 27 deletions

View file

@ -82,7 +82,9 @@ Foam::vector Foam::finiteRotation::eulerAngles(const tensor& rotT)
// Calculate roll angle
rollAngle = atan2(rotT.yz(), rotT.zz());
const scalar c2 = sqrt(rotT.xx() + rotT.xy());
// Use mag to avoid negative value due to round-off
// HJ, 24/Feb/2016
const scalar c2 = sqrt(Foam::max(0, rotT.xx() + rotT.xy()));
// Calculate pitch angle
pitchAngle = atan2(-rotT.xz(), c2);

View file

@ -145,23 +145,21 @@ void Foam::sixDOFqODE::constrainRotation(vector& vec) const
consVec.z() = 0;
}
consVec = referentRotation_.invR() & consVec;
vec = referentRotation_.invR() & consVec;
}
else
{
consVec = vec;
if (fixedRoll_)
{
consVec.x() = 0;
vec.x() = 0;
}
if (fixedPitch_)
{
consVec.y() = 0;
vec.y() = 0;
}
if (fixedYaw_)
{
consVec.z() = 0;
vec.z() = 0;
}
}
}
@ -189,23 +187,21 @@ void Foam::sixDOFqODE::constrainTranslation(vector& vec) const
consVec.z() = 0;
}
consVec = referentRotation_.invR() & consVec;
vec = referentRotation_.invR() & consVec;
}
else
{
consVec = vec;
if (fixedSurge_)
{
consVec.x() = 0;
vec.x() = 0;
}
if (fixedSway_)
{
consVec.y() = 0;
vec.y() = 0;
}
if (fixedHeave_)
{
consVec.z() = 0;
vec.z() = 0;
}
}
}
@ -447,20 +443,19 @@ void Foam::sixDOFqODE::derivatives
dydx[11] = curRotation.eDot(curOmega.value(), 2);
dydx[12] = curRotation.eDot(curOmega.value(), 3);
// // Add rotational constraints by setting RHS of given components to zero
// if (fixedRoll_)
// {
// dydx[10] = 0; // Roll axis (roll quaternion evolution RHS)
// }
// if (fixedPitch_)
// {
// dydx[11] = 0; // Pitch axis (pitch quaternion evolution RHS)
// }
// if (fixedYaw_)
// {
// dydx[12] = 0; // Yaw axis (yaw quaternion evolution RHS)
// }
// Add rotational constraints by setting RHS of given components to zero
if (fixedRoll_)
{
dydx[10] = 0; // Roll axis (roll quaternion evolution RHS)
}
if (fixedPitch_)
{
dydx[11] = 0; // Pitch axis (pitch quaternion evolution RHS)
}
if (fixedYaw_)
{
dydx[12] = 0; // Yaw axis (yaw quaternion evolution RHS)
}
}

View file

@ -1,6 +1,7 @@
solidBodyMotionFunction/solidBodyMotionFunction.C
solidBodyMotionFunction/newSolidBodyMotionFunction.C
noMotion/noMotion.C
translation/translation.C
graphMotion/graphMotion.C

View file

@ -0,0 +1,91 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration | Version: 3.2
\\ / A nd | Web: http://www.foam-extend.org
\\/ M anipulation | For copyright notice see file Copyright
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend 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.
foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "noMotion.H"
#include "addToRunTimeSelectionTable.H"
#include "mathematicalConstants.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace solidBodyMotionFunctions
{
defineTypeNameAndDebug(noMotion, 0);
addToRunTimeSelectionTable
(
solidBodyMotionFunction,
noMotion,
dictionary
);
};
};
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::solidBodyMotionFunctions::noMotion::noMotion
(
const dictionary& SBMFCoeffs,
const Time& runTime
)
:
solidBodyMotionFunction(SBMFCoeffs, runTime)
{}
// * * * * * * * * * * * * * * * * Destructors * * * * * * * * * * * * * * * //
Foam::solidBodyMotionFunctions::noMotion::~noMotion()
{}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
Foam::septernion
Foam::solidBodyMotionFunctions::noMotion::transformation() const
{
return septernion(vector::zero, quaternion::I);
}
Foam::septernion
Foam::solidBodyMotionFunctions::noMotion::velocity() const
{
return septernion(vector::zero, quaternion::I)/time_.deltaT().value();
}
bool Foam::solidBodyMotionFunctions::noMotion::read
(
const dictionary& SBMFCoeffs
)
{
solidBodyMotionFunction::read(SBMFCoeffs);
return true;
}
// ************************************************************************* //

View file

@ -0,0 +1,107 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration | Version: 3.2
\\ / A nd | Web: http://www.foam-extend.org
\\/ M anipulation | For copyright notice see file Copyright
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend 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.
foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::solidBodyMotionFunctions::noMotion
Description
No motion
SourceFiles
noMotion.C
\*---------------------------------------------------------------------------*/
#ifndef noMotion_H
#define noMotion_H
#include "solidBodyMotionFunction.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace solidBodyMotionFunctions
{
/*---------------------------------------------------------------------------*\
Class noMotion Declaration
\*---------------------------------------------------------------------------*/
class noMotion
:
public solidBodyMotionFunction
{
// Private Member Functions
//- Disallow copy construct
noMotion(const noMotion&);
//- Disallow default bitwise assignment
void operator=(const noMotion&);
public:
//- Runtime type information
TypeName("noMotion");
// Constructors
//- Construct from components
noMotion
(
const dictionary& SBMFCoeffs,
const Time& runTime
);
// Destructor
virtual ~noMotion();
// 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
// ************************************************************************* //