FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

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-2010 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
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your 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, see <http://www.gnu.org/licenses/>.
00023 
00024 Application
00025     engineCompRatio
00026 
00027 Description
00028     Calculate the geometric compression ratio.
00029     Note that if you have valves and/or extra volumes it will not work,
00030     since it calculates the volume at BDC and TCD.
00031 
00032 Usage
00033 
00034     - engineCompRatio [OPTIONS]
00035 
00036     @param -case <dir>\n
00037     Case directory.
00038 
00039     @param -parallel \n
00040     Run in parallel.
00041 
00042     @param -help \n
00043     Display help message.
00044 
00045     @param -doc \n
00046     Display Doxygen API documentation page for this application.
00047 
00048     @param -srcDoc \n
00049     Display Doxygen source documentation page for this application.
00050 
00051 \*---------------------------------------------------------------------------*/
00052 
00053 #include <finiteVolume/fvCFD.H>
00054 #include <engine/engineTime.H>
00055 #include <engine/engineMesh.H>
00056 
00057 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00058 
00059 int main(int argc, char *argv[])
00060 {
00061     #include <OpenFOAM/setRootCase.H>
00062     #include <engine/createEngineTime.H>
00063     #include <engine/createEngineMesh.H>
00064 
00065     // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00066 
00067     scalar eps = 1.0e-10;
00068     scalar fullCycle = 360.0;
00069 
00070     scalar ca0 = -180.0;
00071     scalar ca1 = 0.0;
00072 
00073     while (runTime.theta() > ca0)
00074     {
00075         ca0 += fullCycle;
00076         ca1 += fullCycle;
00077     }
00078 
00079     while (mag(runTime.theta() - ca0) > eps)
00080     {
00081         scalar t0 = runTime.userTimeToTime(ca0 - runTime.theta());
00082         runTime.setDeltaT(t0);
00083         runTime++;
00084         Info<< "CA = " << runTime.theta() << endl;
00085         mesh.move();
00086     }
00087 
00088     scalar Vmax = sum(mesh.V().field());
00089 
00090     while (mag(runTime.theta()-ca1) > eps)
00091     {
00092         scalar t1 = runTime.userTimeToTime(ca1-runTime.theta());
00093         runTime.setDeltaT(t1);
00094         runTime++;
00095         Info<< "CA = " << runTime.theta() << endl;
00096         mesh.move();
00097     }
00098 
00099     scalar Vmin = sum(mesh.V().field());
00100 
00101     Info<< "\nVmax = " << Vmax;
00102     Info<< ", Vmin = " << Vmin << endl;
00103     Info<< "Vmax/Vmin = " << Vmax/Vmin << endl;
00104     Info<< "\nEnd" << endl;
00105 
00106     return 0;
00107 }
00108 
00109 
00110 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines