#!/bin/bash

# Make a flow solver directory
mkdir -p solver/

# Change to the solver directory
cd solver/

# Symbollically link required files
ln -sf ../connectivity/grid.x.ihc
ln -sf ../connectivity/INTOUT
ln -sf ../meshes/grid.bc
ln -sf ../meshes/grid.b2b
ln -sf ../input/solver.yaml

# Set the number of OpenMP threads before running
OMP_NUM_THREADS_0=${OMP_NUM_THREADS}
export OMP_NUM_THREADS=8

# Run the flow solver by providing an input file
# 'solver.yaml' and output the results to a 
# file called 'solver.out'
mpiexec -np 4 --bind-to none lavacurv.3D.NS1.AVX2 solver.yaml | tee solver.out

# Reset the number of OpenMP threads after running
export OMP_NUM_THREADS=${OMP_NUM_THREADS_0}

# Return to the original directory
cd ../
