1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by
13 the Free Software Foundation, either version 3 of the License, or
14 (at your option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
28 #include "stochasticDispersionRAS.H"
29 #include "addToRunTimeSelectionTable.H"
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
35 defineTypeNameAndDebug(stochasticDispersionRAS, 0);
37 addToRunTimeSelectionTable
40 stochasticDispersionRAS,
46 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
48 Foam::stochasticDispersionRAS::stochasticDispersionRAS
50 const dictionary& dict,
54 dispersionRASModel(dict, sm)
58 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
60 Foam::stochasticDispersionRAS::~stochasticDispersionRAS()
64 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
66 void Foam::stochasticDispersionRAS::disperseParcels() const
69 const scalar cps = 0.16432;
70 const vector one(1.0, 1.0, 1.0);
72 scalar dt = spray_.runTime().deltaTValue();
73 const volScalarField& k = turbulence().k();
74 // volVectorField gradk(fvc::grad(k));
75 const volScalarField& epsilon = turbulence().epsilon();
76 const volVectorField& U = spray_.U();
78 forAllIter(spray, spray_, elmnt)
80 const label cellI = elmnt().cell();
81 scalar UrelMag = mag(elmnt().U() - U[cellI] - elmnt().Uturb());
85 k[cellI]/epsilon[cellI],
86 cps*pow(k[cellI], 1.5)/epsilon[cellI]/(UrelMag + SMALL)
89 // parcel is perturbed by the turbulence
92 elmnt().tTurb() += dt;
94 if (elmnt().tTurb() > Tturb)
96 elmnt().tTurb() = 0.0;
98 scalar sigma = sqrt(2.0*k[cellI]/3.0);
99 vector dir = 2.0*spray_.rndGen().sample01<vector>() - one;
100 dir /= mag(dir) + SMALL;
102 // numerical recipes... Ch. 7. Random Numbers...
105 while (rsq > 1.0 || rsq == 0.0)
107 x1 = 2.0*spray_.rndGen().sample01<scalar>() - 1.0;
108 x2 = 2.0*spray_.rndGen().sample01<scalar>() - 1.0;
112 scalar fac = sqrt(-2.0*log(rsq)/rsq);
116 elmnt().Uturb() = sigma*fac*dir;
122 elmnt().tTurb() = GREAT;
123 elmnt().Uturb() = vector::zero;
129 // ************************************************************************* //