FreeFOAM The Cross-Platform CFD Toolkit
yPlusLES.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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.
20 
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/>.
23 
24 Application
25  yPlusLES
26 
27 Description
28  Calculates and reports yPlus for all wall patches, for the specified times.
29 
30 Usage
31 
32  - yPlusLES [OPTIONS]
33 
34  @param -noZero \n
35  Ignore timestep 0.
36 
37  @param -constant \n
38  Include the constant directory.
39 
40  @param -time <time>\n
41  Apply only to specific time.
42 
43  @param -latestTime \n
44  Only apply to latest time step.
45 
46  @param -case <dir>\n
47  Case directory.
48 
49  @param -parallel \n
50  Run in parallel.
51 
52  @param -help \n
53  Display help message.
54 
55  @param -doc \n
56  Display Doxygen API documentation page for this application.
57 
58  @param -srcDoc \n
59  Display Doxygen source documentation page for this application.
60 
61 \*---------------------------------------------------------------------------*/
62 
63 #include <finiteVolume/fvCFD.H>
67 #include <finiteVolume/wallDist.H>
68 
69 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
70 
71 int main(int argc, char *argv[])
72 {
73  timeSelector::addOptions();
74  #include <OpenFOAM/setRootCase.H>
75 # include <OpenFOAM/createTime.H>
76  instantList timeDirs = timeSelector::select0(runTime, args);
77 # include <OpenFOAM/createMesh.H>
78 
79  forAll(timeDirs, timeI)
80  {
81  runTime.setTime(timeDirs[timeI], timeI);
82  Info<< "Time = " << runTime.timeName() << endl;
83  fvMesh::readUpdateState state = mesh.readUpdate();
84 
85  // Wall distance
86  if (timeI == 0 || state != fvMesh::UNCHANGED)
87  {
88  Info<< "Calculating wall distance\n" << endl;
89  wallDist y(mesh, true);
90  Info<< "Writing wall distance to field "
91  << y.name() << nl << endl;
92  y.write();
93  }
94 
95 
96  volScalarField yPlus
97  (
98  IOobject
99  (
100  "yPlus",
101  runTime.timeName(),
102  mesh,
103  IOobject::NO_READ,
104  IOobject::NO_WRITE
105  ),
106  mesh,
107  dimensionedScalar("yPlus", dimless, 0.0)
108  );
109 
110  Info<< "Reading field U\n" << endl;
112  (
113  IOobject
114  (
115  "U",
116  runTime.timeName(),
117  mesh,
118  IOobject::MUST_READ,
119  IOobject::NO_WRITE
120  ),
121  mesh
122  );
123 
124 # include <finiteVolume/createPhi.H>
125 
127 
129  (
130  incompressible::LESModel::New(U, phi, laminarTransport)
131  );
132 
133  volScalarField::GeometricBoundaryField d = nearWallDist(mesh).y();
134  volScalarField nuEff = sgsModel->nuEff();
135 
136  const fvPatchList& patches = mesh.boundary();
137 
138  forAll(patches, patchi)
139  {
140  const fvPatch& currPatch = patches[patchi];
141 
142  if (isA<wallFvPatch>(currPatch))
143  {
144  yPlus.boundaryField()[patchi] =
145  d[patchi]
146  *sqrt
147  (
148  nuEff.boundaryField()[patchi]
149  *mag(U.boundaryField()[patchi].snGrad())
150  )
151  /sgsModel->nu().boundaryField()[patchi];
152  const scalarField& Yp = yPlus.boundaryField()[patchi];
153 
154  Info<< "Patch " << patchi
155  << " named " << currPatch.name()
156  << " y+ : min: " << min(Yp) << " max: " << max(Yp)
157  << " average: " << average(Yp) << nl << endl;
158  }
159  }
160 
161  Info<< "Writing yPlus to field "
162  << yPlus.name() << nl << endl;
163 
164  yPlus.write();
165  }
166 
167  Info<< "End\n" << endl;
168 
169  return 0;
170 }
171 
172 
173 // ************************ vim: set sw=4 sts=4 et: ************************ //