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

gradientDispersionRAS.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 "error.H"
00028 
00029 #include "gradientDispersionRAS.H"
00030 #include "addToRunTimeSelectionTable.H"
00031 
00032 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00033 
00034 namespace Foam
00035 {
00036 
00037 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
00038 
00039 defineTypeNameAndDebug(gradientDispersionRAS, 0);
00040 
00041 addToRunTimeSelectionTable
00042 (
00043     dispersionModel,
00044     gradientDispersionRAS,
00045     dictionary
00046 );
00047 
00048 
00049 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00050 
00051 // Construct from components
00052 gradientDispersionRAS::gradientDispersionRAS
00053 (
00054     const dictionary& dict,
00055     spray& sm
00056 )
00057 :
00058     dispersionRASModel(dict, sm)
00059 {}
00060 
00061 
00062 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00063 
00064 gradientDispersionRAS::~gradientDispersionRAS()
00065 {}
00066 
00067 
00068 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00069 
00070 void gradientDispersionRAS::disperseParcels() const
00071 {
00072 
00073     const scalar cps = 0.16432;
00074 
00075     scalar dt = spray_.runTime().deltaT().value();
00076     const volScalarField& k = turbulence().k();
00077     volVectorField gradk = fvc::grad(k);
00078     const volScalarField& epsilon = turbulence().epsilon();
00079     const volVectorField& U = spray_.U();
00080 
00081     for
00082     (
00083         spray::iterator elmnt = spray_.begin();
00084         elmnt != spray_.end();
00085         ++elmnt
00086     )
00087     {
00088         label celli = elmnt().cell();
00089         scalar UrelMag = mag(elmnt().U() - U[celli] - elmnt().Uturb());
00090 
00091         scalar Tturb = min
00092         (
00093             k[celli]/epsilon[celli], 
00094             cps*pow(k[celli], 1.5)/epsilon[celli]/(UrelMag + SMALL)
00095         );
00096         // parcel is perturbed by the turbulence
00097         if (dt < Tturb)
00098         {
00099             elmnt().tTurb() += dt;
00100 
00101             if (elmnt().tTurb() > Tturb)
00102             {
00103                 elmnt().tTurb() = 0.0;
00104 
00105                 scalar sigma = sqrt(2.0*k[celli]/3.0);
00106                 vector dir = -gradk[celli]/(mag(gradk[celli]) + SMALL);
00107 
00108                 // numerical recipes... Ch. 7. Random Numbers...
00109                 scalar x1 = 0.0;
00110                 scalar x2 = 0.0;
00111                 scalar rsq = 10.0;
00112                 while((rsq > 1.0) || (rsq == 0.0))
00113                 {
00114                     x1 = 2.0*spray_.rndGen().scalar01() - 1.0;
00115                     x2 = 2.0*spray_.rndGen().scalar01() - 1.0;
00116                     rsq = x1*x1 + x2*x2;
00117                 }
00118                 
00119                 scalar fac = sqrt(-2.0*log(rsq)/rsq);
00120                 
00121                 // in 2D calculations the -grad(k) is always
00122                 // away from the axis of symmetry
00123                 // This creates a 'hole' in the spray and to
00124                 // prevent this we let x1 be both negative/positive
00125                 if (spray_.twoD())
00126                 {
00127                     fac *= x1;
00128                 }
00129                 else
00130                 {
00131                     fac *= mag(x1);
00132                 }
00133                 
00134                 elmnt().Uturb() = sigma*fac*dir;
00135             }
00136         }
00137         else
00138         {
00139             elmnt().tTurb() = GREAT;
00140             elmnt().Uturb() = vector::zero;
00141         }
00142     }
00143 }
00144 
00145 
00146 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00147 
00148 } // End namespace Foam
00149 
00150 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd