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