Commit a0522a2b authored by graham's avatar graham
Browse files

sixDoFRigidBody: adding constraints.

Adding outline and placeholders for constraints and their solution.
parent 8bcb2c8f
......@@ -17,6 +17,12 @@ $(sDoFRBMR)/sixDoFRigidBodyMotionRestraint/sixDoFRigidBodyMotionRestraint.C
$(sDoFRBMR)/sixDoFRigidBodyMotionRestraint/newSixDoFRigidBodyMotionRestraint.C
$(sDoFRBMR)/linearSpring/linearSpring.C
sDoFRBMC = $(sDoFRBM)/sixDoFRigidBodyMotionConstraint
$(sDoFRBMC)/sixDoFRigidBodyMotionConstraint/sixDoFRigidBodyMotionConstraint.C
$(sDoFRBMC)/sixDoFRigidBodyMotionConstraint/newSixDoFRigidBodyMotionConstraint.C
$(sDoFRBMC)/fixedPoint/fixedPoint.C
pointPatchFields/derived/sixDoFRigidBodyDisplacement/sixDoFRigidBodyDisplacementPointPatchVectorField.C
pointPatchFields/derived/uncoupledSixDoFRigidBodyDisplacement/uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField.C
pointPatchFields/derived/constrainedSixDoFRigidBodyDisplacement/constrainedSixDoFRigidBodyDisplacementPointPatchVectorField.C
......
......@@ -49,15 +49,61 @@ void Foam::sixDoFRigidBodyMotion::applyRestraints()
a() += rF/mass_;
tau() += Q().T() & (rM + (rP - centreOfMass()) ^ rF);
tau() += Q().T() & (rM + ((rP - centreOfMass()) ^ rF));
}
}
}
void Foam::sixDoFRigidBodyMotion::applyConstraints()
void Foam::sixDoFRigidBodyMotion::applyConstraints(scalar deltaT)
{
if (Pstream::master())
{
label iter = 0;
bool converged = true;
// constraint force accumulator
vector cFA = vector::zero;
// constraint moment accumulator
vector cMA = vector::zero;
do
{
converged = true;
Info<< "Iteration " << iter << endl;
forAll(constraints_, cI)
{
Info<< "Constraint " << cI << endl;
// constraint position
point cP = vector::zero;
// constraint force
vector cF = vector::zero;
// constraint moment
vector cM = vector::zero;
converged = converged && constraints_[cI].constrain
(
*this,
cFA,
cMA,
deltaT,
cP,
cF,
cM
);
}
iter++;
} while(!converged);
}
}
......@@ -67,6 +113,7 @@ Foam::sixDoFRigidBodyMotion::sixDoFRigidBodyMotion()
:
motionState_(),
restraints_(),
constraints_(),
refCentreOfMass_(vector::zero),
momentOfInertia_(diagTensor::one*VSMALL),
mass_(VSMALL)
......@@ -96,6 +143,7 @@ Foam::sixDoFRigidBodyMotion::sixDoFRigidBodyMotion
tau
),
restraints_(),
constraints_(),
refCentreOfMass_(refCentreOfMass),
momentOfInertia_(momentOfInertia),
mass_(mass)
......@@ -106,6 +154,7 @@ Foam::sixDoFRigidBodyMotion::sixDoFRigidBodyMotion(const dictionary& dict)
:
motionState_(dict),
restraints_(),
constraints_(),
refCentreOfMass_(dict.lookupOrDefault("refCentreOfMass", centreOfMass())),
momentOfInertia_(dict.lookup("momentOfInertia")),
mass_(readScalar(dict.lookup("mass")))
......@@ -123,6 +172,7 @@ Foam::sixDoFRigidBodyMotion::sixDoFRigidBodyMotion
:
motionState_(sDoFRBM.motionState()),
restraints_(sDoFRBM.restraints()),
constraints_(sDoFRBM.constraints()),
refCentreOfMass_(sDoFRBM.refCentreOfMass()),
momentOfInertia_(sDoFRBM.momentOfInertia()),
mass_(sDoFRBM.mass())
......@@ -176,7 +226,32 @@ void Foam::sixDoFRigidBodyMotion::addConstraints
const dictionary& dict
)
{
if (dict.found("constraints"))
{
const dictionary& constraintDict = dict.subDict("constraints");
label i = 0;
constraints_.setSize(constraintDict.size());
forAllConstIter(IDLList<entry>, constraintDict, iter)
{
if (iter().isDict())
{
Info<< "Adding constraint: " << iter().keyword() << endl;
constraints_.set
(
i,
sixDoFRigidBodyMotionConstraint::New(iter().dict())
);
}
i++;
}
constraints_.setSize(i);
}
}
......@@ -244,7 +319,7 @@ void Foam::sixDoFRigidBodyMotion::updateForce
applyRestraints();
applyConstraints();
applyConstraints(deltaT);
v() += 0.5*deltaT*a();
......@@ -282,5 +357,17 @@ void Foam::sixDoFRigidBodyMotion::updateForce
}
Foam::point Foam::sixDoFRigidBodyMotion::predictedPosition
(
const point& pt,
const vector deltaForce,
const vector deltaMoment,
scalar deltaT
) const
{
Info<< "predictedPosition NOT IMPLEMENTED" << endl;
return pt;
}
// ************************************************************************* //
......@@ -59,6 +59,7 @@ SourceFiles
#include "sixDoFRigidBodyMotionState.H"
#include "pointField.H"
#include "sixDoFRigidBodyMotionRestraint.H"
#include "sixDoFRigidBodyMotionConstraint.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -90,8 +91,8 @@ class sixDoFRigidBodyMotion
//- Restraints on the motion
PtrList<sixDoFRigidBodyMotionRestraint> restraints_;
// //- Constaints on the motion
// PtrList<sixDoFRigidBodyMotionConstraint> constraints_;
//- Constaints on the motion
PtrList<sixDoFRigidBodyMotionConstraint> constraints_;
//- Centre of mass of reference state
point refCentreOfMass_;
......@@ -121,7 +122,7 @@ class sixDoFRigidBodyMotion
void applyRestraints();
//- Apply the constraints to the object
void applyConstraints();
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
......@@ -135,6 +136,10 @@ class sixDoFRigidBodyMotion
inline const PtrList<sixDoFRigidBodyMotionRestraint>&
restraints() const;
//- Return access to the constraints
inline const PtrList<sixDoFRigidBodyMotionConstraint>&
constraints() const;
//- Return access to the centre of mass
inline const point& refCentreOfMass() const;
......@@ -256,6 +261,17 @@ public:
// motion state
inline point currentPosition(const point& pt) const;
//- Predict the position of the supplied point after deltaT
// given the current motion state and the additional supplied
// force and moment
point predictedPosition
(
const point& pt,
const vector deltaForce,
const vector deltaMoment,
scalar deltaT
) const;
//- Return the angular velocity in the global frame
inline vector omega() const;
......
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 "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
);
vector error = predictedPosition - fixedPoint_;
Info<< error << endl;
return true;
}
bool Foam::sixDoFRigidBodyMotionConstraints::fixedPoint::read
(
const dictionary& sDoFRBMCDict
)
{
sixDoFRigidBodyMotionConstraint::read(sDoFRBMCDict);
sDoFRBMCCoeffs_.lookup("fixedPoint") >> fixedPoint_;
return true;
}
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / 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::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.
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);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace solidBodyMotionFunctions
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 "sixDoFRigidBodyMotionConstraint.H"
// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
Foam::autoPtr<Foam::sixDoFRigidBodyMotionConstraint>
Foam::sixDoFRigidBodyMotionConstraint::New(const dictionary& sDoFRBMCDict)
{
word sixDoFRigidBodyMotionConstraintTypeName =
sDoFRBMCDict.lookup("sixDoFRigidBodyMotionConstraint");
Info<< "Selecting sixDoFRigidBodyMotionConstraint function "
<< sixDoFRigidBodyMotionConstraintTypeName << endl;
dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find
(
sixDoFRigidBodyMotionConstraintTypeName
);
if (cstrIter == dictionaryConstructorTablePtr_->end())
{
FatalErrorIn
(
"sixDoFRigidBodyMotionConstraint::New"
"("
"const dictionary& sDoFRBMCDict"
")"
) << "Unknown sixDoFRigidBodyMotionConstraint type "
<< sixDoFRigidBodyMotionConstraintTypeName << endl << endl
<< "Valid sixDoFRigidBodyMotionConstraints are : " << endl
<< dictionaryConstructorTablePtr_->sortedToc()
<< exit(FatalError);
}
return autoPtr<sixDoFRigidBodyMotionConstraint>(cstrIter()(sDoFRBMCDict));
}
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 "sixDoFRigidBodyMotionConstraint.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug(Foam::sixDoFRigidBodyMotionConstraint, 0);