Making parallel motion consistent. Moving all motion state data to a

sepatate class so that it may be scattered in one operation.
This commit is contained in:
graham 2009-09-29 17:35:53 +01:00
parent dfd02c8b4f
commit ce299b3917
10 changed files with 601 additions and 161 deletions

View File

@ -34,5 +34,7 @@ pointPatchFields/derived/surfaceDisplacement/surfaceDisplacementPointPatchVector
pointPatchFields/derived/sixDofRigidBodyDisplacement/sixDofRigidBodyDisplacementPointPatchVectorField.C pointPatchFields/derived/sixDofRigidBodyDisplacement/sixDofRigidBodyDisplacementPointPatchVectorField.C
pointPatchFields/derived/sixDofRigidBodyDisplacement/sixDofRigidBodyMotion/sixDofRigidBodyMotion.C pointPatchFields/derived/sixDofRigidBodyDisplacement/sixDofRigidBodyMotion/sixDofRigidBodyMotion.C
pointPatchFields/derived/sixDofRigidBodyDisplacement/sixDofRigidBodyMotion/sixDofRigidBodyMotionIO.C pointPatchFields/derived/sixDofRigidBodyDisplacement/sixDofRigidBodyMotion/sixDofRigidBodyMotionIO.C
pointPatchFields/derived/sixDofRigidBodyDisplacement/sixDofRigidBodyMotion/sixDofRigidBodyMotionState.C
pointPatchFields/derived/sixDofRigidBodyDisplacement/sixDofRigidBodyMotion/sixDofRigidBodyMotionStateIO.C
LIB = $(FOAM_LIBBIN)/libfvMotionSolvers LIB = $(FOAM_LIBBIN)/libfvMotionSolvers

View File

@ -130,7 +130,7 @@ void sixDofRigidBodyDisplacementPointPatchVectorField::updateCoeffs()
dictionary forcesDict; dictionary forcesDict;
forcesDict.add("patches", wordList(1, ptPatch.name())); forcesDict.add("patches", wordList(1, ptPatch.name()));
forcesDict.add("rhoInf", 0.0); forcesDict.add("rhoInf", 1.0);
forcesDict.add("CofR", motion_.centreOfMass()); forcesDict.add("CofR", motion_.centreOfMass());
forces f("forces", db(), forcesDict); forces f("forces", db(), forcesDict);
@ -148,22 +148,6 @@ void sixDofRigidBodyDisplacementPointPatchVectorField::updateCoeffs()
gravity = g.value(); gravity = g.value();
} }
else
{
uniformDimensionedVectorField g
(
IOobject
(
"g",
db().time().constant(),
db(),
IOobject::READ_IF_PRESENT,
IOobject::NO_WRITE
)
);
gravity = g.value();
}
motion_.updateForce motion_.updateForce
( (
@ -172,15 +156,6 @@ void sixDofRigidBodyDisplacementPointPatchVectorField::updateCoeffs()
t.deltaT().value() t.deltaT().value()
); );
// motion_.updateForce
// (
// vector::zero,
// vector::zero,
// t.deltaT().value()
// );
Info<< motion_ << endl;
Field<vector>::operator=(motion_.generatePositions(p0_) - p0_); Field<vector>::operator=(motion_.generatePositions(p0_) - p0_);
fixedValuePointPatchField<vector>::updateCoeffs(); fixedValuePointPatchField<vector>::updateCoeffs();

View File

