mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
sixDoFRigidBodyMotion: Created separate library
Added sixDoFRigidBodyMotionSolver using septernion interpolation for mesh-morphing
This commit is contained in:
@ -4,33 +4,4 @@ forces/forcesFunctionObject.C
|
||||
forceCoeffs/forceCoeffs.C
|
||||
forceCoeffs/forceCoeffsFunctionObject.C
|
||||
|
||||
sDoFRBM = pointPatchFields/derived/sixDoFRigidBodyMotion
|
||||
|
||||
$(sDoFRBM)/sixDoFRigidBodyMotion.C
|
||||
$(sDoFRBM)/sixDoFRigidBodyMotionIO.C
|
||||
$(sDoFRBM)/sixDoFRigidBodyMotionState.C
|
||||
$(sDoFRBM)/sixDoFRigidBodyMotionStateIO.C
|
||||
|
||||
sDoFRBMR = $(sDoFRBM)/sixDoFRigidBodyMotionRestraint
|
||||
|
||||
$(sDoFRBMR)/sixDoFRigidBodyMotionRestraint/sixDoFRigidBodyMotionRestraint.C
|
||||
$(sDoFRBMR)/sixDoFRigidBodyMotionRestraint/sixDoFRigidBodyMotionRestraintNew.C
|
||||
$(sDoFRBMR)/linearAxialAngularSpring/linearAxialAngularSpring.C
|
||||
$(sDoFRBMR)/linearSpring/linearSpring.C
|
||||
$(sDoFRBMR)/sphericalAngularSpring/sphericalAngularSpring.C
|
||||
$(sDoFRBMR)/tabulatedAxialAngularSpring/tabulatedAxialAngularSpring.C
|
||||
|
||||
sDoFRBMC = $(sDoFRBM)/sixDoFRigidBodyMotionConstraint
|
||||
|
||||
$(sDoFRBMC)/sixDoFRigidBodyMotionConstraint/sixDoFRigidBodyMotionConstraint.C
|
||||
$(sDoFRBMC)/sixDoFRigidBodyMotionConstraint/sixDoFRigidBodyMotionConstraintNew.C
|
||||
$(sDoFRBMC)/fixedAxis/fixedAxis.C
|
||||
$(sDoFRBMC)/fixedLine/fixedLine.C
|
||||
$(sDoFRBMC)/fixedOrientation/fixedOrientation.C
|
||||
$(sDoFRBMC)/fixedPlane/fixedPlane.C
|
||||
$(sDoFRBMC)/fixedPoint/fixedPoint.C
|
||||
|
||||
pointPatchFields/derived/sixDoFRigidBodyDisplacement/sixDoFRigidBodyDisplacementPointPatchVectorField.C
|
||||
pointPatchFields/derived/uncoupledSixDoFRigidBodyDisplacement/uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField.C
|
||||
|
||||
LIB = $(FOAM_LIBBIN)/libforces
|
||||
|
||||
@ -1,293 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#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_(),
|
||||
initialPoints_(p.localPoints()),
|
||||
rhoInf_(1.0),
|
||||
rhoName_("rho"),
|
||||
lookupGravity_(-1),
|
||||
g_(vector::zero),
|
||||
curTimeIndex_(-1)
|
||||
{}
|
||||
|
||||
|
||||
sixDoFRigidBodyDisplacementPointPatchVectorField::
|
||||
sixDoFRigidBodyDisplacementPointPatchVectorField
|
||||
(
|
||||
const pointPatch& p,
|
||||
const DimensionedField<vector, pointMesh>& iF,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fixedValuePointPatchField<vector>(p, iF, dict),
|
||||
motion_(dict),
|
||||
rhoInf_(1.0),
|
||||
rhoName_(dict.lookupOrDefault<word>("rhoName", "rho")),
|
||||
lookupGravity_(-1),
|
||||
g_(vector::zero),
|
||||
curTimeIndex_(-1)
|
||||
{
|
||||
if (rhoName_ == "rhoInf")
|
||||
{
|
||||
rhoInf_ = readScalar(dict.lookup("rhoInf"));
|
||||
}
|
||||
|
||||
if (dict.readIfPresent("g", g_))
|
||||
{
|
||||
lookupGravity_ = -2;
|
||||
}
|
||||
|
||||
if (!dict.found("value"))
|
||||
{
|
||||
updateCoeffs();
|
||||
}
|
||||
|
||||
if (dict.found("initialPoints"))
|
||||
{
|
||||
initialPoints_ = vectorField("initialPoints", dict , p.size());
|
||||
}
|
||||
else
|
||||
{
|
||||
initialPoints_ = 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_),
|
||||
initialPoints_(ptf.initialPoints_, mapper),
|
||||
rhoInf_(ptf.rhoInf_),
|
||||
rhoName_(ptf.rhoName_),
|
||||
lookupGravity_(ptf.lookupGravity_),
|
||||
g_(ptf.g_),
|
||||
curTimeIndex_(-1)
|
||||
{}
|
||||
|
||||
|
||||
sixDoFRigidBodyDisplacementPointPatchVectorField::
|
||||
sixDoFRigidBodyDisplacementPointPatchVectorField
|
||||
(
|
||||
const sixDoFRigidBodyDisplacementPointPatchVectorField& ptf,
|
||||
const DimensionedField<vector, pointMesh>& iF
|
||||
)
|
||||
:
|
||||
fixedValuePointPatchField<vector>(ptf, iF),
|
||||
motion_(ptf.motion_),
|
||||
initialPoints_(ptf.initialPoints_),
|
||||
rhoInf_(ptf.rhoInf_),
|
||||
rhoName_(ptf.rhoName_),
|
||||
lookupGravity_(ptf.lookupGravity_),
|
||||
g_(ptf.g_),
|
||||
curTimeIndex_(-1)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void sixDoFRigidBodyDisplacementPointPatchVectorField::autoMap
|
||||
(
|
||||
const pointPatchFieldMapper& m
|
||||
)
|
||||
{
|
||||
fixedValuePointPatchField<vector>::autoMap(m);
|
||||
|
||||
initialPoints_.autoMap(m);
|
||||
}
|
||||
|
||||
|
||||
void sixDoFRigidBodyDisplacementPointPatchVectorField::rmap
|
||||
(
|
||||
const pointPatchField<vector>& ptf,
|
||||
const labelList& addr
|
||||
)
|
||||
{
|
||||
const sixDoFRigidBodyDisplacementPointPatchVectorField& sDoFptf =
|
||||
refCast<const sixDoFRigidBodyDisplacementPointPatchVectorField>(ptf);
|
||||
|
||||
fixedValuePointPatchField<vector>::rmap(sDoFptf, addr);
|
||||
|
||||
initialPoints_.rmap(sDoFptf.initialPoints_, addr);
|
||||
}
|
||||
|
||||
|
||||
void sixDoFRigidBodyDisplacementPointPatchVectorField::updateCoeffs()
|
||||
{
|
||||
if (this->updated())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (lookupGravity_ < 0)
|
||||
{
|
||||
if (db().foundObject<uniformDimensionedVectorField>("g"))
|
||||
{
|
||||
if (lookupGravity_ == -2)
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"void sixDoFRigidBodyDisplacementPointPatchVectorField"
|
||||
"::updateCoeffs()"
|
||||
)
|
||||
<< "Specifying the value of g in this boundary condition "
|
||||
<< "when g is available from the database is considered "
|
||||
<< "a fatal error to avoid the possibility of inconsistency"
|
||||
<< exit(FatalError);
|
||||
}
|
||||
else
|
||||
{
|
||||
lookupGravity_ = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lookupGravity_ = 0;
|
||||
}
|
||||
}
|
||||
|
||||
const polyMesh& mesh = this->dimensionedInternalField().mesh()();
|
||||
const Time& t = mesh.time();
|
||||
const pointPatch& ptPatch = this->patch();
|
||||
|
||||
// Store the motion state at the beginning of the time-step
|
||||
if (curTimeIndex_ != this->db().time().timeIndex())
|
||||
{
|
||||
motion_.newTime();
|
||||
curTimeIndex_ = this->db().time().timeIndex();
|
||||
}
|
||||
|
||||
// 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(), t.deltaT0Value());
|
||||
|
||||
dictionary forcesDict;
|
||||
|
||||
forcesDict.add("type", forces::typeName);
|
||||
forcesDict.add("patches", wordList(1, ptPatch.name()));
|
||||
forcesDict.add("rhoInf", rhoInf_);
|
||||
forcesDict.add("rhoName", rhoName_);
|
||||
forcesDict.add("CofR", motion_.centreOfMass());
|
||||
|
||||
forces f("forces", db(), forcesDict);
|
||||
|
||||
f.calcForcesMoment();
|
||||
|
||||
// Get the forces on the patch faces at the current positions
|
||||
|
||||
if (lookupGravity_ == 1)
|
||||
{
|
||||
uniformDimensionedVectorField g =
|
||||
db().lookupObject<uniformDimensionedVectorField>("g");
|
||||
|
||||
g_ = g.value();
|
||||
}
|
||||
|
||||
motion_.updateAcceleration
|
||||
(
|
||||
f.forceEff() + g_*motion_.mass(),
|
||||
f.momentEff(),
|
||||
t.deltaTValue()
|
||||
);
|
||||
|
||||
Field<vector>::operator=
|
||||
(
|
||||
motion_.currentPosition(initialPoints_) - initialPoints_
|
||||
);
|
||||
|
||||
fixedValuePointPatchField<vector>::updateCoeffs();
|
||||
}
|
||||
|
||||
|
||||
void sixDoFRigidBodyDisplacementPointPatchVectorField::write(Ostream& os) const
|
||||
{
|
||||
pointPatchField<vector>::write(os);
|
||||
|
||||
os.writeKeyword("rhoName") << rhoName_ << token::END_STATEMENT << nl;
|
||||
|
||||
if (rhoName_ == "rhoInf")
|
||||
{
|
||||
os.writeKeyword("rhoInf") << rhoInf_ << token::END_STATEMENT << nl;
|
||||
}
|
||||
|
||||
if (lookupGravity_ == 0 || lookupGravity_ == -2)
|
||||
{
|
||||
os.writeKeyword("g") << g_ << token::END_STATEMENT << nl;
|
||||
}
|
||||
|
||||
motion_.write(os);
|
||||
|
||||
initialPoints_.writeEntry("initialPoints", os);
|
||||
|
||||
writeEntry("value", os);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
makePointPatchTypeField
|
||||
(
|
||||
pointPatchVectorField,
|
||||
sixDoFRigidBodyDisplacementPointPatchVectorField
|
||||
);
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,196 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
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_;
|
||||
|
||||
//- Initial positions of points on the patch
|
||||
pointField initialPoints_;
|
||||
|
||||
//- Reference density required by the forces object for
|
||||
// incompressible calculations, required if rhoName == rhoInf
|
||||
scalar rhoInf_;
|
||||
|
||||
//- Name of density field, optional unless used for an
|
||||
// incompressible simulation, when this needs to be specified
|
||||
// as rhoInf
|
||||
word rhoName_;
|
||||
|
||||
//- State of gravity lookup:
|
||||
// -1 = not determined yet, as the BC may be instantiated before g has
|
||||
// been read into the db yet. Determination deferred until first
|
||||
// call to updateCoeffs. A g keyword was not supplied to the
|
||||
// dictionary.
|
||||
// -2 = as for -1, but a gravity value was specified in the dictionary,
|
||||
// specifying a value in the dictionary is considered a fatal
|
||||
// error if g is available from the db.
|
||||
// 0 = Use this boundary condition's own value of gravity, as not
|
||||
// available from the db.
|
||||
// 1 = Lookup gravity from db.
|
||||
label lookupGravity_;
|
||||
|
||||
//- Gravity vector to store when not available from the db
|
||||
vector g_;
|
||||
|
||||
//- Current time index (used for updating)
|
||||
label curTimeIndex_;
|
||||
|
||||
|
||||
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
|
||||
|
||||
// Mapping functions
|
||||
|
||||
//- Map (and resize as needed) from self given a mapping object
|
||||
virtual void autoMap
|
||||
(
|
||||
const pointPatchFieldMapper&
|
||||
);
|
||||
|
||||
//- Reverse map the given pointPatchField onto this pointPatchField
|
||||
virtual void rmap
|
||||
(
|
||||
const pointPatchField<vector>&,
|
||||
const labelList&
|
||||
);
|
||||
|
||||
|
||||
// Evaluation functions
|
||||
|
||||
//- Update the coefficients associated with the patch field
|
||||
virtual void updateCoeffs();
|
||||
|
||||
|
||||
//- Write
|
||||
virtual void write(Ostream&) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,536 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "sixDoFRigidBodyMotion.H"
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::sixDoFRigidBodyMotion::applyRestraints()
|
||||
{
|
||||
if (restraints_.empty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
forAll(restraints_, rI)
|
||||
{
|
||||
if (report_)
|
||||
{
|
||||
Info<< "Restraint " << restraintNames_[rI] << ": ";
|
||||
}
|
||||
|
||||
// restraint position
|
||||
point rP = vector::zero;
|
||||
|
||||
// restraint force
|
||||
vector rF = vector::zero;
|
||||
|
||||
// restraint moment
|
||||
vector rM = vector::zero;
|
||||
|
||||
restraints_[rI].restrain(*this, rP, rF, rM);
|
||||
|
||||
a() += rF/mass_;
|
||||
|
||||
// Moments are returned in global axes, transforming to
|
||||
// body local to add to torque.
|
||||
tau() += Q().T() & (rM + ((rP - centreOfMass()) ^ rF));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::sixDoFRigidBodyMotion::applyConstraints(scalar deltaT)
|
||||
{
|
||||
if (constraints_.empty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
label iteration = 0;
|
||||
|
||||
bool allConverged = true;
|
||||
|
||||
// constraint force accumulator
|
||||
vector cFA = vector::zero;
|
||||
|
||||
// constraint moment accumulator
|
||||
vector cMA = vector::zero;
|
||||
|
||||
do
|
||||
{
|
||||
allConverged = true;
|
||||
|
||||
forAll(constraints_, cI)
|
||||
{
|
||||
if (sixDoFRigidBodyMotionConstraint::debug)
|
||||
{
|
||||
Info<< "Constraint " << constraintNames_[cI] << ": ";
|
||||
}
|
||||
|
||||
// constraint position
|
||||
point cP = vector::zero;
|
||||
|
||||
// constraint force
|
||||
vector cF = vector::zero;
|
||||
|
||||
// constraint moment
|
||||
vector cM = vector::zero;
|
||||
|
||||
bool constraintConverged = constraints_[cI].constrain
|
||||
(
|
||||
*this,
|
||||
cFA,
|
||||
cMA,
|
||||
deltaT,
|
||||
cP,
|
||||
cF,
|
||||
cM
|
||||
);
|
||||
|
||||
allConverged = allConverged && constraintConverged;
|
||||
|
||||
// Accumulate constraint force
|
||||
cFA += cF;
|
||||
|
||||
// Accumulate constraint moment
|
||||
cMA += cM + ((cP - centreOfMass()) ^ cF);
|
||||
}
|
||||
|
||||
} while(++iteration < maxConstraintIterations_ && !allConverged);
|
||||
|
||||
if (iteration >= maxConstraintIterations_)
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"Foam::sixDoFRigidBodyMotion::applyConstraints(scalar)"
|
||||
)
|
||||
<< nl << "Maximum number of sixDoFRigidBodyMotion constraint "
|
||||
<< "iterations ("
|
||||
<< maxConstraintIterations_
|
||||
<< ") exceeded." << nl
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
Info<< "sixDoFRigidBodyMotion constraints converged in "
|
||||
<< iteration << " iterations" << endl;
|
||||
|
||||
if (report_)
|
||||
{
|
||||
Info<< "Constraint force: " << cFA << nl
|
||||
<< "Constraint moment: " << cMA
|
||||
<< endl;
|
||||
}
|
||||
|
||||
// Add the constraint forces and moments to the motion state variables
|
||||
a() += cFA/mass_;
|
||||
|
||||
// The moment of constraint forces has already been added
|
||||
// during accumulation. Moments are returned in global axes,
|
||||
// transforming to body local
|
||||
tau() += Q().T() & cMA;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::sixDoFRigidBodyMotion::sixDoFRigidBodyMotion()
|
||||
:
|
||||
motionState_(),
|
||||
motionState0_(),
|
||||
restraints_(),
|
||||
restraintNames_(),
|
||||
constraints_(),
|
||||
constraintNames_(),
|
||||
maxConstraintIterations_(0),
|
||||
initialCentreOfMass_(vector::zero),
|
||||
initialQ_(I),
|
||||
momentOfInertia_(diagTensor::one*VSMALL),
|
||||
mass_(VSMALL),
|
||||
aRelax_(1.0),
|
||||
aDamp_(1.0),
|
||||
report_(false)
|
||||
{}
|
||||
|
||||
|
||||
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& initialCentreOfMass,
|
||||
const tensor& initialQ,
|
||||
const diagTensor& momentOfInertia,
|
||||
scalar aRelax,
|
||||
scalar aDamp,
|
||||
bool report
|
||||
)
|
||||
:
|
||||
motionState_
|
||||
(
|
||||
centreOfMass,
|
||||
Q,
|
||||
v,
|
||||
a,
|
||||
pi,
|
||||
tau
|
||||
),
|
||||
motionState0_(motionState_),
|
||||
restraints_(),
|
||||
restraintNames_(),
|
||||
constraints_(),
|
||||
constraintNames_(),
|
||||
maxConstraintIterations_(0),
|
||||
initialCentreOfMass_(initialCentreOfMass),
|
||||
initialQ_(initialQ),
|
||||
momentOfInertia_(momentOfInertia),
|
||||
mass_(mass),
|
||||
aRelax_(aRelax),
|
||||
aDamp_(aDamp),
|
||||
report_(report)
|
||||
{}
|
||||
|
||||
|
||||
Foam::sixDoFRigidBodyMotion::sixDoFRigidBodyMotion(const dictionary& dict)
|
||||
:
|
||||
motionState_(dict),
|
||||
motionState0_(motionState_),
|
||||
restraints_(),
|
||||
restraintNames_(),
|
||||
constraints_(),
|
||||
constraintNames_(),
|
||||
maxConstraintIterations_(0),
|
||||
initialCentreOfMass_
|
||||
(
|
||||
dict.lookupOrDefault("initialCentreOfMass", centreOfMass())
|
||||
),
|
||||
initialQ_
|
||||
(
|
||||
dict.lookupOrDefault("initialOrientation", Q())
|
||||
),
|
||||
momentOfInertia_(dict.lookup("momentOfInertia")),
|
||||
mass_(readScalar(dict.lookup("mass"))),
|
||||
aRelax_(dict.lookupOrDefault<scalar>("accelerationRelaxation", 1.0)),
|
||||
aDamp_(dict.lookupOrDefault<scalar>("accelerationDamping", 1.0)),
|
||||
report_(dict.lookupOrDefault<Switch>("report", false))
|
||||
{
|
||||
addRestraints(dict);
|
||||
|
||||
addConstraints(dict);
|
||||
}
|
||||
|
||||
|
||||
Foam::sixDoFRigidBodyMotion::sixDoFRigidBodyMotion
|
||||
(
|
||||
const sixDoFRigidBodyMotion& sDoFRBM
|
||||
)
|
||||
:
|
||||
motionState_(sDoFRBM.motionState_),
|
||||
motionState0_(sDoFRBM.motionState0_),
|
||||
restraints_(sDoFRBM.restraints_),
|
||||
restraintNames_(sDoFRBM.restraintNames_),
|
||||
constraints_(sDoFRBM.constraints_),
|
||||
constraintNames_(sDoFRBM.constraintNames_),
|
||||
maxConstraintIterations_(sDoFRBM.maxConstraintIterations_),
|
||||
initialCentreOfMass_(sDoFRBM.initialCentreOfMass_),
|
||||
initialQ_(sDoFRBM.initialQ_),
|
||||
momentOfInertia_(sDoFRBM.momentOfInertia_),
|
||||
mass_(sDoFRBM.mass_),
|
||||
aRelax_(sDoFRBM.aRelax_),
|
||||
aDamp_(sDoFRBM.aDamp_),
|
||||
report_(sDoFRBM.report_)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::sixDoFRigidBodyMotion::~sixDoFRigidBodyMotion()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::sixDoFRigidBodyMotion::addRestraints
|
||||
(
|
||||
const dictionary& dict
|
||||
)
|
||||
{
|
||||
if (dict.found("restraints"))
|
||||
{
|
||||
const dictionary& restraintDict = dict.subDict("restraints");
|
||||
|
||||
label i = 0;
|
||||
|
||||
restraints_.setSize(restraintDict.size());
|
||||
|
||||
restraintNames_.setSize(restraintDict.size());
|
||||
|
||||
forAllConstIter(IDLList<entry>, restraintDict, iter)
|
||||
{
|
||||
if (iter().isDict())
|
||||
{
|
||||
// Info<< "Adding restraint: " << iter().keyword() << endl;
|
||||
|
||||
restraints_.set
|
||||
(
|
||||
i,
|
||||
sixDoFRigidBodyMotionRestraint::New(iter().dict())
|
||||
);
|
||||
|
||||
restraintNames_[i] = iter().keyword();
|
||||
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
restraints_.setSize(i);
|
||||
|
||||
restraintNames_.setSize(i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::sixDoFRigidBodyMotion::addConstraints
|
||||
(
|
||||
const dictionary& dict
|
||||
)
|
||||
{
|
||||
if (dict.found("constraints"))
|
||||
{
|
||||
const dictionary& constraintDict = dict.subDict("constraints");
|
||||
|
||||
label i = 0;
|
||||
|
||||
constraints_.setSize(constraintDict.size());
|
||||
|
||||
constraintNames_.setSize(constraintDict.size());
|
||||
|
||||
forAllConstIter(IDLList<entry>, constraintDict, iter)
|
||||
{
|
||||
if (iter().isDict())
|
||||
{
|
||||
// Info<< "Adding constraint: " << iter().keyword() << endl;
|
||||
|
||||
constraints_.set
|
||||
(
|
||||
i,
|
||||
sixDoFRigidBodyMotionConstraint::New(iter().dict())
|
||||
);
|
||||
|
||||
constraintNames_[i] = iter().keyword();
|
||||
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
constraints_.setSize(i);
|
||||
|
||||
constraintNames_.setSize(i);
|
||||
|
||||
if (!constraints_.empty())
|
||||
{
|
||||
maxConstraintIterations_ = readLabel
|
||||
(
|
||||
constraintDict.lookup("maxIterations")
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::sixDoFRigidBodyMotion::updatePosition
|
||||
(
|
||||
scalar deltaT,
|
||||
scalar deltaT0
|
||||
)
|
||||
{
|
||||
// First leapfrog velocity adjust and motion part, required before
|
||||
// force calculation
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
v() = v0() + aDamp_*0.5*deltaT0*a();
|
||||
pi() = pi0() + aDamp_*0.5*deltaT0*tau();
|
||||
|
||||
// Leapfrog move part
|
||||
centreOfMass() = centreOfMass0() + deltaT*v();
|
||||
|
||||
// Leapfrog orientation adjustment
|
||||
Tuple2<tensor, vector> Qpi = rotate(Q0(), pi(), deltaT);
|
||||
Q() = Qpi.first();
|
||||
pi() = Qpi.second();
|
||||
}
|
||||
|
||||
Pstream::scatter(motionState_);
|
||||
}
|
||||
|
||||
|
||||
void Foam::sixDoFRigidBodyMotion::updateAcceleration
|
||||
(
|
||||
const vector& fGlobal,
|
||||
const vector& tauGlobal,
|
||||
scalar deltaT
|
||||
)
|
||||
{
|
||||
static bool first = true;
|
||||
|
||||
// Second leapfrog velocity adjust part, required after motion and
|
||||
// acceleration calculation
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
// Save the previous iteration accelerations for relaxation
|
||||
vector aPrevIter = a();
|
||||
vector tauPrevIter = tau();
|
||||
|
||||
// Calculate new accelerations
|
||||
a() = fGlobal/mass_;
|
||||
tau() = (Q().T() & tauGlobal);
|
||||
applyRestraints();
|
||||
|
||||
// Relax accelerations on all but first iteration
|
||||
if (!first)
|
||||
{
|
||||
a() = aRelax_*a() + (1 - aRelax_)*aPrevIter;
|
||||
tau() = aRelax_*tau() + (1 - aRelax_)*tauPrevIter;
|
||||
}
|
||||
first = false;
|
||||
|
||||
// Apply constraints after relaxation
|
||||
applyConstraints(deltaT);
|
||||
|
||||
// Correct velocities
|
||||
v() += aDamp_*0.5*deltaT*a();
|
||||
pi() += aDamp_*0.5*deltaT*tau();
|
||||
|
||||
if (report_)
|
||||
{
|
||||
status();
|
||||
}
|
||||
}
|
||||
|
||||
Pstream::scatter(motionState_);
|
||||
}
|
||||
|
||||
|
||||
void Foam::sixDoFRigidBodyMotion::updateVelocity(scalar deltaT)
|
||||
{
|
||||
// Second leapfrog velocity adjust part, required after motion and
|
||||
// acceleration calculation
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
v() += aDamp_*0.5*deltaT*a();
|
||||
pi() += aDamp_*0.5*deltaT*tau();
|
||||
|
||||
if (report_)
|
||||
{
|
||||
status();
|
||||
}
|
||||
}
|
||||
|
||||
Pstream::scatter(motionState_);
|
||||
}
|
||||
|
||||
|
||||
void Foam::sixDoFRigidBodyMotion::updateAcceleration
|
||||
(
|
||||
const pointField& positions,
|
||||
const vectorField& forces,
|
||||
scalar deltaT
|
||||
)
|
||||
{
|
||||
vector fGlobal = vector::zero;
|
||||
|
||||
vector tauGlobal = vector::zero;
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
fGlobal = sum(forces);
|
||||
|
||||
forAll(positions, i)
|
||||
{
|
||||
tauGlobal += (positions[i] - centreOfMass()) ^ forces[i];
|
||||
}
|
||||
}
|
||||
|
||||
updateAcceleration(fGlobal, tauGlobal, deltaT);
|
||||
}
|
||||
|
||||
|
||||
Foam::point Foam::sixDoFRigidBodyMotion::predictedPosition
|
||||
(
|
||||
const point& pInitial,
|
||||
const vector& deltaForce,
|
||||
const vector& deltaMoment,
|
||||
scalar deltaT
|
||||
) const
|
||||
{
|
||||
vector vTemp = v() + deltaT*(a() + deltaForce/mass_);
|
||||
vector piTemp = pi() + deltaT*(tau() + (Q().T() & deltaMoment));
|
||||
point centreOfMassTemp = centreOfMass0() + deltaT*vTemp;
|
||||
Tuple2<tensor, vector> QpiTemp = rotate(Q0(), piTemp, deltaT);
|
||||
|
||||
return
|
||||
(
|
||||
centreOfMassTemp
|
||||
+ (QpiTemp.first() & initialQ_.T() & (pInitial - initialCentreOfMass_))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Foam::vector Foam::sixDoFRigidBodyMotion::predictedOrientation
|
||||
(
|
||||
const vector& vInitial,
|
||||
const vector& deltaMoment,
|
||||
scalar deltaT
|
||||
) const
|
||||
{
|
||||
vector piTemp = pi() + deltaT*(tau() + (Q().T() & deltaMoment));
|
||||
Tuple2<tensor, vector> QpiTemp = rotate(Q0(), piTemp, deltaT);
|
||||
|
||||
return (QpiTemp.first() & initialQ_.T() & vInitial);
|
||||
}
|
||||
|
||||
|
||||
void Foam::sixDoFRigidBodyMotion::status() const
|
||||
{
|
||||
Info<< "Centre of mass: " << centreOfMass() << nl
|
||||
<< "Linear velocity: " << v() << nl
|
||||
<< "Angular velocity: " << omega()
|
||||
<< endl;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,434 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
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 (where Q = I) 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}
|
||||
|
||||
Can add restraints (i.e. a spring) and constraints (i.e. motion
|
||||
may only be on a plane).
|
||||
|
||||
SourceFiles
|
||||
sixDoFRigidBodyMotionI.H
|
||||
sixDoFRigidBodyMotion.C
|
||||
sixDoFRigidBodyMotionIO.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef sixDoFRigidBodyMotion_H
|
||||
#define sixDoFRigidBodyMotion_H
|
||||
|
||||
#include "sixDoFRigidBodyMotionState.H"
|
||||
#include "pointField.H"
|
||||
#include "sixDoFRigidBodyMotionRestraint.H"
|
||||
#include "sixDoFRigidBodyMotionConstraint.H"
|
||||
#include "Tuple2.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
|
||||
|
||||
//- Motion state data object
|
||||
sixDoFRigidBodyMotionState motionState_;
|
||||
|
||||
//- Motion state data object for previous time-step
|
||||
sixDoFRigidBodyMotionState motionState0_;
|
||||
|
||||
//- Restraints on the motion
|
||||
PtrList<sixDoFRigidBodyMotionRestraint> restraints_;
|
||||
|
||||
//- Names of the restraints
|
||||
wordList restraintNames_;
|
||||
|
||||
//- Constaints on the motion
|
||||
PtrList<sixDoFRigidBodyMotionConstraint> constraints_;
|
||||
|
||||
//- Names of the constraints
|
||||
wordList constraintNames_;
|
||||
|
||||
//- Maximum number of iterations allowed to attempt to obey
|
||||
// constraints
|
||||
label maxConstraintIterations_;
|
||||
|
||||
//- Centre of mass of initial state
|
||||
point initialCentreOfMass_;
|
||||
|
||||
//- Orientation of initial state
|
||||
tensor initialQ_;
|
||||
|
||||
//- Moment of inertia of the body in reference configuration
|
||||
// (Q = I)
|
||||
diagTensor momentOfInertia_;
|
||||
|
||||
//- Mass of the body
|
||||
scalar mass_;
|
||||
|
||||
//- Acceleration relaxation coefficient
|
||||
scalar aRelax_;
|
||||
|
||||
//- Acceleration damping coefficient (for steady-state simulations)
|
||||
scalar aDamp_;
|
||||
|
||||
//- Switch to turn reporting of motion data on and off
|
||||
Switch report_;
|
||||
|
||||
|
||||
// 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;
|
||||
|
||||
//- Apply rotation tensors to Q0 for the given torque (pi) and deltaT
|
||||
// and return the rotated Q and pi as a tuple
|
||||
inline Tuple2<tensor, vector> rotate
|
||||
(
|
||||
const tensor& Q0,
|
||||
const vector& pi,
|
||||
const scalar deltaT
|
||||
) const;
|
||||
|
||||
//- Apply the restraints to the object
|
||||
void applyRestraints();
|
||||
|
||||
//- Apply the constraints to the object
|
||||
void applyConstraints(scalar deltaT);
|
||||
|
||||
|
||||
// Access functions retained as private because of the risk of
|
||||
// confusion over what is a body local frame vector and what is global
|
||||
|
||||
// Access
|
||||
|
||||
//- Return access to the motion state
|
||||
inline const sixDoFRigidBodyMotionState& motionState() const;
|
||||
|
||||
//- Return access to the restraints
|
||||
inline const PtrList<sixDoFRigidBodyMotionRestraint>&
|
||||
restraints() const;
|
||||
|
||||
//- Return access to the restraintNames
|
||||
inline const wordList& restraintNames() const;
|
||||
|
||||
//- Return access to the constraints
|
||||
inline const PtrList<sixDoFRigidBodyMotionConstraint>&
|
||||
constraints() const;
|
||||
|
||||
//- Return access to the constraintNames
|
||||
inline const wordList& constraintNames() const;
|
||||
|
||||
//- Return access to the maximum allowed number of
|
||||
// constraint iterations
|
||||
inline label maxConstraintIterations() const;
|
||||
|
||||
//- Return access to the initial centre of mass
|
||||
inline const point& initialCentreOfMass() const;
|
||||
|
||||
//- Return access to the initial orientation
|
||||
inline const tensor& initialQ() 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;
|
||||
|
||||
//- Return access to the orientation at previous time-step
|
||||
inline const tensor& Q0() const;
|
||||
|
||||
//- Return access to velocity at previous time-step
|
||||
inline const vector& v0() const;
|
||||
|
||||
//- Return access to acceleration at previous time-step
|
||||
inline const vector& a0() const;
|
||||
|
||||
//- Return access to angular momentum at previous time-step
|
||||
inline const vector& pi0() const;
|
||||
|
||||
//- Return access to torque at previous time-step
|
||||
inline const vector& tau0() const;
|
||||
|
||||
|
||||
// Edit
|
||||
|
||||
//- Return access to the centre of mass
|
||||
inline point& initialCentreOfMass();
|
||||
|
||||
//- Return access to the centre of mass
|
||||
inline tensor& initialQ();
|
||||
|
||||
//- 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();
|
||||
|
||||
|
||||
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& initialCentreOfMass,
|
||||
const tensor& initialQ,
|
||||
const diagTensor& momentOfInertia,
|
||||
scalar aRelax = 1.0,
|
||||
scalar aDamp = 1.0,
|
||||
bool report = false
|
||||
);
|
||||
|
||||
//- Construct from dictionary
|
||||
sixDoFRigidBodyMotion(const dictionary& dict);
|
||||
|
||||
//- Construct as copy
|
||||
sixDoFRigidBodyMotion(const sixDoFRigidBodyMotion&);
|
||||
|
||||
|
||||
//- Destructor
|
||||
~sixDoFRigidBodyMotion();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Add restraints to the motion, public to allow external
|
||||
// addition of restraints after construction
|
||||
void addRestraints(const dictionary& dict);
|
||||
|
||||
//- Add restraints to the motion, public to allow external
|
||||
// addition of restraints after construction
|
||||
void addConstraints(const dictionary& dict);
|
||||
|
||||
//- First leapfrog velocity adjust and motion part, required
|
||||
// before force calculation. Takes old timestep for variable
|
||||
// timestep cases.
|
||||
void updatePosition
|
||||
(
|
||||
scalar deltaT,
|
||||
scalar deltaT0
|
||||
);
|
||||
|
||||
//- Second leapfrog velocity adjust part
|
||||
// required after motion and force calculation
|
||||
void updateAcceleration
|
||||
(
|
||||
const vector& fGlobal,
|
||||
const vector& tauGlobal,
|
||||
scalar deltaT
|
||||
);
|
||||
|
||||
//- Second leapfrog velocity adjust part
|
||||
// required after motion and force calculation
|
||||
void updateVelocity(scalar deltaT);
|
||||
|
||||
//- Global forces supplied at locations, calculating net force
|
||||
// and moment
|
||||
void updateAcceleration
|
||||
(
|
||||
const pointField& positions,
|
||||
const vectorField& forces,
|
||||
scalar deltaT
|
||||
);
|
||||
|
||||
//- Transform the given initial state pointField by the current
|
||||
// motion state
|
||||
inline tmp<pointField> currentPosition
|
||||
(
|
||||
const pointField& pInitial
|
||||
) const;
|
||||
|
||||
//- Transform the given initial state point by the current motion
|
||||
// state
|
||||
inline point currentPosition(const point& pInitial) const;
|
||||
|
||||
//- Transform the given initial state direction by the current
|
||||
// motion state
|
||||
inline vector currentOrientation(const vector& vInitial) const;
|
||||
|
||||
//- Access the orientation tensor, Q.
|
||||
// globalVector = Q & bodyLocalVector
|
||||
// bodyLocalVector = Q.T() & globalVector
|
||||
inline const tensor& orientation() const;
|
||||
|
||||
//- Predict the position of the supplied initial state point
|
||||
// after deltaT given the current motion state and the
|
||||
// additional supplied force and moment
|
||||
point predictedPosition
|
||||
(
|
||||
const point& pInitial,
|
||||
const vector& deltaForce,
|
||||
const vector& deltaMoment,
|
||||
scalar deltaT
|
||||
) const;
|
||||
|
||||
//- Predict the orientation of the supplied initial state
|
||||
// vector after deltaT given the current motion state and the
|
||||
// additional supplied moment
|
||||
vector predictedOrientation
|
||||
(
|
||||
const vector& vInitial,
|
||||
const vector& deltaMoment,
|
||||
scalar deltaT
|
||||
) const;
|
||||
|
||||
//- Return the angular velocity in the global frame
|
||||
inline vector omega() const;
|
||||
|
||||
//- Return the velocity of a position given by the current
|
||||
// motion state
|
||||
inline point currentVelocity(const point& pt) const;
|
||||
|
||||
//- Report the status of the motion
|
||||
void status() const;
|
||||
|
||||
|
||||
// Access
|
||||
|
||||
//- Return const access to the centre of mass
|
||||
inline const point& centreOfMass() const;
|
||||
|
||||
//- Return const access to the centre of mass at previous time-step
|
||||
inline const point& centreOfMass0() const;
|
||||
|
||||
//- Return access to the inertia tensor
|
||||
inline const diagTensor& momentOfInertia() const;
|
||||
|
||||
//- Return const access to the mass
|
||||
inline scalar mass() const;
|
||||
|
||||
//- Return the report Switch
|
||||
inline bool report() const;
|
||||
|
||||
|
||||
// Edit
|
||||
|
||||
//- Store the motion state at the beginning of the time-step
|
||||
inline void newTime();
|
||||
|
||||
//- Return non-const access to the centre of mass
|
||||
inline point& centreOfMass();
|
||||
|
||||
//- Return non-const access to the inertia tensor
|
||||
inline diagTensor& momentOfInertia();
|
||||
|
||||
//- Return non-const access to the mass
|
||||
inline scalar& mass();
|
||||
|
||||
|
||||
//- 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
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,187 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "fixedAxis.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "sixDoFRigidBodyMotion.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace sixDoFRigidBodyMotionConstraints
|
||||
{
|
||||
defineTypeNameAndDebug(fixedAxis, 0);
|
||||
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
sixDoFRigidBodyMotionConstraint,
|
||||
fixedAxis,
|
||||
dictionary
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::sixDoFRigidBodyMotionConstraints::fixedAxis::fixedAxis
|
||||
(
|
||||
const dictionary& sDoFRBMCDict
|
||||
)
|
||||
:
|
||||
sixDoFRigidBodyMotionConstraint(sDoFRBMCDict),
|
||||
fixedAxis_()
|
||||
{
|
||||
read(sDoFRBMCDict);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructors * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::sixDoFRigidBodyMotionConstraints::fixedAxis::~fixedAxis()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::sixDoFRigidBodyMotionConstraints::fixedAxis::constrain
|
||||
(
|
||||
const sixDoFRigidBodyMotion& motion,
|
||||
const vector& existingConstraintForce,
|
||||
const vector& existingConstraintMoment,
|
||||
scalar deltaT,
|
||||
vector& constraintPosition,
|
||||
vector& constraintForceIncrement,
|
||||
vector& constraintMomentIncrement
|
||||
) const
|
||||
{
|
||||
constraintMomentIncrement = vector::zero;
|
||||
|
||||
vector predictedDir = motion.predictedOrientation
|
||||
(
|
||||
fixedAxis_,
|
||||
existingConstraintMoment,
|
||||
deltaT
|
||||
);
|
||||
|
||||
scalar theta = acos(min(predictedDir & fixedAxis_, 1.0));
|
||||
|
||||
vector rotationAxis = fixedAxis_ ^ predictedDir;
|
||||
|
||||
scalar magRotationAxis = mag(rotationAxis);
|
||||
|
||||
if (magRotationAxis > VSMALL)
|
||||
{
|
||||
rotationAxis /= magRotationAxis;
|
||||
|
||||
const tensor& Q = motion.orientation();
|
||||
|
||||
// Transform rotationAxis to body local system
|
||||
rotationAxis = Q.T() & rotationAxis;
|
||||
|
||||
constraintMomentIncrement =
|
||||
-relaxationFactor_
|
||||
*(motion.momentOfInertia() & rotationAxis)
|
||||
*theta/sqr(deltaT);
|
||||
|
||||
// Transform moment increment to global system
|
||||
constraintMomentIncrement = Q & constraintMomentIncrement;
|
||||
|
||||
// Remove any moment that is around the fixedAxis_
|
||||
constraintMomentIncrement -=
|
||||
(constraintMomentIncrement & fixedAxis_)*fixedAxis_;
|
||||
}
|
||||
|
||||
constraintPosition = motion.centreOfMass();
|
||||
|
||||
constraintForceIncrement = vector::zero;
|
||||
|
||||
bool converged(mag(theta) < tolerance_);
|
||||
|
||||
if (sixDoFRigidBodyMotionConstraint::debug)
|
||||
{
|
||||
Info<< " angle " << theta
|
||||
<< " force " << constraintForceIncrement
|
||||
<< " moment " << constraintMomentIncrement;
|
||||
|
||||
if (converged)
|
||||
{
|
||||
Info<< " converged";
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< " not converged";
|
||||
}
|
||||
|
||||
Info<< endl;
|
||||
}
|
||||
|
||||
return converged;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::sixDoFRigidBodyMotionConstraints::fixedAxis::read
|
||||
(
|
||||
const dictionary& sDoFRBMCDict
|
||||
)
|
||||
{
|
||||
sixDoFRigidBodyMotionConstraint::read(sDoFRBMCDict);
|
||||
|
||||
sDoFRBMCCoeffs_.lookup("axis") >> fixedAxis_;
|
||||
|
||||
scalar magFixedAxis(mag(fixedAxis_));
|
||||
|
||||
if (magFixedAxis > VSMALL)
|
||||
{
|
||||
fixedAxis_ /= magFixedAxis;
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"Foam::sixDoFRigidBodyMotionConstraints::fixedAxis::read"
|
||||
"("
|
||||
"const dictionary& sDoFRBMCDict"
|
||||
")"
|
||||
)
|
||||
<< "axis has zero length"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void Foam::sixDoFRigidBodyMotionConstraints::fixedAxis::write
|
||||
(
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
os.writeKeyword("axis")
|
||||
<< fixedAxis_ << token::END_STATEMENT << nl;
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,127 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::sixDoFRigidBodyMotionConstraints::fixedAxis
|
||||
|
||||
Description
|
||||
sixDoFRigidBodyMotionConstraint. Body may only rotate around
|
||||
an axis fixed in global space.
|
||||
|
||||
SourceFiles
|
||||
fixedAxis.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef fixedAxis_H
|
||||
#define fixedAxis_H
|
||||
|
||||
#include "sixDoFRigidBodyMotionConstraint.H"
|
||||
#include "point.H"
|
||||
#include "tensor.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
namespace sixDoFRigidBodyMotionConstraints
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class fixedAxis Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class fixedAxis
|
||||
:
|
||||
public sixDoFRigidBodyMotionConstraint
|
||||
{
|
||||
|
||||
// Private data
|
||||
|
||||
//- Reference axis in global space
|
||||
vector fixedAxis_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("fixedAxis");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
fixedAxis
|
||||
(
|
||||
const dictionary& sDoFRBMCDict
|
||||
);
|
||||
|
||||
//- Construct and return a clone
|
||||
virtual autoPtr<sixDoFRigidBodyMotionConstraint> clone() const
|
||||
{
|
||||
return autoPtr<sixDoFRigidBodyMotionConstraint>
|
||||
(
|
||||
new fixedAxis(*this)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~fixedAxis();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Calculate the constraint position, force and moment.
|
||||
// Global reference frame vectors. Returns boolean stating
|
||||
// whether the constraint been converged to tolerance.
|
||||
virtual bool constrain
|
||||
(
|
||||
const sixDoFRigidBodyMotion& motion,
|
||||
const vector& existingConstraintForce,
|
||||
const vector& existingConstraintMoment,
|
||||
scalar deltaT,
|
||||
vector& constraintPosition,
|
||||
vector& constraintForceIncrement,
|
||||
vector& constraintMomentIncrement
|
||||
) const;
|
||||
|
||||
//- Update properties from given dictionary
|
||||
virtual bool read(const dictionary& sDoFRBMCCoeff);
|
||||
|
||||
//- Write
|
||||
virtual void write(Ostream&) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace solidBodyMotionFunctions
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,178 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "fixedLine.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "sixDoFRigidBodyMotion.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace sixDoFRigidBodyMotionConstraints
|
||||
{
|
||||
defineTypeNameAndDebug(fixedLine, 0);
|
||||
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
sixDoFRigidBodyMotionConstraint,
|
||||
fixedLine,
|
||||
dictionary
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::sixDoFRigidBodyMotionConstraints::fixedLine::fixedLine
|
||||
(
|
||||
const dictionary& sDoFRBMCDict
|
||||
)
|
||||
:
|
||||
sixDoFRigidBodyMotionConstraint(sDoFRBMCDict),
|
||||
refPt_(),
|
||||
dir_()
|
||||
{
|
||||
read(sDoFRBMCDict);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructors * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::sixDoFRigidBodyMotionConstraints::fixedLine::~fixedLine()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::sixDoFRigidBodyMotionConstraints::fixedLine::constrain
|
||||
(
|
||||
const sixDoFRigidBodyMotion& motion,
|
||||
const vector& existingConstraintForce,
|
||||
const vector& existingConstraintMoment,
|
||||
scalar deltaT,
|
||||
vector& constraintPosition,
|
||||
vector& constraintForceIncrement,
|
||||
vector& constraintMomentIncrement
|
||||
) const
|
||||
{
|
||||
point predictedPosition = motion.predictedPosition
|
||||
(
|
||||
refPt_,
|
||||
existingConstraintForce,
|
||||
existingConstraintMoment,
|
||||
deltaT
|
||||
);
|
||||
|
||||
constraintPosition = motion.currentPosition(refPt_);
|
||||
|
||||
// Info<< "current position " << constraintPosition << nl
|
||||
// << "next predictedPosition " << predictedPosition
|
||||
// << endl;
|
||||
|
||||
// Vector from reference point to predicted point
|
||||
vector rC = predictedPosition - refPt_;
|
||||
|
||||
vector error = rC - ((rC) & dir_)*dir_;
|
||||
|
||||
// Info<< "error " << error << endl;
|
||||
|
||||
constraintForceIncrement =
|
||||
-relaxationFactor_*error*motion.mass()/sqr(deltaT);
|
||||
|
||||
constraintMomentIncrement = vector::zero;
|
||||
|
||||
bool converged(mag(error) < tolerance_);
|
||||
|
||||
if (sixDoFRigidBodyMotionConstraint::debug)
|
||||
{
|
||||
Info<< " error " << error
|
||||
<< " force " << constraintForceIncrement
|
||||
<< " moment " << constraintMomentIncrement;
|
||||
|
||||
if (converged)
|
||||
{
|
||||
Info<< " converged";
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< " not converged";
|
||||
}
|
||||
|
||||
Info<< endl;
|
||||
}
|
||||
|
||||
return converged;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::sixDoFRigidBodyMotionConstraints::fixedLine::read
|
||||
(
|
||||
const dictionary& sDoFRBMCDict
|
||||
)
|
||||
{
|
||||
sixDoFRigidBodyMotionConstraint::read(sDoFRBMCDict);
|
||||
|
||||
sDoFRBMCCoeffs_.lookup("refPoint") >> refPt_;
|
||||
|
||||
sDoFRBMCCoeffs_.lookup("direction") >> dir_;
|
||||
|
||||
scalar magDir(mag(dir_));
|
||||
|
||||
if (magDir > VSMALL)
|
||||
{
|
||||
dir_ /= magDir;
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"Foam::sixDoFRigidBodyMotionConstraints::fixedLine::read"
|
||||
"("
|
||||
"const dictionary& sDoFRBMCDict"
|
||||
")"
|
||||
)
|
||||
<< "line direction has zero length"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void Foam::sixDoFRigidBodyMotionConstraints::fixedLine::write
|
||||
(
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
os.writeKeyword("refPoint")
|
||||
<< refPt_ << token::END_STATEMENT << nl;
|
||||
|
||||
os.writeKeyword("direction")
|
||||
<< dir_ << token::END_STATEMENT << nl;
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,128 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::sixDoFRigidBodyMotionConstraints::fixedLine
|
||||
|
||||
Description
|
||||
sixDoFRigidBodyMotionConstraint. Reference point may only move
|
||||
along a line.
|
||||
|
||||
SourceFiles
|
||||
fixedLine.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef fixedLine_H
|
||||
#define fixedLine_H
|
||||
|
||||
#include "sixDoFRigidBodyMotionConstraint.H"
|
||||
#include "point.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
namespace sixDoFRigidBodyMotionConstraints
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class fixedLine Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class fixedLine
|
||||
:
|
||||
public sixDoFRigidBodyMotionConstraint
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Reference point for the constraining line
|
||||
point refPt_;
|
||||
|
||||
//- Direction of the constraining line
|
||||
vector dir_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("fixedLine");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
fixedLine
|
||||
(
|
||||
const dictionary& sDoFRBMCDict
|
||||
);
|
||||
|
||||
//- Construct and return a clone
|
||||
virtual autoPtr<sixDoFRigidBodyMotionConstraint> clone() const
|
||||
{
|
||||
return autoPtr<sixDoFRigidBodyMotionConstraint>
|
||||
(
|
||||
new fixedLine(*this)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~fixedLine();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Calculate the constraint position, force and moment.
|
||||
// Global reference frame vectors. Returns boolean stating
|
||||
// whether the constraint been converged to tolerance.
|
||||
virtual bool constrain
|
||||
(
|
||||
const sixDoFRigidBodyMotion& motion,
|
||||
const vector& existingConstraintForce,
|
||||
const vector& existingConstraintMoment,
|
||||
scalar deltaT,
|
||||
vector& constraintPosition,
|
||||
vector& constraintForceIncrement,
|
||||
vector& constraintMomentIncrement
|
||||
) const;
|
||||
|
||||
//- Update properties from given dictionary
|
||||
virtual bool read(const dictionary& sDoFRBMCCoeff);
|
||||
|
||||
//- Write
|
||||
virtual void write(Ostream&) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace solidBodyMotionFunctions
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,186 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "fixedOrientation.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "sixDoFRigidBodyMotion.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace sixDoFRigidBodyMotionConstraints
|
||||
{
|
||||
defineTypeNameAndDebug(fixedOrientation, 0);
|
||||
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
sixDoFRigidBodyMotionConstraint,
|
||||
fixedOrientation,
|
||||
dictionary
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::sixDoFRigidBodyMotionConstraints::fixedOrientation::fixedOrientation
|
||||
(
|
||||
const dictionary& sDoFRBMCDict
|
||||
)
|
||||
:
|
||||
sixDoFRigidBodyMotionConstraint(sDoFRBMCDict)
|
||||
{
|
||||
read(sDoFRBMCDict);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructors * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::sixDoFRigidBodyMotionConstraints::fixedOrientation::~fixedOrientation()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::sixDoFRigidBodyMotionConstraints::fixedOrientation::constrain
|
||||
(
|
||||
const sixDoFRigidBodyMotion& motion,
|
||||
const vector& existingConstraintForce,
|
||||
const vector& existingConstraintMoment,
|
||||
scalar deltaT,
|
||||
vector& constraintPosition,
|
||||
vector& constraintForceIncrement,
|
||||
vector& constraintMomentIncrement
|
||||
) const
|
||||
{
|
||||
constraintMomentIncrement = vector::zero;
|
||||
|
||||
scalar maxTheta = -SMALL;
|
||||
|
||||
for (direction cmpt=0; cmpt<vector::nComponents; cmpt++)
|
||||
{
|
||||
vector axis = vector::zero;
|
||||
|
||||
axis[cmpt] = 1;
|
||||
|
||||
vector refDir = vector::zero;
|
||||
|
||||
refDir[(cmpt + 1) % 3] = 1;
|
||||
|
||||
vector predictedDir = motion.predictedOrientation
|
||||
(
|
||||
refDir,
|
||||
existingConstraintMoment,
|
||||
deltaT
|
||||
);
|
||||
|
||||
// Removing any axis component from predictedDir
|
||||
predictedDir -= (axis & predictedDir)*axis;
|
||||
|
||||
scalar theta = GREAT;
|
||||
|
||||
scalar magPredictedDir = mag(predictedDir);
|
||||
|
||||
if (magPredictedDir > VSMALL)
|
||||
{
|
||||
predictedDir /= magPredictedDir;
|
||||
|
||||
theta = acos(min(predictedDir & refDir, 1.0));
|
||||
|
||||
// Recalculating axis to give correct sign to angle
|
||||
axis = (refDir ^ predictedDir);
|
||||
|
||||
scalar magAxis = mag(axis);
|
||||
|
||||
if (magAxis > VSMALL)
|
||||
{
|
||||
axis /= magAxis;
|
||||
}
|
||||
else
|
||||
{
|
||||
axis = vector::zero;
|
||||
}
|
||||
}
|
||||
|
||||
if (theta > maxTheta)
|
||||
{
|
||||
maxTheta = theta;
|
||||
}
|
||||
|
||||
constraintMomentIncrement +=
|
||||
-relaxationFactor_
|
||||
*theta*axis
|
||||
*motion.momentOfInertia()[cmpt]/sqr(deltaT);
|
||||
}
|
||||
|
||||
constraintPosition = motion.centreOfMass();
|
||||
|
||||
constraintForceIncrement = vector::zero;
|
||||
|
||||
bool converged(mag(maxTheta) < tolerance_);
|
||||
|
||||
if (sixDoFRigidBodyMotionConstraint::debug)
|
||||
{
|
||||
Info<< " max angle " << maxTheta
|
||||
<< " force " << constraintForceIncrement
|
||||
<< " moment " << constraintMomentIncrement;
|
||||
|
||||
if (converged)
|
||||
{
|
||||
Info<< " converged";
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< " not converged";
|
||||
}
|
||||
|
||||
Info<< endl;
|
||||
}
|
||||
|
||||
return converged;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::sixDoFRigidBodyMotionConstraints::fixedOrientation::read
|
||||
(
|
||||
const dictionary& sDoFRBMCDict
|
||||
)
|
||||
{
|
||||
sixDoFRigidBodyMotionConstraint::read(sDoFRBMCDict);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void Foam::sixDoFRigidBodyMotionConstraints::fixedOrientation::write
|
||||
(
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,122 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::sixDoFRigidBodyMotionConstraints::fixedOrientation
|
||||
|
||||
Description
|
||||
sixDoFRigidBodyMotionConstraint. Orientation of body fixed global
|
||||
space. Only valid where the predicted deviation from alignment is
|
||||
< 90 degrees.
|
||||
|
||||
SourceFiles
|
||||
fixedOrientation.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef fixedOrientation_H
|
||||
#define fixedOrientation_H
|
||||
|
||||
#include "sixDoFRigidBodyMotionConstraint.H"
|
||||
#include "point.H"
|
||||
#include "tensor.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
namespace sixDoFRigidBodyMotionConstraints
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class fixedOrientation Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class fixedOrientation
|
||||
:
|
||||
public sixDoFRigidBodyMotionConstraint
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("fixedOrientation");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
fixedOrientation
|
||||
(
|
||||
const dictionary& sDoFRBMCDict
|
||||
);
|
||||
|
||||
//- Construct and return a clone
|
||||
virtual autoPtr<sixDoFRigidBodyMotionConstraint> clone() const
|
||||
{
|
||||
return autoPtr<sixDoFRigidBodyMotionConstraint>
|
||||
(
|
||||
new fixedOrientation(*this)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~fixedOrientation();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Calculate the constraint position, force and moment.
|
||||
// Global reference frame vectors. Returns boolean stating
|
||||
// whether the constraint been converged to tolerance.
|
||||
virtual bool constrain
|
||||
(
|
||||
const sixDoFRigidBodyMotion& motion,
|
||||
const vector& existingConstraintForce,
|
||||
const vector& existingConstraintMoment,
|
||||
scalar deltaT,
|
||||
vector& constraintPosition,
|
||||
vector& constraintForceIncrement,
|
||||
vector& constraintMomentIncrement
|
||||
) const;
|
||||
|
||||
//- Update properties from given dictionary
|
||||
virtual bool read(const dictionary& sDoFRBMCCoeff);
|
||||
|
||||
//- Write
|
||||
virtual void write(Ostream&) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace solidBodyMotionFunctions
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,161 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "fixedPlane.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "sixDoFRigidBodyMotion.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace sixDoFRigidBodyMotionConstraints
|
||||
{
|
||||
defineTypeNameAndDebug(fixedPlane, 0);
|
||||
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
sixDoFRigidBodyMotionConstraint,
|
||||
fixedPlane,
|
||||
dictionary
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::sixDoFRigidBodyMotionConstraints::fixedPlane::fixedPlane
|
||||
(
|
||||
const dictionary& sDoFRBMCDict
|
||||
)
|
||||
:
|
||||
sixDoFRigidBodyMotionConstraint(sDoFRBMCDict),
|
||||
fixedPlane_(vector::one)
|
||||
{
|
||||
read(sDoFRBMCDict);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructors * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::sixDoFRigidBodyMotionConstraints::fixedPlane::~fixedPlane()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::sixDoFRigidBodyMotionConstraints::fixedPlane::constrain
|
||||
(
|
||||
const sixDoFRigidBodyMotion& motion,
|
||||
const vector& existingConstraintForce,
|
||||
const vector& existingConstraintMoment,
|
||||
scalar deltaT,
|
||||
vector& constraintPosition,
|
||||
vector& constraintForceIncrement,
|
||||
vector& constraintMomentIncrement
|
||||
) const
|
||||
{
|
||||
const point& refPt = fixedPlane_.refPoint();
|
||||
|
||||
const vector& n = fixedPlane_.normal();
|
||||
|
||||
point predictedPosition = motion.predictedPosition
|
||||
(
|
||||
refPt,
|
||||
existingConstraintForce,
|
||||
existingConstraintMoment,
|
||||
deltaT
|
||||
);
|
||||
|
||||
constraintPosition = motion.currentPosition(refPt);
|
||||
|
||||
// Info<< "current position " << constraintPosition << nl
|
||||
// << "next predictedPosition " << predictedPosition
|
||||
// << endl;
|
||||
|
||||
vector error = ((predictedPosition - refPt) & n)*n;
|
||||
|
||||
// Info<< "error " << error << endl;
|
||||
|
||||
constraintForceIncrement =
|
||||
-relaxationFactor_*error*motion.mass()/sqr(deltaT);
|
||||
|
||||
constraintMomentIncrement = vector::zero;
|
||||
|
||||
bool converged(mag(error) < tolerance_);
|
||||
|
||||
if (sixDoFRigidBodyMotionConstraint::debug)
|
||||
{
|
||||
Info<< " error " << error
|
||||
<< " force " << constraintForceIncrement
|
||||
<< " moment " << constraintMomentIncrement;
|
||||
|
||||
if (converged)
|
||||
{
|
||||
Info<< " converged";
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< " not converged";
|
||||
}
|
||||
|
||||
Info<< endl;
|
||||
}
|
||||
|
||||
return converged;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::sixDoFRigidBodyMotionConstraints::fixedPlane::read
|
||||
(
|
||||
const dictionary& sDoFRBMCDict
|
||||
)
|
||||
{
|
||||
sixDoFRigidBodyMotionConstraint::read(sDoFRBMCDict);
|
||||
|
||||
point refPt = sDoFRBMCCoeffs_.lookup("refPoint");
|
||||
|
||||
vector normal = sDoFRBMCCoeffs_.lookup("normal");
|
||||
|
||||
fixedPlane_ = plane(refPt, normal);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void Foam::sixDoFRigidBodyMotionConstraints::fixedPlane::write
|
||||
(
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
os.writeKeyword("refPoint")
|
||||
<< fixedPlane_.refPoint() << token::END_STATEMENT << nl;
|
||||
|
||||
os.writeKeyword("normal")
|
||||
<< fixedPlane_.normal() << token::END_STATEMENT << nl;
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,126 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::sixDoFRigidBodyMotionConstraints::fixedPlane
|
||||
|
||||
Description
|
||||
sixDoFRigidBodyMotionConstraint. Reference point may only move
|
||||
along a plane.
|
||||
|
||||
SourceFiles
|
||||
fixedPlane.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef fixedPlane_H
|
||||
#define fixedPlane_H
|
||||
|
||||
#include "sixDoFRigidBodyMotionConstraint.H"
|
||||
#include "plane.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
namespace sixDoFRigidBodyMotionConstraints
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class fixedPlane Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class fixedPlane
|
||||
:
|
||||
public sixDoFRigidBodyMotionConstraint
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Plane which the transformed reference point is constrained
|
||||
// to move along
|
||||
plane fixedPlane_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("fixedPlane");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
fixedPlane
|
||||
(
|
||||
const dictionary& sDoFRBMCDict
|
||||
);
|
||||
|
||||
//- Construct and return a clone
|
||||
virtual autoPtr<sixDoFRigidBodyMotionConstraint> clone() const
|
||||
{
|
||||
return autoPtr<sixDoFRigidBodyMotionConstraint>
|
||||
(
|
||||
new fixedPlane(*this)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~fixedPlane();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Calculate the constraint position, force and moment.
|
||||
// Global reference frame vectors. Returns boolean stating
|
||||
// whether the constraint been converged to tolerance.
|
||||
virtual bool constrain
|
||||
(
|
||||
const sixDoFRigidBodyMotion& motion,
|
||||
const vector& existingConstraintForce,
|
||||
const vector& existingConstraintMoment,
|
||||
scalar deltaT,
|
||||
vector& constraintPosition,
|
||||
vector& constraintForceIncrement,
|
||||
vector& constraintMomentIncrement
|
||||
) const;
|
||||
|
||||
//- Update properties from given dictionary
|
||||
virtual bool read(const dictionary& sDoFRBMCCoeff);
|
||||
|
||||
//- Write
|
||||
virtual void write(Ostream&) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace solidBodyMotionFunctions
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,163 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "fixedPoint.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "sixDoFRigidBodyMotion.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace sixDoFRigidBodyMotionConstraints
|
||||
{
|
||||
defineTypeNameAndDebug(fixedPoint, 0);
|
||||
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
sixDoFRigidBodyMotionConstraint,
|
||||
fixedPoint,
|
||||
dictionary
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::sixDoFRigidBodyMotionConstraints::fixedPoint::fixedPoint
|
||||
(
|
||||
const dictionary& sDoFRBMCDict
|
||||
)
|
||||
:
|
||||
sixDoFRigidBodyMotionConstraint(sDoFRBMCDict),
|
||||
fixedPoint_()
|
||||
{
|
||||
read(sDoFRBMCDict);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructors * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::sixDoFRigidBodyMotionConstraints::fixedPoint::~fixedPoint()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::sixDoFRigidBodyMotionConstraints::fixedPoint::constrain
|
||||
(
|
||||
const sixDoFRigidBodyMotion& motion,
|
||||
const vector& existingConstraintForce,
|
||||
const vector& existingConstraintMoment,
|
||||
scalar deltaT,
|
||||
vector& constraintPosition,
|
||||
vector& constraintForceIncrement,
|
||||
vector& constraintMomentIncrement
|
||||
) const
|
||||
{
|
||||
point predictedPosition = motion.predictedPosition
|
||||
(
|
||||
fixedPoint_,
|
||||
existingConstraintForce,
|
||||
existingConstraintMoment,
|
||||
deltaT
|
||||
);
|
||||
|
||||
constraintPosition = motion.currentPosition(fixedPoint_);
|
||||
|
||||
// Info<< "current position " << constraintPosition << nl
|
||||
// << "next predictedPosition " << predictedPosition
|
||||
// << endl;
|
||||
|
||||
vector error = predictedPosition - fixedPoint_;
|
||||
|
||||
// Info<< "error " << error << endl;
|
||||
|
||||
// Correction force derived from Lagrange multiplier:
|
||||
// G = -lambda*grad(sigma)
|
||||
// where
|
||||
// sigma = mag(error) = 0
|
||||
// so
|
||||
// grad(sigma) = error/mag(error)
|
||||
// Solving for lambda using the SHAKE methodology gives
|
||||
// lambda = mass*mag(error)/sqr(deltaT)
|
||||
// This is only strictly applicable (i.e. will converge in one
|
||||
// iteration) to constraints at the centre of mass. Everything
|
||||
// else will need to iterate, and may need under-relaxed to be
|
||||
// stable.
|
||||
|
||||
constraintForceIncrement =
|
||||
-relaxationFactor_*error*motion.mass()/sqr(deltaT);
|
||||
|
||||
constraintMomentIncrement = vector::zero;
|
||||
|
||||
bool converged(mag(error) < tolerance_);
|
||||
|
||||
if (sixDoFRigidBodyMotionConstraint::debug)
|
||||
{
|
||||
Info<< " error " << error
|
||||
<< " force " << constraintForceIncrement
|
||||
<< " moment " << constraintMomentIncrement;
|
||||
|
||||
if (converged)
|
||||
{
|
||||
Info<< " converged";
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< " not converged";
|
||||
}
|
||||
|
||||
Info<< endl;
|
||||
}
|
||||
|
||||
return converged;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::sixDoFRigidBodyMotionConstraints::fixedPoint::read
|
||||
(
|
||||
const dictionary& sDoFRBMCDict
|
||||
)
|
||||
{
|
||||
sixDoFRigidBodyMotionConstraint::read(sDoFRBMCDict);
|
||||
|
||||
sDoFRBMCCoeffs_.lookup("fixedPoint") >> fixedPoint_;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void Foam::sixDoFRigidBodyMotionConstraints::fixedPoint::write
|
||||
(
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
os.writeKeyword("fixedPoint")
|
||||
<< fixedPoint_ << token::END_STATEMENT << nl;
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,127 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::sixDoFRigidBodyMotionConstraints::fixedPoint
|
||||
|
||||
Description
|
||||
sixDoFRigidBodyMotionConstraint. Point fixed in space.
|
||||
|
||||
SourceFiles
|
||||
fixedPoint.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef fixedPoint_H
|
||||
#define fixedPoint_H
|
||||
|
||||
#include "sixDoFRigidBodyMotionConstraint.H"
|
||||
#include "point.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
namespace sixDoFRigidBodyMotionConstraints
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class fixedPoint Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class fixedPoint
|
||||
:
|
||||
public sixDoFRigidBodyMotionConstraint
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Point which is rigidly attached to the body and constrains
|
||||
// it so that this point remains fixed. This serves as the
|
||||
// reference point for displacements as well as the target
|
||||
// position.
|
||||
point fixedPoint_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("fixedPoint");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
fixedPoint
|
||||
(
|
||||
const dictionary& sDoFRBMCDict
|
||||
);
|
||||
|
||||
//- Construct and return a clone
|
||||
virtual autoPtr<sixDoFRigidBodyMotionConstraint> clone() const
|
||||
{
|
||||
return autoPtr<sixDoFRigidBodyMotionConstraint>
|
||||
(
|
||||
new fixedPoint(*this)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~fixedPoint();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Calculate the constraint position, force and moment.
|
||||
// Global reference frame vectors. Returns boolean stating
|
||||
// whether the constraint been converged to tolerance.
|
||||
virtual bool constrain
|
||||
(
|
||||
const sixDoFRigidBodyMotion& motion,
|
||||
const vector& existingConstraintForce,
|
||||
const vector& existingConstraintMoment,
|
||||
scalar deltaT,
|
||||
vector& constraintPosition,
|
||||
vector& constraintForceIncrement,
|
||||
vector& constraintMomentIncrement
|
||||
) const;
|
||||
|
||||
//- Update properties from given dictionary
|
||||
virtual bool read(const dictionary& sDoFRBMCCoeff);
|
||||
|
||||
//- Write
|
||||
virtual void write(Ostream&) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace solidBodyMotionFunctions
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,97 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "sixDoFRigidBodyMotionConstraint.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(sixDoFRigidBodyMotionConstraint, 0);
|
||||
|
||||
defineRunTimeSelectionTable(sixDoFRigidBodyMotionConstraint, dictionary);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::sixDoFRigidBodyMotionConstraint::sixDoFRigidBodyMotionConstraint
|
||||
(
|
||||
const dictionary& sDoFRBMCDict
|
||||
)
|
||||
:
|
||||
sDoFRBMCCoeffs_
|
||||
(
|
||||
sDoFRBMCDict.subDict
|
||||
(
|
||||
word(sDoFRBMCDict.lookup("sixDoFRigidBodyMotionConstraint"))
|
||||
+ "Coeffs"
|
||||
)
|
||||
),
|
||||
tolerance_(readScalar(sDoFRBMCDict.lookup("tolerance"))),
|
||||
relaxationFactor_
|
||||
(
|
||||
sDoFRBMCDict.lookupOrDefault<scalar>("relaxationFactor", 1)
|
||||
)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::sixDoFRigidBodyMotionConstraint::~sixDoFRigidBodyMotionConstraint()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::sixDoFRigidBodyMotionConstraint::read
|
||||
(
|
||||
const dictionary& sDoFRBMCDict
|
||||
)
|
||||
{
|
||||
tolerance_ = (readScalar(sDoFRBMCDict.lookup("tolerance")));
|
||||
|
||||
relaxationFactor_ = sDoFRBMCDict.lookupOrDefault<scalar>
|
||||
(
|
||||
"relaxationFactor",
|
||||
1
|
||||
);
|
||||
|
||||
sDoFRBMCCoeffs_ = sDoFRBMCDict.subDict(type() + "Coeffs");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void Foam::sixDoFRigidBodyMotionConstraint::write(Ostream& os) const
|
||||
{
|
||||
os.writeKeyword("tolerance")
|
||||
<< tolerance_ << token::END_STATEMENT << nl;
|
||||
|
||||
os.writeKeyword("relaxationFactor")
|
||||
<< relaxationFactor_ << token::END_STATEMENT << nl;
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,178 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Namespace
|
||||
Foam::sixDoFRigidBodyMotionConstraints
|
||||
|
||||
Description
|
||||
Namespace for six DoF motion constraints
|
||||
|
||||
|
||||
Class
|
||||
Foam::sixDoFRigidBodyMotionConstraint
|
||||
|
||||
Description
|
||||
Base class for defining constraints for sixDoF motions
|
||||
|
||||
SourceFiles
|
||||
sixDoFRigidBodyMotionConstraint.C
|
||||
sixDoFRigidBodyMotionConstraintNew.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef sixDoFRigidBodyMotionConstraint_H
|
||||
#define sixDoFRigidBodyMotionConstraint_H
|
||||
|
||||
#include "Time.H"
|
||||
#include "dictionary.H"
|
||||
#include "autoPtr.H"
|
||||
#include "vector.H"
|
||||
#include "runTimeSelectionTables.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of classes
|
||||
class sixDoFRigidBodyMotion;
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class sixDoFRigidBodyMotionConstraint Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class sixDoFRigidBodyMotionConstraint
|
||||
{
|
||||
|
||||
protected:
|
||||
|
||||
// Protected data
|
||||
|
||||
//- Constraint model specific coefficient dictionary
|
||||
dictionary sDoFRBMCCoeffs_;
|
||||
|
||||
//- Solution tolerance. Meaning depends on model, usually an
|
||||
// absolute distance or angle.
|
||||
scalar tolerance_;
|
||||
|
||||
//- Relaxation factor for solution, default to one
|
||||
scalar relaxationFactor_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("sixDoFRigidBodyMotionConstraint");
|
||||
|
||||
|
||||
// Declare run-time constructor selection table
|
||||
|
||||
declareRunTimeSelectionTable
|
||||
(
|
||||
autoPtr,
|
||||
sixDoFRigidBodyMotionConstraint,
|
||||
dictionary,
|
||||
(const dictionary& sDoFRBMCDict),
|
||||
(sDoFRBMCDict)
|
||||
);
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from the sDoFRBMCDict dictionary and Time
|
||||
sixDoFRigidBodyMotionConstraint
|
||||
(
|
||||
const dictionary& sDoFRBMCDict
|
||||
);
|
||||
|
||||
//- Construct and return a clone
|
||||
virtual autoPtr<sixDoFRigidBodyMotionConstraint> clone() const = 0;
|
||||
|
||||
|
||||
// Selectors
|
||||
|
||||
//- Select constructed from the sDoFRBMCDict dictionary and Time
|
||||
static autoPtr<sixDoFRigidBodyMotionConstraint> New
|
||||
(
|
||||
const dictionary& sDoFRBMCDict
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~sixDoFRigidBodyMotionConstraint();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Calculate the constraint position, force and moment.
|
||||
// Global reference frame vectors. Returns boolean stating
|
||||
// whether the constraint been converged to tolerance.
|
||||
virtual bool constrain
|
||||
(
|
||||
const sixDoFRigidBodyMotion& motion,
|
||||
const vector& existingConstraintForce,
|
||||
const vector& existingConstraintMoment,
|
||||
scalar deltaT,
|
||||
vector& constraintPosition,
|
||||
vector& constraintForceIncrement,
|
||||
vector& constraintMomentIncrement
|
||||
) const = 0;
|
||||
|
||||
//- Update properties from given dictionary
|
||||
virtual bool read(const dictionary& sDoFRBMCDict);
|
||||
|
||||
// Access
|
||||
|
||||
// Return access to sDoFRBMCCoeffs
|
||||
inline const dictionary& coeffDict() const
|
||||
{
|
||||
return sDoFRBMCCoeffs_;
|
||||
}
|
||||
|
||||
//- Return access to the tolerance
|
||||
inline scalar tolerance() const
|
||||
{
|
||||
return tolerance_;
|
||||
}
|
||||
|
||||
//- Return access to the relaxationFactor
|
||||
inline scalar relaxationFactor() const
|
||||
{
|
||||
return relaxationFactor_;
|
||||
}
|
||||
|
||||
//- Write
|
||||
virtual void write(Ostream&) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,63 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "sixDoFRigidBodyMotionConstraint.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::autoPtr<Foam::sixDoFRigidBodyMotionConstraint>
|
||||
Foam::sixDoFRigidBodyMotionConstraint::New(const dictionary& sDoFRBMCDict)
|
||||
{
|
||||
const word constraintType
|
||||
(
|
||||
sDoFRBMCDict.lookup("sixDoFRigidBodyMotionConstraint")
|
||||
);
|
||||
|
||||
// Info<< "Selecting sixDoFRigidBodyMotionConstraint function "
|
||||
// << constraintType << endl;
|
||||
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(constraintType);
|
||||
|
||||
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"sixDoFRigidBodyMotionConstraint::New"
|
||||
"("
|
||||
"const dictionary& sDoFRBMCDict"
|
||||
")"
|
||||
) << "Unknown sixDoFRigidBodyMotionConstraint type "
|
||||
<< constraintType << nl << nl
|
||||
<< "Valid sixDoFRigidBodyMotionConstraints are : " << endl
|
||||
<< dictionaryConstructorTablePtr_->sortedToc()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
return autoPtr<sixDoFRigidBodyMotionConstraint>(cstrIter()(sDoFRBMCDict));
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,367 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
// * * * * * * * * * * * * * 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 Foam::Tuple2<Foam::tensor, Foam::vector>
|
||||
Foam::sixDoFRigidBodyMotion::rotate
|
||||
(
|
||||
const tensor& Q0,
|
||||
const vector& pi0,
|
||||
const scalar deltaT
|
||||
) const
|
||||
{
|
||||
Tuple2<tensor, vector> Qpi(Q0, pi0);
|
||||
tensor& Q = Qpi.first();
|
||||
vector& pi = Qpi.second();
|
||||
|
||||
tensor 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;
|
||||
|
||||
return Qpi;
|
||||
}
|
||||
|
||||
|
||||
inline const Foam::sixDoFRigidBodyMotionState&
|
||||
Foam::sixDoFRigidBodyMotion::motionState() const
|
||||
{
|
||||
return motionState_;
|
||||
}
|
||||
|
||||
|
||||
inline const Foam::PtrList<Foam::sixDoFRigidBodyMotionRestraint>&
|
||||
Foam::sixDoFRigidBodyMotion::restraints() const
|
||||
{
|
||||
return restraints_;
|
||||
}
|
||||
|
||||
|
||||
inline const Foam::wordList& Foam::sixDoFRigidBodyMotion::restraintNames() const
|
||||
{
|
||||
return restraintNames_;
|
||||
}
|
||||
|
||||
|
||||
inline const Foam::PtrList<Foam::sixDoFRigidBodyMotionConstraint>&
|
||||
Foam::sixDoFRigidBodyMotion::constraints() const
|
||||
{
|
||||
return constraints_;
|
||||
}
|
||||
|
||||
|
||||
inline const Foam::wordList&
|
||||
Foam::sixDoFRigidBodyMotion::constraintNames() const
|
||||
{
|
||||
return constraintNames_;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::label Foam::sixDoFRigidBodyMotion::maxConstraintIterations() const
|
||||
{
|
||||
return maxConstraintIterations_;
|
||||
}
|
||||
|
||||
|
||||
inline const Foam::point&
|
||||
Foam::sixDoFRigidBodyMotion::initialCentreOfMass() const
|
||||
{
|
||||
return initialCentreOfMass_;
|
||||
}
|
||||
|
||||
|
||||
inline const Foam::tensor&
|
||||
Foam::sixDoFRigidBodyMotion::initialQ() const
|
||||
{
|
||||
return initialQ_;
|
||||
}
|
||||
|
||||
|
||||
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 const Foam::tensor& Foam::sixDoFRigidBodyMotion::Q0() const
|
||||
{
|
||||
return motionState0_.Q();
|
||||
}
|
||||
|
||||
|
||||
inline const Foam::vector& Foam::sixDoFRigidBodyMotion::v0() const
|
||||
{
|
||||
return motionState0_.v();
|
||||
}
|
||||
|
||||
|
||||
inline const Foam::vector& Foam::sixDoFRigidBodyMotion::a0() const
|
||||
{
|
||||
return motionState0_.a();
|
||||
}
|
||||
|
||||
|
||||
inline const Foam::vector& Foam::sixDoFRigidBodyMotion::pi0() const
|
||||
{
|
||||
return motionState0_.pi();
|
||||
}
|
||||
|
||||
|
||||
inline const Foam::vector& Foam::sixDoFRigidBodyMotion::tau0() const
|
||||
{
|
||||
return motionState0_.tau();
|
||||
}
|
||||
|
||||
|
||||
inline Foam::point& Foam::sixDoFRigidBodyMotion::initialCentreOfMass()
|
||||
{
|
||||
return initialCentreOfMass_;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::tensor& Foam::sixDoFRigidBodyMotion::initialQ()
|
||||
{
|
||||
return initialQ_;
|
||||
}
|
||||
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
inline Foam::tmp<Foam::pointField>
|
||||
Foam::sixDoFRigidBodyMotion::currentPosition(const pointField& pInitial) const
|
||||
{
|
||||
return
|
||||
(
|
||||
centreOfMass()
|
||||
+ (Q() & initialQ_.T() & (pInitial - initialCentreOfMass_)))
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::point Foam::sixDoFRigidBodyMotion::currentPosition
|
||||
(
|
||||
const point& pInitial
|
||||
) const
|
||||
{
|
||||
return
|
||||
(
|
||||
centreOfMass()
|
||||
+ (Q() & initialQ_.T() & (pInitial - initialCentreOfMass_))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
inline Foam::vector Foam::sixDoFRigidBodyMotion::currentOrientation
|
||||
(
|
||||
const vector& vInitial
|
||||
) const
|
||||
{
|
||||
return (Q() & initialQ_.T() & vInitial);
|
||||
}
|
||||
|
||||
|
||||
inline const Foam::tensor&
|
||||
Foam::sixDoFRigidBodyMotion::orientation() const
|
||||
{
|
||||
return Q();
|
||||
}
|
||||
|
||||
|
||||
inline Foam::vector Foam::sixDoFRigidBodyMotion::omega() const
|
||||
{
|
||||
return Q() & (inv(momentOfInertia_) & pi());
|
||||
}
|
||||
|
||||
|
||||
inline Foam::point Foam::sixDoFRigidBodyMotion::currentVelocity
|
||||
(
|
||||
const point& pt
|
||||
) const
|
||||
{
|
||||
return (omega() ^ (pt - centreOfMass())) + v();
|
||||
}
|
||||
|
||||
|
||||
inline const Foam::point& Foam::sixDoFRigidBodyMotion::centreOfMass() const
|
||||
{
|
||||
return motionState_.centreOfMass();
|
||||
}
|
||||
|
||||
|
||||
inline const Foam::point& Foam::sixDoFRigidBodyMotion::centreOfMass0() const
|
||||
{
|
||||
return motionState0_.centreOfMass();
|
||||
}
|
||||
|
||||
|
||||
inline const Foam::diagTensor&
|
||||
Foam::sixDoFRigidBodyMotion::momentOfInertia() const
|
||||
{
|
||||
return momentOfInertia_;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::scalar Foam::sixDoFRigidBodyMotion::mass() const
|
||||
{
|
||||
return mass_;
|
||||
}
|
||||
|
||||
|
||||
inline bool Foam::sixDoFRigidBodyMotion::report() const
|
||||
{
|
||||
return report_;
|
||||
}
|
||||
|
||||
|
||||
inline void Foam::sixDoFRigidBodyMotion::newTime()
|
||||
{
|
||||
motionState0_ = motionState_;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::point& Foam::sixDoFRigidBodyMotion::centreOfMass()
|
||||
{
|
||||
return motionState_.centreOfMass();
|
||||
}
|
||||
|
||||
|
||||
inline Foam::diagTensor& Foam::sixDoFRigidBodyMotion::momentOfInertia()
|
||||
{
|
||||
return momentOfInertia_;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::scalar& Foam::sixDoFRigidBodyMotion::mass()
|
||||
{
|
||||
return mass_;
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,157 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "sixDoFRigidBodyMotion.H"
|
||||
#include "IOstreams.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::sixDoFRigidBodyMotion::write(Ostream& os) const
|
||||
{
|
||||
motionState_.write(os);
|
||||
|
||||
os.writeKeyword("initialCentreOfMass")
|
||||
<< initialCentreOfMass_ << token::END_STATEMENT << nl;
|
||||
os.writeKeyword("initialOrientation")
|
||||
<< initialQ_ << token::END_STATEMENT << nl;
|
||||
os.writeKeyword("momentOfInertia")
|
||||
<< momentOfInertia_ << token::END_STATEMENT << nl;
|
||||
os.writeKeyword("mass")
|
||||
<< mass_ << token::END_STATEMENT << nl;
|
||||
os.writeKeyword("accelerationRelaxation")
|
||||
<< aRelax_ << token::END_STATEMENT << nl;
|
||||
os.writeKeyword("report")
|
||||
<< report_ << token::END_STATEMENT << nl;
|
||||
|
||||
if (!restraints_.empty())
|
||||
{
|
||||
os << indent << "restraints" << nl
|
||||
<< indent << token::BEGIN_BLOCK << incrIndent << nl;
|
||||
|
||||
forAll(restraints_, rI)
|
||||
{
|
||||
word restraintType = restraints_[rI].type();
|
||||
|
||||
os << indent << restraintNames_[rI] << nl
|
||||
<< indent << token::BEGIN_BLOCK << incrIndent << endl;
|
||||
|
||||
os.writeKeyword("sixDoFRigidBodyMotionRestraint")
|
||||
<< restraintType << token::END_STATEMENT << nl;
|
||||
|
||||
os.writeKeyword(word(restraintType + "Coeffs")) << nl;
|
||||
|
||||
os << indent << token::BEGIN_BLOCK << nl << incrIndent;
|
||||
|
||||
restraints_[rI].write(os);
|
||||
|
||||
os << decrIndent << indent << token::END_BLOCK << nl;
|
||||
|
||||
os << decrIndent << indent << token::END_BLOCK << endl;
|
||||
}
|
||||
|
||||
os << decrIndent << indent << token::END_BLOCK << nl;
|
||||
}
|
||||
|
||||
if (!constraints_.empty())
|
||||
{
|
||||
os << indent << "constraints" << nl
|
||||
<< indent << token::BEGIN_BLOCK << incrIndent << nl;
|
||||
|
||||
os.writeKeyword("maxIterations")
|
||||
<< maxConstraintIterations_ << token::END_STATEMENT << nl;
|
||||
|
||||
forAll(constraints_, rI)
|
||||
{
|
||||
word constraintType = constraints_[rI].type();
|
||||
|
||||
os << indent << constraintNames_[rI] << nl
|
||||
<< indent << token::BEGIN_BLOCK << incrIndent << endl;
|
||||
|
||||
os.writeKeyword("sixDoFRigidBodyMotionConstraint")
|
||||
<< constraintType << token::END_STATEMENT << nl;
|
||||
|
||||
constraints_[rI].sixDoFRigidBodyMotionConstraint::write(os);
|
||||
|
||||
os.writeKeyword(word(constraintType + "Coeffs")) << nl;
|
||||
|
||||
os << indent << token::BEGIN_BLOCK << nl << incrIndent;
|
||||
|
||||
constraints_[rI].write(os);
|
||||
|
||||
os << decrIndent << indent << token::END_BLOCK << nl;
|
||||
|
||||
os << decrIndent << indent << token::END_BLOCK << endl;
|
||||
}
|
||||
|
||||
os << decrIndent << indent << token::END_BLOCK << nl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
||||
|
||||
Foam::Istream& Foam::operator>>(Istream& is, sixDoFRigidBodyMotion& sDoFRBM)
|
||||
{
|
||||
is >> sDoFRBM.motionState_
|
||||
>> sDoFRBM.initialCentreOfMass_
|
||||
>> sDoFRBM.initialQ_
|
||||
>> 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.initialCentreOfMass()
|
||||
<< token::SPACE << sDoFRBM.initialQ()
|
||||
<< 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;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,217 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "linearAxialAngularSpring.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "sixDoFRigidBodyMotion.H"
|
||||
#include "transform.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace sixDoFRigidBodyMotionRestraints
|
||||
{
|
||||
defineTypeNameAndDebug(linearAxialAngularSpring, 0);
|
||||
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
sixDoFRigidBodyMotionRestraint,
|
||||
linearAxialAngularSpring,
|
||||
dictionary
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::sixDoFRigidBodyMotionRestraints::linearAxialAngularSpring::
|
||||
linearAxialAngularSpring
|
||||
(
|
||||
const dictionary& sDoFRBMRDict
|
||||
)
|
||||
:
|
||||
sixDoFRigidBodyMotionRestraint(sDoFRBMRDict),
|
||||
refQ_(),
|
||||
axis_(),
|
||||
stiffness_(),
|
||||
damping_()
|
||||
{
|
||||
read(sDoFRBMRDict);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructors * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::sixDoFRigidBodyMotionRestraints::linearAxialAngularSpring::
|
||||
~linearAxialAngularSpring()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
void
|
||||
Foam::sixDoFRigidBodyMotionRestraints::linearAxialAngularSpring::restrain
|
||||
(
|
||||
const sixDoFRigidBodyMotion& motion,
|
||||
vector& restraintPosition,
|
||||
vector& restraintForce,
|
||||
vector& restraintMoment
|
||||
) const
|
||||
{
|
||||
vector refDir = rotationTensor(vector(1, 0 ,0), axis_) & vector(0, 1, 0);
|
||||
|
||||
vector oldDir = refQ_ & refDir;
|
||||
vector newDir = motion.orientation() & refDir;
|
||||
|
||||
if (mag(oldDir & axis_) > 0.95 || mag(newDir & axis_) > 0.95)
|
||||
{
|
||||
// Directions getting close to the axis, change reference
|
||||
|
||||
refDir = rotationTensor(vector(1, 0 ,0), axis_) & vector(0, 0, 1);
|
||||
oldDir = refQ_ & refDir;
|
||||
newDir = motion.orientation() & refDir;
|
||||
}
|
||||
|
||||
// Removing any axis component from oldDir and newDir and normalising
|
||||
oldDir -= (axis_ & oldDir)*axis_;
|
||||
oldDir /= (mag(oldDir) + VSMALL);
|
||||
|
||||
newDir -= (axis_ & newDir)*axis_;
|
||||
newDir /= (mag(newDir) + VSMALL);
|
||||
|
||||
scalar theta = mag(acos(min(oldDir & newDir, 1.0)));
|
||||
|
||||
// Temporary axis with sign information.
|
||||
vector a = (oldDir ^ newDir);
|
||||
|
||||
// Remove any component that is not along axis that may creep in
|
||||
a = (a & axis_)*axis_;
|
||||
|
||||
scalar magA = mag(a);
|
||||
|
||||
if (magA > VSMALL)
|
||||
{
|
||||
a /= magA;
|
||||
}
|
||||
else
|
||||
{
|
||||
a = vector::zero;
|
||||
}
|
||||
|
||||
// Damping of along axis angular velocity only
|
||||
restraintMoment = -stiffness_*theta*a - damping_*(motion.omega() & a)*a;
|
||||
|
||||
restraintForce = vector::zero;
|
||||
|
||||
// Not needed to be altered as restraintForce is zero, but set to
|
||||
// centreOfMass to be sure of no spurious moment
|
||||
restraintPosition = motion.centreOfMass();
|
||||
|
||||
if (motion.report())
|
||||
{
|
||||
Info<< " angle " << theta*sign(a & axis_)
|
||||
<< " force " << restraintForce
|
||||
<< " moment " << restraintMoment
|
||||
<< endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool Foam::sixDoFRigidBodyMotionRestraints::linearAxialAngularSpring::read
|
||||
(
|
||||
const dictionary& sDoFRBMRDict
|
||||
)
|
||||
{
|
||||
sixDoFRigidBodyMotionRestraint::read(sDoFRBMRDict);
|
||||
|
||||
refQ_ = sDoFRBMRCoeffs_.lookupOrDefault<tensor>("referenceOrientation", I);
|
||||
|
||||
if (mag(mag(refQ_) - sqrt(3.0)) > 1e-9)
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"Foam::sixDoFRigidBodyMotionRestraints::linearAxialAngularSpring::"
|
||||
"read"
|
||||
"("
|
||||
"const dictionary& sDoFRBMRDict"
|
||||
")"
|
||||
)
|
||||
<< "referenceOrientation " << refQ_ << " is not a rotation tensor. "
|
||||
<< "mag(referenceOrientation) - sqrt(3) = "
|
||||
<< mag(refQ_) - sqrt(3.0) << nl
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
axis_ = sDoFRBMRCoeffs_.lookup("axis");
|
||||
|
||||
scalar magAxis(mag(axis_));
|
||||
|
||||
if (magAxis > VSMALL)
|
||||
{
|
||||
axis_ /= magAxis;
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"Foam::sixDoFRigidBodyMotionRestraints::linearAxialAngularSpring::"
|
||||
"read"
|
||||
"("
|
||||
"const dictionary& sDoFRBMCDict"
|
||||
")"
|
||||
)
|
||||
<< "axis has zero length"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
sDoFRBMRCoeffs_.lookup("stiffness") >> stiffness_;
|
||||
|
||||
sDoFRBMRCoeffs_.lookup("damping") >> damping_;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void Foam::sixDoFRigidBodyMotionRestraints::linearAxialAngularSpring::write
|
||||
(
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
os.writeKeyword("referenceOrientation")
|
||||
<< refQ_ << token::END_STATEMENT << nl;
|
||||
|
||||
os.writeKeyword("axis")
|
||||
<< axis_ << token::END_STATEMENT << nl;
|
||||
|
||||
os.writeKeyword("stiffness")
|
||||
<< stiffness_ << token::END_STATEMENT << nl;
|
||||
|
||||
os.writeKeyword("damping")
|
||||
<< damping_ << token::END_STATEMENT << nl;
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,130 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::sixDoFRigidBodyMotionRestraints::linearAxialAngularSpring
|
||||
|
||||
Description
|
||||
sixDoFRigidBodyMotionRestraints model. Linear axial angular spring.
|
||||
|
||||
SourceFiles
|
||||
linearAxialAngularSpring.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef linearAxialAngularSpring_H
|
||||
#define linearAxialAngularSpring_H
|
||||
|
||||
#include "sixDoFRigidBodyMotionRestraint.H"
|
||||
#include "point.H"
|
||||
#include "tensor.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
namespace sixDoFRigidBodyMotionRestraints
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class linearAxialAngularSpring Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class linearAxialAngularSpring
|
||||
:
|
||||
public sixDoFRigidBodyMotionRestraint
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Reference orientation where there is no moment
|
||||
tensor refQ_;
|
||||
|
||||
//- Global unit axis around which the motion is sprung
|
||||
vector axis_;
|
||||
|
||||
//- Spring stiffness coefficient (Nm/rad)
|
||||
scalar stiffness_;
|
||||
|
||||
//- Damping coefficient (Nms/rad)
|
||||
scalar damping_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("linearAxialAngularSpring");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
linearAxialAngularSpring
|
||||
(
|
||||
const dictionary& sDoFRBMRDict
|
||||
);
|
||||
|
||||
//- Construct and return a clone
|
||||
virtual autoPtr<sixDoFRigidBodyMotionRestraint> clone() const
|
||||
{
|
||||
return autoPtr<sixDoFRigidBodyMotionRestraint>
|
||||
(
|
||||
new linearAxialAngularSpring(*this)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~linearAxialAngularSpring();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Calculate the restraint position, force and moment.
|
||||
// Global reference frame vectors.
|
||||
virtual void restrain
|
||||
(
|
||||
const sixDoFRigidBodyMotion& motion,
|
||||
vector& restraintPosition,
|
||||
vector& restraintForce,
|
||||
vector& restraintMoment
|
||||
) const;
|
||||
|
||||
//- Update properties from given dictionary
|
||||
virtual bool read(const dictionary& sDoFRBMRCoeff);
|
||||
|
||||
//- Write
|
||||
virtual void write(Ostream&) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace solidBodyMotionFunctions
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,150 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "linearSpring.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "sixDoFRigidBodyMotion.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace sixDoFRigidBodyMotionRestraints
|
||||
{
|
||||
defineTypeNameAndDebug(linearSpring, 0);
|
||||
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
sixDoFRigidBodyMotionRestraint,
|
||||
linearSpring,
|
||||
dictionary
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::sixDoFRigidBodyMotionRestraints::linearSpring::linearSpring
|
||||
(
|
||||
const dictionary& sDoFRBMRDict
|
||||
)
|
||||
:
|
||||
sixDoFRigidBodyMotionRestraint(sDoFRBMRDict),
|
||||
anchor_(),
|
||||
refAttachmentPt_(),
|
||||
stiffness_(),
|
||||
damping_(),
|
||||
restLength_()
|
||||
{
|
||||
read(sDoFRBMRDict);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructors * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::sixDoFRigidBodyMotionRestraints::linearSpring::~linearSpring()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::sixDoFRigidBodyMotionRestraints::linearSpring::restrain
|
||||
(
|
||||
const sixDoFRigidBodyMotion& motion,
|
||||
vector& restraintPosition,
|
||||
vector& restraintForce,
|
||||
vector& restraintMoment
|
||||
) const
|
||||
{
|
||||
restraintPosition = motion.currentPosition(refAttachmentPt_);
|
||||
|
||||
vector r = restraintPosition - anchor_;
|
||||
|
||||
scalar magR = mag(r);
|
||||
|
||||
// r is now the r unit vector
|
||||
r /= (magR + VSMALL);
|
||||
|
||||
vector v = motion.currentVelocity(restraintPosition);
|
||||
|
||||
restraintForce = -stiffness_*(magR - restLength_)*r - damping_*(r & v)*r;
|
||||
|
||||
restraintMoment = vector::zero;
|
||||
|
||||
if (motion.report())
|
||||
{
|
||||
Info<< " attachmentPt - anchor " << r*magR
|
||||
<< " spring length " << magR
|
||||
<< " force " << restraintForce
|
||||
<< " moment " << restraintMoment
|
||||
<< endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool Foam::sixDoFRigidBodyMotionRestraints::linearSpring::read
|
||||
(
|
||||
const dictionary& sDoFRBMRDict
|
||||
)
|
||||
{
|
||||
sixDoFRigidBodyMotionRestraint::read(sDoFRBMRDict);
|
||||
|
||||
sDoFRBMRCoeffs_.lookup("anchor") >> anchor_;
|
||||
|
||||
sDoFRBMRCoeffs_.lookup("refAttachmentPt") >> refAttachmentPt_;
|
||||
|
||||
sDoFRBMRCoeffs_.lookup("stiffness") >> stiffness_;
|
||||
|
||||
sDoFRBMRCoeffs_.lookup("damping") >> damping_;
|
||||
|
||||
sDoFRBMRCoeffs_.lookup("restLength") >> restLength_;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void Foam::sixDoFRigidBodyMotionRestraints::linearSpring::write
|
||||
(
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
os.writeKeyword("anchor")
|
||||
<< anchor_ << token::END_STATEMENT << nl;
|
||||
|
||||
os.writeKeyword("refAttachmentPt")
|
||||
<< refAttachmentPt_ << token::END_STATEMENT << nl;
|
||||
|
||||
os.writeKeyword("stiffness")
|
||||
<< stiffness_ << token::END_STATEMENT << nl;
|
||||
|
||||
os.writeKeyword("damping")
|
||||
<< damping_ << token::END_STATEMENT << nl;
|
||||
|
||||
os.writeKeyword("restLength")
|
||||
<< restLength_ << token::END_STATEMENT << nl;
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,133 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::sixDoFRigidBodyMotionRestraints::linearSpring
|
||||
|
||||
Description
|
||||
sixDoFRigidBodyMotionRestraints model. Linear spring.
|
||||
|
||||
SourceFiles
|
||||
linearSpring.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef linearSpring_H
|
||||
#define linearSpring_H
|
||||
|
||||
#include "sixDoFRigidBodyMotionRestraint.H"
|
||||
#include "point.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
namespace sixDoFRigidBodyMotionRestraints
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class linearSpring Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class linearSpring
|
||||
:
|
||||
public sixDoFRigidBodyMotionRestraint
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Anchor point, where the spring is attached to an immovable
|
||||
// object
|
||||
point anchor_;
|
||||
|
||||
//- Reference point of attachment to the solid body
|
||||
point refAttachmentPt_;
|
||||
|
||||
//- Spring stiffness coefficient (N/m)
|
||||
scalar stiffness_;
|
||||
|
||||
//- Damping coefficient (Ns/m)
|
||||
scalar damping_;
|
||||
|
||||
//- Rest length - length of spring when no forces are applied to it
|
||||
scalar restLength_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("linearSpring");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
linearSpring
|
||||
(
|
||||
const dictionary& sDoFRBMRDict
|
||||
);
|
||||
|
||||
//- Construct and return a clone
|
||||
virtual autoPtr<sixDoFRigidBodyMotionRestraint> clone() const
|
||||
{
|
||||
return autoPtr<sixDoFRigidBodyMotionRestraint>
|
||||
(
|
||||
new linearSpring(*this)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~linearSpring();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Calculate the restraint position, force and moment.
|
||||
// Global reference frame vectors.
|
||||
virtual void restrain
|
||||
(
|
||||
const sixDoFRigidBodyMotion& motion,
|
||||
vector& restraintPosition,
|
||||
vector& restraintForce,
|
||||
vector& restraintMoment
|
||||
) const;
|
||||
|
||||
//- Update properties from given dictionary
|
||||
virtual bool read(const dictionary& sDoFRBMRCoeff);
|
||||
|
||||
//- Write
|
||||
virtual void write(Ostream&) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace solidBodyMotionFunctions
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,75 +0,0 @@
|
||||
/*---------------------------------------------------------------------------* \
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "sixDoFRigidBodyMotionRestraint.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(sixDoFRigidBodyMotionRestraint, 0);
|
||||
|
||||
defineRunTimeSelectionTable(sixDoFRigidBodyMotionRestraint, dictionary);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::sixDoFRigidBodyMotionRestraint::sixDoFRigidBodyMotionRestraint
|
||||
(
|
||||
const dictionary& sDoFRBMRDict
|
||||
)
|
||||
:
|
||||
sDoFRBMRCoeffs_
|
||||
(
|
||||
sDoFRBMRDict.subDict
|
||||
(
|
||||
word(sDoFRBMRDict.lookup("sixDoFRigidBodyMotionRestraint"))
|
||||
+ "Coeffs"
|
||||
)
|
||||
)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::sixDoFRigidBodyMotionRestraint::~sixDoFRigidBodyMotionRestraint()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::sixDoFRigidBodyMotionRestraint::read
|
||||
(
|
||||
const dictionary& sDoFRBMRDict
|
||||
)
|
||||
{
|
||||
sDoFRBMRCoeffs_ = sDoFRBMRDict.subDict(type() + "Coeffs");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,155 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Namespace
|
||||
Foam::sixDoFRigidBodyMotionRestraints
|
||||
|
||||
Description
|
||||
Namespace for six DoF motion restraints
|
||||
|
||||
|
||||
Class
|
||||
Foam::sixDoFRigidBodyMotionRestraint
|
||||
|
||||
Description
|
||||
Base class for defining restraints for sixDoF motions
|
||||
|
||||
SourceFiles
|
||||
sixDoFRigidBodyMotionRestraint.C
|
||||
sixDoFRigidBodyMotionRestraintNew.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef sixDoFRigidBodyMotionRestraint_H
|
||||
#define sixDoFRigidBodyMotionRestraint_H
|
||||
|
||||
#include "Time.H"
|
||||
#include "dictionary.H"
|
||||
#include "autoPtr.H"
|
||||
#include "vector.H"
|
||||
#include "runTimeSelectionTables.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of classes
|
||||
class sixDoFRigidBodyMotion;
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class sixDoFRigidBodyMotionRestraint Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class sixDoFRigidBodyMotionRestraint
|
||||
{
|
||||
|
||||
protected:
|
||||
|
||||
// Protected data
|
||||
|
||||
//- Restraint model specific coefficient dictionary
|
||||
dictionary sDoFRBMRCoeffs_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("sixDoFRigidBodyMotionRestraint");
|
||||
|
||||
|
||||
// Declare run-time constructor selection table
|
||||
|
||||
declareRunTimeSelectionTable
|
||||
(
|
||||
autoPtr,
|
||||
sixDoFRigidBodyMotionRestraint,
|
||||
dictionary,
|
||||
(const dictionary& sDoFRBMRDict),
|
||||
(sDoFRBMRDict)
|
||||
);
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from the sDoFRBMRDict dictionary and Time
|
||||
sixDoFRigidBodyMotionRestraint
|
||||
(
|
||||
const dictionary& sDoFRBMRDict
|
||||
);
|
||||
|
||||
//- Construct and return a clone
|
||||
virtual autoPtr<sixDoFRigidBodyMotionRestraint> clone() const = 0;
|
||||
|
||||
|
||||
// Selectors
|
||||
|
||||
//- Select constructed from the sDoFRBMRDict dictionary and Time
|
||||
static autoPtr<sixDoFRigidBodyMotionRestraint> New
|
||||
(
|
||||
const dictionary& sDoFRBMRDict
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~sixDoFRigidBodyMotionRestraint();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Calculate the restraint position, force and moment.
|
||||
// Global reference frame vectors.
|
||||
virtual void restrain
|
||||
(
|
||||
const sixDoFRigidBodyMotion& motion,
|
||||
vector& restraintPosition,
|
||||
vector& restraintForce,
|
||||
vector& restraintMoment
|
||||
) const = 0;
|
||||
|
||||
//- Update properties from given dictionary
|
||||
virtual bool read(const dictionary& sDoFRBMRDict);
|
||||
|
||||
// Access
|
||||
|
||||
// Return access to sDoFRBMRCoeffs
|
||||
inline const dictionary& coeffDict() const
|
||||
{
|
||||
return sDoFRBMRCoeffs_;
|
||||
}
|
||||
|
||||
//- Write
|
||||
virtual void write(Ostream&) const = 0;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,63 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "sixDoFRigidBodyMotionRestraint.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::autoPtr<Foam::sixDoFRigidBodyMotionRestraint>
|
||||
Foam::sixDoFRigidBodyMotionRestraint::New(const dictionary& sDoFRBMRDict)
|
||||
{
|
||||
const word restraintType
|
||||
(
|
||||
sDoFRBMRDict.lookup("sixDoFRigidBodyMotionRestraint")
|
||||
);
|
||||
|
||||
// Info<< "Selecting sixDoFRigidBodyMotionRestraint function "
|
||||
// << restraintType << endl;
|
||||
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(restraintType);
|
||||
|
||||
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"sixDoFRigidBodyMotionRestraint::New"
|
||||
"("
|
||||
"const dictionary& sDoFRBMRDict"
|
||||
")"
|
||||
) << "Unknown sixDoFRigidBodyMotionRestraint type "
|
||||
<< restraintType << nl << nl
|
||||
<< "Valid sixDoFRigidBodyMotionRestraint types are : " << endl
|
||||
<< dictionaryConstructorTablePtr_->sortedToc()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
return autoPtr<sixDoFRigidBodyMotionRestraint>(cstrIter()(sDoFRBMRDict));
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,170 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "sphericalAngularSpring.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "sixDoFRigidBodyMotion.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace sixDoFRigidBodyMotionRestraints
|
||||
{
|
||||
defineTypeNameAndDebug(sphericalAngularSpring, 0);
|
||||
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
sixDoFRigidBodyMotionRestraint,
|
||||
sphericalAngularSpring,
|
||||
dictionary
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::sixDoFRigidBodyMotionRestraints::sphericalAngularSpring::
|
||||
sphericalAngularSpring
|
||||
(
|
||||
const dictionary& sDoFRBMRDict
|
||||
)
|
||||
:
|
||||
sixDoFRigidBodyMotionRestraint(sDoFRBMRDict),
|
||||
refQ_(),
|
||||
stiffness_(),
|
||||
damping_()
|
||||
{
|
||||
read(sDoFRBMRDict);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructors * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::sixDoFRigidBodyMotionRestraints::sphericalAngularSpring::
|
||||
~sphericalAngularSpring()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
void
|
||||
Foam::sixDoFRigidBodyMotionRestraints::sphericalAngularSpring::restrain
|
||||
(
|
||||
const sixDoFRigidBodyMotion& motion,
|
||||
vector& restraintPosition,
|
||||
vector& restraintForce,
|
||||
vector& restraintMoment
|
||||
) const
|
||||
{
|
||||
restraintMoment = vector::zero;
|
||||
|
||||
for (direction cmpt=0; cmpt<vector::nComponents; cmpt++)
|
||||
{
|
||||
vector axis = vector::zero;
|
||||
|
||||
axis[cmpt] = 1;
|
||||
|
||||
vector refDir = vector::zero;
|
||||
|
||||
refDir[(cmpt + 1) % 3] = 1;
|
||||
|
||||
vector newDir = motion.orientation() & refDir;
|
||||
|
||||
axis = (refQ_ & axis);
|
||||
|
||||
refDir = (refQ_ & refDir);
|
||||
|
||||
newDir -= (axis & newDir)*axis;
|
||||
|
||||
restraintMoment += -stiffness_*(refDir ^ newDir);
|
||||
}
|
||||
|
||||
restraintMoment += -damping_*motion.omega();
|
||||
|
||||
restraintForce = vector::zero;
|
||||
|
||||
// Not needed to be altered as restraintForce is zero, but set to
|
||||
// centreOfMass to be sure of no spurious moment
|
||||
restraintPosition = motion.centreOfMass();
|
||||
|
||||
if (motion.report())
|
||||
{
|
||||
Info<< " force " << restraintForce
|
||||
<< " moment " << restraintMoment
|
||||
<< endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool Foam::sixDoFRigidBodyMotionRestraints::sphericalAngularSpring::read
|
||||
(
|
||||
const dictionary& sDoFRBMRDict
|
||||
)
|
||||
{
|
||||
sixDoFRigidBodyMotionRestraint::read(sDoFRBMRDict);
|
||||
|
||||
refQ_ = sDoFRBMRCoeffs_.lookupOrDefault<tensor>("referenceOrientation", I);
|
||||
|
||||
if (mag(mag(refQ_) - sqrt(3.0)) > 1e-9)
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"Foam::sixDoFRigidBodyMotionRestraints::sphericalAngularSpring::"
|
||||
"read"
|
||||
"("
|
||||
"const dictionary& sDoFRBMRDict"
|
||||
")"
|
||||
)
|
||||
<< "referenceOrientation " << refQ_ << " is not a rotation tensor. "
|
||||
<< "mag(referenceOrientation) - sqrt(3) = "
|
||||
<< mag(refQ_) - sqrt(3.0) << nl
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
sDoFRBMRCoeffs_.lookup("stiffness") >> stiffness_;
|
||||
|
||||
sDoFRBMRCoeffs_.lookup("damping") >> damping_;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void Foam::sixDoFRigidBodyMotionRestraints::sphericalAngularSpring::write
|
||||
(
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
os.writeKeyword("referenceOrientation")
|
||||
<< refQ_ << token::END_STATEMENT << nl;
|
||||
|
||||
os.writeKeyword("stiffness") << stiffness_ << token::END_STATEMENT << nl;
|
||||
|
||||
os.writeKeyword("damping") << damping_ << token::END_STATEMENT << nl;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,127 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::sixDoFRigidBodyMotionRestraints::sphericalAngularSpring
|
||||
|
||||
Description
|
||||
sixDoFRigidBodyMotionRestraints model. Spherical angular spring.
|
||||
|
||||
SourceFiles
|
||||
sphericalAngularSpring.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef sphericalAngularSpring_H
|
||||
#define sphericalAngularSpring_H
|
||||
|
||||
#include "sixDoFRigidBodyMotionRestraint.H"
|
||||
#include "point.H"
|
||||
#include "tensor.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
namespace sixDoFRigidBodyMotionRestraints
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class sphericalAngularSpring Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class sphericalAngularSpring
|
||||
:
|
||||
public sixDoFRigidBodyMotionRestraint
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Reference orientation where there is no moment
|
||||
tensor refQ_;
|
||||
|
||||
//- Spring stiffness coefficient (Nm/rad)
|
||||
scalar stiffness_;
|
||||
|
||||
//- Damping coefficient (Nms/rad)
|
||||
scalar damping_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("sphericalAngularSpring");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
sphericalAngularSpring
|
||||
(
|
||||
const dictionary& sDoFRBMRDict
|
||||
);
|
||||
|
||||
//- Construct and return a clone
|
||||
virtual autoPtr<sixDoFRigidBodyMotionRestraint> clone() const
|
||||
{
|
||||
return autoPtr<sixDoFRigidBodyMotionRestraint>
|
||||
(
|
||||
new sphericalAngularSpring(*this)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~sphericalAngularSpring();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Calculate the restraint position, force and moment.
|
||||
// Global reference frame vectors.
|
||||
virtual void restrain
|
||||
(
|
||||
const sixDoFRigidBodyMotion& motion,
|
||||
vector& restraintPosition,
|
||||
vector& restraintForce,
|
||||
vector& restraintMoment
|
||||
) const;
|
||||
|
||||
//- Update properties from given dictionary
|
||||
virtual bool read(const dictionary& sDoFRBMRCoeff);
|
||||
|
||||
//- Write
|
||||
virtual void write(Ostream&) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace solidBodyMotionFunctions
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,253 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "tabulatedAxialAngularSpring.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "sixDoFRigidBodyMotion.H"
|
||||
#include "transform.H"
|
||||
#include "unitConversion.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace sixDoFRigidBodyMotionRestraints
|
||||
{
|
||||
defineTypeNameAndDebug(tabulatedAxialAngularSpring, 0);
|
||||
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
sixDoFRigidBodyMotionRestraint,
|
||||
tabulatedAxialAngularSpring,
|
||||
dictionary
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::sixDoFRigidBodyMotionRestraints::tabulatedAxialAngularSpring::
|
||||
tabulatedAxialAngularSpring
|
||||
(
|
||||
const dictionary& sDoFRBMRDict
|
||||
)
|
||||
:
|
||||
sixDoFRigidBodyMotionRestraint(sDoFRBMRDict),
|
||||
refQ_(),
|
||||
axis_(),
|
||||
moment_(),
|
||||
convertToDegrees_(),
|
||||
damping_()
|
||||
{
|
||||
read(sDoFRBMRDict);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructors * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::sixDoFRigidBodyMotionRestraints::tabulatedAxialAngularSpring::
|
||||
~tabulatedAxialAngularSpring()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
void
|
||||
Foam::sixDoFRigidBodyMotionRestraints::tabulatedAxialAngularSpring::restrain
|
||||
(
|
||||
const sixDoFRigidBodyMotion& motion,
|
||||
vector& restraintPosition,
|
||||
vector& restraintForce,
|
||||
vector& restraintMoment
|
||||
) const
|
||||
{
|
||||
vector refDir = rotationTensor(vector(1, 0 ,0), axis_) & vector(0, 1, 0);
|
||||
|
||||
vector oldDir = refQ_ & refDir;
|
||||
|
||||
vector newDir = motion.orientation() & refDir;
|
||||
|
||||
if (mag(oldDir & axis_) > 0.95 || mag(newDir & axis_) > 0.95)
|
||||
{
|
||||
// Directions getting close to the axis, change reference
|
||||
|
||||
refDir = rotationTensor(vector(1, 0 ,0), axis_) & vector(0, 0, 1);
|
||||
oldDir = refQ_ & refDir;
|
||||
newDir = motion.orientation() & refDir;
|
||||
}
|
||||
|
||||
// Removing any axis component from oldDir and newDir and normalising
|
||||
oldDir -= (axis_ & oldDir)*axis_;
|
||||
oldDir /= (mag(oldDir) + VSMALL);
|
||||
|
||||
newDir -= (axis_ & newDir)*axis_;
|
||||
newDir /= (mag(newDir) + VSMALL);
|
||||
|
||||
scalar theta = mag(acos(min(oldDir & newDir, 1.0)));
|
||||
|
||||
// Determining the sign of theta by comparing the cross product of
|
||||
// the direction vectors with the axis
|
||||
theta *= sign((oldDir ^ newDir) & axis_);
|
||||
|
||||
scalar moment;
|
||||
|
||||
if (convertToDegrees_)
|
||||
{
|
||||
moment = moment_(radToDeg(theta));
|
||||
}
|
||||
else
|
||||
{
|
||||
moment = moment_(theta);
|
||||
}
|
||||
|
||||
// Damping of along axis angular velocity only
|
||||
restraintMoment = moment*axis_ - damping_*(motion.omega() & axis_)*axis_;
|
||||
|
||||
restraintForce = vector::zero;
|
||||
|
||||
// Not needed to be altered as restraintForce is zero, but set to
|
||||
// centreOfMass to be sure of no spurious moment
|
||||
restraintPosition = motion.centreOfMass();
|
||||
|
||||
if (motion.report())
|
||||
{
|
||||
Info<< " angle " << theta
|
||||
<< " force " << restraintForce
|
||||
<< " moment " << restraintMoment
|
||||
<< endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool Foam::sixDoFRigidBodyMotionRestraints::tabulatedAxialAngularSpring::read
|
||||
(
|
||||
const dictionary& sDoFRBMRDict
|
||||
)
|
||||
{
|
||||
sixDoFRigidBodyMotionRestraint::read(sDoFRBMRDict);
|
||||
|
||||
refQ_ = sDoFRBMRCoeffs_.lookupOrDefault<tensor>("referenceOrientation", I);
|
||||
|
||||
if (mag(mag(refQ_) - sqrt(3.0)) > 1e-9)
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"Foam::sixDoFRigidBodyMotionRestraints::"
|
||||
"tabulatedAxialAngularSpring::read"
|
||||
"("
|
||||
"const dictionary& sDoFRBMRDict"
|
||||
")"
|
||||
)
|
||||
<< "referenceOrientation " << refQ_ << " is not a rotation tensor. "
|
||||
<< "mag(referenceOrientation) - sqrt(3) = "
|
||||
<< mag(refQ_) - sqrt(3.0) << nl
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
axis_ = sDoFRBMRCoeffs_.lookup("axis");
|
||||
|
||||
scalar magAxis(mag(axis_));
|
||||
|
||||
if (magAxis > VSMALL)
|
||||
{
|
||||
axis_ /= magAxis;
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"Foam::sixDoFRigidBodyMotionRestraints::"
|
||||
"tabulatedAxialAngularSpring::read"
|
||||
"("
|
||||
"const dictionary& sDoFRBMCDict"
|
||||
")"
|
||||
)
|
||||
<< "axis has zero length"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
moment_ = interpolationTable<scalar>(sDoFRBMRCoeffs_);
|
||||
|
||||
const word angleFormat = sDoFRBMRCoeffs_.lookup("angleFormat");
|
||||
|
||||
if (angleFormat == "degrees" || angleFormat == "degree")
|
||||
{
|
||||
convertToDegrees_ = true;
|
||||
}
|
||||
else if (angleFormat == "radians" || angleFormat == "radian")
|
||||
{
|
||||
convertToDegrees_ = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"Foam::sixDoFRigidBodyMotionRestraints::"
|
||||
"tabulatedAxialAngularSpring::read"
|
||||
"("
|
||||
"const dictionary&"
|
||||
")"
|
||||
)
|
||||
<< "angleFormat must be degree, degrees, radian or radians"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
sDoFRBMRCoeffs_.lookup("damping") >> damping_;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void Foam::sixDoFRigidBodyMotionRestraints::tabulatedAxialAngularSpring::write
|
||||
(
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
os.writeKeyword("referenceOrientation")
|
||||
<< refQ_ << token::END_STATEMENT << nl;
|
||||
|
||||
os.writeKeyword("axis")
|
||||
<< axis_ << token::END_STATEMENT << nl;
|
||||
|
||||
moment_.write(os);
|
||||
|
||||
os.writeKeyword("angleFormat");
|
||||
|
||||
if (convertToDegrees_)
|
||||
{
|
||||
os << "degrees" << token::END_STATEMENT << nl;
|
||||
}
|
||||
else
|
||||
{
|
||||
os << "radians" << token::END_STATEMENT << nl;
|
||||
}
|
||||
|
||||
os.writeKeyword("damping")
|
||||
<< damping_ << token::END_STATEMENT << nl;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,137 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::sixDoFRigidBodyMotionRestraints::tabulatedAxialAngularSpring
|
||||
|
||||
Description
|
||||
sixDoFRigidBodyMotionRestraints model. Axial angular spring with moment
|
||||
values drawn from an interpolation table. Linear damping.
|
||||
|
||||
SourceFiles
|
||||
tabulatedAxialAngularSpring.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef tabulatedAxialAngularSpring_H
|
||||
#define tabulatedAxialAngularSpring_H
|
||||
|
||||
#include "sixDoFRigidBodyMotionRestraint.H"
|
||||
#include "point.H"
|
||||
#include "tensor.H"
|
||||
#include "interpolationTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
namespace sixDoFRigidBodyMotionRestraints
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class tabulatedAxialAngularSpring Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class tabulatedAxialAngularSpring
|
||||
:
|
||||
public sixDoFRigidBodyMotionRestraint
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Reference orientation where there is no moment
|
||||
tensor refQ_;
|
||||
|
||||
//- Global unit axis around which the motion is sprung
|
||||
vector axis_;
|
||||
|
||||
//- Spring moment interpolation table, depending on angleFormat
|
||||
interpolationTable<scalar> moment_;
|
||||
|
||||
//- Boolean stating whether the angle around the axis needs to
|
||||
// be converted to degrees before asking the
|
||||
// interpolationTable for a moment value
|
||||
bool convertToDegrees_;
|
||||
|
||||
//- Damping coefficient (Nms/rad)
|
||||
scalar damping_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("tabulatedAxialAngularSpring");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
tabulatedAxialAngularSpring
|
||||
(
|
||||
const dictionary& sDoFRBMRDict
|
||||
);
|
||||
|
||||
//- Construct and return a clone
|
||||
virtual autoPtr<sixDoFRigidBodyMotionRestraint> clone() const
|
||||
{
|
||||
return autoPtr<sixDoFRigidBodyMotionRestraint>
|
||||
(
|
||||
new tabulatedAxialAngularSpring(*this)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~tabulatedAxialAngularSpring();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Calculate the restraint position, force and moment.
|
||||
// Global reference frame vectors.
|
||||
virtual void restrain
|
||||
(
|
||||
const sixDoFRigidBodyMotion& motion,
|
||||
vector& restraintPosition,
|
||||
vector& restraintForce,
|
||||
vector& restraintMoment
|
||||
) const;
|
||||
|
||||
//- Update properties from given dictionary
|
||||
virtual bool read(const dictionary& sDoFRBMRCoeff);
|
||||
|
||||
//- Write
|
||||
virtual void write(Ostream&) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace solidBodyMotionFunctions
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,94 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#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("orientation", tensor(I))),
|
||||
v_(dict.lookupOrDefault("velocity", vector::zero)),
|
||||
a_(dict.lookupOrDefault("acceleration", vector::zero)),
|
||||
pi_(dict.lookupOrDefault("angularMomentum", vector::zero)),
|
||||
tau_(dict.lookupOrDefault("torque", 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()
|
||||
{}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,193 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
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
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,101 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// * * * * * * * * * * * * * * * 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_;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,97 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#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("orientation")
|
||||
<< Q_ << token::END_STATEMENT << nl;
|
||||
os.writeKeyword("velocity")
|
||||
<< v_ << token::END_STATEMENT << nl;
|
||||
os.writeKeyword("acceleration")
|
||||
<< a_ << token::END_STATEMENT << nl;
|
||||
os.writeKeyword("angularMomentum")
|
||||
<< pi_ << token::END_STATEMENT << nl;
|
||||
os.writeKeyword("torque")
|
||||
<< 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;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,202 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField.H"
|
||||
#include "pointPatchFields.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "Time.H"
|
||||
#include "fvMesh.H"
|
||||
#include "volFields.H"
|
||||
#include "uniformDimensionedFields.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField::
|
||||
uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField
|
||||
(
|
||||
const pointPatch& p,
|
||||
const DimensionedField<vector, pointMesh>& iF
|
||||
)
|
||||
:
|
||||
fixedValuePointPatchField<vector>(p, iF),
|
||||
motion_(),
|
||||
initialPoints_(p.localPoints())
|
||||
{}
|
||||
|
||||
|
||||
uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField::
|
||||
uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField
|
||||
(
|
||||
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("initialPoints"))
|
||||
{
|
||||
initialPoints_ = vectorField("initialPoints", dict , p.size());
|
||||
}
|
||||
else
|
||||
{
|
||||
initialPoints_ = p.localPoints();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField::
|
||||
uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField
|
||||
(
|
||||
const uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField& ptf,
|
||||
const pointPatch& p,
|
||||
const DimensionedField<vector, pointMesh>& iF,
|
||||
const pointPatchFieldMapper& mapper
|
||||
)
|
||||
:
|
||||
fixedValuePointPatchField<vector>(ptf, p, iF, mapper),
|
||||
motion_(ptf.motion_),
|
||||
initialPoints_(ptf.initialPoints_, mapper)
|
||||
{}
|
||||
|
||||
|
||||
uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField::
|
||||
uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField
|
||||
(
|
||||
const uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField& ptf,
|
||||
const DimensionedField<vector, pointMesh>& iF
|
||||
)
|
||||
:
|
||||
fixedValuePointPatchField<vector>(ptf, iF),
|
||||
motion_(ptf.motion_),
|
||||
initialPoints_(ptf.initialPoints_)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField::autoMap
|
||||
(
|
||||
const pointPatchFieldMapper& m
|
||||
)
|
||||
{
|
||||
fixedValuePointPatchField<vector>::autoMap(m);
|
||||
|
||||
initialPoints_.autoMap(m);
|
||||
}
|
||||
|
||||
|
||||
void uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField::rmap
|
||||
(
|
||||
const pointPatchField<vector>& ptf,
|
||||
const labelList& addr
|
||||
)
|
||||
{
|
||||
const uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField& uSDoFptf =
|
||||
refCast
|
||||
<
|
||||
const uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField
|
||||
>(ptf);
|
||||
|
||||
fixedValuePointPatchField<vector>::rmap(uSDoFptf, addr);
|
||||
|
||||
initialPoints_.rmap(uSDoFptf.initialPoints_, addr);
|
||||
}
|
||||
|
||||
|
||||
void uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField::updateCoeffs()
|
||||
{
|
||||
if (this->updated())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const polyMesh& mesh = this->dimensionedInternalField().mesh()();
|
||||
const Time& t = mesh.time();
|
||||
|
||||
motion_.updatePosition(t.deltaTValue(), t.deltaT0Value());
|
||||
|
||||
vector gravity = vector::zero;
|
||||
|
||||
if (db().foundObject<uniformDimensionedVectorField>("g"))
|
||||
{
|
||||
uniformDimensionedVectorField g =
|
||||
db().lookupObject<uniformDimensionedVectorField>("g");
|
||||
|
||||
gravity = g.value();
|
||||
}
|
||||
|
||||
// Do not modify the accelerations, except with gravity, where available
|
||||
motion_.updateAcceleration
|
||||
(
|
||||
gravity*motion_.mass(),
|
||||
vector::zero, t.deltaTValue()
|
||||
);
|
||||
|
||||
Field<vector>::operator=
|
||||
(
|
||||
motion_.currentPosition(initialPoints_) - initialPoints_
|
||||
);
|
||||
|
||||
fixedValuePointPatchField<vector>::updateCoeffs();
|
||||
}
|
||||
|
||||
|
||||
void uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField::write
|
||||
(
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
pointPatchField<vector>::write(os);
|
||||
motion_.write(os);
|
||||
initialPoints_.writeEntry("initialPoints", os);
|
||||
writeEntry("value", os);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
makePointPatchTypeField
|
||||
(
|
||||
pointPatchVectorField,
|
||||
uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField
|
||||
);
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,168 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField
|
||||
|
||||
Description
|
||||
Foam::uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField
|
||||
|
||||
SourceFiles
|
||||
uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField_H
|
||||
#define uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField_H
|
||||
|
||||
#include "fixedValuePointPatchField.H"
|
||||
#include "sixDoFRigidBodyMotion.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField
|
||||
:
|
||||
public fixedValuePointPatchField<vector>
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Six dof motion object
|
||||
sixDoFRigidBodyMotion motion_;
|
||||
|
||||
//- Initial positions of points on the patch
|
||||
pointField initialPoints_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("uncoupledSixDoFRigidBodyDisplacement");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from patch and internal field
|
||||
uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField
|
||||
(
|
||||
const pointPatch&,
|
||||
const DimensionedField<vector, pointMesh>&
|
||||
);
|
||||
|
||||
//- Construct from patch, internal field and dictionary
|
||||
uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField
|
||||
(
|
||||
const pointPatch&,
|
||||
const DimensionedField<vector, pointMesh>&,
|
||||
const dictionary&
|
||||
);
|
||||
|
||||
//- Construct by mapping given patchField<vector> onto a new patch
|
||||
uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField
|
||||
(
|
||||
const uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField&,
|
||||
const pointPatch&,
|
||||
const DimensionedField<vector, pointMesh>&,
|
||||
const pointPatchFieldMapper&
|
||||
);
|
||||
|
||||
//- Construct and return a clone
|
||||
virtual autoPtr<pointPatchField<vector> > clone() const
|
||||
{
|
||||
return autoPtr<pointPatchField<vector> >
|
||||
(
|
||||
new uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField
|
||||
(
|
||||
*this
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
//- Construct as copy setting internal field reference
|
||||
uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField
|
||||
(
|
||||
const uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField&,
|
||||
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 uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField
|
||||
(
|
||||
*this,
|
||||
iF
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// Member functions
|
||||
|
||||
// Mapping functions
|
||||
|
||||
//- Map (and resize as needed) from self given a mapping object
|
||||
virtual void autoMap
|
||||
(
|
||||
const pointPatchFieldMapper&
|
||||
);
|
||||
|
||||
//- Reverse map the given pointPatchField onto this pointPatchField
|
||||
virtual void rmap
|
||||
(
|
||||
const pointPatchField<vector>&,
|
||||
const labelList&
|
||||
);
|
||||
|
||||
|
||||
// Evaluation functions
|
||||
|
||||
//- Update the coefficients associated with the patch field
|
||||
virtual void updateCoeffs();
|
||||
|
||||
|
||||
//- Write
|
||||
virtual void write(Ostream&) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
Reference in New Issue
Block a user