Restored translationODE class

Accidentally removed it in one of the previous commits
This commit is contained in:
Vuko Vukcevic 2017-03-02 14:22:30 +01:00 committed by Hrvoje Jasak
parent 6a514ecb48
commit 21201c4585
4 changed files with 550 additions and 0 deletions

View file

@ -9,6 +9,9 @@ $(ODESolvers)/SIBS/SIBS.C
$(ODESolvers)/SIBS/SIMPR.C $(ODESolvers)/SIBS/SIMPR.C
$(ODESolvers)/SIBS/polyExtrapolate.C $(ODESolvers)/SIBS/polyExtrapolate.C
translationODE = translationODE
$(translationODE)/translationODE.C
sixDOF = sixDOF sixDOF = sixDOF
$(sixDOF)/finiteRotation/finiteRotation.C $(sixDOF)/finiteRotation/finiteRotation.C
$(sixDOF)/sixDOFqODE/sixDOFqODE.C $(sixDOF)/sixDOFqODE/sixDOFqODE.C

View file

@ -0,0 +1,202 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
translationODE
Description
Ordinary differential equation for three degrees of freedom
solid body motion
Author
Hrvoje Jasak
Dubravko Matijasevic
\*---------------------------------------------------------------------------*/
#include "translationODE.H"
#include "objectRegistry.H"
#include "foamTime.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
// namespace Foam
// {
// defineTypeNameAndDebug(translationODE, 0);
// }
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::translationODE::setCoeffs()
{
// Set ODE coefficients from position and rotation
// Linear displacement in relative coordinate system
{
const vector& xVal = Xrel_.value();
coeffs_[0] = xVal.x();
coeffs_[1] = xVal.y();
coeffs_[2] = xVal.z();
}
// Linear velocity in relative coordinate system
{
const vector& uVal = U_.value();
coeffs_[3] = uVal.x();
coeffs_[4] = uVal.y();
coeffs_[5] = uVal.z();
}
}
Foam::dimensionedVector Foam::translationODE::A
(
const dimensionedVector& xR,
const dimensionedVector& uR
) const
{
return
(
- (linSpringCoeffs_ & xR) // spring
- (linDampingCoeffs_ & uR) // damping
+ force()
)/mass_; // gravity
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
Foam::translationODE::translationODE
(
const IOobject& io
)
:
IOdictionary(io),
mass_(lookup("mass")),
xEquilibrium_(lookup("equilibriumPosition")),
linSpringCoeffs_(lookup("linearSpring")),
linDampingCoeffs_(lookup("linearDamping")),
Xrel_(lookup("Xrel")),
U_(lookup("U")),
Uold_(lookup("Uold")),
force_(lookup("force")),
coeffs_(6, 0.0)
{
setCoeffs();
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::translationODE::~translationODE()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::translationODE::derivatives
(
const scalar x,
const scalarField& y,
scalarField& dydx
) const
{
// Set the derivatives for displacement
dydx[0] = y[3];
dydx[1] = y[4];
dydx[2] = y[5];
dimensionedVector curX("curX", dimLength, vector(y[0], y[1], y[2]));
dimensionedVector curU("curU", dimLength/dimTime, vector(y[3], y[4], y[5]));
const vector& accel = A(curX, curU).value();
dydx[3] = accel.x();
dydx[4] = accel.y();
dydx[5] = accel.z();
}
void Foam::translationODE::jacobian
(
const scalar x,
const scalarField& y,
scalarField& dfdx,
scalarSquareMatrix& dfdy
) const
{
notImplemented("translationODE::jacobian(...) const");
}
void Foam::translationODE::update(const scalar delta)
{
// Update position
vector& Xval = Xrel_.value();
Xval.x() = coeffs_[0];
Xval.y() = coeffs_[1];
Xval.z() = coeffs_[2];
// Update velocity
Uold_ = U_;
vector& Uval = U_.value();
Uval.x() = coeffs_[3];
Uval.y() = coeffs_[4];
Uval.z() = coeffs_[5];
}
bool Foam::translationODE::writeData(Ostream& os) const
{
os << *this;
return os.good();
}
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
Foam::Ostream& Foam::operator<<(Ostream& os, const translationODE& sds)
{
os.writeKeyword("mass") << sds.mass_ << token::END_STATEMENT << endl;
os.writeKeyword("equilibriumPosition") << sds.xEquilibrium_
<< token::END_STATEMENT << endl;
os.writeKeyword("linearSpring") << sds.linSpringCoeffs_
<< token::END_STATEMENT << endl;
os.writeKeyword("linearDamping") << sds.linDampingCoeffs_
<< token::END_STATEMENT << endl;
os.writeKeyword("Xrel") << sds.Xrel() << token::END_STATEMENT << endl;
os.writeKeyword("U") << sds.U() << token::END_STATEMENT << endl;
os.writeKeyword("Uold") << tab << sds.Uold() << token::END_STATEMENT << nl;
os.writeKeyword("force") << sds.force() << token::END_STATEMENT << endl;
return os;
}
// ************************************************************************* //

View file

@ -0,0 +1,251 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
translationODE
Description
Ordinary differential equation for three degrees of freedom solid
body translation
Author
Hrvoje Jasak
Dubravko Matijasevic
SourceFiles
translationODEI.H
translationODE.C
\*---------------------------------------------------------------------------*/
#ifndef translationODE_H
#define translationODE_H
#include "ODE.H"
#include "IOdictionary.H"
#include "dimensionedTypes.H"
#include "dimensionedDiagTensor.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class translationODE Declaration
\*---------------------------------------------------------------------------*/
class translationODE
:
public IOdictionary,
public ODE
{
// Private data
// Body data
//- Mass
dimensionedScalar mass_;
// Platform variables
//- Spring equilibrium position for translation
const dimensionedVector xEquilibrium_;
//- Linear spring coeffs
const dimensionedDiagTensor linSpringCoeffs_;
//- Linear damping coeffs
const dimensionedDiagTensor linDampingCoeffs_;
// Body position and rotation variables
//- Displacement relative to spring equilibrium
dimensionedVector Xrel_;
//- Velocity of mass centroid
dimensionedVector U_;
//- Velocity of mass centroid at previous time-step
dimensionedVector Uold_;
// External forces
//- Force driving the motion
dimensionedVector force_;
//- ODE coefficients
scalarField coeffs_;
// Private Member Functions
//- Disallow default bitwise copy construct
translationODE(const translationODE&);
//- Disallow default bitwise assignment
void operator=(const translationODE&);
//- Set ODE coefficients from position and rotation
inline void setCoeffs();
// Variables in relative coordinate system (solved for)
//- Return acceleration in relative coordinate system
// given current values of relative displacement and velocity
dimensionedVector A
(
const dimensionedVector& xR,
const dimensionedVector& uR
) const;
public:
// //- Runtime type information
// TypeName("translationODE");
// Constructors
//- Construct from dictionary
translationODE(const IOobject& io);
// Destructor
virtual ~translationODE();
// Member Functions
//- Return mass
inline const dimensionedScalar& mass() const;
// Variables in relative coordinate system (solved for)
//- Return displacement in relative coordinate system
inline const dimensionedVector& Xrel() const;
// Displacement and rotation in the absolute coordinate system
//- Return position of origin in absolute coordinate system
inline dimensionedVector X() const;
//- Return velocity of origin
inline const dimensionedVector& U() const;
//- Return velocity of origin for the previous time-step
inline const dimensionedVector& Uold() const;
//- Return acceleration of origin
inline dimensionedVector A() const;
// Average motion per time-step
//- Return average velocity of origin
inline dimensionedVector Uaverage() const;
// Force
//- Return force
inline const dimensionedVector& force() const;
//- Return access to force
inline dimensionedVector& force();
// ODE parameters
//- Return number of equations
virtual label nEqns() const
{
return 6;
}
//- Return reference to interpolation coefficients
virtual scalarField& coeffs()
{
return coeffs_;
}
//- Return reference to interpolation coefficients
virtual const scalarField& coeffs() const
{
return coeffs_;
}
//- Return derivatives
virtual void derivatives
(
const scalar x,
const scalarField& y,
scalarField& dydx
) const;
//- Return Jacobian
virtual void jacobian
(
const scalar x,
const scalarField& y,
scalarField& dfdx,
scalarSquareMatrix& dfdy
) const;
//- Update ODE after the solution, advancing by delta
virtual void update(const scalar delta);
//- WriteData member function required by regIOobject
bool writeData(Ostream&) const;
// Ostream operator
friend Ostream& operator<<(Ostream&, const translationODE&);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "translationODEI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -0,0 +1,94 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
translationODE
Description
Ordinary differential equation for three degrees of freedom
solid body translation
Author
Hrvoje Jasak
Dubravko Matijasevic
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
const Foam::dimensionedScalar& Foam::translationODE::mass() const
{
return mass_;
}
const Foam::dimensionedVector& Foam::translationODE::Xrel() const
{
return Xrel_;
}
Foam::dimensionedVector Foam::translationODE::X() const
{
return xEquilibrium_ + Xrel();
}
const Foam::dimensionedVector& Foam::translationODE::U() const
{
return U_;
}
const Foam::dimensionedVector& Foam::translationODE::Uold() const
{
return Uold_;
}
Foam::dimensionedVector Foam::translationODE::A() const
{
return A(Xrel(), U());
}
Foam::dimensionedVector Foam::translationODE::Uaverage() const
{
return 0.5*(U_ + Uold_);
}
const Foam::dimensionedVector& Foam::translationODE::force() const
{
return force_;
}
Foam::dimensionedVector& Foam::translationODE::force()
{
return force_;
}
// ************************************************************************* //