@ -30,54 +30,47 @@ License
Foam::sixDofRigidBodyMotion::sixDofRigidBodyMotion() Foam::sixDofRigidBodyMotion::sixDofRigidBodyMotion()
: :
centreOfMass_(vector::zero), motionState_(),
refCentreOfMass_(vector::zero), refCentreOfMass_(vector::zero),
momentOfInertia_(diagTensor::one*VSMALL), momentOfInertia_(diagTensor::one*VSMALL),
mass_(VSMALL), mass_(VSMALL)
Q_(I),
v_(vector::zero),
a_(vector::zero),
pi_(vector::zero),
tau_(vector::zero)
{} {}
Foam::sixDofRigidBodyMotion::sixDofRigidBodyMotion Foam::sixDofRigidBodyMotion::sixDofRigidBodyMotion
( (
const point& centreOfMass, const point& centreOfMass,
const point& refCentreOfMass,
const diagTensor& momentOfInertia,
scalar mass,
const tensor& Q, const tensor& Q,
const vector& v, const vector& v,
const vector& a, const vector& a,
const vector& pi, const vector& pi,
const vector& tau const vector& tau,
scalar mass,
const point& refCentreOfMass,
const diagTensor& momentOfInertia
) )
: :
centreOfMass_(centreOfMass), motionState_
(
centreOfMass,
Q,
v,
a,
pi,
tau
),
refCentreOfMass_(refCentreOfMass), refCentreOfMass_(refCentreOfMass),
momentOfInertia_(momentOfInertia), momentOfInertia_(momentOfInertia),
mass_(mass), mass_(mass)
Q_(Q),
v_(v),
a_(a),
pi_(pi),
tau_(tau)
{} {}
Foam::sixDofRigidBodyMotion::sixDofRigidBodyMotion(const dictionary& dict) Foam::sixDofRigidBodyMotion::sixDofRigidBodyMotion(const dictionary& dict)
: :
centreOfMass_(dict.lookup("centreOfMass")), motionState_(dict),
refCentreOfMass_(dict.lookupOrDefault("refCentreOfMass", centreOfMass_)), refCentreOfMass_(dict.lookupOrDefault("refCentreOfMass", centreOfMass())),
momentOfInertia_(dict.lookup("momentOfInertia")), momentOfInertia_(dict.lookup("momentOfInertia")),
mass_(readScalar(dict.lookup("mass"))), mass_(readScalar(dict.lookup("mass")))
Q_(dict.lookupOrDefault("Q", tensor(I))),
v_(dict.lookupOrDefault("v", vector::zero)),
a_(dict.lookupOrDefault("a", vector::zero)),
pi_(dict.lookupOrDefault("pi", vector::zero)),
tau_(dict.lookupOrDefault("tau", vector::zero))
{} {}
@ -86,15 +79,10 @@ Foam::sixDofRigidBodyMotion::sixDofRigidBodyMotion
const sixDofRigidBodyMotion& sDofRBM const sixDofRigidBodyMotion& sDofRBM
) )
: :
centreOfMass_(sDofRBM.centreOfMass()), motionState_(sDofRBM.motionState()),
refCentreOfMass_(sDofRBM.refCentreOfMass()), refCentreOfMass_(sDofRBM.refCentreOfMass()),
momentOfInertia_(sDofRBM.momentOfInertia()), momentOfInertia_(sDofRBM.momentOfInertia()),
mass_(sDofRBM.mass()), mass_(sDofRBM.mass())
Q_(sDofRBM.Q()),
v_(sDofRBM.v()),
a_(sDofRBM.a()),
pi_(sDofRBM.pi()),
tau_(sDofRBM.tau())
{} {}
@ -114,36 +102,42 @@ void Foam::sixDofRigidBodyMotion::updatePosition
// First leapfrog velocity adjust and motion part, required before // First leapfrog velocity adjust and motion part, required before
// force calculation // force calculation
v_ += 0.5*deltaT*a_; if (Pstream::master())
{
v() += 0.5*deltaT*a();
pi_ += 0.5*deltaT*tau_; pi() += 0.5*deltaT*tau();
// Leapfrog move part // Leapfrog move part
centreOfMass_ += deltaT*v_; centreOfMass() += deltaT*v();
// Leapfrog orientation adjustment // Leapfrog orientation adjustment
tensor R; tensor R;
R = rotationTensorX(0.5*deltaT*pi_.x()/momentOfInertia_.xx()); R = rotationTensorX(0.5*deltaT*pi().x()/momentOfInertia_.xx());
pi_ = pi_ & R; pi() = pi() & R;
Q_ = Q_ & R; Q() = Q() & R;
R = rotationTensorY(0.5*deltaT*pi_.y()/momentOfInertia_.yy()); R = rotationTensorY(0.5*deltaT*pi().y()/momentOfInertia_.yy());
pi_ = pi_ & R; pi() = pi() & R;
Q_ = Q_ & R; Q() = Q() & R;
R = rotationTensorZ(deltaT*pi_.z()/momentOfInertia_.zz()); R = rotationTensorZ(deltaT*pi().z()/momentOfInertia_.zz());
pi_ = pi_ & R; pi() = pi() & R;
Q_ = Q_ & R; Q() = Q() & R;
R = rotationTensorY(0.5*deltaT*pi_.y()/momentOfInertia_.yy()); R = rotationTensorY(0.5*deltaT*pi().y()/momentOfInertia_.yy());
pi_ = pi_ & R; pi() = pi() & R;
Q_ = Q_ & R; Q() = Q() & R;
R = rotationTensorX(0.5*deltaT*pi_.x()/momentOfInertia_.xx()); R = rotationTensorX(0.5*deltaT*pi().x()/momentOfInertia_.xx());
pi_ = pi_ & R; pi() = pi() & R;
Q_ = Q_ & R; Q() = Q() & R;
}
Pstream::scatter(motionState_);
} }
@ -157,14 +151,18 @@ void Foam::sixDofRigidBodyMotion::updateForce
// Second leapfrog velocity adjust part, required after motion and // Second leapfrog velocity adjust part, required after motion and
// force calculation part // force calculation part
a_ = fGlobal/mass_; if (Pstream::master())
{
a() = fGlobal/mass_;
tau_ = (Q_.T() & tauGlobal); tau() = (Q().T() & tauGlobal);
v_ += 0.5*deltaT*a_; v() += 0.5*deltaT*a();
pi_ += 0.5*deltaT*tau_; pi() += 0.5*deltaT*tau();
}
Pstream::scatter(motionState_);
} }
@ -178,30 +176,34 @@ void Foam::sixDofRigidBodyMotion::updateForce
// Second leapfrog velocity adjust part, required after motion and // Second leapfrog velocity adjust part, required after motion and
// force calculation part // force calculation part
a_ = vector::zero; if (Pstream::master())
tau_ = vector::zero;
forAll(positions, i)
{ {
const vector& f = forces[i]; a() = vector::zero;
a_ += f/mass_; tau() = vector::zero;
tau_ += (positions[i] ^ (Q_.T() & f)); forAll(positions, i)
{
const vector& f = forces[i];
a() += f/mass_;
tau() += (positions[i] ^ (Q().T() & f));
}
v() += 0.5*deltaT*a();
pi() += 0.5*deltaT*tau();
} }
v_ += 0.5*deltaT*a_; Pstream::scatter(motionState_);
pi_ += 0.5*deltaT*tau_;
} }
Foam::tmp<Foam::pointField> Foam::tmp<Foam::pointField>
Foam::sixDofRigidBodyMotion::generatePositions(const pointField& pts) const Foam::sixDofRigidBodyMotion::generatePositions(const pointField& pts) const
{ {
return (centreOfMass_ + (Q_ & (pts - refCentreOfMass_))); return (centreOfMass() + (Q() & (pts - refCentreOfMass_)));
} }

