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
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066 #include <finiteVolume/fvCFD.H>
00067 #include <finiteVolume/wallDist.H>
00068
00069
00070
00071 int main(int argc, char *argv[])
00072 {
00073 argList::validOptions.insert("ybl", "scalar");
00074 argList::validOptions.insert("Cbl", "scalar");
00075 argList::validOptions.insert("writenut", "");
00076
00077 # include <OpenFOAM/setRootCase.H>
00078
00079 # include <OpenFOAM/createTime.H>
00080 # include <OpenFOAM/createMesh.H>
00081
00082
00083
00084 Info<< "Reading field U\n" << endl;
00085 volVectorField U
00086 (
00087 IOobject
00088 (
00089 "U",
00090 runTime.timeName(),
00091 mesh,
00092 IOobject::MUST_READ,
00093 IOobject::NO_WRITE
00094 ),
00095 mesh
00096 );
00097
00098 # include <finiteVolume/createPhi.H>
00099
00100 Info<< "Calculating wall distance field" << endl;
00101 volScalarField y = wallDist(mesh).y();
00102
00103
00104 dimensionedScalar ybl("ybl", dimLength, 0);
00105
00106 if (args.optionFound("ybl"))
00107 {
00108
00109 ybl.value() = args.optionRead<scalar>("ybl");
00110 }
00111 else if (args.optionFound("Cbl"))
00112 {
00113
00114 ybl.value() = gAverage(y) * args.optionRead<scalar>("Cbl");
00115 }
00116 else
00117 {
00118 FatalErrorIn(args.executable())
00119 << "Neither option 'ybl' or 'Cbl' have been provided to calculate"
00120 " the boundary-layer thickness"
00121 << exit(FatalError);
00122 }
00123
00124 Info<< "\nCreating boundary-layer for U of thickness "
00125 << ybl.value() << " m" << nl << endl;
00126
00127
00128
00129
00130
00131 scalar yblv = ybl.value();
00132 forAll(U, celli)
00133 {
00134 if (y[celli] <= yblv)
00135 {
00136 U[celli] *= ::pow(y[celli]/yblv, (1.0/7.0));
00137 }
00138 }
00139
00140 Info<< "Writing U" << endl;
00141 U.write();
00142
00143
00144 phi = fvc::interpolate(U) & mesh.Sf();
00145 phi.write();
00146
00147
00148 dimensionedScalar kappa("kappa", dimless, 0.41);
00149 dimensionedScalar Cmu("Cmu", dimless, 0.09);
00150
00151
00152
00153 IOobject epsilonHeader
00154 (
00155 "epsilon",
00156 runTime.timeName(),
00157 mesh,
00158 IOobject::MUST_READ
00159 );
00160
00161 IOobject kHeader
00162 (
00163 "k",
00164 runTime.timeName(),
00165 mesh,
00166 IOobject::MUST_READ
00167 );
00168
00169 IOobject nuTildaHeader
00170 (
00171 "nuTilda",
00172 runTime.timeName(),
00173 mesh,
00174 IOobject::MUST_READ
00175 );
00176
00177
00178 volScalarField nut
00179 (
00180 "nut",
00181 sqr(kappa*min(y, ybl))*::sqrt(2)*mag(dev(symm(fvc::grad(U))))
00182 );
00183
00184 if (args.optionFound("writenut"))
00185 {
00186 Info<< "Writing nut" << endl;
00187 nut.write();
00188 }
00189
00190
00191
00192
00193 if (nuTildaHeader.headerOk())
00194 {
00195 Info<< "Reading field nuTilda\n" << endl;
00196 volScalarField nuTilda(nuTildaHeader, mesh);
00197 nuTilda = nut;
00198 nuTilda.correctBoundaryConditions();
00199
00200 Info<< "Writing nuTilda\n" << endl;
00201 nuTilda.write();
00202 }
00203
00204 if (kHeader.headerOk() && epsilonHeader.headerOk())
00205 {
00206 Info<< "Reading field k\n" << endl;
00207 volScalarField k(kHeader, mesh);
00208
00209 Info<< "Reading field epsilon\n" << endl;
00210 volScalarField epsilon(epsilonHeader, mesh);
00211
00212 scalar ck0 = ::pow(Cmu.value(), 0.25)*kappa.value();
00213 k = sqr(nut/(ck0*min(y, ybl)));
00214 k.correctBoundaryConditions();
00215
00216 scalar ce0 = ::pow(Cmu.value(), 0.75)/kappa.value();
00217 epsilon = ce0*k*sqrt(k)/min(y, ybl);
00218 epsilon.correctBoundaryConditions();
00219
00220 Info<< "Writing k\n" << endl;
00221 k.write();
00222
00223 Info<< "Writing epsilon\n" << endl;
00224 epsilon.write();
00225 }
00226
00227 Info<< nl << "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
00228 << " ClockTime = " << runTime.elapsedClockTime() << " s"
00229 << nl << endl;
00230
00231 Info<< "End\n" << endl;
00232
00233 return 0;
00234 }
00235
00236
00237