1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
28 Calculates and reports yPlus for all wall patches, for the specified times
29 when using RAS turbulence models.
31 Default behaviour assumes operating in incompressible mode. To apply to
32 compressible RAS cases, use the -compressible option.
34 \*---------------------------------------------------------------------------*/
38 #include "incompressible/singlePhaseTransportModel/singlePhaseTransportModel.H"
39 #include "incompressible/RAS/RASModel/RASModel.H"
40 #include "nutWallFunction/nutWallFunctionFvPatchScalarField.H"
42 #include "basicPsiThermo.H"
43 #include "compressible/RAS/RASModel/RASModel.H"
44 #include "mutWallFunction/mutWallFunctionFvPatchScalarField.H"
48 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50 void calcIncompressibleYPlus
54 const volVectorField& U,
58 typedef incompressible::RASModels::nutWallFunctionFvPatchScalarField
59 wallFunctionPatchField;
61 #include "createPhi.H"
63 singlePhaseTransportModel laminarTransport(U, phi);
65 autoPtr<incompressible::RASModel> RASModel
67 incompressible::RASModel::New(U, phi, laminarTransport)
70 const volScalarField::GeometricBoundaryField nutPatches =
71 RASModel->nut()().boundaryField();
73 bool foundNutPatch = false;
74 forAll(nutPatches, patchi)
76 if (isA<wallFunctionPatchField>(nutPatches[patchi]))
80 const wallFunctionPatchField& nutPw =
81 dynamic_cast<const wallFunctionPatchField&>
84 yPlus.boundaryField()[patchi] = nutPw.yPlus();
85 const scalarField& Yp = yPlus.boundaryField()[patchi];
87 Info<< "Patch " << patchi
88 << " named " << nutPw.patch().name()
89 << " y+ : min: " << min(Yp) << " max: " << max(Yp)
90 << " average: " << average(Yp) << nl << endl;
96 Info<< " no " << wallFunctionPatchField::typeName << " patches"
102 void calcCompressibleYPlus
106 const volVectorField& U,
107 volScalarField& yPlus
110 typedef compressible::RASModels::mutWallFunctionFvPatchScalarField
111 wallFunctionPatchField;
122 if (!rhoHeader.headerOk())
124 Info<< " no rho field" << endl;
128 Info << "Reading field rho\n" << endl;
129 volScalarField rho(rhoHeader, mesh);
131 #include "compressibleCreatePhi.H"
133 autoPtr<basicPsiThermo> pThermo
135 basicPsiThermo::New(mesh)
137 basicPsiThermo& thermo = pThermo();
139 autoPtr<compressible::RASModel> RASModel
141 compressible::RASModel::New
150 const volScalarField::GeometricBoundaryField mutPatches =
151 RASModel->mut()().boundaryField();
153 bool foundMutPatch = false;
154 forAll(mutPatches, patchi)
156 if (isA<wallFunctionPatchField>(mutPatches[patchi]))
158 foundMutPatch = true;
160 const wallFunctionPatchField& mutPw =
161 dynamic_cast<const wallFunctionPatchField&>
162 (mutPatches[patchi]);
164 yPlus.boundaryField()[patchi] = mutPw.yPlus();
165 const scalarField& Yp = yPlus.boundaryField()[patchi];
167 Info<< "Patch " << patchi
168 << " named " << mutPw.patch().name()
169 << " y+ : min: " << min(Yp) << " max: " << max(Yp)
170 << " average: " << average(Yp) << nl << endl;
176 Info<< " no " << wallFunctionPatchField::typeName << " patches"
182 int main(int argc, char *argv[])
184 timeSelector::addOptions();
186 #include "addRegionOption.H"
188 argList::validOptions.insert("compressible","");
190 #include "setRootCase.H"
191 #include "createTime.H"
192 instantList timeDirs = timeSelector::select0(runTime, args);
193 #include "createNamedMesh.H"
195 bool compressible = args.optionFound("compressible");
197 forAll(timeDirs, timeI)
199 runTime.setTime(timeDirs[timeI], timeI);
200 Info<< "Time = " << runTime.timeName() << endl;
201 fvMesh::readUpdateState state = mesh.readUpdate();
204 if (timeI == 0 || state != fvMesh::UNCHANGED)
206 Info<< "Calculating wall distance\n" << endl;
207 wallDist y(mesh, true);
208 Info<< "Writing wall distance to field "
209 << y.name() << nl << endl;
224 dimensionedScalar("yPlus", dimless, 0.0)
236 if (UHeader.headerOk())
238 Info << "Reading field U\n" << endl;
239 volVectorField U(UHeader, mesh);
243 calcCompressibleYPlus(mesh, runTime, U, yPlus);
247 calcIncompressibleYPlus(mesh, runTime, U, yPlus);
252 Info<< " no U field" << endl;
255 Info<< "Writing yPlus to field " << yPlus.name() << nl << endl;
260 Info<< "End\n" << endl;
266 // ************************************************************************* //