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

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

# copy propeller surface from resources folder
cp $FOAM_TUTORIALS/resources/geometry/propellerTip.obj.gz constant/triSurface/


# - meshing

runApplication blockMesh

runApplication surfaceFeatureExtract

runApplication snappyHexMesh -overwrite
# force removal of fields generated by snappy
\rm -rf 0
cp -rf 0.org 0


# - generate face/cell sets and zones

#runApplication setSet -batch removeRedundantZones.setSet
#mv log.setSet log.removeRedundantZones.setSet
runApplication topoSet -dict system/removeRedundantZones.topoSetDict
mv log.topoSet log.removeRedundantZones.topoSet

#runApplication setSet -batch createInletOutletSets.setSet
#mv log.setSet log.createInletOutletSets.setSet
runApplication topoSet -dict system/createInletOutletSets.topoSetDict
mv log.topoSet log.createInletOutletSets.topoSet

#runApplication setSet -batch createAMIFaces.setSet
#mv log.setSet log.createAMIFaces.setSet
runApplication topoSet -dict system/createAMIFaces.topoSetDict
mv log.topoSet log.createAMIFaces.topoSet


# - create the inlet/outlet patches

runApplication createPatch -overwrite


# - apply the initial fields

cp -rf 0.org 0


# - create the AMI faces by creating baffles, and then splitting the mesh

runApplication createBaffles -overwrite

runApplication mergeOrSplitBaffles -split -overwrite
