00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include "RASModel.H"
00028 #include "wallFvPatch.H"
00029 #include "addToRunTimeSelectionTable.H"
00030
00031
00032
00033 namespace Foam
00034 {
00035 namespace compressible
00036 {
00037
00038
00039
00040 defineTypeNameAndDebug(RASModel, 0);
00041 defineRunTimeSelectionTable(RASModel, dictionary);
00042 addToRunTimeSelectionTable(turbulenceModel, RASModel, turbulenceModel);
00043
00044
00045
00046 void RASModel::printCoeffs()
00047 {
00048 if (printCoeffs_)
00049 {
00050 Info<< type() << "Coeffs" << coeffDict_ << endl;
00051 }
00052 }
00053
00054
00055
00056
00057 RASModel::RASModel
00058 (
00059 const word& type,
00060 const volScalarField& rho,
00061 const volVectorField& U,
00062 const surfaceScalarField& phi,
00063 const basicThermo& thermophysicalModel
00064 )
00065 :
00066 turbulenceModel(rho, U, phi, thermophysicalModel),
00067
00068 IOdictionary
00069 (
00070 IOobject
00071 (
00072 "RASProperties",
00073 U.time().constant(),
00074 U.db(),
00075 IOobject::MUST_READ,
00076 IOobject::NO_WRITE
00077 )
00078 ),
00079
00080 turbulence_(lookup("turbulence")),
00081 printCoeffs_(lookupOrDefault<Switch>("printCoeffs", false)),
00082 coeffDict_(subDictPtr(type + "Coeffs")),
00083
00084 k0_("k0", dimVelocity*dimVelocity, SMALL),
00085 epsilon0_("epsilon", k0_.dimensions()/dimTime, SMALL),
00086 epsilonSmall_("epsilonSmall", epsilon0_.dimensions(), SMALL),
00087 omega0_("omega", dimless/dimTime, SMALL),
00088 omegaSmall_("omegaSmall", omega0_.dimensions(), SMALL),
00089
00090 y_(mesh_)
00091 {}
00092
00093
00094
00095
00096 autoPtr<RASModel> RASModel::New
00097 (
00098 const volScalarField& rho,
00099 const volVectorField& U,
00100 const surfaceScalarField& phi,
00101 const basicThermo& thermophysicalModel
00102 )
00103 {
00104 word modelName;
00105
00106
00107
00108
00109 {
00110 IOdictionary dict
00111 (
00112 IOobject
00113 (
00114 "RASProperties",
00115 U.time().constant(),
00116 U.db(),
00117 IOobject::MUST_READ,
00118 IOobject::NO_WRITE
00119 )
00120 );
00121
00122 dict.lookup("RASModel") >> modelName;
00123 }
00124
00125 Info<< "Selecting RAS turbulence model " << modelName << endl;
00126
00127 dictionaryConstructorTable::iterator cstrIter =
00128 dictionaryConstructorTablePtr_->find(modelName);
00129
00130 if (cstrIter == dictionaryConstructorTablePtr_->end())
00131 {
00132 FatalErrorIn
00133 (
00134 "RASModel::New(const volScalarField&, "
00135 "const volVectorField&, const surfaceScalarField&, "
00136 "basicThermo&)"
00137 ) << "Unknown RASModel type " << modelName
00138 << endl << endl
00139 << "Valid RASModel types are :" << endl
00140 << dictionaryConstructorTablePtr_->toc()
00141 << exit(FatalError);
00142 }
00143
00144 return autoPtr<RASModel>
00145 (
00146 cstrIter()(rho, U, phi, thermophysicalModel)
00147 );
00148 }
00149
00150
00151
00152
00153 scalar RASModel::yPlusLam(const scalar kappa, const scalar E) const
00154 {
00155 scalar ypl = 11.0;
00156
00157 for (int i=0; i<10; i++)
00158 {
00159 ypl = log(E*ypl)/kappa;
00160 }
00161
00162 return ypl;
00163 }
00164
00165
00166 tmp<scalarField> RASModel::yPlus(const label patchNo, const scalar Cmu) const
00167 {
00168 const fvPatch& curPatch = mesh_.boundary()[patchNo];
00169
00170 tmp<scalarField> tYp(new scalarField(curPatch.size()));
00171 scalarField& Yp = tYp();
00172
00173 if (isType<wallFvPatch>(curPatch))
00174 {
00175 Yp = pow(Cmu, 0.25)
00176 *y_[patchNo]
00177 *sqrt(k()().boundaryField()[patchNo].patchInternalField())
00178 /(
00179 mu().boundaryField()[patchNo].patchInternalField()
00180 /rho_.boundaryField()[patchNo]
00181 );
00182 }
00183 else
00184 {
00185 WarningIn
00186 (
00187 "tmp<scalarField> RASModel::yPlus(const label patchNo) const"
00188 ) << "Patch " << patchNo << " is not a wall. Returning null field"
00189 << nl << endl;
00190
00191 Yp.setSize(0);
00192 }
00193
00194 return tYp;
00195 }
00196
00197
00198 void RASModel::correct()
00199 {
00200 if (mesh_.changing())
00201 {
00202 y_.correct();
00203 }
00204 }
00205
00206
00207 bool RASModel::read()
00208 {
00209 if (regIOobject::read())
00210 {
00211 lookup("turbulence") >> turbulence_;
00212
00213 if (const dictionary* dictPtr = subDictPtr(type() + "Coeffs"))
00214 {
00215 coeffDict_ <<= *dictPtr;
00216 }
00217
00218 k0_.readIfPresent(*this);
00219 epsilon0_.readIfPresent(*this);
00220 epsilonSmall_.readIfPresent(*this);
00221 omega0_.readIfPresent(*this);
00222 omegaSmall_.readIfPresent(*this);
00223
00224 return true;
00225 }
00226 else
00227 {
00228 return false;
00229 }
00230 }
00231
00232
00233
00234
00235 }
00236 }
00237
00238