[SCM] Gerris Flow Solver branch, upstream, updated. b3aa46814a06c9cb2912790b23916ffb44f1f203

Stephane Popinet popinet at users.sf.net
Fri May 15 02:55:33 UTC 2009


The following commit has been merged in the upstream branch:
commit dc9a928fad9d58849ad14ef6e120ee56c52e55d4
Author: Stephane Popinet <popinet at users.sf.net>
Date:   Sun Jun 8 03:16:39 2008 +1000

    New 'garden sprinkler effect' example for wave model
    
    darcs-hash:20080607171639-d4795-dadb5c2feae01f580488fce0f5b8e24a25f20f4d.gz

diff --git a/doc/examples/Makefile.am b/doc/examples/Makefile.am
index ac6fd4a..7fbf7b7 100644
--- a/doc/examples/Makefile.am
+++ b/doc/examples/Makefile.am
@@ -7,7 +7,8 @@ EXAMPLES = \
 	tangaroa \
 	logo \
 	tides \
-	ship
+	ship \
+	garden
 
 EXTRA_DIST = \
 	template.tex \
diff --git a/doc/examples/tides/tides.gfv b/doc/examples/garden/end.gfv
similarity index 72%
copy from doc/examples/tides/tides.gfv
copy to doc/examples/garden/end.gfv
index c886916..3690731 100644
--- a/doc/examples/tides/tides.gfv
+++ b/doc/examples/garden/end.gfv
@@ -1,25 +1,25 @@
-# GfsView 3D
+# GfsView 2D
 View {
   tx = 0 ty = 0
   sx = 1 sy = 1 sz = 1
   q0 = 0 q1 = 0 q2 = 0 q3 = 1
-  fov = 15.1811
+  fov = 24.9119
   r = 0.3 g = 0.4 b = 0.6
   res = 1
   lc = 0.001
   reactivity = 0.1
 }
