OpenFOAM: API Guide
v2112
The open source CFD toolbox
engineCompRatio.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 | www.openfoam.com
6
\\/ M anipulation |
7
-------------------------------------------------------------------------------
8
Copyright (C) 2011-2013 OpenFOAM Foundation
9
-------------------------------------------------------------------------------
10
License
11
This file is part of OpenFOAM.
12
13
OpenFOAM is free software: you can redistribute it and/or modify it
14
under the terms of the GNU General Public License as published by
15
the Free Software Foundation, either version 3 of the License, or
16
(at your option) any later version.
17
18
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21
for more details.
22
23
You should have received a copy of the GNU General Public License
24
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26
Application
27
engineCompRatio
28
29
Group
30
grpPostProcessingUtilities
31
32
Description
33
Calculate the engine geometric compression ratio.
34
35
Note: if you have valves and/or extra volumes it will not work,
36
since it calculates the volume at BDC and TCD.
37
38
\*---------------------------------------------------------------------------*/
39
40
#include "
fvCFD.H
"
41
#include "
engineTime.H
"
42
#include "
engineMesh.H
"
43
44
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45
46
int
main(
int
argc,
char
*argv[])
47
{
48
argList::addNote
49
(
50
"Calculate the engine geometric compression ratio"
51
);
52
53
#include "
setRootCase.H
"
54
#include "
createEngineTime.H
"
55
#include "
createEngineMesh.H
"
56
57
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
58
59
scalar eps = 1.0e-10;
60
scalar fullCycle = 360.0;
61
62
scalar ca0 = -180.0;
63
scalar ca1 = 0.0;
64
65
while
(
runTime
.theta() > ca0)
66
{
67
ca0 += fullCycle;
68
ca1 += fullCycle;
69
}
70
71
while
(
mag
(
runTime
.theta() - ca0) > eps)
72
{
73
scalar t0 =
runTime
.userTimeToTime(ca0 -
runTime
.theta());
74
runTime
.setDeltaT(t0);
75
++
runTime
;
76
Info
<<
"CA = "
<<
runTime
.theta() <<
endl
;
77
mesh
.move();
78
}
79
80
scalar Vmax =
sum
(
mesh
.V().field());
81
82
while
(
mag
(
runTime
.theta() - ca1) > eps)
83
{
84
scalar t1 =
runTime
.userTimeToTime(ca1 -
runTime
.theta());
85
runTime
.setDeltaT(t1);
86
++
runTime
;
87
Info
<<
"CA = "
<<
runTime
.theta() <<
endl
;
88
mesh
.move();
89
}
90
91
scalar Vmin =
sum
(
mesh
.V().field());
92
93
Info
<<
"\nVmax = "
<< Vmax
94
<<
", Vmin = "
<< Vmin <<
nl
95
<<
"Vmax/Vmin = "
<< Vmax/Vmin <<
endl
;
96
97
Info
<<
"\nEnd\n"
<<
endl
;
98
99
return
0;
100
}
101
102
103
// ************************************************************************* //
createEngineTime.H
runTime
engineTime & runTime
Definition:
createEngineTime.H:13
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition:
Ostream.H:369
Foam::Info
messageStream Info
Information stream (stdout output on master, null elsewhere)
createEngineMesh.H
engineMesh.H
mesh
dynamicFvMesh & mesh
Definition:
createDynamicFvMesh.H:6
setRootCase.H
Foam::nl
constexpr char nl
Definition:
Ostream.H:404
engineTime.H
Foam::mag
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Foam::sum
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
Definition:
DimensionedFieldFunctions.C:327
fvCFD.H
applications
utilities
postProcessing
miscellaneous
engineCompRatio
engineCompRatio.C
Generated by
1.8.17
OPENFOAM® is a registered
trademark
of OpenCFD Ltd.