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

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

# Set application name
application=$(getApplication)

runApplication chemkinToFoam \
               chemkin/grimech30.dat chemkin/thermo30.dat chemkin/transportProperties \
               constant/reactionsGRI constant/thermo.compressibleGasGRI

runApplication blockMesh
runApplication setFields

if ! isTest $@
then
    # Run the application without chemistry until 1500 to let the flow develop
    foamDictionary -entry "startTime" -set "0" system/controlDict
    foamDictionary -entry "writeInterval" -set "1500" system/controlDict
    foamDictionary -entry "endTime" -set "1500" system/controlDict
    rm -rf constant/chemistryProperties > /dev/null 2>&1
    foamDictionary -entry "chemistry" -set "off" constant/chemistryProperties

    runApplication $application

    # Run with chemistry until flame reach its full size
    foamDictionary -entry "startTime" -set "1500" system/controlDict
    foamDictionary -entry "writeInterval" -set "100" system/controlDict
    foamDictionary -entry "endTime" -set "5000" system/controlDict
    rm -rf constant/chemistryProperties > /dev/null 2>&1
    foamDictionary -entry "chemistry" -set "on" constant/chemistryProperties
fi

runApplication -o $application

rm -rf constant/chemistryProperties > /dev/null 2>&1

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