1 0 GfsRiver GfsBox GfsGEdge {} {
PhysicalParams { L = 8. }
RefineSurface 9 (y - 8.*(0.5 - 1./512.))
InitMask {} (y < 8.*(0.5 - 1./512.))
Init {} {
Zb = x*x/8.+cos(M_PI*x)/2.
P = {
double p = x > 0. ? 0.35 : x < -2. ? 1.9 : -1.;
return MAX (0., p - Zb);
}
}
PhysicalParams { g = 1. }
AdvectionParams {
gradient = none
}
Time { end = 40 }
OutputProgress { istep = 10 } stderr
OutputScalarSum { istep = 10 } ke { v = (P > 0. ? U*U/P : 0.) }
OutputScalarSum { istep = 10 } vol { v = P }
OutputScalarNorm { istep = 10 } u { v = (P > 0. ? U/P : 0.) }
OutputSimulation { step = 0.3 } {
gfsplot "
load 'dam.plot'
set title sprintf('t = %4.1f', (t))
plot [-4.:4.]'-' u (x):(Zb):(H) w filledcu lc 3, \
'-' u (x):(Zb) w l lw 4 lc 1 lt 1
set term pngcairo size 800,600
set output sprintf('sim-%04.1f.png', (t))
replot
set term wxt noraise
"
} { format = text }
EventScript { start = end } {
echo "\rcreating animation... " > /dev/stderr
sleep 10
for f in sim-*.png; do
convert $f -trim +repage -bordercolor white \
-border 10 -resize 640x282! `basename $f .png`.gif && rm -f $f
done
gifsicle --colors 256 --optimize --delay 12 --loopcount=0 sim-*.gif > dam.gif && \
rm -f sim-*.gif
}
}
GfsBox {
left = Boundary
right = Boundary
}