RASModel.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) 2019-2020 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 "RASModel.H"
30 
31 // * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
32 
33 template<class BasicTurbulenceModel>
35 {
36  if (printCoeffs_)
37  {
38  Info<< coeffDict_.dictName() << coeffDict_ << endl;
39  }
40 }
41 
42 
43 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
44 
45 template<class BasicTurbulenceModel>
47 (
48  const word& type,
49  const alphaField& alpha,
50  const rhoField& rho,
51  const volVectorField& U,
52  const surfaceScalarField& alphaRhoPhi,
53  const surfaceScalarField& phi,
54  const transportModel& transport,
55  const word& propertiesName
56 )
57 :
58  BasicTurbulenceModel
59  (
60  type,
61  alpha,
62  rho,
63  U,
64  alphaRhoPhi,
65  phi,
66  transport,
67  propertiesName
68  ),
69 
70  RASDict_(this->subOrEmptyDict("RAS")),
71  turbulence_(RASDict_.get<Switch>("turbulence")),
72  printCoeffs_(RASDict_.getOrDefault<Switch>("printCoeffs", false)),
73  coeffDict_(RASDict_.optionalSubDict(type + "Coeffs")),
74 
75  kMin_
76  (
78  (
79  "kMin",
80  RASDict_,
82  SMALL
83  )
84  ),
85 
86  epsilonMin_
87  (
89  (
90  "epsilonMin",
91  RASDict_,
92  kMin_.dimensions()/dimTime,
93  SMALL
94  )
95  ),
96 
97  omegaMin_
98  (
100  (
101  "omegaMin",
102  RASDict_,
104  SMALL
105  )
106  )
107 {
108  // Force the construction of the mesh deltaCoeffs which may be needed
109  // for the construction of the derived models and BCs
110  this->mesh_.deltaCoeffs();
111 }
112 
113 
114 // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
115 
116 template<class BasicTurbulenceModel>
119 (
120  const alphaField& alpha,
121  const rhoField& rho,
122  const volVectorField& U,
123  const surfaceScalarField& alphaRhoPhi,
124  const surfaceScalarField& phi,
125  const transportModel& transport,
126  const word& propertiesName
127 )
128 {
129  const IOdictionary modelDict
130  (
131  IOobject
132  (
133  IOobject::groupName(propertiesName, alphaRhoPhi.group()),
134  U.time().constant(),
135  U.db(),
136  IOobject::MUST_READ_IF_MODIFIED,
137  IOobject::NO_WRITE,
138  false // Do not register
139  )
140  );
141 
142  const dictionary& dict = modelDict.subDict("RAS");
143 
144  const word modelType
145  (
146  // "RASModel" for v2006 and earlier
147  dict.getCompat<word>("model", {{"RASModel", -2006}})
148  );
149 
150  Info<< "Selecting RAS turbulence model " << modelType << endl;
151 
152  auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType);
153 
154  if (!cstrIter.found())
155  {
157  (
158  dict,
159  "RAS model",
160  modelType,
161  *dictionaryConstructorTablePtr_
162  ) << exit(FatalIOError);
163  }
164 
165  return autoPtr<RASModel>
166  (
167  cstrIter()(alpha, rho, U, alphaRhoPhi, phi, transport, propertiesName)
168  );
169 }
170 
171 
172 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
173 
174 template<class BasicTurbulenceModel>
176 {
178  {
179  RASDict_ <<= this->subDict("RAS");
180  RASDict_.readEntry("turbulence", turbulence_);
181 
182  coeffDict_ <<= RASDict_.optionalSubDict(type() + "Coeffs");
183 
184  kMin_.readIfPresent(RASDict_);
185  epsilonMin_.readIfPresent(RASDict_);
186  omegaMin_.readIfPresent(RASDict_);
187 
188  return true;
189  }
190 
191  return false;
192 }
193 
194 
195 template<class BasicTurbulenceModel>
197 {
199 }
200 
201 
202 // ************************************************************************* //
Foam::IOdictionary
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:54
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:104
Foam::Switch
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Definition: Switch.H:77
Foam::dimless
const dimensionSet dimless(0, 0, 0, 0, 0, 0, 0)
Dimensionless.
Definition: dimensionSets.H:50
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::dimVelocity
const dimensionSet dimVelocity
Foam::constant::atomic::alpha
const dimensionedScalar alpha
Fine-structure constant: default SI units: [].
Definition: readThermalProperties.H:212
Foam::RASModel::RASModel
RASModel(const RASModel &)=delete
No copy construct.
Foam::FatalIOError
IOerror FatalIOError
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:350
rho
rho
Definition: readInitialConditions.H:88
Foam::ThermalDiffusivity::alphaField
BasicTurbulenceModel::alphaField alphaField
Definition: ThermalDiffusivity.H:58
Foam::dimTime
const dimensionSet dimTime(0, 0, 1, 0, 0, 0, 0)
Definition: dimensionSets.H:54
FatalIOErrorInLookup
#define FatalIOErrorInLookup(ios, lookupTag, lookupName, lookupTable)
Report an error message using Foam::FatalIOError.
Definition: error.H:406
Foam::RASModel::New
static autoPtr< RASModel > New(const alphaField &alpha, const rhoField &rho, const volVectorField &U, const surfaceScalarField &alphaRhoPhi, const surfaceScalarField &phi, const transportModel &transport, const word &propertiesName=turbulenceModel::propertiesName)
Return a reference to the selected RAS model.
Definition: RASModel.C:119
Foam::Info
messageStream Info
Information stream (uses stdout - output is on the master only)
correct
fvOptions correct(rho)
Foam::dictionary::subDict
const dictionary & subDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary.
Definition: dictionary.C:528
phi
surfaceScalarField & phi
Definition: setRegionFluidFields.H:8
Foam::blockMeshTools::read
void read(Istream &, label &, const dictionary &)
In-place read with dictionary lookup.
Definition: blockMeshTools.C:33
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
RASModel.H
Foam::dimensioned
Generic dimensioned Type class.
Definition: dimensionedScalarFwd.H:43
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
Foam::ThermalDiffusivity::transportModel
BasicTurbulenceModel::transportModel transportModel
Definition: ThermalDiffusivity.H:60
Foam::RASModel::correct
virtual void correct()
Solve the turbulence equations and correct the turbulence viscosity.
Definition: RASModel.C:196
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
U
U
Definition: pEqn.H:72
Foam::sqr
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Definition: dimensionedSymmTensor.C:51
Foam::RASModel::printCoeffs
virtual void printCoeffs(const word &type)
Print model coefficients.
Definition: RASModel.C:34
Foam::roots::type
type
Types of root.
Definition: Roots.H:54
Foam::GeometricField< scalar, fvPatchField, volMesh >
Foam::RASModel::read
virtual bool read()
Read model coefficients if they have changed.
Definition: RASModel.C:175