DEShybrid.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
6  \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
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 the
13  Free Software Foundation; either version 2 of the License, or (at your
14  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, write to the Free Software Foundation,
23  Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 
25 Class
26  Foam::DEShybrid
27 
28 Description
29  Hybrid convection scheme of Travin et al. for hybrid RAS/LES calculations.
30  The scheme blends between a low-dissipative convection scheme within the
31  LES region (e.g. linear) and a numerically more robust convection scheme in
32  the RAS region (e.g. upwind-biased schemes).
33 
34  The routine calculates the blending factor denoted as "sigma" in the
35  literature reference, where 0 <= sigma <= sigmaMax, which is then employed
36  to set the weights:
37  \f[
38  weight = (1-sigma) w_1 + sigma w_2
39  \f]
40 
41  where
42  \vartable
43  sigma | blending factor
44  w_1 | scheme 1 weights
45  w_2 | scheme 2 weights
46  \endvartable
47 
48  First published in:
49  \verbatim
50  A. Travin, M. Shur, M. Strelets, P. Spalart (2000).
51  Physical and numerical upgrades in the detached-eddy simulation of
52  complex turbulent flows.
53  In Proceedings of the 412th Euromech Colloquium on LES and Complex
54  Transition and Turbulent Flows, Munich, Germany
55  \endverbatim
56 
57  Original publication contained a typo for C_H3 constant. Corrected version
58  with minor changes for 2 lower limiters published in:
59  \verbatim
60  P. Spalart, M. Shur, M. Strelets, A. Travin (2012).
61  Sensitivity of Landing-Gear Noise Predictions by Large-Eddy
62  Simulation to Numerics and Resolution.
63  AIAA Paper 2012-1174, 50th AIAA Aerospace Sciences Meeting,
64  Nashville / TN, Jan. 2012
65  \endverbatim
66 
67  Example of the DEShybrid scheme specification using linear within the LES
68  region and linearUpwind within the RAS region:
69  \verbatim
70  divSchemes
71  {
72  .
73  .
74  div(phi,U) Gauss DEShybrid
75  linear // scheme 1
76  linearUpwind grad(U) // scheme 2
77  0.65 // DES coefficient, typically = 0.65
78  30 // Reference velocity scale
79  2 // Reference length scale
80  0 // Minimum sigma limit (0-1)
81  1; // Maximum sigma limit (0-1)
82  .
83  .
84  }
85  \endverbatim
86 
87 Notes
88  - Scheme 1 should be linear (or other low-dissipative schemes) which will
89  be used in the detached/vortex shedding regions.
90  - Scheme 2 should be an upwind/deferred correction/TVD scheme which will
91  be used in the free-stream/Euler/boundary layer regions.
92  - the scheme is compiled into a separate library, and not available to
93  solvers by default. In order to use the scheme, add the library as a
94  run-time loaded library in the \$FOAM\_CASE/system/controlDict
95  dictionary, e.g.:
96 
97  libs ("libturbulenceModelSchemes.so");
98 
99 SourceFiles
100  DEShybrid.C
101 
102 \*---------------------------------------------------------------------------*/
103 
104 #ifndef DEShybrid_H
105 #define DEShybrid_H
106 
108 #include "surfaceInterpolate.H"
109 #include "fvcGrad.H"
110 #include "blendedSchemeBase.H"
111 #include "turbulentTransportModel.H"
113 
114 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
115 
116 namespace Foam
117 {
118 
119 /*---------------------------------------------------------------------------*\
120  class DEShybrid Declaration
121 \*---------------------------------------------------------------------------*/
122 
123 template<class Type>
124 class DEShybrid
125 :
126  public surfaceInterpolationScheme<Type>,
127  public blendedSchemeBase<Type>
128 {
129  // Private Data
130 
131  //- Scheme 1
133 
134  //- Scheme 2
136 
137  //- DES Coefficient
138  scalar CDES_;
139 
140  //- Reference velocity scale [m/s]
142 
143  //- Reference length scale [m]
145 
146  //- Minimum bound for sigma (0 <= sigmaMin <= 1)
147  scalar sigmaMin_;
148 
149  //- Maximum bound for sigma (0 <= sigmaMax <= 1)
150  scalar sigmaMax_;
151 
152  //- Scheme constants
153  scalar CH1_;
154  scalar CH2_;
155  scalar CH3_;
156 
157  //- Disallow default bitwise copy construct
158  DEShybrid(const DEShybrid&);
159 
160  //- Disallow default bitwise assignment
161  void operator=(const DEShybrid&);
162 
163 
164  // Private Member Functions
165 
166  //- Calculate the blending factor
168  (
170  const volScalarField& nuEff,
171  const volVectorField& U,
172  const volScalarField& delta
173  ) const
174  {
176  const volScalarField S(sqrt(2.0)*mag(symm(gradU())));
177  const volScalarField Omega(sqrt(2.0)*mag(skew(gradU())));
178  const dimensionedScalar tau0_ = L0_/U0_;
179 
180  const volScalarField B
181  (
182  CH3_*Omega*max(S, Omega)
183  /max(0.5*(sqr(S) + sqr(Omega)), sqr(1.0e-3/tau0_))
184  );
186  (
187  max(Foam::sqrt(0.5*(sqr(S) + sqr(Omega))), 0.1/tau0_)
188  );
189 
190  const volScalarField lTurb(Foam::sqrt(nuEff/(pow(0.09, 1.5)*K)));
191  const volScalarField g(tanh(pow4(B)));
192  const volScalarField A
193  (
194  CH2_*max(scalar(0), CDES_*delta/max(lTurb*g, 1.0e-15*L0_) - 0.5)
195  );
196 
197  const volScalarField factor
198  (
199  IOobject
200  (
201  typeName + ":Factor",
202  this->mesh().time().timeName(),
203  this->mesh(),
206  ),
207  max(sigmaMax_*tanh(pow(A, CH1_)), sigmaMin_)
208  );
209 
210  if (blendedSchemeBaseName::debug)
211  {
212  factor.write();
213  }
214 
216  (
218  (
219  vf.name() + "BlendingFactor",
220  fvc::interpolate(factor)
221  )
222  );
223  }
224 
225 
226 public:
227 
228  //- Runtime type information
229  TypeName("DEShybrid");
230 
231 
232  // Constructors
233 
234  //- Construct from mesh and Istream.
235  // The name of the flux field is read from the Istream and looked-up
236  // from the mesh objectRegistry
237  DEShybrid(const fvMesh& mesh, Istream& is)
238  :
240  tScheme1_
241  (
243  ),
244  tScheme2_
245  (
247  ),
248  CDES_(readScalar(is)),
249  U0_("U0", dimLength/dimTime, readScalar(is)),
250  L0_("L0", dimLength, readScalar(is)),
251  sigmaMin_(readScalar(is)),
252  sigmaMax_(readScalar(is)),
253  CH1_(3.0),
254  CH2_(1.0),
255  CH3_(2.0)
256  {
257  if (U0_.value() <= 0)
258  {
260  << "U0 coefficient must be greater than 0. "
261  << "Current value: " << U0_ << exit(FatalError);
262  }
263  if (L0_.value() <= 0)
264  {
266  << "L0 coefficient must be greater than 0. "
267  << "Current value: " << L0_ << exit(FatalError);
268  }
269  if (sigmaMin_ < 0)
270  {
272  << "sigmaMin coefficient must be greater than or equal to 0. "
273  << "Current value: " << sigmaMin_ << exit(FatalError);
274  }
275  if (sigmaMax_ < 0)
276  {
278  << "sigmaMax coefficient must be greater than or equal to 0. "
279  << "Current value: " << sigmaMax_ << exit(FatalError);
280  }
281  if (sigmaMin_ > 1)
282  {
284  << "sigmaMin coefficient must be less than or equal to 1. "
285  << "Current value: " << sigmaMin_ << exit(FatalError);
286  }
287  if (sigmaMax_ > 1)
288  {
290  << "sigmaMax coefficient must be less than or equal to 1. "
291  << "Current value: " << sigmaMax_ << exit(FatalError);
292  }
293  }
294 
295  //- Construct from mesh, faceFlux and Istream
296  DEShybrid
297  (
298  const fvMesh& mesh,
299  const surfaceScalarField& faceFlux,
300  Istream& is
301  )
302  :
304  tScheme1_
305  (
306  surfaceInterpolationScheme<Type>::New(mesh, faceFlux, is)
307  ),
308  tScheme2_
309  (
310  surfaceInterpolationScheme<Type>::New(mesh, faceFlux, is)
311  ),
313  U0_("U0", dimLength/dimTime, readScalar(is)),
314  L0_("L0", dimLength, readScalar(is)),
315  sigmaMin_(readScalar(is)),
316  sigmaMax_(readScalar(is)),
317  CH1_(3.0),
318  CH2_(1.0),
319  CH3_(2.0)
320  {
321  if (U0_.value() <= 0)
322  {
324  << "U0 coefficient must be greater than 0. "
325  << "Current value: " << U0_ << exit(FatalError);
326  }
327  if (L0_.value() <= 0)
328  {
330  << "L0 coefficient must be greater than 0. "
331  << "Current value: " << U0_ << exit(FatalError);
332  }
333  if (sigmaMin_ < 0)
334  {
336  << "sigmaMin coefficient must be greater than or equal to 0. "
337  << "Current value: " << sigmaMin_ << exit(FatalError);
338  }
339  if (sigmaMax_ < 0)
340  {
342  << "sigmaMax coefficient must be greater than or equal to 0. "
343  << "Current value: " << sigmaMax_ << exit(FatalError);
344  }
345  if (sigmaMin_ > 1)
346  {
348  << "sigmaMin coefficient must be less than or equal to 1. "
349  << "Current value: " << sigmaMin_ << exit(FatalError);
350  }
351  if (sigmaMax_ > 1)
352  {
354  << "sigmaMax coefficient must be less than or equal to 1. "
355  << "Current value: " << sigmaMax_ << exit(FatalError);
356  }
357  }
358 
359 
360  // Member Functions
361 
362  //- Return the face-based blending factor
364  (
366  ) const
367  {
368  const fvMesh& mesh = this->mesh();
369 
370  typedef compressible::turbulenceModel cmpModel;
371  typedef incompressible::turbulenceModel icoModel;
372 
373  // Assuming that LES delta field is called "delta"
374  const volScalarField& delta = this->mesh().template
375  lookupObject<const volScalarField>("delta");
376 
377  // Could avoid the compressible/incompressible case by looking
378  // up all fields from the database - but retrieving from model
379  // ensures consistent fields are being employed e.g. for multiphase
380  // where group name is used
381 
382  if (mesh.foundObject<icoModel>(icoModel::propertiesName))
383  {
384  const icoModel& model =
385  mesh.lookupObject<icoModel>(icoModel::propertiesName);
386 
387  return calcBlendingFactor(vf, model.nuEff(), model.U(), delta);
388  }
389  else if (mesh.foundObject<cmpModel>(cmpModel::propertiesName))
390  {
391  const cmpModel& model =
392  mesh.lookupObject<cmpModel>(cmpModel::propertiesName);
393 
394  return calcBlendingFactor
395  (
396  vf, model.muEff()/model.rho(), model.U(), delta
397  );
398  }
399  else
400  {
402  << "Scheme requires a turbulence model to be present. "
403  << "Unable to retrieve turbulence model from the mesh "
404  << "database" << exit(FatalError);
405 
406  return tmp<surfaceScalarField>(NULL);
407  }
408  }
409 
410 
411  //- Return the interpolation weighting factors
412  tmp<surfaceScalarField> weights
413  (
414  const GeometricField<Type, fvPatchField, volMesh>& vf
415  ) const
416  {
418 
419  return
420  (scalar(1) - bf)*tScheme1_().weights(vf)
421  + bf*tScheme2_().weights(vf);
422  }
423 
424 
425  //- Return the face-interpolate of the given cell field
426  // with explicit correction
427  tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >
429  (
430  const GeometricField<Type, fvPatchField, volMesh>& vf
431  ) const
432  {
434 
435  return
436  (scalar(1) - bf)*tScheme1_().interpolate(vf)
437  + bf*tScheme2_().interpolate(vf);
438  }
439 
440 
441  //- Return true if this scheme uses an explicit correction
442  virtual bool corrected() const
443  {
444  return tScheme1_().corrected() || tScheme2_().corrected();
445  }
446 
447 
448  //- Return the explicit correction to the face-interpolate
449  // for the given field
450  virtual tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >
451  correction
452  (
453  const GeometricField<Type, fvPatchField, volMesh>& vf
454  ) const
455  {
457 
458  if (tScheme1_().corrected())
459  {
460  if (tScheme2_().corrected())
461  {
462  return
463  (
464  (scalar(1) - bf)
465  * tScheme1_().correction(vf)
466  + bf
467  * tScheme2_().correction(vf)
468  );
469  }
470  else
471  {
472  return
473  (
474  (scalar(1) - bf)
475  * tScheme1_().correction(vf)
476  );
477  }
478  }
479  else if (tScheme2_().corrected())
480  {
481  return (bf*tScheme2_().correction(vf));
482  }
483  else
484  {
485  return tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >
486  (
487  NULL
488  );
489  }
490  }
491 };
492 
493 
494 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
495 
496 } // End namespace Foam
497 
498 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
499 
500 #endif
501 
502 // ************************************************************************* //
Foam::DEShybrid::tScheme1_
tmp< surfaceInterpolationScheme< Type > > tScheme1_
Scheme 1.
Definition: DEShybrid.H:80
Foam::IOobject
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
Foam::DEShybrid::DEShybrid
DEShybrid(const DEShybrid &)
Disallow default bitwise copy construct.
Foam::symm
dimensionedSymmTensor symm(const dimensionedSymmTensor &dt)
Definition: dimensionedSymmTensor.C:82
Foam::fvc::grad
tmp< GeometricField< typename outerProduct< vector, Type >::type, fvPatchField, volMesh >> grad(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
Definition: fvcGrad.C:52
blendedSchemeBase.H
Foam::skew
dimensionedTensor skew(const dimensionedTensor &dt)
Definition: dimensionedTensor.C:135
Foam::dimLength
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:50
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:118
Foam::DEShybrid::CH3_
scalar CH3_
Definition: DEShybrid.H:103
Foam::DEShybrid::CDES_
scalar CDES_
DES Coefficient.
Definition: DEShybrid.H:86
Foam::fvc::interpolate
tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > interpolate(const GeometricField< Type, fvPatchField, volMesh > &vf, const surfaceScalarField &faceFlux, Istream &schemeData)
Interpolate field onto faces using scheme given by Istream.
Definition: surfaceInterpolate.C:110
turbulentTransportModel.H
Foam::DEShybrid::sigmaMin_
scalar sigmaMin_
Minimum bound for sigma (0 <= sigmaMin <= 1)
Definition: DEShybrid.H:95
g
const dimensionedVector & g
Definition: setRegionFluidFields.H:33
Foam::DEShybrid::L0_
dimensionedScalar L0_
Reference length scale [m].
Definition: DEShybrid.H:92
Foam::dimensioned::value
const Type & value() const
Return const reference to value.
Definition: dimensionedType.C:261
Foam::mag
dimensioned< scalar > mag(const dimensioned< Type > &)
A
simpleMatrix< scalar > A(Nc)
Foam::IOobject::NO_WRITE
@ NO_WRITE
Definition: IOobject.H:118
U
U
Definition: pEqn.H:46
K
CGAL::Exact_predicates_exact_constructions_kernel K
Definition: CGALTriangulation3DKernel.H:56
Foam::DEShybrid::U0_
dimensionedScalar U0_
Reference velocity scale [m/s].
Definition: DEShybrid.H:89
Foam::dimTime
const dimensionSet dimTime(0, 0, 1, 0, 0, 0, 0)
Definition: dimensionSets.H:51
Foam::pow4
dimensionedScalar pow4(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:98
Foam::tanh
dimensionedScalar tanh(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:263
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:57
Foam::IOobject::NO_READ
@ NO_READ
Definition: IOobject.H:111
delta
scalar delta
Definition: LISASMDCalcMethod2.H:8
Foam::pow
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
Definition: dimensionedScalar.C:73
Foam::FatalError
error FatalError
Foam::DEShybrid::blendingFactor
virtual tmp< surfaceScalarField > blendingFactor(const GeometricField< Type, fvPatchField, volMesh > &vf) const
Return the face-based blending factor.
Definition: DEShybrid.H:312
Foam::dimensioned
Generic dimensioned Type class.
Definition: dimensionedScalarFwd.H:41
surfaceInterpolate.H
Surface Interpolation.
Foam::DEShybrid::correction
virtual tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > correction(const GeometricField< Type, fvPatchField, volMesh > &vf) const
Return the explicit correction to the face-interpolate.
Definition: DEShybrid.H:400
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
Foam::DEShybrid::corrected
virtual bool corrected() const
Return true if this scheme uses an explicit correction.
Definition: DEShybrid.H:390
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::e
const double e
Elementary charge.
Definition: doubleFloat.H:94
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
Foam::max
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
Foam::objectRegistry::foundObject
bool foundObject(const word &name) const
Is the named Type found?
Definition: objectRegistryTemplates.C:142
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:318
Foam::DEShybrid::CH1_
scalar CH1_
Scheme constants.
Definition: DEShybrid.H:101
Foam::surfaceInterpolationScheme::surfaceInterpolationScheme
surfaceInterpolationScheme(const surfaceInterpolationScheme &)
Disallow copy construct.
Foam::sqr
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Definition: dimensionedSymmTensor.C:49
Foam::readScalar
bool readScalar(const char *buf, doubleScalar &s)
Read whole of buf as a scalar. Return true if succesful.
Definition: doubleScalar.H:63
Foam::DEShybrid::sigmaMax_
scalar sigmaMax_
Maximum bound for sigma (0 <= sigmaMax <= 1)
Definition: DEShybrid.H:98
Foam::surfaceScalarField
GeometricField< scalar, fvsPatchField, surfaceMesh > surfaceScalarField
Definition: surfaceFieldsFwd.H:52
Foam::DEShybrid::interpolate
tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > interpolate(const GeometricField< Type, fvPatchField, volMesh > &vf) const
Return the face-interpolate of the given cell field.
Definition: DEShybrid.H:377
Foam::ThermalDiffusivity
Templated wrapper class to provide compressible turbulence models thermal diffusivity based thermal t...
Definition: ThermalDiffusivity.H:48
Foam::sqrt
dimensionedScalar sqrt(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:142
fvcGrad.H
Calculate the gradient of the given field.
Foam::surfaceInterpolationScheme::New
static tmp< surfaceInterpolationScheme< Type > > New(const fvMesh &mesh, Istream &schemeData)
Return new tmp interpolation scheme.
Definition: surfaceInterpolationScheme.C:44
Foam::DEShybrid::CH2_
scalar CH2_
Definition: DEShybrid.H:102
timeName
word timeName
Definition: getTimeIndex.H:3
Foam::surfaceInterpolationScheme
Abstract base class for surface interpolation schemes.
Definition: surfaceInterpolationScheme.H:55
Foam::DEShybrid::weights
tmp< surfaceScalarField > weights(const GeometricField< Type, fvPatchField, volMesh > &vf) const
Return the interpolation weighting factors.
Definition: DEShybrid.H:361
Foam::DEShybrid
Definition: DEShybrid.H:72
Foam::IncompressibleTurbulenceModel
Templated abstract base class for single-phase incompressible turbulence models.
Definition: IncompressibleTurbulenceModel.H:52
Foam::surfaceInterpolationScheme::mesh
const fvMesh & mesh() const
Return mesh reference.
Definition: surfaceInterpolationScheme.H:142
Foam::objectRegistry::lookupObject
const Type & lookupObject(const word &name) const
Lookup and return the object of the given Type.
Definition: objectRegistryTemplates.C:165
Foam::DEShybrid::operator=
void operator=(const DEShybrid &)
Disallow default bitwise assignment.
Foam::GeometricField
Generic GeometricField class.
Definition: surfaceFieldsFwd.H:52
Foam::blendedSchemeBase
Base class for blended schemes to provide access to the blending factor surface field.
Definition: blendedSchemeBase.H:52
Foam::DEShybrid::tScheme2_
tmp< surfaceInterpolationScheme< Type > > tScheme2_
Scheme 2.
Definition: DEShybrid.H:83
turbulentFluidThermoModel.H
surfaceInterpolationScheme.H
Foam::DEShybrid::calcBlendingFactor
tmp< surfaceScalarField > calcBlendingFactor(const GeometricField< Type, fvPatchField, volMesh > &vf, const volScalarField &nuEff, const volVectorField &U, const volScalarField &delta) const
Calculate the blending factor.
Definition: DEShybrid.H:116
Foam::DEShybrid::TypeName
TypeName("DEShybrid")
Runtime type information.