GradientDispersionRAS.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 "demandDrivenData.H"
30#include "fvcGrad.H"
31
32// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
33
34template<class CloudType>
36(
37 const dictionary& dict,
38 CloudType& owner
39)
40:
42 gradkPtr_(nullptr),
43 ownGradK_(false)
44{}
45
46
47template<class CloudType>
49(
51)
52:
54 gradkPtr_(dm.gradkPtr_),
55 ownGradK_(dm.ownGradK_)
56{
57 dm.ownGradK_ = false;
58}
59
60
61// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
62
63template<class CloudType>
65{
66 cacheFields(false);
67}
68
69
70// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
71
72template<class CloudType>
74{
76
77 if (store)
78 {
79 gradkPtr_ = fvc::grad(*this->kPtr_).ptr();
80 ownGradK_ = true;
81 }
82 else
83 {
84 if (ownGradK_)
85 {
86 deleteDemandDrivenData(gradkPtr_);
87 gradkPtr_ = nullptr;
88 ownGradK_ = false;
89 }
90 }
91}
92
93
94template<class CloudType>
96(
97 const scalar dt,
98 const label celli,
99 const vector& U,
100 const vector& Uc,
101 vector& UTurb,
102 scalar& tTurb
103)
104{
105 Random& rnd = this->owner().rndGen();
106
107 const scalar cps = 0.16432;
108
109 const scalar k = this->kPtr_->primitiveField()[celli];
110 const scalar epsilon =
111 this->epsilonPtr_->primitiveField()[celli] + ROOTVSMALL;
112 const vector& gradk = this->gradkPtr_->primitiveField()[celli];
113
114 const scalar UrelMag = mag(U - Uc - UTurb);
115
116 const scalar tTurbLoc =
117 min(k/epsilon, cps*pow(k, 1.5)/epsilon/(UrelMag + SMALL));
118
119
120 // Parcel is perturbed by the turbulence
121 if (dt < tTurbLoc)
122 {
123 tTurb += dt;
124
125 if (tTurb > tTurbLoc)
126 {
127 tTurb = 0.0;
128
129 const scalar sigma = sqrt(2.0*k/3.0);
130 const vector dir = -gradk/(mag(gradk) + SMALL);
131
132 scalar fac = 0.0;
133
134 // In 2D calculations the -grad(k) is always
135 // away from the axis of symmetry
136 // This creates a 'hole' in the spray and to
137 // prevent this we let fac be both negative/positive
138 if (this->owner().mesh().nSolutionD() == 2)
139 {
140 fac = rnd.GaussNormal<scalar>();
141 }
142 else
143 {
144 fac = mag(rnd.GaussNormal<scalar>());
145 }
146
147 UTurb = sigma*fac*dir;
148 }
149 }
150 else
151 {
152 tTurb = GREAT;
153 UTurb = Zero;
154 }
155
156 return Uc + UTurb;
157}
158
159
160// ************************************************************************* //
label k
Templated base class for dsmc cloud.
Definition: DSMCCloud.H:75
Base class for particle dispersion models based on RAS turbulence.
virtual void cacheFields(const bool store)
Cache carrier fields.
The velocity is perturbed in the direction of -grad(k), with a Gaussian random number distribution wi...
virtual ~GradientDispersionRAS()
Destructor.
virtual void cacheFields(const bool store)
Cache carrier fields.
bool ownGradK_
Take ownership of the grad(k)
Random number generator.
Definition: Random.H:60
Type GaussNormal()
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
Template functions to aid in the implementation of demand driven data.
scalar epsilon
Calculate the gradient of the given field.
tmp< GeometricField< typename outerProduct< vector, Type >::type, fvPatchField, volMesh > > grad(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
Definition: fvcGrad.C:54
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
void deleteDemandDrivenData(DataPtr &dataPtr)
Calculate the second temporal derivative.
dictionary dict