diff --git a/src/fvMotionSolver/Make/files b/src/fvMotionSolver/Make/files index f229ae322ef04b4bf61dd4bb0eb336fed3764e48..bd1bb87ede2b32056614a854307fa267f09ed13f 100644 --- a/src/fvMotionSolver/Make/files +++ b/src/fvMotionSolver/Make/files @@ -31,5 +31,8 @@ pointPatchFields/derived/oscillatingDisplacement/oscillatingDisplacementPointPat pointPatchFields/derived/angularOscillatingDisplacement/angularOscillatingDisplacementPointPatchVectorField.C pointPatchFields/derived/surfaceSlipDisplacement/surfaceSlipDisplacementPointPatchVectorField.C pointPatchFields/derived/surfaceDisplacement/surfaceDisplacementPointPatchVectorField.C +pointPatchFields/derived/sixDofRigidBodyDisplacement/sixDofRigidBodyDisplacementPointPatchVectorField.C +pointPatchFields/derived/sixDofRigidBodyDisplacement/sixDofRigidBodyMotion/sixDofRigidBodyMotion.C +pointPatchFields/derived/sixDofRigidBodyDisplacement/sixDofRigidBodyMotion/sixDofRigidBodyMotionIO.C LIB = $(FOAM_LIBBIN)/libfvMotionSolvers diff --git a/src/fvMotionSolver/Make/options b/src/fvMotionSolver/Make/options index 966b56964d720cb3acf3a2f006a63d6b14284ef5..9222d5f97c8e43b80117b51b5d21abc1216f2d71 100644 --- a/src/fvMotionSolver/Make/options +++ b/src/fvMotionSolver/Make/options @@ -2,10 +2,12 @@ EXE_INC = \ -I$(LIB_SRC)/triSurface/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude \ -I$(LIB_SRC)/dynamicMesh/lnInclude \ - -I$(LIB_SRC)/finiteVolume/lnInclude + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/postProcessing/functionObjects/forces/lnInclude \ LIB_LIBS = \ -ltriSurface \ -lmeshTools \ -ldynamicMesh \ - -lfiniteVolume + -lfiniteVolume \ + -lforces diff --git a/src/fvMotionSolver/pointPatchFields/derived/sixDofRigidBodyDisplacement/sixDofRigidBodyDisplacementPointPatchVectorField.C b/src/fvMotionSolver/pointPatchFields/derived/sixDofRigidBodyDisplacement/sixDofRigidBodyDisplacementPointPatchVectorField.C new file mode 100644 index 0000000000000000000000000000000000000000..ddfe3d94cbfc1712452b3e2ed3a8e391cd5f6ca1 --- /dev/null +++ b/src/fvMotionSolver/pointPatchFields/derived/sixDofRigidBodyDisplacement/sixDofRigidBodyDisplacementPointPatchVectorField.C @@ -0,0 +1,211 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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()) +{} + + +sixDofRigidBodyDisplacementPointPatchVectorField:: +sixDofRigidBodyDisplacementPointPatchVectorField +( + const pointPatch& p, + const DimensionedField<vector, pointMesh>& iF, + const dictionary& dict +) +: + fixedValuePointPatchField<vector>(p, iF, dict), + motion_(dict) +{ + 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_) +{} + + +sixDofRigidBodyDisplacementPointPatchVectorField:: +sixDofRigidBodyDisplacementPointPatchVectorField +( + const sixDofRigidBodyDisplacementPointPatchVectorField& ptf, + const DimensionedField<vector, pointMesh>& iF +) +: + fixedValuePointPatchField<vector>(ptf, iF), + motion_(ptf.motion_), + p0_(ptf.p0_) +{} + + +// * * * * * * * * * * * * * * * 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.deltaT().value()); + + dictionary forcesDict; + + forcesDict.add("patches", wordList(1, ptPatch.name())); + forcesDict.add("rhoInf", 0.0); + 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(); + } + else + { + uniformDimensionedVectorField g + ( + IOobject + ( + "g", + db().time().constant(), + db(), + IOobject::READ_IF_PRESENT, + IOobject::NO_WRITE + ) + ); + + gravity = g.value(); + } + + motion_.updateForce + ( + fm.first().first() + fm.first().second() + gravity*motion_.mass(), + fm.second().first() + fm.second().second(), + t.deltaT().value() + ); + + // motion_.updateForce + // ( + // vector::zero, + // vector::zero, + // t.deltaT().value() + // ); + + Info<< motion_ << endl; + + Field<vector>::operator=(motion_.generatePositions(p0_) - p0_); + + fixedValuePointPatchField<vector>::updateCoeffs(); +} + + +void sixDofRigidBodyDisplacementPointPatchVectorField::write(Ostream& os) const +{ + pointPatchField<vector>::write(os); + motion_.write(os); + p0_.writeEntry("p0", os); + writeEntry("value", os); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makePointPatchTypeField +( + pointPatchVectorField, + sixDofRigidBodyDisplacementPointPatchVectorField +); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/fvMotionSolver/pointPatchFields/derived/sixDofRigidBodyDisplacement/sixDofRigidBodyDisplacementPointPatchVectorField.H b/src/fvMotionSolver/pointPatchFields/derived/sixDofRigidBodyDisplacement/sixDofRigidBodyDisplacementPointPatchVectorField.H new file mode 100644 index 0000000000000000000000000000000000000000..b619baa3f24e02560fe15c8b2edd8ed3e0a49ba3 --- /dev/null +++ b/src/fvMotionSolver/pointPatchFields/derived/sixDofRigidBodyDisplacement/sixDofRigidBodyDisplacementPointPatchVectorField.H @@ -0,0 +1,153 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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_; + + +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 + +// ************************************************************************* // diff --git a/src/fvMotionSolver/pointPatchFields/derived/sixDofRigidBodyDisplacement/sixDofRigidBodyMotion/sixDofRigidBodyMotion.C b/src/fvMotionSolver/pointPatchFields/derived/sixDofRigidBodyDisplacement/sixDofRigidBodyMotion/sixDofRigidBodyMotion.C new file mode 100644 index 0000000000000000000000000000000000000000..02ad37e4416de104796d267548107c6188f0781b --- /dev/null +++ b/src/fvMotionSolver/pointPatchFields/derived/sixDofRigidBodyDisplacement/sixDofRigidBodyMotion/sixDofRigidBodyMotion.C @@ -0,0 +1,208 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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() +: + centreOfMass_(vector::zero), + refCentreOfMass_(vector::zero), + momentOfInertia_(diagTensor::one*VSMALL), + mass_(VSMALL), + Q_(I), + v_(vector::zero), + a_(vector::zero), + pi_(vector::zero), + tau_(vector::zero) +{} + + +Foam::sixDofRigidBodyMotion::sixDofRigidBodyMotion +( + const point& centreOfMass, + const point& refCentreOfMass, + const diagTensor& momentOfInertia, + scalar mass, + const tensor& Q, + const vector& v, + const vector& a, + const vector& pi, + const vector& tau +) +: + centreOfMass_(centreOfMass), + refCentreOfMass_(refCentreOfMass), + momentOfInertia_(momentOfInertia), + mass_(mass), + Q_(Q), + v_(v), + a_(a), + pi_(pi), + tau_(tau) +{} + + +Foam::sixDofRigidBodyMotion::sixDofRigidBodyMotion(const dictionary& dict) +: + centreOfMass_(dict.lookup("centreOfMass")), + refCentreOfMass_(dict.lookupOrDefault("refCentreOfMass", centreOfMass_)), + momentOfInertia_(dict.lookup("momentOfInertia")), + 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)) +{} + + +Foam::sixDofRigidBodyMotion::sixDofRigidBodyMotion +( + const sixDofRigidBodyMotion& sDofRBM +) +: + centreOfMass_(sDofRBM.centreOfMass()), + refCentreOfMass_(sDofRBM.refCentreOfMass()), + momentOfInertia_(sDofRBM.momentOfInertia()), + mass_(sDofRBM.mass()), + Q_(sDofRBM.Q()), + v_(sDofRBM.v()), + a_(sDofRBM.a()), + pi_(sDofRBM.pi()), + tau_(sDofRBM.tau()) +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::sixDofRigidBodyMotion::~sixDofRigidBodyMotion() +{} + + +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + +void Foam::sixDofRigidBodyMotion::updatePosition +( + scalar deltaT +) +{ + // First leapfrog velocity adjust and motion part, required before + // force calculation + + 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; +} + + +void Foam::sixDofRigidBodyMotion::updateForce +( + const vector& fGlobal, + const vector& tauGlobal, + scalar deltaT +) +{ + // Second leapfrog velocity adjust part, required after motion and + // force calculation part + + a_ = fGlobal/mass_; + + tau_ = (Q_.T() & tauGlobal); + + v_ += 0.5*deltaT*a_; + + pi_ += 0.5*deltaT*tau_; + +} + + +void Foam::sixDofRigidBodyMotion::updateForce +( + const pointField& positions, + const vectorField& forces, + scalar deltaT +) +{ + // Second leapfrog velocity adjust part, required after motion and + // force calculation part + + 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_; + +} + + +Foam::tmp<Foam::pointField> +Foam::sixDofRigidBodyMotion::generatePositions(const pointField& pts) const +{ + return (centreOfMass_ + (Q_ & (pts - refCentreOfMass_))); +} + + +// ************************************************************************* // diff --git a/src/fvMotionSolver/pointPatchFields/derived/sixDofRigidBodyDisplacement/sixDofRigidBodyMotion/sixDofRigidBodyMotion.H b/src/fvMotionSolver/pointPatchFields/derived/sixDofRigidBodyDisplacement/sixDofRigidBodyMotion/sixDofRigidBodyMotion.H new file mode 100644 index 0000000000000000000000000000000000000000..2bdb7fbf0562d46a7b9c2c501b7c2c16b1b342d0 --- /dev/null +++ b/src/fvMotionSolver/pointPatchFields/derived/sixDofRigidBodyDisplacement/sixDofRigidBodyMotion/sixDofRigidBodyMotion.H @@ -0,0 +1,267 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 "vector.H" +#include "diagTensor.H" +#include "pointField.H" +#include "mathConstants.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 + + //- Current position of the centre of mass of the body + point centreOfMass_; + + //- 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_; + + //- 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 + + //- 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 point& refCentreOfMass, + const diagTensor& momentOfInertia, + scalar mass, + const tensor& Q, + const vector& v, + const vector& a, + const vector& pi, + const vector& tau + ); + + //- 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 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 + +// ************************************************************************* // diff --git a/src/fvMotionSolver/pointPatchFields/derived/sixDofRigidBodyDisplacement/sixDofRigidBodyMotion/sixDofRigidBodyMotionI.H b/src/fvMotionSolver/pointPatchFields/derived/sixDofRigidBodyDisplacement/sixDofRigidBodyMotion/sixDofRigidBodyMotionI.H new file mode 100644 index 0000000000000000000000000000000000000000..09b1fa64db8b5375445ed8e8216086ba2ca2b9b0 --- /dev/null +++ b/src/fvMotionSolver/pointPatchFields/derived/sixDofRigidBodyDisplacement/sixDofRigidBodyMotion/sixDofRigidBodyMotionI.H @@ -0,0 +1,176 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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::point& Foam::sixDofRigidBodyMotion::centreOfMass() const +{ + return 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 Q_; +} + + +inline const Foam::vector& Foam::sixDofRigidBodyMotion::v() const +{ + return v_; +} + + +inline const Foam::vector& Foam::sixDofRigidBodyMotion::a() const +{ + return a_; +} + + +inline const Foam::vector& Foam::sixDofRigidBodyMotion::pi() const +{ + return pi_; +} + + +inline const Foam::vector& Foam::sixDofRigidBodyMotion::tau() const +{ + return tau_; +} + + +inline Foam::point& Foam::sixDofRigidBodyMotion::centreOfMass() +{ + return 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 Q_; +} + + +inline Foam::vector& Foam::sixDofRigidBodyMotion::v() +{ + return v_; +} + + +inline Foam::vector& Foam::sixDofRigidBodyMotion::a() +{ + return a_; +} + + +inline Foam::vector& Foam::sixDofRigidBodyMotion::pi() +{ + return pi_; +} + + +inline Foam::vector& Foam::sixDofRigidBodyMotion::tau() +{ + return tau_; +} + + +// ************************************************************************* // diff --git a/src/fvMotionSolver/pointPatchFields/derived/sixDofRigidBodyDisplacement/sixDofRigidBodyMotion/sixDofRigidBodyMotionIO.C b/src/fvMotionSolver/pointPatchFields/derived/sixDofRigidBodyDisplacement/sixDofRigidBodyMotion/sixDofRigidBodyMotionIO.C new file mode 100644 index 0000000000000000000000000000000000000000..b6dcf42891dd016dfe5d565a3ab45e74118c019e --- /dev/null +++ b/src/fvMotionSolver/pointPatchFields/derived/sixDofRigidBodyDisplacement/sixDofRigidBodyMotion/sixDofRigidBodyMotionIO.C @@ -0,0 +1,107 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 +{ + os.writeKeyword("centreOfMass") + << centreOfMass_ << token::END_STATEMENT << nl; + os.writeKeyword("refCentreOfMass") + << refCentreOfMass_ << token::END_STATEMENT << nl; + os.writeKeyword("momentOfInertia") + << momentOfInertia_ << token::END_STATEMENT << nl; + os.writeKeyword("mass") + << 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; +} + + +// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // + +Foam::Istream& Foam::operator>>(Istream& is, sixDofRigidBodyMotion& sDofRBM) +{ + is >> sDofRBM.centreOfMass_ + >> sDofRBM.refCentreOfMass_ + >> sDofRBM.momentOfInertia_ + >> sDofRBM.mass_ + >> sDofRBM.Q_ + >> sDofRBM.v_ + >> sDofRBM.a_ + >> sDofRBM.pi_ + >> sDofRBM.tau_; + + // 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 << token::SPACE << sDofRBM.centreOfMass() + << token::SPACE << sDofRBM.refCentreOfMass() + << token::SPACE << sDofRBM.momentOfInertia() + << 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 + os.check + ( + "Foam::Ostream& Foam::operator<<(Foam::Ostream&, " + "const Foam::sixDofRigidBodyMotion&)" + ); + + return os; +} + + +// ************************************************************************* //