CFD Online Logo CFD Online URL
Home > Forums > OpenFOAM Running, Solving & CFD


Register Blogs Members List Search Today's Posts Mark Forums Read

LinkBack Thread Tools Display Modes
Old   July 2, 2007, 12:06
Default Hey all, one short question a
Posts: n/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?

  Reply With Quote

Old   July 2, 2007, 12:35
Default Hello there, In the standar
Senior Member
Philippose Rajan
Join Date: Mar 2009
Location: Germany
Posts: 531
Rep Power: 16
philippose will become famous soon enough
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 is offline   Reply With Quote

Old   July 2, 2007, 12:42
Default No. The standard (steady) solv
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,915
Rep Power: 40
gschaider will become famous soon enoughgschaider will become famous soon enough
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 ( --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 simpleFoam . pitzDaily

does the same without the plotting.
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request
gschaider is offline   Reply With Quote

Old   July 2, 2007, 13:22
Default Thanks a lot guys! Especially
Posts: n/a
Thanks a lot guys! Especially the last hint was what I was looking for, perfect!
  Reply With Quote

Old   July 3, 2007, 03:12
Default As Philippose mentioned, it is
Senior Member
Mark Olesen
Join Date: Mar 2009
Posts: 779
Rep Power: 18
olesen will become famous soon enough
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.

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);

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


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

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

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

olesen is offline   Reply With Quote

Old   April 30, 2009, 09:10
Senior Member
Wolfgang Heydlauff
Join Date: Mar 2009
Location: Germany
Posts: 136
Rep Power: 9
wolle1982 is on a distinguished road
To plot the residuals on-the-fly on screen graphically, I wrote a short tutorial.

See thread Tutorial of how to plot residuals !
wolle1982 is offline   Reply With Quote


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Steadystate pressurebased compressible solver cosimobianchini OpenFOAM Running, Solving & CFD 1 July 19, 2010 14:45
Steadystate settlingFoam darrin OpenFOAM Running, Solving & CFD 0 February 28, 2007 05:51
Steadystate Vs Transient solver amitshah OpenFOAM Running, Solving & CFD 1 August 23, 2006 02:54
Steadystate Euler solver jelmer OpenFOAM Running, Solving & CFD 1 June 19, 2006 08:24
NonNewtonianIcoFoam for steadystate problem mpml OpenFOAM Running, Solving & CFD 7 July 20, 2005 19:09

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