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

fixedPlane.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 "fixedPlane.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(fixedPlane, 0);
00037     addToRunTimeSelectionTable
00038     (
00039         sixDoFRigidBodyMotionConstraint,
00040         fixedPlane,
00041         dictionary
00042     );
00043 };
00044 };
00045 
00046 
00047 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00048 
00049 Foam::sixDoFRigidBodyMotionConstraints::fixedPlane::fixedPlane
00050 (
00051     const dictionary& sDoFRBMCDict
00052 )
00053 :
00054     sixDoFRigidBodyMotionConstraint(sDoFRBMCDict),
00055     fixedPlane_(vector::one)
00056 {
00057     read(sDoFRBMCDict);
00058 }
00059 
00060 
00061 // * * * * * * * * * * * * * * * * Destructors * * * * * * * * * * * * * * * //
00062 
00063 Foam::sixDoFRigidBodyMotionConstraints::fixedPlane::~fixedPlane()
00064 {}
00065 
00066 
00067 // * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * * //
00068 
00069 bool Foam::sixDoFRigidBodyMotionConstraints::fixedPlane::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     const point& refPt = fixedPlane_.refPoint();
00081 
00082     const vector& n = fixedPlane_.normal();
00083 
00084     point predictedPosition = motion.predictedPosition
00085     (
00086         refPt,
00087         existingConstraintForce,
00088         existingConstraintMoment,
00089         deltaT
00090     );
00091 
00092     constraintPosition = motion.currentPosition(refPt);
00093 
00094     // Info<< "current position " << constraintPosition << nl
00095     //     << "next predictedPosition " << predictedPosition
00096     //     << endl;
00097 
00098     vector error = ((predictedPosition - refPt) & n)*n;
00099 
00100     // Info<< "error " << error << endl;
00101 
00102     constraintForceIncrement =
00103         -relaxationFactor_*error*motion.mass()/sqr(deltaT);
00104 
00105     constraintMomentIncrement = vector::zero;
00106 
00107     bool converged(mag(error) < tolerance_);
00108 
00109     if (sixDoFRigidBodyMotionConstraint::debug)
00110     {
00111         Info<< " error " << error
00112             << " force " << constraintForceIncrement
00113             << " moment " << constraintMomentIncrement;
00114 
00115         if (converged)
00116         {
00117             Info<< " converged";
00118         }
00119         else
00120         {
00121             Info<< " not converged";
00122         }
00123 
00124         Info<< endl;
00125     }
00126 
00127     return converged;
00128 }
00129 
00130 
00131 bool Foam::sixDoFRigidBodyMotionConstraints::fixedPlane::read
00132 (
00133     const dictionary& sDoFRBMCDict
00134 )
00135 {
00136     sixDoFRigidBodyMotionConstraint::read(sDoFRBMCDict);
00137 
00138     point refPt = sDoFRBMCCoeffs_.lookup("refPoint");
00139 
00140     vector normal = sDoFRBMCCoeffs_.lookup("normal");
00141 
00142     fixedPlane_ = plane(refPt, normal);
00143 
00144     return true;
00145 }
00146 
00147 
00148 void Foam::sixDoFRigidBodyMotionConstraints::fixedPlane::write
00149 (
00150     Ostream& os
00151 ) const
00152 {
00153     os.writeKeyword("refPoint")
00154         << fixedPlane_.refPoint() << token::END_STATEMENT << nl;
00155 
00156     os.writeKeyword("normal")
00157         << fixedPlane_.normal() << token::END_STATEMENT << nl;
00158 }
00159 
00160 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines