File: harmonic.sh

package info (click to toggle)
gerris 20131206%2Bdfsg-21
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 14,252 kB
  • sloc: ansic: 66,595; sh: 15,922; f90: 1,513; makefile: 1,150; fortran: 696; python: 493; awk: 104; lisp: 89; xml: 27
file content (107 lines) | stat: -rw-r--r-- 3,038 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
if test x$donotrun != xtrue; then
    rm -f error
    for solver in gerris; do
	rm -f time proj

	if test x$solver = xhypre; then
	    gmodule=GModule
	else
	    gmodule="# GModule"
	fi
   
	for cycle in 0 1 2 3 4 5 6 7 8 9 10 ; do
	    if ( sed "s/GModule/$gmodule/" < $1 | \
                 gerris2D -DLEVEL=8 -DCYCLE=$cycle -DSOLVER=$solver - ) ; then :
	    else
		exit 1
	    fi     
	done
	join time proj | awk '{
          if (NR == 1) {print $0; old = $3} 
          else {print $1,$2,$3,old/$3; old=$3}}' > res-7
	rm -f error order proj time runtime status
	for level in 3 4 5 6 7 8; do
	    if ( sed "s/GModule/$gmodule/" < $1 | \
		 gerris2D -DLEVEL=$level -DCYCLE=10 -DSOLVER=$solver - ) ; then :
	    else
		exit 1
	    fi
	done
	
	if awk 'BEGIN { n = 0 }
                {
		    l[n] = $1; n1[n] = $2; n2[n] = $3; ni[n++] = $4;
		}
                END {
		    for (i = 1; i < n; i++)
			print l[i] " " log(n1[i-1]/n1[i])/log(2.) " " log(n2[i-1]/n2[i])/log(2.) " " log(ni[i-1]/ni[i])/log(2.);
		}' < error > order-$solver; then :
	else
	    exit 1
	fi
	mv res-7 res-7-$solver
	mv error error-$solver
    done
fi

if echo "Save gerris.eps { format = EPS }" | gfsview-batch2D end-gerris-8.gfs gerris.gfv; then :
else
    exit 1
fi

if gnuplot <<EOF ; then :
    set term postscript eps color lw 3 solid 20
    set output 'residual.eps'
    set xlabel 'CPU time'
    set ylabel 'Maximum residual'
    set logscale y
    plot 'res-7.ref' u 2:3 t 'Ref' w lp, \
	'res-7-gerris' u 2:3 t 'Gerris' w lp
    set output 'rate.eps'
    set xlabel 'V-cycle'
    set ylabel 'Cumulative residual reduction factor'
    unset logscale
    plot 'res-7.ref' u 1:4 t 'Ref' w lp, \
	'res-7-gerris' u 1:4 t 'Gerris' w lp
    set output 'error.eps'
    set xlabel 'Level'
    set ylabel 'Error norms'
    set key
    set logscale y
    plot [][:1]'error.ref' u 1:2 t '1 (ref)' w lp, \
         'error.ref' u 1:3 t '2 (ref)' w lp, \
         'error.ref' u 1:4 t 'max (ref)' w lp, \
         'error-gerris' u 1:2 t '1 Gerris' w lp, \
         'error-gerris' u 1:3 t '2 Gerris' w lp, \
         'error-gerris' u 1:4 t 'max Gerris' w lp
    set output 'order.eps'
    set xlabel 'Level'
    set ylabel 'Order'
    set key bottom
    unset logscale
    set xtics 0,1
    set ytics 0,1
    set grid
    plot [][0:3] 'order.ref' u 1:2 t '1 (ref)' w lp, \
                 'order.ref' u 1:3 t '2 (ref)' w lp, \
                 'order.ref' u 1:4 t 'max (ref)' w lp, \
                 'order-gerris' u 1:2 t '1 Gerris' w lp, \
                 'order-gerris' u 1:3 t '2 Gerris' w lp, \
                 'order-gerris' u 1:4 t 'max Gerris' w lp
EOF
else
    exit 1
fi

if cat <<EOF | python3 ; then :
from check import *
from sys import *
if (Curve('res-7-gerris',1,3) - Curve('res-7.ref',1,3)).max() > 1e-8 or\
   (Curve('error-gerris',1,4) - Curve('error.ref',1,4)).max() > 1e-6:
    print((Curve('res-7-gerris',1,3) - Curve('res-7.ref',1,3)).max())
    print((Curve('error-gerris',1,4) - Curve('error.ref',1,4)).max())
    exit(1)
EOF
else
   exit 1
fi