diff --git a/src/postProcessing/functionObjects/forces/Make/files b/src/postProcessing/functionObjects/forces/Make/files index a7541d14c0..0f366f30ad 100644 --- a/src/postProcessing/functionObjects/forces/Make/files +++ b/src/postProcessing/functionObjects/forces/Make/files @@ -22,6 +22,8 @@ sDoFRBMC = $(sDoFRBM)/sixDoFRigidBodyMotionConstraint $(sDoFRBMC)/sixDoFRigidBodyMotionConstraint/sixDoFRigidBodyMotionConstraint.C $(sDoFRBMC)/sixDoFRigidBodyMotionConstraint/newSixDoFRigidBodyMotionConstraint.C $(sDoFRBMC)/fixedPoint/fixedPoint.C +$(sDoFRBMC)/fixedPlane/fixedPlane.C +$(sDoFRBMC)/fixedLine/fixedLine.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 cf5f1f95af..76b376d3b5 100644 --- a/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion.C +++ b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion.C @@ -90,7 +90,7 @@ void Foam::sixDoFRigidBodyMotion::applyConstraints(scalar deltaT) forAll(constraints_, cI) { - // Info<< "Constraint " << cI << endl; + Info<< nl << "Constraint " << cI << endl; // constraint position point cP = vector::zero; diff --git a/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionConstraint/fixedLine/fixedLine.C b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionConstraint/fixedLine/fixedLine.C new file mode 100644 index 0000000000..290531ba9e --- /dev/null +++ b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionConstraint/fixedLine/fixedLine.C @@ -0,0 +1,145 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 "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; + + return (mag(error) < tolerance_); +} + + +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; +} + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionConstraint/fixedLine/fixedLine.H b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionConstraint/fixedLine/fixedLine.H new file mode 100644 index 0000000000..01cc8ff52f --- /dev/null +++ b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionConstraint/fixedLine/fixedLine.H @@ -0,0 +1,127 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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::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 clone() const + { + return autoPtr + ( + 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); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace solidBodyMotionFunctions +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionConstraint/fixedPlane/fixedPlane.C b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionConstraint/fixedPlane/fixedPlane.C new file mode 100644 index 0000000000..29734967bd --- /dev/null +++ b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionConstraint/fixedPlane/fixedPlane.C @@ -0,0 +1,128 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 "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; + + return (mag(error) < tolerance_); +} + + +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; +} + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionConstraint/fixedPlane/fixedPlane.H b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionConstraint/fixedPlane/fixedPlane.H new file mode 100644 index 0000000000..45f35dbbb4 --- /dev/null +++ b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionConstraint/fixedPlane/fixedPlane.H @@ -0,0 +1,125 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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::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 clone() const + { + return autoPtr + ( + 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); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace solidBodyMotionFunctions +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // 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 index cfe8b5421d..3862f16e65 100644 --- a/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionConstraint/fixedPoint/fixedPoint.C +++ b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionConstraint/fixedPoint/fixedPoint.C @@ -53,7 +53,7 @@ Foam::sixDoFRigidBodyMotionConstraints::fixedPoint::fixedPoint ) : sixDoFRigidBodyMotionConstraint(sDoFRBMCDict), - fixedPoint_() + fixedPoint_(sDoFRBMCCoeffs_.lookup("fixedPoint")) { read(sDoFRBMCDict); } 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 index 59b5c35c43..933ba2db09 100644 --- a/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionConstraint/fixedPoint/fixedPoint.H +++ b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionConstraint/fixedPoint/fixedPoint.H @@ -48,7 +48,7 @@ namespace sixDoFRigidBodyMotionConstraints { /*---------------------------------------------------------------------------*\ - Class fixedPoint Declaration + Class fixedPoint Declaration \*---------------------------------------------------------------------------*/ class fixedPoint