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

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