StochasticDispersionRAS.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2024 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 #include "standardNormal.H"
29 
30 using namespace Foam::constant::mathematical;
31 
32 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
33 
34 template<class CloudType>
36 (
37  const dictionary& dict,
38  CloudType& owner
39 )
40 :
42 {}
43 
44 
45 template<class CloudType>
47 (
49 )
50 :
52 {}
53 
54 
55 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
56 
57 template<class CloudType>
59 {}
60 
61 
62 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
63 
64 template<class CloudType>
66 (
67  const scalar dt,
68  const label celli,
69  const vector& U,
70  const vector& Uc,
71  vector& UTurb,
72  scalar& tTurb
73 )
74 {
75  randomGenerator& rndGen = this->owner().rndGen();
76  distributions::standardNormal& stdNormal = this->owner().stdNormal();
77 
78  const scalar cps = 0.16432;
79 
80  const scalar k = this->kPtr_->primitiveField()[celli];
81  const scalar epsilon =
82  this->epsilonPtr_->primitiveField()[celli] + rootVSmall;
83 
84  const scalar UrelMag = mag(U - Uc - UTurb);
85 
86  const scalar tTurbLoc =
87  min(k/epsilon, cps*pow(k, 1.5)/epsilon/(UrelMag + small));
88 
89 
90  // Parcel is perturbed by the turbulence
91  if (dt < tTurbLoc)
92  {
93  tTurb += dt;
94 
95  if (tTurb > tTurbLoc)
96  {
97  tTurb = 0;
98 
99  const scalar sigma = sqrt(2*k/3.0);
100 
101  // Calculate a random direction dir distributed uniformly
102  // in spherical coordinates
103 
104  const scalar theta = rndGen.scalar01()*twoPi;
105  const scalar u = 2*rndGen.scalar01() - 1;
106 
107  const scalar a = sqrt(1 - sqr(u));
108  const vector dir(a*cos(theta), a*sin(theta), u);
109 
110  UTurb = sigma*mag(stdNormal.sample())*dir;
111  }
112  }
113  else
114  {
115  tTurb = great;
116  UTurb = Zero;
117  }
118 
119  return Uc + UTurb;
120 }
121 
122 
123 // ************************************************************************* //
label k
Templated base class for dsmc cloud.
Definition: DSMCCloud.H:80
Base class for particle dispersion models based on RAS turbulence.
The velocity is perturbed in random direction, with a Gaussian random number distribution with varian...
virtual ~StochasticDispersionRAS()
Destructor.
StochasticDispersionRAS(const dictionary &dict, CloudType &owner)
Construct from components.
virtual vector update(const scalar dt, const label celli, const vector &U, const vector &Uc, vector &UTurb, scalar &tTurb)
Update (disperse particles)
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
Standard normal distribution. Not selectable.
virtual scalar sample() const
Sample the distribution.
Random number generator.
scalar scalar01()
Return a scalar uniformly distributed between zero and one.
const scalar epsilon
U
Definition: pEqn.H:72
mathematical constants.
const scalar twoPi(2 *pi)
const dimensionedScalar sigma
Stefan-Boltzmann constant: default SI units: [W/m^2/K^4].
static const zero Zero
Definition: zero.H:97
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
dimensionedSymmTensor sqr(const dimensionedVector &dv)
dimensionedScalar sin(const dimensionedScalar &ds)
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
dimensionedScalar sqrt(const dimensionedScalar &ds)
dimensioned< scalar > mag(const dimensioned< Type > &)
dimensionedScalar cos(const dimensionedScalar &ds)
dictionary dict
randomGenerator rndGen(653213)