#!/bin/bash

# Source tutorial run functions
. $WM_PROJECT_DIR/bin/tools/RunFunctions

# Copy blockMeshDict to constant/polyMesh for foam-extend
mkdir constant/polyMesh
cp system/blockMeshDict constant/polyMesh/

# Create mesh
runApplication blockMesh

# Run solver
runApplication pythonLaplacianFoam

if [[ $WM_PROJECT_VERSION = "v2012" ]]; then
    echo "Printing with singleGraph"
    runApplication -s singleGraph postProcess -func singleGraph -latestTime

    # Generate plot using gnuplot
    runApplication gnuplot plotSingleGraph.gnuplot

    echo "See plot.pdf"

elif [[ $WM_PROJECT_VERSION = "9" ]]; then
    echo "Printing with graphUniform"
    runApplication -s graphUniform postProcess -func graphUniform -latestTime
    
    # Generate plot using gnuplot
    runApplication gnuplot plotGraphUniform.gnuplot

    echo "See plot.pdf"

elif [[ $WM_PROJECT_VERSION = "4.1" ]]; then
    echo “Graphs not generated for foam extend as the postProcess utility is not available”
fi
