Initial commit for version 2.0.x patch release
[OpenFOAM-2.0.x.git] / applications / solvers / combustion / dieselEngineFoam / dieselEngineFoam.C
blob94ab9289994012cf5e2a769e94826aecaf59c5b7
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2004-2011 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
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.
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.
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/>.
24 Application
25     dieselEngineFoam
27 Description
28     Solver for diesel engine spray and combustion.
30 \*---------------------------------------------------------------------------*/
32 #include "fvCFD.H"
33 #include "engineTime.H"
34 #include "engineMesh.H"
35 #include "hCombustionThermo.H"
36 #include "turbulenceModel.H"
37 #include "spray.H"
38 #include "psiChemistryModel.H"
39 #include "chemistrySolver.H"
40 #include "multivariateScheme.H"
41 #include "Switch.H"
42 #include "OFstream.H"
43 #include "volPointInterpolation.H"
44 #include "thermoPhysicsTypes.H"
45 #include "mathematicalConstants.H"
46 #include "pimpleControl.H"
48 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50 int main(int argc, char *argv[])
52     #include "setRootCase.H"
53     #include "createEngineTime.H"
54     #include "createEngineMesh.H"
55     #include "createFields.H"
56     #include "readGravitationalAcceleration.H"
57     #include "readCombustionProperties.H"
58     #include "createSpray.H"
59     #include "initContinuityErrs.H"
60     #include "readEngineTimeControls.H"
61     #include "compressibleCourantNo.H"
62     #include "setInitialDeltaT.H"
63     #include "startSummary.H"
65     pimpleControl pimple(mesh);
67     // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
69     Info<< "\nStarting time loop\n" << endl;
71     while (runTime.run())
72     {
73         #include "readEngineTimeControls.H"
74         #include "compressibleCourantNo.H"
75         #include "setDeltaT.H"
77         runTime++;
79         Info<< "Crank angle = " << runTime.theta() << " CA-deg" << endl;
81         mesh.move();
83         dieselSpray.evolve();
85         Info<< "Solving chemistry" << endl;
87         chemistry.solve
88         (
89             runTime.value() - runTime.deltaTValue(),
90             runTime.deltaTValue()
91         );
93         // turbulent time scale
94         {
95             volScalarField tk
96             (
97                 Cmix*sqrt(turbulence->muEff()/rho/turbulence->epsilon())
98             );
99             volScalarField tc(chemistry.tc());
101             // Chalmers PaSR model
102             kappa = (runTime.deltaT() + tc)/(runTime.deltaT() + tc + tk);
103         }
105         chemistrySh = kappa*chemistry.Sh()();
108         #include "rhoEqn.H"
110         for (pimple.start(); pimple.loop(); pimple++)
111         {
112             #include "UEqn.H"
113             #include "YEqn.H"
114             #include "hsEqn.H"
116             // --- PISO loop
117             for (int corr=1; corr<=pimple.nCorr(); corr++)
118             {
119                 #include "pEqn.H"
120             }
122             if (pimple.turbCorr())
123             {
124                 turbulence->correct();
125             }
126         }
128         #include "logSummary.H"
129         #include "spraySummary.H"
131         rho = thermo.rho();
133         if (runTime.write())
134         {
135             chemistry.dQ()().write();
136         }
138         Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
139             << "  ClockTime = " << runTime.elapsedClockTime() << " s"
140             << nl << endl;
141     }
143     Info<< "End\n" << endl;
145     return 0;
149 // ************************************************************************* //