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 | Copyright (C) 2013-2014 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 \*---------------------------------------------------------------------------*/
25 
26 #include "TurbulenceModel.H"
27 #include "volFields.H"
28 #include "surfaceFields.H"
29 
30 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
31 
32 template
33 <
34  class Alpha,
35  class Rho,
36  class BasicTurbulenceModel,
37  class TransportModel
38 >
41 (
42  const alphaField& alpha,
43  const rhoField& rho,
44  const volVectorField& U,
45  const surfaceScalarField& alphaRhoPhi,
46  const surfaceScalarField& phi,
47  const transportModel& transport,
48  const word& propertiesName
49 )
50 :
51  BasicTurbulenceModel
52  (
53  rho,
54  U,
55  alphaRhoPhi,
56  phi,
57  propertiesName
58  ),
59  alpha_(alpha),
60  transport_(transport)
61 {}
62 
63 
64 // * * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * //
65 
66 template
67 <
68  class Alpha,
69  class Rho,
70  class BasicTurbulenceModel,
71  class TransportModel
72 >
74 <
76 >
78 (
79  const alphaField& alpha,
80  const rhoField& rho,
81  const volVectorField& U,
82  const surfaceScalarField& alphaRhoPhi,
83  const surfaceScalarField& phi,
84  const transportModel& transport,
85  const word& propertiesName
86 )
87 {
88  // get model name, but do not register the dictionary
89  // otherwise it is registered in the database twice
90  const word modelType
91  (
93  (
94  IOobject
95  (
96  IOobject::groupName(propertiesName, U.group()),
97  U.time().constant(),
98  U.db(),
99  IOobject::MUST_READ_IF_MODIFIED,
100  IOobject::NO_WRITE,
101  false
102  )
103  ).lookup("simulationType")
104  );
105 
106  Info<< "Selecting turbulence model type " << modelType << endl;
107 
108  typename dictionaryConstructorTable::iterator cstrIter =
109  dictionaryConstructorTablePtr_->find(modelType);
110 
111  if (cstrIter == dictionaryConstructorTablePtr_->end())
112  {
114  (
115  "TurbulenceModel::New"
116  "(const alphaField&, const rhoField&, "
117  "const volVectorField&, const surfaceScalarField&, "
118  "transportModel&, const word&)"
119  ) << "Unknown TurbulenceModel type "
120  << modelType << nl << nl
121  << "Valid TurbulenceModel types:" << endl
122  << dictionaryConstructorTablePtr_->sortedToc()
123  << exit(FatalError);
124  }
125 
127  (
128  cstrIter()(alpha, rho, U, alphaRhoPhi, phi, transport, propertiesName)
129  );
130 }
131 
132 
133 // ************************************************************************* //
Foam::surfaceFields.
A class for handling words, derived from string.
Definition: word.H:59
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
messageStream Info
const word & constant() const
Return constant name.
Definition: TimePaths.H:124
static const char nl
Definition: Ostream.H:260
Templated abstract base class for turbulence models.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
const dimensionedScalar alpha
Fine-structure constant: default SI units: [].
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:53
TransportModel transportModel
word group() const
Return group (extension part of name)
Definition: IOobject.C:263
surfaceScalarField & phi
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
Definition: error.H:314
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:452
error FatalError
const Time & time() const
Return time.
Definition: IOobject.C:251
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.
const objectRegistry & db() const
Return the local objectRegistry.
Definition: IOobject.C:245
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:117
U
Definition: pEqn.H:82