#!/bin/bash

set -x

GEO_FILE=mesh_noncompatible.geo


for exp in 8 #8 9 10
do
  dir_name=mesh_${exp}
  mesh_step_2d=`echo  "scale=12; 1.0/2.0^$exp" |bc`
  mesh_step_1d=`echo "scale=12; 2.0/2.0^$exp" | bc`

  if test -d $dir_name ; then rm -r $dir_name; fi
  mkdir $dir_name 
  cd $dir_name
  cat ../$GEO_FILE | sed -e "/^h1=/s/.*/h1=$mesh_step_1d;/" | sed -e "/^h2=/s/.*/h2=$mesh_step_2d;/" > $GEO_FILE
  # 2d meshing algorithms: meshadapt, del2d, front2d
  gmsh -2  -algo del2d $GEO_FILE -o mesh.msh
  ~/workspace/flow123d/external_software/ngh-VV/bin/ngh ../ngh.ini
  #~/workspace/flow123d/external_software/ngh/bin/ngh ../ngh.ini
  #cat mesh_ngh.ngh | sed s/1[.]0/100.0/ >sigma_100.ngh  
  ~/workspace/flow123d/external_software/bcd/bin/bcd ../bcd.ini
  cd ..
done