1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
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.
32 Use the -compressible option for compressible RAS cases.
34 \*---------------------------------------------------------------------------*/
38 #include "incompressible/singlePhaseTransportModel/singlePhaseTransportModel.H"
39 #include "incompressible/RAS/RASModel/RASModel.H"
40 #include "nutkWallFunction/nutkWallFunctionFvPatchScalarField.H"
42 #include "basicPsiThermo.H"
43 #include "compressible/RAS/RASModel/RASModel.H"
44 #include "mutkWallFunction/mutkWallFunctionFvPatchScalarField.H"
48 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50 void calcIncompressibleYPlus
54 const volVectorField& U,
58 typedef incompressible::RASModels::nutkWallFunctionFvPatchScalarField
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::mutkWallFunctionFvPatchScalarField
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::addBoolOption
191 "calculate compressible y+"
194 #include "setRootCase.H"
195 #include "createTime.H"
196 instantList timeDirs = timeSelector::select0(runTime, args);
197 #include "createNamedMesh.H"
199 const bool compressible = args.optionFound("compressible");
201 forAll(timeDirs, timeI)
203 runTime.setTime(timeDirs[timeI], timeI);
204 Info<< "Time = " << runTime.timeName() << endl;
205 fvMesh::readUpdateState state = mesh.readUpdate();
208 if (timeI == 0 || state != fvMesh::UNCHANGED)
210 Info<< "Calculating wall distance\n" << endl;
211 wallDist y(mesh, true);
212 Info<< "Writing wall distance to field " << y.name() << nl << endl;
227 dimensionedScalar("yPlus", dimless, 0.0)
239 if (UHeader.headerOk())
241 Info<< "Reading field U\n" << endl;
242 volVectorField U(UHeader, mesh);
246 calcCompressibleYPlus(mesh, runTime, U, yPlus);
250 calcIncompressibleYPlus(mesh, runTime, U, yPlus);
255 Info<< " no U field" << endl;
258 Info<< "Writing yPlus to field " << yPlus.name() << nl << endl;
263 Info<< "End\n" << endl;
269 // ************************************************************************* //