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 "gradientDispersionRAS.H"
29 #include "addToRunTimeSelectionTable.H"
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
35 defineTypeNameAndDebug(gradientDispersionRAS, 0);
37 addToRunTimeSelectionTable
40 gradientDispersionRAS,
46 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
48 Foam::gradientDispersionRAS::gradientDispersionRAS
50 const dictionary& dict,
54 dispersionRASModel(dict, sm)
58 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
60 Foam::gradientDispersionRAS::~gradientDispersionRAS()
64 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
66 void Foam::gradientDispersionRAS::disperseParcels() const
69 const scalar cps = 0.16432;
71 scalar dt = spray_.runTime().deltaTValue();
72 const volScalarField& k = turbulence().k();
73 const volVectorField gradk(fvc::grad(k));
74 const volScalarField& epsilon = turbulence().epsilon();
75 const volVectorField& U = spray_.U();
77 forAllIter(spray, spray_, elmnt)
79 const label cellI = elmnt().cell();
80 scalar UrelMag = mag(elmnt().U() - U[cellI] - elmnt().Uturb());
84 k[cellI]/epsilon[cellI],
85 cps*pow(k[cellI], 1.5)/epsilon[cellI]/(UrelMag + SMALL)
87 // parcel is perturbed by the turbulence
90 elmnt().tTurb() += dt;
92 if (elmnt().tTurb() > Tturb)
94 elmnt().tTurb() = 0.0;
96 scalar sigma = sqrt(2.0*k[cellI]/3.0);
97 vector dir = -gradk[cellI]/(mag(gradk[cellI]) + SMALL);
99 // numerical recipes... Ch. 7. Random Numbers...
103 while ((rsq > 1.0) || (rsq == 0.0))
105 x1 = 2.0*spray_.rndGen().sample01<scalar>() - 1.0;
106 x2 = 2.0*spray_.rndGen().sample01<scalar>() - 1.0;
110 scalar fac = sqrt(-2.0*log(rsq)/rsq);
112 // in 2D calculations the -grad(k) is always
113 // away from the axis of symmetry
114 // This creates a 'hole' in the spray and to
115 // prevent this we let x1 be both negative/positive
125 elmnt().Uturb() = sigma*fac*dir;
130 elmnt().tTurb() = GREAT;
131 elmnt().Uturb() = vector::zero;
137 // ************************************************************************* //