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

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

# copy flange surface from resources directory
cp $FOAM_TUTORIALS/resources/geometry/flange.stl.gz constant/triSurface/

cp system/controlDict system/controlDict.org

sed -e s/"\(endTime[ \t]*\)\([0-9]*\);"/"\1 10;"/g \
    -e s/"\(writeInterval[ \t]*\)\([0-9]*\);"/"\1 10;"/g \
    system/controlDict.org > system/controlDict

runApplication foamyHexMesh

# Change collapseEdges to only do one iteration
cp system/collapseDict system/collapseDict.org

sed -e s/"\(maximumIterations[ \t]*\)\([0-9]*\);"/"\1 1;"/g \
    system/collapseDict.org > system/collapseDict

runApplication collapseEdges -latestTime -collapseFaces

cp system/controlDict.org system/controlDict
cp system/collapseDict.org system/collapseDict

rm -f system/controlDict.org system/collapseDict.org


# ----------------------------------------------------------------- end-of-file
