#!/bin/bash

#GRID_SIZES="0897"
GRID_SIZES="0008 0015 0029 0057 0113 0225 0449"
#GRID_SIZES="1793"

dimensions=2

size=2

time=3

for grid_size in $GRID_SIZES;

do

	rm -r grid-${grid_size}
   	mkdir grid-${grid_size}
   	cd grid-${grid_size}

	tnl-grid-setup --dimensions $dimensions \
	               --origin-x -1.0 \
	               --origin-y -1.0 \
	               --origin-z -1.0 \
	               --proportions-x $size \
	               --proportions-y $size \
	               --proportions-z $size \
	               --size-x ${grid_size} \
	               --size-y ${grid_size} \
	               --size-z ${grid_size}

	tnl-init --test-function sdf-para \
		     --offset 0.25 \
	             --output-file init.tnl \
		     --final-time 0.0 \
		     --snapshot-period 0.1 \


	tnl-init --test-function sdf-para-sdf \
		     --offset 0.25 \
	             --output-file sdf.tnl \
		     --final-time 0.0 \
		     --snapshot-period 0.1

	hamilton-jacobi-parallel --initial-condition init.tnl \
	              --cfl-condition 1.0e-1 \
		      	  --mesh mesh.tnl \
		     	  --initial-tau 1.0e-3 \
		      	  --epsilon 1.0 \
	        	  --delta 0.0 \
	       	      --stop-time $time \
		          --scheme godunov \
		          --subgrid-size 8

        tnl-diff --mesh mesh.tnl --mode sequence --input-files sdf.tnl u-00001.tnl --write-difference yes --output-file ../${grid_size}.diff
	
	cd ..

done


./tnl-err2eoc-2.py --format txt --size $size *.diff

              
