#!/bin/sh

currDir=`pwd`
application=`basename $currDir`
cases="pitzDaily"

tutorialPath=`dirname $0`/..
. $tutorialPath/RunFunctions

runAdiabaticFlameT ()
{
    echo "Running adiabaticFlameT and setting thermophysicalProperties"
    cd $1/constant
    adiabaticFlameT adiabaticFlameTDict > adiabaticFlameTdata_tmp
    mv thermophysicalProperties thermophysicalProperties.bak
    sed -n '/FOAM Project/,/thermoType/p' thermophysicalProperties.bak > \
        thermophysicalProperties
    echo "" >> thermophysicalProperties
    grep stoichiometric adiabaticFlameTdata_tmp >> thermophysicalProperties
    echo "" >> thermophysicalProperties
    grep -A 26 'phi = 0.6$' adiabaticFlameTdata_tmp | \
        sed -n '/fuel/,$p' | \
        sed \
        -e s/";"/"    1.67212e-6 170.672;\n"/g \
        -e s/"oxidant"/"oxidant oxidant"/g \
        -e s/"reactants"/"reactants reactants"/g \
        -e s/"burntProducts"/"burntProducts burntProducts"/g \
        -e s/"products"/"products products"/g \
        >> thermophysicalProperties
    echo "// ************************************************************************* //" >> thermophysicalProperties
    cd ../..
}

for case in $cases
do
#   CURRENTLY NOT USING adiabaticFlameT
#    runAdiabaticFlameT $case
    runApplication blockMesh $case
    runApplication $application $case
done 
