eddyViscosity.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) 2013-2017 OpenFOAM Foundation
9  Copyright (C) 2023 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 "eddyViscosity.H"
30 #include "fvc.H"
31 #include "fvm.H"
32 
33 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
34 
35 template<class BasicTurbulenceModel>
37 (
38  const word& type,
39  const alphaField& alpha,
40  const rhoField& rho,
41  const volVectorField& U,
42  const surfaceScalarField& alphaRhoPhi,
43  const surfaceScalarField& phi,
44  const transportModel& transport,
45  const word& propertiesName
46 )
47 :
48  linearViscousStress<BasicTurbulenceModel>
49  (
50  type,
51  alpha,
52  rho,
53  U,
54  alphaRhoPhi,
55  phi,
56  transport,
57  propertiesName
58  ),
59 
60  nut_
61  (
62  IOobject
63  (
64  IOobject::groupName("nut", alphaRhoPhi.group()),
65  this->runTime_.timeName(),
66  this->mesh_,
67  IOobject::MUST_READ,
68  IOobject::AUTO_WRITE
69  ),
70  this->mesh_
71  )
72 {}
73 
74 
75 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
76 
77 template<class BasicTurbulenceModel>
79 {
81 }
82 
83 
84 template<class BasicTurbulenceModel>
87 {
88  tmp<volScalarField> tk(k());
89 
90  // Get list of patchField type names from k
91  wordList patchFieldTypes(tk().boundaryField().types());
92 
93  // For k patchField types which do not have an equivalent for symmTensor
94  // set to calculated
95  forAll(patchFieldTypes, i)
96  {
97  if
98  (
100  ->found(patchFieldTypes[i])
101  )
102  {
103  patchFieldTypes[i] = fvPatchFieldBase::calculatedType();
104  }
105  }
106 
107  return tmp<volSymmTensorField>
108  (
110  (
111  IOobject
112  (
113  IOobject::groupName("R", this->alphaRhoPhi_.group()),
114  this->runTime_.timeName(),
115  this->mesh_,
116  IOobject::NO_READ,
117  IOobject::NO_WRITE,
118  IOobject::NO_REGISTER
119  ),
120  ((2.0/3.0)*I)*tk() - (nut_)*devTwoSymm(fvc::grad(this->U_)),
121  patchFieldTypes
122  )
123  );
124 }
125 
126 
127 template<class BasicTurbulenceModel>
129 {
130  correctNut();
131 }
132 
133 
134 template<class BasicTurbulenceModel>
136 {
138 }
139 
140 
141 // ************************************************************************* //
GeometricField< symmTensor, fvPatchField, volMesh > volSymmTensorField
Definition: volFieldsFwd.H:85
type
Types of root.
Definition: Roots.H:52
BasicTurbulenceModel::rhoField rhoField
Definition: RASModel.H:143
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Linear viscous stress turbulence model base class.
label k
Boltzmann constant.
virtual tmp< volSymmTensorField > R() const
Return the Reynolds stress tensor.
Definition: eddyViscosity.C:79
BasicTurbulenceModel::transportModel transportModel
Definition: RASModel.H:144
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:421
constexpr const char *const group
Group name for atomic constants.
const word calculatedType
A calculated patch field type.
virtual bool read()=0
Re-read model coefficients if they have changed.
Definition: eddyViscosity.C:71
virtual void correct()=0
Solve the turbulence equations and correct the turbulence viscosity.
word timeName
Definition: getTimeIndex.H:3
static const Identity< scalar > I
Definition: Identity.H:100
A class for handling words, derived from Foam::string.
Definition: word.H:63
void read(Istream &, label &val, const dictionary &)
In-place read with dictionary lookup.
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
virtual void validate()
Validate the turbulence fields after construction.
A class for managing temporary objects.
Definition: HashPtrTable.H:50
const dimensionedScalar alpha
Fine-structure constant: default SI units: [].
Defines the attributes of an object for which implicit objectRegistry management is supported...
Definition: IOobject.H:172
bool found
eddyViscosity(const word &modelName, const alphaField &alpha, const rhoField &rho, const volVectorField &U, const surfaceScalarField &alphaRhoPhi, const surfaceScalarField &phi, const transportModel &transport, const word &propertiesName)
Construct from components.
Definition: eddyViscosity.C:30
tmp< GeometricField< typename outerProduct< vector, Type >::type, faPatchField, areaMesh >> grad(const GeometricField< Type, faePatchField, edgeMesh > &ssf)
Definition: facGrad.C:51
BasicTurbulenceModel::alphaField alphaField
Definition: RASModel.H:142
SymmTensor< Cmpt > devTwoSymm(const SymmTensor< Cmpt > &st)
Return the deviatoric part of twice the symmetric part of a SymmTensor.
Definition: SymmTensorI.H:491