Finalised the use of translationa/rotational restraints in sixDOFODE classes

This commit is contained in:
Vuko Vukcevic 2017-03-10 11:20:42 +01:00 committed by Hrvoje Jasak
parent c63d6b76a8
commit 704829a15e
9 changed files with 318 additions and 57 deletions

View file

@ -23,6 +23,7 @@ $(sixDOF)/sixDOFODE/constraints/translationalConstraints/constantTranslationalAc
$(sixDOF)/sixDOFODE/constraints/translationalConstraints/periodicOscillation/periodicOscillation.C
$(sixDOF)/sixDOFODE/restraints/translationalRestraints/translationalRestraint/translationalRestraint.C
$(sixDOF)/sixDOFODE/restraints/translationalRestraints/linearSpringDamper/linearSpringDamper.C
$(sixDOF)/sixDOFODE/restraints/rotationalRestraints/rotationalRestraint/rotationalRestraint.C
$(sixDOF)/sixDOFODE/sixDOFODE.C

View file

@ -73,13 +73,17 @@ Foam::dimensionedVector Foam::geometricSixDOF::A
scalarSquareMatrix M(rhs.size(), 0.0);
// Insert mass and explicit forcing into the system. Note: translations are
// solved in the global coordinate system
const dimensionedVector explicitForcing
(
force(t) // External force
- (linSpringCoeffs() & xR) // Spring force
- (linDampingCoeffs() & uR) // Damping force
);
// solved in the global coordinate system and the explicit forcing contains
// restraining forces
const dimensionedVector explicitForcing =
force
(
t,
R.T(),
xR.value(),
uR.value()
);
const vector& efVal = explicitForcing.value();
const scalar& m = mass().value();
@ -155,7 +159,15 @@ Foam::dimensionedVector Foam::geometricSixDOF::OmegaDot
const dimensionedVector explicitForcing
(
E(omega) // Euler part
+ (RT & moment(t)) // External torque
+ (
RT
& moment
(
t,
RT.value(),
omega.value()
)
) // External torque with restraints
);
const vector& efVal = explicitForcing.value();
const diagTensor& I = momentOfInertia().value();

View file

@ -57,13 +57,17 @@ Foam::dimensionedVector Foam::quaternionSixDOF::A
scalarSquareMatrix M(rhs.size(), 0.0);
// Insert mass and explicit forcing into the system. Note: translations are
// solved in the global coordinate system
const dimensionedVector explicitForcing
(
force(t) // External force
- (linSpringCoeffs() & xR) // Spring force
- (linDampingCoeffs() & uR) // Damping force
);
// solved in the global coordinate system and the explicit forcing contains
// restraining forces
const dimensionedVector explicitForcing =
force
(
t,
rotation.R(),
xR.value(),
uR.value()
);
const vector& efVal = explicitForcing.value();
const scalar& m = mass().value();
@ -147,7 +151,15 @@ Foam::dimensionedVector Foam::quaternionSixDOF::OmegaDot
const dimensionedVector explicitForcing
(
E(omega) // Euler part
+ (R & moment(t)) // External torque
+ (
R.value()
& moment
(
t,
R.value(),
omega.value()
)
) // External torque with restraints
);
const vector& efVal = explicitForcing.value();
const diagTensor& I = momentOfInertia().value();

View file

