From b99c3261a79636dee5aaf2d6f979a29dc8d5c662 Mon Sep 17 00:00:00 2001 From: Vanja Skuric Date: Sat, 7 May 2016 10:31:37 +0200 Subject: [PATCH] Backported interIbFoam, porousSimpleIbFoam and simpleIbFoam (setFluxRequired, solutionControls) to vanilla 3.0.1 format --- .../immersedBoundary/interIbFoam/UEqn.H | 2 +- .../immersedBoundary/interIbFoam/correctPhi.H | 4 ++-- .../interIbFoam/createFields.H | 2 ++ .../interIbFoam/interIbFoam.C | 13 ++++++------ .../immersedBoundary/interIbFoam/limitU.H | 3 ++- .../immersedBoundary/interIbFoam/pEqn.H | 21 ++++++++----------- .../porousSimpleIbFoam/UEqn.H | 7 +------ .../porousSimpleIbFoam/convergenceCheck.H | 9 -------- .../porousSimpleIbFoam/createFields.H | 2 +- .../porousSimpleIbFoam/initConvergenceCheck.H | 7 ------- .../porousSimpleIbFoam/pEqn.H | 15 +++---------- .../porousSimpleIbFoam/porousSimpleIbFoam.C | 9 ++++---- .../immersedBoundary/simpleIbFoam/UEqn.H | 7 +------ .../simpleIbFoam/convergenceCheck.H | 9 -------- .../simpleIbFoam/createFields.H | 2 +- .../simpleIbFoam/initConvergenceCheck.H | 7 ------- .../immersedBoundary/simpleIbFoam/pEqn.H | 15 +++---------- .../simpleIbFoam/simpleIbFoam.C | 9 ++++---- 18 files changed, 41 insertions(+), 102 deletions(-) delete mode 100644 applications/solvers/immersedBoundary/porousSimpleIbFoam/convergenceCheck.H delete mode 100644 applications/solvers/immersedBoundary/porousSimpleIbFoam/initConvergenceCheck.H delete mode 100644 applications/solvers/immersedBoundary/simpleIbFoam/convergenceCheck.H delete mode 100644 applications/solvers/immersedBoundary/simpleIbFoam/initConvergenceCheck.H diff --git a/applications/solvers/immersedBoundary/interIbFoam/UEqn.H b/applications/solvers/immersedBoundary/interIbFoam/UEqn.H index 528e0aaaf..0b50eec2c 100644 --- a/applications/solvers/immersedBoundary/interIbFoam/UEqn.H +++ b/applications/solvers/immersedBoundary/interIbFoam/UEqn.H @@ -16,7 +16,7 @@ UEqn.relax(); - if (momentumPredictor) + if (pimple.momentumPredictor()) { solve ( diff --git a/applications/solvers/immersedBoundary/interIbFoam/correctPhi.H b/applications/solvers/immersedBoundary/interIbFoam/correctPhi.H index bce66493e..2f5bd5e2f 100644 --- a/applications/solvers/immersedBoundary/interIbFoam/correctPhi.H +++ b/applications/solvers/immersedBoundary/interIbFoam/correctPhi.H @@ -38,7 +38,7 @@ mesh.schemesDict().setFluxRequired(pcorr.name()); - for(int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) + while(pimple.correctNonOrthogonal()) { fvScalarMatrix pcorrEqn ( @@ -48,7 +48,7 @@ pcorrEqn.setReference(pdRefCell, pdRefValue); pcorrEqn.solve(); - if (nonOrth == nNonOrthCorr) + if (pimple.finalNonOrthogonalIter()) { phi -= pcorrEqn.flux(); } diff --git a/applications/solvers/immersedBoundary/interIbFoam/createFields.H b/applications/solvers/immersedBoundary/interIbFoam/createFields.H index 8012f798c..0fcdf751b 100644 --- a/applications/solvers/immersedBoundary/interIbFoam/createFields.H +++ b/applications/solvers/immersedBoundary/interIbFoam/createFields.H @@ -128,6 +128,8 @@ ); } + mesh.schemesDict().setFluxRequired(pd.name()); + // Construct interface from alpha1 distribution interfaceProperties interface(alpha1, U, twoPhaseProperties); diff --git a/applications/solvers/immersedBoundary/interIbFoam/interIbFoam.C b/applications/solvers/immersedBoundary/interIbFoam/interIbFoam.C index 5ea2a8744..28db5f069 100644 --- a/applications/solvers/immersedBoundary/interIbFoam/interIbFoam.C +++ b/applications/solvers/immersedBoundary/interIbFoam/interIbFoam.C @@ -45,6 +45,7 @@ Author #include "interfaceProperties.H" #include "twoPhaseMixture.H" #include "turbulenceModel.H" +#include "pimpleControl.H" #include "immersedBoundaryFvPatch.H" #include "immersedBoundaryAdjustPhi.H" @@ -56,8 +57,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 "createIbMasks.H" @@ -72,7 +75,6 @@ int main(int argc, char *argv[]) while (runTime.run()) { -# include "readPIMPLEControls.H" # include "readTimeControls.H" # include "immersedBoundaryCourantNo.H" # include "setDeltaT.H" @@ -82,8 +84,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(); @@ -92,7 +93,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" } @@ -117,7 +118,7 @@ int main(int argc, char *argv[]) } turbulence->correct(); - } while (++oCorr < nOuterCorr); + } runTime.write(); diff --git a/applications/solvers/immersedBoundary/interIbFoam/limitU.H b/applications/solvers/immersedBoundary/interIbFoam/limitU.H index 322e59b7c..0c59414f8 100644 --- a/applications/solvers/immersedBoundary/interIbFoam/limitU.H +++ b/applications/solvers/immersedBoundary/interIbFoam/limitU.H @@ -1,5 +1,6 @@ { - scalar limitMagU = readScalar(pimple.lookup("limitMagU")); + scalar limitMagU = + readScalar(mesh.solutionDict().subDict("PIMPLE").lookup("limitMagU")); volScalarField magU(mag(U)); diff --git a/applications/solvers/immersedBoundary/interIbFoam/pEqn.H b/applications/solvers/immersedBoundary/interIbFoam/pEqn.H index 42fa96e0e..a765455fc 100644 --- a/applications/solvers/immersedBoundary/interIbFoam/pEqn.H +++ b/applications/solvers/immersedBoundary/interIbFoam/pEqn.H @@ -1,5 +1,5 @@ { - if (nOuterCorr != 1) + if (!pimple.firstIter()) { pd.storePrevIter(); } @@ -29,7 +29,7 @@ )*rUAf*mesh.magSf(); - for(int nonOrth = 0; nonOrth <= nNonOrthCorr; nonOrth++) + while (pimple.correctNonOrthogonal()) { fvScalarMatrix pdEqn ( @@ -38,23 +38,20 @@ 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(); } } // Explicitly relax pressure except for last corrector - if (oCorr != nOuterCorr - 1) + if (!pimple.finalIter()) { pd.relax(); } diff --git a/applications/solvers/immersedBoundary/porousSimpleIbFoam/UEqn.H b/applications/solvers/immersedBoundary/porousSimpleIbFoam/UEqn.H index fd96d5362..2117cd7e5 100644 --- a/applications/solvers/immersedBoundary/porousSimpleIbFoam/UEqn.H +++ b/applications/solvers/immersedBoundary/porousSimpleIbFoam/UEqn.H @@ -9,9 +9,4 @@ pZones.addResistance(UEqn()); - eqnResidual = solve - ( - UEqn() == -fvc::grad(p) - ).initialResidual(); - - maxResidual = max(eqnResidual, maxResidual); + solve(UEqn() == -fvc::grad(p)); diff --git a/applications/solvers/immersedBoundary/porousSimpleIbFoam/convergenceCheck.H b/applications/solvers/immersedBoundary/porousSimpleIbFoam/convergenceCheck.H deleted file mode 100644 index 895806319..000000000 --- a/applications/solvers/immersedBoundary/porousSimpleIbFoam/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/immersedBoundary/porousSimpleIbFoam/createFields.H b/applications/solvers/immersedBoundary/porousSimpleIbFoam/createFields.H index 8c7e220e0..6dc7d36c8 100644 --- a/applications/solvers/immersedBoundary/porousSimpleIbFoam/createFields.H +++ b/applications/solvers/immersedBoundary/porousSimpleIbFoam/createFields.H @@ -32,7 +32,7 @@ label pRefCell = 0; scalar pRefValue = 0.0; setRefCell(p, mesh.solutionDict().subDict("SIMPLE"), pRefCell, pRefValue); - + mesh.schemesDict().setFluxRequired(p.name()); singlePhaseTransportModel laminarTransport(U, phi); diff --git a/applications/solvers/immersedBoundary/porousSimpleIbFoam/initConvergenceCheck.H b/applications/solvers/immersedBoundary/porousSimpleIbFoam/initConvergenceCheck.H deleted file mode 100644 index b56197f22..000000000 --- a/applications/solvers/immersedBoundary/porousSimpleIbFoam/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/immersedBoundary/porousSimpleIbFoam/pEqn.H b/applications/solvers/immersedBoundary/porousSimpleIbFoam/pEqn.H index b49a24366..dc9f26a38 100644 --- a/applications/solvers/immersedBoundary/porousSimpleIbFoam/pEqn.H +++ b/applications/solvers/immersedBoundary/porousSimpleIbFoam/pEqn.H @@ -14,7 +14,7 @@ adjustPhi(phi, U, p); // Non-orthogonal pressure corrector loop - 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()) { phi -= pEqn.flux(); } diff --git a/applications/solvers/immersedBoundary/porousSimpleIbFoam/porousSimpleIbFoam.C b/applications/solvers/immersedBoundary/porousSimpleIbFoam/porousSimpleIbFoam.C index 289922e9f..6c873025b 100644 --- a/applications/solvers/immersedBoundary/porousSimpleIbFoam/porousSimpleIbFoam.C +++ b/applications/solvers/immersedBoundary/porousSimpleIbFoam/porousSimpleIbFoam.C @@ -37,6 +37,7 @@ Author #include "singlePhaseTransportModel.H" #include "RASModel.H" #include "porousZones.H" +#include "simpleControl.H" #include "immersedBoundaryFvPatch.H" #include "immersedBoundaryAdjustPhi.H" @@ -48,6 +49,9 @@ int main(int argc, char *argv[]) # include "setRootCase.H" # include "createTime.H" # include "createMesh.H" + + simpleControl simple(mesh); + # include "createIbMasks.H" # include "createFields.H" # include "initContinuityErrs.H" @@ -60,9 +64,6 @@ int main(int argc, char *argv[]) { Info<< "Time = " << runTime.timeName() << nl << endl; -# include "readSIMPLEControls.H" -# include "initConvergenceCheck.H" - p.storePrevIter(); // Pressure-velocity SIMPLE corrector @@ -78,8 +79,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/immersedBoundary/simpleIbFoam/UEqn.H b/applications/solvers/immersedBoundary/simpleIbFoam/UEqn.H index e41c4422a..5e1c5816b 100644 --- a/applications/solvers/immersedBoundary/simpleIbFoam/UEqn.H +++ b/applications/solvers/immersedBoundary/simpleIbFoam/UEqn.H @@ -7,9 +7,4 @@ UEqn().relax(); - eqnResidual = solve - ( - UEqn() == -fvc::grad(p) - ).initialResidual(); - - maxResidual = max(eqnResidual, maxResidual); + solve(UEqn() == -fvc::grad(p)); diff --git a/applications/solvers/immersedBoundary/simpleIbFoam/convergenceCheck.H b/applications/solvers/immersedBoundary/simpleIbFoam/convergenceCheck.H deleted file mode 100644 index 895806319..000000000 --- a/applications/solvers/immersedBoundary/simpleIbFoam/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/immersedBoundary/simpleIbFoam/createFields.H b/applications/solvers/immersedBoundary/simpleIbFoam/createFields.H index b957c7265..7527c084a 100644 --- a/applications/solvers/immersedBoundary/simpleIbFoam/createFields.H +++ b/applications/solvers/immersedBoundary/simpleIbFoam/createFields.H @@ -32,7 +32,7 @@ label pRefCell = 0; scalar pRefValue = 0.0; setRefCell(p, mesh.solutionDict().subDict("SIMPLE"), pRefCell, pRefValue); - + mesh.schemesDict().setFluxRequired(p.name()); singlePhaseTransportModel laminarTransport(U, phi); diff --git a/applications/solvers/immersedBoundary/simpleIbFoam/initConvergenceCheck.H b/applications/solvers/immersedBoundary/simpleIbFoam/initConvergenceCheck.H deleted file mode 100644 index b56197f22..000000000 --- a/applications/solvers/immersedBoundary/simpleIbFoam/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/immersedBoundary/simpleIbFoam/pEqn.H b/applications/solvers/immersedBoundary/simpleIbFoam/pEqn.H index 6a54f2e8d..dc9f26a38 100644 --- a/applications/solvers/immersedBoundary/simpleIbFoam/pEqn.H +++ b/applications/solvers/immersedBoundary/simpleIbFoam/pEqn.H @@ -14,7 +14,7 @@ adjustPhi(phi, U, p); // Non-orthogonal pressure corrector loop - 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()) { phi -= pEqn.flux(); } diff --git a/applications/solvers/immersedBoundary/simpleIbFoam/simpleIbFoam.C b/applications/solvers/immersedBoundary/simpleIbFoam/simpleIbFoam.C index 2b6bcbcd1..69c09be88 100644 --- a/applications/solvers/immersedBoundary/simpleIbFoam/simpleIbFoam.C +++ b/applications/solvers/immersedBoundary/simpleIbFoam/simpleIbFoam.C @@ -36,6 +36,7 @@ Author #include "fvCFD.H" #include "singlePhaseTransportModel.H" #include "RASModel.H" +#include "simpleControl.H" #include "immersedBoundaryFvPatch.H" #include "immersedBoundaryAdjustPhi.H" @@ -47,6 +48,9 @@ int main(int argc, char *argv[]) # include "setRootCase.H" # include "createTime.H" # include "createMesh.H" + + simpleControl simple(mesh); + # include "createIbMasks.H" # include "createFields.H" # include "initContinuityErrs.H" @@ -59,9 +63,6 @@ int main(int argc, char *argv[]) { Info<< "Time = " << runTime.timeName() << nl << endl; -# include "readSIMPLEControls.H" -# include "initConvergenceCheck.H" - p.storePrevIter(); // Pressure-velocity SIMPLE corrector @@ -77,8 +78,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;