CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Running, Solving & CFD

To Plot Residuals on the fly.

Register Blogs Community New Posts Updated Threads Search

Like Tree5Likes
  • 5 Post By chern

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 18, 2013, 09:02
Default To Plot Residuals on the fly.
  #1
New Member
 
neeraj's Avatar
 
OpenFoam
Join Date: Jul 2012
Posts: 24
Rep Power: 14
neeraj is on a distinguished road
Can anyone explain how to plot real time residuals in openfoam 2.1.1. I have seen tutorials for older versions but its not working in 2.1.1
neeraj is offline   Reply With Quote

Old   January 18, 2013, 17:14
Default
  #2
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by neeraj View Post
Can anyone explain how to plot real time residuals in openfoam 2.1.1. I have seen tutorials for older versions but its not working in 2.1.1
It should. All these methods read the standard-output and extract the residuals from it. The format of the residuals has not changed for years (in pyFoam I havn't had to change the pattern since 1.5 I think and I regularly use it for plotting residuals from 1.6 to 2.1)

But maybe if you refer to the method you're using (link on this forum) and the solver you're using someone can enlighten you
__________________
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   January 21, 2013, 06:26
Default
  #3
New Member
 
Alexandr
Join Date: Jul 2012
Location: Odessa, Ukraine
Posts: 2
Rep Power: 0
chern is on a distinguished road
Needed: Linux, OpenFoam, gnuplot, X (X.org).


1) Run in first terminal shell solver like icoFoam as:

$ icoFoam > log.icoFoam

2) Run in second terminal shell gnuplot as:

$ gnuplot Courant

repeat this step for other plot in third terminal etc.

3) Make additional file for plot graph on runtime OpenFoam.


- If you don't need logscale: comment line "set logscale y" with # in first position as "#set logscale y" or delete line.
- For plotting any other fields in log file you must editing argument grep command ex. "grep 'Courant Number'"
count words in grep string number of field:
"Courant Number mean: 0.000417096 max: 0.124527"
1-"Courant" 2-"Number" 3-"mean:" 5-"max:"
filds No 4 and 6 is mean and max Courant number. Its using in args of cut command: "cut -d' ' -f4"
- If you need draw only one graph: use command plot like:
"plot "< cat log.icoFoam | grep 'Courant Number' | cut -d' ' -f4 | tr -d ','" title 'Courant Number mean' with lines"

- Edit time in seconds in gnuplot command "pause 10" for redraw plot.

- Other commands are trivial



File: log.icoFoam (part of file for example)
------------------------------------
Time = 0.1

Courant Number mean: 0.000417096 max: 0.124527
DILUPBiCG: Solving for Uy, Initial residual = 1, Final residual = 3.59578e-17, No Iterations 1
DICPCG: Solving for p, Initial residual = 1, Final residual = 9.72814e-07, No Iterations 756
time step continuity errors : sum local = 2.66067e-09, global = 5.15345e-14, cumulative = 5.15345e-14
DICPCG: Solving for p, Initial residual = 1.07532e-06, Final residual = 4.96329e-07, No Iterations 1
time step continuity errors : sum local = 1.23062e-09, global = 5.01838e-13, cumulative = 5.53373e-13
ExecutionTime = 4.9 s ClockTime = 5 s
------------------------------------

File: Courant
------------------------------------
set logscale y
set title "Courant"
set ylabel 'Courant'
set xlabel 'Iteration'
plot "< cat log.icoFoam | grep 'Courant Number' | cut -d' ' -f4 | tr -d ','" title 'Courant Number mean' with lines,\
"< cat log.icoFoam | grep 'Courant Number' | cut -d' ' -f6 | tr -d ','" title 'Courant Number max' with lines
pause 10
reread
------------------------------------

File: Residuals
------------------------------------
set logscale y
set title "Residuals"
set ylabel 'Residual'
set xlabel 'Iteration'
plot "< cat log.icoFoam | grep 'Solving for p' | cut -d' ' -f9 | tr -d ','" title 'p' with points
pause 10
reread
------------------------------------
emjay, FrankFlow, amuzeshi and 2 others like this.

Last edited by chern; January 21, 2013 at 07:45.
chern is offline   Reply With Quote

Old   October 1, 2013, 15:46
Default
  #4
Senior Member
 
izna O'connor
Join Date: Jun 2013
Posts: 143
Rep Power: 13
izna is on a distinguished road
hi,

but if i want the iteration at the same time to be plotted so that i can monitor the residuals... what command should i use?

Can you please kindly tell me?

Kind regards
Izna
izna is offline   Reply With Quote

Old   October 2, 2013, 07:07
Default
  #5
Member
 
Logan Page
Join Date: Sep 2010
Posts: 38
Rep Power: 16
Logan Page is on a distinguished road
If you want the residuals to be piped to the terminal as well as the log file, while the simulation is running, you can use:
icoFoam 2>&1 | tee log.icoFoam

Then you can use gnuplot (as chern suggested above) or pyFoam to plot the residuals from the log file.
Logan Page is offline   Reply With Quote

Old   October 2, 2013, 07:23
Default
  #6
New Member
 
Filip Gjetvaj
Join Date: Mar 2013
Location: Montpellier, FR
Posts: 17
Rep Power: 13
File is on a distinguished road
Hi Izna

I think this is what you're looking for

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

Regards
Filip
File is offline   Reply With Quote

Reply


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 Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Tutorials] Tutorial of how to plot residuals ! wolle1982 OpenFOAM Community Contributions 171 February 20, 2024 03:55
plot residuals in multiregion solver val46 OpenFOAM 4 December 12, 2016 07:06
plot of residuals hawkeye321 OpenFOAM 5 December 7, 2012 10:05
Residuals Plot kamalipour FLUENT 2 December 15, 2011 04:44
URGENT: plot residuals for complete simulation?? Khan FLUENT 1 February 1, 2007 13:35


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