FreeFOAM The Cross-Platform CFD Toolkit
wallGradU.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  wallGradU
26 
27 Description
28  Calculates and writes the gradient of U at the wall
29 
30 Usage
31 
32  - wallGradU [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>
64 
65 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
66 
67 int main(int argc, char *argv[])
68 {
69  timeSelector::addOptions();
70  #include <OpenFOAM/setRootCase.H>
71 # include <OpenFOAM/createTime.H>
72  instantList timeDirs = timeSelector::select0(runTime, args);
73 # include <OpenFOAM/createMesh.H>
74 
75  forAll(timeDirs, timeI)
76  {
77  runTime.setTime(timeDirs[timeI], timeI);
78  Info<< "Time = " << runTime.timeName() << endl;
79 
80  IOobject Uheader
81  (
82  "U",
83  runTime.timeName(),
84  mesh,
85  IOobject::MUST_READ
86  );
87 
88  // Check U exists
89  if (Uheader.headerOk())
90  {
91  mesh.readUpdate();
92 
93  Info<< " Reading U" << endl;
94  volVectorField U(Uheader, mesh);
95 
96  Info<< " Calculating wallGradU" << endl;
97 
98  volVectorField wallGradU
99  (
100  IOobject
101  (
102  "wallGradU",
103  runTime.timeName(),
104  mesh,
105  IOobject::NO_READ,
106  IOobject::AUTO_WRITE
107  ),
108  mesh,
110  (
111  "wallGradU",
112  U.dimensions()/dimLength,
113  vector::zero
114  )
115  );
116 
117  forAll(wallGradU.boundaryField(), patchi)
118  {
119  wallGradU.boundaryField()[patchi] =
120  -U.boundaryField()[patchi].snGrad();
121  }
122 
123  wallGradU.write();
124  }
125  else
126  {
127  Info<< " No U" << endl;
128  }
129  }
130 
131  Info<< "End" << endl;
132 
133  return 0;
134 }
135 
136 
137 // ************************ vim: set sw=4 sts=4 et: ************************ //