CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (https://www.cfd-online.com/Forums/openfoam-solving/)
-   -   SteadyState (https://www.cfd-online.com/Forums/openfoam-solving/59603-steadystate.html)

tutlhino July 2, 2007 12:06

Hey all, one short question a
 
Hey all,
one short question about the steadyState setting. Is it possible that the simulation stops when it has reached the desired residual, or does it do that automatically? 'Cause I need to measure the time when it has converged, but I've seen that after 1000 iterations, which was the default setting, all residuals were far below the desired residual!? And is it possible to get a convergence plot of the simulation?

Cheers
Florian

philippose July 2, 2007 12:35

Hello there, In the standar
 
Hello there,

In the standard steady state incompressible solver, for example "simpleFoam", there is no option to automatically stop the simulation once a specific variable has converged to a desired level, though it would not be difficult, to modify a solver to include such a functionality.

As for viewing plots of residuals.... use the command "foamLog". This utility basically extracts data (such as the residuals, etc..) from the log file into separate data files, which you can then plot using programs like "gnuplot" or "kst", etc...etc...

Have a nice day!

Philippose

gschaider July 2, 2007 12:42

No. The standard (steady) solv
 
No. The standard (steady) solvers happily keep working until endTime is reached.

Convergence plots you can get if you produce a log file (for instance by starting a job with foamJob) and then use a script to process the output (it's delivered with OpenFOAM, but I can'T remember the name).

What I use in such situations is a script from pyFoam (http://openfoamwiki.net/index.php/Contrib_PyFoam):

pyFoamPlotRunner.py --steady simpleFoam . pitzDaily

It starts the simulation and monitors ther output. Using that output it
* plots the residuals
* tells the simulation to stop and write a result once none of the linear solvers iterates anymore

pyFoamSteadyRunner.py simpleFoam . pitzDaily

does the same without the plotting.
Bernhard

tutlhino July 2, 2007 13:22

Thanks a lot guys! Especially
 
Thanks a lot guys! Especially the last hint was what I was looking for, perfect!

olesen July 3, 2007 03:12

As Philippose mentioned, it is
 
As Philippose mentioned, it is not so hard to add in a convergence check.

In the top-level code, you can add a convergence lookup just after re-reading the SIMPLE controls:

# include "readSIMPLEControls.H"

// add in convergence criterion
scalar eqnResidual = 1, maxResidual = 0;
scalar convergenceCriterion = 0;

if (simple.found("convergence"))
{
convergenceCriterion = readScalar(simple.lookup("convergence"));

if (convergenceCriterion <0> 1)
{
Info<< "out-of-range convergence criterion: "
<< convergenceCriterion
<< endl;
convergenceCriterion = 0;
}
}


For each of the solved variables, just extend the change the solve() method with initialResidual() method.
eg,

eqnResidual = hEqn.solve().initialResidual();
maxResidual = max(eqnResidual, maxResidual);


Just remember to only capture the first value from the pressure correction:

// retain the residual from the first iteration
if (nonOrth == 0)
{
eqnResidual = pEqn().solve().initialResidual();
maxResidual = max(eqnResidual, maxResidual);
}
else
{
pEqn().solve();
}


Back in the top-level code, you can now add the convergence check at the bottom of the loop:

runTime.write();

Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
<< " ClockTime = " << runTime.elapsedClockTime() << " s"
<< nl << endl;

if (maxResidual < convergenceCriterion)
{
Info<< "convergence criterion satisfied: "
<< convergenceCriterion
<< endl;

runTime.writeAndEnd();
Info<< "latestTime = " << runTime.timeName() << endl;
}

-----

wolle1982 April 30, 2009 09:10

To plot the residuals on-the-fly on screen graphically, I wrote a short tutorial.

See thread http://www.cfd-online.com/Forums/ope...residuals.html


All times are GMT -4. The time now is 03:03.