#!/bin/sh

if ! which gnuplot > /dev/null 2>&1
then
    echo "gnuplot not found - skipping graph creation" >&2
    exit 1
fi

graphFile=postProcessing/graph/$(foamListTimes -latestTime)/line.xy

gnuplot<<EOF
    set terminal postscript eps color enhanced font "Helvetica,20" size 5,5
    set output 'graphs.eps'

    set multiplot layout 3,1

    set ylabel 'Temperature [K]'
    plot [][225:425] "$graphFile" u 1:2 w l t ''

    set ylabel 'Velocity [m/s]'
    plot [][-50:350] "$graphFile" u 1:3 w l t ''

    set xlabel 'Position [m]'
    set ylabel 'Pressure [kPa]'
    plot [][-10:110] "$graphFile" u 1:(\$4/1e3) w l t ''
EOF

#------------------------------------------------------------------------------
