Commit 655ef104 authored by Mark Olesen's avatar Mark Olesen
Browse files

convergence check for terminating SIMPLE steady-state solvers

  - rhoPorousSimpleFoam
  - rhoSimpleFoam
  - buoyantSimpleFoam
  - buoyantSimpleRadiationFoam
  - simpleFoam
parent 32d46dc3
......@@ -35,7 +35,12 @@
{
pZones.addResistance(UEqn());
solve(UEqn() == -fvc::grad(p));
eqnResidual = solve
(
UEqn() == -fvc::grad(p)
). initialResidual();
maxResidual = max(eqnResidual, maxResidual);
trAU = 1.0/UEqn().A();
trAU().rename("rAU");
......
// check convergence
if (maxResidual < convergenceCriterion)
{
Info<< "reached convergence criterion: " << convergenceCriterion << endl;
runTime.writeAndEnd();
Info<< "latestTime = " << runTime.timeName() << endl;
}
......@@ -11,7 +11,8 @@
hEqn.relax();
hEqn.solve();
eqnResidual = hEqn.solve().initialResidual();
maxResidual = max(eqnResidual, maxResidual);
thermo->correct();
}
// initialize values for convergence checks
scalar eqnResidual = 1, maxResidual = 0;
scalar convergenceCriterion = 0;
simple.readIfPresent("convergence", convergenceCriterion);
......@@ -26,7 +26,16 @@ for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
}
tpEqn().setReference(pRefCell, pRefValue);
tpEqn().solve();
// retain the residual from the first iteration
if (nonOrth == 0)
{
eqnResidual = tpEqn().solve().initialResidual();
maxResidual = max(eqnResidual, maxResidual);
}
else
{
tpEqn().solve();
}
if (nonOrth == nNonOrthCorr)
{
......
......@@ -56,6 +56,7 @@ int main(int argc, char *argv[])
Info<< "Time = " << runTime.timeName() << nl << endl;
# include "readSIMPLEControls.H"
# include "initConvergenceCheck.H"
p.storePrevIter();
rho.storePrevIter();
......@@ -70,10 +71,11 @@ int main(int argc, char *argv[])
turbulence->correct();
runTime.write();
Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
<< " ClockTime = " << runTime.elapsedClockTime() << " s"
<< nl << endl;
# include "convergenceCheck.H"
}
Info<< "End\n" << endl;
......
......@@ -9,4 +9,9 @@
UEqn().relax();
solve(UEqn() == -fvc::grad(p));
eqnResidual = solve
(
UEqn() == -fvc::grad(p)
).initialResidual();
maxResidual = max(eqnResidual, maxResidual);
// check convergence
if (maxResidual < convergenceCriterion)
{
Info<< "reached convergence criterion: " << convergenceCriterion << endl;
runTime.writeAndEnd();
Info<< "latestTime = " << runTime.timeName() << endl;
}
......@@ -11,7 +11,8 @@
hEqn.relax();
hEqn.solve();
eqnResidual = hEqn.solve().initialResidual();
maxResidual = max(eqnResidual, maxResidual);
thermo->correct();
}
// initialize values for convergence checks
scalar eqnResidual = 1, maxResidual = 0;
scalar convergenceCriterion = 0;
simple.readIfPresent("convergence", convergenceCriterion);
......@@ -12,7 +12,16 @@ for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
);
pEqn.setReference(pRefCell, pRefValue);
pEqn.solve();
// retain the residual from the first iteration
if (nonOrth == 0)
{
eqnResidual = pEqn.solve().initialResidual();
maxResidual = max(eqnResidual, maxResidual);
}
else
{
pEqn.solve();
}
if (nonOrth == nNonOrthCorr)
{
......
......@@ -26,8 +26,7 @@ Application
rhoSimpleFoam
Description
Steady-state solver for turbulent flow of compressible fluids for
ventilation and heat-transfer.
Steady-state solver for turbulent flow of compressible fluids
\*---------------------------------------------------------------------------*/
......@@ -56,6 +55,7 @@ int main(int argc, char *argv[])
Info<< "Time = " << runTime.timeName() << nl << endl;
# include "readSIMPLEControls.H"
# include "initConvergenceCheck.H"
p.storePrevIter();
rho.storePrevIter();
......@@ -74,6 +74,8 @@ int main(int argc, char *argv[])
Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
<< " ClockTime = " << runTime.elapsedClockTime() << " s"
<< nl << endl;
# include "convergenceCheck.H"
}
Info<< "End\n" << endl;
......
......@@ -9,4 +9,10 @@
UEqn().relax();
solve(UEqn() == -fvc::grad(pd) - fvc::grad(rho)*gh);
eqnResidual = solve
(
UEqn() == -fvc::grad(pd) - fvc::grad(rho)*gh
).initialResidual();
maxResidual = max(eqnResidual, maxResidual);
......@@ -26,8 +26,7 @@ Application
buoyantSimpleFoam
Description
Steady-state solver for buoyant, turbulent flow of compressible fluids for
ventilation and heat-transfer.
Steady-state solver for buoyant, turbulent flow of compressible fluids
\*---------------------------------------------------------------------------*/
......@@ -57,6 +56,7 @@ int main(int argc, char *argv[])
Info<< "Time = " << runTime.timeName() << nl << endl;
# include "readSIMPLEControls.H"
# include "initConvergenceCheck.H"
pd.storePrevIter();
rho.storePrevIter();
......@@ -64,9 +64,7 @@ int main(int argc, char *argv[])
// Pressure-velocity SIMPLE corrector
{
# include "UEqn.H"
# include "hEqn.H"
# include "pEqn.H"
}
......@@ -77,6 +75,8 @@ int main(int argc, char *argv[])
Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
<< " ClockTime = " << runTime.elapsedClockTime() << " s"
<< nl << endl;
# include "convergenceCheck.H"
}
Info<< "End\n" << endl;
......
// check convergence
if (maxResidual < convergenceCriterion)
{
Info<< "reached convergence criterion: " << convergenceCriterion << endl;
runTime.writeAndEnd();
Info<< "latestTime = " << runTime.timeName() << endl;
}
......@@ -11,7 +11,8 @@
hEqn.relax();
hEqn.solve();
eqnResidual = hEqn.solve().initialResidual();
maxResidual = max(eqnResidual, maxResidual);
thermo->correct();
}
// initialize values for convergence checks
scalar eqnResidual = 1, maxResidual = 0;
scalar convergenceCriterion = 0;
simple.readIfPresent("convergence", convergenceCriterion);
......@@ -13,7 +13,16 @@ for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
);
pdEqn.setReference(pdRefCell, pdRefValue);
pdEqn.solve();
// retain the residual from the first iteration
if (nonOrth == 0)
{
eqnResidual = pdEqn.solve().initialResidual();
maxResidual = max(eqnResidual, maxResidual);
}
else
{
pdEqn.solve();
}
if (nonOrth == nNonOrthCorr)
{
......
......@@ -9,4 +9,10 @@
UEqn().relax();
solve(UEqn() == -fvc::grad(pd) - fvc::grad(rho)*gh);
eqnResidual = solve
(
UEqn() == -fvc::grad(pd) - fvc::grad(rho)*gh
).initialResidual();
maxResidual = max(eqnResidual, maxResidual);
......@@ -58,6 +58,7 @@ int main(int argc, char *argv[])
Info<< "Time = " << runTime.timeName() << nl << endl;
# include "readSIMPLEControls.H"
# include "initConvergenceCheck.H"
pd.storePrevIter();
rho.storePrevIter();
......@@ -65,9 +66,7 @@ int main(int argc, char *argv[])
// Pressure-velocity SIMPLE corrector
{
# include "UEqn.H"
# include "hEqn.H"
# include "pEqn.H"
}
......@@ -78,6 +77,8 @@ int main(int argc, char *argv[])
Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
<< " ClockTime = " << runTime.elapsedClockTime() << " s"
<< nl << endl;
# include "convergenceCheck.H"
}
Info<< "End\n" << endl;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment