#!/bin/bash

# Check if the mesh file (mesh.msh) exists
if [ ! -f mesh.msh ]; then
    echo "Error: The mesh file 'mesh.msh' not found!"
    exit 1
fi

# Convert the Fluent mesh to OpenFOAM format
fluentMeshToFoam mesh.msh

# Run the simulation in parallel and use pyFoamPlotRunner to generate plots
pyFoamPlotRunner.py simpleFoam 

# Create the 'pyfoam' directory if it doesn't exist
mkdir -p pyfoam

# Move files starting with 'PyFoam' to the 'pyfoam' directory
mv PyFoam* pyfoam/ 2>/dev/null

# Move the 'Gnuplotting.analyzed' folder to the 'pyfoam' directory
mv Gnu* pyfoam/ 2>/dev/null

# Run parafoam
paraFoam
