#!/bin/sh
cd ${0%/*} || exit 1    # Run from this directory

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

echo "running case: /${PWD##*/}"  #displays the folder name

echo "m4: generating blockMeshDict"
m4 system/blockMeshDict.m4 > system/blockMeshDict

runApplication blockMesh

FILE=./system/decomposeParDict
if test -f "$FILE"; then
    echo "Running in parallel"
    runApplication decomposePar
    runParallel $(getApplication)
    runApplication reconstructPar
    rm -r ./processor*
else
    echo "Running on a single core"
    runApplication $(getApplication)
fi

echo '\n'

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