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

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