yPlusRAS.C
Go to the documentation of this file.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
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #include "fvCFD.H"
00038
00039 #include "incompressible/singlePhaseTransportModel/singlePhaseTransportModel.H"
00040 #include "incompressible/RAS/RASModel/RASModel.H"
00041 #include "nutWallFunction/nutWallFunctionFvPatchScalarField.H"
00042
00043 #include "basicPsiThermo.H"
00044 #include "compressible/RAS/RASModel/RASModel.H"
00045 #include "mutWallFunction/mutWallFunctionFvPatchScalarField.H"
00046
00047 #include "wallDist.H"
00048
00049
00050
00051 void calcIncompressibleYPlus
00052 (
00053 const fvMesh& mesh,
00054 const Time& runTime,
00055 const volVectorField& U,
00056 volScalarField& yPlus
00057 )
00058 {
00059 typedef incompressible::RASModels::nutWallFunctionFvPatchScalarField
00060 wallFunctionPatchField;
00061
00062 #include "createPhi.H"
00063
00064 singlePhaseTransportModel laminarTransport(U, phi);
00065
00066 autoPtr<incompressible::RASModel> RASModel
00067 (
00068 incompressible::RASModel::New(U, phi, laminarTransport)
00069 );
00070
00071 const volScalarField::GeometricBoundaryField nutPatches =
00072 RASModel->nut()().boundaryField();
00073
00074 bool foundNutPatch = false;
00075 forAll(nutPatches, patchi)
00076 {
00077 if (isA<wallFunctionPatchField>(nutPatches[patchi]))
00078 {
00079 foundNutPatch = true;
00080
00081 const wallFunctionPatchField& nutPw =
00082 dynamic_cast<const wallFunctionPatchField&>
00083 (nutPatches[patchi]);
00084
00085 yPlus.boundaryField()[patchi] = nutPw.yPlus();
00086 const scalarField& Yp = yPlus.boundaryField()[patchi];
00087
00088 Info<< "Patch " << patchi
00089 << " named " << nutPw.patch().name()
00090 << " y+ : min: " << min(Yp) << " max: " << max(Yp)
00091 << " average: " << average(Yp) << nl << endl;
00092 }
00093 }
00094
00095 if (!foundNutPatch)
00096 {
00097 Info<< " no " << wallFunctionPatchField::typeName << " patches"
00098 << endl;
00099 }
00100 }
00101
00102
00103 void calcCompressibleYPlus
00104 (
00105 const fvMesh& mesh,
00106 const Time& runTime,
00107 const volVectorField& U,
00108 volScalarField& yPlus
00109 )
00110 {
00111 typedef compressible::RASModels::mutWallFunctionFvPatchScalarField
00112 wallFunctionPatchField;
00113
00114 IOobject rhoHeader
00115 (
00116 "rho",
00117 runTime.timeName(),
00118 mesh,
00119 IOobject::MUST_READ,
00120 IOobject::NO_WRITE
00121 );
00122
00123 if (!rhoHeader.headerOk())
00124 {
00125 Info<< " no rho field" << endl;
00126 return;
00127 }
00128
00129 Info << "Reading field rho\n" << endl;
00130 volScalarField rho(rhoHeader, mesh);
00131
00132 #include "compressibleCreatePhi.H"
00133
00134 autoPtr<basicPsiThermo> pThermo
00135 (
00136 basicPsiThermo::New(mesh)
00137 );
00138 basicPsiThermo& thermo = pThermo();
00139
00140 autoPtr<compressible::RASModel> RASModel
00141 (
00142 compressible::RASModel::New
00143 (
00144 rho,
00145 U,
00146 phi,
00147 thermo
00148 )
00149 );
00150
00151 const volScalarField::GeometricBoundaryField mutPatches =
00152 RASModel->mut()().boundaryField();
00153
00154 bool foundMutPatch = false;
00155 forAll(mutPatches, patchi)
00156 {
00157 if (isA<wallFunctionPatchField>(mutPatches[patchi]))
00158 {
00159 foundMutPatch = true;
00160
00161 const wallFunctionPatchField& mutPw =
00162 dynamic_cast<const wallFunctionPatchField&>
00163 (mutPatches[patchi]);
00164
00165 yPlus.boundaryField()[patchi] = mutPw.yPlus();
00166 const scalarField& Yp = yPlus.boundaryField()[patchi];
00167
00168 Info<< "Patch " << patchi
00169 << " named " << mutPw.patch().name()
00170 << " y+ : min: " << min(Yp) << " max: " << max(Yp)
00171 << " average: " << average(Yp) << nl << endl;
00172 }
00173 }
00174
00175 if (!foundMutPatch)
00176 {
00177 Info<< " no " << wallFunctionPatchField::typeName << " patches"
00178 << endl;
00179 }
00180 }
00181
00182
00183 int main(int argc, char *argv[])
00184 {
00185 timeSelector::addOptions();
00186
00187 #include "addRegionOption.H"
00188
00189 argList::validOptions.insert("compressible","");
00190
00191 #include "setRootCase.H"
00192 #include "createTime.H"
00193 instantList timeDirs = timeSelector::select0(runTime, args);
00194 #include "createNamedMesh.H"
00195
00196 bool compressible = args.optionFound("compressible");
00197
00198 forAll(timeDirs, timeI)
00199 {
00200 runTime.setTime(timeDirs[timeI], timeI);
00201 Info<< "Time = " << runTime.timeName() << endl;
00202 fvMesh::readUpdateState state = mesh.readUpdate();
00203
00204
00205 if (timeI == 0 || state != fvMesh::UNCHANGED)
00206 {
00207 Info<< "Calculating wall distance\n" << endl;
00208 wallDist y(mesh, true);
00209 Info<< "Writing wall distance to field "
00210 << y.name() << nl << endl;
00211 y.write();
00212 }
00213
00214 volScalarField yPlus
00215 (
00216 IOobject
00217 (
00218 "yPlus",
00219 runTime.timeName(),
00220 mesh,
00221 IOobject::NO_READ,
00222 IOobject::NO_WRITE
00223 ),
00224 mesh,
00225 dimensionedScalar("yPlus", dimless, 0.0)
00226 );
00227
00228 IOobject UHeader
00229 (
00230 "U",
00231 runTime.timeName(),
00232 mesh,
00233 IOobject::MUST_READ,
00234 IOobject::NO_WRITE
00235 );
00236
00237 if (UHeader.headerOk())
00238 {
00239 Info << "Reading field U\n" << endl;
00240 volVectorField U(UHeader, mesh);
00241
00242 if (compressible)
00243 {
00244 calcCompressibleYPlus(mesh, runTime, U, yPlus);
00245 }
00246 else
00247 {
00248 calcIncompressibleYPlus(mesh, runTime, U, yPlus);
00249 }
00250 }
00251 else
00252 {
00253 Info<< " no U field" << endl;
00254 }
00255
00256 Info<< "Writing yPlus to field " << yPlus.name() << nl << endl;
00257
00258 yPlus.write();
00259 }
00260
00261 Info<< "End\n" << endl;
00262
00263 return 0;
00264 }
00265
00266
00267
Copyright © 2000-2009 OpenCFD Ltd