CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Main CFD Forum

Real-time residual and results plotting

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

Reply
 
LinkBack Thread Tools Display Modes
Old   January 29, 2007, 07:23
Default Real-time residual and results plotting
  #1
simone Marras
Guest
 
Posts: n/a
Hello, I'd like to know how to plot the residual into a graphics in real-time during the running of my own code. It's a code written in C, compiled with gcc and run as an executable, and the only way I have now to view the diagram of the residual is printing out the values and only afterwards to view them through octave/gnuplot or matlab.

Anyone worte a script to let the executable communicate with a visualization tool?

Thanks a lot

Simone
  Reply With Quote

Old   January 29, 2007, 08:00
Default Re: Real-time residual and results plotting
  #2
Praveen. C
Guest
 
Posts: n/a
You could use pgplot.

http://www.astro.caltech.edu/~tjp/pgplot/

I use a much simpler solution. From my code I run gnuplot (use the system subroutine which is available in both fortran and C) to generate a png file of the residue plot. I open the png file with xv or display (part of imagemagick); the image display gets updated automatically whenever the png file is modified.
  Reply With Quote

Old   January 29, 2007, 08:19
Default Re: Real-time residual and results plotting
  #3
simone Marras
Guest
 
Posts: n/a
Thank you very much for the hint. Ill work on it starting from your suggestion. In case I want to use your way, calling gnuplot from C, would it be called as: system(gnuplot 'filename') ?

thanks again

simone
  Reply With Quote

Old   January 29, 2007, 08:24
Default Re: Real-time residual and results plotting
  #4
Balduin Bankerotti
Guest
 
Posts: n/a
Found this some time ago:


c Fortran-gnuplot interaction for real-time animation using named pipe
c
c This is a simple example of how gnuplot can be used to create
c real-time animation of data produced by running fortran 77 code.
c
c I put it in the searchable directory in a hope that it can be useful,
c but no guarantees of any kind: use it at your own risk. Too many
c frames per second can hang you system heavily.
c
c To understand how it works, you need to know what a named pipe is, and what
c plot '-' means in gnuplot: read the manuals.
c
c And, PLEASE, if you know why a.out > FIFOfile works
c but just a.out does not
c even though the gnuplot commands are written to the pipe and not
c to the standard output, send me an explanation to
c chernysh@soton.ac.uk (Sergei Chernyshenko) or
c by other means, see http://www.afm.ses.soton.ac.uk/ -> People.
c
c How to use:
c
c at the linux command prompt, type mkfifo FIFOfile
c compile this file and name the executable a.out .
c in an xterm window type gnuplot < FIFOfile
c in another window type a.out > FIFOfile
c enjoy
c
c do not use too many frames per second, the computer may hang.
c
c second(x) gives the CPU time in seconds. Replace if unavailable.

nframe=0
open(1,file='FIFOfile', status='unknown')
write(1,*) 'set xrange [-10:10]'
write(1,*) 'set yrange [-2:2]'
write(1,*)'set title \'Demonstrating animation Fortran-gnuplot'
1 ,' via named pipe\''
close(1)
1 call second(x)
c 15 frames per second:
if(15*x.gt.nframe) then
nframe=nframe+1
open(1,file='FIFOfile', status='unknown')
write(1,*) 'plot sin(x-',x,'),',' \'-\' w lp'
write(1,*) 0.2
write(1,*) 0.3
write(1,*) 0.4
write(1,*) 0.5
i=(x/10)
i=i*10
write(1,*) (x-i)/10.
write(1,*) 0.7
write(1,*) 0.8
write(1,*) 0.9
write(1,*) 'e'
close(1)
endif
goto 1
stop
end
  Reply With Quote

Old   January 29, 2007, 08:31
Default Re: Real-time residual and results plotting
  #5
simone Marras
Guest
 
Posts: n/a
Very useful, thanks

s.
  Reply With Quote

Old   January 29, 2007, 08:35
Default Re: Real-time residual and results plotting
  #6
Praveen. C
Guest
 
Posts: n/a
Say you have put all your gnuplot commands in file "plot.gnu". In C you would run gnuplot as

system("gnuplot plot.gnu");

Suppose gnuplot generates plot.png

You open it in xv as

xv -poll plot.png &

or in display as

display -update 10 plot.png &

You can also start the image viewer from within your C code.
  Reply With Quote

Old   January 29, 2007, 08:57
Default Re: Real-time residual and results plotting
  #7
simone Marras
Guest
 
Posts: n/a
I try this and let you know. Supposedly then this same thing would work also if I generate my plots with octave? For exemple I could view a vector field step by step during the exsecution of my C code?

system("octave plot.gnu");
  Reply With Quote

Reply

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
Moving mesh Niklas Wikstrom (Wikstrom) OpenFOAM Running, Solving & CFD 122 June 15, 2014 06:20
transsonic nozzle with rhoSimpleFoam Unseen OpenFOAM Running, Solving & CFD 7 April 16, 2014 03:38
Orifice Plate with a fully developed flow - Problems with convergence jonmec OpenFOAM Running, Solving & CFD 3 July 28, 2011 05:24
Extrusion with OpenFoam problem No. Iterations 0 Lord Kelvin OpenFOAM 6 April 12, 2011 11:24
SimpleFoam k and epsilon bounded nedved OpenFOAM Running, Solving & CFD 1 November 25, 2008 21:21


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