#!/bin/bash

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

gnuplot<<EOF
    C='cipsaMultiphaseEuler'
    R='addonMultiphaseEuler'

    set terminal pngcairo enhanced
    set grid
    set key outside below

    #===GRAPH===
    #---U---
    set output 'horizontal_line_U.png'
    FILE='postProcessing/graph/1000/line.csv'

    set xlabel 'x'
    set ylabel 'U.y'

    plot '../'.C.'/'.FILE using 1:3 with lines title C, \
         '../'.R.'/'.FILE using 1:3 with lines title R

    #---T---
    set output 'horizontal_line_T.png'

    set ylabel 'T'

    plot '../'.C.'/'.FILE using 1:5 with lines title C, \
         '../'.R.'/'.FILE using 1:5 with lines title R

    #===RESIDUALS===
    set output 'residuals_p_rgh.png'
    FILE='postProcessing/residuals/0/residuals.dat'

    set xlabel 't'
    set ylabel 'residuals(p\_rgh)'
    set logscale y
    set format y '10^{%T}'

    plot '../'.C.'/'.FILE using 1:2 with lines title C, \
         '../'.R.'/'.FILE using 1:2 with lines title R

EOF

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