#!/bin/bash

# for i in ../Parallel/mglib/Test/grids/gr.2_*
#   do
#   echo $i
#   ./main.exe --test_set_mglib --test_set $i --test 0 --verbose 2
#   ./main.exe --test_set_mglib --test_set $i --test 0 --verbose 2 --bottom_solver 3
#   ./main.exe --test_set_mglib --test_set $i --test 0 --verbose 2 --bottom_solver 2
#   ./main.exe --test_set_mglib --test_set $i --test 0 --verbose 2 --bottom_solver 0
#   ./main.exe --test_set_mglib --test_set $i --test 1 --verbose 2
#   ./main.exe --test_set_mglib --test_set $i --test 2 --verbose 2
#   ./main.exe --test_set_mglib --test_set $i --test 3 --verbose 2
# done

estr='MG finished at
solution norm'

dim=${dim:-2}
nb=${nb:-32}
pdxyz=${pdxyz:-128}
mxiter=${mxiter:-20}

max_iter=100
((a=1))
while [[ $a -le $max_iter ]] ; do
  echo "Test $a, bottom solver 1"
  ./main.exe \
      --test_random_boxes \
      --dim $dim \
      --random_iseed $a \
      --pd_xyz $pdxyz   \
      --random_num_boxes $nb \
      --bottom_solver 1 \
      --max_iter $mxiter \
      | egrep "$estr"
  echo "Test $a, bottom solver 3"
  ./main.exe \
      --test_random_boxes \
      --dim $dim \
      --random_iseed $a \
      --pd_xyz $pdxyz \
      --random_num_boxes $nb \
      --bottom_solver 3  \
      --max_iter $mxiter \
      | egrep "$estr"
  ((a=a+1))
done
