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

sonicDyMFoam.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     sonicDyMFoam
00027 
00028 Description
00029     Transient solver for trans-sonic/supersonic, laminar or turbulent flow
00030     of a compressible gas with mesh motion..
00031 
00032 \*---------------------------------------------------------------------------*/
00033 
00034 #include "fvCFD.H"
00035 #include "basicPsiThermo.H"
00036 #include "turbulenceModel.H"
00037 #include "motionSolver.H"
00038 
00039 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00040 
00041 int main(int argc, char *argv[])
00042 {
00043     #include "setRootCase.H"
00044     #include "createTime.H"
00045     #include "createMesh.H"
00046     #include "createFields.H"
00047     #include "initContinuityErrs.H"
00048 
00049     // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00050 
00051     Info<< "\nStarting time loop\n" << endl;
00052 
00053     autoPtr<Foam::motionSolver> motionPtr = motionSolver::New(mesh);
00054 
00055     while (runTime.loop())
00056     {
00057         Info<< "Time = " << runTime.timeName() << nl << endl;
00058 
00059         #include "readPISOControls.H"
00060         #include "compressibleCourantNo.H"
00061 
00062         mesh.movePoints(motionPtr->newPoints());
00063 
00064         #include "rhoEqn.H"
00065 
00066         fvVectorMatrix UEqn
00067         (
00068             fvm::ddt(rho, U)
00069           + fvm::div(phi, U)
00070           + turbulence->divDevRhoReff(U)
00071         );
00072 
00073         solve(UEqn == -fvc::grad(p));
00074 
00075         #include "eEqn.H"
00076 
00077 
00078         // --- PISO loop
00079 
00080         for (int corr=0; corr<nCorr; corr++)
00081         {
00082             U = UEqn.H()/UEqn.A();
00083 
00084             surfaceScalarField phid
00085             (
00086                 "phid",
00087                 fvc::interpolate(psi)
00088                *(
00089                     (fvc::interpolate(U) & mesh.Sf()) - fvc::meshPhi(rho, U)
00090                 )
00091             );
00092 
00093             for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
00094             {
00095                 fvScalarMatrix pEqn
00096                 (
00097                     fvm::ddt(psi, p)
00098                   + fvm::div(phid, p)
00099                   - fvm::laplacian(rho/UEqn.A(), p)
00100                 );
00101 
00102                 pEqn.solve();
00103 
00104                 phi = pEqn.flux();
00105             }
00106 
00107             #include "compressibleContinuityErrs.H"
00108 
00109             U -= fvc::grad(p)/UEqn.A();
00110             U.correctBoundaryConditions();
00111         }
00112 
00113         DpDt = fvc::DDt
00114         (
00115             surfaceScalarField
00116             (
00117                 "phiU",
00118                 phi/fvc::interpolate(rho) + fvc::meshPhi(rho, U)
00119             ),
00120             p
00121         );
00122 
00123         turbulence->correct();
00124 
00125         rho = psi*p;
00126 
00127         runTime.write();
00128 
00129         Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
00130             << "  ClockTime = " << runTime.elapsedClockTime() << " s"
00131             << nl << endl;
00132     }
00133 
00134     Info<< "End\n" << endl;
00135 
00136     return 0;
00137 }
00138 
00139 
00140 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd