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

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-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 <lagrangianIntermediate/StochasticDispersionRAS.H>
00027 
00028 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00029 
00030 template<class CloudType>
00031 Foam::StochasticDispersionRAS<CloudType>::StochasticDispersionRAS
00032 (
00033     const dictionary& dict,
00034     CloudType& owner
00035 )
00036 :
00037     DispersionRASModel<CloudType>(dict, owner)
00038 {}
00039 
00040 
00041 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00042 
00043 template<class CloudType>
00044 Foam::StochasticDispersionRAS<CloudType>::~StochasticDispersionRAS()
00045 {}
00046 
00047 
00048 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00049 
00050 template<class CloudType>
00051 bool Foam::StochasticDispersionRAS<CloudType>::active() const
00052 {
00053     return true;
00054 }
00055 
00056 
00057 template<class CloudType>
00058 Foam::vector Foam::StochasticDispersionRAS<CloudType>::update
00059 (
00060     const scalar dt,
00061     const label celli,
00062     const vector& U,
00063     const vector& Uc,
00064     vector& UTurb,
00065     scalar& tTurb
00066 )
00067 {
00068     const scalar cps = 0.16432;
00069 
00070     const volScalarField& k = *this->kPtr_;
00071     const volScalarField& epsilon = *this->epsilonPtr_;
00072 
00073     const scalar UrelMag = mag(U - Uc - UTurb);
00074 
00075     const scalar tTurbLoc = min
00076     (
00077         k[celli]/epsilon[celli],
00078         cps*pow(k[celli], 1.5)/epsilon[celli]/(UrelMag + SMALL)
00079     );
00080 
00081     // Parcel is perturbed by the turbulence
00082     if (dt < tTurbLoc)
00083     {
00084         tTurb += dt;
00085 
00086         if (tTurb > tTurbLoc)
00087         {
00088             tTurb = 0.0;
00089 
00090             scalar sigma = sqrt(2.0*k[celli]/3.0);
00091             vector dir = 2.0*this->owner().rndGen().vector01() - vector::one;
00092             dir /= mag(dir) + SMALL;
00093 
00094             // Numerical Recipes... Ch. 7. Random Numbers...
00095             scalar x1 = 0.0;
00096             scalar x2 = 0.0;
00097             scalar rsq = 10.0;
00098             while ((rsq > 1.0) || (rsq == 0.0))
00099             {
00100                 x1 = 2.0*this->owner().rndGen().scalar01() - 1.0;
00101                 x2 = 2.0*this->owner().rndGen().scalar01() - 1.0;
00102                 rsq = x1*x1 + x2*x2;
00103             }
00104 
00105             scalar fac = sqrt(-2.0*log(rsq)/rsq);
00106 
00107             fac *= mag(x1);
00108 
00109             UTurb = sigma*fac*dir;
00110 
00111         }
00112     }
00113     else
00114     {
00115         tTurb = GREAT;
00116         UTurb = vector::zero;
00117     }
00118 
00119     return Uc + UTurb;
00120 }
00121 
00122 
00123 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines