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

pimpleDyMFoam.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     pimpleDyMFoam.C
00027 
00028 Description
00029     Transient solver for incompressible, flow of Newtonian fluids
00030     on a moving mesh using the PIMPLE (merged PISO-SIMPLE) algorithm.
00031 
00032     Turbulence modelling is generic, i.e. laminar, RAS or LES may be selected.
00033 
00034 \*---------------------------------------------------------------------------*/
00035 
00036 #include "fvCFD.H"
00037 #include "singlePhaseTransportModel.H"
00038 #include "turbulenceModel.H"
00039 #include "dynamicFvMesh.H"
00040 
00041 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00042 
00043 int main(int argc, char *argv[])
00044 {
00045     #include "setRootCase.H"
00046 
00047     #include "createTime.H"
00048     #include "createDynamicFvMesh.H"
00049     #include "readPIMPLEControls.H"
00050     #include "initContinuityErrs.H"
00051     #include "createFields.H"
00052     #include "readTimeControls.H"
00053 
00054     // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00055 
00056     Info<< "\nStarting time loop\n" << endl;
00057 
00058     while (runTime.run())
00059     {
00060         #include "readControls.H"
00061         #include "CourantNo.H"
00062 
00063         // Make the fluxes absolute
00064         fvc::makeAbsolute(phi, U);
00065 
00066         #include "setDeltaT.H"
00067 
00068         runTime++;
00069 
00070         Info<< "Time = " << runTime.timeName() << nl << endl;
00071 
00072         mesh.update();
00073 
00074         if (mesh.changing() && correctPhi)
00075         {
00076             #include "correctPhi.H"
00077         }
00078 
00079         // Make the fluxes relative to the mesh motion
00080         fvc::makeRelative(phi, U);
00081 
00082         if (mesh.changing() && checkMeshCourantNo)
00083         {
00084             #include "meshCourantNo.H"
00085         }
00086 
00087         // --- PIMPLE loop
00088         for (int ocorr=0; ocorr<nOuterCorr; ocorr++)
00089         {
00090             if (nOuterCorr != 1)
00091             {
00092                 p.storePrevIter();
00093             }
00094 
00095             #include "UEqn.H"
00096 
00097             // --- PISO loop
00098             for (int corr=0; corr<nCorr; corr++)
00099             {
00100                 rAU = 1.0/UEqn.A();
00101 
00102                 U = rAU*UEqn.H();
00103                 phi = (fvc::interpolate(U) & mesh.Sf());
00104 
00105                 if (p.needReference())
00106                 {
00107                     fvc::makeRelative(phi, U);
00108                     adjustPhi(phi, U, p);
00109                     fvc::makeAbsolute(phi, U);
00110                 }
00111 
00112                 for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
00113                 {
00114                     fvScalarMatrix pEqn
00115                     (
00116                         fvm::laplacian(rAU, p) == fvc::div(phi)
00117                     );
00118 
00119                     pEqn.setReference(pRefCell, pRefValue);
00120 
00121                     if
00122                     (
00123                         ocorr == nOuterCorr-1
00124                      && corr == nCorr-1
00125                      && nonOrth == nNonOrthCorr)
00126                     {
00127                         pEqn.solve(mesh.solver(p.name() + "Final"));
00128                     }
00129                     else
00130                     {
00131                         pEqn.solve(mesh.solver(p.name()));
00132                     }
00133 
00134                     if (nonOrth == nNonOrthCorr)
00135                     {
00136                         phi -= pEqn.flux();
00137                     }
00138                 }
00139 
00140                 #include "continuityErrs.H"
00141 
00142                 // Explicitly relax pressure for momentum corrector
00143                 if (ocorr != nOuterCorr-1)
00144                 {
00145                     p.relax();
00146                 }
00147 
00148                 // Make the fluxes relative to the mesh motion
00149                 fvc::makeRelative(phi, U);
00150 
00151                 U -= rAU*fvc::grad(p);
00152                 U.correctBoundaryConditions();
00153             }
00154         }
00155 
00156         turbulence->correct();
00157 
00158         runTime.write();
00159 
00160         Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
00161             << "  ClockTime = " << runTime.elapsedClockTime() << " s"
00162             << nl << endl;
00163     }
00164 
00165     Info<< "End\n" << endl;
00166 
00167     return 0;
00168 }
00169 
00170 
00171 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd