#!/bin/sh
cd "${0%/*}" || exit                                # Run from this directory
. ${WM_PROJECT_DIR:?}/bin/tools/RunFunctions        # Tutorial run functions
#------------------------------------------------------------------------------

runApplication surfaceFeatureExtract

runApplication foamyHexMesh

# Collapse only patch faces from incomplete conformation
runApplication -s indirectPatchFaces \
    collapseEdges -collapseFaceSet indirectPatchFaces -latestTime -overwrite

# Collapse small edges and sliver faces
runApplication -s collapseFaces \
    collapseEdges -collapseFaces -latestTime -overwrite

runApplication checkMesh -allTopology -allGeometry -latestTime

latestTime=$(foamListTimes -latestTime)

# Move the mesh into polyMesh
rm -rf constant/polyMesh
mv "${latestTime}"/polyMesh constant

# Clean up intermediate meshes
rm -r [1-9]*

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