Commit c1940876 authored by graham's avatar graham
Browse files

In: src/postProcessing/functionObjects/forces, adding mechanisms for

restraints and constraints.

Moving sixDoFRigidBodyMotion back one directory.

Adding uncoupledSixDoFRigidBodyDisplacement to execute motion
specified by the six DoF motion state, but not applying surface
forces.  Useful for pre-displacing a mesh.

Adding constrainedSixDoFRigidBodyDisplacement to temporarily perform
Vorticity's lander simulation.  Will be removed when generalised
constraints are added.
parent 129f7962
......@@ -4,10 +4,21 @@ 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/newSixDoFRigidBodyMotionRestraint.C
$(sDoFRBMR)/linearSpring/linearSpring.C
pointPatchFields/derived/sixDoFRigidBodyDisplacement/sixDoFRigidBodyDisplacementPointPatchVectorField.C
pointPatchFields/derived/sixDoFRigidBodyDisplacement/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion.C
pointPatchFields/derived/sixDoFRigidBodyDisplacement/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionIO.C
pointPatchFields/derived/sixDoFRigidBodyDisplacement/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionState.C
pointPatchFields/derived/sixDoFRigidBodyDisplacement/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionStateIO.C
pointPatchFields/derived/uncoupledSixDoFRigidBodyDisplacement/uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField.C
pointPatchFields/derived/constrainedSixDoFRigidBodyDisplacement/constrainedSixDoFRigidBodyDisplacementPointPatchVectorField.C
LIB = $(FOAM_LIBBIN)/libforces
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "constrainedSixDoFRigidBodyDisplacementPointPatchVectorField.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 * * * * * * * * * * * * * * //
constrainedSixDoFRigidBodyDisplacementPointPatchVectorField::
constrainedSixDoFRigidBodyDisplacementPointPatchVectorField
(
const pointPatch& p,
const DimensionedField<vector, pointMesh>& iF
)
:
fixedValuePointPatchField<vector>(p, iF),
motion_(),
p0_(p.localPoints()),
rhoInf_(1.0)
{}
constrainedSixDoFRigidBodyDisplacementPointPatchVectorField::
constrainedSixDoFRigidBodyDisplacementPointPatchVectorField
(
const pointPatch& p,
const DimensionedField<vector, pointMesh>& iF,
const dictionary& dict
)
:
fixedValuePointPatchField<vector>(p, iF, dict),
motion_(dict),
rhoInf_(readScalar(dict.lookup("rhoInf")))
{
if (!dict.found("value"))
{
updateCoeffs();
}
if (dict.found("p0"))
{
p0_ = vectorField("p0", dict , p.size());
}
else
{
p0_ = p.localPoints();
}
}
constrainedSixDoFRigidBodyDisplacementPointPatchVectorField::
constrainedSixDoFRigidBodyDisplacementPointPatchVectorField
(
const constrainedSixDoFRigidBodyDisplacementPointPatchVectorField& ptf,
const pointPatch& p,
const DimensionedField<vector, pointMesh>& iF,
const pointPatchFieldMapper& mapper
)
:
fixedValuePointPatchField<vector>(ptf, p, iF, mapper),
motion_(ptf.motion_),
p0_(ptf.p0_, mapper),
rhoInf_(ptf.rhoInf_)
{}
constrainedSixDoFRigidBodyDisplacementPointPatchVectorField::
constrainedSixDoFRigidBodyDisplacementPointPatchVectorField
(
const constrainedSixDoFRigidBodyDisplacementPointPatchVectorField& ptf,
const DimensionedField<vector, pointMesh>& iF
)
:
fixedValuePointPatchField<vector>(ptf, iF),
motion_(ptf.motion_),
p0_(ptf.p0_),
rhoInf_(ptf.rhoInf_)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void constrainedSixDoFRigidBodyDisplacementPointPatchVectorField::updateCoeffs()
{
if (this->updated())
{
return;
}
const polyMesh& mesh = this->dimensionedInternalField().mesh()();
const Time& t = mesh.time();
const pointPatch& ptPatch = this->patch();
// Patch force data is valid for the current positions, so
// calculate the forces on the motion object from this data, then
// update the positions
motion_.updatePosition(t.deltaTValue());
dictionary forcesDict;
forcesDict.add("patches", wordList(1, ptPatch.name()));
forcesDict.add("rhoInf", rhoInf_);
forcesDict.add("CofR", motion_.centreOfMass());
forces f("forces", db(), forcesDict);
forces::forcesMoments fm = f.calcForcesMoment();
// Get the forces on the patch faces at the current positions
vector gravity = vector::zero;
if (db().foundObject<uniformDimensionedVectorField>("g"))
{
uniformDimensionedVectorField g =
db().lookupObject<uniformDimensionedVectorField>("g");
gravity = g.value();
}
vector rotationAxis(0, 1, 0);
vector torque
(
(
(fm.second().first() + fm.second().second())
& rotationAxis
)
*rotationAxis
);
motion_.updateForce
(
vector::zero, // Force no centre of mass motion
torque, // Only rotation allowed around the unit rotationAxis
t.deltaTValue()
);
Field<vector>::operator=(motion_.generatePositions(p0_) - p0_);
fixedValuePointPatchField<vector>::updateCoeffs();
}
void constrainedSixDoFRigidBodyDisplacementPointPatchVectorField::write
(
Ostream& os
) const
{
pointPatchField<vector>::write(os);
motion_.write(os);
os.writeKeyword("rhoInf")
<< rhoInf_ << token::END_STATEMENT << nl;
p0_.writeEntry("p0", os);
writeEntry("value", os);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
makePointPatchTypeField
(
pointPatchVectorField,
constrainedSixDoFRigidBodyDisplacementPointPatchVectorField
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::constrainedSixDoFRigidBodyDisplacementPointPatchVectorField
Description
Foam::constrainedSixDoFRigidBodyDisplacementPointPatchVectorField
SourceFiles
constrainedSixDoFRigidBodyDisplacementPointPatchVectorField.C
\*---------------------------------------------------------------------------*/
#ifndef constrainedSixDoFRigidBodyDisplacementPointPatchVectorField_H
#define constrainedSixDoFRigidBodyDisplacementPointPatchVectorField_H
#include "fixedValuePointPatchField.H"
#include "sixDoFRigidBodyMotion.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class constrainedSixDoFRigidBodyDisplacementPointPatchVectorField Declaration
\*---------------------------------------------------------------------------*/
class constrainedSixDoFRigidBodyDisplacementPointPatchVectorField
:
public fixedValuePointPatchField<vector>
{
// Private data
//- Six dof motion object
sixDoFRigidBodyMotion motion_;
//- Reference positions of points on the patch
pointField p0_;
//- Reference density required by the forces object for
// incompressible calculations
scalar rhoInf_;
public:
//- Runtime type information
TypeName("constrainedSixDoFRigidBodyDisplacement");
// Constructors
//- Construct from patch and internal field
constrainedSixDoFRigidBodyDisplacementPointPatchVectorField
(
const pointPatch&,
const DimensionedField<vector, pointMesh>&
);
//- Construct from patch, internal field and dictionary
constrainedSixDoFRigidBodyDisplacementPointPatchVectorField
(
const pointPatch&,
const DimensionedField<vector, pointMesh>&,
const dictionary&
);
//- Construct by mapping given patchField<vector> onto a new patch
constrainedSixDoFRigidBodyDisplacementPointPatchVectorField
(
const constrainedSixDoFRigidBodyDisplacementPointPatchVectorField&,
const pointPatch&,
const DimensionedField<vector, pointMesh>&,
const pointPatchFieldMapper&
);
//- Construct and return a clone
virtual autoPtr<pointPatchField<vector> > clone() const
{
return autoPtr<pointPatchField<vector> >
(
new constrainedSixDoFRigidBodyDisplacementPointPatchVectorField
(
*this
)
);
}
//- Construct as copy setting internal field reference
constrainedSixDoFRigidBodyDisplacementPointPatchVectorField
(
const constrainedSixDoFRigidBodyDisplacementPointPatchVectorField&,
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 constrainedSixDoFRigidBodyDisplacementPointPatchVectorField
(
*this,
iF
)
);
}
// Member functions
// Evaluation functions
//- Update the coefficients associated with the patch field
virtual void updateCoeffs();
//- Write
virtual void write(Ostream&) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //
......@@ -160,6 +160,26 @@ void sixDoFRigidBodyDisplacementPointPatchVectorField::updateCoeffs()
t.deltaTValue()
);
// ----------------------------------------
// vector rotationAxis(0, 1, 0);
// vector torque
// (
// (
// (fm.second().first() + fm.second().second())
// & rotationAxis
// )
// *rotationAxis
// );
// motion_.updateForce
// (
// vector::zero, // Force no centre of mass motion
// torque, // Only rotation allowed around the unit rotationAxis
// t.deltaTValue()
// );
// ----------------------------------------
Field<vector>::operator=(motion_.generatePositions(p0_) - p0_);
fixedValuePointPatchField<vector>::updateCoeffs();
......
......@@ -26,11 +26,29 @@ License
#include "sixDoFRigidBodyMotion.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::sixDoFRigidBodyMotion::applyRestraints()
{
forAll(restraints_, rI)
{
restraints_[rI].restraintForce();
}
}
void Foam::sixDoFRigidBodyMotion::applyConstraints()
{
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::sixDoFRigidBodyMotion::sixDoFRigidBodyMotion()
:
motionState_(),
restraints_(),
refCentreOfMass_(vector::zero),
momentOfInertia_(diagTensor::one*VSMALL),
mass_(VSMALL)
......@@ -59,6 +77,7 @@ Foam::sixDoFRigidBodyMotion::sixDoFRigidBodyMotion
pi,
tau
),
restraints_(),
refCentreOfMass_(refCentreOfMass),
momentOfInertia_(momentOfInertia),
mass_(mass)
......@@ -68,10 +87,15 @@ Foam::sixDoFRigidBodyMotion::sixDoFRigidBodyMotion
Foam::sixDoFRigidBodyMotion::sixDoFRigidBodyMotion(const dictionary& dict)
:
motionState_(dict),
restraints_(),
refCentreOfMass_(dict.lookupOrDefault("refCentreOfMass", centreOfMass())),
momentOfInertia_(dict.lookup("momentOfInertia")),
mass_(readScalar(dict.lookup("mass")))
{}
{
addRestraints(dict);
addConstraints(dict);
}
Foam::sixDoFRigidBodyMotion::sixDoFRigidBodyMotion
......@@ -80,6 +104,7 @@ Foam::sixDoFRigidBodyMotion::sixDoFRigidBodyMotion
)
:
motionState_(sDoFRBM.motionState()),
restraints_(sDoFRBM.restraints()),
refCentreOfMass_(sDoFRBM.refCentreOfMass()),
momentOfInertia_(sDoFRBM.momentOfInertia()),
mass_(sDoFRBM.mass())
......@@ -94,6 +119,49 @@ 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());
forAllConstIter(IDLList<entry>, restraintDict, iter)
{
if (iter().isDict())
{
Info<< "Adding restraint: " << iter().keyword() << endl;
restraints_.set
(
i,
sixDoFRigidBodyMotionRestraint::New(iter().dict())
);
}
i++;
}
restraints_.setSize(i);
}
}
void Foam::sixDoFRigidBodyMotion::addConstraints
(
const dictionary& dict
)
{
}
void Foam::sixDoFRigidBodyMotion::updatePosition
(
scalar deltaT
......@@ -149,7 +217,7 @@ void Foam::sixDoFRigidBodyMotion::updateForce
)
{
// Second leapfrog velocity adjust part, required after motion and
// force calculation part
// force calculation
if (Pstream::master())
{
......@@ -157,6 +225,10 @@ void Foam::sixDoFRigidBodyMotion::updateForce
tau() = (Q().T() & tauGlobal);
applyRestraints();