OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

yPlusLES.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 Application
00026     yPlusLES
00027 
00028 Description
00029     Calculates and reports yPlus for all wall patches, for the specified times.
00030 
00031 \*---------------------------------------------------------------------------*/
00032 
00033 #include "fvCFD.H"
00034 #include "incompressible/singlePhaseTransportModel/singlePhaseTransportModel.H"
00035 #include "LESModel.H"
00036 #include "nearWallDist.H"
00037 #include "wallDist.H"
00038 
00039 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00040 
00041 int main(int argc, char *argv[])
00042 {
00043     timeSelector::addOptions();
00044     #include "setRootCase.H"
00045 #   include "createTime.H"
00046     instantList timeDirs = timeSelector::select0(runTime, args);
00047 #   include "createMesh.H"
00048 
00049     forAll(timeDirs, timeI)
00050     {
00051         runTime.setTime(timeDirs[timeI], timeI);
00052         Info<< "Time = " << runTime.timeName() << endl;
00053         fvMesh::readUpdateState state = mesh.readUpdate();
00054 
00055         // Wall distance
00056         if (timeI == 0 || state != fvMesh::UNCHANGED)
00057         {
00058             Info<< "Calculating wall distance\n" << endl;
00059             wallDist y(mesh, true);
00060             Info<< "Writing wall distance to field "
00061                 << y.name() << nl << endl;
00062             y.write();
00063         }
00064 
00065 
00066         volScalarField yPlus
00067         (
00068             IOobject
00069             (
00070                 "yPlus",
00071                 runTime.timeName(),
00072                 mesh,
00073                 IOobject::NO_READ,
00074                 IOobject::NO_WRITE
00075             ),
00076             mesh,
00077             dimensionedScalar("yPlus", dimless, 0.0)
00078         );
00079 
00080         Info<< "Reading field U\n" << endl;
00081         volVectorField U
00082         (
00083             IOobject
00084             (
00085                 "U",
00086                 runTime.timeName(),
00087                 mesh,
00088                 IOobject::MUST_READ,
00089                 IOobject::NO_WRITE
00090             ),
00091             mesh
00092         );
00093 
00094 #       include "createPhi.H"
00095 
00096         singlePhaseTransportModel laminarTransport(U, phi);
00097 
00098         autoPtr<incompressible::LESModel> sgsModel
00099         (
00100             incompressible::LESModel::New(U, phi, laminarTransport)
00101         );
00102 
00103         volScalarField::GeometricBoundaryField d = nearWallDist(mesh).y();
00104         volScalarField nuEff = sgsModel->nuEff();
00105 
00106         const fvPatchList& patches = mesh.boundary();
00107 
00108         forAll(patches, patchi)
00109         {
00110             const fvPatch& currPatch = patches[patchi];
00111 
00112             if (typeid(currPatch) == typeid(wallFvPatch))
00113             {
00114                 yPlus.boundaryField()[patchi] =
00115                     d[patchi]
00116                    *sqrt
00117                     (
00118                         nuEff.boundaryField()[patchi]
00119                        *mag(U.boundaryField()[patchi].snGrad())
00120                     )
00121                    /sgsModel->nu().boundaryField()[patchi];
00122                 const scalarField& Yp = yPlus.boundaryField()[patchi];
00123 
00124                 Info<< "Patch " << patchi
00125                     << " named " << currPatch.name()
00126                     << " y+ : min: " << min(Yp) << " max: " << max(Yp)
00127                     << " average: " << average(Yp) << nl << endl;
00128             }
00129         }
00130 
00131         Info<< "Writing yPlus to field "
00132             << yPlus.name() << nl << endl;
00133 
00134         yPlus.write();
00135     }
00136 
00137     Info<< "End\n" << endl;
00138 
00139     return 0;
00140 }
00141 
00142 
00143 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd