initial commit for version 1.5.x patch release
[OpenFOAM-1.5.x.git] / applications / utilities / postProcessing / wall / yPlusLES / yPlusLES.C
blobd7c145b95324cf542d16c02b719bd68620d1aa63
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2008 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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
25 Application
26     yPlusLES
28 Description
29     Calculates and reports yPlus for all wall patches, for the specified times.
31 \*---------------------------------------------------------------------------*/
33 #include "fvCFD.H"
34 #include "incompressible/singlePhaseTransportModel/singlePhaseTransportModel.H"
35 #include "incompressible/LESModel/LESModel.H"
36 #include "nearWallDist.H"
38 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
40 int main(int argc, char *argv[])
42     timeSelector::addOptions();
43     #include "setRootCase.H"
44 #   include "createTime.H"
45     instantList timeDirs = timeSelector::select0(runTime, args);
46 #   include "createMesh.H"
48     forAll(timeDirs, timeI)
49     {
50         runTime.setTime(timeDirs[timeI], timeI);
51         Info<< "Time = " << runTime.timeName() << endl;
52         mesh.readUpdate();
54         volScalarField yPlus
55         (
56             IOobject
57             (
58                 "yPlus",
59                 runTime.timeName(),
60                 mesh,
61                 IOobject::NO_READ,
62                 IOobject::NO_WRITE
63             ),
64             mesh,
65             dimensionedScalar("yPlus", dimless, 0.0)
66         );
68         Info<< "Reading field U\n" << endl;
69         volVectorField U
70         (
71             IOobject
72             (
73                 "U",
74                 runTime.timeName(),
75                 mesh,
76                 IOobject::MUST_READ,
77                 IOobject::NO_WRITE
78             ),
79             mesh
80         );
82 #       include "createPhi.H"
84         singlePhaseTransportModel laminarTransport(U, phi);
86         autoPtr<incompressible::LESModel> sgsModel
87         (
88             incompressible::LESModel::New(U, phi, laminarTransport)
89         );
91         volScalarField::GeometricBoundaryField d = nearWallDist(mesh).y();
92         volScalarField nuEff = sgsModel->nuEff();
94         const fvPatchList& patches = mesh.boundary();
96         forAll(patches, patchi)
97         {
98             const fvPatch& currPatch = patches[patchi];
100             if (typeid(currPatch) == typeid(wallFvPatch))
101             {
102                 yPlus.boundaryField()[patchi] =
103                     d[patchi]
104                    *sqrt
105                     (
106                         nuEff.boundaryField()[patchi]
107                        *mag(U.boundaryField()[patchi].snGrad())
108                     )
109                    /sgsModel->nu().boundaryField()[patchi];
110                 const scalarField& Yp = yPlus.boundaryField()[patchi];
112                 Info<< "Patch " << patchi
113                     << " named " << currPatch.name()
114                     << " y+ : min: " << min(Yp) << " max: " << max(Yp)
115                     << " average: " << average(Yp) << nl << endl;
116             }
117         }
119         yPlus.write();
120     }
122     Info<< "End\n" << endl;
124     return 0;
128 // ************************************************************************* //