From d230fff954ba049c2b57e74383b208df58556a5d Mon Sep 17 00:00:00 2001 From: Vanja Skuric Date: Sat, 7 May 2016 08:38:01 +0200 Subject: [PATCH] Backported MRFSimpleFoam and porousSimpleFoam (setFluxRequired, solutionControl) --- .../incompressible/MRFSimpleFoam/MRFSimpleFoam.C | 10 ++++++---- .../incompressible/MRFSimpleFoam/createFields.H | 2 +- .../incompressible/porousSimpleFoam/UEqn.H | 7 +------ .../porousSimpleFoam/createFields.H | 2 +- .../incompressible/porousSimpleFoam/pEqn.H | 16 ++++------------ .../porousSimpleFoam/porousSimpleFoam.C | 9 ++++----- 6 files changed, 17 insertions(+), 29 deletions(-) diff --git a/applications/solvers/incompressible/MRFSimpleFoam/MRFSimpleFoam.C b/applications/solvers/incompressible/MRFSimpleFoam/MRFSimpleFoam.C index 00ecd40a5..7bb094647 100644 --- a/applications/solvers/incompressible/MRFSimpleFoam/MRFSimpleFoam.C +++ b/applications/solvers/incompressible/MRFSimpleFoam/MRFSimpleFoam.C @@ -34,6 +34,7 @@ Description #include "incompressible/singlePhaseTransportModel/singlePhaseTransportModel.H" #include "incompressible/RAS/RASModel/RASModel.H" #include "MRFZones.H" +#include "simpleControl.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -44,6 +45,9 @@ int main(int argc, char *argv[]) # include "createTime.H" # include "createMesh.H" + + simpleControl simple(mesh); + # include "createFields.H" # include "initContinuityErrs.H" @@ -55,8 +59,6 @@ int main(int argc, char *argv[]) { Info<< "Time = " << runTime.timeName() << nl << endl; -# include "readSIMPLEControls.H" - p.storePrevIter(); // Pressure-velocity SIMPLE corrector @@ -84,7 +86,7 @@ int main(int argc, char *argv[]) adjustPhi(phi, U, p); // Non-orthogonal pressure corrector loop - for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) + while (simple.correctNonOrthogonal()) { fvScalarMatrix pEqn ( @@ -94,7 +96,7 @@ int main(int argc, char *argv[]) pEqn.setReference(pRefCell, pRefValue); pEqn.solve(); - if (nonOrth == nNonOrthCorr) + if (simple.finalNonOrthogonalIter()) { phi -= pEqn.flux(); } diff --git a/applications/solvers/incompressible/MRFSimpleFoam/createFields.H b/applications/solvers/incompressible/MRFSimpleFoam/createFields.H index 43242a6e3..3a08cae15 100644 --- a/applications/solvers/incompressible/MRFSimpleFoam/createFields.H +++ b/applications/solvers/incompressible/MRFSimpleFoam/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/incompressible/porousSimpleFoam/UEqn.H b/applications/solvers/incompressible/porousSimpleFoam/UEqn.H index 688120809..9cbcd6129 100644 --- a/applications/solvers/incompressible/porousSimpleFoam/UEqn.H +++ b/applications/solvers/incompressible/porousSimpleFoam/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/incompressible/porousSimpleFoam/createFields.H b/applications/solvers/incompressible/porousSimpleFoam/createFields.H index 04d57d057..fa4f98151 100644 --- a/applications/solvers/incompressible/porousSimpleFoam/createFields.H +++ b/applications/solvers/incompressible/porousSimpleFoam/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/incompressible/porousSimpleFoam/pEqn.H b/applications/solvers/incompressible/porousSimpleFoam/pEqn.H index e6797cd86..fbe81daee 100644 --- a/applications/solvers/incompressible/porousSimpleFoam/pEqn.H +++ b/applications/solvers/incompressible/porousSimpleFoam/pEqn.H @@ -11,7 +11,7 @@ UEqn.clear(); phi = fvc::interpolate(U) & mesh.Sf(); adjustPhi(phi, U, p); -for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) +while (simple.correctNonOrthogonal()) { tmp tpEqn; @@ -25,18 +25,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/incompressible/porousSimpleFoam/porousSimpleFoam.C b/applications/solvers/incompressible/porousSimpleFoam/porousSimpleFoam.C index 310c80c01..c54de64ff 100644 --- a/applications/solvers/incompressible/porousSimpleFoam/porousSimpleFoam.C +++ b/applications/solvers/incompressible/porousSimpleFoam/porousSimpleFoam.C @@ -34,6 +34,7 @@ Description #include "singlePhaseTransportModel.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" @@ -53,9 +57,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 @@ -71,8 +72,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;