changed isA<wallPolyPatch> & isA<wallFvPatch> almost everywhere
[openfoam-extend-OpenFOAM-1.6-ext.git] / src / turbulenceModels / incompressible / RAS / RASModel / RASModel.C
blobae0a49d878a261bc669a14e5075cd9f5f4a8c847
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright held by original author
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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 \*---------------------------------------------------------------------------*/
27 #include "RASModel.H"
28 #include "addToRunTimeSelectionTable.H"
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
32 namespace Foam
34 namespace incompressible
37 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
39 defineTypeNameAndDebug(RASModel, 0);
40 defineRunTimeSelectionTable(RASModel, dictionary);
41 addToRunTimeSelectionTable(turbulenceModel, RASModel, turbulenceModel);
43 // * * * * * * * * * * * * * Protected Member Functions  * * * * * * * * * * //
45 void RASModel::printCoeffs()
47     if (printCoeffs_)
48     {
49         Info<< type() << "Coeffs" << coeffDict_ << endl;
50     }
54 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
56 RASModel::RASModel
58     const word& type,
59     const volVectorField& U,
60     const surfaceScalarField& phi,
61     transportModel& lamTransportModel
64     turbulenceModel(U, phi, lamTransportModel),
66     IOdictionary
67     (
68         IOobject
69         (
70             "RASProperties",
71             U.time().constant(),
72             U.db(),
73             IOobject::MUST_READ,
74             IOobject::NO_WRITE
75         )
76     ),
78     turbulence_(lookup("turbulence")),
79     printCoeffs_(lookupOrDefault<Switch>("printCoeffs", false)),
80     coeffDict_(subOrEmptyDict(type + "Coeffs")),
82     k0_("k0", dimVelocity*dimVelocity, SMALL),
83     epsilon0_("epsilon0", k0_.dimensions()/dimTime, SMALL),
84     epsilonSmall_("epsilonSmall", epsilon0_.dimensions(), SMALL),
85     omega0_("omega0", dimless/dimTime, SMALL),
86     omegaSmall_("omegaSmall", omega0_.dimensions(), SMALL),
88     y_(mesh_)
90     // Force the construction of the mesh deltaCoeffs which may be needed
91     // for the construction of the derived models and BCs
92     mesh_.deltaCoeffs();
96 // * * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * //
98 autoPtr<RASModel> RASModel::New
100     const volVectorField& U,
101     const surfaceScalarField& phi,
102     transportModel& transport
105     word modelName;
107     // Enclose the creation of the dictionary to ensure it is deleted
108     // before the turbulenceModel is created otherwise the dictionary is
109     // entered in the database twice
110     {
111         IOdictionary dict
112         (
113             IOobject
114             (
115                 "RASProperties",
116                 U.time().constant(),
117                 U.db(),
118                 IOobject::MUST_READ,
119                 IOobject::NO_WRITE
120             )
121         );
123         dict.lookup("RASModel") >> modelName;
124     }
126     Info<< "Selecting RAS turbulence model " << modelName << endl;
128     dictionaryConstructorTable::iterator cstrIter =
129         dictionaryConstructorTablePtr_->find(modelName);
131     if (cstrIter == dictionaryConstructorTablePtr_->end())
132     {
133         FatalErrorIn
134         (
135             "RASModel::New(const volVectorField&, "
136             "const surfaceScalarField&, transportModel&)"
137         )   << "Unknown RASModel type " << modelName
138             << endl << endl
139             << "Valid RASModel types are :" << endl
140             << dictionaryConstructorTablePtr_->toc()
141             << exit(FatalError);
142     }
144     return autoPtr<RASModel>(cstrIter()(U, phi, transport));
148 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
151 scalar RASModel::yPlusLam(const scalar kappa, const scalar E) const
153     scalar ypl = 11.0;
155     for (int i=0; i<10; i++)
156     {
157         ypl = log(max(E*ypl, 1))/kappa;
158     }
160     return ypl;
164 tmp<scalarField> RASModel::yPlus(const label patchNo, const scalar Cmu) const
166     const fvPatch& curPatch = mesh_.boundary()[patchNo];
168     tmp<scalarField> tYp(new scalarField(curPatch.size()));
169     scalarField& Yp = tYp();
171     if (curPatch.isWall())
172     {
173         Yp = pow(Cmu, 0.25)
174             *y_[patchNo]
175             *sqrt(k()().boundaryField()[patchNo].patchInternalField())
176             /nu().boundaryField()[patchNo];
177     }
178     else
179     {
180         WarningIn
181         (
182             "tmp<scalarField> RASModel::yPlus(const label patchNo) const"
183         )   << "Patch " << patchNo << " is not a wall. Returning null field"
184             << nl << endl;
186         Yp.setSize(0);
187     }
189     return tYp;
193 void RASModel::correct()
195     turbulenceModel::correct();
197     if (turbulence_ && mesh_.changing())
198     {
199         y_.correct();
200     }
204 bool RASModel::read()
206     if (regIOobject::read())
207     {
208         lookup("turbulence") >> turbulence_;
210         if (const dictionary* dictPtr = subDictPtr(type() + "Coeffs"))
211         {
212             coeffDict_ <<= *dictPtr;
213         }
215         k0_.readIfPresent(*this);
216         epsilon0_.readIfPresent(*this);
217         epsilonSmall_.readIfPresent(*this);
218         omega0_.readIfPresent(*this);
219         omegaSmall_.readIfPresent(*this);
221         return true;
222     }
223     else
224     {
225         return false;
226     }
230 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
232 } // End namespace incompressible
233 } // End namespace Foam
235 // ************************************************************************* //