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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
29 #include "constants.H"
30 
31 using namespace Foam::constant::mathematical;
32 
33 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
34 
35 template<class CloudType>
37 (
38  const dictionary& dict,
39  CloudType& owner
40 )
41 :
43 {}
44 
45 
46 template<class CloudType>
48 (
50 )
51 :
53 {}
54 
55 
56 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
57 
58 template<class CloudType>
60 {}
61 
62 
63 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
64 
65 template<class CloudType>
67 (
68  const scalar dt,
69  const label celli,
70  const vector& U,
71  const vector& Uc,
72  vector& UTurb,
73  scalar& tTurb
74 )
75 {
76  Random& rnd = this->owner().rndGen();
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 = rnd.sample01<scalar>()*twoPi;
105  const scalar u = 2*rnd.sample01<scalar>() - 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(rnd.GaussNormal<scalar>())*dir;
111  }
112  }
113  else
114  {
115  tTurb = GREAT;
116  UTurb = Zero;
117  }
118 
119  return Uc + UTurb;
120 }
121 
122 
123 // ************************************************************************* //
Foam::Random
Random number generator.
Definition: Random.H:59
Foam::Random::GaussNormal
Type GaussNormal()
Definition: RandomTemplates.C:49
Foam::Zero
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
StochasticDispersionRAS.H
Foam::sin
dimensionedScalar sin(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:264
Foam::Random::sample01
Type sample01()
Return a sample whose components lie in the range [0,1].
Definition: RandomTemplates.C:36
Foam::StochasticDispersionRAS
The velocity is perturbed in random direction, with a Gaussian random number distribution with varian...
Definition: StochasticDispersionRAS.H:50
Foam::min
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:33
Foam::StochasticDispersionRAS::StochasticDispersionRAS
StochasticDispersionRAS(const dictionary &dict, CloudType &owner)
Construct from components.
Definition: StochasticDispersionRAS.C:37
Foam::DSMCCloud::rndGen
Random & rndGen()
Return reference to the random object.
Definition: DSMCCloudI.H:124
Foam::pow
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
Definition: dimensionedScalar.C:75
Foam::DSMCCloud
Templated base class for dsmc cloud.
Definition: DSMCCloud.H:71
Foam::constant::mathematical::twoPi
constexpr scalar twoPi(2 *M_PI)
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:67
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
constants.H
U
U
Definition: pEqn.H:72
Foam::sqr
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Definition: dimensionedSymmTensor.C:51
Foam::constant::mathematical
Mathematical constants.
Foam::Vector< scalar >
Foam::sqrt
dimensionedScalar sqrt(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:144
Foam::mag
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
k
label k
Boltzmann constant.
Definition: LISASMDCalcMethod2.H:41
epsilon
scalar epsilon
Definition: evaluateNearWall.H:7
sigma
dimensionedScalar sigma("sigma", dimMass/sqr(dimTime), transportProperties)
Foam::StochasticDispersionRAS::~StochasticDispersionRAS
virtual ~StochasticDispersionRAS()
Destructor.
Definition: StochasticDispersionRAS.C:59
Foam::DispersionRASModel
Base class for particle dispersion models based on RAS turbulence.
Definition: DispersionRASModel.H:49
Foam::cos
dimensionedScalar cos(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:265