#!/bin/bash

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

gnuplot<<EOF

    time = '0.03'

    D = 3e-3
    sigma = 0.07

    pAnalytical = 2*sigma/D

    set terminal pngcairo color enhanced


    #---velocity-norm---
    FILE = '../postProcessing/sumMagVelocity/0/volFieldValue.dat'
    set output 'sumMagVelocity.png'

    set grid
    set logscale y
    set format y '10^{%T}'

    set xlabel 't'
    set ylabel '{/Symbol S}|u|'

    plot FILE u 1:((\$2*\$2+\$3*\$3)**0.5) '%lf (%lf %lf %lf) (%lf %lf %lf)' w l notitle

    unset logscale
    unset format y


    #---pressure-field---
    FILE = '../postProcessing/planeA/'.time.'/cutPlane.xy'
    set output 'pressure_surface.png'

    set title 't = '.time.' s'

    set xlabel 'x/D'
    set ylabel 'y/D'
    set zlabel 'p_{rgh}'

    set xtics 0.5
    set ytics 0.5

    set view equal xy
    set ticslevel 0
    unset parametric

    set mapping cartesian
    #set view 60,30,1,1
    #set auto
    #set isosamples 60
    set hidden3d
    set dgrid3d 40,40 qnorm 2

    splot FILE u (\$1/D):(\$2/D):4 w l notitle

EOF

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