#!/bin/bash

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

gnuplot<<EOF

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

TIME = system("foamListTimes -functionEntries -case .. | tail -n1")

set term pngcairo

set grid
set key box

set style line 1 dt 2 lt 1 lw 2 pt 2 lc "black"
set style line 3 lt 2 lw 2 pt 2 lc "green"

set output '../kMean.png'
set ylabel 'y (m)'
set xlabel 'k (m^2/s^2)'

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

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