#!/bin/bash

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

gnuplot<<EOF

set terminal pngcairo color enhanced
set grid
set key outside below

LIST = system("foamListTimes -case .. -withZero")
TIMES(n) = word(LIST, n)
NUM = words(LIST)

xpos = "0.5"

set palette model HSV
set palette defined (0 0 1 0, 1 0 1 1, 7 0.8333 1 1, 8 0.8333 0.9 1)

#===verticalLine===
set output 'temperatures_vertical.png'
FILE(n) = "../postProcessing/graph/".TIMES(n)."/line.csv"
RFILE =   "reference/T.gas1.analytical.csv"

set title "Two phases, HT, definitePhases, x = ".xpos

set xlabel "y [m]"
set ylabel "T [K]"
set cbrange [0:TIMES(NUM)]
set cblabel 't'
#set yrange [309:311]

plot for [i=1:NUM] FILE(i) u (column("y")):(column("T.gas1")) w lp pt 4 lc palette cb TIMES(i) notitle, \
     for [i=1:NUM] FILE(i) u (column("y")):(column("T.gas2")) w p  pt 6 lc palette cb TIMES(i) notitle, \
                   RFILE   u (column("y")):(column("T.gas1")) w l       lt -1                  t "analytical"


EOF

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