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:
Vuko Vukcevic 2017-02-27 16:56:17 +01:00 committed by Hrvoje Jasak
parent ed31562fe8
commit b3118e18a4
8 changed files with 228 additions and 65 deletions

View file

@ -13,6 +13,7 @@ sixDOF = sixDOF
$(sixDOF)/finiteRotation/finiteRotation.C $(sixDOF)/finiteRotation/finiteRotation.C
$(sixDOF)/sixDOFqODE/sixDOFqODE.C $(sixDOF)/sixDOFqODE/sixDOFqODE.C
$(sixDOF)/sixDOFODE/sixDOFODEIO.C
$(sixDOF)/sixDOFODE/sixDOFODE.C $(sixDOF)/sixDOFODE/sixDOFODE.C
$(sixDOF)/sixDOFODE/newSixDOFODE.C $(sixDOF)/sixDOFODE/newSixDOFODE.C
$(sixDOF)/quaternionSixDOF/quaternionSixDOF.C $(sixDOF)/quaternionSixDOF/quaternionSixDOF.C

View file

@ -29,7 +29,7 @@ Description
Author Author
Dubravko Matijasevic, FSB Zagreb. All rights reserved. Dubravko Matijasevic, FSB Zagreb. All rights reserved.
Hrvoje Jasak, FSB Zagreb. All rights reserved. Hrvoje Jasak, FSB Zagreb. All rights reserved.
Vuko Vukcevic, FSB Zagreb. All rights reserved. Vuko Vukcevic, FSB Zagreb. All rights reserved.
SourceFiles SourceFiles
@ -38,6 +38,7 @@ SourceFiles
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "quaternionSixDOF.H" #include "quaternionSixDOF.H"
#include "sixDOFODEIO.H"
#include "addToRunTimeSelectionTable.H" #include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -226,29 +227,29 @@ Foam::quaternionSixDOF::quaternionSixDOF(const IOobject& io)
: :
sixDOFODE(io), sixDOFODE(io),
Xrel_(lookup("Xrel")), Xrel_(dict().lookup("Xrel")),
U_(lookup("U")), U_(dict().lookup("U")),
Uaverage_(U_), Uaverage_(U_),
rotation_ rotation_
( (
vector(lookup("rotationVector")), vector(dict().lookup("rotationVector")),
dimensionedScalar(lookup("rotationAngle")).value() dimensionedScalar(dict().lookup("rotationAngle")).value()
), ),
omega_(lookup("omega")), omega_(dict().lookup("omega")),
omegaAverage_(omega_), omegaAverage_(omega_),
omegaAverageAbsolute_(omega_), omegaAverageAbsolute_(omega_),
coeffs_(13, 0.0), coeffs_(13, 0.0),
fixedSurge_(lookup("fixedSurge")), fixedSurge_(dict().lookup("fixedSurge")),
fixedSway_(lookup("fixedSway")), fixedSway_(dict().lookup("fixedSway")),
fixedHeave_(lookup("fixedHeave")), fixedHeave_(dict().lookup("fixedHeave")),
fixedRoll_(lookup("fixedRoll")), fixedRoll_(dict().lookup("fixedRoll")),
fixedPitch_(lookup("fixedPitch")), fixedPitch_(dict().lookup("fixedPitch")),
fixedYaw_(lookup("fixedYaw")), fixedYaw_(dict().lookup("fixedYaw")),
referentMotionConstraints_ referentMotionConstraints_
( (
lookupOrDefault<Switch> dict().lookupOrDefault<Switch>
( (
"referentMotionConstraints", "referentMotionConstraints",
false false
@ -271,9 +272,9 @@ Foam::quaternionSixDOF::quaternionSixDOF
IOobject IOobject
( (
name, name,
qsd.instance(), qsd.dict().instance(),
qsd.local(), qsd.dict().local(),
qsd.db(), qsd.dict().db(),
IOobject::NO_READ, IOobject::NO_READ,
IOobject::NO_WRITE IOobject::NO_WRITE
) )
@ -658,18 +659,18 @@ bool Foam::quaternionSixDOF::writeData(Ostream& os) const
os.writeKeyword("omega") << tab << this->omega() os.writeKeyword("omega") << tab << this->omega()
<< token::END_STATEMENT << nl << nl; << token::END_STATEMENT << nl << nl;
os.writeKeyword("fixedSurge") << tab << this->fixedSurge_ << os.writeKeyword("fixedSurge") << tab << fixedSurge_ <<
token::END_STATEMENT << endl; token::END_STATEMENT << nl;
os.writeKeyword("fixedSway") << tab << this->fixedSway_ << os.writeKeyword("fixedSway") << tab << fixedSway_ <<
token::END_STATEMENT << endl; token::END_STATEMENT << nl;
os.writeKeyword("fixedHeave") << tab << this->fixedHeave_ << os.writeKeyword("fixedHeave") << tab << fixedHeave_ <<
token::END_STATEMENT << endl; token::END_STATEMENT << nl;
os.writeKeyword("fixedRoll") << tab << this->fixedRoll_ << os.writeKeyword("fixedRoll") << tab << fixedRoll_ <<
token::END_STATEMENT << endl; token::END_STATEMENT << nl;
os.writeKeyword("fixedPitch") << tab << this->fixedPitch_ << os.writeKeyword("fixedPitch") << tab << fixedPitch_ <<
token::END_STATEMENT << endl; token::END_STATEMENT << nl;
os.writeKeyword("fixedYaw") << tab << this->fixedYaw_ << os.writeKeyword("fixedYaw") << tab << fixedYaw_ <<
token::END_STATEMENT << endl; token::END_STATEMENT << nl << endl;
return os.good(); return os.good();
} }

View file

@ -29,7 +29,7 @@ Description
Author Author
Dubravko Matijasevic, FSB Zagreb. All rights reserved. Dubravko Matijasevic, FSB Zagreb. All rights reserved.
Hrvoje Jasak, FSB Zagreb. All rights reserved. Hrvoje Jasak, FSB Zagreb. All rights reserved.
Vuko Vukcevic, FSB Zagreb. All rights reserved. Vuko Vukcevic, FSB Zagreb. All rights reserved.
SourceFiles SourceFiles

View file

@ -83,11 +83,7 @@ void Foam::sixDOFBodies::setBodies()
solvers_.set solvers_.set
( (
bodyI, bodyI,
ODESolver::New ODESolver::New(lookup("solver"), odes_[bodyI])
(
lookup("solver"),
odes_[bodyI]
)
); );
} }
} }

