#!/bin/bash

###################################
## Dune simulation
###################################

## remove all previously generated files
#./clean -f
./clean

## make an archive from the sources
./dobackup


if [ ! -e genesis ]; then
  ln -s ../src/genesis .
fi
if [ ! -e rescal ]; then
  ln -s ../src/rescal .
fi

## parameters file (input)
#PAR_FILE="dun.par"
#PAR_FILE="dun_bar.par"
PAR_FILE="barchan.par"
#PAR_FILE="sandbed.par"
#PAR_FILE="dun_coarsening.par"
#PAR_FILE="dun_star.par"
#PAR_FILE="dun_col.par"
#PAR_FILE="dun_scale.par"
echo PAR_FILE=$PAR_FILE

### number of OpenMP threads
export OMP_NUM_THREADS=2
echo OMP_NUM_THREADS=$OMP_NUM_THREADS

## general log files (output)
GENESIS_LOG_FILE="GENESIS.log"
RESCAL_LOG_FILE="RESCAL.log"

## generation of binary cellular space 
## with python code
#./genesis.py -f $PAR_FILE > $GENESIS_LOG_FILE
## or with C code
./genesis -f $PAR_FILE -s 2000 > $GENESIS_LOG_FILE

## default execution using light shading, vertical cross sections together with velocity of the flow
nice ./rescal $PAR_FILE -cv0 -lc -ls 45 -vel >> $RESCAL_LOG_FILE

## execution with light shading, vertical and horizontal cross sections, velocity of the flow, and shear stress
#nice ./rescal $PAR_FILE -cv0 -lc -ch 20 -ls 45 -vel -vss >> $RESCAL_LOG_FILE

## generation of 100 PNG images and logs with delay in t0 unit
#nice ./rescal $PAR_FILE -cv0 -ls 45 -vel -vss -dlog 100t0 -dpng 100t0 -stop 10000t0 >> $RESCAL_LOG_FILE

## generation of 120 PNG images, a few CSP files and info logs, then stop after 30 minutes
#nice ./rescal $PAR_FILE -cv0 -lc -ch 20 -ls 45 -vel -vss -dlog 60 -dpng 15 -dcsp 5 -stop 30 >> $RESCAL_LOG_FILE

## plot probability function between shear stress and erosion
#./plot_cgv

