Motion constraints in sixDOFqODE
This commit is contained in:
parent
5e78a541c5
commit
4de19563e9
7 changed files with 138 additions and 11 deletions
|
@ -1,9 +1,9 @@
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
========= |
|
========= |
|
||||||
\\ / F ield | foam-extend: Open Source CFD
|
\\ / F ield | foam-extend: Open Source CFD
|
||||||
\\ / O peration | Version: 3.2
|
\\ / O peration |
|
||||||
\\ / A nd | Web: http://www.foam-extend.org
|
\\ / A nd | For copyright notice see file Copyright
|
||||||
\\/ M anipulation | For copyright notice see file Copyright
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of foam-extend.
|
This file is part of foam-extend.
|
||||||
|
@ -72,7 +72,7 @@ Foam::scalar Foam::finiteRotation::rotAngle(const tensor& rotT)
|
||||||
|
|
||||||
Foam::vector Foam::finiteRotation::eulerAngles(const tensor& rotT)
|
Foam::vector Foam::finiteRotation::eulerAngles(const tensor& rotT)
|
||||||
{
|
{
|
||||||
// Define a vector containing euler angles (x = roll, y = pitch, z = yaw)
|
// Create a vector containing euler angles (x = roll, y = pitch, z = yaw)
|
||||||
vector eulerAngles;
|
vector eulerAngles;
|
||||||
|
|
||||||
scalar& rollAngle = eulerAngles.x();
|
scalar& rollAngle = eulerAngles.x();
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
========= |
|
========= |
|
||||||
\\ / F ield | foam-extend: Open Source CFD
|
\\ / F ield | foam-extend: Open Source CFD
|
||||||
\\ / O peration | Version: 3.2
|
\\ / O peration |
|
||||||
\\ / A nd | Web: http://www.foam-extend.org
|
\\ / A nd | For copyright notice see file Copyright
|
||||||
\\/ M anipulation | For copyright notice see file Copyright
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of foam-extend.
|
This file is part of foam-extend.
|
||||||
|
@ -69,7 +69,7 @@ class finiteRotation
|
||||||
//- Calculate rotation angle from given rotation tensor
|
//- Calculate rotation angle from given rotation tensor
|
||||||
static scalar rotAngle(const tensor& rotT);
|
static scalar rotAngle(const tensor& rotT);
|
||||||
|
|
||||||
//- Calculate Euler angles (x-y-z (roll-pitch-yaw) convenction) from
|
//- Calculate Euler angles (x-y-z (roll-pitch-yaw) convention) from
|
||||||
// given rotation tensor. Reference: Mike Day, Insomniac Games,
|
// given rotation tensor. Reference: Mike Day, Insomniac Games,
|
||||||
// Extracting Euler Angles from a Rotation Matrix.
|
// Extracting Euler Angles from a Rotation Matrix.
|
||||||
static vector eulerAngles(const tensor& rotT);
|
static vector eulerAngles(const tensor& rotT);
|
||||||
|
|
|
@ -118,11 +118,14 @@ Foam::dimensionedVector Foam::sixDOFqODE::E
|
||||||
Foam::sixDOFqODE::sixDOFqODE(const IOobject& io)
|
Foam::sixDOFqODE::sixDOFqODE(const IOobject& io)
|
||||||
:
|
:
|
||||||
IOdictionary(io),
|
IOdictionary(io),
|
||||||
|
|
||||||
mass_(lookup("mass")),
|
mass_(lookup("mass")),
|
||||||
momentOfInertia_(lookup("momentOfInertia")),
|
momentOfInertia_(lookup("momentOfInertia")),
|
||||||
|
|
||||||
Xequilibrium_(lookup("equilibriumPosition")),
|
Xequilibrium_(lookup("equilibriumPosition")),
|
||||||
linSpringCoeffs_(lookup("linearSpring")),
|
linSpringCoeffs_(lookup("linearSpring")),
|
||||||
linDampingCoeffs_(lookup("linearDamping")),
|
linDampingCoeffs_(lookup("linearDamping")),
|
||||||
|
|
||||||
Xrel_(lookup("Xrel")),
|
Xrel_(lookup("Xrel")),
|
||||||
U_(lookup("U")),
|
U_(lookup("U")),
|
||||||
Uaverage_(U_),
|
Uaverage_(U_),
|
||||||
|
@ -134,11 +137,20 @@ Foam::sixDOFqODE::sixDOFqODE(const IOobject& io)
|
||||||
omega_(lookup("omega")),
|
omega_(lookup("omega")),
|
||||||
omegaAverage_(omega_),
|
omegaAverage_(omega_),
|
||||||
omegaAverageAbsolute_(omega_),
|
omegaAverageAbsolute_(omega_),
|
||||||
|
|
||||||
force_(lookup("force")),
|
force_(lookup("force")),
|
||||||
moment_(lookup("moment")),
|
moment_(lookup("moment")),
|
||||||
forceRelative_(lookup("forceRelative")),
|
forceRelative_(lookup("forceRelative")),
|
||||||
momentRelative_(lookup("momentRelative")),
|
momentRelative_(lookup("momentRelative")),
|
||||||
coeffs_(13, 0.0)
|
|
||||||
|
coeffs_(13, 0.0),
|
||||||
|
|
||||||
|
fixedSurge_(lookup("fixedSurge")),
|
||||||
|
fixedSway_(lookup("fixedSway")),
|
||||||
|
fixedHeave_(lookup("fixedHeave")),
|
||||||
|
fixedRoll_(lookup("fixedRoll")),
|
||||||
|
fixedPitch_(lookup("fixedPitch")),
|
||||||
|
fixedYaw_(lookup("fixedYaw"))
|
||||||
{
|
{
|
||||||
setCoeffs();
|
setCoeffs();
|
||||||
}
|
}
|
||||||
|
@ -163,11 +175,14 @@ Foam::sixDOFqODE::sixDOFqODE
|
||||||
IOobject::NO_WRITE
|
IOobject::NO_WRITE
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
|
|
||||||
mass_(sd.mass_.name(), sd.mass_),
|
mass_(sd.mass_.name(), sd.mass_),
|
||||||
momentOfInertia_(sd.momentOfInertia_.name(), sd.momentOfInertia_),
|
momentOfInertia_(sd.momentOfInertia_.name(), sd.momentOfInertia_),
|
||||||
|
|
||||||
Xequilibrium_(sd.Xequilibrium_.name(), sd.Xequilibrium_),
|
Xequilibrium_(sd.Xequilibrium_.name(), sd.Xequilibrium_),
|
||||||
linSpringCoeffs_(sd.linSpringCoeffs_.name(), sd.linSpringCoeffs_),
|
linSpringCoeffs_(sd.linSpringCoeffs_.name(), sd.linSpringCoeffs_),
|
||||||
linDampingCoeffs_(sd.linDampingCoeffs_.name(), sd.linDampingCoeffs_),
|
linDampingCoeffs_(sd.linDampingCoeffs_.name(), sd.linDampingCoeffs_),
|
||||||
|
|
||||||
Xrel_(sd.Xrel_.name(), sd.Xrel_),
|
Xrel_(sd.Xrel_.name(), sd.Xrel_),
|
||||||
U_(sd.U_.name(), sd.U_),
|
U_(sd.U_.name(), sd.U_),
|
||||||
Uaverage_(sd.Uaverage_.name(), sd.Uaverage_),
|
Uaverage_(sd.Uaverage_.name(), sd.Uaverage_),
|
||||||
|
@ -179,11 +194,20 @@ Foam::sixDOFqODE::sixDOFqODE
|
||||||
sd.omegaAverageAbsolute_.name(),
|
sd.omegaAverageAbsolute_.name(),
|
||||||
sd.omegaAverageAbsolute_
|
sd.omegaAverageAbsolute_
|
||||||
),
|
),
|
||||||
|
|
||||||
force_(sd.force_.name(), sd.force_),
|
force_(sd.force_.name(), sd.force_),
|
||||||
moment_(sd.moment_.name(), sd.moment_),
|
moment_(sd.moment_.name(), sd.moment_),
|
||||||
forceRelative_(sd.forceRelative_.name(), sd.forceRelative_),
|
forceRelative_(sd.forceRelative_.name(), sd.forceRelative_),
|
||||||
momentRelative_(sd.momentRelative_.name(), sd.momentRelative_),
|
momentRelative_(sd.momentRelative_.name(), sd.momentRelative_),
|
||||||
coeffs_(sd.coeffs_)
|
|
||||||
|
coeffs_(sd.coeffs_),
|
||||||
|
|
||||||
|
fixedSurge_(sd.fixedSurge_),
|
||||||
|
fixedSway_(sd.fixedSway_),
|
||||||
|
fixedHeave_(sd.fixedHeave_),
|
||||||
|
fixedRoll_(sd.fixedRoll_),
|
||||||
|
fixedPitch_(sd.fixedPitch_),
|
||||||
|
fixedYaw_(sd.fixedYaw_)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
@ -199,9 +223,11 @@ void Foam::sixDOFqODE::setState(const sixDOFqODE& sd)
|
||||||
{
|
{
|
||||||
mass_ = sd.mass_;
|
mass_ = sd.mass_;
|
||||||
momentOfInertia_ = sd.momentOfInertia_;
|
momentOfInertia_ = sd.momentOfInertia_;
|
||||||
|
|
||||||
Xequilibrium_ = sd.Xequilibrium_;
|
Xequilibrium_ = sd.Xequilibrium_;
|
||||||
linSpringCoeffs_ = sd.linSpringCoeffs_;
|
linSpringCoeffs_ = sd.linSpringCoeffs_;
|
||||||
linDampingCoeffs_ = sd.linDampingCoeffs_;
|
linDampingCoeffs_ = sd.linDampingCoeffs_;
|
||||||
|
|
||||||
Xrel_ = sd.Xrel_;
|
Xrel_ = sd.Xrel_;
|
||||||
U_ = sd.U_;
|
U_ = sd.U_;
|
||||||
Uaverage_ = sd.Uaverage_;
|
Uaverage_ = sd.Uaverage_;
|
||||||
|
@ -209,6 +235,7 @@ void Foam::sixDOFqODE::setState(const sixDOFqODE& sd)
|
||||||
omega_ = sd.omega_;
|
omega_ = sd.omega_;
|
||||||
omegaAverage_ = sd.omegaAverage_;
|
omegaAverage_ = sd.omegaAverage_;
|
||||||
omegaAverageAbsolute_ = sd.omegaAverageAbsolute_;
|
omegaAverageAbsolute_ = sd.omegaAverageAbsolute_;
|
||||||
|
|
||||||
force_ = sd.force_;
|
force_ = sd.force_;
|
||||||
moment_ = sd.moment_;
|
moment_ = sd.moment_;
|
||||||
forceRelative_ = sd.forceRelative_;
|
forceRelative_ = sd.forceRelative_;
|
||||||
|
@ -217,6 +244,13 @@ void Foam::sixDOFqODE::setState(const sixDOFqODE& sd)
|
||||||
// Copy ODE coefficients: this carries actual ODE state
|
// Copy ODE coefficients: this carries actual ODE state
|
||||||
// HJ, 23/Mar/2015
|
// HJ, 23/Mar/2015
|
||||||
coeffs_ = sd.coeffs_;
|
coeffs_ = sd.coeffs_;
|
||||||
|
|
||||||
|
fixedSurge_ = sd.fixedSurge_;
|
||||||
|
fixedSway_ = sd.fixedSway_;
|
||||||
|
fixedHeave_ = sd.fixedHeave_;
|
||||||
|
fixedRoll_ = sd.fixedRoll_;
|
||||||
|
fixedPitch_ = sd.fixedPitch_;
|
||||||
|
fixedYaw_ = sd.fixedYaw_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -248,6 +282,23 @@ void Foam::sixDOFqODE::derivatives
|
||||||
dydx[4] = accel.y();
|
dydx[4] = accel.y();
|
||||||
dydx[5] = accel.z();
|
dydx[5] = accel.z();
|
||||||
|
|
||||||
|
// Add translational constraints by setting RHS of given components to zero
|
||||||
|
if (fixedSurge_)
|
||||||
|
{
|
||||||
|
dydx[0] = 0; // Surge velocity
|
||||||
|
dydx[3] = 0; // Surge acceleration
|
||||||
|
}
|
||||||
|
if (fixedSway_)
|
||||||
|
{
|
||||||
|
dydx[1] = 0; // Sway velocity
|
||||||
|
dydx[4] = 0; // Sway acceleration
|
||||||
|
}
|
||||||
|
if (fixedHeave_)
|
||||||
|
{
|
||||||
|
dydx[2] = 0; // Heave velocity
|
||||||
|
dydx[5] = 0; // Heave acceleration
|
||||||
|
}
|
||||||
|
|
||||||
// Set the derivatives for rotation
|
// Set the derivatives for rotation
|
||||||
dimensionedVector curOmega
|
dimensionedVector curOmega
|
||||||
(
|
(
|
||||||
|
@ -266,6 +317,23 @@ void Foam::sixDOFqODE::derivatives
|
||||||
dydx[10] = curRotation.eDot(curOmega.value(), 1);
|
dydx[10] = curRotation.eDot(curOmega.value(), 1);
|
||||||
dydx[11] = curRotation.eDot(curOmega.value(), 2);
|
dydx[11] = curRotation.eDot(curOmega.value(), 2);
|
||||||
dydx[12] = curRotation.eDot(curOmega.value(), 3);
|
dydx[12] = curRotation.eDot(curOmega.value(), 3);
|
||||||
|
|
||||||
|
// Add rotational constraints by setting RHS of given components to zero
|
||||||
|
if (fixedRoll_)
|
||||||
|
{
|
||||||
|
dydx[6] = 0; // Roll angular acceleration
|
||||||
|
dydx[10] = 0; // Roll angular velocity (roll quaternion evolution RHS)
|
||||||
|
}
|
||||||
|
if (fixedPitch_)
|
||||||
|
{
|
||||||
|
dydx[7] = 0; // Pitch angular acceleration
|
||||||
|
dydx[11] = 0; // Pitch angular velocity (pitch quaternion evolution RHS)
|
||||||
|
}
|
||||||
|
if (fixedYaw_)
|
||||||
|
{
|
||||||
|
dydx[8] = 0; // Yaw angular acceleration
|
||||||
|
dydx[12] = 0; // Yaw angular velocity (yaw quaternion evolution RHS)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -367,6 +435,19 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const sixDOFqODE& sds)
|
||||||
os.writeKeyword("momentRelative") << tab << sds.momentRelative()
|
os.writeKeyword("momentRelative") << tab << sds.momentRelative()
|
||||||
<< token::END_STATEMENT << endl;
|
<< token::END_STATEMENT << endl;
|
||||||
|
|
||||||
|
os.writeKeyword("fixedSurge") << tab << sds.fixedSurge_ <<
|
||||||
|
token::END_STATEMENT << endl;
|
||||||
|
os.writeKeyword("fixedSway") << tab << sds.fixedSway_ <<
|
||||||
|
token::END_STATEMENT << endl;
|
||||||
|
os.writeKeyword("fixedHeave") << tab << sds.fixedHeave_ <<
|
||||||
|
token::END_STATEMENT << endl;
|
||||||
|
os.writeKeyword("fixedRoll") << tab << sds.fixedRoll_ <<
|
||||||
|
token::END_STATEMENT << endl;
|
||||||
|
os.writeKeyword("fixedPitch") << tab << sds.fixedPitch_ <<
|
||||||
|
token::END_STATEMENT << endl;
|
||||||
|
os.writeKeyword("fixedYaw") << tab << sds.fixedYaw_ <<
|
||||||
|
token::END_STATEMENT << endl;
|
||||||
|
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -131,6 +131,27 @@ class sixDOFqODE
|
||||||
scalarField coeffs_;
|
scalarField coeffs_;
|
||||||
|
|
||||||
|
|
||||||
|
//- Motion constraints (given as fixed motion components)
|
||||||
|
|
||||||
|
//- Fixed surge (x-translation)
|
||||||
|
Switch fixedSurge_;
|
||||||
|
|
||||||
|
//- Fixed sway (y-translation)
|
||||||
|
Switch fixedSway_;
|
||||||
|
|
||||||
|
//- Fixed heave (z-translation)
|
||||||
|
Switch fixedHeave_;
|
||||||
|
|
||||||
|
//- Fixed roll (rotation around x)
|
||||||
|
Switch fixedRoll_;
|
||||||
|
|
||||||
|
//- Fixed pitch (rotation around y)
|
||||||
|
Switch fixedPitch_;
|
||||||
|
|
||||||
|
//- Fixed yaw (rotation around z)
|
||||||
|
Switch fixedYaw_;
|
||||||
|
|
||||||
|
|
||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
//- Disallow default bitwise copy construct
|
//- Disallow default bitwise copy construct
|
||||||
|
|
|
@ -36,4 +36,12 @@ moment m [1 2 -2 0 0 0 0] (0 0 0);
|
||||||
forceRelative fRel [1 1 -2 0 0 0 0] (0 0 0);
|
forceRelative fRel [1 1 -2 0 0 0 0] (0 0 0);
|
||||||
momentRelative mRel [1 2 -2 0 0 0 0] (-0.5773502692 -0.5773502692 -0.5773502692);
|
momentRelative mRel [1 2 -2 0 0 0 0] (-0.5773502692 -0.5773502692 -0.5773502692);
|
||||||
|
|
||||||
|
// Motion constraints
|
||||||
|
fixedSurge no;
|
||||||
|
fixedSway no;
|
||||||
|
fixedHeave no;
|
||||||
|
fixedRoll no;
|
||||||
|
fixedPitch no;
|
||||||
|
fixedYaw no;
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|
|
@ -35,4 +35,12 @@ moment m [1 2 -2 0 0 0 0] (0 0 0);
|
||||||
forceRelative fRel [1 1 -2 0 0 0 0] (0 0 0);
|
forceRelative fRel [1 1 -2 0 0 0 0] (0 0 0);
|
||||||
momentRelative mRel [1 2 -2 0 0 0 0] (0 0 10);
|
momentRelative mRel [1 2 -2 0 0 0 0] (0 0 10);
|
||||||
|
|
||||||
|
// Motion constraints
|
||||||
|
fixedSurge no;
|
||||||
|
fixedSway no;
|
||||||
|
fixedHeave no;
|
||||||
|
fixedRoll no;
|
||||||
|
fixedPitch no;
|
||||||
|
fixedYaw no;
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|
|
@ -35,4 +35,13 @@ moment m [1 2 -2 0 0 0 0] (0 0 0);
|
||||||
forceRelative fRel [1 1 -2 0 0 0 0] (0 0 0);
|
forceRelative fRel [1 1 -2 0 0 0 0] (0 0 0);
|
||||||
momentRelative mRel [1 2 -2 0 0 0 0] (0 0 0);
|
momentRelative mRel [1 2 -2 0 0 0 0] (0 0 0);
|
||||||
|
|
||||||
|
|
||||||
|
// Motion constraints
|
||||||
|
fixedSurge no;
|
||||||
|
fixedSway no;
|
||||||
|
fixedHeave no;
|
||||||
|
fixedRoll no;
|
||||||
|
fixedPitch no;
|
||||||
|
fixedYaw no;
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|
Reference in a new issue