#!/bin/bash
# ================================
# Allrun script for cavity case
# ================================

# Load OpenFOAM environment (if not already loaded)
. $WM_PROJECT_DIR/bin/tools/RunFunctions

# 1. Generate mesh
runApplication blockMesh

# 2. Decompose for parallel run
runApplication decomposePar

# 3. Run solver in parallel with 6 processors
mpirun -np 6 nonNewtonianIcoFoam -parallel > log.solver

# 4. Reconstruct fields
runApplication reconstructPar

# 5. Create an empty file to mark completion
touch result.foam

echo "--------------------------------------"
echo "Simulation finished. Result ready in result.foam"
echo "--------------------------------------"
