OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

reflectParcel.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-2009 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 the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     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, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 \*---------------------------------------------------------------------------*/
00026 
00027 #include "reflectParcel.H"
00028 #include "addToRunTimeSelectionTable.H"
00029 #include "wallPolyPatch.H"
00030 
00031 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00032 
00033 namespace Foam
00034 {
00035 
00036 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
00037 
00038 defineTypeNameAndDebug(reflectParcel, 0);
00039 
00040 addToRunTimeSelectionTable
00041 (
00042     wallModel,
00043     reflectParcel,
00044     dictionary
00045 );
00046 
00047 
00048 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00049 
00050 // Construct from components
00051 reflectParcel::reflectParcel
00052 (
00053     const dictionary& dict,
00054     const volVectorField& U,
00055     spray& sm
00056 )
00057 :
00058     wallModel(dict, U, sm),
00059     U_(U),
00060     coeffsDict_(dict.subDict(typeName + "Coeffs")),
00061     elasticity_(readScalar(coeffsDict_.lookup("elasticity")))
00062 {}
00063 
00064 
00065 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00066 
00067 reflectParcel::~reflectParcel()
00068 {}
00069 
00070 
00071 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00072 
00073 // Return 'keepParcel'
00074 bool reflectParcel::wallTreatment
00075 (
00076     parcel& p,
00077     const label globalFacei
00078 ) const
00079 {
00080     label patchi = p.patch(globalFacei);
00081     label facei = p.patchFace(patchi, globalFacei);
00082 
00083     const polyMesh& mesh = spray_.mesh();
00084 
00085     if (isType<wallPolyPatch>(mesh_.boundaryMesh()[patchi]))
00086     {
00087         // wallNormal defined to point outwards of domain
00088         vector Sf = mesh_.Sf().boundaryField()[patchi][facei];
00089         Sf /= mag(Sf);
00090 
00091         if (!mesh.moving())
00092         {
00093             // static mesh
00094             scalar Un = p.U() & Sf;
00095             
00096             if (Un > 0)
00097             {
00098                 p.U() -= (1.0 + elasticity_)*Un*Sf;
00099             }
00100 
00101         }
00102         else
00103         {
00104             // moving mesh
00105             vector Ub1 = U_.boundaryField()[patchi][facei];
00106             vector Ub0 = U_.oldTime().boundaryField()[patchi][facei];
00107 
00108             scalar dt = spray_.runTime().deltaT().value();
00109             const vectorField& oldPoints = mesh.oldPoints();
00110 
00111             const vector& Cf1 = mesh.faceCentres()[globalFacei];
00112 
00113             vector Cf0 = mesh.faces()[globalFacei].centre(oldPoints);
00114             vector Cf = Cf0 + p.stepFraction()*(Cf1 - Cf0);
00115             vector Sf0 = mesh.faces()[globalFacei].normal(oldPoints);
00116 
00117             // for layer addition Sf0 = vector::zero and we use Sf
00118             if (mag(Sf0) > SMALL)
00119             {
00120                 Sf0 /= mag(Sf0);
00121             }
00122             else
00123             {
00124                 Sf0 = Sf;
00125             }
00126 
00127             scalar magSfDiff = mag(Sf - Sf0);
00128 
00129             vector Ub = Ub0 + p.stepFraction()*(Ub1 - Ub0);
00130                 
00131             if (magSfDiff > SMALL)
00132             {
00133                 // rotation + translation
00134                 vector Sfp = Sf0 + p.stepFraction()*(Sf - Sf0);
00135 
00136                 vector omega = Sf0 ^ Sf;
00137                 scalar magOmega = mag(omega);
00138                 omega /= magOmega+SMALL;
00139                     
00140                 scalar phiVel = ::asin(magOmega)/dt;
00141                     
00142                 scalar dist = (p.position() - Cf) & Sfp;
00143                 vector pos = p.position() - dist*Sfp;
00144                 vector vrot = phiVel*(omega ^ (pos - Cf));
00145 
00146                 vector v = Ub + vrot;
00147                 
00148                 scalar Un = ((p.U() - v) & Sfp);
00149                 
00150                 if (Un > 0.0)
00151                 {
00152                     p.U() -= (1.0 + elasticity_)*Un*Sfp;
00153                 }
00154             }
00155             else
00156             {
00157                 // translation
00158                 vector Ur = p.U() - Ub;
00159                 scalar Urn = Ur & Sf;
00160                 /*
00161                 if (mag(Ub-v) > SMALL)
00162                 {
00163                     Info << "reflectParcel:: v = " << v
00164                         << ", Ub = " << Ub
00165                         << ", facei = " << facei
00166                         << ", patchi = " << patchi
00167                         << ", globalFacei = " << globalFacei
00168                         << ", name = " << mesh_.boundaryMesh()[patchi].name()
00169                         << endl;
00170                 }
00171                     */
00172                 if (Urn > 0.0)
00173                 {
00174                     p.U() -= (1.0 + elasticity_)*Urn*Sf;
00175                 }
00176             }
00177         }
00178 
00179     }
00180     else
00181     {
00182         FatalError
00183             << "bool reflectParcel::wallTreatment(parcel& parcel) const "
00184                 << " parcel has hit a boundary " 
00185                 << mesh_.boundary()[patchi].type()
00186                 << " which not yet has been implemented."
00187             << abort(FatalError);
00188     }
00189     return true;
00190 }
00191 
00192 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00193 
00194 } // End namespace Foam
00195 
00196 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd