1 0 GfsAxi GfsBox GfsGEdge {} {
   Refine 5
   VariableTracerVOFHeight T
   PhysicalParams { alpha = 1./(T + 1e-2*(1. - T)) }
   VariableCurvature K T Kmax
   VariablePosition Y T y
   InitFraction T (0.2*(1. + 0.1*sin(M_PI*x)) - y)
   SourceTension T 1. K
#   SourceViscosity 1./20.*(T + 1e-2*(1. - T))

   AdaptGradient { istep = 1 } { maxlevel = 6 cmax = 0 } T
   AdaptFunction { istep = 1 } { 
       # adapt down to 14 levels to capture breakup asymptotics and
       # only 10 levels after breakup
       maxlevel = (t < 0.7455 ? 14 : 10)
       cmax = 0.2 
   } (T > 0 && T < 1)*Kmax*dL

   Time { end = 0.8 }

   OutputScalarStats { istep = 1 } p { v = P }
   # we need more precision for the time output
   OutputScalarStats { istep = 1 } y { v = Y format = "%10.6e" }
   OutputScalarStats { istep = 1 } k { v = K }
   OutputBalance { istep = 1 } balance
   OutputScalarSum { istep = 1 } ke { v = Velocity2*T }
   OutputScalarNorm { istep = 1 } u { v = U }
#   OutputSimulation { istep = 10 } stdout
  
   GModule gfsview
   OutputView { start = 0.6 istep = 5 end = 0.7455 } { 
       ppm2mpeg -s 640x480 > plateau.mpg 
   } { width = 1280 height = 960 } zoom.gfv
   OutputView { step = 0.2 } plateau-%g.eps { format = EPS } plateau.gfv
   OutputView { start = 0.7451 } plateau-t0.eps { format = EPS } plateau.gfv
   OutputView { start = 0.7451 } zoom-t0.eps { format = EPS } zoom.gfv

   EventScript { start = end } {
       # set t0 (breakup time) as the time for which the minimum
       # radius is smaller than the size of the finest cell: 1/2^14
       t0=`awk '{ if ($5 < 1./2.**14) { print $3; exit(0);} }' < y`
       rm -f fit.log
       gnuplot <<EOF
       set term postscript eps lw 3 20 color enhanced
       set key spacing 1.5
       set grid
       set output 'y.eps'
       set xlabel 't_0 - t'
       set ylabel 'r_{min}'
       set logscale
       fit [1e-6:1e-3] a*x**(2./3.) 'y' u ($t0 - \$3):5 via a
       plot [1e-6:][1./2**14:]'y' u ($t0 - \$3):5 ps 0.5 t '', a*x**(2./3.) t 'x^{2/3}'
EOF
       status=0
       if awk '{if ($1 == "rms" && (NF < 8 || $8 > 4e-5)) {
                  print "rmsy: " $8 > "/dev/stderr"; exit (1); 
               }}' < fit.log; then :
       else
	   status=$GFS_STOP;
       fi
       rm -f fit.log
       gnuplot <<EOF
       set term postscript eps lw 3 20 color enhanced
       set key spacing 1.5
       set grid
       set output 'u.eps'
       set xlabel 't_0 - t'
       set ylabel 'u_{max}'
       set logscale
       fit [1e-6:1e-3] a*x**(-1./3.) 'u' u ($t0 - \$3):9 via a
       plot [1e-6:]'u' u ($t0 - \$3):9 ps 0.5 t '', a*x**(-1./3.) t 'x^{-1/3}'
EOF
       if awk '{if ($1 == "rms" && (NF < 8 || $8 > 8.)) {
                  print "rmsu: " $8 > "/dev/stderr"; exit (1); 
               }}' < fit.log; then :
       else
	   status=$GFS_STOP;
       fi
       exit $status;
   }
}
GfsBox {
    bottom = Boundary
    left = Boundary
    right = Boundary
}