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

# Source case functions
. "$WM_PROJECT_DIR/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/D5/${latestTime}/line.csv" \
    "${targetDirectory}/D5"
cp -f "postProcessing/D10/${latestTime}/line.csv" \
    "${targetDirectory}/D10"
cp -f "postProcessing/D15/${latestTime}/line.csv" \
    "${targetDirectory}/D15"
cp -f "postProcessing/D20/${latestTime}/line.csv" \
    "${targetDirectory}/D20"
cp -f "postProcessing/residuals/0/residuals.dat" \
    "${targetDirectory}"

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

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