#!/bin/bash

cd "${0%/*}" || exit 1

echo "=============================================="
echo " Finned Channel CFD Case - OpenFOAM 9"
echo "=============================================="

echo ""
echo "0. Fetching STL geometry from Mesh folder..."
mkdir -p constant/triSurface
cp ../../../Mesh/fluidDomain.stl constant/triSurface/ || exit 1

echo ""
echo "1. Creating background mesh..."
blockMesh || exit 1

echo ""
echo "2. Extracting surface features..."
surfaceFeatures || exit 1

echo ""
echo "3. Generating geometry-conforming mesh..."
snappyHexMesh -overwrite || exit 1

echo ""
echo "4. Creating face sets..."
topoSet || exit 1

echo ""
echo "5. Creating final boundary patches..."
createPatch -overwrite || exit 1

echo ""
echo "6. Checking final mesh..."
checkMesh || exit 1

echo ""
echo "7. Starting solver..."
echo "=============================================="

buoyantSimpleFoam

echo ""
echo "=============================================="
echo " Simulation completed."
echo "=============================================="
