StochasticDispersionRAS.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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
19  for more details.
20 
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/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
27 #include "constants.H"
28 
29 using namespace Foam::constant::mathematical;
30 
31 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32 
33 template<class CloudType>
35 (
36  const dictionary& dict,
37  CloudType& owner
38 )
39 :
41 {}
42 
43 
44 template<class CloudType>
46 (
48 )
49 :
51 {}
52 
53 
54 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
55 
56 template<class CloudType>
58 {}
59 
60 
61 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
62 
63 template<class CloudType>
65 (
66  const scalar dt,
67  const label celli,
68  const vector& U,
69  const vector& Uc,
70  vector& UTurb,
71  scalar& tTurb
72 )
73 {
74  cachedRandom& rnd = this->owner().rndGen();
75 
76  const scalar cps = 0.16432;
77 
78  const scalar k = this->kPtr_->primitiveField()[celli];
79  const scalar epsilon =
80  this->epsilonPtr_->primitiveField()[celli] + ROOTVSMALL;
81 
82  const scalar UrelMag = mag(U - Uc - UTurb);
83 
84  const scalar tTurbLoc =
85  min(k/epsilon, cps*pow(k, 1.5)/epsilon/(UrelMag + SMALL));
86 
87 
88  // Parcel is perturbed by the turbulence
89  if (dt < tTurbLoc)
90  {
91  tTurb += dt;
92 
93  if (tTurb > tTurbLoc)
94  {
95  tTurb = 0;
96 
97  const scalar sigma = sqrt(2*k/3.0);
98 
99  // Calculate a random direction dir distributed uniformly
100  // in spherical coordinates
101 
102  const scalar theta = rnd.sample01<scalar>()*twoPi;
103  const scalar u = 2*rnd.sample01<scalar>() - 1;
104 
105  const scalar a = sqrt(1 - sqr(u));
106  const vector dir(a*cos(theta), a*sin(theta), u);
107 
108  UTurb = sigma*mag(rnd.GaussNormal<scalar>())*dir;
109  }
110  }
111  else
112  {
113  tTurb = GREAT;
114  UTurb = Zero;
115  }
116 
117  return Uc + UTurb;
118 }
119 
120 
121 // ************************************************************************* //
dictionary dict
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
dimensionedSymmTensor sqr(const dimensionedVector &dv)
dimensionedScalar sqrt(const dimensionedScalar &ds)
const dimensionedScalar sigma
Stefan-Boltzmann constant: default SI units: [W/m2/K4].
Random number generator.
Definition: cachedRandom.H:63
label k
Boltzmann constant.
virtual ~StochasticDispersionRAS()
Destructor.
Type GaussNormal()
Return a sample whose components are normally distributed.
Type sample01()
Return a sample whose components lie in the range 0-1.
dimensionedScalar cos(const dimensionedScalar &ds)
mathematical constants.
Random & rndGen()
Return refernce to the random object.
Definition: DSMCCloudI.H:121
static const zero Zero
Definition: zero.H:91
virtual vector update(const scalar dt, const label celli, const vector &U, const vector &Uc, vector &UTurb, scalar &tTurb)
Update (disperse particles)
const scalar twoPi(2 *pi)
dimensionedScalar sin(const dimensionedScalar &ds)
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
scalar epsilon
dimensioned< scalar > mag(const dimensioned< Type > &)
Base class for particle dispersion models based on RAS turbulence.
Templated base class for dsmc cloud.
Definition: DSMCCloud.H:68
StochasticDispersionRAS(const dictionary &dict, CloudType &owner)
Construct from components.
The velocity is perturbed in random direction, with a Gaussian random number distribution with varian...