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

# Source run functions
. "$WM_PROJECT_SITE/$WM_PROJECT_VERSION/bin/tools/RunFunctions"

# Run cases
normal/Allrun
inverted/Allrun

# Compare solutions
latestTime=$(foamListTimes -case normal/ -latestTime)
case=$(basename "$PWD")
cp inverted/"${latestTime}"/U.gas1     normal/"${latestTime}"/U.gas1.inverted
cp inverted/"${latestTime}"/U.gas2     normal/"${latestTime}"/U.gas2.inverted
cp inverted/"${latestTime}"/alpha.gas1 \
    normal/"${latestTime}"/alpha.gas1.inverted
cp inverted/"${latestTime}"/alpha.gas2 \
    normal/"${latestTime}"/alpha.gas2.inverted
runApplication -s "${case}.U.gas1" foamPostProcess \
    -case normal/ -latestTime \
    -func "deviation(field=U.gas1, reference=U.gas1.inverted)"
runApplication -s "${case}.U.gas2" foamPostProcess \
    -case normal/ -latestTime \
    -func "deviation(field=U.gas2, reference=U.gas2.inverted)"
runApplication -s "${case}.alpha.gas1" foamPostProcess \
    -case normal/ -latestTime \
    -func "deviation(field=alpha.gas1, reference=alpha.gas1.inverted)"
runApplication -s "${case}.alpha.gas2" foamPostProcess \
    -case normal/ -latestTime \
    -func "deviation(field=alpha.gas2, reference=alpha.gas2.inverted)"

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