Home
Downloads
Documentation
Installation
User Guide
man-pages
API Documentation
README
Release Notes
Changes
License
Support
SourceForge Project
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
applications
utilities
postProcessing
miscellaneous
ptot
ptot.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
ptot
26
27
Description
28
For each time: calculate the total pressure.
29
30
Usage
31
32
- ptot [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
71
# include <
OpenFOAM/setRootCase.H
>
72
# include <
OpenFOAM/createTime.H
>
73
74
instantList
timeDirs
= timeSelector::select0(runTime,
args
);
75
76
# include <
OpenFOAM/createMesh.H
>
77
78
forAll
(timeDirs, timeI)
79
{
80
runTime.setTime(timeDirs[timeI], timeI);
81
82
Info
<<
"Time = "
<< runTime.timeName() <<
endl
;
83
84
IOobject
pheader
85
(
86
"p"
,
87
runTime.timeName(),
88
mesh
,
89
IOobject::MUST_READ
90
);
91
92
IOobject
Uheader
93
(
94
"U"
,
95
runTime.timeName(),
96
mesh
,
97
IOobject::MUST_READ
98
);
99
100
101
// Check p and U exist
102
if
(pheader.headerOk() && Uheader.headerOk())
103
{
104
mesh
.
readUpdate
();
105
106
Info
<<
" Reading p"
<<
endl
;
107
volScalarField
p
(pheader,
mesh
);
108
109
Info
<<
" Reading U"
<<
endl
;
110
volVectorField
U
(Uheader,
mesh
);
111
112
Info
<<
" Calculating ptot"
<<
endl
;
113
if
(
p
.dimensions() ==
dimensionSet
(0, 2, -2, 0, 0))
114
{
115
volScalarField
ptot
116
(
117
IOobject
118
(
119
"ptot"
,
120
runTime.timeName(),
121
mesh
,
122
IOobject::NO_READ
123
),
124
p
+ 0.5*
magSqr
(
U
)
125
);
126
ptot.
write
();
127
}
128
else
129
{
130
IOobject
rhoheader
131
(
132
"rho"
,
133
runTime.timeName(),
134
mesh
,
135
IOobject::MUST_READ
136
);
137
138
// Check rho exists
139
if
(rhoheader.headerOk())
140
{
141
Info
<<
" Reading rho"
<<
endl
;
142
volScalarField
rho
(rhoheader,
mesh
);
143
144
volScalarField
ptot
145
(
146
IOobject
147
(
148
"ptot"
,
149
runTime.timeName(),
150
mesh
,
151
IOobject::NO_READ
152
),
153
p
+ 0.5*
rho
*
magSqr
(
U
)
154
);
155
ptot.
write
();
156
}
157
else
158
{
159
Info
<<
" No rho"
<<
endl
;
160
}
161
}
162
}
163
else
164
{
165
Info
<<
" No p or U"
<<
endl
;
166
}
167
168
Info
<<
endl
;
169
}
170
171
return
0;
172
}
173
174
175
// ************************ vim: set sw=4 sts=4 et: ************************ //