#!/bin/bash

if ! command -v gnuplot > /dev/null 2>&1
then
    echo 'gnuplot not found - skipping graph creation' >&2
    exit 1
else
    mkdir -p ../postProcessing/report
fi

gnuplot<<EOF
    set term pngcairo
    set output '../postProcessing/report/image.png'

    set style line 1 dt 2 lt 1 lw 2 pt 2 lc 'black'
    set style line 2 lt 2 lw 5 pt 2 lc 'red'
    set style line 3 lt 2 lw 2 pt 2 lc 'green'

    TIME = system('foamListTimes -functionEntries  -case .. | tail -n 1')

    set xlabel 'xlabel'
    set ylabel 'ylabel'

    plot 'experiment/line.dat' u 1:2 w p ls 2 t 'Experiment', \
         'reference/line.csv' u 1:2 w l ls 3 t 'Reference', \
         '../postProcessing/sampleLine/'.TIME.'/line.csv' u 1:2 w l ls 1 t 'Simulation'
EOF

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