View File

@ -53,8 +53,7 @@ SourceFiles
#ifndef sixDofRigidBodyMotion_H #ifndef sixDofRigidBodyMotion_H
#define sixDofRigidBodyMotion_H #define sixDofRigidBodyMotion_H
#include "vector.H" #include "sixDofRigidBodyMotionState.H"
#include "diagTensor.H"
#include "pointField.H" #include "pointField.H"
#include "mathConstants.H" #include "mathConstants.H"
@ -81,8 +80,8 @@ class sixDofRigidBodyMotion
{ {
// Private data // Private data
//- Current position of the centre of mass of the body // state data object
point centreOfMass_; sixDofRigidBodyMotionState motionState_;
//- Centre of mass of reference state //- Centre of mass of reference state
point refCentreOfMass_; point refCentreOfMass_;
@ -93,23 +92,6 @@ class sixDofRigidBodyMotion
//- Mass of the body //- Mass of the body
scalar mass_; scalar mass_;
//- Orientation, stored as the rotation tensor to transform
// from the body to the global reference frame, i.e.:
// globalVector = Q_ & bodyLocalVector
// bodyLocalVector = Q_.T() & globalVector
tensor Q_;
// Linear velocity of body
vector v_;
// Total linear acceleration of body
vector a_;
//- Angular momentum of body, in body local reference frame
vector pi_;
//- Total torque on body, in body local reference frame
vector tau_;
// Private Member Functions // Private Member Functions
@ -137,14 +119,14 @@ public:
sixDofRigidBodyMotion sixDofRigidBodyMotion
( (
const point& centreOfMass, const point& centreOfMass,
const point& refCentreOfMass,
const diagTensor& momentOfInertia,
scalar mass,
const tensor& Q, const tensor& Q,
const vector& v, const vector& v,
const vector& a, const vector& a,
const vector& pi, const vector& pi,
const vector& tau const vector& tau,
scalar mass,
const point& refCentreOfMass,
const diagTensor& momentOfInertia
); );
//- Construct from dictionary //- Construct from dictionary
@ -183,6 +165,9 @@ public:
// Access // Access
//- Return access to the motion state
inline const sixDofRigidBodyMotionState& motionState() const;
//- Return access to the centre of mass //- Return access to the centre of mass
inline const point& centreOfMass() const; inline const point& centreOfMass() const;

View File

@ -64,9 +64,16 @@ Foam::sixDofRigidBodyMotion::rotationTensorZ(scalar phi) const
} }
inline const Foam::sixDofRigidBodyMotionState&
Foam::sixDofRigidBodyMotion::motionState() const
{
return motionState_;
}
inline const Foam::point& Foam::sixDofRigidBodyMotion::centreOfMass() const inline const Foam::point& Foam::sixDofRigidBodyMotion::centreOfMass() const
{ {
return centreOfMass_; return motionState_.centreOfMass();
} }
@ -91,37 +98,37 @@ inline Foam::scalar Foam::sixDofRigidBodyMotion::mass() const
inline const Foam::tensor& Foam::sixDofRigidBodyMotion::Q() const inline const Foam::tensor& Foam::sixDofRigidBodyMotion::Q() const
{ {
return Q_; return motionState_.Q();
} }
inline const Foam::vector& Foam::sixDofRigidBodyMotion::v() const inline const Foam::vector& Foam::sixDofRigidBodyMotion::v() const
{ {
return v_; return motionState_.v();
} }
inline const Foam::vector& Foam::sixDofRigidBodyMotion::a() const inline const Foam::vector& Foam::sixDofRigidBodyMotion::a() const
{ {
return a_; return motionState_.a();
} }
inline const Foam::vector& Foam::sixDofRigidBodyMotion::pi() const inline const Foam::vector& Foam::sixDofRigidBodyMotion::pi() const
{ {
return pi_; return motionState_.pi();
} }
inline const Foam::vector& Foam::sixDofRigidBodyMotion::tau() const inline const Foam::vector& Foam::sixDofRigidBodyMotion::tau() const
{ {
return tau_; return motionState_.tau();
} }
inline Foam::point& Foam::sixDofRigidBodyMotion::centreOfMass() inline Foam::point& Foam::sixDofRigidBodyMotion::centreOfMass()
{ {
return centreOfMass_; return motionState_.centreOfMass();
} }
@ -145,31 +152,31 @@ inline Foam::scalar& Foam::sixDofRigidBodyMotion::mass()
inline Foam::tensor& Foam::sixDofRigidBodyMotion::Q() inline Foam::tensor& Foam::sixDofRigidBodyMotion::Q()
{ {
return Q_; return motionState_.Q();
} }
inline Foam::vector& Foam::sixDofRigidBodyMotion::v() inline Foam::vector& Foam::sixDofRigidBodyMotion::v()
{ {
return v_; return motionState_.v();
} }
inline Foam::vector& Foam::sixDofRigidBodyMotion::a() inline Foam::vector& Foam::sixDofRigidBodyMotion::a()
{ {
return a_; return motionState_.a();
} }
inline Foam::vector& Foam::sixDofRigidBodyMotion::pi() inline Foam::vector& Foam::sixDofRigidBodyMotion::pi()
{ {
return pi_; return motionState_.pi();
} }
inline Foam::vector& Foam::sixDofRigidBodyMotion::tau() inline Foam::vector& Foam::sixDofRigidBodyMotion::tau()
{ {
return tau_; return motionState_.tau();
} }