View file

@ -30,7 +30,7 @@ Description
Author Author
Dubravko Matijasevic, FSB Zagreb. All rights reserved. Dubravko Matijasevic, FSB Zagreb. All rights reserved.
Hrvoje Jasak, FSB Zagreb. All rights reserved. Hrvoje Jasak, FSB Zagreb. All rights reserved.
Vuko Vukcevic, FSB Zagreb. All rights reserved. Vuko Vukcevic, FSB Zagreb. All rights reserved.
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
@ -123,14 +123,15 @@ void Foam::sixDOFODE::aitkensRelaxation
Foam::sixDOFODE::sixDOFODE(const IOobject& io) Foam::sixDOFODE::sixDOFODE(const IOobject& io)
: :
IOdictionary(io), ODE(),
dict_(io, *this),
mass_(lookup("mass")), mass_(dict_.lookup("mass")),
momentOfInertia_(lookup("momentOfInertia")), momentOfInertia_(dict_.lookup("momentOfInertia")),
Xequilibrium_(lookup("equilibriumPosition")), Xequilibrium_(dict_.lookup("equilibriumPosition")),
linSpringCoeffs_(lookup("linearSpring")), linSpringCoeffs_(dict_.lookup("linearSpring")),
linDampingCoeffs_(lookup("linearDamping")), linDampingCoeffs_(dict_.lookup("linearDamping")),
relaxFactorT_(1.0), relaxFactorT_(1.0),
relaxFactorR_(1.0), relaxFactorR_(1.0),
@ -142,10 +143,10 @@ Foam::sixDOFODE::sixDOFODE(const IOobject& io)
An_(3, vector::zero), An_(3, vector::zero),
OmegaDotn_(3, vector::zero), OmegaDotn_(3, vector::zero),
force_(lookup("force")), force_(dict_.lookup("force")),
moment_(lookup("moment")), moment_(dict_.lookup("moment")),
forceRelative_(lookup("forceRelative")), forceRelative_(dict_.lookup("forceRelative")),
momentRelative_(lookup("momentRelative")) momentRelative_(dict_.lookup("momentRelative"))
{} {}
@ -157,6 +158,11 @@ Foam::sixDOFODE::~sixDOFODE()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
const Foam::sixDOFODEIO& Foam::sixDOFODE::dict() const
{
return dict_;
}
void Foam::sixDOFODE::relaxAcceleration 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;
}
// ************************************************************************* // // ************************************************************************* //

View file

@ -31,7 +31,7 @@ Description
Author Author
Dubravko Matijasevic, FSB Zagreb. All rights reserved. Dubravko Matijasevic, FSB Zagreb. All rights reserved.
Hrvoje Jasak, FSB Zagreb. All rights reserved. Hrvoje Jasak, FSB Zagreb. All rights reserved.
Vuko Vukcevic, FSB Zagreb. All rights reserved. Vuko Vukcevic, FSB Zagreb. All rights reserved.
SourceFiles SourceFiles
@ -45,7 +45,7 @@ SourceFiles
#define sixDOFODE_H #define sixDOFODE_H
#include "ODE.H" #include "ODE.H"
#include "IOdictionary.H" #include "sixDOFODEIO.H"
#include "dimensionedTypes.H" #include "dimensionedTypes.H"
#include "autoPtr.H" #include "autoPtr.H"
#include "runTimeSelectionTables.H" #include "runTimeSelectionTables.H"
@ -55,6 +55,9 @@ SourceFiles
namespace Foam namespace Foam
{ {
// Forward declarations of classes
class IOobject;
class finiteRotation; class finiteRotation;
class HamiltonRodriguezRot; class HamiltonRodriguezRot;
@ -64,11 +67,14 @@ class HamiltonRodriguezRot;
class sixDOFODE class sixDOFODE
: :
public IOdictionary,
public ODE public ODE
{ {
// Private data // Private data
//- Dictionary object controlling I/O for sixDOFODE
const sixDOFODEIO dict_;
// Body data // Body data
//- Mass //- Mass
@ -191,6 +197,9 @@ public:
// Access to common data // Access to common data
//- Return sixDOFODEIO (IOdictionary)
const sixDOFODEIO& dict() const;
//- Return mass //- Return mass
inline const dimensionedScalar& mass() const; inline const dimensionedScalar& mass() const;
@ -377,11 +386,6 @@ public:
//- writeData member function required by regIOobject //- writeData member function required by regIOobject
virtual bool writeData(Ostream&) const; virtual bool writeData(Ostream&) const;
// Ostream operator
friend Ostream& operator<<(Ostream&, const sixDOFODE&);
}; };

View 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);
}
// ************************************************************************* //

View 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
// ************************************************************************* //