From 8e850800f7f106e847ed7cb6a1d3f40d151cb63a Mon Sep 17 00:00:00 2001 From: graham Date: Tue, 2 Feb 2010 11:51:52 +0000 Subject: [PATCH] ENC: sixDoFRigidBodyMotion. Adding fixedAxis constraint. --- .../functionObjects/forces/Make/files | 7 +- .../sixDoFRigidBodyMotion.C | 5 +- .../sixDoFRigidBodyMotion.H | 7 +- .../fixedAxis/fixedAxis.C | 157 ++++++++++++++++++ .../fixedAxis/fixedAxis.H | 126 ++++++++++++++ .../sixDoFRigidBodyMotionI.H | 9 +- 6 files changed, 305 insertions(+), 6 deletions(-) create mode 100644 src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionConstraint/fixedAxis/fixedAxis.C create mode 100644 src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionConstraint/fixedAxis/fixedAxis.H diff --git a/src/postProcessing/functionObjects/forces/Make/files b/src/postProcessing/functionObjects/forces/Make/files index 4bf07db958..59996bffc9 100644 --- a/src/postProcessing/functionObjects/forces/Make/files +++ b/src/postProcessing/functionObjects/forces/Make/files @@ -15,18 +15,19 @@ sDoFRBMR = $(sDoFRBM)/sixDoFRigidBodyMotionRestraint $(sDoFRBMR)/sixDoFRigidBodyMotionRestraint/sixDoFRigidBodyMotionRestraint.C $(sDoFRBMR)/sixDoFRigidBodyMotionRestraint/newSixDoFRigidBodyMotionRestraint.C +$(sDoFRBMR)/linearAxialAngularSpring/linearAxialAngularSpring.C $(sDoFRBMR)/linearSpring/linearSpring.C $(sDoFRBMR)/sphericalAngularSpring/sphericalAngularSpring.C -$(sDoFRBMR)/linearAxialAngularSpring/linearAxialAngularSpring.C sDoFRBMC = $(sDoFRBM)/sixDoFRigidBodyMotionConstraint $(sDoFRBMC)/sixDoFRigidBodyMotionConstraint/sixDoFRigidBodyMotionConstraint.C $(sDoFRBMC)/sixDoFRigidBodyMotionConstraint/newSixDoFRigidBodyMotionConstraint.C -$(sDoFRBMC)/fixedPoint/fixedPoint.C -$(sDoFRBMC)/fixedPlane/fixedPlane.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 diff --git a/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion.C b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion.C index 689a743cc9..1088ab1506 100644 --- a/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion.C +++ b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion.C @@ -54,6 +54,8 @@ void Foam::sixDoFRigidBodyMotion::applyRestraints() a() += rF/mass_; + // Moments are returned in global axes, transforming to + // body local to add to torque. tau() += Q().T() & (rM + ((rP - centreOfMass()) ^ rF)); } } @@ -137,7 +139,8 @@ void Foam::sixDoFRigidBodyMotion::applyConstraints(scalar deltaT) a() += cFA/mass_; // The moment of constraint forces has already been added - // during accumulation + // during accumulation. Moments are returned in global axes, + // transforming to body local tau() += Q().T() & cMA; } } diff --git a/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion.H b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion.H index 348e5ddf8d..ecde4ac6d7 100644 --- a/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion.H +++ b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion.H @@ -272,7 +272,12 @@ public: //- Transform the given reference state direction by the current // motion state - inline point currentOrientation(const vector& refDir) const; + inline vector currentOrientation(const vector& refDir) const; + + //- Access the orientation tensor, Q. + // globalVector = Q & bodyLocalVector + // bodyLocalVector = Q.T() & globalVector + inline const tensor& currentOrientation() const; //- Predict the position of the supplied point after deltaT // given the current motion state and the additional supplied diff --git a/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionConstraint/fixedAxis/fixedAxis.C b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionConstraint/fixedAxis/fixedAxis.C new file mode 100644 index 0000000000..996b76b06c --- /dev/null +++ b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionConstraint/fixedAxis/fixedAxis.C @@ -0,0 +1,157 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 "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(predictedDir & fixedAxis_); + + vector rotationAxis = fixedAxis_ ^ predictedDir; + + scalar magRotationAxis = mag(rotationAxis); + + if (magRotationAxis > VSMALL) + { + rotationAxis /= magRotationAxis; + + const tensor& Q = motion.currentOrientation(); + + // 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; + + return (mag(theta) < tolerance_); +} + + +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; +} + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionConstraint/fixedAxis/fixedAxis.H b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionConstraint/fixedAxis/fixedAxis.H new file mode 100644 index 0000000000..5ba3dcb60d --- /dev/null +++ b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionConstraint/fixedAxis/fixedAxis.H @@ -0,0 +1,126 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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::fixedAxis + +Description + sixDoFRigidBodyMotionConstraint. Axis of body fixed 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 clone() const + { + return autoPtr + ( + 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); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace solidBodyMotionFunctions +} // 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 7de803afe1..f112ef42ef 100644 --- a/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionI.H +++ b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionI.H @@ -210,7 +210,7 @@ inline Foam::point Foam::sixDoFRigidBodyMotion::currentPosition } -inline Foam::point Foam::sixDoFRigidBodyMotion::currentOrientation +inline Foam::vector Foam::sixDoFRigidBodyMotion::currentOrientation ( const vector& refDir ) const @@ -219,6 +219,13 @@ inline Foam::point Foam::sixDoFRigidBodyMotion::currentOrientation } +inline const Foam::tensor& +Foam::sixDoFRigidBodyMotion::currentOrientation() const +{ + return Q(); +} + + inline Foam::vector Foam::sixDoFRigidBodyMotion::omega() const { return Q() & (inv(momentOfInertia_) & pi());