FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

fixedPoint.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2010 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software: you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
00023 
00024 \*---------------------------------------------------------------------------*/
00025 
00026 #include "fixedPoint.H"
00027 #include <OpenFOAM/addToRunTimeSelectionTable.H>
00028 #include <forces/sixDoFRigidBodyMotion.H>
00029 
00030 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
00031 
00032 namespace Foam
00033 {
00034 namespace sixDoFRigidBodyMotionConstraints
00035 {
00036     defineTypeNameAndDebug(fixedPoint, 0);
00037     addToRunTimeSelectionTable
00038     (
00039         sixDoFRigidBodyMotionConstraint,
00040         fixedPoint,
00041         dictionary
00042     );
00043 };
00044 };
00045 
00046 
00047 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00048 
00049 Foam::sixDoFRigidBodyMotionConstraints::fixedPoint::fixedPoint
00050 (
00051     const dictionary& sDoFRBMCDict
00052 )
00053 :
00054     sixDoFRigidBodyMotionConstraint(sDoFRBMCDict),
00055     fixedPoint_()
00056 {
00057     read(sDoFRBMCDict);
00058 }
00059 
00060 
00061 // * * * * * * * * * * * * * * * * Destructors * * * * * * * * * * * * * * * //
00062 
00063 Foam::sixDoFRigidBodyMotionConstraints::fixedPoint::~fixedPoint()
00064 {}
00065 
00066 
00067 // * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * * //
00068 
00069 bool Foam::sixDoFRigidBodyMotionConstraints::fixedPoint::constrain
00070 (
00071     const sixDoFRigidBodyMotion& motion,
00072     const vector& existingConstraintForce,
00073     const vector& existingConstraintMoment,
00074     scalar deltaT,
00075     vector& constraintPosition,
00076     vector& constraintForceIncrement,
00077     vector& constraintMomentIncrement
00078 ) const
00079 {
00080     point predictedPosition = motion.predictedPosition
00081     (
00082         fixedPoint_,
00083         existingConstraintForce,
00084         existingConstraintMoment,
00085         deltaT
00086     );
00087 
00088     constraintPosition = motion.currentPosition(fixedPoint_);
00089 
00090     // Info<< "current position " << constraintPosition << nl
00091     //     << "next predictedPosition " << predictedPosition
00092     //     << endl;
00093 
00094     vector error = predictedPosition - fixedPoint_;
00095 
00096     // Info<< "error " << error << endl;
00097 
00098     // Correction force derived from Lagrange multiplier:
00099     //     G = -lambda*grad(sigma)
00100     // where
00101     //     sigma = mag(error) = 0
00102     // so
00103     //     grad(sigma) = error/mag(error)
00104     // Solving for lambda using the SHAKE methodology gives
00105     //     lambda = mass*mag(error)/sqr(deltaT)
00106     // This is only strictly applicable (i.e. will converge in one
00107     // iteration) to constraints at the centre of mass.  Everything
00108     // else will need to iterate, and may need under-relaxed to be
00109     // stable.
00110 
00111     constraintForceIncrement =
00112         -relaxationFactor_*error*motion.mass()/sqr(deltaT);
00113 
00114     constraintMomentIncrement = vector::zero;
00115 
00116     bool converged(mag(error) < tolerance_);
00117 
00118     if (sixDoFRigidBodyMotionConstraint::debug)
00119     {
00120         Info<< " error " << error
00121             << " force " << constraintForceIncrement
00122             << " moment " << constraintMomentIncrement;
00123 
00124         if (converged)
00125         {
00126             Info<< " converged";
00127         }
00128         else
00129         {
00130             Info<< " not converged";
00131         }
00132 
00133         Info<< endl;
00134     }
00135 
00136     return converged;
00137 }
00138 
00139 
00140 bool Foam::sixDoFRigidBodyMotionConstraints::fixedPoint::read
00141 (
00142     const dictionary& sDoFRBMCDict
00143 )
00144 {
00145     sixDoFRigidBodyMotionConstraint::read(sDoFRBMCDict);
00146 
00147     sDoFRBMCCoeffs_.lookup("fixedPoint") >> fixedPoint_;
00148 
00149     return true;
00150 }
00151 
00152 
00153 void Foam::sixDoFRigidBodyMotionConstraints::fixedPoint::write
00154 (
00155     Ostream& os
00156 ) const
00157 {
00158     os.writeKeyword("fixedPoint")
00159         << fixedPoint_ << token::END_STATEMENT << nl;
00160 }
00161 
00162 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines