RASModel.H
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) 2013-2026 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 Class
25  Foam::RASModel
26 
27 Description
28  Templated abstract base class for RAS turbulence models
29 
30  with support for generalised Newtonian viscosity models including
31  strain-rate dependency.
32 
33 SourceFiles
34  RASModel.C
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef RASModel_H
39 #define RASModel_H
40 
41 #include "momentumTransportModel.H"
43 
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 
46 namespace Foam
47 {
48 
49 /*---------------------------------------------------------------------------*\
50  Class RASModel Declaration
51 \*---------------------------------------------------------------------------*/
52 
53 template<class BasicMomentumTransportModel>
54 class RASModel
55 :
56  public BasicMomentumTransportModel
57 {
58 
59 protected:
60 
61  // Protected data
62 
63  //- Turbulence on/off flag
65 
66  //- Lower limit of k
68 
69  //- Upper limit coefficient for nut
71 
72  //- Run-time selectable generalised Newtonian viscosity model
75 
76 
77  // Protected Member Functions
78 
79  //- Const access to the RAS dictionary
80  const dictionary& RASDict() const;
81 
82  //- Const access to the coefficients dictionary
83  const dictionary& typeDict() const;
84 
85  //- Const access to the coefficients dictionary
86  const dictionary& typeDict(const word&) const;
87 
88 
89 public:
90 
91  typedef typename BasicMomentumTransportModel::alphaField alphaField;
92  typedef typename BasicMomentumTransportModel::rhoField rhoField;
93 
94 
95  //- Runtime type information
96  TypeName("RAS");
97 
98 
99  // Declare run-time constructor selection table
100 
102  (
103  autoPtr,
104  RASModel,
105  dictionary,
106  (
107  const alphaField& alpha,
108  const rhoField& rho,
109  const volVectorField& U,
110  const surfaceScalarField& alphaRhoPhi,
111  const surfaceScalarField& phi,
112  const viscosity& viscosity
113  ),
114  (alpha, rho, U, alphaRhoPhi, phi, viscosity)
115  );
116 
117 
118  // Constructors
119 
120  //- Construct from components
121  RASModel
122  (
123  const word& type,
124  const alphaField& alpha,
125  const rhoField& rho,
126  const volVectorField& U,
127  const surfaceScalarField& alphaRhoPhi,
128  const surfaceScalarField& phi,
129  const viscosity& viscosity
130  );
131 
132  //- Disallow default bitwise copy construction
133  RASModel(const RASModel&) = delete;
134 
135 
136  // Selectors
137 
138  //- Return a reference to the selected RAS model
139  static autoPtr<RASModel> New
140  (
141  const alphaField& alpha,
142  const rhoField& rho,
143  const volVectorField& U,
144  const surfaceScalarField& alphaRhoPhi,
145  const surfaceScalarField& phi,
146  const viscosity& viscosity
147  );
148 
149 
150  //- Destructor
151  virtual ~RASModel()
152  {}
153 
154 
155  // Member Functions
156 
157  //- Read model coefficients if they have changed
158  virtual bool read();
159 
160  //- Return the laminar viscosity
161  virtual tmp<volScalarField> nu() const
162  {
163  return viscosityModel_->nu();
164  }
165 
166  //- Return the laminar viscosity on patchi
167  virtual tmp<scalarField> nu(const label patchi) const
168  {
169  return viscosityModel_->nu(patchi);
170  }
171 
172  //- Return the effective viscosity
173  virtual tmp<volScalarField> nuEff() const
174  {
175  return volScalarField::New
176  (
177  this->groupName("nuEff"),
178  this->nut() + this->nu()
179  );
180  }
181 
182  //- Return the effective viscosity on patch
183  virtual tmp<scalarField> nuEff(const label patchi) const
184  {
185  return this->nut(patchi) + this->nu(patchi);
186  }
187 
188  //- Predict the turbulence transport coefficients if possible
189  // without solving turbulence transport model equations
190  virtual void predict()
191  {}
192 
193  //- Solve the turbulence equations and correct the turbulence viscosity
194  virtual void correct();
195 
196 
197  // Member Operators
198 
199  //- Disallow default bitwise assignment
200  void operator=(const RASModel&) = delete;
201 };
202 
203 
204 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
205 
206 } // End namespace Foam
207 
208 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
209 
210 #ifdef NoRepository
211  #include "RASModel.C"
212 #endif
213 
214 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
215 
216 #endif
217 
218 // ************************************************************************* //
Generic GeometricField class.
static tmp< GeometricField< Type, GeoMesh, PrimitiveField > > New(const word &name, const Internal &, const PtrList< Patch > &, const HashPtrTable< Source > &=HashPtrTable< Source >())
Return a temporary field constructed from name,.
Templated abstract base class for RAS turbulence models.
Definition: RASModel.H:56
BasicMomentumTransportModel::alphaField alphaField
Definition: RASModel.H:90
static autoPtr< RASModel > New(const alphaField &alpha, const rhoField &rho, const volVectorField &U, const surfaceScalarField &alphaRhoPhi, const surfaceScalarField &phi, const viscosity &viscosity)
Return a reference to the selected RAS model.
Definition: RASModel.C:89
virtual ~RASModel()
Destructor.
Definition: RASModel.H:150
virtual tmp< volScalarField > nuEff() const
Return the effective viscosity.
Definition: RASModel.H:172
virtual void correct()
Solve the turbulence equations and correct the turbulence viscosity.
Definition: RASModel.C:187
dimensionedScalar nutMaxCoeff_
Upper limit coefficient for nut.
Definition: RASModel.H:69
autoPtr< laminarModels::generalisedNewtonianViscosityModel > viscosityModel_
Run-time selectable generalised Newtonian viscosity model.
Definition: RASModel.H:73
virtual tmp< volScalarField > nu() const
Return the laminar viscosity.
Definition: RASModel.H:160
virtual void predict()
Predict the turbulence transport coefficients if possible.
Definition: RASModel.H:189
const dictionary & typeDict() const
Const access to the coefficients dictionary.
Definition: RASModel.C:154
RASModel(const word &type, const alphaField &alpha, const rhoField &rho, const volVectorField &U, const surfaceScalarField &alphaRhoPhi, const surfaceScalarField &phi, const viscosity &viscosity)
Construct from components.
Definition: RASModel.C:33
void operator=(const RASModel &)=delete
Disallow default bitwise assignment.
Switch turbulence_
Turbulence on/off flag.
Definition: RASModel.H:63
dimensionedScalar kMin_
Lower limit of k.
Definition: RASModel.H:66
declareRunTimeSelectionTable(autoPtr, RASModel, dictionary,(const alphaField &alpha, const rhoField &rho, const volVectorField &U, const surfaceScalarField &alphaRhoPhi, const surfaceScalarField &phi, const viscosity &viscosity),(alpha, rho, U, alphaRhoPhi, phi, viscosity))
TypeName("RAS")
Runtime type information.
const dictionary & RASDict() const
Const access to the RAS dictionary.
Definition: RASModel.C:146
virtual bool read()
Read model coefficients if they have changed.
Definition: RASModel.C:169
BasicMomentumTransportModel::rhoField rhoField
Definition: RASModel.H:91
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Definition: Switch.H:61
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
A class for managing temporary objects.
Definition: tmp.H:55
Abstract base class for all fluid physical properties.
Definition: viscosity.H:50
A class for handling words, derived from string.
Definition: word.H:63
const scalar nut
label patchi
U
Definition: pEqn.H:72
rho
Definition: pEqn.H:1
volScalarField alpha(IOobject("alpha", runTime.name(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE), lambda *max(Ua &U, zeroSensitivity))
Namespace for OpenFOAM.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
Definition: POSIX.C:488