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-------------------------------------------------------------------------------
10License
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
26Application
27 engineCompRatio
28
29Group
30 grpPostProcessingUtilities
31
32Description
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
46int 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// ************************************************************************* //
dynamicFvMesh & mesh
engineTime & runTime
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
messageStream Info
Information stream (stdout output on master, null elsewhere)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
constexpr char nl
The newline '\n' character (0x0a)
Definition: Ostream.H:53