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-2015 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_->internalField()[cellI];
79  const scalar epsilon =
80  this->epsilonPtr_->internalField()[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 = vector::zero;
115  }
116 
117  return Uc + UTurb;
118 }
119 
120 
121 // ************************************************************************* //
Foam::cachedRandom::sample01
Type sample01()
Return a sample whose components lie in the range 0-1.
Definition: cachedRandomTemplates.C:32
Foam::Vector< scalar >::zero
static const Vector zero
Definition: Vector.H:80
StochasticDispersionRAS.H
Foam::sin
dimensionedScalar sin(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:255
Foam::constant::mathematical::twoPi
const scalar twoPi(2 *pi)
Foam::mag
dimensioned< scalar > mag(const dimensioned< Type > &)
Foam::StochasticDispersionRAS
The velocity is perturbed in random direction, with a Gaussian random number distribution with varian...
Definition: StochasticDispersionRAS.H:48
Foam::StochasticDispersionRAS::StochasticDispersionRAS
StochasticDispersionRAS(const dictionary &dict, CloudType &owner)
Construct from components.
Definition: StochasticDispersionRAS.C:35
Foam::DSMCCloud::rndGen
Random & rndGen()
Return refernce to the random object.
Definition: DSMCCloudI.H:121
U
U
Definition: pEqn.H:46
Foam::label
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
Foam::cachedRandom
Random number generator.
Definition: cachedRandom.H:63
Foam::pow
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
Definition: dimensionedScalar.C:73
Foam::DSMCCloud
Templated base class for dsmc cloud.
Definition: DSMCCloud.H:68
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
constants.H
epsilon
epsilon
Definition: createTDFields.H:56
Foam::sqr
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Definition: dimensionedSymmTensor.C:49
Foam::constant::mathematical
mathematical constants.
Foam::Vector< scalar >
Foam::sqrt
dimensionedScalar sqrt(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:142
k
label k
Boltzmann constant.
Definition: LISASMDCalcMethod2.H:41
Foam::cachedRandom::GaussNormal
Type GaussNormal()
Return a sample whose components are normally distributed.
Definition: cachedRandomTemplates.C:45
Foam::constant::physicoChemical::sigma
const dimensionedScalar sigma
Stefan-Boltzmann constant: default SI units: [W/m2/K4].
Foam::min
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
Foam::StochasticDispersionRAS::~StochasticDispersionRAS
virtual ~StochasticDispersionRAS()
Destructor.
Definition: StochasticDispersionRAS.C:57
Foam::DispersionRASModel
Base class for particle dispersion models based on RAS turbulence.
Definition: DispersionRASModel.H:47
Foam::StochasticDispersionRAS::update
virtual vector update(const scalar dt, const label cellI, const vector &U, const vector &Uc, vector &UTurb, scalar &tTurb)
Update (disperse particles)
Definition: StochasticDispersionRAS.C:65
Foam::cos
dimensionedScalar cos(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:256