Restructuring sixDOFODE class
Separation of I/O and core functionality was necessary in order to enable correct simulation restart because of combined run-time selection and automatic read/write operations provided by regIOobject (IOdictionary)
This commit is contained in:
parent
ed31562fe8
commit
b3118e18a4
8 changed files with 228 additions and 65 deletions
|
@ -13,6 +13,7 @@ sixDOF = sixDOF
|
|||
$(sixDOF)/finiteRotation/finiteRotation.C
|
||||
$(sixDOF)/sixDOFqODE/sixDOFqODE.C
|
||||
|
||||
$(sixDOF)/sixDOFODE/sixDOFODEIO.C
|
||||
$(sixDOF)/sixDOFODE/sixDOFODE.C
|
||||
$(sixDOF)/sixDOFODE/newSixDOFODE.C
|
||||
$(sixDOF)/quaternionSixDOF/quaternionSixDOF.C
|
||||
|
|
|
@ -38,6 +38,7 @@ SourceFiles
|
|||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "quaternionSixDOF.H"
|
||||
#include "sixDOFODEIO.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
@ -226,29 +227,29 @@ Foam::quaternionSixDOF::quaternionSixDOF(const IOobject& io)
|
|||
:
|
||||
sixDOFODE(io),
|
||||
|
||||
Xrel_(lookup("Xrel")),
|
||||
U_(lookup("U")),
|
||||
Xrel_(dict().lookup("Xrel")),
|
||||
U_(dict().lookup("U")),
|
||||
Uaverage_(U_),
|
||||
rotation_
|
||||
(
|
||||
vector(lookup("rotationVector")),
|
||||
dimensionedScalar(lookup("rotationAngle")).value()
|
||||
vector(dict().lookup("rotationVector")),
|
||||
dimensionedScalar(dict().lookup("rotationAngle")).value()
|
||||
),
|
||||
omega_(lookup("omega")),
|
||||
omega_(dict().lookup("omega")),
|
||||
omegaAverage_(omega_),
|
||||
omegaAverageAbsolute_(omega_),
|
||||
|
||||
coeffs_(13, 0.0),
|
||||
|
||||
fixedSurge_(lookup("fixedSurge")),
|
||||
fixedSway_(lookup("fixedSway")),
|
||||
fixedHeave_(lookup("fixedHeave")),
|
||||
fixedRoll_(lookup("fixedRoll")),
|
||||
fixedPitch_(lookup("fixedPitch")),
|
||||
fixedYaw_(lookup("fixedYaw")),
|
||||
fixedSurge_(dict().lookup("fixedSurge")),
|
||||
fixedSway_(dict().lookup("fixedSway")),
|
||||
fixedHeave_(dict().lookup("fixedHeave")),
|
||||
fixedRoll_(dict().lookup("fixedRoll")),
|
||||
fixedPitch_(dict().lookup("fixedPitch")),
|
||||
fixedYaw_(dict().lookup("fixedYaw")),
|
||||
referentMotionConstraints_
|
||||
(
|
||||
lookupOrDefault<Switch>
|
||||
dict().lookupOrDefault<Switch>
|
||||
(
|
||||
"referentMotionConstraints",
|
||||
false
|
||||
|
@ -271,9 +272,9 @@ Foam::quaternionSixDOF::quaternionSixDOF
|
|||
IOobject
|
||||
(
|
||||
name,
|
||||
qsd.instance(),
|
||||
qsd.local(),
|
||||
qsd.db(),
|
||||
qsd.dict().instance(),
|
||||
qsd.dict().local(),
|
||||
qsd.dict().db(),
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
)
|
||||
|
@ -658,18 +659,18 @@ bool Foam::quaternionSixDOF::writeData(Ostream& os) const
|
|||
os.writeKeyword("omega") << tab << this->omega()
|
||||
<< token::END_STATEMENT << nl << nl;
|
||||
|
||||
os.writeKeyword("fixedSurge") << tab << this->fixedSurge_ <<
|
||||
token::END_STATEMENT << endl;
|
||||
os.writeKeyword("fixedSway") << tab << this->fixedSway_ <<
|
||||
token::END_STATEMENT << endl;
|
||||
os.writeKeyword("fixedHeave") << tab << this->fixedHeave_ <<
|
||||
token::END_STATEMENT << endl;
|
||||
os.writeKeyword("fixedRoll") << tab << this->fixedRoll_ <<
|
||||
token::END_STATEMENT << endl;
|
||||
os.writeKeyword("fixedPitch") << tab << this->fixedPitch_ <<
|
||||
token::END_STATEMENT << endl;
|
||||
os.writeKeyword("fixedYaw") << tab << this->fixedYaw_ <<
|
||||
token::END_STATEMENT << endl;
|
||||
os.writeKeyword("fixedSurge") << tab << fixedSurge_ <<
|
||||
token::END_STATEMENT << nl;
|
||||
os.writeKeyword("fixedSway") << tab << fixedSway_ <<
|
||||
token::END_STATEMENT << nl;
|
||||
os.writeKeyword("fixedHeave") << tab << fixedHeave_ <<
|
||||
token::END_STATEMENT << nl;
|
||||
os.writeKeyword("fixedRoll") << tab << fixedRoll_ <<
|
||||
token::END_STATEMENT << nl;
|
||||
os.writeKeyword("fixedPitch") << tab << fixedPitch_ <<
|
||||
token::END_STATEMENT << nl;
|
||||
os.writeKeyword("fixedYaw") << tab << fixedYaw_ <<
|
||||
token::END_STATEMENT << nl << endl;
|
||||
|
||||
return os.good();
|
||||
}
|
||||
|
|
|
@ -83,11 +83,7 @@ void Foam::sixDOFBodies::setBodies()
|
|||
solvers_.set
|
||||
(
|
||||
bodyI,
|
||||
ODESolver::New
|
||||
(
|
||||
lookup("solver"),
|
||||
odes_[bodyI]
|
||||
)
|
||||
ODESolver::New(lookup("solver"), odes_[bodyI])
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -123,14 +123,15 @@ void Foam::sixDOFODE::aitkensRelaxation
|
|||
|
||||
Foam::sixDOFODE::sixDOFODE(const IOobject& io)
|
||||
:
|
||||
IOdictionary(io),
|
||||
ODE(),
|
||||
dict_(io, *this),
|
||||
|
||||
mass_(lookup("mass")),
|
||||
momentOfInertia_(lookup("momentOfInertia")),
|
||||
mass_(dict_.lookup("mass")),
|
||||
momentOfInertia_(dict_.lookup("momentOfInertia")),
|
||||
|
||||
Xequilibrium_(lookup("equilibriumPosition")),
|
||||
linSpringCoeffs_(lookup("linearSpring")),
|
||||
linDampingCoeffs_(lookup("linearDamping")),
|
||||
Xequilibrium_(dict_.lookup("equilibriumPosition")),
|
||||
linSpringCoeffs_(dict_.lookup("linearSpring")),
|
||||
linDampingCoeffs_(dict_.lookup("linearDamping")),
|
||||
|
||||
relaxFactorT_(1.0),
|
||||
relaxFactorR_(1.0),
|
||||
|
@ -142,10 +143,10 @@ Foam::sixDOFODE::sixDOFODE(const IOobject& io)
|
|||
An_(3, vector::zero),
|
||||
OmegaDotn_(3, vector::zero),
|
||||
|
||||
force_(lookup("force")),
|
||||
moment_(lookup("moment")),
|
||||
forceRelative_(lookup("forceRelative")),
|
||||
momentRelative_(lookup("momentRelative"))
|
||||
force_(dict_.lookup("force")),
|
||||
moment_(dict_.lookup("moment")),
|
||||
forceRelative_(dict_.lookup("forceRelative")),
|
||||
momentRelative_(dict_.lookup("momentRelative"))
|
||||
{}
|
||||
|
||||
|
||||
|
@ -157,6 +158,11 @@ Foam::sixDOFODE::~sixDOFODE()
|
|||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
const Foam::sixDOFODEIO& Foam::sixDOFODE::dict() const
|
||||
{
|
||||
return dict_;
|
||||
}
|
||||
|
||||
|
||||
void Foam::sixDOFODE::relaxAcceleration
|
||||
(
|
||||
|
@ -255,16 +261,4 @@ bool Foam::sixDOFODE::writeData(Ostream& os) const
|
|||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * * //
|
||||
|
||||
Foam::Ostream& Foam::operator<<(Ostream& os, const sixDOFODE& sds)
|
||||
{
|
||||
sds.writeData(os);
|
||||
|
||||
os.check("Ostream& operator<<(Ostream&, const sixDOFODE");
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
|
|
@ -45,7 +45,7 @@ SourceFiles
|
|||
#define sixDOFODE_H
|
||||
|
||||
#include "ODE.H"
|
||||
#include "IOdictionary.H"
|
||||
#include "sixDOFODEIO.H"
|
||||
#include "dimensionedTypes.H"
|
||||
#include "autoPtr.H"
|
||||
#include "runTimeSelectionTables.H"
|
||||
|
@ -55,6 +55,9 @@ SourceFiles
|
|||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declarations of classes
|
||||
class IOobject;
|
||||
|
||||
class finiteRotation;
|
||||
class HamiltonRodriguezRot;
|
||||
|
||||
|
@ -64,11 +67,14 @@ class HamiltonRodriguezRot;
|
|||
|
||||
class sixDOFODE
|
||||
:
|
||||
public IOdictionary,
|
||||
public ODE
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Dictionary object controlling I/O for sixDOFODE
|
||||
const sixDOFODEIO dict_;
|
||||
|
||||
|
||||
// Body data
|
||||
|
||||
//- Mass
|
||||
|
@ -191,6 +197,9 @@ public:
|
|||
|
||||
// Access to common data
|
||||
|
||||
//- Return sixDOFODEIO (IOdictionary)
|
||||
const sixDOFODEIO& dict() const;
|
||||
|
||||
//- Return mass
|
||||
inline const dimensionedScalar& mass() const;
|
||||
|
||||
|
@ -377,11 +386,6 @@ public:
|
|||
|
||||
//- writeData member function required by regIOobject
|
||||
virtual bool writeData(Ostream&) const;
|
||||
|
||||
|
||||
// Ostream operator
|
||||
|
||||
friend Ostream& operator<<(Ostream&, const sixDOFODE&);
|
||||
};
|
||||
|
||||
|
||||
|
|
65
src/ODE/sixDOF/sixDOFODE/sixDOFODEIO.C
Normal file
65
src/ODE/sixDOF/sixDOFODE/sixDOFODEIO.C
Normal file
|
@ -0,0 +1,65 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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
|
||||
sixDOFODEIO
|
||||
|
||||
Description
|
||||
Class used to control input/output for sixDOFODEIO. Need separate classes in
|
||||
order to be able to have run-time selection and automatic I/O.
|
||||
|
||||
Author
|
||||
Vuko Vukcevic, FSB Zagreb. All rights reserved.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "sixDOFODEIO.H"
|
||||
#include "sixDOFODE.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::sixDOFODEIO::sixDOFODEIO(const IOobject& io, const sixDOFODE& sixDOF)
|
||||
:
|
||||
IOdictionary(io),
|
||||
sixDOF_(sixDOF)
|
||||
{
|
||||
// Note: parameter sixDOF is incomplete here, must not call its member
|
||||
// functions here.
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::sixDOFODEIO::~sixDOFODEIO()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::sixDOFODEIO::writeData(Ostream& os) const
|
||||
{
|
||||
return sixDOF_.writeData(os);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
102
src/ODE/sixDOF/sixDOFODE/sixDOFODEIO.H
Normal file
102
src/ODE/sixDOF/sixDOFODE/sixDOFODEIO.H
Normal file
|
@ -0,0 +1,102 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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
|
||||
sixDOFODEIO
|
||||
|
||||
Description
|
||||
Class used to control input/output for sixDOFODEIO. Need separate classes in
|
||||
order to be able to have run-time selection and automatic I/O.
|
||||
|
||||
Author
|
||||
Vuko Vukcevic, FSB Zagreb. All rights reserved.
|
||||
|
||||
SourceFiles
|
||||
sixDOFODEIO.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef sixDOFODEIO_H
|
||||
#define sixDOFODEIO_H
|
||||
|
||||
#include "IOdictionary.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
class sixDOFODE;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class sixDOFODEIO Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class sixDOFODEIO
|
||||
:
|
||||
public IOdictionary
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Const reference to the underlying sixDOFODE object
|
||||
const sixDOFODE& sixDOF_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
sixDOFODEIO(const sixDOFODEIO&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const sixDOFODEIO&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from dictionary and sixDOFODE object
|
||||
sixDOFODEIO(const IOobject& io, const sixDOFODE& sixDOF);
|
||||
|
||||
|
||||
// Destructor
|
||||
|
||||
virtual ~sixDOFODEIO();
|
||||
|
||||
|
||||
// Write control
|
||||
|
||||
//- writeData member function controlling output
|
||||
virtual bool writeData(Ostream& os) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
Reference in a new issue