-Linear {
+Isoline {
   r = 0 g = 0 b = 0
   shading = Constant
   maxlevel = -1
 } {
   n.x = 0 n.y = 0 n.z = 1
-  pos = -0.5
-} P*5000./19.62 {
+  pos = 0
+} Hs {
   amin = 1
   amax = 1
   cmap = Jet
 } {
-  scale = 0
+  n = 0 levels = .1,.2,.3,.4,.5,.6,.7,.8,.9,1
 }
diff --git a/doc/examples/garden/garden.gfs b/doc/examples/garden/garden.gfs
new file mode 100644
index 0000000..e3c1b52
--- /dev/null
+++ b/doc/examples/garden/garden.gfs
@@ -0,0 +1,122 @@
+# Title: "Garden sprinkler effect" in wave model
+#
+# Description:
+#
+# The wave model is used to reproduce the classical "Garden Sprinkler
+# Effect" (GSE), a numerical artifact of the discrete directions of
+# wave propagation (see Tolman, 2002).
+#
+# A spatially-Gaussian wave spectrum is initialised in a 5000
+# km-squared domain. The other parameters are those of Tolman, 2002.
+#
+# The final (t = 5 days) significant wave height for different model
+# runs is illustrated in Figure \ref{end}. The interval between the
+# isolines is 0.1 metres as in Figure 1 of Tolman, 2002. For a small
+# number of discrete directions (24), the GSE is evident and the
+# results closely match those of Tolman both for the constant
+# resolution and the adaptive version of the code. For larger number
+# of directions (60 and 120), the results do not show any obvious GSE
+# and match the corresponding results of Tolman (Figure 1.b of Tolman,
+# 2002 but note that the spatial resolution of Tolman is finer, 25 km
+# rather than 78 km here).
+#
+# \begin{figure}[htbp]
+# \caption{\label{end}Final (t = 5 days) significant wave height for
+# different model runs.}
+# \begin{center}
+# \includegraphics[width=\hsize]{end.eps}
+# \end{center}
+# \end{figure}
+#
+# The evolution in time of the significant wave height together with
+# the corresponding adaptive discretisation is illustrated in Figure
+# \ref{mesh} for 120 directions. The mesh is adapted according to the
+# spatial gradient in the significant wave height. This results in
+# substantial savings in computational cost as illustrated by the
+# timings given in Table \ref{cpu}. The computational cost with 120
+# directions is comparable to the cost with 24 directions on a regular
+# (i.e. non-adaptive) mesh. This demonstrates that the GSE can be
+# alleviated -- at comparable computational cost -- by combining
+# adaptive refinement with a refined discretisation in direction
+# space.
+#
+# \begin{figure}[htbp]
+# \caption{\label{mesh}Evolution of the significant wave height and
+# adaptive mesh. 120 directions.}
+# \begin{center}
+# \includegraphics[width=\hsize]{mesh.eps}
+# \end{center}
+# \end{figure}
+#
+# \begin{table}[htbp]
+# \caption{\label{cpu}CPU time for the four models of Figure \ref{end}.}
+# \begin{center}
+# \input{cpu.tex}
+# \end{center}
+# \end{table}
+#
+# Author: St\'ephane Popinet
+# Command: sh garden.sh
+# Version: 1.2.1
+# Required files: garden.sh end.gfv mesh.gfv
+# Running time: 41 minutes
+# Generated files: end.eps mesh.eps cpu.tex
+#
+1 0 GfsWave GfsBox GfsGEdge {} {
+    Refine 6
+    Time { end = 120 }
+
+    # Define some useful functions
+    Global {
+        /* gaussian distribution */
+        static double gaussian (double f, double fmean, double fsigma) {
+            return exp (-((f - fmean)*(f - fmean))/(fsigma*fsigma));
+        }
+        /* cos(theta)^n distribution */
+        static double costheta (double theta, double thetam, double thetapower) {
+            double a = cos (theta - thetam);
+            return a > 0. ? pow (a, thetapower) : 0.;
+        }
+    }
+
+    # Initialise the wave spectrum
+    InitWave {} {
+        /* This function defines the spectral distribution:
+         * a gaussian in frequency space and 
+         * a cos(theta)^2 distribution in direction space 
+         *
+         * Note: for some reason Tolman (2002) uses a factor of 0.125 
+         * for the Gaussian distribution "spread" */
+        return gaussian (Frequency, 0.1, 0.01/sqrt(0.125))*
+               costheta (Direction, 30.*M_PI/180., 2.);
+    } {
+        /* This function defines the significant wave height:
+         * the energy is a gaussian bump in (x,y) space,
+         * the maximum significant wave height is 2.5 
+         *
+         * Note: for some reason Tolman (2002) uses a factor of 0.5
+         * for the Gaussian distribution "spread" */
+        x -= -0.5 + 500./5000.;
+        y -= -0.5 + 500./5000.;
+        double Hsmax = 2.5;
+        double E = (Hsmax*Hsmax/16.)*gaussian (sqrt (x*x + y*y), 0., 150./5000./sqrt(0.5));
+        return 4.*sqrt (E);
+    }
+
+    AdaptGradient { istep = 1 } { cmax = 0.04 minlevel = MINLEVEL maxlevel = 6 } Hs
+
+    OutputTime { istep = 1 } log-MINLEVEL-NTHETA
+    OutputScalarStats { step = 12 } hs-MINLEVEL-NTHETA { v = Hs }
+    OutputSimulation { step = 12 } sim-MINLEVEL-NTHETA-%g.gfs
+    OutputSimulation { start = end } end-MINLEVEL-NTHETA.gfs    
+    OutputPPM { step = 12 } { ppm2mpeg > hs-MINLEVEL-NTHETA.mpg } { v = Hs maxlevel = 7 }
+} {
+    # Number of discretised directions (default is 24)
+    ntheta = NTHETA
+}
+GfsBox {
+    top = Boundary
+    bottom = Boundary
+    left = Boundary
+    right = Boundary
+}
diff --git a/doc/examples/garden/garden.sh b/doc/examples/garden/garden.sh
new file mode 100755
index 0000000..89b3b10
--- /dev/null
+++ b/doc/examples/garden/garden.sh
@@ -0,0 +1,79 @@
+#!/bin/sh
+
+if  gerris2D -DMINLEVEL=6 -DNTHETA=24  garden.gfs &&
+    gerris2D -DMINLEVEL=0 -DNTHETA=24  garden.gfs &&
+    gerris2D -DMINLEVEL=0 -DNTHETA=60  garden.gfs &&
+    gerris2D -DMINLEVEL=0 -DNTHETA=120 garden.gfs; then :
+else
+    exit 1
+fi
+
+for i in 6-24 0-24 0-60 0-120; do
+    echo "Save end-$i.gnu { format = Gnuplot }" | gfsview-batch2D end-$i.gfs end.gfv
+done
+
+for i in 0 24 72 120; do
+    echo "Save mesh-$i.gnu { format = Gnuplot }" | gfsview-batch2D sim-0-120-$i.gfs mesh.gfv
+done
+
+cat <<EOF | gnuplot
+set term postscript eps lw 1 solid 10
+
+set output 'end.eps'
+set multiplot
+set size 0.5,0.5
+set origin 0,0.5
+unset key
+set xtics 0,1000,4000
+set ytics 0,1000,3000
+set title 'Non-adaptive 24 directions'
+plot [-500:4000][-500:3000]'end-6-24.gnu' u (\$1*5000.+2000.):(\$2*5000.+2000.) w l
+set origin 0.5,0.5
+set title 'Adaptive 24 directions'
+plot [-500:4000][-500:3000]'end-0-24.gnu' u (\$1*5000.+2000.):(\$2*5000.+2000.) w l
+set origin 0,0
+set title 'Adaptive 60 directions'
+plot [-500:4000][-500:3000]'end-0-60.gnu' u (\$1*5000.+2000.):(\$2*5000.+2000.) w l
+set origin 0.5,0
+set title 'Adaptive 120 directions'
+plot [-500:4000][-500:3000]'end-0-120.gnu' u (\$1*5000.+2000.):(\$2*5000.+2000.) w l
+unset multiplot
+
+set output 'mesh.eps'
+set size 1,1
+set origin 0,0
+set multiplot
+set size 0.5,0.5
+set origin 0,0.5
+unset key
+set xtics 0,1000,4000
+set ytics 0,1000,3000
+set title 't = 0'
+plot [-500:4000][-500:3000]'mesh-0.gnu' u (\$1*5000.+2000.):(\$2*5000.+2000.) w l
+set origin 0.5,0.5
+set title 't = 1 day'
+plot [-500:4000][-500:3000]'mesh-24.gnu' u (\$1*5000.+2000.):(\$2*5000.+2000.) w l
+set origin 0,0
+set title 't = 3 days'
+plot [-500:4000][-500:3000]'mesh-72.gnu' u (\$1*5000.+2000.):(\$2*5000.+2000.) w l
+set origin 0.5,0
+set title 't = 5 days'
+plot [-500:4000][-500:3000]'mesh-120.gnu' u (\$1*5000.+2000.):(\$2*5000.+2000.) w l
+unset multiplot
+
+EOF
+
+cpu_6_24=`awk '{cpu=$8}END{printf ("%.0f", cpu);}' < log-6-24`
+cpu_0_24=`awk '{cpu=$8}END{printf ("%.0f", cpu);}' < log-0-24`
+cpu_0_60=`awk '{cpu=$8}END{printf ("%.0f", cpu);}' < log-0-60`
+cpu_0_120=`awk '{cpu=$8}END{printf ("%.0f", cpu);}' < log-0-120`
+
+cat <<EOF > cpu.tex
+\\begin{tabular}{c|c|c}
+Adaptivity & \\# directions & CPU time (seconds)\\\\\\hline
+No & 24 & $cpu_6_24 \\\\
+Yes & 24 & $cpu_0_24 \\\\
+Yes & 60 & $cpu_0_60 \\\\
+Yes & 120 & $cpu_0_120
+\\end{tabular}
+EOF
diff --git a/test/shear/curvature/curvature.gfv b/doc/examples/garden/mesh.gfv
similarity index 76%
copy from test/shear/curvature/curvature.gfv
copy to doc/examples/garden/mesh.gfv
index d4439d2..d95cdcc 100644
--- a/test/shear/curvature/curvature.gfv
+++ b/doc/examples/garden/mesh.gfv
@@ -4,32 +4,30 @@ View {
   sx = 1 sy = 1 sz = 1
   q0 = 0 q1 = 0 q2 = 0 q3 = 1
   fov = 24.9119
-  r = 1 g = 1 b = 1
+  r = 0.3 g = 0.4 b = 0.6
   res = 1
   lc = 0.001
   reactivity = 0.1
 }
-Cells {
+Isoline {
   r = 0 g = 0 b = 0
   shading = Constant
   maxlevel = -1
 } {
   n.x = 0 n.y = 0 n.z = 1
   pos = 0
+} Hs {
+  amin = 1
+  amax = 1
+  cmap = Jet
+} {
+  n = 7
 }
-VOF {
-  r = 0.010071 g = 0 b = 1
+Cells {
+  r = 0 g = 0 b = 0
   shading = Constant
   maxlevel = -1
 } {
   n.x = 0 n.y = 0 n.z = 1
   pos = 0
-} P {
-  amin = 1
-  amax = 1
-  cmap = Jet
-} T {
-  reversed = 0
-  use_scalar = 0
-  draw_edges = 0
 }
diff --git a/doc/examples/template.tex b/doc/examples/template.tex
index 8053f13..4b18d68 100644
--- a/doc/examples/template.tex
+++ b/doc/examples/template.tex
@@ -60,6 +60,10 @@ The usefulness and quality of this document very much depend on the contribution
 
 \input{tides/tides.tex}
 
+\section{Waves}
+
+\input{garden/garden.tex}
+
 \section{\label{howto}How to write examples}
 
 This document is generated automatically using self-documenting Gerris parameter files. If you look at \htmladdnormallinkfoot{any}{cylinder/cylinder.gfs} of the {\tt .gfs} files in this document you will see that apart from comments on specific instructions, the top of the file contains fields which describe the simulation. They are:

-- 
Gerris Flow Solver



More information about the debian-science-commits mailing list