@ -137,7 +137,7 @@ public:
// Restraint specific functions
//- Return restraining force (in the local coordinate system)
//- Return restraining moment (in the local coordinate system)
virtual vector restrainingMoment
(
const scalar t,

View file

@ -0,0 +1,98 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration | Version: 4.0
\\ / 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 "linearSpringDamper.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(linearSpringDamper, 0);
addToRunTimeSelectionTable
(
translationalRestraint,
linearSpringDamper,
word
);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::linearSpringDamper::linearSpringDamper
(
const word& name,
const dictionary& dict
)
:
translationalRestraint(name, dict),
linSpringCoeffs_(dict.lookup("linearSpring")),
linDampingCoeffs_(dict.lookup("linearDamping"))
{}
Foam::autoPtr<Foam::translationalRestraint>
Foam::linearSpringDamper::clone() const
{
return autoPtr<translationalRestraint>
(
new linearSpringDamper(*this)
);
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::linearSpringDamper::~linearSpringDamper()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::vector Foam::linearSpringDamper::restrainingForce
(
const scalar,
const tensor&,
const vector& x,
const vector& u
) const
{
return - (linSpringCoeffs_ & x) - (linDampingCoeffs_ & u);
}
void Foam::linearSpringDamper::write(Ostream& os) const
{
os.writeKeyword("type") << tab << type()
<< token::END_STATEMENT << nl << nl;
os.writeKeyword("linearSpring") << tab << linSpringCoeffs_
<< token::END_STATEMENT << nl;
os.writeKeyword("linearDamping") << tab << linDampingCoeffs_
<< token::END_STATEMENT << endl;
}
// ************************************************************************* //

View file

@ -0,0 +1,119 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration | Version: 4.0
\\ / 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::linearSpringDamper
Description
Translational restraint corresponding to linear spring and linear damper
defined by linear spring coefficients and linear damping coefficients.
Author
Vuko Vukcevic, FSB Zagreb. All rights reserved.
SourceFiles
linearSpringDamper.C
\*---------------------------------------------------------------------------*/
#ifndef linearSpringDamper_H
#define linearSpringDamper_H
#include "translationalRestraint.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class linearSpringDamper Declaration
\*---------------------------------------------------------------------------*/
class linearSpringDamper
:
public translationalRestraint
{
// Private Data
//- Linear spring coefficients
diagTensor linSpringCoeffs_;
//- Linear damping coefficients
diagTensor linDampingCoeffs_;
public:
//- Runtime type information
TypeName("linearSpringDamper");
// Constructors
//- Construct from dictionary
linearSpringDamper
(
const word& name,
const dictionary& dict
);
//- Construct and return a clone
virtual autoPtr<translationalRestraint> clone() const;
// Destructor
virtual ~linearSpringDamper();
// Member Functions
// Restraint specific functions
//- Return restraining force (in the global coordinate system)
virtual vector restrainingForce
(
const scalar t,
const tensor& toRelative,
const vector& x,
const vector& u
) const;
// I-O Functions and Operators
//- Virtual write function
virtual void write(Ostream& os) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -191,8 +191,6 @@ void Foam::sixDOFODE::setState(const sixDOFODE& sd)
momentOfInertia_ = sd.momentOfInertia_;
Xequilibrium_ = sd.Xequilibrium_;
linSpringCoeffs_ = sd.linSpringCoeffs_;
linDampingCoeffs_ = sd.linDampingCoeffs_;
force_ = sd.force_;
moment_ = sd.moment_;
@ -207,23 +205,61 @@ void Foam::sixDOFODE::setState(const sixDOFODE& sd)
}
Foam::dimensionedVector Foam::sixDOFODE::force(const scalar t) const
Foam::dimensionedVector Foam::sixDOFODE::force
(
const scalar t,
const tensor& toRelative,
const vector& x,
const vector& u
) const
{
// Get ODE step fraction
const scalar alpha = odeStepFraction(t);
// Return linearly interpolated external force
return (alpha*oldStatePtr_->force() + (1 - alpha)*force());
// Calculate restraining force
dimensionedVector rForce("zero", dimForce, vector::zero);
forAll(translationalRestraints_, trI)
{
rForce.value() += translationalRestraints_[trI].restrainingForce
(
t, // Time
toRelative, // Transformation tensor
x, // Position in the global c.s.
u // Velocity in the global c.s.
);
}
// Return linearly interpolated external force with restraining force
return (alpha*oldStatePtr_->force() + (1 - alpha)*force()) + rForce;
}
Foam::dimensionedVector Foam::sixDOFODE::moment(const scalar t) const
Foam::dimensionedVector Foam::sixDOFODE::moment
(
const scalar t,
const tensor& toRelative,
const vector& omega
) const
{
// Get ODE step fraction
const scalar alpha = odeStepFraction(t);
// Return linearly interpolated external moment
return (alpha*oldStatePtr_->moment() + (1 - alpha)*moment());
// Calculate restraining moment
dimensionedVector rMoment("zero", dimForce*dimLength, vector::zero);
forAll(rotationalRestraints_, rrI)
{
rMoment.value() += rotationalRestraints_[rrI].restrainingMoment
(
t, // Time
toRelative, // Transformation tensor
omega // Angular velocity in local c.s.
);
}
// Return linearly interpolated external moment with restraining moment
return (alpha*oldStatePtr_->moment() + (1 - alpha)*moment() + rMoment);
}
@ -238,8 +274,6 @@ Foam::sixDOFODE::sixDOFODE(const IOobject& io)
momentOfInertia_(dict_.lookup("momentOfInertia")),
Xequilibrium_(dict_.lookup("equilibriumPosition")),
linSpringCoeffs_(dict_.lookup("linearSpring")),
linDampingCoeffs_(dict_.lookup("linearDamping")),
aitkensRelaxation_
(
@ -345,8 +379,6 @@ Foam::sixDOFODE::sixDOFODE(const word& name, const sixDOFODE& sd)
momentOfInertia_(sd.momentOfInertia_),
Xequilibrium_(sd.Xequilibrium_),
linSpringCoeffs_(sd.linSpringCoeffs_),
linDampingCoeffs_(sd.linDampingCoeffs_),
aitkensRelaxation_(sd.aitkensRelaxation_),
minRelaxFactor_(sd.minRelaxFactor_),
@ -399,10 +431,6 @@ bool Foam::sixDOFODE::writeData(Ostream& os) const
os.writeKeyword("equilibriumPosition") << tab << Xequilibrium_
<< token::END_STATEMENT << nl;
os.writeKeyword("linearSpring") << tab << linSpringCoeffs_
<< token::END_STATEMENT << nl;
os.writeKeyword("linearDamping") << tab << linDampingCoeffs_
<< token::END_STATEMENT << nl << nl;
os.writeKeyword("useAitkensRelaxation") << tab << aitkensRelaxation_
<< token::END_STATEMENT << nl;

View file

@ -92,12 +92,6 @@ class sixDOFODE
//- Spring equilibrium position for translation
dimensionedVector Xequilibrium_;
//- Linear spring coeffs
dimensionedDiagTensor linSpringCoeffs_;
//- Linear damping coeffs
dimensionedDiagTensor linDampingCoeffs_;
// Aitkens relaxation data members
@ -216,13 +210,22 @@ protected:
// Get external force and moment (used during the solution process)
//- Return external force given time (linearly interpolated from
// old state and current state)
dimensionedVector force(const scalar t) const;
//- Return external force with restraints for given ODE state
dimensionedVector force
(
const scalar t,
const tensor& toRelative,
const vector& x,
const vector& u
) const;
//- Return external moment given time (linearly interpolated from
// old state and current state)
dimensionedVector moment(const scalar t) const;
//- Return external moment with restraints given ODE state
dimensionedVector moment
(
const scalar t,
const tensor& toRelative,
const vector& omega
) const;
public:

View file

@ -81,18 +81,6 @@ Foam::dimensionedVector& Foam::sixDOFODE::Xequilibrium()
}
const Foam::dimensionedDiagTensor& Foam::sixDOFODE::linSpringCoeffs() const
{
return linSpringCoeffs_;
}
const Foam::dimensionedDiagTensor& Foam::sixDOFODE::linDampingCoeffs() const
{
return linDampingCoeffs_;
}
const Foam::dimensionedVector& Foam::sixDOFODE::force() const
{
return force_;