vanDriestDelta.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-2022 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 
26 #include "vanDriestDelta.H"
27 #include "wallFvPatch.H"
28 #include "fvPatchDistWave.H"
29 #include "FvWallInfoYPlus.H"
31 
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36 namespace LESModels
37 {
38  defineTypeNameAndDebug(vanDriestDelta, 0);
39  addToRunTimeSelectionTable(LESdelta, vanDriestDelta, dictionary);
40 }
41 }
42 
43 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
44 
45 void Foam::LESModels::vanDriestDelta::calcDelta()
46 {
47  const fvMesh& mesh = momentumTransportModel_.mesh();
48 
49  const volVectorField& U = momentumTransportModel_.U();
50  const tmp<volScalarField> tnu = momentumTransportModel_.nu();
51  const volScalarField& nu = tnu();
52  tmp<volScalarField> nuSgs = momentumTransportModel_.nut();
53 
54  volScalarField yStar
55  (
56  IOobject
57  (
58  "yStar",
59  mesh.time().constant(),
60  mesh
61  ),
62  mesh,
64  );
65 
66  const fvPatchList& patches = mesh.boundary();
67  volScalarField::Boundary& yStarBf = yStar.boundaryFieldRef();
68 
69  forAll(patches, patchi)
70  {
71  if (isA<wallFvPatch>(patches[patchi]))
72  {
73  const fvPatchVectorField& Uw = U.boundaryField()[patchi];
74  const scalarField& nuw = nu.boundaryField()[patchi];
75  const scalarField& nuSgsw = nuSgs().boundaryField()[patchi];
76 
77  yStarBf[patchi] =
78  nuw/sqrt((nuw + nuSgsw)*mag(Uw.snGrad()) + vSmall);
79  }
80  }
81 
83  (
85  );
86 
87  FvWallInfoYPlus<wallPoint>::trackData td;
88  td.yPlusCutOff = yPlusCutOff_;
89 
90  fvPatchDistWave::calculateAndCorrect<FvWallInfoYPlus>
91  (
92  mesh,
93  mesh.boundaryMesh().findPatchIDs<wallPolyPatch>(),
94  minWallFaceFraction_,
95  2, // <-- roughly equivalent to old point-cell corrections
96  y,
97  yStar,
98  td
99  );
100 
101  delta_ = min
102  (
103  static_cast<const volScalarField&>(geometricDelta_()),
104  (kappa_/Cdelta_)*((scalar(1) + small) - exp(-y/yStar/Aplus_))*y
105  );
106 }
107 
108 
109 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
110 
112 (
113  const word& name,
114  const momentumTransportModel& turbulence,
115  const dictionary& dict
116 )
117 :
118  LESdelta(name, turbulence),
119  geometricDelta_
120  (
122  (
123  IOobject::groupName("geometricDelta", turbulence.U().group()),
124  turbulence,
125  dict.optionalSubDict(type() + "Coeffs")
126  )
127  ),
128  kappa_(dict.lookupOrDefault<scalar>("kappa", 0.41)),
129  Aplus_
130  (
131  dict.optionalSubDict(type() + "Coeffs").lookupOrDefault<scalar>
132  (
133  "Aplus",
134  26.0
135  )
136  ),
137  Cdelta_
138  (
139  dict.optionalSubDict(type() + "Coeffs").lookupOrDefault<scalar>
140  (
141  "Cdelta",
142  0.158
143  )
144  ),
145  calcInterval_
146  (
147  dict.optionalSubDict(type() + "Coeffs").lookupOrDefault<label>
148  (
149  "calcInterval",
150  1
151  )
152  ),
153  yPlusCutOff_
154  (
155  dict.optionalSubDict(type() + "Coeffs").lookupOrDefault<scalar>
156  (
157  "yPlusCutOff",
158  500
159  )
160  ),
161  minWallFaceFraction_
162  (
163  dict.optionalSubDict(type() + "Coeffs").lookupOrDefault<scalar>
164  (
165  "minWallFaceFraction",
166  0.1
167  )
168  )
169 {
170  delta_ = geometricDelta_();
171 }
172 
173 
174 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
175 
177 {
178  const dictionary& coeffsDict(dict.optionalSubDict(type() + "Coeffs"));
179 
180  geometricDelta_().read(coeffsDict);
181  dict.readIfPresent<scalar>("kappa", kappa_);
182  coeffsDict.readIfPresent<scalar>("Aplus", Aplus_);
183  coeffsDict.readIfPresent<scalar>("Cdelta", Cdelta_);
184  coeffsDict.readIfPresent<label>("calcInterval", calcInterval_);
185 
186  calcDelta();
187 }
188 
189 
191 {
192  if (momentumTransportModel_.mesh().time().timeIndex() % calcInterval_ == 0)
193  {
194  geometricDelta_().correct();
195  calcDelta();
196  }
197 }
198 
199 
200 // ************************************************************************* //
static word group(const word &name)
Return group (extension part of name)
Definition: IOobject.C:134
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
fvPatchField< vector > fvPatchVectorField
static autoPtr< LESdelta > New(const word &name, const momentumTransportModel &turbulence, const dictionary &dict)
Return a reference to the selected LES delta.
Definition: LESdelta.C:66
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
Abstract base class for LES deltas.
Definition: LESdelta.H:50
static tmp< GeometricField< scalar, fvPatchField, volMesh > > New(const word &name, const Internal &, const PtrList< fvPatchField< scalar >> &)
Return a temporary field constructed from name,.
addToRunTimeSelectionTable(LESdelta, cubeRootVolDelta, dictionary)
dimensionedScalar sqrt(const dimensionedScalar &ds)
GeometricBoundaryField< scalar, fvPatchField, volMesh > Boundary
Type of the boundary field.
GeometricField< vector, fvPatchField, volMesh > volVectorField
Definition: volFieldsFwd.H:59
bool read(Istream &, const bool keepHeader=false)
Read dictionary from Istream, optionally keeping the header.
Definition: dictionaryIO.C:104
fvMesh & mesh
Macros for easy insertion into run-time selection tables.
const dimensionSet dimLength
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:58
scalar y
vanDriestDelta(const word &name, const momentumTransportModel &turbulence, const dictionary &)
Construct from name, momentumTransportModel and dictionary.
dimensionedScalar exp(const dimensionedScalar &ds)
const dictionary & optionalSubDict(const word &) const
Find and return a sub-dictionary if found.
Definition: dictionary.C:1060
A class for handling words, derived from string.
Definition: word.H:59
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
static word groupName(Name name, const word &group)
bool readIfPresent(const word &, T &, bool recursive=false, bool patternMatch=true) const
Find an entry if present, and assign to T.
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
defineTypeNameAndDebug(cubeRootVolDelta, 0)
Abstract base class for turbulence models (RAS, LES and laminar).
const volVectorField & U() const
Access function to velocity field.
PtrList< fvPatch > fvPatchList
container classes for fvPatch
Definition: fvPatchList.H:45
label patchi
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
Definition: POSIX.C:488
virtual void read(const dictionary &)
Read the LESdelta dictionary.
dimensioned< scalar > mag(const dimensioned< Type > &)
Namespace for OpenFOAM.