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 incompressible
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 volVectorField& U,
00061 const surfaceScalarField& phi,
00062 transportModel& lamTransportModel
00063 )
00064 :
00065 turbulenceModel(U, phi, lamTransportModel),
00066
00067 IOdictionary
00068 (
00069 IOobject
00070 (
00071 "RASProperties",
00072 U.time().constant(),
00073 U.db(),
00074 IOobject::MUST_READ,
00075 IOobject::NO_WRITE
00076 )
00077 ),
00078
00079 turbulence_(lookup("turbulence")),
00080 printCoeffs_(lookupOrDefault<Switch>("printCoeffs", false)),
00081 coeffDict_(subDictPtr(type + "Coeffs")),
00082
00083 k0_("k0", dimVelocity*dimVelocity, SMALL),
00084 epsilon0_("epsilon", k0_.dimensions()/dimTime, SMALL),
00085 epsilonSmall_("epsilonSmall", epsilon0_.dimensions(), SMALL),
00086 omega0_("omega0", dimless/dimTime, SMALL),
00087 omegaSmall_("omegaSmall", omega0_.dimensions(), SMALL),
00088
00089 y_(mesh_)
00090 {}
00091
00092
00093
00094
00095 autoPtr<RASModel> RASModel::New
00096 (
00097 const volVectorField& U,
00098 const surfaceScalarField& phi,
00099 transportModel& transport
00100 )
00101 {
00102 word modelName;
00103
00104
00105
00106
00107 {
00108 IOdictionary dict
00109 (
00110 IOobject
00111 (
00112 "RASProperties",
00113 U.time().constant(),
00114 U.db(),
00115 IOobject::MUST_READ,
00116 IOobject::NO_WRITE
00117 )
00118 );
00119
00120 dict.lookup("RASModel") >> modelName;
00121 }
00122
00123 Info<< "Selecting RAS turbulence model " << modelName << endl;
00124
00125 dictionaryConstructorTable::iterator cstrIter =
00126 dictionaryConstructorTablePtr_->find(modelName);
00127
00128 if (cstrIter == dictionaryConstructorTablePtr_->end())
00129 {
00130 FatalErrorIn
00131 (
00132 "RASModel::New(const volVectorField&, "
00133 "const surfaceScalarField&, transportModel&)"
00134 ) << "Unknown RASModel type " << modelName
00135 << endl << endl
00136 << "Valid RASModel types are :" << endl
00137 << dictionaryConstructorTablePtr_->toc()
00138 << exit(FatalError);
00139 }
00140
00141 return autoPtr<RASModel>(cstrIter()(U, phi, transport));
00142 }
00143
00144
00145
00146
00147
00148 scalar RASModel::yPlusLam(const scalar kappa, const scalar E) const
00149 {
00150 scalar ypl = 11.0;
00151
00152 for (int i=0; i<10; i++)
00153 {
00154 ypl = log(max(E*ypl, 1))/kappa;
00155 }
00156
00157 return ypl;
00158 }
00159
00160
00161 tmp<scalarField> RASModel::yPlus(const label patchNo, const scalar Cmu) const
00162 {
00163 const fvPatch& curPatch = mesh_.boundary()[patchNo];
00164
00165 tmp<scalarField> tYp(new scalarField(curPatch.size()));
00166 scalarField& Yp = tYp();
00167
00168 if (isType<wallFvPatch>(curPatch))
00169 {
00170 Yp = pow(Cmu, 0.25)
00171 *y_[patchNo]
00172 *sqrt(k()().boundaryField()[patchNo].patchInternalField())
00173 /nu().boundaryField()[patchNo];
00174 }
00175 else
00176 {
00177 WarningIn
00178 (
00179 "tmp<scalarField> RASModel::yPlus(const label patchNo) const"
00180 ) << "Patch " << patchNo << " is not a wall. Returning null field"
00181 << nl << endl;
00182
00183 Yp.setSize(0);
00184 }
00185
00186 return tYp;
00187 }
00188
00189
00190 void RASModel::correct()
00191 {
00192 turbulenceModel::correct();
00193
00194 if (turbulence_ && mesh_.changing())
00195 {
00196 y_.correct();
00197 }
00198 }
00199
00200
00201 bool RASModel::read()
00202 {
00203 if (regIOobject::read())
00204 {
00205 lookup("turbulence") >> turbulence_;
00206
00207 if (const dictionary* dictPtr = subDictPtr(type() + "Coeffs"))
00208 {
00209 coeffDict_ <<= *dictPtr;
00210 }
00211
00212 k0_.readIfPresent(*this);
00213 epsilon0_.readIfPresent(*this);
00214 epsilonSmall_.readIfPresent(*this);
00215 omega0_.readIfPresent(*this);
00216 omegaSmall_.readIfPresent(*this);
00217
00218 return true;
00219 }
00220 else
00221 {
00222 return false;
00223 }
00224 }
00225
00226
00227
00228
00229 }
00230 }
00231
00232