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

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

runApplication blockMesh
runApplication setFields
runApplication decomposePar
runParallel    foamRun
runApplication reconstructPar

# Compare to reference solution
case=$(basename "$PWD")
# shellcheck disable=SC2012
ls -d 0.[0-9]* | runCommand --suffix "${case}" -- diff -s \
    validation/reference.dat -

latestTime=$(foamListTimes -latestTime)
cp validation/Co.air.gz "$latestTime/Co.air.ref.gz"
runApplication -s "${case}" foamPostProcess \
    -func "deviation(field=Co.air, reference=Co.air.ref)" -latestTime

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