DeardorffDiffStress.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-2017 OpenFOAM Foundation
9  Copyright (C) 2019-2021 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "DeardorffDiffStress.H"
30 #include "fvOptions.H"
31 #include "calculatedFvPatchField.H"
32 
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
37 namespace LESModels
38 {
39 
40 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
41 
42 template<class BasicTurbulenceModel>
44 {
45  this->nut_ = Ck_*sqrt(this->k())*this->delta();
46  this->nut_.correctBoundaryConditions();
47  fv::options::New(this->mesh_).correct(this->nut_);
48 
49  BasicTurbulenceModel::correctNut();
50 }
51 
52 
53 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
54 
55 template<class BasicTurbulenceModel>
57 (
58  const alphaField& alpha,
59  const rhoField& rho,
60  const volVectorField& U,
61  const surfaceScalarField& alphaRhoPhi,
62  const surfaceScalarField& phi,
63  const transportModel& transport,
64  const word& propertiesName,
65  const word& type
66 )
67 :
68  ReynoldsStress<LESModel<BasicTurbulenceModel>>
69  (
70  type,
71  alpha,
72  rho,
73  U,
74  alphaRhoPhi,
75  phi,
76  transport,
77  propertiesName
78  ),
79 
80  Ck_
81  (
82  dimensioned<scalar>::getOrAddToDict
83  (
84  "Ck",
85  this->coeffDict_,
86  0.094
87  )
88  ),
89  Cm_
90  (
91  dimensioned<scalar>::getOrAddToDict
92  (
93  "Cm",
94  this->coeffDict_,
95  4.13
96  )
97  ),
98  Ce_
99  (
100  dimensioned<scalar>::getOrAddToDict
101  (
102  "Ce",
103  this->coeffDict_,
104  1.05
105  )
106  ),
107  Cs_
108  (
109  dimensioned<scalar>::getOrAddToDict
110  (
111  "Cs",
112  this->coeffDict_,
113  0.25
114  )
115  )
116 {
117  if (type == typeName)
118  {
119  this->printCoeffs(type);
120  this->boundNormalStress(this->R_);
121  }
122 }
123 
124 
125 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
126 
127 template<class BasicTurbulenceModel>
129 {
131  {
132  Ck_.readIfPresent(this->coeffDict());
133  Cm_.readIfPresent(this->coeffDict());
134  Ce_.readIfPresent(this->coeffDict());
135  Cs_.readIfPresent(this->coeffDict());
136 
137  return true;
138  }
139 
140  return false;
141 }
142 
143 
144 template<class BasicTurbulenceModel>
146 {
147  if (!this->turbulence_)
148  {
149  return;
150  }
151 
152  // Local references
153  const alphaField& alpha = this->alpha_;
154  const rhoField& rho = this->rho_;
155  const surfaceScalarField& alphaRhoPhi = this->alphaRhoPhi_;
156  const volVectorField& U = this->U_;
157  volSymmTensorField& R = this->R_;
158  fv::options& fvOptions(fv::options::New(this->mesh_));
159 
160  ReynoldsStress<LESModel<BasicTurbulenceModel>>::correct();
161 
162  tmp<volTensorField> tgradU(fvc::grad(U));
163  const volTensorField& gradU = tgradU();
164 
165  volSymmTensorField D(symm(gradU));
166 
167  volSymmTensorField P(-twoSymm(R & gradU));
168 
169  volScalarField k(this->k());
170 
171  tmp<fvSymmTensorMatrix> REqn
172  (
173  fvm::ddt(alpha, rho, R)
174  + fvm::div(alphaRhoPhi, R)
175  - fvm::laplacian(I*this->nu() + Cs_*(k/this->epsilon())*R, R)
176  + fvm::Sp(Cm_*alpha*rho*sqrt(k)/this->delta(), R)
177  ==
178  alpha*rho*P
179  + (4.0/5.0)*alpha*rho*k*D
180  - ((2.0/3.0)*(1.0 - Cm_/this->Ce_)*I)*(alpha*rho*this->epsilon())
181  + fvOptions(alpha, rho, R)
182  );
183 
184  REqn.ref().relax();
185  fvOptions.constrain(REqn.ref());
186  REqn.ref().solve();
187  fvOptions.correct(R);
188  this->boundNormalStress(R);
189 
190  correctNut();
191 }
192 
193 
194 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
195 
196 } // End namespace LESModels
197 } // End namespace Foam
198 
199 // ************************************************************************* //
scalar delta
void correct(GeometricField< Type, PatchField, GeoMesh > &field)
Apply correction to field.
GeometricField< symmTensor, fvPatchField, volMesh > volSymmTensorField
Definition: volFieldsFwd.H:85
tmp< GeometricField< typename outerProduct< vector, Type >::type, fvPatchField, volMesh >> grad(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
Definition: fvcGrad.C:47
Templated abstract base class for LES SGS models.
Definition: LESModel.H:56
Differential SGS Stress Equation Model for incompressible and compressible flows. ...
GeometricField< tensor, fvPatchField, volMesh > volTensorField
Definition: volFieldsFwd.H:86
dimensionedScalar sqrt(const dimensionedScalar &ds)
virtual void printCoeffs(const word &type)
Print model coefficients.
Definition: LESModel.C:27
label k
Boltzmann constant.
Generic dimensioned Type class.
GeometricField< vector, fvPatchField, volMesh > volVectorField
Definition: volFieldsFwd.H:82
dimensionedSymmTensor twoSymm(const dimensionedSymmTensor &dt)
fv::options & fvOptions
bool read(const char *buf, int32_t &val)
Same as readInt32.
Definition: int32.H:127
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:81
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: POSIX.C:799
virtual void correct()
Correct sub-grid stress, eddy-Viscosity and related properties.
static const Identity< scalar > I
Definition: Identity.H:100
A class for handling words, derived from Foam::string.
Definition: word.H:63
tmp< fvMatrix< Type > > ddt(const GeometricField< Type, fvPatchField, volMesh > &vf)
Definition: fvmDdt.C:41
zeroField Sp(const Foam::zero, const GeometricField< Type, fvPatchField, volMesh > &)
A no-op source.
void boundNormalStress(volSymmTensorField &R) const
tmp< fvMatrix< Type > > div(const surfaceScalarField &flux, const GeometricField< Type, fvPatchField, volMesh > &vf, const word &name)
Definition: fvmDiv.C:41
Info<< "Predicted p max-min : "<< max(p).value()<< " "<< min(p).value()<< endl;rho==max(psi *p+alphal *rhol0+((alphav *psiv+alphal *psil) - psi) *pSat, rhoMin);# 1 "/home/chef2/andy/OpenFOAM/release/v2312/OpenFOAM-v2312/applications/solvers/multiphase/cavitatingFoam/alphavPsi.H" 1{ alphav=clamp((rho - rholSat)/(rhovSat - rholSat), zero_one{});alphal=1.0 - alphav;Info<< "max-min alphav: "<< max(alphav).value()<< " "<< min(alphav).value()<< endl;psiModel-> correct()
Definition: pEqn.H:63
U
Definition: pEqn.H:72
#define R(A, B, C, D, E, F, K, M)
dimensionedSymmTensor symm(const dimensionedSymmTensor &dt)
tmp< fvMatrix< Type > > laplacian(const GeometricField< Type, fvPatchField, volMesh > &vf, const word &name)
Definition: fvmLaplacian.C:41
virtual void correctNut()
Update the eddy-viscosity.
Base-class for all transport models used by the incompressible turbulence models. ...
scalar epsilon
virtual bool read()
Read model coefficients if they have changed.
const dimensionedScalar & D
GeometricField< scalar, fvsPatchField, surfaceMesh > surfaceScalarField
static options & New(const fvMesh &mesh)
Construct fvOptions and register to database if not present.
Definition: fvOptions.C:96
const dimensionedScalar alpha
Fine-structure constant: default SI units: [].
volScalarField & nu
Namespace for OpenFOAM.
Reynolds-stress turbulence model base class.