From 36b4fa38115b2abad22082251ede0f3fe79a4e0a Mon Sep 17 00:00:00 2001 From: Vanja Skuric Date: Fri, 6 May 2016 22:11:03 +0200 Subject: [PATCH] Backported createTimeControls.H and readTimeControls.H from OF 3.0.1, and pimpleDyMFoam --- .../incompressible/pimpleDyMFoam/UEqn.H | 21 +++------- .../incompressible/pimpleDyMFoam/correctPhi.H | 4 +- .../pimpleDyMFoam/createControls.H | 11 +++++ .../pimpleDyMFoam/createFields.H | 1 + .../pimpleDyMFoam/pimpleDyMFoam.C | 41 ++++++++----------- .../pimpleDyMFoam/readControls.H | 15 ++----- .../general/include/createTimeControls.H | 41 +++++++++++++++++++ .../general/include/readTimeControls.H | 14 +++---- 8 files changed, 85 insertions(+), 63 deletions(-) create mode 100644 applications/solvers/incompressible/pimpleDyMFoam/createControls.H create mode 100644 src/finiteVolume/cfdTools/general/include/createTimeControls.H diff --git a/applications/solvers/incompressible/pimpleDyMFoam/UEqn.H b/applications/solvers/incompressible/pimpleDyMFoam/UEqn.H index 6aa608d3a..84c71fc36 100644 --- a/applications/solvers/incompressible/pimpleDyMFoam/UEqn.H +++ b/applications/solvers/incompressible/pimpleDyMFoam/UEqn.H @@ -5,23 +5,12 @@ + turbulence->divDevReff(U) ); - if (oCorr == nOuterCorr - 1) - { - if (mesh.solutionDict().relax("UFinal")) - { - UEqn.relax(mesh.solutionDict().relaxationFactor("UFinal")); - } - else - { - UEqn.relax(1); - } - } - else - { - UEqn.relax(); - } + UEqn.relax + ( + mesh.solutionDict().relaxationFactor(U.select(pimple.finalIter())) + ); - if (momentumPredictor) + if (pimple.momentumPredictor()) { solve(UEqn == -fvc::grad(p)); } diff --git a/applications/solvers/incompressible/pimpleDyMFoam/correctPhi.H b/applications/solvers/incompressible/pimpleDyMFoam/correctPhi.H index aa99200c4..6246f259f 100644 --- a/applications/solvers/incompressible/pimpleDyMFoam/correctPhi.H +++ b/applications/solvers/incompressible/pimpleDyMFoam/correctPhi.H @@ -37,7 +37,7 @@ mesh.schemesDict().setFluxRequired(pcorr.name()); - for(int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) + while (pimple.correctNonOrthogonal()) { fvScalarMatrix pcorrEqn ( @@ -47,7 +47,7 @@ pcorrEqn.setReference(pRefCell, pRefValue); pcorrEqn.solve(); - if (nonOrth == nNonOrthCorr) + if (pimple.finalNonOrthogonalIter()) { phi -= pcorrEqn.flux(); } diff --git a/applications/solvers/incompressible/pimpleDyMFoam/createControls.H b/applications/solvers/incompressible/pimpleDyMFoam/createControls.H new file mode 100644 index 000000000..ca5e25906 --- /dev/null +++ b/applications/solvers/incompressible/pimpleDyMFoam/createControls.H @@ -0,0 +1,11 @@ +#include "createTimeControls.H" + +bool correctPhi +( + pimple.dict().lookupOrDefault("correctPhi", false) +); + +bool checkMeshCourantNo +( + pimple.dict().lookupOrDefault("checkMeshCourantNo", false) +); diff --git a/applications/solvers/incompressible/pimpleDyMFoam/createFields.H b/applications/solvers/incompressible/pimpleDyMFoam/createFields.H index bc798ba98..1925b94be 100644 --- a/applications/solvers/incompressible/pimpleDyMFoam/createFields.H +++ b/applications/solvers/incompressible/pimpleDyMFoam/createFields.H @@ -33,6 +33,7 @@ label pRefCell = 0; scalar pRefValue = 0.0; setRefCell(p, mesh.solutionDict().subDict("PIMPLE"), pRefCell, pRefValue); + mesh.schemesDict().setFluxRequired(p.name()); singlePhaseTransportModel laminarTransport(U, phi); diff --git a/applications/solvers/incompressible/pimpleDyMFoam/pimpleDyMFoam.C b/applications/solvers/incompressible/pimpleDyMFoam/pimpleDyMFoam.C index 6c24eed98..1ae34775d 100644 --- a/applications/solvers/incompressible/pimpleDyMFoam/pimpleDyMFoam.C +++ b/applications/solvers/incompressible/pimpleDyMFoam/pimpleDyMFoam.C @@ -36,6 +36,7 @@ Description #include "singlePhaseTransportModel.H" #include "turbulenceModel.H" #include "dynamicFvMesh.H" +#include "pimpleControl.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -45,10 +46,12 @@ int main(int argc, char *argv[]) # include "createTime.H" # include "createDynamicFvMesh.H" -# include "readPIMPLEControls.H" + + pimpleControl pimple(mesh); + # include "initContinuityErrs.H" # include "createFields.H" -# include "readTimeControls.H" +# include "createControls.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -93,10 +96,9 @@ int main(int argc, char *argv[]) fvc::makeRelative(phi, U); // --- PIMPLE loop - label oCorr = 0; - do + while (pimple.loop()) { - if (nOuterCorr != 1) + if (!pimple.firstIter()) { p.storePrevIter(); } @@ -104,7 +106,7 @@ int main(int argc, char *argv[]) # include "UEqn.H" // --- PISO loop - for (int corr = 0; corr < nCorr; corr++) + while (pimple.correct()) { rAU = 1.0/UEqn.A(); @@ -114,7 +116,7 @@ int main(int argc, char *argv[]) adjustPhi(phi, U, p); - for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) + while (pimple.correctNonOrthogonal()) { fvScalarMatrix pEqn ( @@ -123,24 +125,15 @@ int main(int argc, char *argv[]) pEqn.setReference(pRefCell, pRefValue); - if + pEqn.solve ( -// oCorr == nOuterCorr - 1 - corr == nCorr - 1 - && nonOrth == nNonOrthCorr - ) - { - pEqn.solve + mesh.solutionDict().solver ( - mesh.solutionDict().solver(p.name() + "Final") - ); - } - else - { - pEqn.solve(mesh.solutionDict().solver(p.name())); - } + p.select(pimple.finalInnerIter()) + ) + ); - if (nonOrth == nNonOrthCorr) + if (pimple.finalNonOrthogonalIter()) { phi -= pEqn.flux(); } @@ -149,7 +142,7 @@ int main(int argc, char *argv[]) # include "continuityErrs.H" // Explicitly relax pressure for momentum corrector - if (oCorr != nOuterCorr - 1) + if (!pimple.finalIter()) { p.relax(); } @@ -164,7 +157,7 @@ int main(int argc, char *argv[]) } turbulence->correct(); - } while (++oCorr < nOuterCorr); + } runTime.write(); diff --git a/applications/solvers/incompressible/pimpleDyMFoam/readControls.H b/applications/solvers/incompressible/pimpleDyMFoam/readControls.H index 3bd20c5c5..9f982e260 100644 --- a/applications/solvers/incompressible/pimpleDyMFoam/readControls.H +++ b/applications/solvers/incompressible/pimpleDyMFoam/readControls.H @@ -1,14 +1,5 @@ -# include "readTimeControls.H" -# include "readPIMPLEControls.H" +#include "readTimeControls.H" - bool correctPhi = false; - if (pimple.found("correctPhi")) - { - correctPhi = Switch(pimple.lookup("correctPhi")); - } +correctPhi = pimple.dict().lookupOrDefault("correctPhi", false); - bool checkMeshCourantNo = false; - if (pimple.found("checkMeshCourantNo")) - { - checkMeshCourantNo = Switch(pimple.lookup("checkMeshCourantNo")); - } +checkMeshCourantNo = pimple.dict().lookupOrDefault("checkMeshCourantNo", false); diff --git a/src/finiteVolume/cfdTools/general/include/createTimeControls.H b/src/finiteVolume/cfdTools/general/include/createTimeControls.H new file mode 100644 index 000000000..b948f1955 --- /dev/null +++ b/src/finiteVolume/cfdTools/general/include/createTimeControls.H @@ -0,0 +1,41 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | foam-extend: Open Source CFD + \\ / O peration | Version: 3.2 + \\ / A nd | Web: http://www.foam-extend.org + \\/ M anipulation | For copyright notice see file Copyright +------------------------------------------------------------------------------- +License + This file is part of foam-extend. + + foam-extend 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 3 of the License, or (at your + option) any later version. + + foam-extend 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 foam-extend. If not, see . + +Global + readTimeControls + +Description + Read the control parameters used by setDeltaT + +\*---------------------------------------------------------------------------*/ + +bool adjustTimeStep = + runTime.controlDict().lookupOrDefault("adjustTimeStep", false); + +scalar maxCo = + runTime.controlDict().lookupOrDefault("maxCo", 1.0); + +scalar maxDeltaT = + runTime.controlDict().lookupOrDefault("maxDeltaT", GREAT); + +// ************************************************************************* // diff --git a/src/finiteVolume/cfdTools/general/include/readTimeControls.H b/src/finiteVolume/cfdTools/general/include/readTimeControls.H index 46a0d8504..4ea4ea232 100644 --- a/src/finiteVolume/cfdTools/general/include/readTimeControls.H +++ b/src/finiteVolume/cfdTools/general/include/readTimeControls.H @@ -29,17 +29,13 @@ Description \*---------------------------------------------------------------------------*/ -Switch adjustTimeStep -( - runTime.controlDict().lookup("adjustTimeStep") -); +adjustTimeStep = + runTime.controlDict().lookupOrDefault("adjustTimeStep", false); -scalar maxCo -( - readScalar(runTime.controlDict().lookup("maxCo")) -); +maxCo = + runTime.controlDict().lookupOrDefault("maxCo", 1.0); -scalar maxDeltaT = +maxDeltaT = runTime.controlDict().lookupOrDefault("maxDeltaT", GREAT); // ************************************************************************* //