1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
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 Extended version for being able to handle two phase flows using the
38 Frank Albina, 16/Nov/2009
40 \*---------------------------------------------------------------------------*/
43 #include "incompressible/incompressibleTwoPhaseMixture/twoPhaseMixture.H"
44 #include "incompressible/singlePhaseTransportModel/singlePhaseTransportModel.H"
45 #include "incompressible/RAS/RASModel/RASModel.H"
46 #include "nutWallFunction/nutWallFunctionFvPatchScalarField.H"
48 #include "basicPsiThermo.H"
49 #include "compressible/RAS/RASModel/RASModel.H"
50 #include "mutWallFunction/mutWallFunctionFvPatchScalarField.H"
54 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
56 void calcIncompressibleYPlus
60 const volVectorField& U,
64 typedef incompressible::RASModels::nutWallFunctionFvPatchScalarField
65 wallFunctionPatchField;
67 # include "createPhi.H"
69 singlePhaseTransportModel laminarTransport(U, phi);
71 autoPtr<incompressible::RASModel> RASModel
73 incompressible::RASModel::New(U, phi, laminarTransport)
76 const volScalarField::GeometricBoundaryField nutPatches =
77 RASModel->nut()().boundaryField();
79 bool foundNutPatch = false;
80 forAll(nutPatches, patchi)
82 if (isA<wallFunctionPatchField>(nutPatches[patchi]))
86 const wallFunctionPatchField& nutPw =
87 dynamic_cast<const wallFunctionPatchField&>
90 yPlus.boundaryField()[patchi] = nutPw.yPlus();
91 const scalarField& Yp = yPlus.boundaryField()[patchi];
93 Info<< "Patch " << patchi
94 << " named " << nutPw.patch().name()
95 << " y+ : min: " << min(Yp) << " max: " << max(Yp)
96 << " average: " << average(Yp) << nl << endl;
102 Info<< " no " << wallFunctionPatchField::typeName << " patches"
108 void calcCompressibleYPlus
112 const volVectorField& U,
113 volScalarField& yPlus
116 typedef compressible::RASModels::mutWallFunctionFvPatchScalarField
117 wallFunctionPatchField;
128 if (!rhoHeader.headerOk())
130 Info<< " no rho field" << endl;
134 Info << "Reading field rho\n" << endl;
135 volScalarField rho(rhoHeader, mesh);
137 # include "compressibleCreatePhi.H"
139 autoPtr<basicPsiThermo> pThermo
141 basicPsiThermo::New(mesh)
143 basicPsiThermo& thermo = pThermo();
145 autoPtr<compressible::RASModel> RASModel
147 compressible::RASModel::New
156 const volScalarField::GeometricBoundaryField mutPatches =
157 RASModel->mut()().boundaryField();
159 bool foundMutPatch = false;
160 forAll(mutPatches, patchi)
162 if (isA<wallFunctionPatchField>(mutPatches[patchi]))
164 foundMutPatch = true;
166 const wallFunctionPatchField& mutPw =
167 dynamic_cast<const wallFunctionPatchField&>
168 (mutPatches[patchi]);
170 yPlus.boundaryField()[patchi] = mutPw.yPlus();
171 const scalarField& Yp = yPlus.boundaryField()[patchi];
173 Info<< "Patch " << patchi
174 << " named " << mutPw.patch().name()
175 << " y+ : min: " << min(Yp) << " max: " << max(Yp)
176 << " average: " << average(Yp) << nl << endl;
182 Info<< " no " << wallFunctionPatchField::typeName << " patches"
188 // Calculate two phase Y+
189 void calcTwoPhaseYPlus
193 const volVectorField& U,
194 volScalarField& yPlus
197 typedef incompressible::RASModels::nutWallFunctionFvPatchScalarField
198 wallFunctionPatchField;
200 # include "createPhi.H"
211 if (!alphaHeader.headerOk())
213 Info<< " no alpha1 field" << endl;
217 Info << "Reading field alpha1\n" << endl;
218 volScalarField alpha(alphaHeader, mesh);
220 Info<< "Reading transportProperties\n" << endl;
221 twoPhaseMixture twoPhaseProperties(U, phi, "alpha1");
223 autoPtr<incompressible::RASModel> RASModel
225 incompressible::RASModel::New(U, phi, twoPhaseProperties)
228 const volScalarField::GeometricBoundaryField nutPatches =
229 RASModel->nut()().boundaryField();
231 bool foundNutPatch = false;
232 forAll(nutPatches, patchi)
234 if (isA<wallFunctionPatchField>(nutPatches[patchi]))
236 foundNutPatch = true;
238 const wallFunctionPatchField& nutPw =
239 dynamic_cast<const wallFunctionPatchField&>
240 (nutPatches[patchi]);
242 yPlus.boundaryField()[patchi] = nutPw.yPlus();
243 const scalarField& Yp = yPlus.boundaryField()[patchi];
245 Info<< "Patch " << patchi
246 << " named " << nutPw.patch().name()
247 << " y+ : min: " << min(Yp) << " max: " << max(Yp)
248 << " average: " << average(Yp) << nl << endl;
254 Info<< " no " << wallFunctionPatchField::typeName << " patches"
260 int main(int argc, char *argv[])
262 timeSelector::addOptions();
264 #include "addRegionOption.H"
266 argList::validOptions.insert("compressible","");
267 argList::validOptions.insert("twoPhase","");
269 #include "setRootCase.H"
270 #include "createTime.H"
271 instantList timeDirs = timeSelector::select0(runTime, args);
272 #include "createNamedMesh.H"
274 bool compressible = args.optionFound("compressible");
276 // Check if two phase model was selected
277 bool twoPhase = args.optionFound("twoPhase");
279 forAll(timeDirs, timeI)
281 runTime.setTime(timeDirs[timeI], timeI);
282 Info<< "Time = " << runTime.timeName() << endl;
283 fvMesh::readUpdateState state = mesh.readUpdate();
286 if (timeI == 0 || state != fvMesh::UNCHANGED)
288 Info<< "Calculating wall distance\n" << endl;
289 wallDist y(mesh, true);
290 Info<< "Writing wall distance to field "
291 << y.name() << nl << endl;
306 dimensionedScalar("yPlus", dimless, 0.0)
309 Info << "Reading field U\n" << endl;
319 if (UHeader.headerOk())
321 Info << "Reading field U\n" << endl;
322 volVectorField U(UHeader, mesh);
326 calcCompressibleYPlus(mesh, runTime, U, yPlus);
330 calcTwoPhaseYPlus(mesh, runTime, U, yPlus);
334 calcIncompressibleYPlus(mesh, runTime, U, yPlus);
339 Info<< " no U field" << endl;
342 Info<< "Writing yPlus to field " << yPlus.name() << nl << endl;
347 Info<< "End\n" << endl;
353 // ************************************************************************* //