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) 2011-2015 OpenFOAM Foundation
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 \*---------------------------------------------------------------------------*/
32 
33 #include "fvCFD.H"
34 
35 
36 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
37 
38 int main(int argc, char *argv[])
39 {
40  timeSelector::addOptions();
41  #include "addRegionOption.H"
42 
43  #include "setRootCase.H"
44  #include "createTime.H"
45 
46  instantList timeDirs = timeSelector::select0(runTime, args);
47 
48  #include "createNamedMesh.H"
49 
50  runTime.setTime(timeDirs.last(), timeDirs.size()-1);
51 
52  volScalarField pMean
53  (
54  IOobject
55  (
56  "pMean",
57  runTime.timeName(),
58  mesh,
59  IOobject::MUST_READ
60  ),
61  mesh
62  );
63 
64  forAll(timeDirs, timeI)
65  {
66  runTime.setTime(timeDirs[timeI], timeI);
67 
68  Info<< "Time = " << runTime.timeName() << endl;
69 
70  IOobject pheader
71  (
72  "p",
73  runTime.timeName(),
74  mesh,
75  IOobject::MUST_READ
76  );
77 
78  // Check p exists
79  if (pheader.headerOk())
80  {
81  mesh.readUpdate();
82 
83  Info<< " Reading p" << endl;
84  volScalarField p(pheader, mesh);
85 
86  Info<< " Calculating pPrime2" << endl;
87  volScalarField pPrime2
88  (
89  IOobject
90  (
91  "pPrime2",
92  runTime.timeName(),
93  mesh,
94  IOobject::NO_READ
95  ),
96  sqr(p - pMean)
97  );
98  pPrime2.write();
99  }
100  else
101  {
102  Info<< " No p" << endl;
103  }
104 
105  Info<< endl;
106  }
107 
108  Info<< nl << "End" << nl << endl;
109 
110  return 0;
111 }
112 
113 
114 // ************************************************************************* //
p
p
Definition: pEqn.H:62
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::instantList
List< instant > instantList
List of instants.
Definition: instantList.H:42
Foam::nl
static const char nl
Definition: Ostream.H:260
Foam::Info
messageStream Info
addRegionOption.H
main
int main(int argc, char *argv[])
Definition: postCalc.C:54
Foam::volScalarField
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:52
createNamedMesh.H
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
setRootCase.H
timeDirs
static instantList timeDirs
Definition: globalFoam.H:44
Foam::sqr
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Definition: dimensionedSymmTensor.C:49
createTime.H
fvCFD.H
args
Foam::argList args(argc, argv)