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

# Source tutorial run functions
. $WM_PROJECT_DIR/bin/tools/RunFunctions

rm -rf source target targetPar

cp -r $FOAM_TUTORIALS/incompressible/icoFoam/cavity source
cd source
cp $FOAM_TUTORIALS/multiphase/interFoam/laminar/damBreak/system/decomposeParDict system/
runApplication blockMesh
runApplication decomposePar
runApplication icoFoam
cd ..

cp -r $FOAM_TUTORIALS/incompressible/icoFoam/cavity target
cd target
runApplication blockMesh

# parallelSource, serial target, consistent: fail
runApplication mapFields -sourceTime latestTime -parallelSource -consistent ../source
mv log.mapFields log.mapFields-fail

# parallelSource, serial target, empty mapFieldsDict: pass
cp $FOAM_TUTORIALS/incompressible/icoFoam/cavityGrade/system/mapFieldsDict system/
runApplication mapFields -sourceTime latestTime -parallelSource ../source
mv log.mapFields log.mapFields-pass
cd ../

cp -r $FOAM_TUTORIALS/incompressible/icoFoam/cavity targetPar
cd targetPar
cp $FOAM_TUTORIALS/multiphase/interFoam/laminar/damBreak/system/decomposeParDict system/
runApplication blockMesh
runApplication decomposePar

# parallelSource, parallelTarget, consistent: fail
runApplication mapFields -sourceTime latestTime -parallelSource -parallelTarget -consistent ../source
mv log.mapFields log.mapFields-fail

# parallelSource, parallelTarget, empty mapFieldsDict: pass
cp $FOAM_TUTORIALS/incompressible/icoFoam/cavityGrade/system/mapFieldsDict system/
runApplication mapFields -sourceTime latestTime -parallelSource -parallelTarget ../source
mv log.mapFields log.mapFields-pass
