From bd877ccc1c0f0ce9f363396d51615f6baa2699b1 Mon Sep 17 00:00:00 2001 From: Ned Coltman Date: Mon, 26 Nov 2018 13:39:07 +0100 Subject: [PATCH 1/2] [freeflow] cleanup convergence script --- test/freeflow/navierstokes/convergence.sh | 53 ++++++++++++++--------- 1 file changed, 33 insertions(+), 20 deletions(-) diff --git a/test/freeflow/navierstokes/convergence.sh b/test/freeflow/navierstokes/convergence.sh index 945249cbff..353de4baf5 100755 --- a/test/freeflow/navierstokes/convergence.sh +++ b/test/freeflow/navierstokes/convergence.sh @@ -1,7 +1,7 @@ #! /bin/bash -if [ $# -ne 3 ]; then - echo "usage: $0 EXECUTABLE_NAME DIMENSION NUM_REFINEMENT_STEPS" +if [ $# -ne 4 ]; then + echo "usage: $0 EXECUTABLE_NAME PARAMS DIMENSION NUM_REFINEMENT_STEPS" exit fi @@ -11,34 +11,47 @@ LOGFILE=logfile_$1.out rm $LOGFILE L2ERRORFILE=l2error_$1.txt -if [ $2 == 1 ]; then -GRIDCELLS="4" -elif [ $2 == 2 ]; then -GRIDCELLS="4 4" +DIM=$3 +INITIALCELLS=4 + +if [ $DIM == 1 ]; then +GRIDCELLS="$INITIALCELLS" +elif [ $DIM == 2 ]; then +GRIDCELLS="$INITIALCELLS $INITIALCELLS" else -GRIDCELLS="4 4 4" +GRIDCELLS="$INITIALCELLS $INITIALCELLS $INITIALCELLS" fi -MAX=$3 +MAX=$4 +MAXCELLS=$INITIALCELLS for (( i=0; i <= $MAX; ++i )); do printf "refinement $i / $MAX " - ./$1 $1.input -Grid.Cells "$GRIDCELLS" -Grid.Refinement $i -Problem.PrintL2Error true &>> $LOGFILE + ((MAXCELLS *=2)) + ./$1 params.input -Grid.Cells "$GRIDCELLS" -Grid.Refinement $i -Problem.PrintL2Error true &>> $LOGFILE echo "done." done grep "L2 error (abs/rel) for" $LOGFILE | tee $L2ERRORFILE -echo "reset; \ -set log x; \ -set log y; \ -set arrow from graph 0,1 to graph 1,0 nohead lc rgb 'gray'; \ -set arrow from graph 0,1 to graph 1,0.5 nohead lc rgb 'gray'" > $1.gp - -PLOT="plot '$L2ERRORFILE' u 6:17 w lp t 'pressure', '$L2ERRORFILE' u 6:23 w lp t 'velocity'" -if [ $2 == 2 ]; then -PLOT=$PLOT", '$L2ERRORFILE' u 6:29 w lp t 'velocity'" -elif [ $2 == 3 ]; then -PLOT=$PLOT", '$L2ERRORFILE' u 6:35 w lp t 'velocity'" +echo "reset +set terminal pngcairo size 1000,750 +set output 'convergence.png' +set xrange [($INITIALCELLS-1):$MAXCELLS] +set yrange [:1] +set xlabel 'number of cells per dimension' +set ylabel 'l2 error (abs)' +set log x +set log y" > $1.gp + +PLOT="plot x**-1 w l lc rgb 'gray40' t 'O_1', \ +x**-2 w l lc rgb 'blue20' t 'O_2', \ +'$L2ERRORFILE' u (\$6**(1./$DIM.)):17 w lp t 'pressure', \ +'$L2ERRORFILE' u (\$6**(1./$DIM.)):23 w lp t 'velocity_x'" +if [ $DIM == 2 ]; then +PLOT=$PLOT", '$L2ERRORFILE' u (\$6**(1./$DIM.)):29 w lp t 'velocity_y'" +elif [ $DIM == 3 ]; then +PLOT=$PLOT", '$L2ERRORFILE' u (\$6**(1./$DIM.)):29 w lp t 'velocity_y', '$L2ERRORFILE' u (\$6**(1./$DIM.)):35 w lp t 'velocity_z'" fi echo $PLOT >> $1.gp gnuplot --persist $1.gp +eog convergence.png -- GitLab From f8931fae2fe21f14fe21d28e4e9eb1a932d92004 Mon Sep 17 00:00:00 2001 From: Melanie Lipp Date: Mon, 26 Nov 2018 21:44:15 +0100 Subject: [PATCH 2/2] [freeflow] further cleanup convergence script. --- test/freeflow/navierstokes/convergence.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/test/freeflow/navierstokes/convergence.sh b/test/freeflow/navierstokes/convergence.sh index 353de4baf5..03c64a04f2 100755 --- a/test/freeflow/navierstokes/convergence.sh +++ b/test/freeflow/navierstokes/convergence.sh @@ -1,4 +1,5 @@ #! /bin/bash +# usage: build the executable in the build directory, copy the file to the folder with the executable, an example command to run the script is ./convergence.sh test_ff_stokes_donea ./params.input 2 4 if [ $# -ne 4 ]; then echo "usage: $0 EXECUTABLE_NAME PARAMS DIMENSION NUM_REFINEMENT_STEPS" @@ -27,7 +28,7 @@ MAXCELLS=$INITIALCELLS for (( i=0; i <= $MAX; ++i )); do printf "refinement $i / $MAX " ((MAXCELLS *=2)) - ./$1 params.input -Grid.Cells "$GRIDCELLS" -Grid.Refinement $i -Problem.PrintL2Error true &>> $LOGFILE + ./$1 $2 -Grid.Cells "$GRIDCELLS" -Grid.Refinement $i -Problem.PrintL2Error true &>> $LOGFILE echo "done." done @@ -37,13 +38,15 @@ set terminal pngcairo size 1000,750 set output 'convergence.png' set xrange [($INITIALCELLS-1):$MAXCELLS] set yrange [:1] +set format x '10^{%L}' +set format y '10^{%L}' set xlabel 'number of cells per dimension' -set ylabel 'l2 error (abs)' +set ylabel 'abs(l2 error)' set log x set log y" > $1.gp -PLOT="plot x**-1 w l lc rgb 'gray40' t 'O_1', \ -x**-2 w l lc rgb 'blue20' t 'O_2', \ +PLOT="plot x**-1 w l lc rgb 'gray40' t 'order_1', \ +x**-2 w l lc rgb 'blue20' t 'order_2', \ '$L2ERRORFILE' u (\$6**(1./$DIM.)):17 w lp t 'pressure', \ '$L2ERRORFILE' u (\$6**(1./$DIM.)):23 w lp t 'velocity_x'" if [ $DIM == 2 ]; then -- GitLab