1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 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, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29 Calculates and reports yPlus for all wall patches, for the specified times
30 when using RAS turbulence models.
32 Default behaviour assumes operating in incompressible mode. To apply to
33 compressible RAS cases, use the -compressible option.
35 \*---------------------------------------------------------------------------*/
39 #include "incompressible/singlePhaseTransportModel/singlePhaseTransportModel.H"
40 #include "incompressible/RAS/RASModel/RASModel.H"
41 #include "nutWallFunction/nutWallFunctionFvPatchScalarField.H"
43 #include "basicPsiThermo.H"
44 #include "compressible/RAS/RASModel/RASModel.H"
45 #include "mutWallFunction/mutWallFunctionFvPatchScalarField.H"
49 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51 void calcIncompressibleYPlus
55 const volVectorField& U,
59 typedef incompressible::RASModels::nutWallFunctionFvPatchScalarField
60 wallFunctionPatchField;
62 #include "createPhi.H"
64 singlePhaseTransportModel laminarTransport(U, phi);
66 autoPtr<incompressible::RASModel> RASModel
68 incompressible::RASModel::New(U, phi, laminarTransport)
71 const volScalarField::GeometricBoundaryField nutPatches =
72 RASModel->nut()().boundaryField();
74 bool foundNutPatch = false;
75 forAll(nutPatches, patchi)
77 if (isA<wallFunctionPatchField>(nutPatches[patchi]))
81 const wallFunctionPatchField& nutPw =
82 dynamic_cast<const wallFunctionPatchField&>
85 yPlus.boundaryField()[patchi] = nutPw.yPlus();
86 const scalarField& Yp = yPlus.boundaryField()[patchi];
88 Info<< "Patch " << patchi
89 << " named " << nutPw.patch().name()
90 << " y+ : min: " << min(Yp) << " max: " << max(Yp)
91 << " average: " << average(Yp) << nl << endl;
97 Info<< " no " << wallFunctionPatchField::typeName << " patches"
103 void calcCompressibleYPlus
107 const volVectorField& U,
108 volScalarField& yPlus
111 typedef compressible::RASModels::mutWallFunctionFvPatchScalarField
112 wallFunctionPatchField;
123 if (!rhoHeader.headerOk())
125 Info<< " no rho field" << endl;
129 Info << "Reading field rho\n" << endl;
130 volScalarField rho(rhoHeader, mesh);
132 #include "compressibleCreatePhi.H"
134 autoPtr<basicPsiThermo> pThermo
136 basicPsiThermo::New(mesh)
138 basicPsiThermo& thermo = pThermo();
140 autoPtr<compressible::RASModel> RASModel
142 compressible::RASModel::New
151 const volScalarField::GeometricBoundaryField mutPatches =
152 RASModel->mut()().boundaryField();
154 bool foundMutPatch = false;
155 forAll(mutPatches, patchi)
157 if (isA<wallFunctionPatchField>(mutPatches[patchi]))
159 foundMutPatch = true;
161 const wallFunctionPatchField& mutPw =
162 dynamic_cast<const wallFunctionPatchField&>
163 (mutPatches[patchi]);
165 yPlus.boundaryField()[patchi] = mutPw.yPlus();
166 const scalarField& Yp = yPlus.boundaryField()[patchi];
168 Info<< "Patch " << patchi
169 << " named " << mutPw.patch().name()
170 << " y+ : min: " << min(Yp) << " max: " << max(Yp)
171 << " average: " << average(Yp) << nl << endl;
177 Info<< " no " << wallFunctionPatchField::typeName << " patches"
183 int main(int argc, char *argv[])
185 timeSelector::addOptions();
187 #include "addRegionOption.H"
189 argList::validOptions.insert("compressible","");
191 #include "setRootCase.H"
192 #include "createTime.H"
193 instantList timeDirs = timeSelector::select0(runTime, args);
194 #include "createNamedMesh.H"
196 bool compressible = args.optionFound("compressible");
198 forAll(timeDirs, timeI)
200 runTime.setTime(timeDirs[timeI], timeI);
201 Info<< "Time = " << runTime.timeName() << endl;
202 fvMesh::readUpdateState state = mesh.readUpdate();
205 if (timeI == 0 || state != fvMesh::UNCHANGED)
207 Info<< "Calculating wall distance\n" << endl;
208 wallDist y(mesh, true);
209 Info<< "Writing wall distance to field "
210 << y.name() << nl << endl;
225 dimensionedScalar("yPlus", dimless, 0.0)
237 if (UHeader.headerOk())
239 Info << "Reading field U\n" << endl;
240 volVectorField U(UHeader, mesh);
244 calcCompressibleYPlus(mesh, runTime, U, yPlus);
248 calcIncompressibleYPlus(mesh, runTime, U, yPlus);
253 Info<< " no U field" << endl;
256 Info<< "Writing yPlus to field " << yPlus.name() << nl << endl;
261 Info<< "End\n" << endl;
267 // ************************************************************************* //