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-------------------------------------------------------------------------------
10License
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
31using namespace Foam::constant::mathematical;
32
33// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
34
35template<class CloudType>
37(
38 const dictionary& dict,
39 CloudType& owner
40)
41:
43{}
44
45
46template<class CloudType>
48(
50)
51:
53{}
54
55
56// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
57
58template<class CloudType>
60{}
61
62
63// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
64
65template<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// ************************************************************************* //
label k
Templated base class for dsmc cloud.
Definition: DSMCCloud.H:75
Base class for particle dispersion models based on RAS turbulence.
Random number generator.
Definition: Random.H:60
Type GaussNormal()
Type sample01()
Return a sample whose components lie in the range [0,1].
The velocity is perturbed in random direction, with a Gaussian random number distribution with varian...
virtual ~StochasticDispersionRAS()
Destructor.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
virtual bool update()
Update the mesh for both mesh motion and topology change.
U
Definition: pEqn.H:72
scalar epsilon
Mathematical constants.
constexpr scalar twoPi(2 *M_PI)
dimensionedSymmTensor sqr(const dimensionedVector &dv)
dimensionedScalar sin(const dimensionedScalar &ds)
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
dimensionedScalar sqrt(const dimensionedScalar &ds)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:33
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
dimensionedScalar cos(const dimensionedScalar &ds)
dictionary dict