FreeFOAM The Cross-Platform CFD Toolkit
pPrime2.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  pPrime2
26 
27 Description
28  Calculates and writes the scalar field of pPrime2 (sqr(p - pMean)) at
29  each time
30 
31 Usage
32 
33  - pPrime2 [OPTIONS]
34 
35  @param -noZero \n
36  Ignore timestep 0.
37 
38  @param -constant \n
39  Include the constant directory.
40 
41  @param -time <time>\n
42  Apply only to specific time.
43 
44  @param -latestTime \n
45  Only apply to latest time step.
46 
47  @param -case <dir>\n
48  Case directory.
49 
50  @param -parallel \n
51  Run in parallel.
52 
53  @param -help \n
54  Display help message.
55 
56  @param -doc \n
57  Display Doxygen API documentation page for this application.
58 
59  @param -srcDoc \n
60  Display Doxygen source documentation page for this application.
61 
62 \*---------------------------------------------------------------------------*/
63 
64 #include <finiteVolume/fvCFD.H>
65 
66 
67 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
68 
69 int main(int argc, char *argv[])
70 {
71  timeSelector::addOptions();
72 
73 # include <OpenFOAM/setRootCase.H>
74 # include <OpenFOAM/createTime.H>
75 
76  instantList timeDirs = timeSelector::select0(runTime, args);
77 
78 # include <OpenFOAM/createMesh.H>
79 
80  runTime.setTime(timeDirs[timeDirs.size()-1], timeDirs.size()-1);
81 
82  volScalarField pMean
83  (
84  IOobject
85  (
86  "pMean",
87  runTime.timeName(),
88  mesh,
89  IOobject::MUST_READ
90  ),
91  mesh
92  );
93 
94  forAll(timeDirs, timeI)
95  {
96  runTime.setTime(timeDirs[timeI], timeI);
97 
98  Info<< "Time = " << runTime.timeName() << endl;
99 
100  IOobject pheader
101  (
102  "p",
103  runTime.timeName(),
104  mesh,
105  IOobject::MUST_READ
106  );
107 
108  // Check p exists
109  if (pheader.headerOk())
110  {
111  mesh.readUpdate();
112 
113  Info<< " Reading p" << endl;
114  volScalarField p(pheader, mesh);
115 
116  Info<< " Calculating pPrime2" << endl;
117  volScalarField pPrime2
118  (
119  IOobject
120  (
121  "pPrime2",
122  runTime.timeName(),
123  mesh,
124  IOobject::NO_READ
125  ),
126  sqr(p - pMean)
127  );
128  pPrime2.write();
129  }
130  else
131  {
132  Info<< " No p" << endl;
133  }
134 
135  Info<< endl;
136  }
137 
138  return 0;
139 }
140 
141 
142 // ************************ vim: set sw=4 sts=4 et: ************************ //