CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM (https://www.cfd-online.com/Forums/openfoam/)
-   -   Using gnuplot to plot probe data (https://www.cfd-online.com/Forums/openfoam/218227-using-gnuplot-plot-probe-data.html)

Rotidpor June 13, 2019 02:36

Using gnuplot to plot probe data
 
Hello everyone.


I started using gnuplot because it is a convenient tool to plot data. Basically, you just have to type a line or two in a terminal to have your data plotted.
Yet I don't understand the syntax, I found a way to plot my residuals using an openfoam command which extracts the data in my log file and puts it in a single column text file. This way I can tell gnuplot to plot it correctly using simple commands.
This is what I do :


foamLog -n "name of my log file"
gnuplot
plot './Uz_0'


It works well for single column data files created by foamLog. Now my problem is that I want to do the same with probes. Often, my probe files are two columns files, time/iteration versus quantity of interest. But for the velocity, the file is much more complicated with "(" and ")" and four columns.


Is there a simple way to tell gnuplot how to plot a two column file ? Is there an openFoam utility that can convert the velocity probe file into something more manageable like several one column files, as foamLog does for the logfile ?


Thank you all for any input.

tomf June 14, 2019 03:34

Hi,

Not an OpenFOAM utility, but sed would work for this:

Code:

sed 's/[()]/ /g' postProcessing/probes/0/U > postProcessing/probes/0/U_noBrackets
Or if you just want to keep the file, you can do replacement inside the file itself as:

Code:

sed -i 's/[()]/ /g' postProcessing/probes/0/U
And than plot on the U_noBrackets or new U file.

Regards,
Tom

Rotidpor June 17, 2019 02:29

Thank you for your answer tomf, it was helpful.


For those who will read this, here is the gnuplot syntax to plot a file with multiple columns : https://stackoverflow.com/questions/...-all-on-y-axis


Another thing : I realised that gnuplot can actually handle parenthesis. You don't need to remove them before trying to plot. Looks like it just ignores them, which is practical.

SHUBHAM9595 March 9, 2022 05:44

To all the FOAMers...

This is a small attempt to save ur time:).....The following script can be be used to monitor as well as export the probes of pressure, velocity and temperature. The script is written for 3 probe points....you might need to edit it accordingly as per the number of probes and fields that u r observing

Code:

#! /bin/sh

set terminal pngcairo enhanced font "Century Schoolbook,20.0" size 1500,1100
set output "U1.png"
set grid
set autoscale
set title "Velocity Probe-1"
set ylabel 'magnitude'
set xlabel 'Time'
set style line 1
plot "< cat postProcessing/probes/0/U | tr -d '()' " using 1:2 lw 3 title '1probeUx' with lines,\
        "< cat postProcessing/probes/0/U | tr -d '()'" using 1:3 lw 3 title '1probeUy' with lines,\
    "< cat postProcessing/probes/0/U | tr -d '()'" using 1:4 lw 3 title '1probeUz' with lines,
    set terminal x11 0
        set output
        replot
    pause 1

set terminal pngcairo enhanced font "Century Schoolbook,20.0" size 1500,1100
set output "U2.png"
set grid
set autoscale
set title "Velocity Probe-2"
set ylabel 'magnitude'
set xlabel 'Time'
set style line 1
plot "< cat postProcessing/probes/0/U | tr -d '()' " using 1:5 lw 3 title '2probeUx' with lines,\
          "< cat postProcessing/probes/0/U | tr -d '()'" using 1:6 lw 3 title '2probeUy' with lines,\
    "< cat postProcessing/probes/0/U | tr -d '()'" using 1:7 lw 3 title '2probeUz' with lines,
    set terminal x11 1
        set output
        replot
    pause 1
   
set terminal pngcairo enhanced font "Century Schoolbook,20.0" size 1500,1100
set output "U3.png"
set grid
set autoscale
set title "Velocity Probe-3"
set ylabel 'magnitude'
set xlabel 'Time'
set style line 1
plot "< cat postProcessing/probes/0/U | tr -d '()' " using 1:8 lw 3 title '3probeUx' with lines,\
          "< cat postProcessing/probes/0/U | tr -d '()'" using 1:9 lw 3 title '3probeUy' with lines,\
    "< cat postProcessing/probes/0/U | tr -d '()'" using 1:10 lw 3 title '3probeUz' with lines,
    set terminal x11 2
        set output
        replot
    pause 1
 
set terminal pngcairo enhanced font "Century Schoolbook,20.0" size 1500,1100
set output "pressure_probes.png"
set grid
set autoscale
set title "Pressure Probes"
set ylabel 'magnitude'
set xlabel 'Time'
set style line 1
plot "< cat postProcessing/probes/0/p | tr -d '()' " using 1:2 lw 3 title 'Pressure probe 1' with lines,\
        "< cat postProcessing/probes/0/p | tr -d '()'" using 1:3 lw 3 title 'Pressure probe 2' with lines,\
    "< cat postProcessing/probes/0/p | tr -d '()'" using 1:4 lw 3 title 'Pressure probe 3' with lines,
    set terminal x11 3
        set output
        replot
    pause 1
 
set terminal pngcairo enhanced font "Century Schoolbook,20.0" size 1500,1100
set output "Thermal_probes.png"
set grid
set autoscale
set title "Temperature Probes"
set ylabel 'magnitude'
set xlabel 'Time'
set style line 1
plot "< cat postProcessing/probes/0/T | tr -d '()' " using 1:2 lw 3 title 'Thermal probe 1' with lines,\
        "< cat postProcessing/probes/0/T | tr -d '()'" using 1:3 lw 3 title 'Thermal probe 2' with lines,\
    "< cat postProcessing/probes/0/T | tr -d '()'" using 1:4 lw 3 title 'Thermal probe 3' with lines,
    set terminal x11 4
        set output
        replot
    pause 60



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