From 9a7ca2b98898f957039ae43f6ac266fcb46b6f9d Mon Sep 17 00:00:00 2001 From: henry <Henry Weller h.weller@opencfd.co.uk> Date: Wed, 13 Aug 2008 12:40:14 +0100 Subject: [PATCH] Added pimpleFoam to the collection. --- .../incompressible/pimpleFoam/Make/files | 3 + .../incompressible/pimpleFoam/Make/options | 10 ++ .../solvers/incompressible/pimpleFoam/UEqn.H | 36 +++++++ .../incompressible/pimpleFoam/createFields.H | 42 +++++++++ .../solvers/incompressible/pimpleFoam/pEqn.H | 53 +++++++++++ .../incompressible/pimpleFoam/pimpleFoam.C | 93 +++++++++++++++++++ 6 files changed, 237 insertions(+) create mode 100644 applications/solvers/incompressible/pimpleFoam/Make/files create mode 100644 applications/solvers/incompressible/pimpleFoam/Make/options create mode 100644 applications/solvers/incompressible/pimpleFoam/UEqn.H create mode 100644 applications/solvers/incompressible/pimpleFoam/createFields.H create mode 100644 applications/solvers/incompressible/pimpleFoam/pEqn.H create mode 100644 applications/solvers/incompressible/pimpleFoam/pimpleFoam.C diff --git a/applications/solvers/incompressible/pimpleFoam/Make/files b/applications/solvers/incompressible/pimpleFoam/Make/files new file mode 100644 index 00000000000..92943d3370c --- /dev/null +++ b/applications/solvers/incompressible/pimpleFoam/Make/files @@ -0,0 +1,3 @@ +pimpleFoam.C + +EXE = $(FOAM_USER_APPBIN)/pimpleFoam diff --git a/applications/solvers/incompressible/pimpleFoam/Make/options b/applications/solvers/incompressible/pimpleFoam/Make/options new file mode 100644 index 00000000000..8a31f7e5abb --- /dev/null +++ b/applications/solvers/incompressible/pimpleFoam/Make/options @@ -0,0 +1,10 @@ +EXE_INC = \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/turbulenceModels/RAS \ + -I$(LIB_SRC)/transportModels + +EXE_LIBS = \ + -lincompressibleRASModels \ + -lincompressibleTransportModels \ + -lfiniteVolume \ + -lmeshTools diff --git a/applications/solvers/incompressible/pimpleFoam/UEqn.H b/applications/solvers/incompressible/pimpleFoam/UEqn.H new file mode 100644 index 00000000000..12b4260e5df --- /dev/null +++ b/applications/solvers/incompressible/pimpleFoam/UEqn.H @@ -0,0 +1,36 @@ +// Solve the Momentum equation + +tmp<fvVectorMatrix> UEqn +( + fvm::ddt(U) + + fvm::div(phi, U) + + turbulence->divDevReff(U) +); + +if (oCorr == nOuterCorr-1) +{ + UEqn().relax(1); +} +else +{ + UEqn().relax(); +} + +volScalarField rUA = 1.0/UEqn().A(); + +if (momentumPredictor) +{ + if (oCorr == nOuterCorr-1) + { + solve(UEqn() == -fvc::grad(p), mesh.solver("UFinal")); + } + else + { + solve(UEqn() == -fvc::grad(p)); + } +} +else +{ + U = rUA*(UEqn().H() - fvc::grad(p)); + U.correctBoundaryConditions(); +} diff --git a/applications/solvers/incompressible/pimpleFoam/createFields.H b/applications/solvers/incompressible/pimpleFoam/createFields.H new file mode 100644 index 00000000000..7c81ab5baf4 --- /dev/null +++ b/applications/solvers/incompressible/pimpleFoam/createFields.H @@ -0,0 +1,42 @@ +Info<< "Reading field p\n" << endl; +volScalarField p +( + IOobject + ( + "p", + runTime.timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh +); + +Info<< "Reading field U\n" << endl; +volVectorField U +( + IOobject + ( + "U", + runTime.timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh +); + +#include "createPhi.H" + + +label pRefCell = 0; +scalar pRefValue = 0.0; +setRefCell(p, mesh.solutionDict().subDict("PISO"), pRefCell, pRefValue); + + +singlePhaseTransportModel laminarTransport(U, phi); + +autoPtr<incompressible::RASModel> turbulence +( + incompressible::RASModel::New(U, phi, laminarTransport) +); diff --git a/applications/solvers/incompressible/pimpleFoam/pEqn.H b/applications/solvers/incompressible/pimpleFoam/pEqn.H new file mode 100644 index 00000000000..41f99bb542d --- /dev/null +++ b/applications/solvers/incompressible/pimpleFoam/pEqn.H @@ -0,0 +1,53 @@ +U = rUA*UEqn().H(); + +if (nCorr <= 1) +{ + UEqn.clear(); +} + +phi = (fvc::interpolate(U) & mesh.Sf()) + + fvc::ddtPhiCorr(rUA, U, phi); + +adjustPhi(phi, U, p); + +// Non-orthogonal pressure corrector loop +for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) +{ + // Pressure corrector + fvScalarMatrix pEqn + ( + fvm::laplacian(rUA, p) == fvc::div(phi) + ); + + pEqn.setReference(pRefCell, pRefValue); + + if + ( + oCorr == nOuterCorr-1 + && corr == nCorr-1 + && nonOrth == nNonOrthCorr + ) + { + pEqn.solve(mesh.solver("pFinal")); + } + else + { + pEqn.solve(); + } + + if (nonOrth == nNonOrthCorr) + { + phi -= pEqn.flux(); + } +} + +#include "continuityErrs.H" + +// Explicitly relax pressure for momentum corrector except for last corrector +if (oCorr != nOuterCorr-1) +{ + p.relax(); +} + +U -= rUA*fvc::grad(p); +U.correctBoundaryConditions(); diff --git a/applications/solvers/incompressible/pimpleFoam/pimpleFoam.C b/applications/solvers/incompressible/pimpleFoam/pimpleFoam.C new file mode 100644 index 00000000000..f3c16142393 --- /dev/null +++ b/applications/solvers/incompressible/pimpleFoam/pimpleFoam.C @@ -0,0 +1,93 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Application + pimpleFoam + +Description + Large time-step transient solver for incompressible, turbulent flow using + the PIMPLE (merged PISO-SIMPLE) algorithm. + +\*---------------------------------------------------------------------------*/ + +#include "fvCFD.H" +#include "incompressible/singlePhaseTransportModel/singlePhaseTransportModel.H" +#include "incompressible/RASModel/RASModel.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +int main(int argc, char *argv[]) +{ + #include "setRootCase.H" + #include "createTime.H" + #include "createMesh.H" + #include "createFields.H" + #include "initContinuityErrs.H" + + Info<< "\nStarting time loop\n" << endl; + + while (runTime.run()) + { + #include "readTimeControls.H" + #include "readPIMPLEControls.H" + #include "CourantNo.H" + #include "setDeltaT.H" + + runTime++; + + Info<< "Time = " << runTime.timeName() << nl << endl; + + if (nOuterCorr != 1) + { + p.storePrevIter(); + } + + // --- Pressure-velocity PIMPLE corrector loop + for (int oCorr=0; oCorr<nOuterCorr; oCorr++) + { + #include "UEqn.H" + + // --- PISO loop + for (int corr=0; corr<nCorr; corr++) + { + #include "pEqn.H" + } + + turbulence->correct(); + } + + runTime.write(); + + Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" + << " ClockTime = " << runTime.elapsedClockTime() << " s" + << nl << endl; + } + + Info<< "End\n" << endl; + + return 0; +} + + +// ************************************************************************* // -- GitLab