October 14, 2010 0

Plotting massive datasets on the fly

By in OpenFOAM

One of the hassles with working on a distant HPC is that you need to push and pull huge amounts of data back and forth. This wouldn’t be a big issue if you would have a really fast internet connection and/or if you would just need to do that once a day. Unfortunately, neither is the case for my application. I’m doing two phase CFD simulations using OpenFOAM and quite large logfiles and datafiles are accumulated during a single simulation. Since I want to check e.g. the convergence of the forces on my geometry during runtime, I need to plot a datafile which increases in size each timestep up to 10MB. This cannot be done on my local machine, since the download of the datafile would take way too long.To avoid this issue, I forward the X-session from the HPC cluster to my local machine.

slogin -X $user@$server

The plotting is done on that cluster and only the output is forwarded to my machine. For the plotting itself, I love to use gnuplot and its extensive functionality. As a output terminal for gnuplot, I use X11. It allows you to zoom into the data and customize the origin of the visual plot, without having to adjust the plotting parameters inside your gnuplot script.

Assume, that I would like to plot the second column over the first column of a file called forces.dat, the gnuplot file plot.gnp would look like:

reset
set xlabel 'Iterations'
set ylabel 'Force [N]'
plot 'forces.dat' using 1:2 with lines title 'not working plot'

Unfortunately, OpenFOAM stores the forces in a list of vectors. This means, that there are plenty of brackets inside that forces.dat file and gnuplot is not capable of ignoring these brackes. They need to be removed for the plotting, which can be done in several ways and I am using sed. But one question comes up to mind: What if I do not want to execute a load 'plot.gnp' each time, I want to update my plot, since new data is available?

For this purpose I am piping the output of this script directly into the plot and I do not need to store the ouput of  the small sed script (shown in a previous post) in an additional file:

plot "<./removeBrackets.sh" using 1:2 with lines

If you would want to visualize e.g. the residuals of a run, which are stored in the logfile of the solver, you are running, you can do the same with a grep, intead of a sed. Or you can use Bernhard’s pyFoam extension, which I highly recommend.

Related posts:

  1. Remove brackets from file

Tags: , , , ,

Leave a Reply