diff --git a/applications/solvers/DNS/dnsFoam/createFields.H b/applications/solvers/DNS/dnsFoam/createFields.H index 36fc513e0..34a2b963f 100644 --- a/applications/solvers/DNS/dnsFoam/createFields.H +++ b/applications/solvers/DNS/dnsFoam/createFields.H @@ -27,3 +27,5 @@ ); # include "createPhi.H" + + mesh.schemesDict().setFluxRequired(p.name()); diff --git a/applications/solvers/DNS/dnsFoam/dnsFoam.C b/applications/solvers/DNS/dnsFoam/dnsFoam.C index 84e2f0fbb..6219abde1 100644 --- a/applications/solvers/DNS/dnsFoam/dnsFoam.C +++ b/applications/solvers/DNS/dnsFoam/dnsFoam.C @@ -35,6 +35,7 @@ Description #include "fft.H" #include "calcEk.H" #include "graph.H" +#include "pisoControl.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -44,6 +45,9 @@ int main(int argc, char *argv[]) #include "createTime.H" #include "createMeshNoClear.H" + + pisoControl piso(mesh); + #include "readTransportProperties.H" #include "createFields.H" #include "readTurbulenceProperties.H" @@ -57,8 +61,6 @@ int main(int argc, char *argv[]) { Info<< "Time = " << runTime.timeName() << nl << endl; - #include "readPISOControls.H" - force.internalField() = ReImSum ( fft::reverseTransform @@ -83,7 +85,7 @@ int main(int argc, char *argv[]) // --- PISO loop - for (int corr=1; corr<=1; corr++) + while (piso.correct()) { volScalarField rUA = 1.0/UEqn.A(); diff --git a/applications/solvers/basic/laplacianFoam/laplacianFoam.C b/applications/solvers/basic/laplacianFoam/laplacianFoam.C index d025f6bb4..6c78e8f7e 100644 --- a/applications/solvers/basic/laplacianFoam/laplacianFoam.C +++ b/applications/solvers/basic/laplacianFoam/laplacianFoam.C @@ -50,7 +50,7 @@ int main(int argc, char *argv[]) Info<< "\nCalculating temperature distribution\n" << endl; - while (runTime.loop()) + while (simple.loop()) { Info<< "Time = " << runTime.timeName() << nl << endl; diff --git a/applications/solvers/basic/potentialDyMFoam/createFields.H b/applications/solvers/basic/potentialDyMFoam/createFields.H index f29c44789..6f3ccee89 100644 --- a/applications/solvers/basic/potentialDyMFoam/createFields.H +++ b/applications/solvers/basic/potentialDyMFoam/createFields.H @@ -47,5 +47,5 @@ label pRefCell = 0; scalar pRefValue = 0.0; - setRefCell(p, mesh.solutionDict().subDict("PISO"), pRefCell, pRefValue); + setRefCell(p, piso.dict(), pRefCell, pRefValue); mesh.schemesDict().setFluxRequired(p.name()); diff --git a/applications/solvers/basic/potentialDyMFoam/potentialDyMFoam.C b/applications/solvers/basic/potentialDyMFoam/potentialDyMFoam.C index 763ebf180..af3bcdcda 100644 --- a/applications/solvers/basic/potentialDyMFoam/potentialDyMFoam.C +++ b/applications/solvers/basic/potentialDyMFoam/potentialDyMFoam.C @@ -80,8 +80,6 @@ int main(int argc, char *argv[]) while (piso.correctNonOrthogonal()) { - p.storePrevIter(); - fvScalarMatrix pEqn ( fvm::laplacian diff --git a/applications/solvers/basic/potentialFoam/createFields.H b/applications/solvers/basic/potentialFoam/createFields.H index 108ad4e6d..604aef5cf 100644 --- a/applications/solvers/basic/potentialFoam/createFields.H +++ b/applications/solvers/basic/potentialFoam/createFields.H @@ -49,5 +49,5 @@ label pRefCell = 0; scalar pRefValue = 0.0; - setRefCell(p, mesh.solutionDict().subDict("SIMPLE"), pRefCell, pRefValue); + setRefCell(p, simple.dict(), pRefCell, pRefValue); mesh.schemesDict().setFluxRequired(p.name()); diff --git a/applications/solvers/basic/scalarTransportFoam/scalarTransportFoam.C b/applications/solvers/basic/scalarTransportFoam/scalarTransportFoam.C index 3a72a378a..56145a53f 100644 --- a/applications/solvers/basic/scalarTransportFoam/scalarTransportFoam.C +++ b/applications/solvers/basic/scalarTransportFoam/scalarTransportFoam.C @@ -52,7 +52,7 @@ int main(int argc, char *argv[]) # include "CourantNo.H" - while (runTime.loop()) + while (simple.loop()) { Info<< "Time = " << runTime.timeName() << nl << endl; diff --git a/applications/solvers/combustion/PDRFoam/PDRFoam.C b/applications/solvers/combustion/PDRFoam/PDRFoam.C index e3a5e8c1f..3d4311526 100644 --- a/applications/solvers/combustion/PDRFoam/PDRFoam.C +++ b/applications/solvers/combustion/PDRFoam/PDRFoam.C @@ -64,6 +64,7 @@ Description #include "ignition.H" #include "Switch.H" #include "bound.H" +#include "pisoControl.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -73,6 +74,9 @@ int main(int argc, char *argv[]) # include "createTime.H" # include "createMesh.H" + + pisoControl piso(mesh); + # include "readCombustionProperties.H" # include "readGravitationalAcceleration.H" # include "createFields.H" @@ -90,7 +94,6 @@ int main(int argc, char *argv[]) while (runTime.run()) { # include "readTimeControls.H" -# include "readPISOControls.H" # include "CourantNo.H" # include "setDeltaT.H" @@ -102,7 +105,7 @@ int main(int argc, char *argv[]) # include "UEqn.H" // --- PISO loop - for (int corr=1; corr<=nCorr; corr++) + while (piso.correct()) { # include "bEqn.H" # include "ftEqn.H" diff --git a/applications/solvers/combustion/PDRFoam/PDRFoamAutoRefine.C b/applications/solvers/combustion/PDRFoam/PDRFoamAutoRefine.C index fee3bd322..263e6b90b 100644 --- a/applications/solvers/combustion/PDRFoam/PDRFoamAutoRefine.C +++ b/applications/solvers/combustion/PDRFoam/PDRFoamAutoRefine.C @@ -66,6 +66,7 @@ Description #include "Switch.H" #include "bound.H" #include "dynamicRefineFvMesh.H" +#include "pisoControl.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -75,10 +76,12 @@ int main(int argc, char *argv[]) # include "createTime.H" # include "createDynamicFvMesh.H" + + pisoControl piso(mesh); + # include "readCombustionProperties.H" # include "readGravitationalAcceleration.H" # include "createFields.H" -# include "readPISOControls.H" # include "initContinuityErrs.H" # include "createTimeControls.H" # include "setInitialDeltaT.H" @@ -92,7 +95,6 @@ int main(int argc, char *argv[]) while (runTime.run()) { # include "readTimeControls.H" -# include "readPISOControls.H" # include "CourantNo.H" # include "setDeltaT.H" @@ -168,7 +170,7 @@ int main(int argc, char *argv[]) # include "UEqn.H" // --- PISO loop - for (int corr=1; corr<=nCorr; corr++) + while (piso.correct()) { # include "bEqn.H" # include "ftEqn.H" diff --git a/applications/solvers/combustion/PDRFoam/UEqn.H b/applications/solvers/combustion/PDRFoam/UEqn.H index aea6ad9a4..af2ea9510 100644 --- a/applications/solvers/combustion/PDRFoam/UEqn.H +++ b/applications/solvers/combustion/PDRFoam/UEqn.H @@ -9,7 +9,7 @@ volSymmTensorField invA = inv(I*UEqn.A() + drag->Dcu()); - if (momentumPredictor) + if (piso.momentumPredictor()) { U = invA & (UEqn.H() - betav*fvc::grad(p)); U.correctBoundaryConditions(); diff --git a/applications/solvers/combustion/PDRFoam/createFields.H b/applications/solvers/combustion/PDRFoam/createFields.H index 74a18ab6f..6d3a4bdf5 100644 --- a/applications/solvers/combustion/PDRFoam/createFields.H +++ b/applications/solvers/combustion/PDRFoam/createFields.H @@ -163,3 +163,5 @@ fields.add(h); fields.add(hu); flameWrinkling->addXi(fields); + + mesh.schemesDict().setFluxRequired(p.name()); diff --git a/applications/solvers/combustion/PDRFoam/pEqn.H b/applications/solvers/combustion/PDRFoam/pEqn.H index 524c8eac7..250fdf2a0 100644 --- a/applications/solvers/combustion/PDRFoam/pEqn.H +++ b/applications/solvers/combustion/PDRFoam/pEqn.H @@ -3,7 +3,7 @@ rho = thermo.rho(); volScalarField rUA = 1.0/UEqn.A(); U = invA & UEqn.H(); -if (transonic) +if (piso.transonic()) { surfaceScalarField phid ( @@ -15,7 +15,7 @@ if (transonic) ) ); - for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) + while (piso.correctNonOrthogonal()) { fvScalarMatrix pEqn ( @@ -26,7 +26,7 @@ if (transonic) pEqn.solve(); - if (nonOrth == nNonOrthCorr) + if (piso.finalNonOrthogonalIter()) { phi == pEqn.flux(); } @@ -41,7 +41,7 @@ else + fvc::ddtPhiCorr(rUA, rho, U, phi) ); - for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) + while (piso.correctNonOrthogonal()) { fvScalarMatrix pEqn ( @@ -52,7 +52,7 @@ else pEqn.solve(); - if (nonOrth == nNonOrthCorr) + if (piso.finalNonOrthogonalIter()) { phi += pEqn.flux(); } diff --git a/applications/solvers/combustion/rhoReactingFoam/UEqn.H b/applications/solvers/combustion/rhoReactingFoam/UEqn.H index 9697c6e1e..1e626d75b 100644 --- a/applications/solvers/combustion/rhoReactingFoam/UEqn.H +++ b/applications/solvers/combustion/rhoReactingFoam/UEqn.H @@ -9,7 +9,7 @@ UEqn.relax(); - if (momentumPredictor) + if (pimple.momentumPredictor()) { solve(UEqn == -fvc::grad(p)); } diff --git a/applications/solvers/combustion/rhoReactingFoam/createFields.H b/applications/solvers/combustion/rhoReactingFoam/createFields.H index d4119b8c9..035d5a77b 100644 --- a/applications/solvers/combustion/rhoReactingFoam/createFields.H +++ b/applications/solvers/combustion/rhoReactingFoam/createFields.H @@ -97,3 +97,5 @@ DimensionedField chemistrySh mesh, dimensionedScalar("chemistrySh", dimEnergy/dimTime/dimVolume, 0.0) ); + +mesh.schemesDict().setFluxRequired(p.name()); diff --git a/applications/solvers/combustion/rhoReactingFoam/pEqn.H b/applications/solvers/combustion/rhoReactingFoam/pEqn.H index 32653a927..222e8c959 100644 --- a/applications/solvers/combustion/rhoReactingFoam/pEqn.H +++ b/applications/solvers/combustion/rhoReactingFoam/pEqn.H @@ -8,7 +8,7 @@ volScalarField rUA = 1.0/UEqn.A(); U = rUA*UEqn.H(); - if (transonic) + if (pimple.transonic()) { surfaceScalarField phiv = (fvc::interpolate(U) & mesh.Sf()) @@ -22,7 +22,7 @@ fvc::interpolate(thermo.psi())*phiv ); - for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) + while (pimple.correctNonOrthogonal()) { fvScalarMatrix pEqn ( @@ -31,21 +31,12 @@ - fvm::laplacian(rho*rUA, p) ); - if + pEqn.solve ( - ocorr == nOuterCorr - && corr == nCorr - && nonOrth == nNonOrthCorr - ) - { - pEqn.solve(mesh.solutionDict().solver(p.name() + "Final")); - } - else - { - pEqn.solve(); - } + mesh.solutionDict().solver(p.select(pimple.finalInnerIter())) + ); - if (nonOrth == nNonOrthCorr) + if (pimple.finalNonOrthogonalIter()) { phi += pEqn.flux(); } @@ -60,7 +51,7 @@ + fvc::ddtPhiCorr(rUA, rho, U, phi) ); - for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) + while (pimple.correctNonOrthogonal()) { fvScalarMatrix pEqn ( @@ -69,21 +60,12 @@ - fvm::laplacian(rho*rUA, p) ); - if + pEqn.solve ( - ocorr == nOuterCorr - && corr == nCorr - && nonOrth == nNonOrthCorr - ) - { - pEqn.solve(mesh.solutionDict().solver(p.name() + "Final")); - } - else - { - pEqn.solve(); - } + mesh.solutionDict().solver(p.select(pimple.finalInnerIter())) + ); - if (nonOrth == nNonOrthCorr) + if (pimple.finalNonOrthogonalIter()) { phi += pEqn.flux(); } diff --git a/applications/solvers/combustion/rhoReactingFoam/rhoReactingFoam.C b/applications/solvers/combustion/rhoReactingFoam/rhoReactingFoam.C index dc729c5f3..645d3a2cc 100644 --- a/applications/solvers/combustion/rhoReactingFoam/rhoReactingFoam.C +++ b/applications/solvers/combustion/rhoReactingFoam/rhoReactingFoam.C @@ -36,6 +36,7 @@ Description #include "rhoChemistryModel.H" #include "chemistrySolver.H" #include "multivariateScheme.H" +#include "pimpleControl.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -44,6 +45,9 @@ int main(int argc, char *argv[]) # include "setRootCase.H" # include "createTime.H" # include "createMesh.H" + + pimpleControl pimple(mesh); + # include "readChemistryProperties.H" # include "readGravitationalAcceleration.H" # include "createFields.H" @@ -59,7 +63,6 @@ int main(int argc, char *argv[]) while (runTime.run()) { # include "readTimeControls.H" -# include "readPISOControls.H" # include "compressibleCourantNo.H" # include "setDeltaT.H" @@ -69,14 +72,14 @@ int main(int argc, char *argv[]) # include "chemistry.H" # include "rhoEqn.H" - for (label ocorr=1; ocorr <= nOuterCorr; ocorr++) + while (pimple.loop()) { # include "UEqn.H" # include "YEqn.H" # include "hsEqn.H" // --- PISO loop - for (int corr=1; corr<=nCorr; corr++) + while (pimple.correct()) { # include "pEqn.H" } diff --git a/applications/solvers/compressible/rhoPimpleFoam/createFields.H b/applications/solvers/compressible/rhoPimpleFoam/createFields.H index 20e25e948..13f306ddc 100644 --- a/applications/solvers/compressible/rhoPimpleFoam/createFields.H +++ b/applications/solvers/compressible/rhoPimpleFoam/createFields.H @@ -39,10 +39,7 @@ # include "compressibleCreatePhi.H" - dimensionedScalar pMin - ( - mesh.solutionDict().subDict("PIMPLE").lookup("pMin") - ); + dimensionedScalar pMin(pimple.dict().lookup("pMin")); Info<< "Creating turbulence model\n" << endl; autoPtr turbulence diff --git a/applications/solvers/compressible/rhoPimpleFoam/rhoPimpleFoam.C b/applications/solvers/compressible/rhoPimpleFoam/rhoPimpleFoam.C index 836ce67aa..c2c0570c0 100644 --- a/applications/solvers/compressible/rhoPimpleFoam/rhoPimpleFoam.C +++ b/applications/solvers/compressible/rhoPimpleFoam/rhoPimpleFoam.C @@ -67,12 +67,6 @@ int main(int argc, char *argv[]) Info<< "Time = " << runTime.timeName() << nl << endl; - if (!pimple.firstIter()) - { - p.storePrevIter(); - rho.storePrevIter(); - } - #include "rhoEqn.H" // --- Pressure-velocity PIMPLE corrector loop diff --git a/applications/solvers/compressible/rhoPorousMRFPimpleFoam/createFields.H b/applications/solvers/compressible/rhoPorousMRFPimpleFoam/createFields.H index b9a86ef99..325c8cbaa 100644 --- a/applications/solvers/compressible/rhoPorousMRFPimpleFoam/createFields.H +++ b/applications/solvers/compressible/rhoPorousMRFPimpleFoam/createFields.H @@ -39,10 +39,7 @@ #include "compressibleCreatePhi.H" - dimensionedScalar pMin - ( - mesh.solutionDict().subDict("PIMPLE").lookup("pMin") - ); + dimensionedScalar pMin(pimple.dict().lookup("pMin")); Info<< "Creating turbulence model\n" << endl; autoPtr turbulence @@ -68,3 +65,5 @@ porousZones pZones(mesh); Switch pressureImplicitPorosity(false); + + mesh.schemesDict().setFluxRequired(p.name()); diff --git a/applications/solvers/compressible/rhoPorousSimpleFoam/UEqn.H b/applications/solvers/compressible/rhoPorousSimpleFoam/UEqn.H index 546094428..fd79c8400 100644 --- a/applications/solvers/compressible/rhoPorousSimpleFoam/UEqn.H +++ b/applications/solvers/compressible/rhoPorousSimpleFoam/UEqn.H @@ -34,12 +34,7 @@ { pZones.addResistance(UEqn()); - eqnResidual = solve - ( - UEqn() == -fvc::grad(p) - ). initialResidual(); - - maxResidual = max(eqnResidual, maxResidual); + solve(UEqn() == -fvc::grad(p)); trAU = 1.0/UEqn().A(); trAU().rename("rAU"); diff --git a/applications/solvers/compressible/rhoPorousSimpleFoam/convergenceCheck.H b/applications/solvers/compressible/rhoPorousSimpleFoam/convergenceCheck.H deleted file mode 100644 index 895806319..000000000 --- a/applications/solvers/compressible/rhoPorousSimpleFoam/convergenceCheck.H +++ /dev/null @@ -1,9 +0,0 @@ -// check convergence - -if (maxResidual < convergenceCriterion) -{ - Info<< "reached convergence criterion: " << convergenceCriterion << endl; - runTime.writeAndEnd(); - Info<< "latestTime = " << runTime.timeName() << endl; -} - diff --git a/applications/solvers/compressible/rhoPorousSimpleFoam/createFields.H b/applications/solvers/compressible/rhoPorousSimpleFoam/createFields.H index 1177cba2a..65edfa008 100644 --- a/applications/solvers/compressible/rhoPorousSimpleFoam/createFields.H +++ b/applications/solvers/compressible/rhoPorousSimpleFoam/createFields.H @@ -43,12 +43,10 @@ label pRefCell = 0; scalar pRefValue = 0.0; - setRefCell(p, mesh.solutionDict().subDict("SIMPLE"), pRefCell, pRefValue); + setRefCell(p, simple.dict(), pRefCell, pRefValue); + mesh.schemesDict().setFluxRequired(p.name()); - dimensionedScalar pMin - ( - mesh.solutionDict().subDict("SIMPLE").lookup("pMin") - ); + dimensionedScalar pMin(simple.dict().lookup("pMin")); Info<< "Creating turbulence model\n" << endl; autoPtr turbulence @@ -71,12 +69,9 @@ if (pZones.size()) { // nUCorrectors for pressureImplicitPorosity - if (mesh.solutionDict().subDict("SIMPLE").found("nUCorrectors")) + if (simple.dict().found("nUCorrectors")) { - nUCorr = readInt - ( - mesh.solutionDict().subDict("SIMPLE").lookup("nUCorrectors") - ); + nUCorr = readInt(simple.dict().lookup("nUCorrectors")); } if (nUCorr > 0) diff --git a/applications/solvers/compressible/rhoPorousSimpleFoam/hEqn.H b/applications/solvers/compressible/rhoPorousSimpleFoam/hEqn.H index 605b8820d..324dcd642 100644 --- a/applications/solvers/compressible/rhoPorousSimpleFoam/hEqn.H +++ b/applications/solvers/compressible/rhoPorousSimpleFoam/hEqn.H @@ -11,8 +11,7 @@ hEqn.relax(); - eqnResidual = hEqn.solve().initialResidual(); - maxResidual = max(eqnResidual, maxResidual); + hEqn.solve().initialResidual(); thermo.correct(); } diff --git a/applications/solvers/compressible/rhoPorousSimpleFoam/initConvergenceCheck.H b/applications/solvers/compressible/rhoPorousSimpleFoam/initConvergenceCheck.H deleted file mode 100644 index b56197f22..000000000 --- a/applications/solvers/compressible/rhoPorousSimpleFoam/initConvergenceCheck.H +++ /dev/null @@ -1,7 +0,0 @@ -// initialize values for convergence checks - - scalar eqnResidual = 1, maxResidual = 0; - scalar convergenceCriterion = 0; - - simple.readIfPresent("convergence", convergenceCriterion); - diff --git a/applications/solvers/compressible/rhoPorousSimpleFoam/pEqn.H b/applications/solvers/compressible/rhoPorousSimpleFoam/pEqn.H index 4d8e010f7..ab81dac30 100644 --- a/applications/solvers/compressible/rhoPorousSimpleFoam/pEqn.H +++ b/applications/solvers/compressible/rhoPorousSimpleFoam/pEqn.H @@ -12,7 +12,7 @@ UEqn.clear(); phi = fvc::interpolate(rho*U) & mesh.Sf(); bool closedVolume = adjustPhi(phi, U, p); -for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) +while (simple.correctNonOrthogonal()) { tmp tpEqn; @@ -26,18 +26,10 @@ for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) } tpEqn().setReference(pRefCell, pRefValue); - // retain the residual from the first iteration - if (nonOrth == 0) - { - eqnResidual = tpEqn().solve().initialResidual(); - maxResidual = max(eqnResidual, maxResidual); - } - else - { - tpEqn().solve(); - } - if (nonOrth == nNonOrthCorr) + tpEqn().solve(); + + if (simple.finalNonOrthogonalIter()) { phi -= tpEqn().flux(); } diff --git a/applications/solvers/compressible/rhoPorousSimpleFoam/rhoPorousSimpleFoam.C b/applications/solvers/compressible/rhoPorousSimpleFoam/rhoPorousSimpleFoam.C index b72e7efd2..ad7422b1a 100644 --- a/applications/solvers/compressible/rhoPorousSimpleFoam/rhoPorousSimpleFoam.C +++ b/applications/solvers/compressible/rhoPorousSimpleFoam/rhoPorousSimpleFoam.C @@ -34,6 +34,7 @@ Description #include "basicPsiThermo.H" #include "RASModel.H" #include "porousZones.H" +#include "simpleControl.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -42,6 +43,9 @@ int main(int argc, char *argv[]) #include "setRootCase.H" #include "createTime.H" #include "createMesh.H" + + simpleControl simple(mesh); + #include "createFields.H" #include "initContinuityErrs.H" @@ -49,16 +53,10 @@ int main(int argc, char *argv[]) Info<< "\nStarting time loop\n" << endl; - while (runTime.loop()) + while (simple.loop()) { Info<< "Time = " << runTime.timeName() << nl << endl; - #include "readSIMPLEControls.H" - #include "initConvergenceCheck.H" - - p.storePrevIter(); - rho.storePrevIter(); - // Pressure-velocity SIMPLE corrector { #include "UEqn.H" @@ -72,8 +70,6 @@ int main(int argc, char *argv[]) Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" << " ClockTime = " << runTime.elapsedClockTime() << " s" << nl << endl; - - #include "convergenceCheck.H" } Info<< "End\n" << endl; diff --git a/applications/solvers/compressible/rhoSimpleFoam/UEqn.H b/applications/solvers/compressible/rhoSimpleFoam/UEqn.H index 401e1203d..21ec2646b 100644 --- a/applications/solvers/compressible/rhoSimpleFoam/UEqn.H +++ b/applications/solvers/compressible/rhoSimpleFoam/UEqn.H @@ -8,9 +8,4 @@ UEqn().relax(); - eqnResidual = solve - ( - UEqn() == -fvc::grad(p) - ).initialResidual(); - - maxResidual = max(eqnResidual, maxResidual); + solve(UEqn() == -fvc::grad(p)); diff --git a/applications/solvers/compressible/rhoSimpleFoam/convergenceCheck.H b/applications/solvers/compressible/rhoSimpleFoam/convergenceCheck.H deleted file mode 100644 index 895806319..000000000 --- a/applications/solvers/compressible/rhoSimpleFoam/convergenceCheck.H +++ /dev/null @@ -1,9 +0,0 @@ -// check convergence - -if (maxResidual < convergenceCriterion) -{ - Info<< "reached convergence criterion: " << convergenceCriterion << endl; - runTime.writeAndEnd(); - Info<< "latestTime = " << runTime.timeName() << endl; -} - diff --git a/applications/solvers/compressible/rhoSimpleFoam/createFields.H b/applications/solvers/compressible/rhoSimpleFoam/createFields.H index 122280cfa..f335c6a6f 100644 --- a/applications/solvers/compressible/rhoSimpleFoam/createFields.H +++ b/applications/solvers/compressible/rhoSimpleFoam/createFields.H @@ -42,17 +42,11 @@ label pRefCell = 0; scalar pRefValue = 0.0; - setRefCell(p, mesh.solutionDict().subDict("SIMPLE"), pRefCell, pRefValue); + setRefCell(p, simple.dict(), pRefCell, pRefValue); + mesh.schemesDict().setFluxRequired(p.name()); - dimensionedScalar rhoMax - ( - mesh.solutionDict().subDict("SIMPLE").lookup("rhoMax") - ); - - dimensionedScalar rhoMin - ( - mesh.solutionDict().subDict("SIMPLE").lookup("rhoMin") - ); + dimensionedScalar rhoMax(simple.dict().lookup("rhoMax")); + dimensionedScalar rhoMin(simple.dict().lookup("rhoMin")); Info<< "Creating turbulence model\n" << endl; autoPtr turbulence diff --git a/applications/solvers/compressible/rhoSimpleFoam/hEqn.H b/applications/solvers/compressible/rhoSimpleFoam/hEqn.H index 57395e977..e6c74938e 100644 --- a/applications/solvers/compressible/rhoSimpleFoam/hEqn.H +++ b/applications/solvers/compressible/rhoSimpleFoam/hEqn.H @@ -11,8 +11,7 @@ hEqn.relax(); - eqnResidual = hEqn.solve().initialResidual(); - maxResidual = max(eqnResidual, maxResidual); + hEqn.solve(); thermo.correct(); } diff --git a/applications/solvers/compressible/rhoSimpleFoam/initConvergenceCheck.H b/applications/solvers/compressible/rhoSimpleFoam/initConvergenceCheck.H deleted file mode 100644 index b56197f22..000000000 --- a/applications/solvers/compressible/rhoSimpleFoam/initConvergenceCheck.H +++ /dev/null @@ -1,7 +0,0 @@ -// initialize values for convergence checks - - scalar eqnResidual = 1, maxResidual = 0; - scalar convergenceCriterion = 0; - - simple.readIfPresent("convergence", convergenceCriterion); - diff --git a/applications/solvers/compressible/rhoSimpleFoam/pEqn.H b/applications/solvers/compressible/rhoSimpleFoam/pEqn.H index 04af6df75..3865aeb9f 100644 --- a/applications/solvers/compressible/rhoSimpleFoam/pEqn.H +++ b/applications/solvers/compressible/rhoSimpleFoam/pEqn.H @@ -9,7 +9,7 @@ UEqn.clear(); bool closedVolume = false; -if (transonic) +if (simple.transonic()) { surfaceScalarField phid ( @@ -17,7 +17,7 @@ if (transonic) fvc::interpolate(psi)*(fvc::interpolate(U) & mesh.Sf()) ); - for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) + while (simple.correctNonOrthogonal()) { fvScalarMatrix pEqn ( @@ -26,22 +26,13 @@ if (transonic) ); // Relax the pressure equation to ensure diagonal-dominance - pEqn.relax(mesh.solutionDict().relaxationFactor("pEqn")); + pEqn.relax(); pEqn.setReference(pRefCell, pRefValue); - // retain the residual from the first iteration - if (nonOrth == 0) - { - eqnResidual = pEqn.solve().initialResidual(); - maxResidual = max(eqnResidual, maxResidual); - } - else - { - pEqn.solve(); - } + pEqn.solve(); - if (nonOrth == nNonOrthCorr) + if (simple.finalNonOrthogonalIter()) { phi == pEqn.flux(); } @@ -52,7 +43,7 @@ else phi = fvc::interpolate(rho)*(fvc::interpolate(U) & mesh.Sf()); closedVolume = adjustPhi(phi, U, p); - for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) + while (simple.correctNonOrthogonal()) { fvScalarMatrix pEqn ( @@ -61,18 +52,9 @@ else pEqn.setReference(pRefCell, pRefValue); - // Retain the residual from the first iteration - if (nonOrth == 0) - { - eqnResidual = pEqn.solve().initialResidual(); - maxResidual = max(eqnResidual, maxResidual); - } - else - { - pEqn.solve(); - } + pEqn.solve(); - if (nonOrth == nNonOrthCorr) + if (simple.finalNonOrthogonalIter()) { phi -= pEqn.flux(); } diff --git a/applications/solvers/compressible/rhoSimpleFoam/rhoSimpleFoam.C b/applications/solvers/compressible/rhoSimpleFoam/rhoSimpleFoam.C index 6c63d09c0..afa315bed 100644 --- a/applications/solvers/compressible/rhoSimpleFoam/rhoSimpleFoam.C +++ b/applications/solvers/compressible/rhoSimpleFoam/rhoSimpleFoam.C @@ -33,6 +33,7 @@ Description #include "fvCFD.H" #include "basicPsiThermo.H" #include "RASModel.H" +#include "simpleControl.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -41,6 +42,9 @@ int main(int argc, char *argv[]) #include "setRootCase.H" #include "createTime.H" #include "createMesh.H" + + simpleControl simple(mesh); + #include "createFields.H" #include "initContinuityErrs.H" @@ -48,16 +52,10 @@ int main(int argc, char *argv[]) Info<< "\nStarting time loop\n" << endl; - while (runTime.loop()) + while (simple.loop()) { Info<< "Time = " << runTime.timeName() << nl << endl; -# include "readSIMPLEControls.H" -# include "initConvergenceCheck.H" - - p.storePrevIter(); - rho.storePrevIter(); - // Pressure-velocity SIMPLE corrector { # include "UEqn.H" @@ -72,8 +70,6 @@ int main(int argc, char *argv[]) Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" << " ClockTime = " << runTime.elapsedClockTime() << " s" << nl << endl; - - #include "convergenceCheck.H" } Info<< "End\n" << endl; diff --git a/applications/solvers/compressible/rhoSonicFoam/createFields.H b/applications/solvers/compressible/rhoSonicFoam/createFields.H index f0c0e4a22..aa121b96e 100644 --- a/applications/solvers/compressible/rhoSonicFoam/createFields.H +++ b/applications/solvers/compressible/rhoSonicFoam/createFields.H @@ -94,3 +94,5 @@ rho*Cv*T + 0.5*rho*magSqr(rhoU/rho), T.boundaryField().types() ); + + mesh.schemesDict().setFluxRequired(p.name()); diff --git a/applications/solvers/compressible/rhopSonicFoam/createFields.H b/applications/solvers/compressible/rhopSonicFoam/createFields.H index fed843271..c8e478e88 100644 --- a/applications/solvers/compressible/rhopSonicFoam/createFields.H +++ b/applications/solvers/compressible/rhopSonicFoam/createFields.H @@ -127,3 +127,4 @@ fields.add(magRhoU); fields.add(H); + mesh.schemesDict().setFluxRequired(p.name()); diff --git a/applications/solvers/compressible/rhopSonicFoam/rhopSonicFoam.C b/applications/solvers/compressible/rhopSonicFoam/rhopSonicFoam.C index 9551a2778..8fd9c00d6 100644 --- a/applications/solvers/compressible/rhopSonicFoam/rhopSonicFoam.C +++ b/applications/solvers/compressible/rhopSonicFoam/rhopSonicFoam.C @@ -36,6 +36,7 @@ Description #include "MUSCL.H" #include "LimitedScheme.H" #include "boundaryTypes.H" +#include "pimpleControl.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -45,6 +46,9 @@ int main(int argc, char *argv[]) # include "setRootCase.H" # include "createTime.H" # include "createMesh.H" + + pimpleControl pimple(mesh); + # include "readThermodynamicProperties.H" # include "createFields.H" # include "createTimeControls.H" @@ -57,8 +61,7 @@ int main(int argc, char *argv[]) { Info<< "Time = " << runTime.value() << nl << endl; -# include "readPISOControls.H" - scalar HbyAblend = readScalar(piso.lookup("HbyAblend")); + scalar HbyAblend = readScalar(pimple.dict().lookup("HbyAblend")); # include "readTimeControls.H" @@ -72,7 +75,7 @@ int main(int argc, char *argv[]) # include "setDeltaT.H" - for (int outerCorr = 0; outerCorr < nOuterCorr; outerCorr++) + while (pimple.loop()) { magRhoU = mag(rhoU); H = (rhoE + p)/rho; @@ -118,7 +121,7 @@ int main(int argc, char *argv[]) psi = 1.0/(R*T); p = rho/psi; - for (int corr = 0; corr < nCorr; corr++) + while (pimple.correct()) { volScalarField rrhoUA = 1.0/rhoUEqn.A(); surfaceScalarField rrhoUAf("rrhoUAf", fvc::interpolate(rrhoUA)); diff --git a/applications/solvers/compressible/sonicDyMFoam/UEqn.H b/applications/solvers/compressible/sonicDyMFoam/UEqn.H index 377aa0a13..bdcc54f6e 100644 --- a/applications/solvers/compressible/sonicDyMFoam/UEqn.H +++ b/applications/solvers/compressible/sonicDyMFoam/UEqn.H @@ -5,20 +5,9 @@ + turbulence->divDevRhoReff(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())) + ); solve(UEqn == -fvc::grad(p)); diff --git a/applications/solvers/compressible/sonicDyMFoam/createControls.H b/applications/solvers/compressible/sonicDyMFoam/createControls.H index 45a18790e..a9c1b9b0a 100644 --- a/applications/solvers/compressible/sonicDyMFoam/createControls.H +++ b/applications/solvers/compressible/sonicDyMFoam/createControls.H @@ -1,14 +1,11 @@ # include "createTimeControls.H" -# include "readPIMPLEControls.H" - bool correctPhi = false; - if (pimple.found("correctPhi")) - { - correctPhi = Switch(pimple.lookup("correctPhi")); - } +bool correctPhi +( + pimple.dict().lookupOrDefault("correctPhi", false) +); - bool checkMeshCourantNo = false; - if (pimple.found("checkMeshCourantNo")) - { - checkMeshCourantNo = Switch(pimple.lookup("checkMeshCourantNo")); - } +bool checkMeshCourantNo +( + pimple.dict().lookupOrDefault("checkMeshCourantNo", false) +); diff --git a/applications/solvers/compressible/sonicDyMFoam/createFields.H b/applications/solvers/compressible/sonicDyMFoam/createFields.H index a17764ce4..0bec8c245 100644 --- a/applications/solvers/compressible/sonicDyMFoam/createFields.H +++ b/applications/solvers/compressible/sonicDyMFoam/createFields.H @@ -51,3 +51,5 @@ thermo ) ); + + mesh.schemesDict().setFluxRequired(p.name()); diff --git a/applications/solvers/compressible/sonicDyMFoam/eEqn.H b/applications/solvers/compressible/sonicDyMFoam/eEqn.H index 5a4596437..cbe3c5eda 100644 --- a/applications/solvers/compressible/sonicDyMFoam/eEqn.H +++ b/applications/solvers/compressible/sonicDyMFoam/eEqn.H @@ -17,21 +17,10 @@ // viscous heating? ); - if (oCorr == nOuterCorr - 1) - { - if (mesh.solutionDict().relax("eFinal")) - { - eEqn.relax(mesh.solutionDict().relaxationFactor("eFinal")); - } - else - { - eEqn.relax(1); - } - } - else - { - eEqn.relax(); - } + eEqn.relax + ( + mesh.solutionDict().relaxationFactor(e.select(pimple.finalIter())) + ); eEqn.solve(); diff --git a/applications/solvers/compressible/sonicDyMFoam/pEqn.H b/applications/solvers/compressible/sonicDyMFoam/pEqn.H index 1be1b12b2..20cb4ea4c 100644 --- a/applications/solvers/compressible/sonicDyMFoam/pEqn.H +++ b/applications/solvers/compressible/sonicDyMFoam/pEqn.H @@ -3,7 +3,7 @@ # include "limitU.H" - for (int nonOrth = 0; nonOrth <= nNonOrthCorr; nonOrth++) + while (pimple.correctNonOrthogonal()) { // Calculate phi for boundary conditions phi = rhof* @@ -36,25 +36,13 @@ - fvm::laplacian(rho*rUA, p) ); - if + pEqn.solve ( -// oCorr == nOuterCorr - 1 - corr == nCorr - 1 - && nonOrth == nNonOrthCorr - ) - { - pEqn.solve - ( - mesh.solutionDict().solver(p.name() + "Final") - ); - } - else - { - pEqn.solve(mesh.solutionDict().solver(p.name())); - } + mesh.solutionDict().solver(p.select(pimple.finalInnerIter())) + ); // Calculate the flux - if (nonOrth == nNonOrthCorr) + if (pimple.finalNonOrthogonalIter()) { phi = phid2 + pEqn.flux(); } diff --git a/applications/solvers/compressible/sonicDyMFoam/readControls.H b/applications/solvers/compressible/sonicDyMFoam/readControls.H index 2db7f5142..9f982e260 100644 --- a/applications/solvers/compressible/sonicDyMFoam/readControls.H +++ b/applications/solvers/compressible/sonicDyMFoam/readControls.H @@ -1,14 +1,5 @@ -# include "readTimeControls.H" -# include "readPIMPLEControls.H" +#include "readTimeControls.H" - correctPhi = false; - if (pimple.found("correctPhi")) - { - correctPhi = Switch(pimple.lookup("correctPhi")); - } +correctPhi = pimple.dict().lookupOrDefault("correctPhi", false); - checkMeshCourantNo = false; - if (pimple.found("checkMeshCourantNo")) - { - checkMeshCourantNo = Switch(pimple.lookup("checkMeshCourantNo")); - } +checkMeshCourantNo = pimple.dict().lookupOrDefault("checkMeshCourantNo", false); diff --git a/applications/solvers/compressible/sonicDyMFoam/sonicDyMFoam.C b/applications/solvers/compressible/sonicDyMFoam/sonicDyMFoam.C index 0920a9542..d8e9c123f 100644 --- a/applications/solvers/compressible/sonicDyMFoam/sonicDyMFoam.C +++ b/applications/solvers/compressible/sonicDyMFoam/sonicDyMFoam.C @@ -47,6 +47,7 @@ Author #include "specie.H" #include "basicPsiThermo.H" #include "turbulenceModel.H" +#include "pimpleControl.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -56,6 +57,9 @@ int main(int argc, char *argv[]) # include "createTime.H" # include "createDynamicFvMesh.H" + + pimpleControl pimple(mesh); + # include "createFields.H" # include "initContinuityErrs.H" # include "createControls.H" @@ -106,8 +110,7 @@ int main(int argc, char *argv[]) } // --- PIMPLE loop - label oCorr = 0; - do + while (pimple.loop()) { # include "rhoEqn.H" # include "eEqn.H" @@ -123,13 +126,13 @@ int main(int argc, char *argv[]) // but psi and rho are not surfaceScalarField rhoReff = rhof - psisf*fvc::interpolate(p); - for (int corr = 0; corr < nCorr; corr++) + while (pimple.correct()) { # include "pEqn.H" } turbulence->correct(); - } while (++oCorr < nOuterCorr); + } runTime.write(); diff --git a/applications/solvers/compressible/sonicFoam/UEqn.H b/applications/solvers/compressible/sonicFoam/UEqn.H index 377aa0a13..bdcc54f6e 100644 --- a/applications/solvers/compressible/sonicFoam/UEqn.H +++ b/applications/solvers/compressible/sonicFoam/UEqn.H @@ -5,20 +5,9 @@ + turbulence->divDevRhoReff(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())) + ); solve(UEqn == -fvc::grad(p)); diff --git a/applications/solvers/compressible/sonicFoam/createFields.H b/applications/solvers/compressible/sonicFoam/createFields.H index 8e03212c2..e88da74d3 100644 --- a/applications/solvers/compressible/sonicFoam/createFields.H +++ b/applications/solvers/compressible/sonicFoam/createFields.H @@ -50,3 +50,5 @@ thermo ) ); + + mesh.schemesDict().setFluxRequired(p.name()); diff --git a/applications/solvers/compressible/sonicFoam/eEqn.H b/applications/solvers/compressible/sonicFoam/eEqn.H index 3f9cc4184..413758c7f 100644 --- a/applications/solvers/compressible/sonicFoam/eEqn.H +++ b/applications/solvers/compressible/sonicFoam/eEqn.H @@ -14,21 +14,10 @@ // viscous heating? ); - if (oCorr == nOuterCorr - 1) - { - if (mesh.solutionDict().relax("eFinal")) - { - eEqn.relax(mesh.solutionDict().relaxationFactor("eFinal")); - } - else - { - eEqn.relax(1); - } - } - else - { - eEqn.relax(); - } + eEqn.relax + ( + mesh.solutionDict().relaxationFactor(e.select(pimple.finalIter())) + ); eEqn.solve(); diff --git a/applications/solvers/compressible/sonicFoam/pEqn.H b/applications/solvers/compressible/sonicFoam/pEqn.H index 2a53cc3ec..686acebaa 100644 --- a/applications/solvers/compressible/sonicFoam/pEqn.H +++ b/applications/solvers/compressible/sonicFoam/pEqn.H @@ -1,7 +1,7 @@ { U = UEqn.H()/UEqn.A(); - for (int nonOrth = 0; nonOrth <= nNonOrthCorr; nonOrth++) + while (pimple.correctNonOrthogonal()) { // Calculate phi for boundary conditions phi = rhof* @@ -36,7 +36,7 @@ pEqn.solve(); // Calculate the flux - if (nonOrth == nNonOrthCorr) + if (pimple.finalNonOrthogonalIter()) { phi = phid2 + pEqn.flux(); } diff --git a/applications/solvers/compressible/sonicFoam/sonicFoam.C b/applications/solvers/compressible/sonicFoam/sonicFoam.C index fb11a64bc..9085439ee 100644 --- a/applications/solvers/compressible/sonicFoam/sonicFoam.C +++ b/applications/solvers/compressible/sonicFoam/sonicFoam.C @@ -42,6 +42,7 @@ Author #include "fvCFD.H" #include "basicPsiThermo.H" #include "turbulenceModel.H" +#include "pimpleControl.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -50,6 +51,9 @@ int main(int argc, char *argv[]) # include "setRootCase.H" # include "createTime.H" # include "createMesh.H" + + pimpleControl pimple(mesh); + # include "createFields.H" # include "initContinuityErrs.H" # include "createTimeControls.H" @@ -61,7 +65,6 @@ int main(int argc, char *argv[]) while (runTime.run()) { # include "readTimeControls.H" -# include "readPIMPLEControls.H" # include "compressibleCourantNo.H" # include "setDeltaT.H" @@ -70,8 +73,7 @@ int main(int argc, char *argv[]) Info<< "Time = " << runTime.timeName() << nl << endl; // --- PIMPLE loop - label oCorr = 0; - do + while (pimple.loop()) { # include "rhoEqn.H" # include "eEqn.H" @@ -87,13 +89,13 @@ int main(int argc, char *argv[]) // but psi and rho are not surfaceScalarField rhoReff = rhof - psisf*fvc::interpolate(p); - for (int corr = 0; corr < nCorr; corr++) + while (pimple.correct()) { # include "pEqn.H" } turbulence->correct(); - } while (++oCorr < nOuterCorr); + } runTime.write(); diff --git a/applications/solvers/compressible/sonicLiquidFoam/compressibleContinuityErrs.H b/applications/solvers/compressible/sonicLiquidFoam/compressibleContinuityErrs.H index 9851dfb7a..313cf3272 100644 --- a/applications/solvers/compressible/sonicLiquidFoam/compressibleContinuityErrs.H +++ b/applications/solvers/compressible/sonicLiquidFoam/compressibleContinuityErrs.H @@ -1,8 +1,8 @@ { - scalar sumLocalContErr = + sumLocalContErr = (sum(mag(rho - rho0 - psi*(p - p0)))/sum(rho)).value(); - scalar globalContErr = (sum(rho - rho0 - psi*(p - p0))/sum(rho)).value(); + globalContErr = (sum(rho - rho0 - psi*(p - p0))/sum(rho)).value(); cumulativeContErr += globalContErr; diff --git a/applications/solvers/compressible/sonicLiquidFoam/createFields.H b/applications/solvers/compressible/sonicLiquidFoam/createFields.H index f419234c7..cf3dce8f8 100644 --- a/applications/solvers/compressible/sonicLiquidFoam/createFields.H +++ b/applications/solvers/compressible/sonicLiquidFoam/createFields.H @@ -42,3 +42,5 @@ # include "compressibleCreatePhi.H" + + mesh.schemesDict().setFluxRequired(p.name()); diff --git a/applications/solvers/compressible/sonicLiquidFoam/sonicLiquidFoam.C b/applications/solvers/compressible/sonicLiquidFoam/sonicLiquidFoam.C index 66df9e7df..259dc677a 100644 --- a/applications/solvers/compressible/sonicLiquidFoam/sonicLiquidFoam.C +++ b/applications/solvers/compressible/sonicLiquidFoam/sonicLiquidFoam.C @@ -31,6 +31,7 @@ Description \*---------------------------------------------------------------------------*/ #include "fvCFD.H" +#include "pimpleControl.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -39,6 +40,9 @@ int main(int argc, char *argv[]) # include "setRootCase.H" # include "createTime.H" # include "createMesh.H" + + pimpleControl pimple(mesh); + # include "readThermodynamicProperties.H" # include "readTransportProperties.H" # include "createFields.H" @@ -52,14 +56,12 @@ int main(int argc, char *argv[]) { Info<< "Time = " << runTime.timeName() << nl << endl; -# include "readPIMPLEControls.H" # include "compressibleCourantNo.H" # include "rhoEqn.H" // --- PIMPLE loop - label oCorr = 0; - do + while (pimple.loop()) { fvVectorMatrix UEqn ( @@ -71,7 +73,7 @@ int main(int argc, char *argv[]) solve(UEqn == -fvc::grad(p)); // --- PISO loop - for (int corr = 0; corr < nCorr; corr++) + while (pimple.correct()) { volScalarField rAU("rAU", 1.0/UEqn.A()); surfaceScalarField rhorAUf @@ -113,7 +115,7 @@ int main(int argc, char *argv[]) U -= rAU*fvc::grad(p); U.correctBoundaryConditions(); } - } while (++oCorr < nOuterCorr); + } // Correct density diff --git a/applications/solvers/compressible/steadyCompressibleFoam/UEqn.H b/applications/solvers/compressible/steadyCompressibleFoam/UEqn.H index 4e2e22af0..204c349fb 100644 --- a/applications/solvers/compressible/steadyCompressibleFoam/UEqn.H +++ b/applications/solvers/compressible/steadyCompressibleFoam/UEqn.H @@ -10,9 +10,4 @@ UEqn.relax(); - eqnResidual = solve - ( - UEqn == -fvc::grad(p) - ).initialResidual(); - - maxResidual = max(eqnResidual, maxResidual); + solve(UEqn == -fvc::grad(p)); diff --git a/applications/solvers/compressible/steadyCompressibleFoam/convergenceCheck.H b/applications/solvers/compressible/steadyCompressibleFoam/convergenceCheck.H deleted file mode 100644 index 895806319..000000000 --- a/applications/solvers/compressible/steadyCompressibleFoam/convergenceCheck.H +++ /dev/null @@ -1,9 +0,0 @@ -// check convergence - -if (maxResidual < convergenceCriterion) -{ - Info<< "reached convergence criterion: " << convergenceCriterion << endl; - runTime.writeAndEnd(); - Info<< "latestTime = " << runTime.timeName() << endl; -} - diff --git a/applications/solvers/compressible/steadyCompressibleFoam/createFields.H b/applications/solvers/compressible/steadyCompressibleFoam/createFields.H index e5329725d..daead2e3d 100644 --- a/applications/solvers/compressible/steadyCompressibleFoam/createFields.H +++ b/applications/solvers/compressible/steadyCompressibleFoam/createFields.H @@ -60,3 +60,5 @@ thermo ) ); + + mesh.schemesDict().setFluxRequired(p.name()); diff --git a/applications/solvers/compressible/steadyCompressibleFoam/hEqn.H b/applications/solvers/compressible/steadyCompressibleFoam/hEqn.H index 728fdb6da..c93a3b888 100644 --- a/applications/solvers/compressible/steadyCompressibleFoam/hEqn.H +++ b/applications/solvers/compressible/steadyCompressibleFoam/hEqn.H @@ -17,8 +17,7 @@ hEqn.relax(); - eqnResidual = hEqn.solve().initialResidual(); - maxResidual = max(eqnResidual, maxResidual); + hEqn.solve(); // Bounding of enthalpy taken out thermo.correct(); diff --git a/applications/solvers/compressible/steadyCompressibleFoam/initConvergenceCheck.H b/applications/solvers/compressible/steadyCompressibleFoam/initConvergenceCheck.H deleted file mode 100644 index 47a1852f0..000000000 --- a/applications/solvers/compressible/steadyCompressibleFoam/initConvergenceCheck.H +++ /dev/null @@ -1,7 +0,0 @@ -// initialize values for convergence checks - - scalar eqnResidual = 1, maxResidual = 0; - scalar convergenceCriterion = 0; - - pimple.readIfPresent("convergence", convergenceCriterion); - diff --git a/applications/solvers/compressible/steadyCompressibleFoam/pEqn.H b/applications/solvers/compressible/steadyCompressibleFoam/pEqn.H index 5736d3d6f..5b3df948f 100644 --- a/applications/solvers/compressible/steadyCompressibleFoam/pEqn.H +++ b/applications/solvers/compressible/steadyCompressibleFoam/pEqn.H @@ -8,7 +8,7 @@ surfaceScalarField rhoReff = rhof - psisf*fvc::interpolate(p); // --- PISO loop - for (int corr = 0; corr < nCorr; corr++) + while (pimple.correct()) { U = rUA*UEqn.H(); @@ -21,13 +21,7 @@ p.storePrevIter(); - volScalarField divPhid - ( - "divPhid", - fvc::div(phid) - ); - - for (int nonOrth = 0; nonOrth <= nNonOrthCorr; nonOrth++) + while (pimple.correctNonOrthogonal()) { fvScalarMatrix pEqn ( @@ -40,16 +34,10 @@ - fvm::laplacian(rho*rUA, p) ); - // Retain the residual from the first pressure solution - eqnResidual = pEqn.solve().initialResidual(); - - if (corr == 0 && nonOrth == 0) - { - maxResidual = max(eqnResidual, maxResidual); - } + pEqn.solve(); // Calculate the flux - if (nonOrth == nNonOrthCorr) + if (pimple.finalNonOrthogonalIter()) { phi = phid2 + pEqn.flux(); } diff --git a/applications/solvers/compressible/steadyCompressibleFoam/steadyCompressibleFoam.C b/applications/solvers/compressible/steadyCompressibleFoam/steadyCompressibleFoam.C index e1d2c9732..4fcdd878e 100644 --- a/applications/solvers/compressible/steadyCompressibleFoam/steadyCompressibleFoam.C +++ b/applications/solvers/compressible/steadyCompressibleFoam/steadyCompressibleFoam.C @@ -35,6 +35,7 @@ Author #include "fvCFD.H" #include "basicPsiThermo.H" #include "RASModel.H" +#include "pimpleControl.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -45,8 +46,10 @@ int main(int argc, char *argv[]) # include "createTime.H" # include "createMesh.H" + + pimpleControl pimple(mesh); + # include "createFields.H" -# include "readPIMPLEControls.H" # include "initContinuityErrs.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -57,11 +60,8 @@ int main(int argc, char *argv[]) { Info<< "Time = " << runTime.timeName() << nl << endl; -# include "readPIMPLEControls.H" # include "readFieldBounds.H" -# include "initConvergenceCheck.H" - # include "UEqn.H" # include "pEqn.H" @@ -77,8 +77,6 @@ int main(int argc, char *argv[]) Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" << " ClockTime = " << runTime.elapsedClockTime() << " s" << nl << endl; - -# include "convergenceCheck.H" } Info<< "End\n" << endl; diff --git a/applications/solvers/compressible/steadyCompressibleMRFFoam/UEqn.H b/applications/solvers/compressible/steadyCompressibleMRFFoam/UEqn.H index 1c39c948b..f1c57b01d 100644 --- a/applications/solvers/compressible/steadyCompressibleMRFFoam/UEqn.H +++ b/applications/solvers/compressible/steadyCompressibleMRFFoam/UEqn.H @@ -13,9 +13,4 @@ UEqn.relax(); - eqnResidual = solve - ( - UEqn == -fvc::grad(p) - ).initialResidual(); - - maxResidual = max(eqnResidual, maxResidual); + solve(UEqn == -fvc::grad(p)); diff --git a/applications/solvers/compressible/steadyCompressibleMRFFoam/convergenceCheck.H b/applications/solvers/compressible/steadyCompressibleMRFFoam/convergenceCheck.H deleted file mode 100644 index 895806319..000000000 --- a/applications/solvers/compressible/steadyCompressibleMRFFoam/convergenceCheck.H +++ /dev/null @@ -1,9 +0,0 @@ -// check convergence - -if (maxResidual < convergenceCriterion) -{ - Info<< "reached convergence criterion: " << convergenceCriterion << endl; - runTime.writeAndEnd(); - Info<< "latestTime = " << runTime.timeName() << endl; -} - diff --git a/applications/solvers/compressible/steadyCompressibleMRFFoam/createFields.H b/applications/solvers/compressible/steadyCompressibleMRFFoam/createFields.H index 6b466f155..7dc807fd1 100644 --- a/applications/solvers/compressible/steadyCompressibleMRFFoam/createFields.H +++ b/applications/solvers/compressible/steadyCompressibleMRFFoam/createFields.H @@ -101,3 +101,5 @@ h ); i == h - 0.5*(magSqr(Urot) - magSqr(Urel)); + + mesh.schemesDict().setFluxRequired(p.name()); diff --git a/applications/solvers/compressible/steadyCompressibleMRFFoam/hEqn.H b/applications/solvers/compressible/steadyCompressibleMRFFoam/hEqn.H index 6bf1b5f52..3aebca26b 100644 --- a/applications/solvers/compressible/steadyCompressibleMRFFoam/hEqn.H +++ b/applications/solvers/compressible/steadyCompressibleMRFFoam/hEqn.H @@ -25,9 +25,6 @@ hEqn.relax(); - eqnResidual = hEqn.solve().initialResidual(); - maxResidual = max(eqnResidual, maxResidual); - // Bounding of enthalpy taken out thermo.correct(); psis = thermo.psi()/thermo.Cp()*thermo.Cv(); diff --git a/applications/solvers/compressible/steadyCompressibleMRFFoam/iEqn.H b/applications/solvers/compressible/steadyCompressibleMRFFoam/iEqn.H index d3d754972..2fa37cfcc 100644 --- a/applications/solvers/compressible/steadyCompressibleMRFFoam/iEqn.H +++ b/applications/solvers/compressible/steadyCompressibleMRFFoam/iEqn.H @@ -20,8 +20,7 @@ iEqn.relax(); - eqnResidual = iEqn.solve().initialResidual(); - maxResidual = max(eqnResidual, maxResidual); + iEqn.solve(); // Calculate enthalpy out of rothalpy h = i + 0.5*(magSqr(Urot) - magSqr(Urel)); diff --git a/applications/solvers/compressible/steadyCompressibleMRFFoam/initConvergenceCheck.H b/applications/solvers/compressible/steadyCompressibleMRFFoam/initConvergenceCheck.H deleted file mode 100644 index 47a1852f0..000000000 --- a/applications/solvers/compressible/steadyCompressibleMRFFoam/initConvergenceCheck.H +++ /dev/null @@ -1,7 +0,0 @@ -// initialize values for convergence checks - - scalar eqnResidual = 1, maxResidual = 0; - scalar convergenceCriterion = 0; - - pimple.readIfPresent("convergence", convergenceCriterion); - diff --git a/applications/solvers/compressible/steadyCompressibleMRFFoam/pEqn.H b/applications/solvers/compressible/steadyCompressibleMRFFoam/pEqn.H index f66193394..1d30e61e4 100644 --- a/applications/solvers/compressible/steadyCompressibleMRFFoam/pEqn.H +++ b/applications/solvers/compressible/steadyCompressibleMRFFoam/pEqn.H @@ -4,11 +4,10 @@ surfaceScalarField psisf = fvc::interpolate(psis); surfaceScalarField rhof = fvc::interpolate(rho); - // Needs to be outside of loop since p is changing, but psi and rho are not + // Needs to be outside of loop since p is changing, but psi and rho are not. surfaceScalarField rhoReff = rhof - psisf*fvc::interpolate(p); - // --- PISO loop - for (int corr = 0; corr < nCorr; corr++) + while (pimple.correct()) { U = rUA*UEqn.H(); @@ -26,13 +25,7 @@ p.storePrevIter(); - volScalarField divPhid - ( - "divPhid", - fvc::div(phid) - ); - - for (int nonOrth = 0; nonOrth <= nNonOrthCorr; nonOrth++) + while (pimple.correctNonOrthogonal()) { fvScalarMatrix pEqn ( @@ -45,16 +38,10 @@ - fvm::laplacian(rho*rUA, p) ); - // Retain the residual from the first pressure solution - eqnResidual = pEqn.solve().initialResidual(); - - if (corr == 0 && nonOrth == 0) - { - maxResidual = max(eqnResidual, maxResidual); - } + pEqn.solve(); // Calculate the flux - if (nonOrth == nNonOrthCorr) + if (pimple.finalNonOrthogonalIter()) { phi = phid2 + pEqn.flux(); } diff --git a/applications/solvers/compressible/steadyCompressibleMRFFoam/steadyCompressibleMRFFoam.C b/applications/solvers/compressible/steadyCompressibleMRFFoam/steadyCompressibleMRFFoam.C index 1ec4bd8c8..84337526b 100644 --- a/applications/solvers/compressible/steadyCompressibleMRFFoam/steadyCompressibleMRFFoam.C +++ b/applications/solvers/compressible/steadyCompressibleMRFFoam/steadyCompressibleMRFFoam.C @@ -37,6 +37,7 @@ Author #include "basicPsiThermo.H" #include "RASModel.H" #include "MRFZones.H" +#include "pimpleControl.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -47,8 +48,10 @@ int main(int argc, char *argv[]) # include "createTime.H" # include "createMesh.H" + + pimpleControl pimple(mesh); + # include "createFields.H" -# include "readPIMPLEControls.H" # include "initContinuityErrs.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -59,11 +62,8 @@ int main(int argc, char *argv[]) { Info<< "Time = " << runTime.timeName() << nl << endl; -# include "readPIMPLEControls.H" # include "readFieldBounds.H" -# include "initConvergenceCheck.H" - # include "UEqn.H" # include "pEqn.H" @@ -81,8 +81,6 @@ int main(int argc, char *argv[]) Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" << " ClockTime = " << runTime.elapsedClockTime() << " s" << nl << endl; - -# include "convergenceCheck.H" } Info<< "End\n" << endl; diff --git a/applications/solvers/compressible/steadyCompressibleSRFFoam/UEqn.H b/applications/solvers/compressible/steadyCompressibleSRFFoam/UEqn.H index 334595328..79e6bc93c 100644 --- a/applications/solvers/compressible/steadyCompressibleSRFFoam/UEqn.H +++ b/applications/solvers/compressible/steadyCompressibleSRFFoam/UEqn.H @@ -11,9 +11,4 @@ UrelEqn.relax(); - eqnResidual = solve - ( - UrelEqn == -fvc::grad(p) - ).initialResidual(); - - maxResidual = max(eqnResidual, maxResidual); + solve(UrelEqn == -fvc::grad(p)); diff --git a/applications/solvers/compressible/steadyCompressibleSRFFoam/convergenceCheck.H b/applications/solvers/compressible/steadyCompressibleSRFFoam/convergenceCheck.H deleted file mode 100644 index 895806319..000000000 --- a/applications/solvers/compressible/steadyCompressibleSRFFoam/convergenceCheck.H +++ /dev/null @@ -1,9 +0,0 @@ -// check convergence - -if (maxResidual < convergenceCriterion) -{ - Info<< "reached convergence criterion: " << convergenceCriterion << endl; - runTime.writeAndEnd(); - Info<< "latestTime = " << runTime.timeName() << endl; -} - diff --git a/applications/solvers/compressible/steadyCompressibleSRFFoam/createFields.H b/applications/solvers/compressible/steadyCompressibleSRFFoam/createFields.H index 8ed2f88c5..bf7075ae4 100644 --- a/applications/solvers/compressible/steadyCompressibleSRFFoam/createFields.H +++ b/applications/solvers/compressible/steadyCompressibleSRFFoam/createFields.H @@ -104,3 +104,5 @@ h ); i == h - 0.5*(magSqr(Urot) - magSqr(Urel)); + + mesh.schemesDict().setFluxRequired(p.name()); diff --git a/applications/solvers/compressible/steadyCompressibleSRFFoam/iEqn.H b/applications/solvers/compressible/steadyCompressibleSRFFoam/iEqn.H index de48d20d6..c37796f06 100644 --- a/applications/solvers/compressible/steadyCompressibleSRFFoam/iEqn.H +++ b/applications/solvers/compressible/steadyCompressibleSRFFoam/iEqn.H @@ -13,8 +13,7 @@ iEqn.relax(); - eqnResidual = iEqn.solve().initialResidual(); - maxResidual = max(eqnResidual, maxResidual); + iEqn.solve(); // Calculate enthalpy out of rothalpy h = i + 0.5*(magSqr(Urot) - magSqr(Urel)); diff --git a/applications/solvers/compressible/steadyCompressibleSRFFoam/initConvergenceCheck.H b/applications/solvers/compressible/steadyCompressibleSRFFoam/initConvergenceCheck.H deleted file mode 100644 index 47a1852f0..000000000 --- a/applications/solvers/compressible/steadyCompressibleSRFFoam/initConvergenceCheck.H +++ /dev/null @@ -1,7 +0,0 @@ -// initialize values for convergence checks - - scalar eqnResidual = 1, maxResidual = 0; - scalar convergenceCriterion = 0; - - pimple.readIfPresent("convergence", convergenceCriterion); - diff --git a/applications/solvers/compressible/steadyCompressibleSRFFoam/pEqn.H b/applications/solvers/compressible/steadyCompressibleSRFFoam/pEqn.H index f4429ad0f..3a8a1162b 100644 --- a/applications/solvers/compressible/steadyCompressibleSRFFoam/pEqn.H +++ b/applications/solvers/compressible/steadyCompressibleSRFFoam/pEqn.H @@ -4,11 +4,10 @@ surfaceScalarField psisf = fvc::interpolate(psis); surfaceScalarField rhof = fvc::interpolate(rho); - // Needs to be outside of loop since p is changing, but psi and rho are not + // Needs to be outside of loop since p is changing, but psi and rho are not. surfaceScalarField rhoReff = rhof - psisf*fvc::interpolate(p); - // --- PISO loop - for (int corr = 0; corr < nCorr; corr++) + while (pimple.correct()) { Urel = rUrelA*UrelEqn.H(); @@ -21,13 +20,7 @@ p.storePrevIter(); - volScalarField divPhid - ( - "divPhid", - fvc::div(phid) - ); - - for (int nonOrth = 0; nonOrth <= nNonOrthCorr; nonOrth++) + while (pimple.correctNonOrthogonal()) { fvScalarMatrix pEqn ( @@ -40,16 +33,10 @@ - fvm::laplacian(rho*rUrelA, p) ); - // Retain the residual from the first pressure solution - eqnResidual = pEqn.solve().initialResidual(); - - if (corr == 0 && nonOrth == 0) - { - maxResidual = max(eqnResidual, maxResidual); - } + pEqn.solve(); // Calculate the flux - if (nonOrth == nNonOrthCorr) + if (pimple.finalNonOrthogonalIter()) { phi = phid2 + pEqn.flux(); } diff --git a/applications/solvers/compressible/steadyCompressibleSRFFoam/steadyCompressibleSRFFoam.C b/applications/solvers/compressible/steadyCompressibleSRFFoam/steadyCompressibleSRFFoam.C index 86957b3bf..de683db1b 100644 --- a/applications/solvers/compressible/steadyCompressibleSRFFoam/steadyCompressibleSRFFoam.C +++ b/applications/solvers/compressible/steadyCompressibleSRFFoam/steadyCompressibleSRFFoam.C @@ -37,6 +37,7 @@ Author #include "basicPsiThermo.H" #include "RASModel.H" #include "SRFModel.H" +#include "pimpleControl.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -47,8 +48,10 @@ int main(int argc, char *argv[]) # include "createTime.H" # include "createMesh.H" + + pimpleControl pimple(mesh); + # include "createFields.H" -# include "readPIMPLEControls.H" # include "initContinuityErrs.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -59,11 +62,8 @@ int main(int argc, char *argv[]) { Info<< "Time = " << runTime.timeName() << nl << endl; -# include "readPIMPLEControls.H" # include "readFieldBounds.H" -# include "initConvergenceCheck.H" - # include "UEqn.H" # include "pEqn.H" @@ -87,8 +87,6 @@ int main(int argc, char *argv[]) Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" << " ClockTime = " << runTime.elapsedClockTime() << " s" << nl << endl; - -# include "convergenceCheck.H" } Info<< "End\n" << endl; diff --git a/applications/solvers/coupled/MRFPorousFoam/createFields.H b/applications/solvers/coupled/MRFPorousFoam/createFields.H index d06ae12d7..7a3ee5372 100644 --- a/applications/solvers/coupled/MRFPorousFoam/createFields.H +++ b/applications/solvers/coupled/MRFPorousFoam/createFields.H @@ -56,3 +56,5 @@ Info<< "Creating field rAU\n" << endl; // will be used. HJ, 1/Mar/2016 tmp trAU; tmp trTU; + +mesh.schemesDict().setFluxRequired(p.name()); diff --git a/applications/solvers/coupled/blockCoupledScalarTransportFoam/blockCoupledScalarTransportFoam.C b/applications/solvers/coupled/blockCoupledScalarTransportFoam/blockCoupledScalarTransportFoam.C index 413ee4e5a..66a486307 100644 --- a/applications/solvers/coupled/blockCoupledScalarTransportFoam/blockCoupledScalarTransportFoam.C +++ b/applications/solvers/coupled/blockCoupledScalarTransportFoam/blockCoupledScalarTransportFoam.C @@ -39,7 +39,7 @@ Description #include "foamTime.H" #include "fvMesh.H" #include "fvBlockMatrix.H" - +#include "simpleControl.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -49,6 +49,9 @@ int main(int argc, char *argv[]) # include "setRootCase.H" # include "createTime.H" # include "createMesh.H" + + simpleControl simple(mesh); + # include "createFields.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -57,13 +60,11 @@ int main(int argc, char *argv[]) # include "CourantNo.H" - for (runTime++; !runTime.end(); runTime++) + while (simple.loop()) { Info<< "Time = " << runTime.timeName() << nl << endl; -# include "readSIMPLEControls.H" - - for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) + while (simple.correctNonOrthogonal()) { fvScalarMatrix TEqn ( diff --git a/applications/solvers/coupled/conjugateHeatFoam/UEqn.H b/applications/solvers/coupled/conjugateHeatFoam/UEqn.H index df6f90ac0..10aeeb0c6 100644 --- a/applications/solvers/coupled/conjugateHeatFoam/UEqn.H +++ b/applications/solvers/coupled/conjugateHeatFoam/UEqn.H @@ -9,7 +9,7 @@ UEqn.relax(); - if (momentumPredictor) + if (piso.momentumPredictor()) { solve ( diff --git a/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatFoam.C b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatFoam.C index 8fe806845..3f8e90dac 100644 --- a/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatFoam.C +++ b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatFoam.C @@ -38,6 +38,8 @@ Description #include "thermalModel.H" #include "singlePhaseTransportModel.H" #include "RASModel.H" +#include "pisoControl.H" +#include "simpleControl.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -47,6 +49,9 @@ int main(int argc, char *argv[]) # include "createTime.H" # include "createFluidMesh.H" # include "createSolidMesh.H" + + pisoControl piso(mesh); + # include "readGravitationalAcceleration.H" # include "createFields.H" # include "createSolidFields.H" @@ -64,7 +69,6 @@ int main(int argc, char *argv[]) Info<< "Time = " << runTime.timeName() << nl << endl; # include "readTimeControls.H" -# include "readPISOControls.H" # include "CourantNo.H" # include "setDeltaT.H" @@ -75,7 +79,7 @@ int main(int argc, char *argv[]) p_rgh.storePrevIter(); - for (int corr = 0; corr < nCorr; corr++) + while (piso.correct()) { # include "pEqn.H" } diff --git a/applications/solvers/coupled/conjugateHeatFoam/createFields.H b/applications/solvers/coupled/conjugateHeatFoam/createFields.H index 720ef6deb..d04677e18 100644 --- a/applications/solvers/coupled/conjugateHeatFoam/createFields.H +++ b/applications/solvers/coupled/conjugateHeatFoam/createFields.H @@ -64,13 +64,8 @@ label pRefCell = 0; scalar pRefValue = 0.0; - setRefCell - ( - p_rgh, - mesh.solutionDict().subDict("PISO"), - pRefCell, - pRefValue - ); + setRefCell(p_rgh, piso.dict(), pRefCell, pRefValue); + mesh.schemesDict().setFluxRequired(p_rgh.name()); autoPtr turbulence ( diff --git a/applications/solvers/coupled/conjugateHeatFoam/initConvergenceCheck.H b/applications/solvers/coupled/conjugateHeatFoam/initConvergenceCheck.H deleted file mode 100644 index b56197f22..000000000 --- a/applications/solvers/coupled/conjugateHeatFoam/initConvergenceCheck.H +++ /dev/null @@ -1,7 +0,0 @@ -// initialize values for convergence checks - - scalar eqnResidual = 1, maxResidual = 0; - scalar convergenceCriterion = 0; - - simple.readIfPresent("convergence", convergenceCriterion); - diff --git a/applications/solvers/coupled/conjugateHeatFoam/pEqn.H b/applications/solvers/coupled/conjugateHeatFoam/pEqn.H index 57e9a156d..e85345491 100644 --- a/applications/solvers/coupled/conjugateHeatFoam/pEqn.H +++ b/applications/solvers/coupled/conjugateHeatFoam/pEqn.H @@ -10,7 +10,7 @@ surfaceScalarField buoyancyPhi(rUAf*ghf*fvc::snGrad(rhok)*mesh.magSf()); phi -= buoyancyPhi; - for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) + while (piso.correctNonOrthogonal()) { fvScalarMatrix p_rghEqn ( @@ -19,16 +19,15 @@ p_rghEqn.setReference(pRefCell, pRefValue); - if (corr == nCorr-1 && nonOrth == nNonOrthCorr) - { - p_rghEqn.solve(mesh.solutionDict().solver(p_rgh.name() + "Final")); - } - else - { - p_rghEqn.solve(mesh.solutionDict().solver(p_rgh.name())); - } + p_rghEqn.solve + ( + mesh.solutionDict().solver + ( + p_rgh.select(piso.finalInnerIter()) + ) + ); - if (nonOrth == nNonOrthCorr) + if (piso.finalNonOrthogonalIter()) { // Calculate the conservative fluxes phi -= p_rghEqn.flux(); diff --git a/applications/solvers/coupled/conjugateHeatFoam/readSolidControls.H b/applications/solvers/coupled/conjugateHeatFoam/readSolidControls.H deleted file mode 100644 index c2b6f17f5..000000000 --- a/applications/solvers/coupled/conjugateHeatFoam/readSolidControls.H +++ /dev/null @@ -1,7 +0,0 @@ - const dictionary& simple = solidMesh.solutionDict().subDict("SIMPLE"); - - int nNonOrthCorr = 0; - if (simple.found("nNonOrthogonalCorrectors")) - { - nNonOrthCorr = readInt(simple.lookup("nNonOrthogonalCorrectors")); - } diff --git a/applications/solvers/coupled/conjugateHeatFoam/solveEnergy.H b/applications/solvers/coupled/conjugateHeatFoam/solveEnergy.H index e7f3c809c..61b5863c2 100644 --- a/applications/solvers/coupled/conjugateHeatFoam/solveEnergy.H +++ b/applications/solvers/coupled/conjugateHeatFoam/solveEnergy.H @@ -1,8 +1,8 @@ { // Solid side -# include "readSolidControls.H" + simpleControl simpleSolid(solidMesh); - for (int nonOrth = 0; nonOrth <= nNonOrthCorr; nonOrth++) + while (simpleSolid.correctNonOrthogonal()) { coupledFvScalarMatrix TEqns(2); diff --git a/applications/solvers/coupled/conjugateHeatSimpleFoam/UEqn.H b/applications/solvers/coupled/conjugateHeatSimpleFoam/UEqn.H index 59633497a..32510f030 100644 --- a/applications/solvers/coupled/conjugateHeatSimpleFoam/UEqn.H +++ b/applications/solvers/coupled/conjugateHeatSimpleFoam/UEqn.H @@ -9,7 +9,7 @@ UEqn().relax(); - eqnResidual = solve + solve ( UEqn() == @@ -22,6 +22,4 @@ )*mesh.magSf() ) ) - ).initialResidual(); - - maxResidual = max(eqnResidual, maxResidual); + ); diff --git a/applications/solvers/coupled/conjugateHeatSimpleFoam/conjugateHeatSimpleFoam.C b/applications/solvers/coupled/conjugateHeatSimpleFoam/conjugateHeatSimpleFoam.C index 9a1e44be9..a34d1a3ed 100644 --- a/applications/solvers/coupled/conjugateHeatSimpleFoam/conjugateHeatSimpleFoam.C +++ b/applications/solvers/coupled/conjugateHeatSimpleFoam/conjugateHeatSimpleFoam.C @@ -38,6 +38,7 @@ Description #include "thermalModel.H" #include "singlePhaseTransportModel.H" #include "RASModel.H" +#include "simpleControl.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -47,6 +48,9 @@ int main(int argc, char *argv[]) # include "createTime.H" # include "createFluidMesh.H" # include "createSolidMesh.H" + + simpleControl simple(mesh); + # include "readGravitationalAcceleration.H" # include "createFields.H" # include "createSolidFields.H" @@ -56,13 +60,10 @@ int main(int argc, char *argv[]) Info<< "\nStarting time loop\n" << endl; - while (runTime.loop()) + while (simple.loop()) { Info<< "Time = " << runTime.timeName() << nl << endl; -# include "readSIMPLEControls.H" -# include "initConvergenceCheck.H" - // Detach patches # include "detachPatches.H" diff --git a/applications/solvers/coupled/conjugateHeatSimpleFoam/createFields.H b/applications/solvers/coupled/conjugateHeatSimpleFoam/createFields.H index e84f341f8..42330b79f 100644 --- a/applications/solvers/coupled/conjugateHeatSimpleFoam/createFields.H +++ b/applications/solvers/coupled/conjugateHeatSimpleFoam/createFields.H @@ -64,13 +64,8 @@ label pRefCell = 0; scalar pRefValue = 0.0; - setRefCell - ( - p_rgh, - mesh.solutionDict().subDict("SIMPLE"), - pRefCell, - pRefValue - ); + setRefCell(p_rgh, simple.dict(), pRefCell, pRefValue); + mesh.schemesDict().setFluxRequired(p_rgh.name()); autoPtr turbulence ( diff --git a/applications/solvers/coupled/conjugateHeatSimpleFoam/initConvergenceCheck.H b/applications/solvers/coupled/conjugateHeatSimpleFoam/initConvergenceCheck.H deleted file mode 100644 index b56197f22..000000000 --- a/applications/solvers/coupled/conjugateHeatSimpleFoam/initConvergenceCheck.H +++ /dev/null @@ -1,7 +0,0 @@ -// initialize values for convergence checks - - scalar eqnResidual = 1, maxResidual = 0; - scalar convergenceCriterion = 0; - - simple.readIfPresent("convergence", convergenceCriterion); - diff --git a/applications/solvers/coupled/conjugateHeatSimpleFoam/pEqn.H b/applications/solvers/coupled/conjugateHeatSimpleFoam/pEqn.H index 559b052c6..dddf81e5b 100644 --- a/applications/solvers/coupled/conjugateHeatSimpleFoam/pEqn.H +++ b/applications/solvers/coupled/conjugateHeatSimpleFoam/pEqn.H @@ -11,7 +11,7 @@ surfaceScalarField buoyancyPhi(rUAf*ghf*fvc::snGrad(rhok)*mesh.magSf()); phi -= buoyancyPhi; - for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) + while (simple.correctNonOrthogonal()) { fvScalarMatrix p_rghEqn ( @@ -20,18 +20,9 @@ p_rghEqn.setReference(pRefCell, pRefValue); - // retain the residual from the first iteration - if (nonOrth == 0) - { - eqnResidual = p_rghEqn.solve().initialResidual(); - maxResidual = max(eqnResidual, maxResidual); - } - else - { - p_rghEqn.solve(); - } + p_rghEqn.solve(); - if (nonOrth == nNonOrthCorr) + if (simple.finalNonOrthogonalIter()) { // Calculate the conservative fluxes phi -= p_rghEqn.flux(); diff --git a/applications/solvers/coupled/conjugateHeatSimpleFoam/readSolidControls.H b/applications/solvers/coupled/conjugateHeatSimpleFoam/readSolidControls.H deleted file mode 100644 index c2b6f17f5..000000000 --- a/applications/solvers/coupled/conjugateHeatSimpleFoam/readSolidControls.H +++ /dev/null @@ -1,7 +0,0 @@ - const dictionary& simple = solidMesh.solutionDict().subDict("SIMPLE"); - - int nNonOrthCorr = 0; - if (simple.found("nNonOrthogonalCorrectors")) - { - nNonOrthCorr = readInt(simple.lookup("nNonOrthogonalCorrectors")); - } diff --git a/applications/solvers/coupled/conjugateHeatSimpleFoam/solveEnergy.H b/applications/solvers/coupled/conjugateHeatSimpleFoam/solveEnergy.H index 95d0a236a..833d954e8 100644 --- a/applications/solvers/coupled/conjugateHeatSimpleFoam/solveEnergy.H +++ b/applications/solvers/coupled/conjugateHeatSimpleFoam/solveEnergy.H @@ -1,8 +1,8 @@ { // Solid side -# include "readSolidControls.H" + simpleControl simpleSolid(solidMesh); - for (int nonOrth = 0; nonOrth <= nNonOrthCorr; nonOrth++) + while (simpleSolid.correctNonOrthogonal()) { coupledFvScalarMatrix TEqns(2); diff --git a/applications/solvers/coupled/pUCoupledFoam/createFields.H b/applications/solvers/coupled/pUCoupledFoam/createFields.H index 2a2a4a833..179cbd40f 100644 --- a/applications/solvers/coupled/pUCoupledFoam/createFields.H +++ b/applications/solvers/coupled/pUCoupledFoam/createFields.H @@ -65,3 +65,5 @@ volScalarField rAU mesh, runTime.deltaT() ); + +mesh.schemesDict().setFluxRequired(p.name()); \ No newline at end of file diff --git a/applications/solvers/electromagnetics/mhdFoam/createFields.H b/applications/solvers/electromagnetics/mhdFoam/createFields.H index b54cae44c..d5a0e62de 100644 --- a/applications/solvers/electromagnetics/mhdFoam/createFields.H +++ b/applications/solvers/electromagnetics/mhdFoam/createFields.H @@ -104,4 +104,7 @@ label pRefCell = 0; scalar pRefValue = 0.0; - setRefCell(p, mesh.solutionDict().subDict("PISO"), pRefCell, pRefValue); + setRefCell(p, piso.dict(), pRefCell, pRefValue); + mesh.schemesDict().setFluxRequired(p.name()); + + mesh.schemesDict().setFluxRequired(pB.name()); diff --git a/applications/solvers/electromagnetics/mhdFoam/mhdFoam.C b/applications/solvers/electromagnetics/mhdFoam/mhdFoam.C index 44394f123..06058ce45 100644 --- a/applications/solvers/electromagnetics/mhdFoam/mhdFoam.C +++ b/applications/solvers/electromagnetics/mhdFoam/mhdFoam.C @@ -50,6 +50,7 @@ Description #include "fvCFD.H" #include "OSspecific.H" +#include "pisoControl.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -59,6 +60,9 @@ int main(int argc, char *argv[]) # include "createTime.H" # include "createMesh.H" + + pisoControl piso(mesh); + # include "createFields.H" # include "initContinuityErrs.H" @@ -69,7 +73,6 @@ int main(int argc, char *argv[]) while (runTime.loop()) { -# include "readPISOControls.H" # include "readBPISOControls.H" Info<< "Time = " << runTime.timeName() << nl << endl; @@ -91,7 +94,7 @@ int main(int argc, char *argv[]) // --- PISO loop - for (int corr = 0; corr < nCorr; corr++) + while (piso.correct()) { volScalarField rUA = 1.0/UEqn.A(); @@ -100,7 +103,7 @@ int main(int argc, char *argv[]) phi = (fvc::interpolate(U) & mesh.Sf()) + fvc::ddtPhiCorr(rUA, U, phi); - for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) + while (piso.correctNonOrthogonal()) { fvScalarMatrix pEqn ( @@ -110,7 +113,7 @@ int main(int argc, char *argv[]) pEqn.setReference(pRefCell, pRefValue); pEqn.solve(); - if (nonOrth == nNonOrthCorr) + if (piso.finalNonOrthogonalIter()) { phi -= pEqn.flux(); } diff --git a/applications/solvers/engine/icoDyMEngineFoam/createFields.H b/applications/solvers/engine/icoDyMEngineFoam/createFields.H index 9e28b859b..3fbf47549 100644 --- a/applications/solvers/engine/icoDyMEngineFoam/createFields.H +++ b/applications/solvers/engine/icoDyMEngineFoam/createFields.H @@ -52,7 +52,7 @@ label pRefCell = 0; scalar pRefValue = 0.0; - setRefCell(p, mesh.solutionDict().subDict("PISO"), pRefCell, pRefValue); + setRefCell(p, piso.dict(), pRefCell, pRefValue); mesh.schemesDict().setFluxRequired(p.name()); scalar totalVolume = sum(mesh.V()).value(); diff --git a/applications/solvers/engine/sonicTurbDyMEngineFoam/UEqn.H b/applications/solvers/engine/sonicTurbDyMEngineFoam/UEqn.H index 21a4d5fab..07f87de6a 100644 --- a/applications/solvers/engine/sonicTurbDyMEngineFoam/UEqn.H +++ b/applications/solvers/engine/sonicTurbDyMEngineFoam/UEqn.H @@ -6,13 +6,9 @@ + turbulence->divDevRhoReff(U) ); - if (oCorr == nOuterCorr - 1) - { - UEqn.relax(1); - } - else - { - UEqn.relax(); - } + UEqn.relax + ( + mesh.solutionDict().relaxationFactor(U.select(pimple.finalIter())) + ); solve(UEqn == -fvc::grad(p)); diff --git a/applications/solvers/engine/sonicTurbDyMEngineFoam/createFields.H b/applications/solvers/engine/sonicTurbDyMEngineFoam/createFields.H index 030e65640..6acbbcbb6 100644 --- a/applications/solvers/engine/sonicTurbDyMEngineFoam/createFields.H +++ b/applications/solvers/engine/sonicTurbDyMEngineFoam/createFields.H @@ -128,3 +128,5 @@ ), fvc::interpolate(rho) * fvc::meshPhi(U) ); + + mesh.schemesDict().setFluxRequired(p.name()); diff --git a/applications/solvers/engine/sonicTurbDyMEngineFoam/pEqn.H b/applications/solvers/engine/sonicTurbDyMEngineFoam/pEqn.H index 05075d8d7..45d692a63 100644 --- a/applications/solvers/engine/sonicTurbDyMEngineFoam/pEqn.H +++ b/applications/solvers/engine/sonicTurbDyMEngineFoam/pEqn.H @@ -4,18 +4,13 @@ rUA = 1.0/UEqn.A(); U = rUA*UEqn.H(); - if (nOuterCorr != 1) - { - p.storePrevIter(); - } - - if (transonic) + if (pimple.transonic()) { surfaceScalarField phid = fvc::interpolate(thermo.psi())* ((fvc::interpolate(U) & mesh.Sf()) - fvc::meshPhi(rho, U)); - for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) + while (pimple.correctNonOrthogonal()) { fvScalarMatrix pEqn ( @@ -26,7 +21,7 @@ pEqn.solve(); - if (nonOrth == nNonOrthCorr) + if (pimple.finalNonOrthogonalIter()) { phi == pEqn.flux(); } @@ -37,7 +32,7 @@ phi = fvc::interpolate(rho)* ((fvc::interpolate(U) & mesh.Sf()) - fvc::meshPhi(rho, U)); - for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) + while (pimple.correctNonOrthogonal()) { fvScalarMatrix pEqn ( @@ -48,7 +43,7 @@ pEqn.solve(); - if (nonOrth == nNonOrthCorr) + if (pimple.finalNonOrthogonalIter()) { phi += pEqn.flux(); } @@ -56,7 +51,7 @@ } // Explicitly relax pressure except for last corrector - if (oCorr != nOuterCorr - 1) + if (!pimple.finalIter()) { p.relax(); } diff --git a/applications/solvers/engine/sonicTurbDyMEngineFoam/sonicTurbDyMEngineFoam.C b/applications/solvers/engine/sonicTurbDyMEngineFoam/sonicTurbDyMEngineFoam.C index 04225e83b..5b2b6e2f3 100644 --- a/applications/solvers/engine/sonicTurbDyMEngineFoam/sonicTurbDyMEngineFoam.C +++ b/applications/solvers/engine/sonicTurbDyMEngineFoam/sonicTurbDyMEngineFoam.C @@ -39,6 +39,7 @@ Description #include "turbulenceModel.H" #include "Switch.H" #include "OFstream.H" +#include "pimpleControl.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -49,7 +50,9 @@ int main(int argc, char *argv[]) # include "createEngineTime.H" # include "createEngineDynamicMesh.H" -# include "readPIMPLEControls.H" + + pimpleControl pimple(mesh); + # include "createFields.H" # include "initContinuityErrs.H" # include "createTimeControls.H" @@ -67,7 +70,6 @@ int main(int argc, char *argv[]) while (runTime.run()) { -# include "readPIMPLEControls.H" # include "checkTotalVolume.H" # include "readEngineTimeControls.H" # include "compressibleCourantNo.H" @@ -106,19 +108,18 @@ int main(int argc, char *argv[]) } // Pressure-velocity corrector - int oCorr = 0; - do + while (pimple.loop()) { # include "rhoEqn.H" # include "UEqn.H" // --- PISO loop - for (int corr = 1; corr <= nCorr; corr++) + while (pimple.correct()) { # include "pEqn.H" # include "hEqn.H" } - } while (++oCorr < nOuterCorr); + } turbulence->correct(); diff --git a/applications/solvers/engine/turbDyMEngineFoam/UEqn.H b/applications/solvers/engine/turbDyMEngineFoam/UEqn.H index d60edb253..eb6b24fce 100644 --- a/applications/solvers/engine/turbDyMEngineFoam/UEqn.H +++ b/applications/solvers/engine/turbDyMEngineFoam/UEqn.H @@ -5,7 +5,7 @@ + turbulence->divDevReff(U) ); - if (momentumPredictor) + if (piso.momentumPredictor()) { solve(UEqn == -fvc::grad(p)); } diff --git a/applications/solvers/engine/turbDyMEngineFoam/correctPhi.H b/applications/solvers/engine/turbDyMEngineFoam/correctPhi.H index 5a8dc6a33..42cac00cf 100644 --- a/applications/solvers/engine/turbDyMEngineFoam/correctPhi.H +++ b/applications/solvers/engine/turbDyMEngineFoam/correctPhi.H @@ -28,7 +28,7 @@ mesh.schemesDict().setFluxRequired(pcorr.name()); - for(int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) + while (piso.correctNonOrthogonal()) { fvScalarMatrix pcorrEqn ( @@ -38,7 +38,7 @@ pcorrEqn.setReference(pRefCell, pRefValue); pcorrEqn.solve(); - if (nonOrth == nNonOrthCorr) + if (piso.finalNonOrthogonalIter()) { phi -= pcorrEqn.flux(); } diff --git a/applications/solvers/engine/turbDyMEngineFoam/createControls.H b/applications/solvers/engine/turbDyMEngineFoam/createControls.H index d76028fda..04d4121db 100644 --- a/applications/solvers/engine/turbDyMEngineFoam/createControls.H +++ b/applications/solvers/engine/turbDyMEngineFoam/createControls.H @@ -1,8 +1,6 @@ # include "createTimeControls.H" -# include "readPISOControls.H" - bool checkMeshCourantNo = false; - if (piso.found("checkMeshCourantNo")) - { - checkMeshCourantNo = Switch(piso.lookup("checkMeshCourantNo")); - } +bool checkMeshCourantNo +( + piso.dict().lookupOrDefault("checkMeshCourantNo", false) +); diff --git a/applications/solvers/engine/turbDyMEngineFoam/createFields.H b/applications/solvers/engine/turbDyMEngineFoam/createFields.H index 2db24767d..9cad74217 100644 --- a/applications/solvers/engine/turbDyMEngineFoam/createFields.H +++ b/applications/solvers/engine/turbDyMEngineFoam/createFields.H @@ -33,7 +33,8 @@ label pRefCell = 0; scalar pRefValue = 0.0; - setRefCell(p, mesh.solutionDict().subDict("PISO"), pRefCell, pRefValue); + setRefCell(p, piso.dict(), pRefCell, pRefValue); + mesh.schemesDict().setFluxRequired(p.name()); scalar totalVolume = sum(mesh.V()).value(); diff --git a/applications/solvers/engine/turbDyMEngineFoam/readControls.H b/applications/solvers/engine/turbDyMEngineFoam/readControls.H index 375b524f2..bf221077f 100644 --- a/applications/solvers/engine/turbDyMEngineFoam/readControls.H +++ b/applications/solvers/engine/turbDyMEngineFoam/readControls.H @@ -1,8 +1,3 @@ # include "readTimeControls.H" -# include "readPISOControls.H" - checkMeshCourantNo = false; - if (piso.found("checkMeshCourantNo")) - { - checkMeshCourantNo = Switch(piso.lookup("checkMeshCourantNo")); - } +checkMeshCourantNo = piso.dict().lookupOrDefault("checkMeshCourantNo", false); diff --git a/applications/solvers/engine/turbDyMEngineFoam/turbDyMEngineFoam.C b/applications/solvers/engine/turbDyMEngineFoam/turbDyMEngineFoam.C index 780a16a7f..1a8d46463 100644 --- a/applications/solvers/engine/turbDyMEngineFoam/turbDyMEngineFoam.C +++ b/applications/solvers/engine/turbDyMEngineFoam/turbDyMEngineFoam.C @@ -35,6 +35,7 @@ Description #include "turbulenceModel.H" #include "dynamicFvMesh.H" #include "engineTime.H" +#include "pisoControl.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -45,6 +46,9 @@ int main(int argc, char *argv[]) # include "createEngineTime.H" # include "createDynamicFvMesh.H" + + pisoControl piso(mesh); + # include "initContinuityErrs.H" # include "createFields.H" # include "createControls.H" @@ -89,7 +93,7 @@ int main(int argc, char *argv[]) # include "UEqn.H" // --- PISO loop - for (int corr = 0; corr < nCorr; corr++) + while (piso.correct()) { rUA = 1.0/UEqn.A(); @@ -99,7 +103,7 @@ int main(int argc, char *argv[]) adjustPhi(phi, U, p); - for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) + while (piso.correctNonOrthogonal()) { fvScalarMatrix pEqn ( @@ -108,16 +112,12 @@ int main(int argc, char *argv[]) pEqn.setReference(pRefCell, pRefValue); - if (corr == nCorr - 1 && nonOrth == nNonOrthCorr) - { - pEqn.solve(mesh.solutionDict().solver(p.name() + "Final")); - } - else - { - pEqn.solve(mesh.solutionDict().solver(p.name())); - } + pEqn.solve + ( + mesh.solutionDict().solver(p.select(piso.finalInnerIter())) + ); - if (nonOrth == nNonOrthCorr) + if (piso.finalNonOrthogonalIter()) { phi -= pEqn.flux(); } diff --git a/applications/solvers/equationReaderDemo/UEqn.H b/applications/solvers/equationReaderDemo/UEqn.H index eb40b7665..e6fb6bf89 100644 --- a/applications/solvers/equationReaderDemo/UEqn.H +++ b/applications/solvers/equationReaderDemo/UEqn.H @@ -8,9 +8,4 @@ UEqn().relax(); - eqnResidual = solve - ( - UEqn() == -fvc::grad(p) - ).initialResidual(); - - maxResidual = max(eqnResidual, maxResidual); + solve(UEqn() == -fvc::grad(p)); diff --git a/applications/solvers/equationReaderDemo/createFields.H b/applications/solvers/equationReaderDemo/createFields.H index ab4249625..239a6938f 100644 --- a/applications/solvers/equationReaderDemo/createFields.H +++ b/applications/solvers/equationReaderDemo/createFields.H @@ -31,7 +31,8 @@ label pRefCell = 0; scalar pRefValue = 0.0; - setRefCell(p, mesh.solutionDict().subDict("SIMPLE"), pRefCell, pRefValue); + setRefCell(p, simple.dict(), pRefCell, pRefValue); + mesh.schemesDict().setFluxRequired(p.name()); singlePhaseTransportModel laminarTransport(U, phi); diff --git a/applications/solvers/equationReaderDemo/equationReaderDemo.C b/applications/solvers/equationReaderDemo/equationReaderDemo.C index 78cb4890b..d7efd06ab 100644 --- a/applications/solvers/equationReaderDemo/equationReaderDemo.C +++ b/applications/solvers/equationReaderDemo/equationReaderDemo.C @@ -36,6 +36,7 @@ Author #include "singlePhaseTransportModel.H" #include "RASModel.H" #include "IOEquationReader.H" +#include "simpleControl.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -44,6 +45,9 @@ int main(int argc, char *argv[]) # include "setRootCase.H" # include "createTime.H" # include "createMesh.H" + + simpleControl simple(mesh); + # include "createFields.H" # include "createEquationReader.H" # include "loadEquationData.H" @@ -54,22 +58,10 @@ int main(int argc, char *argv[]) Info<< "\nStarting time loop\n" << endl; - while (runTime.loop()) + while (simple.loop()) { Info<< "Time = " << runTime.timeName() << nl << endl; - dictionary simple = mesh.solutionDict().subDict("SIMPLE"); - - int nNonOrthCorr = - simple.lookupOrDefault("nNonOrthogonalCorrectors", 0); - - bool momentumPredictor = - simple.lookupOrDefault("momentumPredictor", true); - -# include "initConvergenceCheck.H" - - p.storePrevIter(); - // Pressure-velocity SIMPLE corrector { # include "UEqn.H" @@ -85,8 +77,6 @@ int main(int argc, char *argv[]) Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" << " ClockTime = " << runTime.elapsedClockTime() << " s" << nl << endl; - -# include "convergenceCheck.H" } Info<< "End\n" << endl; diff --git a/applications/solvers/equationReaderDemo/pEqn.H b/applications/solvers/equationReaderDemo/pEqn.H index 42ebfc225..22921f652 100644 --- a/applications/solvers/equationReaderDemo/pEqn.H +++ b/applications/solvers/equationReaderDemo/pEqn.H @@ -7,7 +7,7 @@ adjustPhi(phi, U, p); // Non-orthogonal pressure corrector loop - for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) + while (simple.correctNonOrthogonal()) { fvScalarMatrix pEqn ( @@ -16,18 +16,9 @@ pEqn.setReference(pRefCell, pRefValue); - // Retain the residual from the first iteration - if (nonOrth == 0) - { - eqnResidual = pEqn.solve().initialResidual(); - maxResidual = max(eqnResidual, maxResidual); - } - else - { - pEqn.solve(); - } + pEqn.solve(); - if (nonOrth == nNonOrthCorr) + if (simple.finalNonOrthogonalIter()) { phi -= pEqn.flux(); } diff --git a/applications/solvers/heatTransfer/boussinesqBuoyantFoam/boussinesqBuoyantFoam.C b/applications/solvers/heatTransfer/boussinesqBuoyantFoam/boussinesqBuoyantFoam.C index fbb31ef8d..a2daaf199 100644 --- a/applications/solvers/heatTransfer/boussinesqBuoyantFoam/boussinesqBuoyantFoam.C +++ b/applications/solvers/heatTransfer/boussinesqBuoyantFoam/boussinesqBuoyantFoam.C @@ -31,6 +31,7 @@ Description \*---------------------------------------------------------------------------*/ #include "fvCFD.H" +#include "pisoControl.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -41,6 +42,9 @@ int main(int argc, char *argv[]) # include "createTime.H" # include "createMesh.H" + + pisoControl piso(mesh); + # include "readTransportProperties.H" # include "readGravitationalAcceleration.H" # include "createFields.H" @@ -50,11 +54,10 @@ int main(int argc, char *argv[]) Info<< "\nStarting time loop\n" << endl; - for (runTime++; !runTime.end(); runTime++) + while (runTime.loop()) { Info<< "Time = " << runTime.timeName() << nl << endl; -# include "readPISOControls.H" # include "CourantNo.H" fvVectorMatrix UEqn @@ -70,7 +73,7 @@ int main(int argc, char *argv[]) // --- PISO loop - for (int corr = 0; corr < nCorr; corr++) + while (piso.correct()) { volScalarField rUA = 1.0/UEqn.A(); @@ -80,7 +83,7 @@ int main(int argc, char *argv[]) adjustPhi(phi, U, p); - for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) + while (piso.correctNonOrthogonal()) { fvScalarMatrix pEqn ( @@ -90,7 +93,7 @@ int main(int argc, char *argv[]) pEqn.setReference(pRefCell, pRefValue); pEqn.solve(); - if (nonOrth == nNonOrthCorr) + if (piso.finalNonOrthogonalIter()) { phi -= pEqn.flux(); } diff --git a/applications/solvers/heatTransfer/boussinesqBuoyantFoam/createFields.H b/applications/solvers/heatTransfer/boussinesqBuoyantFoam/createFields.H index ce61861ee..247634b45 100644 --- a/applications/solvers/heatTransfer/boussinesqBuoyantFoam/createFields.H +++ b/applications/solvers/heatTransfer/boussinesqBuoyantFoam/createFields.H @@ -48,7 +48,8 @@ label pRefCell = 0; scalar pRefValue = 0.0; - setRefCell(p, mesh.solutionDict().subDict("PISO"), pRefCell, pRefValue); + setRefCell(p, piso.dict(), pRefCell, pRefValue); + mesh.schemesDict().setFluxRequired(p.name()); Info<< "Reading/calculating field rho\n" << endl; volScalarField rho diff --git a/applications/solvers/heatTransfer/buoyantBoussinesqPisoFoam/UEqn.H b/applications/solvers/heatTransfer/buoyantBoussinesqPisoFoam/UEqn.H index 35387f4ff..fa68de296 100644 --- a/applications/solvers/heatTransfer/buoyantBoussinesqPisoFoam/UEqn.H +++ b/applications/solvers/heatTransfer/buoyantBoussinesqPisoFoam/UEqn.H @@ -9,7 +9,7 @@ UEqn.relax(); - if (momentumPredictor) + if (piso.momentumPredictor()) { solve ( diff --git a/applications/solvers/heatTransfer/buoyantBoussinesqPisoFoam/buoyantBoussinesqPisoFoam.C b/applications/solvers/heatTransfer/buoyantBoussinesqPisoFoam/buoyantBoussinesqPisoFoam.C index 73547b6a3..e91ead7cd 100644 --- a/applications/solvers/heatTransfer/buoyantBoussinesqPisoFoam/buoyantBoussinesqPisoFoam.C +++ b/applications/solvers/heatTransfer/buoyantBoussinesqPisoFoam/buoyantBoussinesqPisoFoam.C @@ -48,6 +48,7 @@ Description #include "fvCFD.H" #include "singlePhaseTransportModel.H" #include "turbulenceModel.H" +#include "pisoControl.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -56,6 +57,9 @@ int main(int argc, char *argv[]) # include "setRootCase.H" # include "createTime.H" # include "createMesh.H" + + pisoControl piso(mesh); + # include "readGravitationalAcceleration.H" # include "createFields.H" # include "initContinuityErrs.H" @@ -72,7 +76,6 @@ int main(int argc, char *argv[]) Info<< "Time = " << runTime.timeName() << nl << endl; # include "readTimeControls.H" -# include "readPISOControls.H" # include "CourantNo.H" # include "setDeltaT.H" @@ -80,7 +83,7 @@ int main(int argc, char *argv[]) # include "TEqn.H" // --- PISO loop - for (int corr = 0; corr < nCorr; corr++) + while (piso.correct()) { # include "pEqn.H" } diff --git a/applications/solvers/heatTransfer/buoyantBoussinesqPisoFoam/createFields.H b/applications/solvers/heatTransfer/buoyantBoussinesqPisoFoam/createFields.H index b2fa0af92..8aaa0132c 100644 --- a/applications/solvers/heatTransfer/buoyantBoussinesqPisoFoam/createFields.H +++ b/applications/solvers/heatTransfer/buoyantBoussinesqPisoFoam/createFields.H @@ -54,13 +54,8 @@ label pRefCell = 0; scalar pRefValue = 0.0; - setRefCell - ( - p, - mesh.solutionDict().subDict("PISO"), - pRefCell, - pRefValue - ); + setRefCell(p, piso.dict(), pRefCell, pRefValue); + mesh.schemesDict().setFluxRequired(p.name()); // Kinematic density for buoyancy force diff --git a/applications/solvers/heatTransfer/buoyantBoussinesqPisoFoam/pEqn.H b/applications/solvers/heatTransfer/buoyantBoussinesqPisoFoam/pEqn.H index 02d86340c..2601d0eb6 100644 --- a/applications/solvers/heatTransfer/buoyantBoussinesqPisoFoam/pEqn.H +++ b/applications/solvers/heatTransfer/buoyantBoussinesqPisoFoam/pEqn.H @@ -12,23 +12,16 @@ phi = phiU + rUAf*fvc::interpolate(rhok)*(g & mesh.Sf()); - for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) + while (piso.correctNonOrthogonal()) { fvScalarMatrix pEqn ( fvm::laplacian(rUAf, p) == fvc::div(phi) ); - if (corr == nCorr - 1 && nonOrth == nNonOrthCorr) - { - pEqn.solve(mesh.solutionDict().solver(p.name() + "Final")); - } - else - { - pEqn.solve(mesh.solutionDict().solver(p.name())); - } + pEqn.solve(mesh.solutionDict().solver(p.select(piso.finalInnerIter()))); - if (nonOrth == nNonOrthCorr) + if (piso.finalNonOrthogonalIter()) { phi -= pEqn.flux(); } diff --git a/applications/solvers/heatTransfer/buoyantBoussinesqSimpleFoam/TEqn.H b/applications/solvers/heatTransfer/buoyantBoussinesqSimpleFoam/TEqn.H index 7452a0495..3bdeea045 100644 --- a/applications/solvers/heatTransfer/buoyantBoussinesqSimpleFoam/TEqn.H +++ b/applications/solvers/heatTransfer/buoyantBoussinesqSimpleFoam/TEqn.H @@ -14,8 +14,7 @@ TEqn.relax(); - eqnResidual = TEqn.solve().initialResidual(); - maxResidual = max(eqnResidual, maxResidual); + TEqn.solve(); rhok = 1.0 - beta*(T - TRef); } diff --git a/applications/solvers/heatTransfer/buoyantBoussinesqSimpleFoam/UEqn.H b/applications/solvers/heatTransfer/buoyantBoussinesqSimpleFoam/UEqn.H index bcf99e166..292f44b4b 100644 --- a/applications/solvers/heatTransfer/buoyantBoussinesqSimpleFoam/UEqn.H +++ b/applications/solvers/heatTransfer/buoyantBoussinesqSimpleFoam/UEqn.H @@ -8,7 +8,7 @@ UEqn().relax(); - eqnResidual = solve + solve ( UEqn() == @@ -19,6 +19,4 @@ - fvc::snGrad(p)*mesh.magSf() ) ) - ).initialResidual(); - - maxResidual = max(eqnResidual, maxResidual); + ); diff --git a/applications/solvers/heatTransfer/buoyantBoussinesqSimpleFoam/buoyantBoussinesqSimpleFoam.C b/applications/solvers/heatTransfer/buoyantBoussinesqSimpleFoam/buoyantBoussinesqSimpleFoam.C index acfd8ff48..341f0a3a4 100644 --- a/applications/solvers/heatTransfer/buoyantBoussinesqSimpleFoam/buoyantBoussinesqSimpleFoam.C +++ b/applications/solvers/heatTransfer/buoyantBoussinesqSimpleFoam/buoyantBoussinesqSimpleFoam.C @@ -48,6 +48,7 @@ Description #include "fvCFD.H" #include "singlePhaseTransportModel.H" #include "RASModel.H" +#include "simpleControl.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -56,6 +57,9 @@ int main(int argc, char *argv[]) #include "setRootCase.H" #include "createTime.H" #include "createMesh.H" + + simpleControl simple(mesh); + #include "readGravitationalAcceleration.H" #include "createFields.H" #include "initContinuityErrs.H" @@ -64,15 +68,10 @@ int main(int argc, char *argv[]) Info<< "\nStarting time loop\n" << endl; - while (runTime.loop()) + while (simple.loop()) { Info<< "Time = " << runTime.timeName() << nl << endl; - #include "readSIMPLEControls.H" - #include "initConvergenceCheck.H" - - p.storePrevIter(); - // Pressure-velocity SIMPLE corrector { #include "UEqn.H" @@ -87,8 +86,6 @@ int main(int argc, char *argv[]) Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" << " ClockTime = " << runTime.elapsedClockTime() << " s" << nl << endl; - - #include "convergenceCheck.H" } Info<< "End\n" << endl; diff --git a/applications/solvers/heatTransfer/buoyantBoussinesqSimpleFoam/convergenceCheck.H b/applications/solvers/heatTransfer/buoyantBoussinesqSimpleFoam/convergenceCheck.H deleted file mode 100644 index 895806319..000000000 --- a/applications/solvers/heatTransfer/buoyantBoussinesqSimpleFoam/convergenceCheck.H +++ /dev/null @@ -1,9 +0,0 @@ -// check convergence - -if (maxResidual < convergenceCriterion) -{ - Info<< "reached convergence criterion: " << convergenceCriterion << endl; - runTime.writeAndEnd(); - Info<< "latestTime = " << runTime.timeName() << endl; -} - diff --git a/applications/solvers/heatTransfer/buoyantBoussinesqSimpleFoam/createFields.H b/applications/solvers/heatTransfer/buoyantBoussinesqSimpleFoam/createFields.H index 0e668e9d9..6b90f53a6 100644 --- a/applications/solvers/heatTransfer/buoyantBoussinesqSimpleFoam/createFields.H +++ b/applications/solvers/heatTransfer/buoyantBoussinesqSimpleFoam/createFields.H @@ -57,14 +57,8 @@ label pRefCell = 0; scalar pRefValue = 0.0; - setRefCell - ( - p, - mesh.solutionDict().subDict("SIMPLE"), - pRefCell, - pRefValue - ); - + setRefCell(p, simple.dict(), pRefCell, pRefValue); + mesh.schemesDict().setFluxRequired(p.name()); // Kinematic density for buoyancy force volScalarField rhok diff --git a/applications/solvers/heatTransfer/buoyantBoussinesqSimpleFoam/initConvergenceCheck.H b/applications/solvers/heatTransfer/buoyantBoussinesqSimpleFoam/initConvergenceCheck.H deleted file mode 100644 index b56197f22..000000000 --- a/applications/solvers/heatTransfer/buoyantBoussinesqSimpleFoam/initConvergenceCheck.H +++ /dev/null @@ -1,7 +0,0 @@ -// initialize values for convergence checks - - scalar eqnResidual = 1, maxResidual = 0; - scalar convergenceCriterion = 0; - - simple.readIfPresent("convergence", convergenceCriterion); - diff --git a/applications/solvers/heatTransfer/buoyantBoussinesqSimpleFoam/pEqn.H b/applications/solvers/heatTransfer/buoyantBoussinesqSimpleFoam/pEqn.H index 6408c7ccc..256a336f3 100644 --- a/applications/solvers/heatTransfer/buoyantBoussinesqSimpleFoam/pEqn.H +++ b/applications/solvers/heatTransfer/buoyantBoussinesqSimpleFoam/pEqn.H @@ -12,7 +12,7 @@ rUAf*fvc::interpolate(rhok)*(g & mesh.Sf()); phi += buoyancyPhi; - for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) + while (simple.correctNonOrthogonal()) { fvScalarMatrix pEqn ( @@ -21,18 +21,9 @@ pEqn.setReference(pRefCell, pRefValue); - // retain the residual from the first iteration - if (nonOrth == 0) - { - eqnResidual = pEqn.solve().initialResidual(); - maxResidual = max(eqnResidual, maxResidual); - } - else - { - pEqn.solve(); - } + pEqn.solve(); - if (nonOrth == nNonOrthCorr) + if (simple.finalNonOrthogonalIter()) { // Calculate the conservative fluxes phi -= pEqn.flux(); diff --git a/applications/solvers/heatTransfer/buoyantPisoFoam/UEqn.H b/applications/solvers/heatTransfer/buoyantPisoFoam/UEqn.H index d4878d063..230f18661 100644 --- a/applications/solvers/heatTransfer/buoyantPisoFoam/UEqn.H +++ b/applications/solvers/heatTransfer/buoyantPisoFoam/UEqn.H @@ -9,7 +9,7 @@ UEqn.relax(); - if (momentumPredictor) + if (piso.momentumPredictor()) { solve ( diff --git a/applications/solvers/heatTransfer/buoyantPisoFoam/buoyantPisoFoam.C b/applications/solvers/heatTransfer/buoyantPisoFoam/buoyantPisoFoam.C index 2a277a9bf..05dd6a70f 100644 --- a/applications/solvers/heatTransfer/buoyantPisoFoam/buoyantPisoFoam.C +++ b/applications/solvers/heatTransfer/buoyantPisoFoam/buoyantPisoFoam.C @@ -37,6 +37,7 @@ Description #include "basicRhoThermo.H" #include "turbulenceModel.H" #include "fixedGradientFvPatchFields.H" +#include "pisoControl.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -45,6 +46,9 @@ int main(int argc, char *argv[]) # include "setRootCase.H" # include "createTime.H" # include "createMesh.H" + + pisoControl piso(mesh); + # include "readGravitationalAcceleration.H" # include "createFields.H" # include "initContinuityErrs.H" @@ -59,7 +63,6 @@ int main(int argc, char *argv[]) while (runTime.run()) { # include "readTimeControls.H" -# include "readPISOControls.H" # include "compressibleCourantNo.H" # include "setDeltaT.H" @@ -75,7 +78,7 @@ int main(int argc, char *argv[]) // --- PISO loop - for (int corr = 0; corr < nCorr; corr++) + while (piso.correct()) { # include "pEqn.H" } diff --git a/applications/solvers/heatTransfer/buoyantPisoFoam/createFields.H b/applications/solvers/heatTransfer/buoyantPisoFoam/createFields.H index b8ac5595e..616d1c170 100644 --- a/applications/solvers/heatTransfer/buoyantPisoFoam/createFields.H +++ b/applications/solvers/heatTransfer/buoyantPisoFoam/createFields.H @@ -65,3 +65,5 @@ dimensionedScalar initialMass = fvc::domainIntegrate(rho); dimensionedScalar totalVolume = sum(mesh.V()); + + mesh.schemesDict().setFluxRequired(p.name()); diff --git a/applications/solvers/heatTransfer/buoyantPisoFoam/pEqn.H b/applications/solvers/heatTransfer/buoyantPisoFoam/pEqn.H index f78fb9483..64edba028 100644 --- a/applications/solvers/heatTransfer/buoyantPisoFoam/pEqn.H +++ b/applications/solvers/heatTransfer/buoyantPisoFoam/pEqn.H @@ -23,7 +23,7 @@ phi = phiU + rhorUAf*fvc::interpolate(rho)*(g & mesh.Sf()); - for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) + while (piso.correctNonOrthogonal()) { fvScalarMatrix pEqn ( @@ -32,16 +32,9 @@ - fvm::laplacian(rhorUAf, p) ); - if (corr == nCorr - 1 && nonOrth == nNonOrthCorr) - { - pEqn.solve(mesh.solutionDict().solver(p.name() + "Final")); - } - else - { - pEqn.solve(mesh.solutionDict().solver(p.name())); - } + pEqn.solve(mesh.solutionDict().solver(p.select(piso.finalInnerIter()))); - if (nonOrth == nNonOrthCorr) + if (piso.finalNonOrthogonalIter()) { phi += pEqn.flux(); } diff --git a/applications/solvers/heatTransfer/buoyantSimpleFoam/UEqn.H b/applications/solvers/heatTransfer/buoyantSimpleFoam/UEqn.H index 0170d6e38..560988360 100644 --- a/applications/solvers/heatTransfer/buoyantSimpleFoam/UEqn.H +++ b/applications/solvers/heatTransfer/buoyantSimpleFoam/UEqn.H @@ -8,7 +8,7 @@ UEqn().relax(); - eqnResidual = solve + solve ( UEqn() == @@ -17,6 +17,4 @@ fvc::interpolate(rho)*(g & mesh.Sf()) - fvc::snGrad(p)*mesh.magSf() ) - ).initialResidual(); - - maxResidual = max(eqnResidual, maxResidual); + ); diff --git a/applications/solvers/heatTransfer/buoyantSimpleFoam/buoyantSimpleFoam.C b/applications/solvers/heatTransfer/buoyantSimpleFoam/buoyantSimpleFoam.C index 913f3634b..9ff38ec08 100644 --- a/applications/solvers/heatTransfer/buoyantSimpleFoam/buoyantSimpleFoam.C +++ b/applications/solvers/heatTransfer/buoyantSimpleFoam/buoyantSimpleFoam.C @@ -33,6 +33,7 @@ Description #include "basicPsiThermo.H" #include "RASModel.H" #include "fixedGradientFvPatchFields.H" +#include "simpleControl.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -41,6 +42,9 @@ int main(int argc, char *argv[]) #include "setRootCase.H" #include "createTime.H" #include "createMesh.H" + + simpleControl simple(mesh); + #include "readGravitationalAcceleration.H" #include "createFields.H" #include "initContinuityErrs.H" @@ -49,16 +53,10 @@ int main(int argc, char *argv[]) Info<< "\nStarting time loop\n" << endl; - while (runTime.loop()) + while (simple.loop()) { Info<< "Time = " << runTime.timeName() << nl << endl; - #include "readSIMPLEControls.H" - #include "initConvergenceCheck.H" - - p.storePrevIter(); - rho.storePrevIter(); - // Pressure-velocity SIMPLE corrector { #include "UEqn.H" @@ -73,8 +71,6 @@ int main(int argc, char *argv[]) Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" << " ClockTime = " << runTime.elapsedClockTime() << " s" << nl << endl; - - #include "convergenceCheck.H" } Info<< "End\n" << endl; diff --git a/applications/solvers/heatTransfer/buoyantSimpleFoam/convergenceCheck.H b/applications/solvers/heatTransfer/buoyantSimpleFoam/convergenceCheck.H deleted file mode 100644 index 895806319..000000000 --- a/applications/solvers/heatTransfer/buoyantSimpleFoam/convergenceCheck.H +++ /dev/null @@ -1,9 +0,0 @@ -// check convergence - -if (maxResidual < convergenceCriterion) -{ - Info<< "reached convergence criterion: " << convergenceCriterion << endl; - runTime.writeAndEnd(); - Info<< "latestTime = " << runTime.timeName() << endl; -} - diff --git a/applications/solvers/heatTransfer/buoyantSimpleFoam/createFields.H b/applications/solvers/heatTransfer/buoyantSimpleFoam/createFields.H index b304ace10..3539a0eee 100644 --- a/applications/solvers/heatTransfer/buoyantSimpleFoam/createFields.H +++ b/applications/solvers/heatTransfer/buoyantSimpleFoam/createFields.H @@ -57,13 +57,9 @@ label pRefCell = 0; scalar pRefValue = 0.0; - setRefCell - ( - p, - mesh.solutionDict().subDict("SIMPLE"), - pRefCell, - pRefValue - ); + setRefCell(p, simple.dict(), pRefCell, pRefValue); dimensionedScalar initialMass = fvc::domainIntegrate(rho); + + mesh.schemesDict().setFluxRequired(p.name()); diff --git a/applications/solvers/heatTransfer/buoyantSimpleFoam/hEqn.H b/applications/solvers/heatTransfer/buoyantSimpleFoam/hEqn.H index 0c507ce3d..b91a17ee7 100644 --- a/applications/solvers/heatTransfer/buoyantSimpleFoam/hEqn.H +++ b/applications/solvers/heatTransfer/buoyantSimpleFoam/hEqn.H @@ -11,8 +11,7 @@ hEqn.relax(); - eqnResidual = hEqn.solve().initialResidual(); - maxResidual = max(eqnResidual, maxResidual); + hEqn.solve(); thermo.correct(); } diff --git a/applications/solvers/heatTransfer/buoyantSimpleFoam/initConvergenceCheck.H b/applications/solvers/heatTransfer/buoyantSimpleFoam/initConvergenceCheck.H deleted file mode 100644 index c920b6708..000000000 --- a/applications/solvers/heatTransfer/buoyantSimpleFoam/initConvergenceCheck.H +++ /dev/null @@ -1,7 +0,0 @@ - // initialize values for convergence checks - - scalar eqnResidual = 1, maxResidual = 0; - scalar convergenceCriterion = 0; - - simple.readIfPresent("convergence", convergenceCriterion); - diff --git a/applications/solvers/heatTransfer/buoyantSimpleFoam/pEqn.H b/applications/solvers/heatTransfer/buoyantSimpleFoam/pEqn.H index 11768ea2f..0321e0748 100644 --- a/applications/solvers/heatTransfer/buoyantSimpleFoam/pEqn.H +++ b/applications/solvers/heatTransfer/buoyantSimpleFoam/pEqn.H @@ -14,7 +14,7 @@ rhorUAf*fvc::interpolate(rho)*(g & mesh.Sf()); phi += buoyancyPhi; - for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) + while (simple.correctNonOrthogonal()) { fvScalarMatrix pEqn ( @@ -23,18 +23,9 @@ pEqn.setReference(pRefCell, pRefValue); - // retain the residual from the first iteration - if (nonOrth == 0) - { - eqnResidual = pEqn.solve().initialResidual(); - maxResidual = max(eqnResidual, maxResidual); - } - else - { - pEqn.solve(); - } + pEqn.solve(); - if (nonOrth == nNonOrthCorr) + if (simple.finalNonOrthogonalIter()) { // For closed-volume cases adjust the pressure and density levels // to obey overall mass continuity diff --git a/applications/solvers/heatTransfer/buoyantSimpleRadiationFoam/buoyantSimpleRadiationFoam.C b/applications/solvers/heatTransfer/buoyantSimpleRadiationFoam/buoyantSimpleRadiationFoam.C index f5ee87a62..3f451f99c 100644 --- a/applications/solvers/heatTransfer/buoyantSimpleRadiationFoam/buoyantSimpleRadiationFoam.C +++ b/applications/solvers/heatTransfer/buoyantSimpleRadiationFoam/buoyantSimpleRadiationFoam.C @@ -35,6 +35,7 @@ Description #include "RASModel.H" #include "fixedGradientFvPatchFields.H" #include "radiationModel.H" +#include "simpleControl.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -43,6 +44,9 @@ int main(int argc, char *argv[]) # include "setRootCase.H" # include "createTime.H" # include "createMesh.H" + + simpleControl simple(mesh); + # include "readGravitationalAcceleration.H" # include "createFields.H" # include "createRadiationModel.H" @@ -52,16 +56,10 @@ int main(int argc, char *argv[]) Info<< "\nStarting time loop\n" << endl; - while (runTime.loop()) + while (simple.loop()) { Info<< "Time = " << runTime.timeName() << nl << endl; -# include "readSIMPLEControls.H" -# include "initConvergenceCheck.H" - - p.storePrevIter(); - rho.storePrevIter(); - // Pressure-velocity SIMPLE corrector { # include "UEqn.H" @@ -76,8 +74,6 @@ int main(int argc, char *argv[]) Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" << " ClockTime = " << runTime.elapsedClockTime() << " s" << nl << endl; - -# include "convergenceCheck.H" } Info<< "End\n" << endl; diff --git a/applications/solvers/heatTransfer/buoyantSimpleRadiationFoam/hEqn.H b/applications/solvers/heatTransfer/buoyantSimpleRadiationFoam/hEqn.H index 24b17645d..57de44e4a 100644 --- a/applications/solvers/heatTransfer/buoyantSimpleRadiationFoam/hEqn.H +++ b/applications/solvers/heatTransfer/buoyantSimpleRadiationFoam/hEqn.H @@ -12,8 +12,7 @@ hEqn.relax(); - eqnResidual = hEqn.solve().initialResidual(); - maxResidual = max(eqnResidual, maxResidual); + hEqn.solve(); thermo.correct(); diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/setRegionFluidFields.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/setRegionFluidFields.H index 49bffaa4d..5e584cce7 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/setRegionFluidFields.H +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/setRegionFluidFields.H @@ -15,3 +15,5 @@ volScalarField& h = thermo.h(); const dimensionedScalar massIni("massIni", dimMass, initialMassFluid[i]); + + mesh.schemesDict().setFluxRequired(p.name()); diff --git a/applications/solvers/heatTransfer/chtMultiRegionSimpleFoam/fluid/setRegionFluidFields.H b/applications/solvers/heatTransfer/chtMultiRegionSimpleFoam/fluid/setRegionFluidFields.H index 656fb42e5..4c1b4d921 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionSimpleFoam/fluid/setRegionFluidFields.H +++ b/applications/solvers/heatTransfer/chtMultiRegionSimpleFoam/fluid/setRegionFluidFields.H @@ -22,3 +22,5 @@ const label pRefCell = pRefCellFluid[i]; const scalar pRefValue = pRefValueFluid[i]; + + mesh.schemesDict().setFluxRequired(p.name()); diff --git a/applications/solvers/immersedBoundary/icoDyMIbFoam/createFields.H b/applications/solvers/immersedBoundary/icoDyMIbFoam/createFields.H index 51c10db46..2721134d9 100644 --- a/applications/solvers/immersedBoundary/icoDyMIbFoam/createFields.H +++ b/applications/solvers/immersedBoundary/icoDyMIbFoam/createFields.H @@ -52,5 +52,5 @@ label pRefCell = 0; scalar pRefValue = 0.0; - setRefCell(p, mesh.solutionDict().subDict("PIMPLE"), pRefCell, pRefValue); - mesh.schemesDict().setFluxRequired(p.name()); \ No newline at end of file + setRefCell(p, pimple.dict(), pRefCell, pRefValue); + mesh.schemesDict().setFluxRequired(p.name()); diff --git a/applications/solvers/immersedBoundary/icoIbFoam/createFields.H b/applications/solvers/immersedBoundary/icoIbFoam/createFields.H index 51c10db46..2721134d9 100644 --- a/applications/solvers/immersedBoundary/icoIbFoam/createFields.H +++ b/applications/solvers/immersedBoundary/icoIbFoam/createFields.H @@ -52,5 +52,5 @@ label pRefCell = 0; scalar pRefValue = 0.0; - setRefCell(p, mesh.solutionDict().subDict("PIMPLE"), pRefCell, pRefValue); - mesh.schemesDict().setFluxRequired(p.name()); \ No newline at end of file + setRefCell(p, pimple.dict(), pRefCell, pRefValue); + mesh.schemesDict().setFluxRequired(p.name()); diff --git a/applications/solvers/immersedBoundary/interIbFoam/createFields.H b/applications/solvers/immersedBoundary/interIbFoam/createFields.H index 0fcdf751b..68e3b368f 100644 --- a/applications/solvers/immersedBoundary/interIbFoam/createFields.H +++ b/applications/solvers/immersedBoundary/interIbFoam/createFields.H @@ -103,22 +103,13 @@ label pdRefCell = 0; scalar pdRefValue = 0.0; - setRefCell - ( - pd, - mesh.solutionDict().subDict("PIMPLE"), - pdRefCell, - pdRefValue - ); + setRefCell(pd, pimple.dict(), pdRefCell, pdRefValue); scalar pRefValue = 0.0; if (pd.needReference()) { - pRefValue = readScalar - ( - mesh.solutionDict().subDict("PIMPLE").lookup("pRefValue") - ); + pRefValue = readScalar(pimple.dict().lookup("pRefValue")); p += dimensionedScalar ( diff --git a/applications/solvers/immersedBoundary/interIbFoam/limitU.H b/applications/solvers/immersedBoundary/interIbFoam/limitU.H index 0c59414f8..c014ae74f 100644 --- a/applications/solvers/immersedBoundary/interIbFoam/limitU.H +++ b/applications/solvers/immersedBoundary/interIbFoam/limitU.H @@ -1,6 +1,5 @@ { - scalar limitMagU = - readScalar(mesh.solutionDict().subDict("PIMPLE").lookup("limitMagU")); + scalar limitMagU = readScalar(pimple.dict().lookup("limitMagU")); volScalarField magU(mag(U)); diff --git a/applications/solvers/immersedBoundary/interIbFoam/pEqn.H b/applications/solvers/immersedBoundary/interIbFoam/pEqn.H index a765455fc..56980d7da 100644 --- a/applications/solvers/immersedBoundary/interIbFoam/pEqn.H +++ b/applications/solvers/immersedBoundary/interIbFoam/pEqn.H @@ -1,9 +1,4 @@ { - if (!pimple.firstIter()) - { - pd.storePrevIter(); - } - volScalarField rUA = 1.0/UEqn.A(); surfaceScalarField rUAf = fvc::interpolate(rUA); diff --git a/applications/solvers/immersedBoundary/porousSimpleIbFoam/createFields.H b/applications/solvers/immersedBoundary/porousSimpleIbFoam/createFields.H index 6dc7d36c8..a6ba38265 100644 --- a/applications/solvers/immersedBoundary/porousSimpleIbFoam/createFields.H +++ b/applications/solvers/immersedBoundary/porousSimpleIbFoam/createFields.H @@ -31,7 +31,7 @@ label pRefCell = 0; scalar pRefValue = 0.0; - setRefCell(p, mesh.solutionDict().subDict("SIMPLE"), pRefCell, pRefValue); + setRefCell(p, simple.dict(), pRefCell, pRefValue); mesh.schemesDict().setFluxRequired(p.name()); singlePhaseTransportModel laminarTransport(U, phi); diff --git a/applications/solvers/immersedBoundary/porousSimpleIbFoam/porousSimpleIbFoam.C b/applications/solvers/immersedBoundary/porousSimpleIbFoam/porousSimpleIbFoam.C index 6c873025b..d2e97067b 100644 --- a/applications/solvers/immersedBoundary/porousSimpleIbFoam/porousSimpleIbFoam.C +++ b/applications/solvers/immersedBoundary/porousSimpleIbFoam/porousSimpleIbFoam.C @@ -60,12 +60,10 @@ int main(int argc, char *argv[]) Info<< "\nStarting time loop\n" << endl; - while (runTime.loop()) + while (simple.loop()) { Info<< "Time = " << runTime.timeName() << nl << endl; - p.storePrevIter(); - // Pressure-velocity SIMPLE corrector { # include "UEqn.H" diff --git a/applications/solvers/immersedBoundary/potentialIbFoam/createFields.H b/applications/solvers/immersedBoundary/potentialIbFoam/createFields.H index d45cac025..09ed08451 100644 --- a/applications/solvers/immersedBoundary/potentialIbFoam/createFields.H +++ b/applications/solvers/immersedBoundary/potentialIbFoam/createFields.H @@ -46,5 +46,5 @@ label pRefCell = 0; scalar pRefValue = 0.0; - setRefCell(p, mesh.solutionDict().subDict("SIMPLE"), pRefCell, pRefValue); + setRefCell(p, simple.dict(), pRefCell, pRefValue); mesh.schemesDict().setFluxRequired(p.name()); diff --git a/applications/solvers/immersedBoundary/simpleIbFoam/createFields.H b/applications/solvers/immersedBoundary/simpleIbFoam/createFields.H index 7527c084a..1819fb887 100644 --- a/applications/solvers/immersedBoundary/simpleIbFoam/createFields.H +++ b/applications/solvers/immersedBoundary/simpleIbFoam/createFields.H @@ -31,7 +31,7 @@ label pRefCell = 0; scalar pRefValue = 0.0; - setRefCell(p, mesh.solutionDict().subDict("SIMPLE"), pRefCell, pRefValue); + setRefCell(p, simple.dict(), pRefCell, pRefValue); mesh.schemesDict().setFluxRequired(p.name()); singlePhaseTransportModel laminarTransport(U, phi); diff --git a/applications/solvers/immersedBoundary/simpleIbFoam/simpleIbFoam.C b/applications/solvers/immersedBoundary/simpleIbFoam/simpleIbFoam.C index 69c09be88..9b6decb00 100644 --- a/applications/solvers/immersedBoundary/simpleIbFoam/simpleIbFoam.C +++ b/applications/solvers/immersedBoundary/simpleIbFoam/simpleIbFoam.C @@ -59,12 +59,10 @@ int main(int argc, char *argv[]) Info<< "\nStarting time loop\n" << endl; - while (runTime.loop()) + while (simple.loop()) { Info<< "Time = " << runTime.timeName() << nl << endl; - p.storePrevIter(); - // Pressure-velocity SIMPLE corrector { # include "UEqn.H" diff --git a/applications/solvers/incompressible/MRFSimpleFoam/MRFSimpleFoam.C b/applications/solvers/incompressible/MRFSimpleFoam/MRFSimpleFoam.C index 8790ddbb1..e5f10c97c 100644 --- a/applications/solvers/incompressible/MRFSimpleFoam/MRFSimpleFoam.C +++ b/applications/solvers/incompressible/MRFSimpleFoam/MRFSimpleFoam.C @@ -55,12 +55,10 @@ int main(int argc, char *argv[]) Info<< "\nStarting time loop\n" << endl; - for (runTime++; !runTime.end(); runTime++) + while (simple.loop()) { Info<< "Time = " << runTime.timeName() << nl << endl; - p.storePrevIter(); - // Pressure-velocity SIMPLE corrector { // Momentum predictor diff --git a/applications/solvers/incompressible/MRFSimpleFoam/createFields.H b/applications/solvers/incompressible/MRFSimpleFoam/createFields.H index 3a08cae15..8ae490c37 100644 --- a/applications/solvers/incompressible/MRFSimpleFoam/createFields.H +++ b/applications/solvers/incompressible/MRFSimpleFoam/createFields.H @@ -31,7 +31,7 @@ label pRefCell = 0; scalar pRefValue = 0.0; - setRefCell(p, mesh.solutionDict().subDict("SIMPLE"), pRefCell, pRefValue); + setRefCell(p, simple.dict(), pRefCell, pRefValue); mesh.schemesDict().setFluxRequired(p.name()); singlePhaseTransportModel laminarTransport(U, phi); diff --git a/applications/solvers/incompressible/channelFoam/createFields.H b/applications/solvers/incompressible/channelFoam/createFields.H index 20af043b8..5bf5173f3 100644 --- a/applications/solvers/incompressible/channelFoam/createFields.H +++ b/applications/solvers/incompressible/channelFoam/createFields.H @@ -32,7 +32,7 @@ label pRefCell = 0; scalar pRefValue = 0.0; - setRefCell(p, mesh.solutionDict().subDict("PISO"), pRefCell, pRefValue); + setRefCell(p, piso.dict(), pRefCell, pRefValue); mesh.schemesDict().setFluxRequired(p.name()); singlePhaseTransportModel laminarTransport(U, phi); diff --git a/applications/solvers/incompressible/icoDyMFoam/createFields.H b/applications/solvers/incompressible/icoDyMFoam/createFields.H index 4b37f06a1..509a91657 100644 --- a/applications/solvers/incompressible/icoDyMFoam/createFields.H +++ b/applications/solvers/incompressible/icoDyMFoam/createFields.H @@ -52,7 +52,7 @@ label pRefCell = 0; scalar pRefValue = 0.0; - setRefCell(p, mesh.solutionDict().subDict("PISO"), pRefCell, pRefValue); + setRefCell(p, piso.dict(), pRefCell, pRefValue); mesh.schemesDict().setFluxRequired(p.name()); diff --git a/applications/solvers/incompressible/icoDyMSimpleFoam/createFields.H b/applications/solvers/incompressible/icoDyMSimpleFoam/createFields.H index 4b37f06a1..509a91657 100644 --- a/applications/solvers/incompressible/icoDyMSimpleFoam/createFields.H +++ b/applications/solvers/incompressible/icoDyMSimpleFoam/createFields.H @@ -52,7 +52,7 @@ label pRefCell = 0; scalar pRefValue = 0.0; - setRefCell(p, mesh.solutionDict().subDict("PISO"), pRefCell, pRefValue); + setRefCell(p, piso.dict(), pRefCell, pRefValue); mesh.schemesDict().setFluxRequired(p.name()); diff --git a/applications/solvers/incompressible/icoFoam/createFields.H b/applications/solvers/incompressible/icoFoam/createFields.H index 4fc0be97a..4fdfcb208 100644 --- a/applications/solvers/incompressible/icoFoam/createFields.H +++ b/applications/solvers/incompressible/icoFoam/createFields.H @@ -52,5 +52,5 @@ label pRefCell = 0; scalar pRefValue = 0.0; - setRefCell(p, mesh.solutionDict().subDict("PISO"), pRefCell, pRefValue); + setRefCell(p, piso.dict(), pRefCell, pRefValue); mesh.schemesDict().setFluxRequired(p.name()); diff --git a/applications/solvers/incompressible/nonNewtonianIcoFoam/createFields.H b/applications/solvers/incompressible/nonNewtonianIcoFoam/createFields.H index 2eb6e0ed4..b80225fd8 100644 --- a/applications/solvers/incompressible/nonNewtonianIcoFoam/createFields.H +++ b/applications/solvers/incompressible/nonNewtonianIcoFoam/createFields.H @@ -36,5 +36,5 @@ label pRefCell = 0; scalar pRefValue = 0.0; - setRefCell(p, mesh.solutionDict().subDict("PISO"), pRefCell, pRefValue); + setRefCell(p, piso.dict(), pRefCell, pRefValue); mesh.schemesDict().setFluxRequired(p.name()); diff --git a/applications/solvers/incompressible/pimpleDyMFoam/createFields.H b/applications/solvers/incompressible/pimpleDyMFoam/createFields.H index 3362e9353..74a461355 100644 --- a/applications/solvers/incompressible/pimpleDyMFoam/createFields.H +++ b/applications/solvers/incompressible/pimpleDyMFoam/createFields.H @@ -32,7 +32,7 @@ label pRefCell = 0; scalar pRefValue = 0.0; - setRefCell(p, mesh.solutionDict().subDict("PIMPLE"), pRefCell, pRefValue); + setRefCell(p, pimple.dict(), 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 b1cd87930..b5c0638df 100644 --- a/applications/solvers/incompressible/pimpleDyMFoam/pimpleDyMFoam.C +++ b/applications/solvers/incompressible/pimpleDyMFoam/pimpleDyMFoam.C @@ -103,11 +103,6 @@ int main(int argc, char *argv[]) // --- PIMPLE loop while (pimple.loop()) { - if (!pimple.firstIter()) - { - p.storePrevIter(); - } - # include "UEqn.H" // --- PISO loop diff --git a/applications/solvers/incompressible/pimpleFoam/createFields.H b/applications/solvers/incompressible/pimpleFoam/createFields.H index a5e399ff9..a60a24493 100644 --- a/applications/solvers/incompressible/pimpleFoam/createFields.H +++ b/applications/solvers/incompressible/pimpleFoam/createFields.H @@ -31,7 +31,7 @@ volVectorField U label pRefCell = 0; scalar pRefValue = 0.0; -setRefCell(p, mesh.solutionDict().subDict("PIMPLE"), pRefCell, pRefValue); +setRefCell(p, pimple.dict(), pRefCell, pRefValue); mesh.schemesDict().setFluxRequired(p.name()); singlePhaseTransportModel laminarTransport(U, phi); diff --git a/applications/solvers/incompressible/pimpleFoam/pimpleFoam.C b/applications/solvers/incompressible/pimpleFoam/pimpleFoam.C index cc61b85bb..0cd1eef37 100644 --- a/applications/solvers/incompressible/pimpleFoam/pimpleFoam.C +++ b/applications/solvers/incompressible/pimpleFoam/pimpleFoam.C @@ -71,11 +71,6 @@ int main(int argc, char *argv[]) // --- PIMPLE loop while (pimple.loop()) { - if (!pimple.firstIter()) - { - p.storePrevIter(); - } - # include "UEqn.H" // --- PISO loop diff --git a/applications/solvers/incompressible/pisoFoam/createFields.H b/applications/solvers/incompressible/pisoFoam/createFields.H index 4342b3c25..b2e291e36 100644 --- a/applications/solvers/incompressible/pisoFoam/createFields.H +++ b/applications/solvers/incompressible/pisoFoam/createFields.H @@ -31,7 +31,7 @@ label pRefCell = 0; scalar pRefValue = 0.0; - setRefCell(p, mesh.solutionDict().subDict("PISO"), pRefCell, pRefValue); + setRefCell(p, piso.dict(), pRefCell, pRefValue); mesh.schemesDict().setFluxRequired(p.name()); diff --git a/applications/solvers/incompressible/porousSimpleFoam/createFields.H b/applications/solvers/incompressible/porousSimpleFoam/createFields.H index fa4f98151..2213074f6 100644 --- a/applications/solvers/incompressible/porousSimpleFoam/createFields.H +++ b/applications/solvers/incompressible/porousSimpleFoam/createFields.H @@ -31,7 +31,7 @@ label pRefCell = 0; scalar pRefValue = 0.0; - setRefCell(p, mesh.solutionDict().subDict("SIMPLE"), pRefCell, pRefValue); + setRefCell(p, simple.dict(), pRefCell, pRefValue); mesh.schemesDict().setFluxRequired(p.name()); singlePhaseTransportModel laminarTransport(U, phi); @@ -49,12 +49,9 @@ if (pZones.size()) { // nUCorrectors for pressureImplicitPorosity - if (mesh.solutionDict().subDict("SIMPLE").found("nUCorrectors")) + if (simple.dict().found("nUCorrectors")) { - nUCorr = readInt - ( - mesh.solutionDict().subDict("SIMPLE").lookup("nUCorrectors") - ); + nUCorr = readInt(simple.dict().lookup("nUCorrectors")); } if (nUCorr > 0) diff --git a/applications/solvers/incompressible/porousSimpleFoam/porousSimpleFoam.C b/applications/solvers/incompressible/porousSimpleFoam/porousSimpleFoam.C index c54de64ff..83bd923c9 100644 --- a/applications/solvers/incompressible/porousSimpleFoam/porousSimpleFoam.C +++ b/applications/solvers/incompressible/porousSimpleFoam/porousSimpleFoam.C @@ -53,12 +53,10 @@ int main(int argc, char *argv[]) Info<< "\nStarting time loop\n" << endl; - while (runTime.loop()) + while (simple.loop()) { Info<< "Time = " << runTime.timeName() << nl << endl; - p.storePrevIter(); - // Pressure-velocity SIMPLE corrector { #include "UEqn.H" diff --git a/applications/solvers/incompressible/simpleFoam/createFields.H b/applications/solvers/incompressible/simpleFoam/createFields.H index c55d47984..78d6fd69d 100644 --- a/applications/solvers/incompressible/simpleFoam/createFields.H +++ b/applications/solvers/incompressible/simpleFoam/createFields.H @@ -31,7 +31,7 @@ label pRefCell = 0; scalar pRefValue = 0.0; - setRefCell(p, mesh.solutionDict().subDict("SIMPLE"), pRefCell, pRefValue); + setRefCell(p, simple.dict(), pRefCell, pRefValue); mesh.schemesDict().setFluxRequired(p.name()); singlePhaseTransportModel laminarTransport(U, phi); diff --git a/applications/solvers/incompressible/simpleFoam/simpleFoam.C b/applications/solvers/incompressible/simpleFoam/simpleFoam.C index f80402526..8bd72c217 100644 --- a/applications/solvers/incompressible/simpleFoam/simpleFoam.C +++ b/applications/solvers/incompressible/simpleFoam/simpleFoam.C @@ -55,12 +55,10 @@ int main(int argc, char *argv[]) Info<< "\nStarting time loop\n" << endl; - while (runTime.loop()) + while (simple.loop()) { Info<< "Time = " << runTime.timeName() << nl << endl; - p.storePrevIter(); - // Pressure-velocity SIMPLE corrector { # include "UEqn.H" diff --git a/applications/solvers/incompressible/simpleSRFFoam/createFields.H b/applications/solvers/incompressible/simpleSRFFoam/createFields.H index 9cabfc5d0..11f446869 100644 --- a/applications/solvers/incompressible/simpleSRFFoam/createFields.H +++ b/applications/solvers/incompressible/simpleSRFFoam/createFields.H @@ -42,7 +42,7 @@ label pRefCell = 0; scalar pRefValue = 0.0; - setRefCell(p, mesh.solutionDict().subDict("SIMPLE"), pRefCell, pRefValue); + setRefCell(p, simple.dict(), pRefCell, pRefValue); mesh.schemesDict().setFluxRequired(p.name()); singlePhaseTransportModel laminarTransport(Urel, phi); diff --git a/applications/solvers/incompressible/simpleSRFFoam/simpleSRFFoam.C b/applications/solvers/incompressible/simpleSRFFoam/simpleSRFFoam.C index de7c37556..c997a4c03 100644 --- a/applications/solvers/incompressible/simpleSRFFoam/simpleSRFFoam.C +++ b/applications/solvers/incompressible/simpleSRFFoam/simpleSRFFoam.C @@ -59,12 +59,10 @@ int main(int argc, char *argv[]) Info<< "\nStarting time loop\n" << endl; - for (runTime++; !runTime.end(); runTime++) + while(simple.loop()) { Info<< "Time = " << runTime.timeName() << nl << endl; - p.storePrevIter(); - // Pressure-velocity SIMPLE corrector { // Momentum predictor diff --git a/applications/solvers/lagrangian/coalChemistryFoam/UEqn.H b/applications/solvers/lagrangian/coalChemistryFoam/UEqn.H index b02a7c61e..deb710cce 100644 --- a/applications/solvers/lagrangian/coalChemistryFoam/UEqn.H +++ b/applications/solvers/lagrangian/coalChemistryFoam/UEqn.H @@ -11,7 +11,7 @@ UEqn.relax(); - if (momentumPredictor) + if (pimple.momentumPredictor()) { solve(UEqn == -fvc::grad(p)); } diff --git a/applications/solvers/lagrangian/coalChemistryFoam/coalChemistryFoam.C b/applications/solvers/lagrangian/coalChemistryFoam/coalChemistryFoam.C index 4d031e521..570327101 100644 --- a/applications/solvers/lagrangian/coalChemistryFoam/coalChemistryFoam.C +++ b/applications/solvers/lagrangian/coalChemistryFoam/coalChemistryFoam.C @@ -44,6 +44,7 @@ Description #include "chemistrySolver.H" #include "timeActivatedExplicitSource.H" #include "radiationModel.H" +#include "pimpleControl.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -53,6 +54,9 @@ int main(int argc, char *argv[]) #include "createTime.H" #include "createMesh.H" + + pimpleControl pimple(mesh); + #include "readChemistryProperties.H" #include "readGravitationalAcceleration.H" #include "createFields.H" @@ -70,7 +74,6 @@ int main(int argc, char *argv[]) while (runTime.run()) { #include "readTimeControls.H" - #include "readPISOControls.H" #include "compressibleCourantNo.H" #include "setDeltaT.H" @@ -89,14 +92,14 @@ int main(int argc, char *argv[]) #include "rhoEqn.H" // --- PIMPLE loop - for (int ocorr=1; ocorr<=nOuterCorr; ocorr++) + while (pimple.loop()) { #include "UEqn.H" #include "YEqn.H" #include "hsEqn.H" // --- PISO loop - for (int corr=1; corr<=nCorr; corr++) + while (pimple.correct()) { #include "pEqn.H" } diff --git a/applications/solvers/lagrangian/coalChemistryFoam/createFields.H b/applications/solvers/lagrangian/coalChemistryFoam/createFields.H index 65be09775..12a6e9548 100644 --- a/applications/solvers/lagrangian/coalChemistryFoam/createFields.H +++ b/applications/solvers/lagrangian/coalChemistryFoam/createFields.H @@ -149,3 +149,5 @@ mesh, dimensionedScalar("chemistrySh", dimEnergy/dimTime/dimVolume, 0.0) ); + + mesh.schemesDict().setFluxRequired(p.name()); diff --git a/applications/solvers/lagrangian/coalChemistryFoam/pEqn.H b/applications/solvers/lagrangian/coalChemistryFoam/pEqn.H index b31ad45ed..9878707eb 100644 --- a/applications/solvers/lagrangian/coalChemistryFoam/pEqn.H +++ b/applications/solvers/lagrangian/coalChemistryFoam/pEqn.H @@ -3,7 +3,7 @@ rho = thermo.rho(); volScalarField rUA = 1.0/UEqn.A(); U = rUA*UEqn.H(); -if (transonic) +if (pimple.transonic()) { surfaceScalarField phid ( @@ -15,7 +15,7 @@ if (transonic) ) ); - for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) + while (pimple.correctNonOrthogonal()) { fvScalarMatrix pEqn ( @@ -28,7 +28,7 @@ if (transonic) pEqn.solve(); - if (nonOrth == nNonOrthCorr) + if (pimple.finalNonOrthogonalIter()) { phi == pEqn.flux(); } @@ -43,7 +43,7 @@ else + fvc::ddtPhiCorr(rUA, rho, U, phi) ); - for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) + while (pimple.correctNonOrthogonal()) { fvScalarMatrix pEqn ( @@ -56,7 +56,7 @@ else pEqn.solve(); - if (nonOrth == nNonOrthCorr) + if (pimple.finalNonOrthogonalIter()) { phi += pEqn.flux(); } diff --git a/applications/solvers/lagrangian/porousExplicitSourceReactingParcelFoam/UEqn.H b/applications/solvers/lagrangian/porousExplicitSourceReactingParcelFoam/UEqn.H index e77fe75da..f46d1d902 100644 --- a/applications/solvers/lagrangian/porousExplicitSourceReactingParcelFoam/UEqn.H +++ b/applications/solvers/lagrangian/porousExplicitSourceReactingParcelFoam/UEqn.H @@ -12,7 +12,7 @@ pZones.addResistance(UEqn); - if (momentumPredictor) + if (piso.momentumPredictor()) { solve(UEqn == -fvc::grad(p)); } diff --git a/applications/solvers/lagrangian/porousExplicitSourceReactingParcelFoam/createFields.H b/applications/solvers/lagrangian/porousExplicitSourceReactingParcelFoam/createFields.H index cf3f484bd..7a5b48ac9 100644 --- a/applications/solvers/lagrangian/porousExplicitSourceReactingParcelFoam/createFields.H +++ b/applications/solvers/lagrangian/porousExplicitSourceReactingParcelFoam/createFields.H @@ -103,3 +103,5 @@ mesh, dimensionedScalar("chemistrySh", dimEnergy/dimTime/dimVolume, 0.0) ); + + mesh.schemesDict().setFluxRequired(p.name()); diff --git a/applications/solvers/lagrangian/porousExplicitSourceReactingParcelFoam/pEqn.H b/applications/solvers/lagrangian/porousExplicitSourceReactingParcelFoam/pEqn.H index 43d677609..ff590e59e 100644 --- a/applications/solvers/lagrangian/porousExplicitSourceReactingParcelFoam/pEqn.H +++ b/applications/solvers/lagrangian/porousExplicitSourceReactingParcelFoam/pEqn.H @@ -23,7 +23,7 @@ ); } - for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) + while (piso.correctNonOrthogonal()) { fvScalarMatrix pEqn ( @@ -35,16 +35,9 @@ + massSource.SuTot() ); - if (corr == nCorr-1 && nonOrth == nNonOrthCorr) - { - pEqn.solve(mesh.solutionDict().solver("pFinal")); - } - else - { - pEqn.solve(); - } + pEqn.solve(mesh.solutionDict().solver(p.select(piso.finalInnerIter()))); - if (nonOrth == nNonOrthCorr) + if (piso.finalNonOrthogonalIter()) { phi += pEqn.flux(); } diff --git a/applications/solvers/lagrangian/porousExplicitSourceReactingParcelFoam/porousExplicitSourceReactingParcelFoam.C b/applications/solvers/lagrangian/porousExplicitSourceReactingParcelFoam/porousExplicitSourceReactingParcelFoam.C index de63f2fbb..68ef32448 100644 --- a/applications/solvers/lagrangian/porousExplicitSourceReactingParcelFoam/porousExplicitSourceReactingParcelFoam.C +++ b/applications/solvers/lagrangian/porousExplicitSourceReactingParcelFoam/porousExplicitSourceReactingParcelFoam.C @@ -49,6 +49,7 @@ Description #include "radiationModel.H" #include "porousZones.H" #include "timeActivatedExplicitSource.H" +#include "pisoControl.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -58,6 +59,9 @@ int main(int argc, char *argv[]) #include "createTime.H" #include "createMesh.H" + + pisoControl piso(mesh); + #include "readChemistryProperties.H" #include "readGravitationalAcceleration.H" #include "createFields.H" @@ -77,7 +81,6 @@ int main(int argc, char *argv[]) while (runTime.run()) { #include "readTimeControls.H" - #include "readPISOControls.H" #include "readAdditionalSolutionControls.H" #include "compressibleCourantNo.H" #include "setDeltaT.H" @@ -95,7 +98,7 @@ int main(int argc, char *argv[]) #include "hsEqn.H" // --- PISO loop - for (int corr = 0; corr < nCorr; corr++) + while (piso.correct()) { #include "pEqn.H" } diff --git a/applications/solvers/lagrangian/reactingParcelFoam/UEqn.H b/applications/solvers/lagrangian/reactingParcelFoam/UEqn.H index 3c4a92709..1c1c1fd0c 100644 --- a/applications/solvers/lagrangian/reactingParcelFoam/UEqn.H +++ b/applications/solvers/lagrangian/reactingParcelFoam/UEqn.H @@ -10,7 +10,7 @@ UEqn.relax(); - if (momentumPredictor) + if (pimple.momentumPredictor()) { solve(UEqn == -fvc::grad(p)); } diff --git a/applications/solvers/lagrangian/reactingParcelFoam/createFields.H b/applications/solvers/lagrangian/reactingParcelFoam/createFields.H index e071ac8b3..9579be78c 100644 --- a/applications/solvers/lagrangian/reactingParcelFoam/createFields.H +++ b/applications/solvers/lagrangian/reactingParcelFoam/createFields.H @@ -109,3 +109,5 @@ mesh, dimensionedScalar("chemistry::Sh", dimEnergy/dimTime/dimVolume, 0.0) ); + + mesh.schemesDict().setFluxRequired(p.name()); diff --git a/applications/solvers/lagrangian/reactingParcelFoam/pEqn.H b/applications/solvers/lagrangian/reactingParcelFoam/pEqn.H index d27afcce8..50185f5fc 100644 --- a/applications/solvers/lagrangian/reactingParcelFoam/pEqn.H +++ b/applications/solvers/lagrangian/reactingParcelFoam/pEqn.H @@ -3,7 +3,7 @@ rho = thermo.rho(); volScalarField rUA = 1.0/UEqn.A(); U = rUA*UEqn.H(); -if (transonic) +if (pimple.transonic()) { surfaceScalarField phid ( @@ -15,7 +15,7 @@ if (transonic) ) ); - for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) + while (pimple.correctNonOrthogonal()) { fvScalarMatrix pEqn ( @@ -28,7 +28,7 @@ if (transonic) pEqn.solve(); - if (nonOrth == nNonOrthCorr) + if (pimple.finalNonOrthogonalIter()) { phi == pEqn.flux(); } @@ -43,7 +43,7 @@ else + fvc::ddtPhiCorr(rUA, rho, U, phi) ); - for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) + while (pimple.correctNonOrthogonal()) { fvScalarMatrix pEqn ( @@ -56,7 +56,7 @@ else pEqn.solve(); - if (nonOrth == nNonOrthCorr) + if (pimple.finalNonOrthogonalIter()) { phi += pEqn.flux(); } diff --git a/applications/solvers/lagrangian/reactingParcelFoam/reactingParcelFoam.C b/applications/solvers/lagrangian/reactingParcelFoam/reactingParcelFoam.C index 154774cca..93971a15b 100644 --- a/applications/solvers/lagrangian/reactingParcelFoam/reactingParcelFoam.C +++ b/applications/solvers/lagrangian/reactingParcelFoam/reactingParcelFoam.C @@ -37,6 +37,7 @@ Description #include "psiChemistryModel.H" #include "chemistrySolver.H" #include "radiationModel.H" +#include "pimpleControl.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -46,6 +47,9 @@ int main(int argc, char *argv[]) #include "createTime.H" #include "createMesh.H" + + pimpleControl pimple(mesh); + #include "readChemistryProperties.H" #include "readGravitationalAcceleration.H" #include "createFields.H" @@ -63,7 +67,6 @@ int main(int argc, char *argv[]) while (runTime.run()) { #include "readTimeControls.H" - #include "readPISOControls.H" #include "compressibleCourantNo.H" #include "setDeltaT.H" @@ -77,13 +80,13 @@ int main(int argc, char *argv[]) #include "rhoEqn.H" // --- PIMPLE loop - for (int ocorr=1; ocorr<=nOuterCorr; ocorr++) + while (pimple.loop()) { #include "UEqn.H" #include "YEqn.H" // --- PISO loop - for (int corr=1; corr<=nCorr; corr++) + while (pimple.correct()) { #include "hsEqn.H" #include "pEqn.H" diff --git a/applications/solvers/multiSolver/multiSolverDemo/createFields_icoFoam.H b/applications/solvers/multiSolver/multiSolverDemo/createFields_icoFoam.H index 6a7d6b9a8..2e2c782db 100644 --- a/applications/solvers/multiSolver/multiSolverDemo/createFields_icoFoam.H +++ b/applications/solvers/multiSolver/multiSolverDemo/createFields_icoFoam.H @@ -52,4 +52,5 @@ label pRefCell = 0; scalar pRefValue = 0.0; - setRefCell(p, mesh.solutionDict().subDict("PISO"), pRefCell, pRefValue); + setRefCell(p, piso.dict(), pRefCell, pRefValue); + mesh.schemesDict().setFluxRequired(p.name()); diff --git a/applications/solvers/multiSolver/multiSolverDemo/multiSolverDemo.C b/applications/solvers/multiSolver/multiSolverDemo/multiSolverDemo.C index 27091f810..084de4811 100644 --- a/applications/solvers/multiSolver/multiSolverDemo/multiSolverDemo.C +++ b/applications/solvers/multiSolver/multiSolverDemo/multiSolverDemo.C @@ -35,6 +35,8 @@ Author #include "fvCFD.H" #include "multiSolver.H" +#include "pisoControl.H" +#include "simpleControl.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/applications/solvers/multiSolver/multiSolverDemo/solverIcoFoam.H b/applications/solvers/multiSolver/multiSolverDemo/solverIcoFoam.H index 1fedb60d0..2a2407e3c 100644 --- a/applications/solvers/multiSolver/multiSolverDemo/solverIcoFoam.H +++ b/applications/solvers/multiSolver/multiSolverDemo/solverIcoFoam.H @@ -1,6 +1,9 @@ # include "createTime.H" # include "createMesh.H" + + pisoControl piso(mesh); + # include "createFields_icoFoam.H" # include "initContinuityErrs.H" @@ -12,7 +15,6 @@ { Info<< "Time = " << runTime.timeName() << nl << endl; -# include "readPISOControls.H" # include "CourantNo.H" fvVectorMatrix UEqn @@ -26,7 +28,7 @@ // --- PISO loop - for (int corr=0; corr("nNonOrthogonalCorrectors", 0); - - bool momentumPredictor = - simple.lookupOrDefault("momentumPredictor", true); - - for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) + while (simple.correctNonOrthogonal()) { solve ( diff --git a/applications/solvers/multiphase/MRFInterFoam/MRFInterFoam.C b/applications/solvers/multiphase/MRFInterFoam/MRFInterFoam.C index d4374d687..d2dec21ac 100644 --- a/applications/solvers/multiphase/MRFInterFoam/MRFInterFoam.C +++ b/applications/solvers/multiphase/MRFInterFoam/MRFInterFoam.C @@ -43,6 +43,7 @@ Description #include "twoPhaseMixture.H" #include "turbulenceModel.H" #include "MRFZones.H" +#include "pimpleControl.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -51,8 +52,10 @@ int main(int argc, char *argv[]) #include "setRootCase.H" #include "createTime.H" #include "createMesh.H" + + pimpleControl pimple(mesh); + #include "readGravitationalAcceleration.H" - #include "readPIMPLEControls.H" #include "initContinuityErrs.H" #include "createFields.H" #include "createMRFZones.H" @@ -67,7 +70,6 @@ int main(int argc, char *argv[]) while (runTime.run()) { - #include "readPIMPLEControls.H" #include "readTimeControls.H" #include "CourantNo.H" #include "setDeltaT.H" @@ -77,8 +79,7 @@ int main(int argc, char *argv[]) Info<< "Time = " << runTime.timeName() << nl << endl; // Pressure-velocity corrector - int oCorr = 0; - do + while (pimple.loop()) { twoPhaseProperties.correct(); @@ -87,7 +88,7 @@ int main(int argc, char *argv[]) # include "UEqn.H" // --- PISO loop - for (int corr=0; corrcorrect(); - } while (++oCorr < nOuterCorr); + } runTime.write(); diff --git a/applications/solvers/multiphase/MRFInterFoam/UEqn.H b/applications/solvers/multiphase/MRFInterFoam/UEqn.H index 0a65664f7..cc0763d8b 100644 --- a/applications/solvers/multiphase/MRFInterFoam/UEqn.H +++ b/applications/solvers/multiphase/MRFInterFoam/UEqn.H @@ -17,7 +17,7 @@ UEqn.relax(); - if (momentumPredictor) + if (pimple.momentumPredictor()) { solve ( diff --git a/applications/solvers/multiphase/MRFInterFoam/pEqn.H b/applications/solvers/multiphase/MRFInterFoam/pEqn.H index b52c7441c..49d6dc579 100644 --- a/applications/solvers/multiphase/MRFInterFoam/pEqn.H +++ b/applications/solvers/multiphase/MRFInterFoam/pEqn.H @@ -20,7 +20,7 @@ )*rUAf; adjustPhi(phi, U, p); - for(int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) + while (pimple.correctNonOrthogonal()) { fvScalarMatrix pdEqn ( @@ -29,16 +29,12 @@ pdEqn.setReference(pdRefCell, pdRefValue); - if (corr == nCorr-1 && nonOrth == nNonOrthCorr) - { - pdEqn.solve(mesh.solutionDict().solver(pd.name() + "Final")); - } - else - { - pdEqn.solve(mesh.solutionDict().solver(pd.name())); - } + pdEqn.solve + ( + mesh.solutionDict().solver(pd.select(pimple.finalInnerIter())) + ); - if (nonOrth == nNonOrthCorr) + if (pimple.finalNonOrthogonalIter()) { phi -= pdEqn.flux(); } diff --git a/applications/solvers/multiphase/barotropicCavitatingFoam/barotropicCavitatingFoam.C b/applications/solvers/multiphase/barotropicCavitatingFoam/barotropicCavitatingFoam.C index 4d04b5c36..ac37acbbe 100644 --- a/applications/solvers/multiphase/barotropicCavitatingFoam/barotropicCavitatingFoam.C +++ b/applications/solvers/multiphase/barotropicCavitatingFoam/barotropicCavitatingFoam.C @@ -30,6 +30,7 @@ Description \*---------------------------------------------------------------------------*/ #include "fvCFD.H" +#include "pisoControl.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -40,7 +41,9 @@ int main(int argc, char *argv[]) # include "createTime.H" # include "createMesh.H" -# include "readPISOControls.H" + + pisoControl piso(mesh); + # include "readThermodynamicProperties.H" # include "readTransportProperties.H" # include "createFields.H" @@ -61,7 +64,7 @@ int main(int argc, char *argv[]) # include "UEqn.H" // --- PISO loop - for (int corr = 0; corr < nCorr; corr++) + while (piso.correct()) { # include "pEqn.H" } diff --git a/applications/solvers/multiphase/barotropicCavitatingFoam/createFields.H b/applications/solvers/multiphase/barotropicCavitatingFoam/createFields.H index 1286f1d6f..835fa2cfa 100644 --- a/applications/solvers/multiphase/barotropicCavitatingFoam/createFields.H +++ b/applications/solvers/multiphase/barotropicCavitatingFoam/createFields.H @@ -75,3 +75,5 @@ ), (gamma*psig + (1.0 - gamma)*psil)/rho ); + + mesh.schemesDict().setFluxRequired(p.name()); diff --git a/applications/solvers/multiphase/barotropicCavitatingFoam/pEqn.H b/applications/solvers/multiphase/barotropicCavitatingFoam/pEqn.H index 84f5f0910..cc5e701d2 100644 --- a/applications/solvers/multiphase/barotropicCavitatingFoam/pEqn.H +++ b/applications/solvers/multiphase/barotropicCavitatingFoam/pEqn.H @@ -15,7 +15,7 @@ surfaceScalarField phip = fvc::interpolate(psiByRho)*phi; - for(int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) + while (piso.correctNonOrthogonal()) { fvScalarMatrix pEqn ( @@ -29,7 +29,7 @@ + fvc::div(phi) - pEqn ); - if (nonOrth == nNonOrthCorr) + if (piso.finalNonOrthogonalIter()) { phi -= pEqn.flux(); } diff --git a/applications/solvers/multiphase/bubbleFoam/bubbleFoam.C b/applications/solvers/multiphase/bubbleFoam/bubbleFoam.C index e77fd4a81..1104be238 100644 --- a/applications/solvers/multiphase/bubbleFoam/bubbleFoam.C +++ b/applications/solvers/multiphase/bubbleFoam/bubbleFoam.C @@ -34,6 +34,7 @@ Description #include "nearWallDist.H" #include "wallFvPatch.H" #include "Switch.H" +#include "pisoControl.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -43,6 +44,9 @@ int main(int argc, char *argv[]) # include "createTime.H" # include "createMesh.H" + + pisoControl piso(mesh); + # include "readGravitationalAcceleration.H" # include "createFields.H" # include "initContinuityErrs.H" @@ -64,7 +68,7 @@ int main(int argc, char *argv[]) // --- PISO loop - for (int corr = 0; corr < nCorr; corr++) + while (piso.correct()) { # include "pEqn.H" diff --git a/applications/solvers/multiphase/bubbleFoam/createFields.H b/applications/solvers/multiphase/bubbleFoam/createFields.H index 875a4f1be..26013f9f4 100644 --- a/applications/solvers/multiphase/bubbleFoam/createFields.H +++ b/applications/solvers/multiphase/bubbleFoam/createFields.H @@ -178,4 +178,5 @@ label pRefCell = 0; scalar pRefValue = 0.0; - setRefCell(p, mesh.solutionDict().subDict("PISO"), pRefCell, pRefValue); + setRefCell(p, piso.dict(), pRefCell, pRefValue); + mesh.schemesDict().setFluxRequired(p.name()); diff --git a/applications/solvers/multiphase/bubbleFoam/pEqn.H b/applications/solvers/multiphase/bubbleFoam/pEqn.H index dde9a0857..98a3ca381 100644 --- a/applications/solvers/multiphase/bubbleFoam/pEqn.H +++ b/applications/solvers/multiphase/bubbleFoam/pEqn.H @@ -38,7 +38,7 @@ alphaf*rUaAf/rhoa + betaf*rUbAf/rhob ); - for(int nonOrth = 0; nonOrth <= nNonOrthCorr; nonOrth++) + while (piso.correctNonOrthogonal()) { fvScalarMatrix pEqn ( @@ -48,7 +48,7 @@ pEqn.setReference(pRefCell, pRefValue); pEqn.solve(); - if (nonOrth == nNonOrthCorr) + if (piso.finalNonOrthogonalIter()) { surfaceScalarField SfGradp = pEqn.flux()/Dp; diff --git a/applications/solvers/multiphase/bubbleFoam/readBubbleFoamControls.H b/applications/solvers/multiphase/bubbleFoam/readBubbleFoamControls.H index bf70e2bab..05bf3c6eb 100644 --- a/applications/solvers/multiphase/bubbleFoam/readBubbleFoamControls.H +++ b/applications/solvers/multiphase/bubbleFoam/readBubbleFoamControls.H @@ -1,5 +1,3 @@ -# include "readPISOControls.H" + int nAlphaCorr(readInt(piso.dict().lookup("nAlphaCorr"))); - int nAlphaCorr(readInt(piso.lookup("nAlphaCorr"))); - - Switch correctAlpha(piso.lookup("correctAlpha")); + Switch correctAlpha(piso.dict().lookup("correctAlpha")); diff --git a/applications/solvers/multiphase/cavitatingFoam/UEqn.H b/applications/solvers/multiphase/cavitatingFoam/UEqn.H index 01911faaa..9a5761b59 100644 --- a/applications/solvers/multiphase/cavitatingFoam/UEqn.H +++ b/applications/solvers/multiphase/cavitatingFoam/UEqn.H @@ -16,7 +16,7 @@ UEqn.relax(); - if (momentumPredictor) + if (pimple.momentumPredictor()) { solve(UEqn == -fvc::grad(p)); } diff --git a/applications/solvers/multiphase/cavitatingFoam/cavitatingFoam.C b/applications/solvers/multiphase/cavitatingFoam/cavitatingFoam.C index ff40c6ade..d2d293a78 100644 --- a/applications/solvers/multiphase/cavitatingFoam/cavitatingFoam.C +++ b/applications/solvers/multiphase/cavitatingFoam/cavitatingFoam.C @@ -36,6 +36,7 @@ Description #include "barotropicCompressibilityModel.H" #include "twoPhaseMixture.H" #include "turbulenceModel.H" +#include "pimpleControl.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -45,10 +46,12 @@ int main(int argc, char *argv[]) # include "createTime.H" # include "createMesh.H" + + pimpleControl pimple(mesh); + # include "readThermodynamicProperties.H" # include "createControls.H" # include "createFields.H" -# include "initContinuityErrs.H" # include "compressibleCourantNo.H" # include "setInitialDeltaT.H" @@ -65,13 +68,13 @@ int main(int argc, char *argv[]) runTime++; Info<< "Time = " << runTime.timeName() << nl << endl; - for (int outerCorr = 0; outerCorr < nOuterCorr; outerCorr++) + while (pimple.loop()) { # include "rhoEqn.H" # include "gammaPsi.H" # include "UEqn.H" - for (int corr = 0; corr < nCorr; corr++) + while (pimple.correct()) { # include "pEqn.H" } diff --git a/applications/solvers/multiphase/cavitatingFoam/createFields.H b/applications/solvers/multiphase/cavitatingFoam/createFields.H index 49c7de147..26835d1f5 100644 --- a/applications/solvers/multiphase/cavitatingFoam/createFields.H +++ b/applications/solvers/multiphase/cavitatingFoam/createFields.H @@ -83,3 +83,6 @@ ( incompressible::turbulenceModel::New(U, phiv, twoPhaseProperties) ); + + mesh.schemesDict().setFluxRequired(p.name()); + mesh.schemesDict().setFluxRequired(rho.name()); diff --git a/applications/solvers/multiphase/cavitatingFoam/pEqn.H b/applications/solvers/multiphase/cavitatingFoam/pEqn.H index 9d7956629..17061666a 100644 --- a/applications/solvers/multiphase/cavitatingFoam/pEqn.H +++ b/applications/solvers/multiphase/cavitatingFoam/pEqn.H @@ -1,5 +1,5 @@ { - if (nOuterCorr == 1) + if (pimple.firstIter()) { p = ( @@ -24,7 +24,7 @@ # include "resetPhivPatches.H" - for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) + while (pimple.correctNonOrthogonal()) { fvScalarMatrix pEqn ( @@ -35,16 +35,12 @@ - fvm::laplacian(rUAf, p) ); - if (corr == nCorr - 1 && nonOrth == nNonOrthCorr) - { - pEqn.solve(mesh.solutionDict().solver(p.name() + "Final")); - } - else - { - pEqn.solve(mesh.solutionDict().solver(p.name())); - } + pEqn.solve + ( + mesh.solutionDict().solver(p.select(pimple.finalInnerIter())) + ); - if (nonOrth == nNonOrthCorr) + if (pimple.finalNonOrthogonalIter()) { phiv += (phiGradp + pEqn.flux())/rhof; } @@ -80,9 +76,9 @@ U = HbyA - rUA*fvc::grad(p); // Remove the swirl component of velocity for "wedge" cases - if (piso.found("removeSwirl")) + if (pimple.dict().found("removeSwirl")) { - label swirlCmpt(readLabel(piso.lookup("removeSwirl"))); + label swirlCmpt(readLabel(pimple.dict().lookup("removeSwirl"))); Info<< "Removing swirl component-" << swirlCmpt << " of U" << endl; U.field().replace(swirlCmpt, 0.0); diff --git a/applications/solvers/multiphase/cavitatingFoam/readControls.H b/applications/solvers/multiphase/cavitatingFoam/readControls.H index d4206bef4..a2d4dc80a 100644 --- a/applications/solvers/multiphase/cavitatingFoam/readControls.H +++ b/applications/solvers/multiphase/cavitatingFoam/readControls.H @@ -1,5 +1,3 @@ #include "readTimeControls.H" maxAcousticCo = readScalar(runTime.controlDict().lookup("maxAcousticCo")); - -#include "readPISOControls.H" diff --git a/applications/solvers/multiphase/compressibleInterDyMFoam/UEqn.H b/applications/solvers/multiphase/compressibleInterDyMFoam/UEqn.H index 2becae7f2..b02f00cd7 100644 --- a/applications/solvers/multiphase/compressibleInterDyMFoam/UEqn.H +++ b/applications/solvers/multiphase/compressibleInterDyMFoam/UEqn.H @@ -16,7 +16,7 @@ UEqn.relax(); - if (momentumPredictor) + if (pimple.momentumPredictor()) { solve ( diff --git a/applications/solvers/multiphase/compressibleInterDyMFoam/alphaEqnsSubCycle.H b/applications/solvers/multiphase/compressibleInterDyMFoam/alphaEqnsSubCycle.H index 32a716313..5371c5b85 100644 --- a/applications/solvers/multiphase/compressibleInterDyMFoam/alphaEqnsSubCycle.H +++ b/applications/solvers/multiphase/compressibleInterDyMFoam/alphaEqnsSubCycle.H @@ -1,12 +1,12 @@ { label nAlphaCorr ( - readLabel(piso.lookup("nAlphaCorr")) + readLabel(pimple.dict().lookup("nAlphaCorr")) ); label nAlphaSubCycles ( - readLabel(piso.lookup("nAlphaSubCycles")) + readLabel(pimple.dict().lookup("nAlphaSubCycles")) ); surfaceScalarField phic = mag(phi/mesh.magSf()); @@ -38,7 +38,7 @@ # include "alphaEqns.H" } - if (oCorr == 0) + if (pimple.firstIter()) { interface.correct(); } diff --git a/applications/solvers/multiphase/compressibleInterDyMFoam/compressibleInterDyMFoam.C b/applications/solvers/multiphase/compressibleInterDyMFoam/compressibleInterDyMFoam.C index 515d3c89f..e4464c475 100644 --- a/applications/solvers/multiphase/compressibleInterDyMFoam/compressibleInterDyMFoam.C +++ b/applications/solvers/multiphase/compressibleInterDyMFoam/compressibleInterDyMFoam.C @@ -43,6 +43,7 @@ Description #include "interfaceProperties.H" #include "twoPhaseMixture.H" #include "turbulenceModel.H" +#include "pimpleControl.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -51,6 +52,9 @@ int main(int argc, char *argv[]) #include "setRootCase.H" #include "createTime.H" #include "createDynamicFvMesh.H" + + pimpleControl pimple(mesh); + #include "readGravitationalAcceleration.H" #include "createControls.H" #include "initContinuityErrs.H" @@ -101,7 +105,7 @@ int main(int argc, char *argv[]) turbulence->correct(); // --- Outer-corrector loop - for (int oCorr=0; oCorr 1 && nOuterCorr != 1) - { - FatalErrorIn(args.executable()) - << "Sub-cycling alpha is only allowed for PISO, " - "i.e. when the number of outer-correctors = 1" - << exit(FatalError); - } +if (nAlphaSubCycles > 1 && pimple.nCorrPIMPLE() != 1) +{ + FatalErrorIn(args.executable()) + << "Sub-cycling alpha is only allowed for PISO, " + "i.e. when the number of outer-correctors = 1" + << exit(FatalError); +} - bool correctPhi = true; - if (piso.found("correctPhi")) - { - correctPhi = Switch(piso.lookup("correctPhi")); - } +bool correctPhi +( + pimple.dict().lookupOrDefault("correctPhi", true) +); - bool checkMeshCourantNo = false; - if (piso.found("checkMeshCourantNo")) - { - checkMeshCourantNo = Switch(piso.lookup("checkMeshCourantNo")); - } +bool checkMeshCourantNo +( + pimple.dict().lookupOrDefault("checkMeshCourantNo", false) +); diff --git a/applications/solvers/multiphase/compressibleInterDyMFoam/createFields.H b/applications/solvers/multiphase/compressibleInterDyMFoam/createFields.H index 3da1b5e9c..a2f5fd0a8 100644 --- a/applications/solvers/multiphase/compressibleInterDyMFoam/createFields.H +++ b/applications/solvers/multiphase/compressibleInterDyMFoam/createFields.H @@ -142,3 +142,5 @@ pcorrTypes[i] = fixedValueFvPatchScalarField::typeName; } } + + mesh.schemesDict().setFluxRequired(p.name()); diff --git a/applications/solvers/multiphase/compressibleInterDyMFoam/pEqn.H b/applications/solvers/multiphase/compressibleInterDyMFoam/pEqn.H index 56e1e6baa..df30525d3 100644 --- a/applications/solvers/multiphase/compressibleInterDyMFoam/pEqn.H +++ b/applications/solvers/multiphase/compressibleInterDyMFoam/pEqn.H @@ -4,7 +4,7 @@ tmp pEqnComp; - if (transonic) + if (pimple.transonic()) { pEqnComp = (fvm::ddt(p) + fvm::div(phi, p) - fvm::Sp(fvc::div(phi), p)); @@ -31,7 +31,7 @@ + fvc::interpolate(rho)*(g & mesh.Sf()) )*rUAf; - for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) + while (pimple.correctNonOrthogonal()) { fvScalarMatrix pEqnIncomp ( @@ -39,12 +39,7 @@ - fvm::laplacian(rUAf, p) ); - if - ( - oCorr == nOuterCorr-1 - && corr == nCorr-1 - && nonOrth == nNonOrthCorr - ) + if (pimple.finalInnerIter()) { solve ( @@ -70,7 +65,7 @@ ); } - if (nonOrth == nNonOrthCorr) + if (pimple.finalNonOrthogonalIter()) { dgdt = (pos(alpha2)*(psi2/rho2) - pos(alpha1)*(psi1/rho1)) diff --git a/applications/solvers/multiphase/compressibleInterDyMFoam/readControls.H b/applications/solvers/multiphase/compressibleInterDyMFoam/readControls.H index bd209aef2..703827d6d 100644 --- a/applications/solvers/multiphase/compressibleInterDyMFoam/readControls.H +++ b/applications/solvers/multiphase/compressibleInterDyMFoam/readControls.H @@ -1,24 +1,15 @@ - #include "readPISOControls.H" - #include "readTimeControls.H" +#include "readTimeControls.H" - nAlphaSubCycles = readLabel(piso.lookup("nAlphaSubCycles")); +nAlphaSubCycles = readLabel(pimple.dict().lookup("nAlphaSubCycles")); - if (nAlphaSubCycles > 1 && nOuterCorr != 1) - { - FatalErrorIn(args.executable()) - << "Sub-cycling alpha is only allowed for PISO, " - "i.e. when the number of outer-correctors = 1" - << exit(FatalError); - } +if (nAlphaSubCycles > 1 && pimple.nCorrPIMPLE() != 1) +{ + FatalErrorIn(args.executable()) + << "Sub-cycling alpha is only allowed for PISO, " + "i.e. when the number of outer-correctors = 1" + << exit(FatalError); +} - correctPhi = true; - if (piso.found("correctPhi")) - { - correctPhi = Switch(piso.lookup("correctPhi")); - } +correctPhi = pimple.dict().lookupOrDefault("correctPhi", true); - checkMeshCourantNo = false; - if (piso.found("checkMeshCourantNo")) - { - checkMeshCourantNo = Switch(piso.lookup("checkMeshCourantNo")); - } +checkMeshCourantNo = pimple.dict().lookupOrDefault("checkMeshCourantNo", false); diff --git a/applications/solvers/multiphase/compressibleInterFoam/UEqn.H b/applications/solvers/multiphase/compressibleInterFoam/UEqn.H index 0b1a9ac02..7ec0ef309 100644 --- a/applications/solvers/multiphase/compressibleInterFoam/UEqn.H +++ b/applications/solvers/multiphase/compressibleInterFoam/UEqn.H @@ -16,7 +16,7 @@ UEqn.relax(); - if (momentumPredictor) + if (pimple.momentumPredictor()) { solve ( diff --git a/applications/solvers/multiphase/compressibleInterFoam/alphaEqnsSubCycle.H b/applications/solvers/multiphase/compressibleInterFoam/alphaEqnsSubCycle.H index 89ba7a4e7..d57b8cd6e 100644 --- a/applications/solvers/multiphase/compressibleInterFoam/alphaEqnsSubCycle.H +++ b/applications/solvers/multiphase/compressibleInterFoam/alphaEqnsSubCycle.H @@ -1,12 +1,12 @@ { label nAlphaCorr ( - readLabel(piso.lookup("nAlphaCorr")) + readLabel(pimple.dict().lookup("nAlphaCorr")) ); label nAlphaSubCycles ( - readLabel(piso.lookup("nAlphaSubCycles")) + readLabel(pimple.dict().lookup("nAlphaSubCycles")) ); surfaceScalarField phic = mag(phi/mesh.magSf()); @@ -36,7 +36,7 @@ #include "alphaEqns.H" } - if (oCorr == 0) + if (pimple.firstIter()) { interface.correct(); } diff --git a/applications/solvers/multiphase/compressibleInterFoam/compressibleInterFoam.C b/applications/solvers/multiphase/compressibleInterFoam/compressibleInterFoam.C index 2469bda8c..1fb006e6c 100644 --- a/applications/solvers/multiphase/compressibleInterFoam/compressibleInterFoam.C +++ b/applications/solvers/multiphase/compressibleInterFoam/compressibleInterFoam.C @@ -41,6 +41,7 @@ Description #include "interfaceProperties.H" #include "twoPhaseMixture.H" #include "turbulenceModel.H" +#include "pimpleControl.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -49,9 +50,11 @@ int main(int argc, char *argv[]) #include "setRootCase.H" #include "createTime.H" #include "createMesh.H" + + pimpleControl pimple(mesh); + #include "readGravitationalAcceleration.H" #include "createControls.H" - #include "initContinuityErrs.H" #include "createFields.H" #include "CourantNo.H" #include "setInitialDeltaT.H" @@ -71,7 +74,7 @@ int main(int argc, char *argv[]) Info<< "Time = " << runTime.timeName() << nl << endl; // --- Outer-corrector loop - for (int oCorr=0; oCorr 1 && nOuterCorr != 1) - { - FatalErrorIn(args.executable()) - << "Sub-cycling alpha is only allowed for PISO, " - "i.e. when the number of outer-correctors = 1" - << exit(FatalError); - } +if (nAlphaSubCycles > 1 && pimple.nCorrPIMPLE() != 1) +{ + FatalErrorIn(args.executable()) + << "Sub-cycling alpha is only allowed for PISO, " + "i.e. when the number of outer-correctors = 1" + << exit(FatalError); +} diff --git a/applications/solvers/multiphase/compressibleInterFoam/createFields.H b/applications/solvers/multiphase/compressibleInterFoam/createFields.H index 3e6904d38..555d86782 100644 --- a/applications/solvers/multiphase/compressibleInterFoam/createFields.H +++ b/applications/solvers/multiphase/compressibleInterFoam/createFields.H @@ -127,3 +127,5 @@ ( incompressible::turbulenceModel::New(U, phi, twoPhaseProperties) ); + + mesh.schemesDict().setFluxRequired(p.name()); \ No newline at end of file diff --git a/applications/solvers/multiphase/compressibleInterFoam/pEqn.H b/applications/solvers/multiphase/compressibleInterFoam/pEqn.H index 9d2dc2391..f80200538 100644 --- a/applications/solvers/multiphase/compressibleInterFoam/pEqn.H +++ b/applications/solvers/multiphase/compressibleInterFoam/pEqn.H @@ -4,7 +4,7 @@ tmp pEqnComp; - if (transonic) + if (pimple.transonic()) { pEqnComp = (fvm::ddt(p) + fvm::div(phi, p) - fvm::Sp(fvc::div(phi), p)); @@ -30,7 +30,7 @@ + fvc::interpolate(rho)*(g & mesh.Sf()) )*rUAf; - for(int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) + while (pimple.correctNonOrthogonal()) { fvScalarMatrix pEqnIncomp ( @@ -48,7 +48,7 @@ + pEqnIncomp ); - if (nonOrth == nNonOrthCorr) + if (pimple.finalNonOrthogonalIter()) { dgdt = (pos(alpha2)*(psi2/rho2) - pos(alpha1)*(psi1/rho1)) diff --git a/applications/solvers/multiphase/compressibleInterFoam/readControls.H b/applications/solvers/multiphase/compressibleInterFoam/readControls.H index 10af30422..f5a1e5675 100644 --- a/applications/solvers/multiphase/compressibleInterFoam/readControls.H +++ b/applications/solvers/multiphase/compressibleInterFoam/readControls.H @@ -1,12 +1,11 @@ - #include "readPISOControls.H" - #include "readTimeControls.H" +#include "readTimeControls.H" - nAlphaSubCycles = readLabel(piso.lookup("nAlphaSubCycles")); +nAlphaSubCycles = readLabel(pimple.dict().lookup("nAlphaSubCycles")); - if (nAlphaSubCycles > 1 && nOuterCorr != 1) - { - FatalErrorIn(args.executable()) - << "Sub-cycling alpha is only allowed for PISO, " - "i.e. when the number of outer-correctors = 1" - << exit(FatalError); - } +if (nAlphaSubCycles > 1 && pimple.nCorrPIMPLE() != 1) +{ + FatalErrorIn(args.executable()) + << "Sub-cycling alpha is only allowed for PISO, " + "i.e. when the number of outer-correctors = 1" + << exit(FatalError); +} diff --git a/applications/solvers/multiphase/interDyMFoam/correctPhi.H b/applications/solvers/multiphase/interDyMFoam/correctPhi.H index 78a616422..3fb0cadf7 100644 --- a/applications/solvers/multiphase/interDyMFoam/correctPhi.H +++ b/applications/solvers/multiphase/interDyMFoam/correctPhi.H @@ -29,7 +29,7 @@ mesh.schemesDict().setFluxRequired(pcorr.name()); - for(int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) + while (pimple.correctNonOrthogonal()) { fvScalarMatrix pcorrEqn ( @@ -39,7 +39,7 @@ pcorrEqn.setReference(pdRefCell, pdRefValue); pcorrEqn.solve(); - if (nonOrth == nNonOrthCorr) + if (pimple.finalNonOrthogonalIter()) { phi -= pcorrEqn.flux(); } diff --git a/applications/solvers/multiphase/interDyMFoam/createControls.H b/applications/solvers/multiphase/interDyMFoam/createControls.H index b52e0509a..4c888d9e3 100644 --- a/applications/solvers/multiphase/interDyMFoam/createControls.H +++ b/applications/solvers/multiphase/interDyMFoam/createControls.H @@ -1,13 +1,11 @@ -# include "createTimeControls.H" +#include "createTimeControls.H" - bool correctPhi = true; - if (pimple.found("correctPhi")) - { - correctPhi = Switch(pimple.lookup("correctPhi")); - } +bool correctPhi +( + pimple.dict().lookupOrDefault("correctPhi", true) +); - bool checkMeshCourantNo = false; - if (pimple.found("checkMeshCourantNo")) - { - checkMeshCourantNo = Switch(pimple.lookup("checkMeshCourantNo")); - } +bool checkMeshCourantNo +( + pimple.dict().lookupOrDefault("checkMeshCourantNo", false) +); diff --git a/applications/solvers/multiphase/interDyMFoam/createFields.H b/applications/solvers/multiphase/interDyMFoam/createFields.H index 9ecfc062e..9b66f9ea7 100644 --- a/applications/solvers/multiphase/interDyMFoam/createFields.H +++ b/applications/solvers/multiphase/interDyMFoam/createFields.H @@ -123,22 +123,14 @@ label pdRefCell = 0; scalar pdRefValue = 0.0; - setRefCell - ( - pd, - mesh.solutionDict().subDict("PIMPLE"), - pdRefCell, - pdRefValue - ); + setRefCell(pd, pimple.dict(), pdRefCell, pdRefValue); + mesh.schemesDict().setFluxRequired(pd.name()); scalar pRefValue = 0.0; if (pd.needReference()) { - pRefValue = readScalar - ( - mesh.solutionDict().subDict("PIMPLE").lookup("pRefValue") - ); + pRefValue = readScalar(pimple.dict().lookup("pRefValue")); p += dimensionedScalar ( diff --git a/applications/solvers/multiphase/interDyMFoam/interDyMFoam.C b/applications/solvers/multiphase/interDyMFoam/interDyMFoam.C index 6315063a9..9bf398609 100644 --- a/applications/solvers/multiphase/interDyMFoam/interDyMFoam.C +++ b/applications/solvers/multiphase/interDyMFoam/interDyMFoam.C @@ -39,6 +39,7 @@ Description #include "interfaceProperties.H" #include "twoPhaseMixture.H" #include "turbulenceModel.H" +#include "pimpleControl.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -47,8 +48,10 @@ int main(int argc, char *argv[]) # include "setRootCase.H" # include "createTime.H" # include "createDynamicFvMesh.H" + + pimpleControl pimple(mesh); + # include "readGravitationalAcceleration.H" -# include "readPIMPLEControls.H" # include "initContinuityErrs.H" # include "createFields.H" # include "createControls.H" @@ -96,8 +99,7 @@ int main(int argc, char *argv[]) } // Pressure-velocity corrector - int oCorr = 0; - do + while (pimple.loop()) { twoPhaseProperties.correct(); @@ -106,7 +108,7 @@ int main(int argc, char *argv[]) # include "UEqn.H" // --- PISO loop - for (int corr = 0; corr < nCorr; corr++) + while (pimple.correct()) { # include "pEqn.H" } @@ -124,7 +126,7 @@ int main(int argc, char *argv[]) } turbulence->correct(); - } while (++oCorr < nOuterCorr); + } runTime.write(); diff --git a/applications/solvers/multiphase/interDyMFoam/pEqn.H b/applications/solvers/multiphase/interDyMFoam/pEqn.H index 9654dcdb5..e2dea922e 100644 --- a/applications/solvers/multiphase/interDyMFoam/pEqn.H +++ b/applications/solvers/multiphase/interDyMFoam/pEqn.H @@ -17,7 +17,7 @@ )*rAUf*mesh.magSf(); - for(int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) + while (pimple.correctNonOrthogonal()) { fvScalarMatrix pdEqn ( @@ -26,16 +26,12 @@ pdEqn.setReference(pdRefCell, pdRefValue); - if (corr == nCorr - 1 && nonOrth == nNonOrthCorr) - { - pdEqn.solve(mesh.solutionDict().solver(pd.name() + "Final")); - } - else - { - pdEqn.solve(mesh.solutionDict().solver(pd.name())); - } + pdEqn.solve + ( + mesh.solutionDict().solver(pd.select(pimple.finalInnerIter())) + ); - if (nonOrth == nNonOrthCorr) + if (pimple.finalNonOrthogonalIter()) { phi -= pdEqn.flux(); } diff --git a/applications/solvers/multiphase/interDyMFoam/readControls.H b/applications/solvers/multiphase/interDyMFoam/readControls.H index b3b4512c3..f79b9c91b 100644 --- a/applications/solvers/multiphase/interDyMFoam/readControls.H +++ b/applications/solvers/multiphase/interDyMFoam/readControls.H @@ -1,14 +1,5 @@ -# include "readTimeControls.H" -# include "readPIMPLEControls.H" +#include "readTimeControls.H" - correctPhi = true; - if (pimple.found("correctPhi")) - { - correctPhi = Switch(pimple.lookup("correctPhi")); - } +correctPhi = pimple.dict().lookupOrDefault("correctPhi", true); - checkMeshCourantNo = false; - if (pimple.found("checkMeshCourantNo")) - { - checkMeshCourantNo = Switch(pimple.lookup("checkMeshCourantNo")); - } +checkMeshCourantNo = pimple.dict().lookupOrDefault("checkMeshCourantNo", false); diff --git a/applications/solvers/multiphase/interFoam/UEqn.H b/applications/solvers/multiphase/interFoam/UEqn.H index 85972af16..5acb7a6ec 100644 --- a/applications/solvers/multiphase/interFoam/UEqn.H +++ b/applications/solvers/multiphase/interFoam/UEqn.H @@ -16,7 +16,7 @@ UEqn.relax(); - if (momentumPredictor) + if (pimple.momentumPredictor()) { solve ( diff --git a/applications/solvers/multiphase/interFoam/alphaEqnSubCycle.H b/applications/solvers/multiphase/interFoam/alphaEqnSubCycle.H index fcd2848a4..30e11b4b8 100644 --- a/applications/solvers/multiphase/interFoam/alphaEqnSubCycle.H +++ b/applications/solvers/multiphase/interFoam/alphaEqnSubCycle.H @@ -1,11 +1,11 @@ label nAlphaCorr ( - readLabel(pimple.lookup("nAlphaCorr")) + readLabel(pimple.dict().lookup("nAlphaCorr")) ); label nAlphaSubCycles ( - readLabel(pimple.lookup("nAlphaSubCycles")) + readLabel(pimple.dict().lookup("nAlphaSubCycles")) ); if (nAlphaSubCycles > 1) diff --git a/applications/solvers/multiphase/interFoam/correctPhi.H b/applications/solvers/multiphase/interFoam/correctPhi.H index a1cb1bf0a..ec9c54ab4 100644 --- a/applications/solvers/multiphase/interFoam/correctPhi.H +++ b/applications/solvers/multiphase/interFoam/correctPhi.H @@ -36,7 +36,7 @@ mesh.schemesDict().setFluxRequired(pcorr.name()); - for(int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) + while (pimple.correctNonOrthogonal()) { fvScalarMatrix pcorrEqn ( @@ -46,7 +46,7 @@ pcorrEqn.setReference(pdRefCell, pdRefValue); pcorrEqn.solve(); - if (nonOrth == nNonOrthCorr) + if (pimple.finalNonOrthogonalIter()) { phi -= pcorrEqn.flux(); } diff --git a/applications/solvers/multiphase/interFoam/createFields.H b/applications/solvers/multiphase/interFoam/createFields.H index 8012f798c..db7217a14 100644 --- a/applications/solvers/multiphase/interFoam/createFields.H +++ b/applications/solvers/multiphase/interFoam/createFields.H @@ -103,22 +103,14 @@ label pdRefCell = 0; scalar pdRefValue = 0.0; - setRefCell - ( - pd, - mesh.solutionDict().subDict("PIMPLE"), - pdRefCell, - pdRefValue - ); + setRefCell(pd, pimple.dict(), pdRefCell, pdRefValue); + mesh.schemesDict().setFluxRequired(pd.name()); scalar pRefValue = 0.0; if (pd.needReference()) { - pRefValue = readScalar - ( - mesh.solutionDict().subDict("PIMPLE").lookup("pRefValue") - ); + pRefValue = readScalar(pimple.dict().lookup("pRefValue")); p += dimensionedScalar ( diff --git a/applications/solvers/multiphase/interFoam/interFoam.C b/applications/solvers/multiphase/interFoam/interFoam.C index c5bdc49ea..b0b136c23 100644 --- a/applications/solvers/multiphase/interFoam/interFoam.C +++ b/applications/solvers/multiphase/interFoam/interFoam.C @@ -43,6 +43,7 @@ Description #include "interfaceProperties.H" #include "twoPhaseMixture.H" #include "turbulenceModel.H" +#include "pimpleControl.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -51,8 +52,10 @@ int main(int argc, char *argv[]) # include "setRootCase.H" # include "createTime.H" # include "createMesh.H" + + pimpleControl pimple(mesh); + # include "readGravitationalAcceleration.H" -# include "readPIMPLEControls.H" # include "initContinuityErrs.H" # include "createFields.H" # include "createTimeControls.H" @@ -66,7 +69,6 @@ int main(int argc, char *argv[]) while (runTime.run()) { -# include "readPIMPLEControls.H" # include "readTimeControls.H" # include "CourantNo.H" # include "setDeltaT.H" @@ -76,8 +78,7 @@ int main(int argc, char *argv[]) Info<< "Time = " << runTime.timeName() << nl << endl; // Pressure-velocity corrector - int oCorr = 0; - do + while (pimple.loop()) { twoPhaseProperties.correct(); @@ -86,7 +87,7 @@ int main(int argc, char *argv[]) # include "UEqn.H" // --- PISO loop - for (int corr = 0; corr < nCorr; corr++) + while (pimple.correct()) { # include "pEqn.H" } @@ -106,7 +107,7 @@ int main(int argc, char *argv[]) } turbulence->correct(); - } while (++oCorr < nOuterCorr); + } runTime.write(); diff --git a/applications/solvers/multiphase/interFoam/pEqn.H b/applications/solvers/multiphase/interFoam/pEqn.H index d2389bc16..ed5f16207 100644 --- a/applications/solvers/multiphase/interFoam/pEqn.H +++ b/applications/solvers/multiphase/interFoam/pEqn.H @@ -20,7 +20,7 @@ )*rUAf*mesh.magSf(); - for(int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) + while (pimple.correctNonOrthogonal()) { fvScalarMatrix pdEqn ( @@ -29,16 +29,12 @@ pdEqn.setReference(pdRefCell, pdRefValue); - if (corr == nCorr - 1 && nonOrth == nNonOrthCorr) - { - pdEqn.solve(mesh.solutionDict().solver(pd.name() + "Final")); - } - else - { - pdEqn.solve(mesh.solutionDict().solver(pd.name())); - } + pdEqn.solve + ( + mesh.solutionDict().solver(pd.select(pimple.finalInnerIter())) + ); - if (nonOrth == nNonOrthCorr) + if (pimple.finalNonOrthogonalIter()) { phi -= pdEqn.flux(); } diff --git a/applications/solvers/multiphase/interMixingFoam/alphaEqnsSubCycle.H b/applications/solvers/multiphase/interMixingFoam/alphaEqnsSubCycle.H index 765087a18..dfcd5299c 100644 --- a/applications/solvers/multiphase/interMixingFoam/alphaEqnsSubCycle.H +++ b/applications/solvers/multiphase/interMixingFoam/alphaEqnsSubCycle.H @@ -1,11 +1,11 @@ label nAlphaCorr ( - readLabel(piso.lookup("nAlphaCorr")) + readLabel(pimple.dict().lookup("nAlphaCorr")) ); label nAlphaSubCycles ( - readLabel(piso.lookup("nAlphaSubCycles")) + readLabel(pimple.dict().lookup("nAlphaSubCycles")) ); if (nAlphaSubCycles > 1) diff --git a/applications/solvers/multiphase/interMixingFoam/createFields.H b/applications/solvers/multiphase/interMixingFoam/createFields.H index 6fdd34175..5bceabf74 100644 --- a/applications/solvers/multiphase/interMixingFoam/createFields.H +++ b/applications/solvers/multiphase/interMixingFoam/createFields.H @@ -135,16 +135,14 @@ label pdRefCell = 0; scalar pdRefValue = 0.0; - setRefCell(pd, mesh.solutionDict().subDict("PISO"), pdRefCell, pdRefValue); + setRefCell(pd, pimple.dict(), pdRefCell, pdRefValue); + mesh.schemesDict().setFluxRequired(pd.name()); scalar pRefValue = 0.0; if (pd.needReference()) { - pRefValue = readScalar - ( - mesh.solutionDict().subDict("PISO").lookup("pRefValue") - ); + pRefValue = readScalar(pimple.dict().lookup("pRefValue")); p += dimensionedScalar ( @@ -163,3 +161,5 @@ ( incompressible::turbulenceModel::New(U, phi, threePhaseProperties) ); + + mesh.schemesDict().setFluxRequired(alpha2.name()); diff --git a/applications/solvers/multiphase/interMixingFoam/interMixingFoam.C b/applications/solvers/multiphase/interMixingFoam/interMixingFoam.C index 44de8ab5e..fb844be70 100644 --- a/applications/solvers/multiphase/interMixingFoam/interMixingFoam.C +++ b/applications/solvers/multiphase/interMixingFoam/interMixingFoam.C @@ -36,6 +36,7 @@ Description #include "threePhaseMixture.H" #include "threePhaseInterfaceProperties.H" #include "turbulenceModel.H" +#include "pimpleControl.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -44,8 +45,10 @@ int main(int argc, char *argv[]) # include "setRootCase.H" # include "createTime.H" # include "createMesh.H" + + pimpleControl pimple(mesh); + # include "readGravitationalAcceleration.H" -# include "readPISOControls.H" # include "initContinuityErrs.H" # include "createFields.H" # include "createTimeControls.H" @@ -59,7 +62,6 @@ int main(int argc, char *argv[]) while (runTime.run()) { -# include "readPISOControls.H" # include "readTimeControls.H" # include "CourantNo.H" # include "setDeltaT.H" @@ -76,7 +78,7 @@ int main(int argc, char *argv[]) # include "UEqn.H" // --- PISO loop - for (int corr = 0; corr < nCorr; corr++) + while (pimple.correct()) { # include "pEqn.H" } diff --git a/applications/solvers/multiphase/interMixingFoam/threePhaseInterfaceProperties/threePhaseInterfaceProperties.C b/applications/solvers/multiphase/interMixingFoam/threePhaseInterfaceProperties/threePhaseInterfaceProperties.C index bf8899fee..a14217572 100644 --- a/applications/solvers/multiphase/interMixingFoam/threePhaseInterfaceProperties/threePhaseInterfaceProperties.C +++ b/applications/solvers/multiphase/interMixingFoam/threePhaseInterfaceProperties/threePhaseInterfaceProperties.C @@ -170,7 +170,7 @@ Foam::threePhaseInterfaceProperties::threePhaseInterfaceProperties ( readScalar ( - mixture.U().mesh().solutionDict().subDict("PISO").lookup("cAlpha") + mixture.U().mesh().solutionDict().subDict("PIMPLE").lookup("cAlpha") ) ), sigma12_(mixture.lookup("sigma12")), diff --git a/applications/solvers/multiphase/interPhaseChangeFoam/UEqn.H b/applications/solvers/multiphase/interPhaseChangeFoam/UEqn.H index c59137c7b..182fa3aad 100644 --- a/applications/solvers/multiphase/interPhaseChangeFoam/UEqn.H +++ b/applications/solvers/multiphase/interPhaseChangeFoam/UEqn.H @@ -17,7 +17,7 @@ UEqn.relax(); - if (momentumPredictor) + if (pimple.momentumPredictor()) { solve ( diff --git a/applications/solvers/multiphase/interPhaseChangeFoam/alphaEqnSubCycle.H b/applications/solvers/multiphase/interPhaseChangeFoam/alphaEqnSubCycle.H index dd1d82803..164941f97 100644 --- a/applications/solvers/multiphase/interPhaseChangeFoam/alphaEqnSubCycle.H +++ b/applications/solvers/multiphase/interPhaseChangeFoam/alphaEqnSubCycle.H @@ -13,12 +13,12 @@ surfaceScalarField rhoPhi { label nAlphaCorr ( - readLabel(piso.lookup("nAlphaCorr")) + readLabel(pimple.dict().lookup("nAlphaCorr")) ); label nAlphaSubCycles ( - readLabel(piso.lookup("nAlphaSubCycles")) + readLabel(pimple.dict().lookup("nAlphaSubCycles")) ); surfaceScalarField phic = mag(phi/mesh.magSf()); @@ -44,7 +44,7 @@ surfaceScalarField rhoPhi # include "alphaEqn.H" } - if (nOuterCorr == 1) + if (pimple.nCorrPIMPLE() == 1) { interface.correct(); } diff --git a/applications/solvers/multiphase/interPhaseChangeFoam/correctPhi.H b/applications/solvers/multiphase/interPhaseChangeFoam/correctPhi.H index a1cb1bf0a..ec9c54ab4 100644 --- a/applications/solvers/multiphase/interPhaseChangeFoam/correctPhi.H +++ b/applications/solvers/multiphase/interPhaseChangeFoam/correctPhi.H @@ -36,7 +36,7 @@ mesh.schemesDict().setFluxRequired(pcorr.name()); - for(int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) + while (pimple.correctNonOrthogonal()) { fvScalarMatrix pcorrEqn ( @@ -46,7 +46,7 @@ pcorrEqn.setReference(pdRefCell, pdRefValue); pcorrEqn.solve(); - if (nonOrth == nNonOrthCorr) + if (pimple.finalNonOrthogonalIter()) { phi -= pcorrEqn.flux(); } diff --git a/applications/solvers/multiphase/interPhaseChangeFoam/createFields.H b/applications/solvers/multiphase/interPhaseChangeFoam/createFields.H index 50cc07e7a..011e879f7 100644 --- a/applications/solvers/multiphase/interPhaseChangeFoam/createFields.H +++ b/applications/solvers/multiphase/interPhaseChangeFoam/createFields.H @@ -103,16 +103,14 @@ label pdRefCell = 0; scalar pdRefValue = 0.0; - setRefCell(pd, mesh.solutionDict().subDict("PISO"), pdRefCell, pdRefValue); + setRefCell(pd, pimple.dict(), pdRefCell, pdRefValue); + mesh.schemesDict().setFluxRequired(pd.name()); scalar pRefValue = 0.0; if (pd.needReference()) { - pRefValue = readScalar - ( - mesh.solutionDict().subDict("PISO").lookup("pRefValue") - ); + pRefValue = readScalar(pimple.dict().lookup("pRefValue")); p += dimensionedScalar ( diff --git a/applications/solvers/multiphase/interPhaseChangeFoam/interPhaseChangeFoam.C b/applications/solvers/multiphase/interPhaseChangeFoam/interPhaseChangeFoam.C index de7b70221..e4a3fd563 100644 --- a/applications/solvers/multiphase/interPhaseChangeFoam/interPhaseChangeFoam.C +++ b/applications/solvers/multiphase/interPhaseChangeFoam/interPhaseChangeFoam.C @@ -46,6 +46,7 @@ Description #include "interfaceProperties.H" #include "phaseChangeTwoPhaseMixture.H" #include "turbulenceModel.H" +#include "pimpleControl.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -54,8 +55,10 @@ int main(int argc, char *argv[]) # include "setRootCase.H" # include "createTime.H" # include "createMesh.H" + + pimpleControl pimple(mesh); + # include "readGravitationalAcceleration.H" -# include "readPISOControls.H" # include "initContinuityErrs.H" # include "createFields.H" # include "createTimeControls.H" @@ -69,7 +72,6 @@ int main(int argc, char *argv[]) while (runTime.run()) { -# include "readPISOControls.H" # include "readTimeControls.H" # include "CourantNo.H" # include "setDeltaT.H" @@ -83,12 +85,12 @@ int main(int argc, char *argv[]) turbulence->correct(); // --- Outer-corrector loop - for (int oCorr=0; oCorrcorrect(); - } while (++oCorr < nOuterCorr); + } runTime.write(); diff --git a/applications/solvers/multiphase/settlingFoam/UEqn.H b/applications/solvers/multiphase/settlingFoam/UEqn.H index 8dba5041c..6bec880d1 100644 --- a/applications/solvers/multiphase/settlingFoam/UEqn.H +++ b/applications/solvers/multiphase/settlingFoam/UEqn.H @@ -12,7 +12,7 @@ fvVectorMatrix UEqn - fvm::laplacian(mu, U, "laplacian(muEff,U)") ); -if (momentumPredictor) +if (pimple.momentumPredictor()) { solve ( diff --git a/applications/solvers/multiphase/settlingFoam/compressibleContinuityErrs.H b/applications/solvers/multiphase/settlingFoam/compressibleContinuityErrs.H index 428465ddd..0593cfe8d 100644 --- a/applications/solvers/multiphase/settlingFoam/compressibleContinuityErrs.H +++ b/applications/solvers/multiphase/settlingFoam/compressibleContinuityErrs.H @@ -1,4 +1,4 @@ - scalar sumLocalContErr = + sumLocalContErr = runTime.deltaT().value()* mag ( @@ -6,7 +6,7 @@ + fvc::div(phi) )().weightedAverage(rho*mesh.V()).value(); - scalar globalContErr = + globalContErr = runTime.deltaT().value()* ( fvc::ddt(rho) diff --git a/applications/solvers/multiphase/settlingFoam/createFields.H b/applications/solvers/multiphase/settlingFoam/createFields.H index 400f89c43..57f62457b 100644 --- a/applications/solvers/multiphase/settlingFoam/createFields.H +++ b/applications/solvers/multiphase/settlingFoam/createFields.H @@ -133,8 +133,8 @@ label pRefCell = 0; scalar pRefValue = 0.0; - setRefCell(p, mesh.solutionDict().subDict("PISO"), pRefCell, pRefValue); - + setRefCell(p, pimple.dict(), pRefCell, pRefValue); + mesh.schemesDict().setFluxRequired(p.name()); Info<< "Calculating field mul\n" << endl; volScalarField mul diff --git a/applications/solvers/multiphase/settlingFoam/pEqn.H b/applications/solvers/multiphase/settlingFoam/pEqn.H index 65b954c6d..5c1ee980b 100644 --- a/applications/solvers/multiphase/settlingFoam/pEqn.H +++ b/applications/solvers/multiphase/settlingFoam/pEqn.H @@ -17,7 +17,7 @@ phi = surfaceScalarField phiU("phiU", phi); phi -= ghf*fvc::snGrad(rho)*rUAf*mesh.magSf(); -for(int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) +while (pimple.correctNonOrthogonal()) { fvScalarMatrix pEqn ( @@ -27,7 +27,7 @@ for(int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) pEqn.setReference(pRefCell, pRefValue); pEqn.solve(); - if (nonOrth == nNonOrthCorr) + if (pimple.finalNonOrthogonalIter()) { phi -= pEqn.flux(); } diff --git a/applications/solvers/multiphase/settlingFoam/settlingFoam.C b/applications/solvers/multiphase/settlingFoam/settlingFoam.C index f75769fee..7b6b153cb 100644 --- a/applications/solvers/multiphase/settlingFoam/settlingFoam.C +++ b/applications/solvers/multiphase/settlingFoam/settlingFoam.C @@ -37,6 +37,7 @@ Description #include "Switch.H" #include "plasticViscosity.H" #include "yieldStress.H" +#include "pimpleControl.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -46,6 +47,9 @@ int main(int argc, char *argv[]) # include "createTime.H" # include "createMesh.H" + + pimpleControl pimple(mesh); + # include "readGravitationalAcceleration.H" # include "createFields.H" # include "initContinuityErrs.H" @@ -59,12 +63,11 @@ int main(int argc, char *argv[]) { Info<< "Time = " << runTime.timeName() << nl << endl; -# include "readPISOControls.H" # include "compressibleCourantNo.H" # include "rhoEqn.H" - for (int oCorr=0; oCorr outerCorrTolerance) - && (outerCorr < nOuterCorr) + && (outerCorr < piso.nCorrPIMPLE()) ); Vs += DV; diff --git a/applications/solvers/solidMechanics/icoFsiElasticNonLinULSolidFoam/solveFluid.H b/applications/solvers/solidMechanics/icoFsiElasticNonLinULSolidFoam/solveFluid.H index 0364805a5..dc237463e 100644 --- a/applications/solvers/solidMechanics/icoFsiElasticNonLinULSolidFoam/solveFluid.H +++ b/applications/solvers/solidMechanics/icoFsiElasticNonLinULSolidFoam/solveFluid.H @@ -19,14 +19,14 @@ // --- PISO loop volScalarField rUA = 1.0/UEqn.A(); - for (int corr=0; corr(pNeedRef, andOp()); // Find reference cell if (pNeedRef) { - point refPointi(mesh.solutionDict().subDict("PISO").lookup("pRefPoint")); + point refPointi(mesh.solutionDict().subDict("PIMPLE").lookup("pRefPoint")); label refCelli = mesh.findCell(refPointi); label hasRef = (refCelli >= 0 ? 1 : 0); label sumHasRef = returnReduce