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-2025 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 #include "meshTools.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  const polyMesh& mesh = this->owner().mesh();
77 
78  randomGenerator& rndGen = this->owner().rndGen();
79  distributions::standardNormal& stdNormal = this->owner().stdNormal();
80 
81  const scalar cps = 0.16432;
82 
83  const scalar k = this->kPtr_->primitiveField()[celli];
84  const scalar epsilon =
85  this->epsilonPtr_->primitiveField()[celli] + rootVSmall;
86 
87  const scalar UrelMag = mag(U - Uc - UTurb);
88 
89  const scalar tTurbLoc =
90  min(k/epsilon, cps*pow(k, 1.5)/epsilon/(UrelMag + small));
91 
92 
93  // Parcel is perturbed by the turbulence
94  if (dt < tTurbLoc)
95  {
96  tTurb += dt;
97 
98  if (tTurb > tTurbLoc)
99  {
100  tTurb = 0;
101 
102  const scalar sigma = sqrt(2*k/3.0);
103 
104  // Calculate a random direction dir distributed uniformly
105  // in spherical coordinates
106 
107  const scalar theta = rndGen.scalar01()*twoPi;
108  const scalar u = 2*rndGen.scalar01() - 1;
109 
110  const scalar a = sqrt(1 - sqr(u));
111  const vector dir(a*cos(theta), a*sin(theta), u);
112 
113  UTurb = sigma*mag(stdNormal.sample())*dir;
114 
116  }
117  }
118  else
119  {
120  tTurb = great;
121  UTurb = Zero;
122  }
123 
124  return Uc + UTurb;
125 }
126 
127 
128 // ************************************************************************* //
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 keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
Standard normal distribution. Not selectable.
virtual scalar sample() const
Sample the distribution.
const polyMesh & mesh() const
Return reference to polyMesh.
Definition: fvMesh.H:443
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:80
const Vector< label > & solutionD() const
Return the vector of solved-for directions in mesh.
Definition: polyMesh.C:1029
Random number generator.
scalar scalar01()
Return a scalar uniformly distributed between zero and one.
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
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].
void constrainDirection(const polyMesh &mesh, const Vector< label > &dirs, vector &d)
Set the constrained components of directions/velocity to zero.
Definition: meshTools.C:671
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
dimensionedScalar sin(const dimensionedScalar &ds)
void mag(LagrangianPatchField< scalar > &f, const LagrangianPatchField< Type > &f1)
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
void pow(LagrangianPatchField< typename powProduct< Type, r >::type > &f, const LagrangianPatchField< Type > &f1)
void sqr(LagrangianPatchField< typename outerProduct< Type, Type >::type > &f, const LagrangianPatchField< Type > &f1)
void sqrt(LagrangianPatchField< scalar > &f, const LagrangianPatchField< scalar > &f1)
dimensionedScalar cos(const dimensionedScalar &ds)
dictionary dict
randomGenerator rndGen(653213)