1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
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
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
28 #include "wallFvPatch.H"
29 #include "addToRunTimeSelectionTable.H"
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 namespace compressible
38 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
40 defineTypeNameAndDebug(RASModel, 0);
41 defineRunTimeSelectionTable(RASModel, dictionary);
42 addToRunTimeSelectionTable(turbulenceModel, RASModel, turbulenceModel);
44 // * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
46 void RASModel::printCoeffs()
50 Info<< type() << "Coeffs" << coeffDict_ << endl;
55 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
60 const volScalarField& rho,
61 const volVectorField& U,
62 const surfaceScalarField& phi,
63 const basicThermo& thermophysicalModel
66 turbulenceModel(rho, U, phi, thermophysicalModel),
80 turbulence_(lookup("turbulence")),
81 printCoeffs_(lookupOrDefault<Switch>("printCoeffs", false)),
82 coeffDict_(subOrEmptyDict(type + "Coeffs")),
84 k0_("k0", dimVelocity*dimVelocity, SMALL),
85 epsilon0_("epsilon", k0_.dimensions()/dimTime, SMALL),
86 epsilonSmall_("epsilonSmall", epsilon0_.dimensions(), SMALL),
87 omega0_("omega", dimless/dimTime, SMALL),
88 omegaSmall_("omegaSmall", omega0_.dimensions(), SMALL),
92 // Force the construction of the mesh deltaCoeffs which may be needed
93 // for the construction of the derived models and BCs
98 // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
100 autoPtr<RASModel> RASModel::New
102 const volScalarField& rho,
103 const volVectorField& U,
104 const surfaceScalarField& phi,
105 const basicThermo& thermophysicalModel
110 // Enclose the creation of the dictionary to ensure it is deleted
111 // before the turbulenceModel is created otherwise the dictionary is
112 // entered in the database twice
126 dict.lookup("RASModel") >> modelName;
129 Info<< "Selecting RAS turbulence model " << modelName << endl;
131 dictionaryConstructorTable::iterator cstrIter =
132 dictionaryConstructorTablePtr_->find(modelName);
134 if (cstrIter == dictionaryConstructorTablePtr_->end())
138 "RASModel::New(const volScalarField&, "
139 "const volVectorField&, const surfaceScalarField&, "
141 ) << "Unknown RASModel type " << modelName
143 << "Valid RASModel types are :" << endl
144 << dictionaryConstructorTablePtr_->toc()
148 return autoPtr<RASModel>
150 cstrIter()(rho, U, phi, thermophysicalModel)
155 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
157 scalar RASModel::yPlusLam(const scalar kappa, const scalar E) const
161 for (int i=0; i<10; i++)
163 ypl = log(E*ypl)/kappa;
170 tmp<scalarField> RASModel::yPlus(const label patchNo, const scalar Cmu) const
172 const fvPatch& curPatch = mesh_.boundary()[patchNo];
174 tmp<scalarField> tYp(new scalarField(curPatch.size()));
175 scalarField& Yp = tYp();
177 if (isA<wallFvPatch>(curPatch))
181 *sqrt(k()().boundaryField()[patchNo].patchInternalField())
183 mu().boundaryField()[patchNo].patchInternalField()
184 /rho_.boundaryField()[patchNo]
191 "tmp<scalarField> RASModel::yPlus(const label patchNo) const"
192 ) << "Patch " << patchNo << " is not a wall. Returning null field"
202 void RASModel::correct()
204 if (mesh_.changing())
211 bool RASModel::read()
213 if (regIOobject::read())
215 lookup("turbulence") >> turbulence_;
217 if (const dictionary* dictPtr = subDictPtr(type() + "Coeffs"))
219 coeffDict_ <<= *dictPtr;
222 k0_.readIfPresent(*this);
223 epsilon0_.readIfPresent(*this);
224 epsilonSmall_.readIfPresent(*this);
225 omega0_.readIfPresent(*this);
226 omegaSmall_.readIfPresent(*this);
237 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
239 } // End namespace compressible
240 } // End namespace Foam
242 // ************************************************************************* //