#!/bin/bash

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

gnuplot<<EOF

#\*---------------------General settings--------------------------------------*/

TIME = system("foamListTimes -case .. -latestTime")

set term pngcairo size 800,600 color enhanced
set title 'Fixed Polydisperse Pipe Flow'
set xlabel 'r (mm)'
set xrange [0:25]

set style line 1 lt -1 lw 1 pt 1
set style line 2 lt 2 lw 2 pt 2
set style line 3 lt 3 lw 2 pt 3
set style line 4 lt 4 lw 2 pt 4
set style line 5 lt 5 lw 2 pt 5

#\*---------------------Radial void fraction profile--------------------------*/

set output 'alpha.png'
set ylabel '{/Symbol a}_g (-)'

plot '../postProcessing/graph/'.TIME.'/line.csv' u (\$1*1000):(\$2+\$3) t 'Simulation' w l ls 1

#\*---------------------Radial velocity profile-------------------------------*/

set output 'velocity.png'
set ylabel 'w_g (m/s)'

plot '../postProcessing/graph/'.TIME.'/line.csv' u (\$1*1000):6 t 'Simulation' w l ls 1

#\*---------------------Radial slip velocity profile--------------------------*/

set output 'slipVelocity.png'
set ylabel 'w_{rel} (m/s)'

plot '../postProcessing/graph/'.TIME.'/line.csv' u (\$1*1000):(\$6-\$9) t 'Simulation' w l ls 1

EOF

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