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

# Source case functions
. "$WM_PROJECT_SITE/$WM_PROJECT_VERSION/bin/tools/casesFunctions.sh"

case=$(foamDictionary caseParameterDict -entry case -value)
latestTime=$(foamListTimes -functionEntries | tail -n1)
targetDirectory="validation/reference/${case}"

# Copy results from latest run into reference directory
cp -f "postProcessing/centerLine/${latestTime}/line.csv" \
    "${targetDirectory}/centerLine"
cp -f "postProcessing/D8/${latestTime}/line.csv" "${targetDirectory}/D8"
cp -f "postProcessing/D24/${latestTime}/line.csv" "${targetDirectory}/D24"
cp -f "postProcessing/D40/${latestTime}/line.csv" "${targetDirectory}/D40"
cp -f "postProcessing/D60/${latestTime}/line.csv" "${targetDirectory}/D60"
cp -f "postProcessing/residuals(p,U)/0/residuals.dat" "${targetDirectory}"

# Remove tabs from result files
cd "${targetDirectory}" && removeTabsFromColumns residuals.dat

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