diff --git a/src/postProcessing/functionObjects/forces/Make/files b/src/postProcessing/functionObjects/forces/Make/files index 66f3c0a8ec..a7541d14c0 100644 --- a/src/postProcessing/functionObjects/forces/Make/files +++ b/src/postProcessing/functionObjects/forces/Make/files @@ -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 diff --git a/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion.C b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion.C index d892836425..0eef0872e8 100644 --- a/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion.C +++ b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion.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, 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; +} + // ************************************************************************* // diff --git a/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion.H b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion.H index 274b62be76..4b1c724414 100644 --- a/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion.H +++ b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion.H @@ -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 restraints_; - // //- Constaints on the motion - // PtrList constraints_; + //- Constaints on the motion + PtrList 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& restraints() const; + //- Return access to the constraints + inline const PtrList& + 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; diff --git a/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionConstraint/fixedPoint/fixedPoint.C b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionConstraint/fixedPoint/fixedPoint.C new file mode 100644 index 0000000000..7ff526fe07 --- /dev/null +++ b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionConstraint/fixedPoint/fixedPoint.C @@ -0,0 +1,109 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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; +} + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionConstraint/fixedPoint/fixedPoint.H b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionConstraint/fixedPoint/fixedPoint.H new file mode 100644 index 0000000000..9619d8e72f --- /dev/null +++ b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionConstraint/fixedPoint/fixedPoint.H @@ -0,0 +1,124 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 clone() const + { + return autoPtr + ( + 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 + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionConstraint/sixDoFRigidBodyMotionConstraint/newSixDoFRigidBodyMotionConstraint.C b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionConstraint/sixDoFRigidBodyMotionConstraint/newSixDoFRigidBodyMotionConstraint.C new file mode 100644 index 0000000000..890a83b2c0 --- /dev/null +++ b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionConstraint/sixDoFRigidBodyMotionConstraint/newSixDoFRigidBodyMotionConstraint.C @@ -0,0 +1,65 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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::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(cstrIter()(sDoFRBMCDict)); +} + + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionConstraint/sixDoFRigidBodyMotionConstraint/sixDoFRigidBodyMotionConstraint.C b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionConstraint/sixDoFRigidBodyMotionConstraint/sixDoFRigidBodyMotionConstraint.C new file mode 100644 index 0000000000..bb8c50b3a5 --- /dev/null +++ b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionConstraint/sixDoFRigidBodyMotionConstraint/sixDoFRigidBodyMotionConstraint.C @@ -0,0 +1,75 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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); + +defineRunTimeSelectionTable(Foam::sixDoFRigidBodyMotionConstraint, dictionary); + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::sixDoFRigidBodyMotionConstraint::sixDoFRigidBodyMotionConstraint +( + const dictionary& sDoFRBMCDict +) +: + sDoFRBMCCoeffs_ + ( + sDoFRBMCDict.subDict + ( + word(sDoFRBMCDict.lookup("sixDoFRigidBodyMotionConstraint")) + + "Coeffs" + ) + ), + tolerance_(readScalar(sDoFRBMCDict.lookup("tolerance"))) +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::sixDoFRigidBodyMotionConstraint::~sixDoFRigidBodyMotionConstraint() +{} + + +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + +bool Foam::sixDoFRigidBodyMotionConstraint::read +( + const dictionary& sDoFRBMCDict +) +{ + tolerance_ = (readScalar(sDoFRBMCDict.lookup("tolerance"))); + + sDoFRBMCCoeffs_ = sDoFRBMCDict.subDict(type() + "Coeffs"); + + return true; +} + + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionConstraint/sixDoFRigidBodyMotionConstraint/sixDoFRigidBodyMotionConstraint.H b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionConstraint/sixDoFRigidBodyMotionConstraint/sixDoFRigidBodyMotionConstraint.H new file mode 100644 index 0000000000..be240dce2b --- /dev/null +++ b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionConstraint/sixDoFRigidBodyMotionConstraint/sixDoFRigidBodyMotionConstraint.H @@ -0,0 +1,154 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 + +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 + newDynamicFvMesh.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_; + + +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 clone() const = 0; + + + // Selectors + + //- Select constructed from the sDoFRBMCDict dictionary and Time + static autoPtr 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) = 0; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionI.H b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionI.H index ae80cb18a3..5b0d607ef4 100644 --- a/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionI.H +++ b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionI.H @@ -76,6 +76,13 @@ Foam::sixDoFRigidBodyMotion::restraints() const } +inline const Foam::PtrList& +Foam::sixDoFRigidBodyMotion::constraints() const +{ + return constraints_; +} + + inline const Foam::point& Foam::sixDoFRigidBodyMotion::refCentreOfMass() const { return refCentreOfMass_; diff --git a/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionRestraint/linearSpring/linearSpring.C b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionRestraint/linearSpring/linearSpring.C index 79c66836e9..966e911c6e 100644 --- a/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionRestraint/linearSpring/linearSpring.C +++ b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionRestraint/linearSpring/linearSpring.C @@ -49,17 +49,17 @@ namespace sixDoFRigidBodyMotionRestraints Foam::sixDoFRigidBodyMotionRestraints::linearSpring::linearSpring ( - const dictionary& sDoFRBMRCoeffs + const dictionary& sDoFRBMRDict ) : - sixDoFRigidBodyMotionRestraint(sDoFRBMRCoeffs), + sixDoFRigidBodyMotionRestraint(sDoFRBMRDict), anchor_(), refAttachmentPt_(), stiffness_(), damping_(), restLength_() { - read(sDoFRBMRCoeffs); + read(sDoFRBMRDict); } @@ -98,10 +98,10 @@ void Foam::sixDoFRigidBodyMotionRestraints::linearSpring::restrain bool Foam::sixDoFRigidBodyMotionRestraints::linearSpring::read ( - const dictionary& sDoFRBMRCoeffs + const dictionary& sDoFRBMRDict ) { - sixDoFRigidBodyMotionRestraint::read(sDoFRBMRCoeffs); + sixDoFRigidBodyMotionRestraint::read(sDoFRBMRDict); sDoFRBMRCoeffs_.lookup("anchor") >> anchor_; diff --git a/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionRestraint/linearSpring/linearSpring.H b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionRestraint/linearSpring/linearSpring.H index 34a83a1ce8..c5dc9bc074 100644 --- a/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionRestraint/linearSpring/linearSpring.H +++ b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionRestraint/linearSpring/linearSpring.H @@ -85,7 +85,7 @@ public: //- Construct from components linearSpring ( - const dictionary& sDoFRBMRCoeffs + const dictionary& sDoFRBMRDict ); //- Construct and return a clone diff --git a/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionRestraint/sixDoFRigidBodyMotionRestraint/newSixDoFRigidBodyMotionRestraint.C b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionRestraint/sixDoFRigidBodyMotionRestraint/newSixDoFRigidBodyMotionRestraint.C index 1d5484be7a..7fee5eb84e 100644 --- a/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionRestraint/sixDoFRigidBodyMotionRestraint/newSixDoFRigidBodyMotionRestraint.C +++ b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionRestraint/sixDoFRigidBodyMotionRestraint/newSixDoFRigidBodyMotionRestraint.C @@ -29,10 +29,10 @@ License // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * // Foam::autoPtr -Foam::sixDoFRigidBodyMotionRestraint::New(const dictionary& sDoFRBMRCoeffs) +Foam::sixDoFRigidBodyMotionRestraint::New(const dictionary& sDoFRBMRDict) { word sixDoFRigidBodyMotionRestraintTypeName = - sDoFRBMRCoeffs.lookup("sixDoFRigidBodyMotionRestraint"); + sDoFRBMRDict.lookup("sixDoFRigidBodyMotionRestraint"); Info<< "Selecting sixDoFRigidBodyMotionRestraint function " << sixDoFRigidBodyMotionRestraintTypeName << endl; @@ -49,7 +49,7 @@ Foam::sixDoFRigidBodyMotionRestraint::New(const dictionary& sDoFRBMRCoeffs) ( "sixDoFRigidBodyMotionRestraint::New" "(" - " const dictionary& sDoFRBMRCoeffs" + "const dictionary& sDoFRBMRDict" ")" ) << "Unknown sixDoFRigidBodyMotionRestraint type " << sixDoFRigidBodyMotionRestraintTypeName << endl << endl @@ -58,7 +58,7 @@ Foam::sixDoFRigidBodyMotionRestraint::New(const dictionary& sDoFRBMRCoeffs) << exit(FatalError); } - return autoPtr(cstrIter()(sDoFRBMRCoeffs)); + return autoPtr(cstrIter()(sDoFRBMRDict)); } diff --git a/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionRestraint/sixDoFRigidBodyMotionRestraint/sixDoFRigidBodyMotionRestraint.C b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionRestraint/sixDoFRigidBodyMotionRestraint/sixDoFRigidBodyMotionRestraint.C index 929e8859b1..2d17503421 100644 --- a/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionRestraint/sixDoFRigidBodyMotionRestraint/sixDoFRigidBodyMotionRestraint.C +++ b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionRestraint/sixDoFRigidBodyMotionRestraint/sixDoFRigidBodyMotionRestraint.C @@ -36,14 +36,14 @@ defineRunTimeSelectionTable(Foam::sixDoFRigidBodyMotionRestraint, dictionary); Foam::sixDoFRigidBodyMotionRestraint::sixDoFRigidBodyMotionRestraint ( - const dictionary& sDoFRBMRCoeffs + const dictionary& sDoFRBMRDict ) : sDoFRBMRCoeffs_ ( - sDoFRBMRCoeffs.subDict + sDoFRBMRDict.subDict ( - word(sDoFRBMRCoeffs.lookup("sixDoFRigidBodyMotionRestraint")) + word(sDoFRBMRDict.lookup("sixDoFRigidBodyMotionRestraint")) + "Coeffs" ) ) @@ -60,10 +60,10 @@ Foam::sixDoFRigidBodyMotionRestraint::~sixDoFRigidBodyMotionRestraint() bool Foam::sixDoFRigidBodyMotionRestraint::read ( - const dictionary& sDoFRBMRCoeffs + const dictionary& sDoFRBMRDict ) { - sDoFRBMRCoeffs_ = sDoFRBMRCoeffs.subDict(type() + "Coeffs"); + sDoFRBMRCoeffs_ = sDoFRBMRDict.subDict(type() + "Coeffs"); return true; } diff --git a/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionRestraint/sixDoFRigidBodyMotionRestraint/sixDoFRigidBodyMotionRestraint.H b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionRestraint/sixDoFRigidBodyMotionRestraint/sixDoFRigidBodyMotionRestraint.H index 65c0c0d6d3..b9e0d5f0f1 100644 --- a/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionRestraint/sixDoFRigidBodyMotionRestraint/sixDoFRigidBodyMotionRestraint.H +++ b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionRestraint/sixDoFRigidBodyMotionRestraint/sixDoFRigidBodyMotionRestraint.H @@ -86,17 +86,17 @@ public: autoPtr, sixDoFRigidBodyMotionRestraint, dictionary, - (const dictionary& sDoFRBMRCoeffs), - (sDoFRBMRCoeffs) + (const dictionary& sDoFRBMRDict), + (sDoFRBMRDict) ); // Constructors - //- Construct from the sDoFRBMRCoeffs dictionary and Time + //- Construct from the sDoFRBMRDict dictionary and Time sixDoFRigidBodyMotionRestraint ( - const dictionary& sDoFRBMRCoeffs + const dictionary& sDoFRBMRDict ); //- Construct and return a clone @@ -105,10 +105,10 @@ public: // Selectors - //- Select constructed from the sDoFRBMRCoeffs dictionary and Time + //- Select constructed from the sDoFRBMRDict dictionary and Time static autoPtr New ( - const dictionary& sDoFRBMRCoeffs + const dictionary& sDoFRBMRDict ); @@ -130,7 +130,7 @@ public: ) const = 0; //- Update properties from given dictionary - virtual bool read(const dictionary& sDoFRBMRCoeffs) = 0; + virtual bool read(const dictionary& sDoFRBMRDict) = 0; };