#!/bin/bash

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

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

case=$(foamDictionary caseParameterDict -entry case -value)
latestTime=$(foamListTimes -withFunctionEntries | tail -n 1)
targetDirectory="validation/reference/${case}"
mkdir -p "$targetDirectory"

# Copy results from latest run into reference directory
cp -f postProcessing/Z0.50/"${latestTime}"/line.csv "${targetDirectory}"/Z0.50
cp -f postProcessing/Z0.52/"${latestTime}"/line.csv "${targetDirectory}"/Z0.52
cp -f postProcessing/Z0.85/"${latestTime}"/line.csv "${targetDirectory}"/Z0.85
cp -f postProcessing/Z0.92/"${latestTime}"/line.csv "${targetDirectory}"/Z0.92
cp -f postProcessing/residuals/0/residuals.dat "${targetDirectory}"

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

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