OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

engineCompRatio.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 Application
00026     engineCompRatioFoam
00027 
00028 Description
00029     Calculate the geometric compression ratio.
00030     Note that if you have valves and/or extra volumes it will not work,
00031     since it calculates the volume at BDC and TCD.
00032 
00033 \*---------------------------------------------------------------------------*/
00034 
00035 #include "fvCFD.H"
00036 #include "engineTime.H"
00037 #include "engineMesh.H"
00038 
00039 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00040 
00041 int main(int argc, char *argv[])
00042 {
00043     #include "setRootCase.H"
00044     #include "createEngineTime.H"
00045     #include "createEngineMesh.H"
00046 
00047     // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00048 
00049     scalar eps = 1.0e-10;
00050     scalar fullCycle = 360.0;
00051 
00052     scalar ca0 = -180.0;
00053     scalar ca1 = 0.0;
00054 
00055     while (runTime.theta() > ca0)
00056     {
00057         ca0 += fullCycle;
00058         ca1 += fullCycle;
00059     }
00060 
00061     while (mag(runTime.theta() - ca0) > eps)
00062     {
00063         scalar t0 = runTime.userTimeToTime(ca0 - runTime.theta());
00064         runTime.setDeltaT(t0);
00065         runTime++;
00066         Info<< "CA = " << runTime.theta() << endl;
00067         mesh.move();
00068     }
00069 
00070     scalar Vmax = sum(mesh.V().field());
00071 
00072     while (mag(runTime.theta()-ca1) > eps)
00073     {
00074         scalar t1 = runTime.userTimeToTime(ca1-runTime.theta());
00075         runTime.setDeltaT(t1);
00076         runTime++;
00077         Info<< "CA = " << runTime.theta() << endl;
00078         mesh.move();
00079     }
00080 
00081     scalar Vmin = sum(mesh.V().field());
00082 
00083     Info<< "\nVmax = " << Vmax;
00084     Info<< ", Vmin = " << Vmin << endl;
00085     Info<< "Vmax/Vmin = " << Vmax/Vmin << endl;
00086     Info<< "\nEnd" << endl;
00087 
00088     return 0;
00089 }
00090 
00091 
00092 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd