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

rhoSonicFoam.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     rhoSonicFoam
00027 
00028 Description
00029     Density-based compressible flow solver.
00030 
00031 \*---------------------------------------------------------------------------*/
00032 
00033 #include "fvCFD.H"
00034 
00035 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00036 
00037 int main(int argc, char *argv[])
00038 {
00039 
00040 #   include "setRootCase.H"
00041 #   include "createTime.H"
00042 #   include "createMesh.H"
00043 #   include "readThermodynamicProperties.H"
00044 #   include "createFields.H"
00045 
00046 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00047 
00048     Info<< "\nStarting time loop\n" << endl;
00049 
00050     while (runTime.loop())
00051     {
00052         Info<< "Time = " << runTime.timeName() << nl << endl;
00053 
00054         surfaceScalarField phiv
00055         (
00056             IOobject
00057             (
00058                 "phiv",
00059                 runTime.timeName(),
00060                 mesh,
00061                 IOobject::NO_READ,
00062                 IOobject::NO_WRITE
00063             ),
00064             fvc::interpolate(rhoU)/fvc::interpolate(rho) & mesh.Sf()
00065         );
00066 
00067         scalar CoNum = max
00068         (
00069             mesh.surfaceInterpolation::deltaCoeffs()
00070            *mag(phiv)/mesh.magSf()
00071         ).value()*runTime.deltaT().value();
00072 
00073         Info<< "\nMax Courant Number = " << CoNum << endl;
00074 
00075         solve
00076         (
00077             fvm::ddt(rho)
00078           + fvm::div(phiv, rho)
00079         );
00080 
00081         p = rho/psi;
00082 
00083         solve
00084         (
00085             fvm::ddt(rhoU)
00086           + fvm::div(phiv, rhoU)
00087          == 
00088           - fvc::grad(p)
00089         );
00090 
00091         U == rhoU/rho;
00092 
00093         surfaceScalarField phiv2
00094         (
00095             IOobject
00096             (
00097                 "phiv2",
00098                 runTime.timeName(),
00099                 mesh,
00100                 IOobject::NO_READ,
00101                 IOobject::NO_WRITE
00102             ),
00103             fvc::interpolate(rhoU)/fvc::interpolate(rho) & mesh.Sf()
00104         );
00105 
00106         solve
00107         (
00108             fvm::ddt(rhoE)
00109           + fvm::div(phiv, rhoE)
00110          ==
00111           - fvc::div(phiv2, p)
00112         );
00113 
00114         T = (rhoE - 0.5*rho*magSqr(rhoU/rho))/Cv/rho;
00115         psi = 1.0/(R*T);
00116 
00117         runTime.write();
00118 
00119         Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
00120             << "  ClockTime = " << runTime.elapsedClockTime() << " s"
00121             << nl << endl;
00122     }
00123 
00124     Info<< "End\n" << endl;
00125 
00126     return 0;
00127 }
00128 
00129 
00130 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd