Reorganised the location of the "sixDoFRigidBodyDisplacement" BC to avoid unnecessary

dependency on the libforces.so and the libraries it requires.
This commit is contained in:
henry
2009-12-08 22:35:35 +00:00
parent d92ea78c11
commit ddfd9da81f
10 changed files with 0 additions and 0 deletions

View File

@ -0,0 +1,192 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-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 "sixDoFRigidBodyDisplacementPointPatchVectorField.H"
#include "pointPatchFields.H"
#include "addToRunTimeSelectionTable.H"
#include "Time.H"
#include "fvMesh.H"
#include "volFields.H"
#include "uniformDimensionedFields.H"
#include "forces.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
sixDoFRigidBodyDisplacementPointPatchVectorField::
sixDoFRigidBodyDisplacementPointPatchVectorField
(
const pointPatch& p,
const DimensionedField<vector, pointMesh>& iF
)
:
fixedValuePointPatchField<vector>(p, iF),
motion_(),
p0_(p.localPoints()),
rhoInf_(1.0)
{}
sixDoFRigidBodyDisplacementPointPatchVectorField::
sixDoFRigidBodyDisplacementPointPatchVectorField
(
const pointPatch& p,
const DimensionedField<vector, pointMesh>& iF,
const dictionary& dict
)
:
fixedValuePointPatchField<vector>(p, iF, dict),
motion_(dict),
rhoInf_(readScalar(dict.lookup("rhoInf")))
{
if (!dict.found("value"))
{
updateCoeffs();
}
if (dict.found("p0"))
{
p0_ = vectorField("p0", dict , p.size());
}
else
{
p0_ = p.localPoints();
}
}
sixDoFRigidBodyDisplacementPointPatchVectorField::
sixDoFRigidBodyDisplacementPointPatchVectorField
(
const sixDoFRigidBodyDisplacementPointPatchVectorField& ptf,
const pointPatch& p,
const DimensionedField<vector, pointMesh>& iF,
const pointPatchFieldMapper& mapper
)
:
fixedValuePointPatchField<vector>(ptf, p, iF, mapper),
motion_(ptf.motion_),
p0_(ptf.p0_, mapper),
rhoInf_(ptf.rhoInf_)
{}
sixDoFRigidBodyDisplacementPointPatchVectorField::
sixDoFRigidBodyDisplacementPointPatchVectorField
(
const sixDoFRigidBodyDisplacementPointPatchVectorField& ptf,
const DimensionedField<vector, pointMesh>& iF
)
:
fixedValuePointPatchField<vector>(ptf, iF),
motion_(ptf.motion_),
p0_(ptf.p0_),
rhoInf_(ptf.rhoInf_)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void sixDoFRigidBodyDisplacementPointPatchVectorField::updateCoeffs()
{
if (this->updated())
{
return;
}
const polyMesh& mesh = this->dimensionedInternalField().mesh()();
const Time& t = mesh.time();
const pointPatch& ptPatch = this->patch();
// Patch force data is valid for the current positions, so
// calculate the forces on the motion object from this data, then
// update the positions
motion_.updatePosition(t.deltaTValue());
dictionary forcesDict;
forcesDict.add("patches", wordList(1, ptPatch.name()));
forcesDict.add("rhoInf", rhoInf_);
forcesDict.add("CofR", motion_.centreOfMass());
forces f("forces", db(), forcesDict);
forces::forcesMoments fm = f.calcForcesMoment();
// Get the forces on the patch faces at the current positions
vector gravity = vector::zero;
if (db().foundObject<uniformDimensionedVectorField>("g"))
{
uniformDimensionedVectorField g =
db().lookupObject<uniformDimensionedVectorField>("g");
gravity = g.value();
}
motion_.updateForce
(
fm.first().first() + fm.first().second() + gravity*motion_.mass(),
fm.second().first() + fm.second().second(),
t.deltaTValue()
);
Field<vector>::operator=(motion_.generatePositions(p0_) - p0_);
fixedValuePointPatchField<vector>::updateCoeffs();
}
void sixDoFRigidBodyDisplacementPointPatchVectorField::write(Ostream& os) const
{
pointPatchField<vector>::write(os);
motion_.write(os);
os.writeKeyword("rhoInf")
<< rhoInf_ << token::END_STATEMENT << nl;
p0_.writeEntry("p0", os);
writeEntry("value", os);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
makePointPatchTypeField
(
pointPatchVectorField,
sixDoFRigidBodyDisplacementPointPatchVectorField
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -0,0 +1,157 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-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::sixDoFRigidBodyDisplacementPointPatchVectorField
Description
Foam::sixDoFRigidBodyDisplacementPointPatchVectorField
SourceFiles
sixDoFRigidBodyDisplacementPointPatchVectorField.C
\*---------------------------------------------------------------------------*/
#ifndef sixDoFRigidBodyDisplacementPointPatchVectorField_H
#define sixDoFRigidBodyDisplacementPointPatchVectorField_H
#include "fixedValuePointPatchField.H"
#include "sixDoFRigidBodyMotion.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class sixDoFRigidBodyDisplacementPointPatchVectorField Declaration
\*---------------------------------------------------------------------------*/
class sixDoFRigidBodyDisplacementPointPatchVectorField
:
public fixedValuePointPatchField<vector>
{
// Private data
//- Six dof motion object
sixDoFRigidBodyMotion motion_;
//- Reference positions of points on the patch
pointField p0_;
//- Reference density required by the forces object for
// incompressible calculations
scalar rhoInf_;
public:
//- Runtime type information
TypeName("sixDoFRigidBodyDisplacement");
// Constructors
//- Construct from patch and internal field
sixDoFRigidBodyDisplacementPointPatchVectorField
(
const pointPatch&,
const DimensionedField<vector, pointMesh>&
);
//- Construct from patch, internal field and dictionary
sixDoFRigidBodyDisplacementPointPatchVectorField
(
const pointPatch&,
const DimensionedField<vector, pointMesh>&,
const dictionary&
);
//- Construct by mapping given patchField<vector> onto a new patch
sixDoFRigidBodyDisplacementPointPatchVectorField
(
const sixDoFRigidBodyDisplacementPointPatchVectorField&,
const pointPatch&,
const DimensionedField<vector, pointMesh>&,
const pointPatchFieldMapper&
);
//- Construct and return a clone
virtual autoPtr<pointPatchField<vector> > clone() const
{
return autoPtr<pointPatchField<vector> >
(
new sixDoFRigidBodyDisplacementPointPatchVectorField
(
*this
)
);
}
//- Construct as copy setting internal field reference
sixDoFRigidBodyDisplacementPointPatchVectorField
(
const sixDoFRigidBodyDisplacementPointPatchVectorField&,
const DimensionedField<vector, pointMesh>&
);
//- Construct and return a clone setting internal field reference
virtual autoPtr<pointPatchField<vector> > clone
(
const DimensionedField<vector, pointMesh>& iF
) const
{
return autoPtr<pointPatchField<vector> >
(
new sixDoFRigidBodyDisplacementPointPatchVectorField
(
*this,
iF
)
);
}
// Member functions
// Evaluation functions
//- Update the coefficients associated with the patch field
virtual void updateCoeffs();
//- Write
virtual void write(Ostream&) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,210 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 "sixDoFRigidBodyMotion.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::sixDoFRigidBodyMotion::sixDoFRigidBodyMotion()
:
motionState_(),
refCentreOfMass_(vector::zero),
momentOfInertia_(diagTensor::one*VSMALL),
mass_(VSMALL)
{}
Foam::sixDoFRigidBodyMotion::sixDoFRigidBodyMotion
(
const point& centreOfMass,
const tensor& Q,
const vector& v,
const vector& a,
const vector& pi,
const vector& tau,
scalar mass,
const point& refCentreOfMass,
const diagTensor& momentOfInertia
)
:
motionState_
(
centreOfMass,
Q,
v,
a,
pi,
tau
),
refCentreOfMass_(refCentreOfMass),
momentOfInertia_(momentOfInertia),
mass_(mass)
{}
Foam::sixDoFRigidBodyMotion::sixDoFRigidBodyMotion(const dictionary& dict)
:
motionState_(dict),
refCentreOfMass_(dict.lookupOrDefault("refCentreOfMass", centreOfMass())),
momentOfInertia_(dict.lookup("momentOfInertia")),
mass_(readScalar(dict.lookup("mass")))
{}
Foam::sixDoFRigidBodyMotion::sixDoFRigidBodyMotion
(
const sixDoFRigidBodyMotion& sDoFRBM
)
:
motionState_(sDoFRBM.motionState()),
refCentreOfMass_(sDoFRBM.refCentreOfMass()),
momentOfInertia_(sDoFRBM.momentOfInertia()),
mass_(sDoFRBM.mass())
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::sixDoFRigidBodyMotion::~sixDoFRigidBodyMotion()
{}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
void Foam::sixDoFRigidBodyMotion::updatePosition
(
scalar deltaT
)
{
// First leapfrog velocity adjust and motion part, required before
// force calculation
if (Pstream::master())
{
v() += 0.5*deltaT*a();
pi() += 0.5*deltaT*tau();
// Leapfrog move part
centreOfMass() += deltaT*v();
// Leapfrog orientation adjustment
tensor R;
R = rotationTensorX(0.5*deltaT*pi().x()/momentOfInertia_.xx());
pi() = pi() & R;
Q() = Q() & R;
R = rotationTensorY(0.5*deltaT*pi().y()/momentOfInertia_.yy());
pi() = pi() & R;
Q() = Q() & R;
R = rotationTensorZ(deltaT*pi().z()/momentOfInertia_.zz());
pi() = pi() & R;
Q() = Q() & R;
R = rotationTensorY(0.5*deltaT*pi().y()/momentOfInertia_.yy());
pi() = pi() & R;
Q() = Q() & R;
R = rotationTensorX(0.5*deltaT*pi().x()/momentOfInertia_.xx());
pi() = pi() & R;
Q() = Q() & R;
}
Pstream::scatter(motionState_);
}
void Foam::sixDoFRigidBodyMotion::updateForce
(
const vector& fGlobal,
const vector& tauGlobal,
scalar deltaT
)
{
// Second leapfrog velocity adjust part, required after motion and
// force calculation part
if (Pstream::master())
{
a() = fGlobal/mass_;
tau() = (Q().T() & tauGlobal);
v() += 0.5*deltaT*a();
pi() += 0.5*deltaT*tau();
}
Pstream::scatter(motionState_);
}
void Foam::sixDoFRigidBodyMotion::updateForce
(
const pointField& positions,
const vectorField& forces,
scalar deltaT
)
{
// Second leapfrog velocity adjust part, required after motion and
// force calculation part
if (Pstream::master())
{
a() = vector::zero;
tau() = vector::zero;
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();
}
Pstream::scatter(motionState_);
}
Foam::tmp<Foam::pointField>
Foam::sixDoFRigidBodyMotion::generatePositions(const pointField& pts) const
{
return (centreOfMass() + (Q() & (pts - refCentreOfMass_)));
}
// ************************************************************************* //

View File

@ -0,0 +1,251 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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::sixDoFRigidBodyMotion
Description
Six degree of freedom motion for a rigid body. Angular momentum stored in
body fixed reference frame. Reference orientation of the body must align
with the cartesian axes such that the Inertia tensor is in principle
component form.
Symplectic motion as per:
title = {Symplectic splitting methods for rigid body molecular dynamics},
publisher = {AIP},
year = {1997},
journal = {The Journal of Chemical Physics},
volume = {107},
number = {15},
pages = {5840-5851},
url = {http://link.aip.org/link/?JCP/107/5840/1},
doi = {10.1063/1.474310}
SourceFiles
sixDoFRigidBodyMotionI.H
sixDoFRigidBodyMotion.C
sixDoFRigidBodyMotionIO.C
\*---------------------------------------------------------------------------*/
#ifndef sixDoFRigidBodyMotion_H
#define sixDoFRigidBodyMotion_H
#include "sixDoFRigidBodyMotionState.H"
#include "pointField.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of classes
class Istream;
class Ostream;
// Forward declaration of friend functions and operators
class sixDoFRigidBodyMotion;
Istream& operator>>(Istream&, sixDoFRigidBodyMotion&);
Ostream& operator<<(Ostream&, const sixDoFRigidBodyMotion&);
/*---------------------------------------------------------------------------*\
Class sixDoFRigidBodyMotion Declaration
\*---------------------------------------------------------------------------*/
class sixDoFRigidBodyMotion
{
// Private data
// state data object
sixDoFRigidBodyMotionState motionState_;
//- Centre of mass of reference state
point refCentreOfMass_;
//- Moment of inertia of the body in reference configuration
diagTensor momentOfInertia_;
//- Mass of the body
scalar mass_;
// Private Member Functions
//- Calculate the rotation tensor around the body reference
// frame x-axis by the given angle
inline tensor rotationTensorX(scalar deltaT) const;
//- Calculate the rotation tensor around the body reference
// frame y-axis by the given angle
inline tensor rotationTensorY(scalar deltaT) const;
//- Calculate the rotation tensor around the body reference
// frame z-axis by the given angle
inline tensor rotationTensorZ(scalar deltaT) const;
public:
// Constructors
//- Construct null
sixDoFRigidBodyMotion();
//- Construct from components
sixDoFRigidBodyMotion
(
const point& centreOfMass,
const tensor& Q,
const vector& v,
const vector& a,
const vector& pi,
const vector& tau,
scalar mass,
const point& refCentreOfMass,
const diagTensor& momentOfInertia
);
//- Construct from dictionary
sixDoFRigidBodyMotion(const dictionary& dict);
//- Construct as copy
sixDoFRigidBodyMotion(const sixDoFRigidBodyMotion&);
//- Destructor
~sixDoFRigidBodyMotion();
// Member Functions
void updatePosition
(
scalar deltaT
);
void updateForce
(
const vector& fGlobal,
const vector& tauGlobal,
scalar deltaT
);
void updateForce
(
const pointField& positions,
const vectorField& forces,
scalar deltaT
);
tmp<pointField> generatePositions(const pointField& pts) const;
// Access
//- Return access to the motion state
inline const sixDoFRigidBodyMotionState& motionState() const;
//- Return access to the centre of mass
inline const point& centreOfMass() const;
//- Return access to the centre of mass
inline const point& refCentreOfMass() const;
//- Return access to the inertia tensor
inline const diagTensor& momentOfInertia() const;
//- Return access to the mass
inline scalar mass() 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 access to the centre of mass
inline point& refCentreOfMass();
//- Return non-const access to the inertia tensor
inline diagTensor& momentOfInertia();
//- Return non-const access to the mass
inline scalar& mass();
//- 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;
// IOstream Operators
friend Istream& operator>>(Istream&, sixDoFRigidBodyMotion&);
friend Ostream& operator<<(Ostream&, const sixDoFRigidBodyMotion&);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "sixDoFRigidBodyMotionI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,183 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
inline Foam::tensor
Foam::sixDoFRigidBodyMotion::rotationTensorX(scalar phi) const
{
return tensor
(
1, 0, 0,
0, Foam::cos(phi), -Foam::sin(phi),
0, Foam::sin(phi), Foam::cos(phi)
);
}
inline Foam::tensor
Foam::sixDoFRigidBodyMotion::rotationTensorY(scalar phi) const
{
return tensor
(
Foam::cos(phi), 0, Foam::sin(phi),
0, 1, 0,
-Foam::sin(phi), 0, Foam::cos(phi)
);
}
inline Foam::tensor
Foam::sixDoFRigidBodyMotion::rotationTensorZ(scalar phi) const
{
return tensor
(
Foam::cos(phi), -Foam::sin(phi), 0,
Foam::sin(phi), Foam::cos(phi), 0,
0, 0, 1
);
}
inline const Foam::sixDoFRigidBodyMotionState&
Foam::sixDoFRigidBodyMotion::motionState() const
{
return motionState_;
}
inline const Foam::point& Foam::sixDoFRigidBodyMotion::centreOfMass() const
{
return motionState_.centreOfMass();
}
inline const Foam::point& Foam::sixDoFRigidBodyMotion::refCentreOfMass() const
{
return refCentreOfMass_;
}
inline const Foam::diagTensor&
Foam::sixDoFRigidBodyMotion::momentOfInertia() const
{
return momentOfInertia_;
}
inline Foam::scalar Foam::sixDoFRigidBodyMotion::mass() const
{
return mass_;
}
inline const Foam::tensor& Foam::sixDoFRigidBodyMotion::Q() const
{
return motionState_.Q();
}
inline const Foam::vector& Foam::sixDoFRigidBodyMotion::v() const
{
return motionState_.v();
}
inline const Foam::vector& Foam::sixDoFRigidBodyMotion::a() const
{
return motionState_.a();
}
inline const Foam::vector& Foam::sixDoFRigidBodyMotion::pi() const
{
return motionState_.pi();
}
inline const Foam::vector& Foam::sixDoFRigidBodyMotion::tau() const
{
return motionState_.tau();
}
inline Foam::point& Foam::sixDoFRigidBodyMotion::centreOfMass()
{
return motionState_.centreOfMass();
}
inline Foam::point& Foam::sixDoFRigidBodyMotion::refCentreOfMass()
{
return refCentreOfMass_;
}
inline Foam::diagTensor& Foam::sixDoFRigidBodyMotion::momentOfInertia()
{
return momentOfInertia_;
}
inline Foam::scalar& Foam::sixDoFRigidBodyMotion::mass()
{
return mass_;
}
inline Foam::tensor& Foam::sixDoFRigidBodyMotion::Q()
{
return motionState_.Q();
}
inline Foam::vector& Foam::sixDoFRigidBodyMotion::v()
{
return motionState_.v();
}
inline Foam::vector& Foam::sixDoFRigidBodyMotion::a()
{
return motionState_.a();
}
inline Foam::vector& Foam::sixDoFRigidBodyMotion::pi()
{
return motionState_.pi();
}
inline Foam::vector& Foam::sixDoFRigidBodyMotion::tau()
{
return motionState_.tau();
}
// ************************************************************************* //

View File

@ -0,0 +1,87 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 "sixDoFRigidBodyMotion.H"
#include "IOstreams.H"
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
void Foam::sixDoFRigidBodyMotion::write(Ostream& os) const
{
motionState_.write(os);
os.writeKeyword("refCentreOfMass")
<< refCentreOfMass_ << token::END_STATEMENT << nl;
os.writeKeyword("momentOfInertia")
<< momentOfInertia_ << token::END_STATEMENT << nl;
os.writeKeyword("mass")
<< mass_ << token::END_STATEMENT << nl;
}
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
Foam::Istream& Foam::operator>>(Istream& is, sixDoFRigidBodyMotion& sDoFRBM)
{
is >> sDoFRBM.motionState_
>> sDoFRBM.refCentreOfMass_
>> sDoFRBM.momentOfInertia_
>> sDoFRBM.mass_;
// Check state of Istream
is.check
(
"Foam::Istream& Foam::operator>>"
"(Foam::Istream&, Foam::sixDoFRigidBodyMotion&)"
);
return is;
}
Foam::Ostream& Foam::operator<<
(
Ostream& os,
const sixDoFRigidBodyMotion& sDoFRBM
)
{
os << sDoFRBM.motionState()
<< token::SPACE << sDoFRBM.refCentreOfMass()
<< token::SPACE << sDoFRBM.momentOfInertia()
<< token::SPACE << sDoFRBM.mass() ;
// Check state of Ostream
os.check
(
"Foam::Ostream& Foam::operator<<(Foam::Ostream&, "
"const Foam::sixDoFRigidBodyMotion&)"
);
return os;
}
// ************************************************************************* //

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