FreeFOAM The Cross-Platform CFD Toolkit
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 | 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  engineCompRatio
26 
27 Description
28  Calculate the geometric compression ratio.
29  Note that if you have valves and/or extra volumes it will not work,
30  since it calculates the volume at BDC and TCD.
31 
32 Usage
33 
34  - engineCompRatio [OPTIONS]
35 
36  @param -case <dir>\n
37  Case directory.
38 
39  @param -parallel \n
40  Run in parallel.
41 
42  @param -help \n
43  Display help message.
44 
45  @param -doc \n
46  Display Doxygen API documentation page for this application.
47 
48  @param -srcDoc \n
49  Display Doxygen source documentation page for this application.
50 
51 \*---------------------------------------------------------------------------*/
52 
53 #include <finiteVolume/fvCFD.H>
54 #include <engine/engineTime.H>
55 #include <engine/engineMesh.H>
56 
57 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
58 
59 int main(int argc, char *argv[])
60 {
61  #include <OpenFOAM/setRootCase.H>
62  #include <engine/createEngineTime.H>
63  #include <engine/createEngineMesh.H>
64 
65  // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
66 
67  scalar eps = 1.0e-10;
68  scalar fullCycle = 360.0;
69 
70  scalar ca0 = -180.0;
71  scalar ca1 = 0.0;
72 
73  while (runTime.theta() > ca0)
74  {
75  ca0 += fullCycle;
76  ca1 += fullCycle;
77  }
78 
79  while (mag(runTime.theta() - ca0) > eps)
80  {
81  scalar t0 = runTime.userTimeToTime(ca0 - runTime.theta());
82  runTime.setDeltaT(t0);
83  runTime++;
84  Info<< "CA = " << runTime.theta() << endl;
85  mesh.move();
86  }
87 
88  scalar Vmax = sum(mesh.V().field());
89 
90  while (mag(runTime.theta()-ca1) > eps)
91  {
92  scalar t1 = runTime.userTimeToTime(ca1-runTime.theta());
93  runTime.setDeltaT(t1);
94  runTime++;
95  Info<< "CA = " << runTime.theta() << endl;
96  mesh.move();
97  }
98 
99  scalar Vmin = sum(mesh.V().field());
100 
101  Info<< "\nVmax = " << Vmax;
102  Info<< ", Vmin = " << Vmin << endl;
103  Info<< "Vmax/Vmin = " << Vmax/Vmin << endl;
104  Info<< "\nEnd" << endl;
105 
106  return 0;
107 }
108 
109 
110 // ************************ vim: set sw=4 sts=4 et: ************************ //