#!/bin/bash

# Define the available velocities
VELOCITIES=("0.1" "0.5" "1" "2.5")

# Ask for the velocity
read -p "Which velocity? (Choose from 0.1, 0.5, 1, 2.5): " velocity

# Check if the entered velocity is valid
if [[ ! " ${VELOCITIES[@]} " =~ " $velocity " ]]; then
  echo "Invalid velocity. Please choose from 0.1, 0.5, 1, 2.5."
  exit 1
fi

# Define the available fluids
FLUIDS=("blood" "crude_oil" "printer_ink" "water" "xanthan" "cellulose")

# Ask for the fluid
read -p "Which fluid do you want to select? (Choose from blood, crude_oil, printer_ink, water, xanthan, cellulose): " fluid

# Check if the entered fluid is valid
if [[ ! " ${FLUIDS[@]} " =~ " $fluid " ]]; then
  echo "Invalid fluid selection. Please choose from blood, crude_oil, printer_ink, water, xanthan, cellulose."
  exit 1
fi

# Redirect to the desired folder and execute Allrun
selected_folder="./$velocity/$fluid"
if [ -d "$selected_folder" ]; then
    echo "Executing Allrun in $selected_folder ..."
    cd "$selected_folder"
    ./Allrun
    echo "Allrun executed successfully."
else
    echo "Selected folder does not exist: $selected_folder"
    exit 1
fi

