TurbulenceModel.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-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 "TurbulenceModel.H"
30 #include "volFields.H"
31 #include "surfaceFields.H"
32 
33 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
34 
35 template
36 <
37  class Alpha,
38  class Rho,
39  class BasicTurbulenceModel,
40  class TransportModel
41 >
44 (
45  const alphaField& alpha,
46  const rhoField& rho,
47  const volVectorField& U,
48  const surfaceScalarField& alphaRhoPhi,
49  const surfaceScalarField& phi,
50  const transportModel& transport,
51  const word& propertiesName
52 )
53 :
54  BasicTurbulenceModel
55  (
56  rho,
57  U,
58  alphaRhoPhi,
59  phi,
60  propertiesName
61  ),
62  alpha_(alpha),
63  transport_(transport)
64 {}
65 
66 
67 // * * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * //
68 
69 template
70 <
71  class Alpha,
72  class Rho,
73  class BasicTurbulenceModel,
74  class TransportModel
75 >
77 <
79 >
81 (
82  const alphaField& alpha,
83  const rhoField& rho,
84  const volVectorField& U,
85  const surfaceScalarField& alphaRhoPhi,
86  const surfaceScalarField& phi,
87  const transportModel& transport,
88  const word& propertiesName
89 )
90 {
91  const IOdictionary dict
92  (
93  IOobject
94  (
95  IOobject::groupName(propertiesName, alphaRhoPhi.group()),
96  U.time().constant(),
97  U.db(),
98  IOobject::MUST_READ,
99  IOobject::NO_WRITE,
100  IOobject::NO_REGISTER
101  )
102  );
103 
104  const word modelType(dict.get<word>("simulationType"));
105 
106  Info<< "Selecting turbulence model type " << modelType << endl;
107 
108  auto* ctorPtr = dictionaryConstructorTable(modelType);
109 
110  if (!ctorPtr)
111  {
113  (
114  dict,
115  "simulationType",
116  modelType,
117  *dictionaryConstructorTablePtr_
118  ) << exit(FatalIOError);
119  }
120 
121  return autoPtr<TurbulenceModel>
122  (
123  ctorPtr(alpha, rho, U, alphaRhoPhi, phi, transport, propertiesName)
124  );
125 }
126 
127 
128 // ************************************************************************* //
Foam::surfaceFields.
static word group(const word &name)
Return group (extension part of name)
Definition: IOobject.C:300
dictionary dict
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:125
static autoPtr< TurbulenceModel > 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 turbulence model.
Templated abstract base class for turbulence models.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:531
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:50
A class representing the concept of a GeometricField of 1 used to avoid unnecessary manipulations for...
A class for handling words, derived from Foam::string.
Definition: word.H:63
U
Definition: pEqn.H:72
Base-class for all transport models used by the incompressible turbulence models. ...
messageStream Info
Information stream (stdout output on master, null elsewhere)
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
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
#define FatalIOErrorInLookup(ios, lookupTag, lookupName, lookupTable)
Report an error message using Foam::FatalIOError.
Definition: error.H:635
TurbulenceModel(const TurbulenceModel &)=delete
No copy construct.
IOerror FatalIOError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL IO ERROR&#39; header text and ...