View File

@ -31,24 +31,14 @@ License
void Foam::sixDofRigidBodyMotion::write(Ostream& os) const void Foam::sixDofRigidBodyMotion::write(Ostream& os) const
{ {
os.writeKeyword("centreOfMass") motionState_.write(os);
<< centreOfMass_ << token::END_STATEMENT << nl;
os.writeKeyword("refCentreOfMass") os.writeKeyword("refCentreOfMass")
<< refCentreOfMass_ << token::END_STATEMENT << nl; << refCentreOfMass_ << token::END_STATEMENT << nl;
os.writeKeyword("momentOfInertia") os.writeKeyword("momentOfInertia")
<< momentOfInertia_ << token::END_STATEMENT << nl; << momentOfInertia_ << token::END_STATEMENT << nl;
os.writeKeyword("mass") os.writeKeyword("mass")
<< mass_ << token::END_STATEMENT << nl; << mass_ << token::END_STATEMENT << nl;
os.writeKeyword("Q")
<< Q_ << token::END_STATEMENT << nl;
os.writeKeyword("v")
<< v_ << token::END_STATEMENT << nl;
os.writeKeyword("a")
<< a_ << token::END_STATEMENT << nl;
os.writeKeyword("pi")
<< pi_ << token::END_STATEMENT << nl;
os.writeKeyword("tau")
<< tau_ << token::END_STATEMENT << nl;
} }
@ -56,15 +46,10 @@ void Foam::sixDofRigidBodyMotion::write(Ostream& os) const
Foam::Istream& Foam::operator>>(Istream& is, sixDofRigidBodyMotion& sDofRBM) Foam::Istream& Foam::operator>>(Istream& is, sixDofRigidBodyMotion& sDofRBM)
{ {
is >> sDofRBM.centreOfMass_ is >> sDofRBM.motionState_
>> sDofRBM.refCentreOfMass_ >> sDofRBM.refCentreOfMass_
>> sDofRBM.momentOfInertia_ >> sDofRBM.momentOfInertia_
>> sDofRBM.mass_ >> sDofRBM.mass_;
>> sDofRBM.Q_
>> sDofRBM.v_
>> sDofRBM.a_
>> sDofRBM.pi_
>> sDofRBM.tau_;
// Check state of Istream // Check state of Istream
is.check is.check
@ -83,15 +68,10 @@ Foam::Ostream& Foam::operator<<
const sixDofRigidBodyMotion& sDofRBM const sixDofRigidBodyMotion& sDofRBM
) )
{ {
os << token::SPACE << sDofRBM.centreOfMass() os << sDofRBM.motionState()
<< token::SPACE << sDofRBM.refCentreOfMass() << token::SPACE << sDofRBM.refCentreOfMass()
<< token::SPACE << sDofRBM.momentOfInertia() << token::SPACE << sDofRBM.momentOfInertia()
<< token::SPACE << sDofRBM.mass() << token::SPACE << sDofRBM.mass() ;
<< token::SPACE << sDofRBM.Q()
<< token::SPACE << sDofRBM.v()
<< token::SPACE << sDofRBM.a()
<< token::SPACE << sDofRBM.pi()
<< token::SPACE << sDofRBM.tau();
// Check state of Ostream // Check state of Ostream
os.check os.check

View File

@ -0,0 +1,95 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2009-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM 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 2 of the License, or (at your
option) any later version.
OpenFOAM 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 OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "sixDofRigidBodyMotionState.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::sixDofRigidBodyMotionState::sixDofRigidBodyMotionState()
:
centreOfMass_(vector::zero),
Q_(I),
v_(vector::zero),
a_(vector::zero),
pi_(vector::zero),
tau_(vector::zero)
{}
Foam::sixDofRigidBodyMotionState::sixDofRigidBodyMotionState
(
const point& centreOfMass,
const tensor& Q,
const vector& v,
const vector& a,
const vector& pi,
const vector& tau
)
:
centreOfMass_(centreOfMass),
Q_(Q),
v_(v),
a_(a),
pi_(pi),
tau_(tau)
{}
Foam::sixDofRigidBodyMotionState::sixDofRigidBodyMotionState
(
const dictionary& dict
)
:
centreOfMass_(dict.lookup("centreOfMass")),
Q_(dict.lookupOrDefault("Q", tensor(I))),
v_(dict.lookupOrDefault("v", vector::zero)),
a_(dict.lookupOrDefault("a", vector::zero)),
pi_(dict.lookupOrDefault("pi", vector::zero)),
tau_(dict.lookupOrDefault("tau", vector::zero))
{}
Foam::sixDofRigidBodyMotionState::sixDofRigidBodyMotionState
(
const sixDofRigidBodyMotionState& sDofRBMS
)
:
centreOfMass_(sDofRBMS.centreOfMass()),
Q_(sDofRBMS.Q()),
v_(sDofRBMS.v()),
a_(sDofRBMS.a()),
pi_(sDofRBMS.pi()),
tau_(sDofRBMS.tau())
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::sixDofRigidBodyMotionState::~sixDofRigidBodyMotionState()
{}
// ************************************************************************* //

View File

@ -0,0 +1,194 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2009-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM 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 2 of the License, or (at your
option) any later version.
OpenFOAM 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 OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::sixDofRigidBodyMotionState
Description
Holds the motion state of sixDof object. Wrapped up together
to allow rapid scatter to other processors. The processors must all
maintain exactly the same state data to avoid any drift or inconsistency.
SourceFiles
sixDofRigidBodyMotionStateI.H
sixDofRigidBodyMotionState.C
sixDofRigidBodyMotionStateIO.C
\*---------------------------------------------------------------------------*/
#ifndef sixDofRigidBodyMotionState_H
#define sixDofRigidBodyMotionState_H
#include "vector.H"
#include "point.H"
#include "diagTensor.H"
#include "tensor.H"
#include "dictionary.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of classes
class Istream;
class Ostream;
// Forward declaration of friend functions and operators
class sixDofRigidBodyMotionState;
Istream& operator>>(Istream&, sixDofRigidBodyMotionState&);
Ostream& operator<<(Ostream&, const sixDofRigidBodyMotionState&);
/*---------------------------------------------------------------------------*\
Class sixDofRigidBodyMotionState Declaration
\*---------------------------------------------------------------------------*/
class sixDofRigidBodyMotionState
{
// Private data
//- Current position of the centre of mass of the body
point centreOfMass_;
//- Orientation, stored as the rotation tensor to transform
// from the body to the global reference frame, i.e.:
// globalVector = Q_ & bodyLocalVector
// bodyLocalVector = Q_.T() & globalVector
tensor Q_;
// Linear velocity of body
vector v_;
// Total linear acceleration of body
vector a_;
//- Angular momentum of body, in body local reference frame
vector pi_;
//- Total torque on body, in body local reference frame
vector tau_;
public:
// Constructors
//- Construct null
sixDofRigidBodyMotionState();
//- Construct from components
sixDofRigidBodyMotionState
(
const point& centreOfMass,
const tensor& Q,
const vector& v,
const vector& a,
const vector& pi,
const vector& tau
);
//- Construct from dictionary
sixDofRigidBodyMotionState(const dictionary& dict);
//- Construct as copy
sixDofRigidBodyMotionState(const sixDofRigidBodyMotionState&);
//- Destructor
~sixDofRigidBodyMotionState();
// Member Functions
// Access
//- Return access to the centre of mass
inline const point& centreOfMass() const;
//- Return access to the orientation
inline const tensor& Q() const;
//- Return access to velocity
inline const vector& v() const;
//- Return access to acceleration
inline const vector& a() const;
//- Return access to angular momentum
inline const vector& pi() const;
//- Return access to torque
inline const vector& tau() const;
// Edit
//- Return non-const access to the centre of mass
inline point& centreOfMass();
//- Return non-const access to the orientation
inline tensor& Q();
//- Return non-const access to vector
inline vector& v();
//- Return non-const access to acceleration
inline vector& a();
//- Return non-const access to angular momentum
inline vector& pi();
//- Return non-const access to torque
inline vector& tau();
//- Write
void write(Ostream&) const;
// Friend Functions
// Friend Operators
// IOstream Operators
friend Istream& operator>>(Istream&, sixDofRigidBodyMotionState&);
friend Ostream& operator<<(Ostream&, const sixDofRigidBodyMotionState&);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "sixDofRigidBodyMotionStateI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,102 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2009-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM 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 2 of the License, or (at your
option) any later version.
OpenFOAM 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 OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline const Foam::point& Foam::sixDofRigidBodyMotionState::centreOfMass() const
{
return centreOfMass_;
}
inline const Foam::tensor& Foam::sixDofRigidBodyMotionState::Q() const
{
return Q_;
}
inline const Foam::vector& Foam::sixDofRigidBodyMotionState::v() const
{
return v_;
}
inline const Foam::vector& Foam::sixDofRigidBodyMotionState::a() const
{
return a_;
}
inline const Foam::vector& Foam::sixDofRigidBodyMotionState::pi() const
{
return pi_;
}
inline const Foam::vector& Foam::sixDofRigidBodyMotionState::tau() const
{
return tau_;
}
inline Foam::point& Foam::sixDofRigidBodyMotionState::centreOfMass()
{
return centreOfMass_;
}
inline Foam::tensor& Foam::sixDofRigidBodyMotionState::Q()
{
return Q_;
}
inline Foam::vector& Foam::sixDofRigidBodyMotionState::v()
{
return v_;
}
inline Foam::vector& Foam::sixDofRigidBodyMotionState::a()
{
return a_;
}
inline Foam::vector& Foam::sixDofRigidBodyMotionState::pi()
{
return pi_;
}
inline Foam::vector& Foam::sixDofRigidBodyMotionState::tau()
{
return tau_;
}
// ************************************************************************* //

View File

@ -0,0 +1,98 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2009-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM 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 2 of the License, or (at your
option) any later version.
OpenFOAM 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 OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "sixDofRigidBodyMotionState.H"
#include "IOstreams.H"
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
void Foam::sixDofRigidBodyMotionState::write(Ostream& os) const
{
os.writeKeyword("centreOfMass")
<< centreOfMass_ << token::END_STATEMENT << nl;
os.writeKeyword("Q")
<< Q_ << token::END_STATEMENT << nl;
os.writeKeyword("v")
<< v_ << token::END_STATEMENT << nl;
os.writeKeyword("a")
<< a_ << token::END_STATEMENT << nl;
os.writeKeyword("pi")
<< pi_ << token::END_STATEMENT << nl;
os.writeKeyword("tau")
<< tau_ << token::END_STATEMENT << nl;
}
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
Foam::Istream& Foam::operator>>
(
Istream& is, sixDofRigidBodyMotionState& sDofRBMS
)
{
is >> sDofRBMS.centreOfMass_
>> sDofRBMS.Q_
>> sDofRBMS.v_
>> sDofRBMS.a_
>> sDofRBMS.pi_
>> sDofRBMS.tau_;
// Check state of Istream
is.check
(
"Foam::Istream& Foam::operator>>"
"(Foam::Istream&, Foam::sixDofRigidBodyMotionState&)"
);
return is;
}
Foam::Ostream& Foam::operator<<
(
Ostream& os,
const sixDofRigidBodyMotionState& sDofRBMS
)
{
os << token::SPACE << sDofRBMS.centreOfMass()
<< token::SPACE << sDofRBMS.Q()
<< token::SPACE << sDofRBMS.v()
<< token::SPACE << sDofRBMS.a()
<< token::SPACE << sDofRBMS.pi()
<< token::SPACE << sDofRBMS.tau();
// Check state of Ostream
os.check
(
"Foam::Ostream& Foam::operator<<(Foam::Ostream&, "
"const Foam::sixDofRigidBodyMotionState&)"
);
return os;
}
// ************************************************************************* //