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

Stephane Popinet s.popinet at niwa.co.nz
Fri May 15 02:51:59 UTC 2009


The following commit has been merged in the upstream branch:
commit aec6047ea65b3c62c4c24469b72458c8e691ce09
Author: Stephane Popinet <s.popinet at niwa.co.nz>
Date:   Tue Jun 14 16:23:15 2005 +1000

    Auto-documented Euler test cases replace old-style tests
    
    Only the equivalent test cases for reference2D/stationary1.xmgr and
    reference2D/stationary4box1.xmgr have been implemented at this point.
    
    darcs-hash:20050614062315-fbd8f-824b83fa9027c7ecdc3ddcb2691549fecf0928c8.gz

diff --git a/doc/examples/Makefile.am b/doc/examples/Makefile.am
index b2bd819..5c32368 100644
--- a/doc/examples/Makefile.am
+++ b/doc/examples/Makefile.am
@@ -12,6 +12,7 @@ EXTRA_DIST = \
 	gfs2tex \
 	depend.py \
 	test.py \
+	l2hconf.pm \
 	Makefile.deps
 
 TESTS = test.sh
@@ -35,7 +36,7 @@ gfs2doc: gfs2doc.in
 clean-generic:
 	$(RM) *.dvi *.aux *.log *.toc *.out examples.tex *.pyc test.sh gfs2doc
 
-examples: examples.ps.gz
+examples: examples.ps.gz l2hconf.pm
 	latex2html -no_math -html_version 3.2,math -address "" -info "" -split +3 -show_section_numbers -toc_depth 5 -t "Gerris Examples" -local_icons -white examples.tex
 	cp -f ../share/darcs.css examples/examples.css
 
@@ -58,7 +59,7 @@ examples.tex: template.tex Makefile.deps
 	python gfs2tex $(EXAMPLES)
 	sed "s/GFS_VERSION/`$(top_srcdir)/src/gerris2D -V 2>&1 | awk '{ if ($$5 == "version") print $$6}'`/g" < template.tex > examples.tex
 
-Makefile.deps: Makefile.am
+Makefile.deps: Makefile.am depend.py
 	python depend.py $(EXAMPLES) > Makefile.deps
 
 -include Makefile.deps
diff --git a/doc/examples/gfs2tex.py b/doc/examples/gfs2tex.py
index 7a06ee2..2ca81aa 100644
--- a/doc/examples/gfs2tex.py
+++ b/doc/examples/gfs2tex.py
@@ -55,10 +55,14 @@ class Example:
         else:
             self.path += "/" + self.name
         self.section = ["\\subsection","\\subsubsection"][self.path.count("/")]
-        name = self.path + "/" + self.name + ".gfs"
-        file = open(name)
+        file = open(self.path + "/" + self.name + ".gfs")
         lines = file.readlines()
         self.generated = generated(lines)
+        if os.access(self.path + "/status", os.R_OK):
+            self.status = open(self.path + "/status").readline()
+            self.generated.append("status")
+        else:
+            self.status = None
         p = re.compile(r"\\label\{[a-zA-Z0-9_\-]*\}")
         labels = []
         for line in lines:
@@ -108,11 +112,27 @@ class Example:
                         insthg.append(" ".join(record[1:]))
                 elif not insthg == None:
                     insthg.append(" ".join(record[1:]))
+
+        if os.access(self.path + "/runtime", os.R_OK):
+            self.runtime = float(open(self.path + "/runtime").readline())
+            self.time = ""
+            m = int(self.runtime/60.)
+            if m > 0:
+                self.time += repr(m) + " minutes"
+            s = int(self.runtime-60.*m)
+            if s > 0:
+                self.time += " " + repr(s) + " seconds"
+            self.generated.append("runtime")
+        else:
+            self.runtime = None
             
     def write(self,dico,file=None):
         if file == None:
             file = open(self.path + "/" + self.name + ".tex", 'w')
-        file.write(self.section + "{" + "\n".join(self.title) + "}\n")
+        if self.status:
+            file.write(self.section + "{" + self.status + "\n".join(self.title) + "}\n")
+        else:
+            file.write(self.section + "{" + "\n".join(self.title) + "}\n")
         file.write("\\begin{description}\n")
         file.write("\\item[Author]" + self.author + "\n")
         file.write("\\item[Command]" + "{\\tt " + self.command + "}\n")
@@ -207,3 +227,23 @@ class Example:
             return status,lines
         else:
             return None,None
+
+    def run(self,env=""):
+        out = os.popen("cd " + self.path + " && " +\
+                       "sh -c \"time -p " + env + self.command + "\" 2>&1")
+        lines = []
+        for l in out:
+            record = l.split()
+            if len(record) > 0:
+                if record[0] == "user":
+                    self.runtime = float(record[1])
+                    print >>open(self.path + "/runtime",'w'), self.runtime
+                elif record[0] != "real" and record[0] != "sys":
+                    lines.append(l)
+            else:
+                lines.append(l)
+        status = out.close()
+        if status != None:
+            return status,lines
+        else:
+            return None,None
diff --git a/doc/examples/template.tex b/doc/examples/template.tex
index 9353f38..1a0ed90 100644
--- a/doc/examples/template.tex
+++ b/doc/examples/template.tex
@@ -17,9 +17,9 @@
 \mbox{}\vspace{1cm}
 \begin{center}
 {\huge Gerris examples}\\
-{\large Version 0.6.4}\\
+{\large Version GFS_VERSION}\\
 \vspace{5mm}
-{\large St\'ephane Popinet
+{\large St\'ephane Popinet\\
 \vspace{5mm}
 \today}
 \vspace{1cm}
diff --git a/test/euler/Makefile.am b/test/euler/Makefile.am
index 2f7de33..c3d08d3 100644
--- a/test/euler/Makefile.am
+++ b/test/euler/Makefile.am
@@ -1,34 +1,49 @@
 ## Process this file with automake to produce Makefile.in
 
-INCLUDES = -I$(top_srcdir)/src -I$(includedir) -DG_LOG_DOMAIN=\"Gfs-test\"\
-            $(GTS_CFLAGS)
-LDADD = $(GFS2D_LIBS)
-CFLAGS += -DFTT_2D=1
+TESTDIRS = \
+	reynolds
 
 EXTRA_DIST = \
-	reference2D \
-	parameters \
-	scripts
+	template.tex \
+	depend.py \
+	test.py \
+	gfs2tex \
+	l2hconf.pm \
+	Makefile.deps
 
-REFERENCE = reference2D
+TESTS = test.sh
 
-test.sh:
-	@echo "#! /bin/sh" > test.sh
-	@echo "rm -f report.ps" >> test.sh
-	@echo "./scripts/check.sh \"$(REFERENCE)/*\"" >> test.sh
+test.sh: $(TESTDIRS)
+	@echo "python test.py $(TESTDIRS)" > test.sh
 	@chmod +x test.sh
 
-report.ps: scripts/report.sh timestamp
-	./scripts/report.sh "$(REFERENCE)/*"
-
 clean-generic:
-	./scripts/cleanup.sh
+	$(RM) *.dvi *.aux *.log *.toc *.out tests.tex *.pyc test.sh
+
+tests: tests.ps.gz l2hconf.pm
+	latex2html -no_math -html_version 3.2,math -address "" -info "" -split +3 -show_section_numbers -toc_depth 5 -t "Gerris Tests" -local_icons -white tests.tex
+	cp -f ../../doc/share/darcs.css tests/tests.css
+
+tests.dvi: tests.tex
+	latex -interaction=nonstopmode tests.tex > /dev/null 2>&1
+	latex -interaction=nonstopmode tests.tex > /dev/null 2>&1
+	latex -interaction=nonstopmode tests.tex
+
+tests.ps.gz: tests.dvi
+	dvips tests.dvi -o tests.ps
+	gzip -f --best tests.ps
+
+tests.pdf: tests.dvi
+	dvips -Ppdf -G0 tests.dvi -o tests.ps
+	ps2pdf -sPAPERSIZE=a4 -dMaxSubsetPct=100 -dCompatibilityLevel=1.2 -dSubsetFonts=true -dEmbedAllFonts=true tests.ps tests.pdf
+	rm -f tests.ps
+
+tests.tex: template.tex Makefile.deps
+	rm -r -f tests
+	python gfs2tex $(TESTDIRS)
+	sed "s/GFS_VERSION/`$(top_srcdir)/src/gerris2D -V 2>&1 | awk '{ if ($$5 == "version") print $$6}'`/g" < template.tex > tests.tex
 
-dist-hook:
-	./scripts/cleanup.sh
+Makefile.deps: Makefile.am depend.py
+	python depend.py $(TESTDIRS) > Makefile.deps
 
-if HAVE_MPI
-  TESTS = test.sh ./scripts/mpi.sh
-else
-  TESTS = test.sh
-endif
+-include Makefile.deps
diff --git a/test/euler/reynolds/check.py b/test/euler/check.py
similarity index 100%
rename from test/euler/reynolds/check.py
rename to test/euler/check.py
diff --git a/test/euler/depend.py b/test/euler/depend.py
new file mode 100755
index 0000000..2efcdd5
--- /dev/null
+++ b/test/euler/depend.py
@@ -0,0 +1,24 @@
+#!/usr/bin/python
+
+import sys
+import os
+import os.path
+sys.path.append("../../doc/examples")
+import gfs2tex
+
+dists = ""
+depends = ""
+for start in sys.argv[1:]:
+    for root, dirs, files in os.walk(start,topdown=True):
+        if not ".xvpics" in root:
+            test = gfs2tex.Example(root)
+            name = test.path + "/" + test.name + ".gfs "
+            dists += "\\\n\t" + name
+            depends += "\\\n\t" + name            
+            for f in test.required:
+                dists += "\\\n\t" + test.path + "/" + f + " "
+            for f in test.generated:
+                depends += "\\\n\t" + test.path + "/" + f + " "
+print "EXTRA_DIST += " + dists
+print ""
+print "tests.tex: " + depends
diff --git a/doc/examples/gfs2tex b/test/euler/gfs2tex
similarity index 54%
copy from doc/examples/gfs2tex
copy to test/euler/gfs2tex
index 3ef9e3d..b3501bd 100755
--- a/doc/examples/gfs2tex
+++ b/test/euler/gfs2tex
@@ -4,19 +4,20 @@ import sys
 import os
 import os.path
 import glob
+sys.path.append("../../doc/examples")
 import gfs2tex
 
-if not os.access("examples",os.F_OK):
-    os.mkdir("examples")
+if not os.access("tests",os.F_OK):
+    os.mkdir("tests")
 
 dico = {}
-for f in glob.glob("../html/*.html"):
+for f in glob.glob("../../doc/html/*.html"):
     gfs2tex.dictionary(dico,open(f))
 
 for start in sys.argv[1:]:
     for root, dirs, files in os.walk(start,topdown=True):
         if not ".xvpics" in root:
             example = gfs2tex.Example(root)
-            if not os.access("examples/" + example.path,os.F_OK):
-                os.symlink("../" + example.path, "examples/" + example.path)
+            if not os.access("tests/" + example.path,os.F_OK):
+                os.symlink("../" + example.path, "tests/" + example.path)
             example.write(dico)
diff --git a/doc/examples/l2hconf.pm b/test/euler/l2hconf.pm
similarity index 99%
copy from doc/examples/l2hconf.pm
copy to test/euler/l2hconf.pm
index e977cea..8a525f3 100755
--- a/doc/examples/l2hconf.pm
+++ b/test/euler/l2hconf.pm
@@ -113,7 +113,7 @@ $HTML_VALIDATE = 0;
 #    "../icons".
 #
 $ICONSERVER = ''||'file:/usr/local/share/lib/latex2html/icons';
-$ALTERNATIVE_ICONS = '../../share';
+$ALTERNATIVE_ICONS = '../../../doc/share';
 
 
 # ####### YOU *MAY* WANT/NEED TO CHANGE SOME OF THESE VARIABLES  ##############
diff --git a/test/euler/reynolds/reynolds.gfs b/test/euler/reynolds/box/box.gfs
similarity index 55%
copy from test/euler/reynolds/reynolds.gfs
copy to test/euler/reynolds/box/box.gfs
index 8574161..663a7ef 100644
--- a/test/euler/reynolds/reynolds.gfs
+++ b/test/euler/reynolds/box/box.gfs
@@ -1,44 +1,55 @@
-# Title: Estimation of the numerical viscosity
+# Title: Estimation of the numerical viscosity with refined box
 #
 # Description:
 #
+# Same as the previous test but with a refined box in the middle and four
+# modes of the exact Euler solution.
+#
 # \begin{figure}[htbp]
 # \begin{center}
 # \includegraphics[width=0.8\hsize]{divmax.eps}
 # \end{center}
+# \caption{Evolution of the maximum divergence.}
+# \label{divmax}
 # \end{figure}
 #
 # \begin{figure}[htbp]
 # \begin{center}
 # \includegraphics[width=0.8\hsize]{divL2.eps}
 # \end{center}
+# \caption{Evolution of the L2 norm of the divergence.}
+# \label{divL2}
 # \end{figure}
 #
 # \begin{figure}[htbp]
 # \begin{center}
 # \includegraphics[width=0.8\hsize]{kinetic.eps}
 # \end{center}
+# \caption{Evolution of the kinetic energy.}
+# \label{kinetic}
 # \end{figure}
 #
 # \begin{figure}[htbp]
 # \begin{center}
 # \includegraphics[width=0.8\hsize]{reynolds.eps}
 # \end{center}
+# \caption{Equivalent Reynolds number as a function of resolution.}
+# \label{reynolds}
 # \end{figure}
 #
 # Author: St\'ephane Popinet
-# Command: sh reynolds.sh reynolds.gfs
+# Command: sh ../reynolds.sh box.gfs 4
 # Version: 0.6.4
-# Required files: reynolds.sh div5.ref div6.ref div7.ref reynolds.ref check.py
+# Required files: ../reynolds.sh div5.ref div6.ref div7.ref reynolds.ref
 # Running time: 3 minutes
 # Generated files: divmax.eps reynolds.eps divL2.eps kinetic.eps
 #
 1 2 GfsSimulation GfsBox GfsGEdge {} {
   Time { end = 2 }
-  Refine LEVEL
+  Refine (x > 0.25 || x < -0.25 || y > 0.25 || y < -0.25 ? LEVEL : LEVEL + 1)
   Init {} {
-    U = (- cos (2.*M_PI*x)*sin (2.*M_PI*y))
-    V = (sin (2.*M_PI*x)*cos (2.*M_PI*y))
+    U = (- cos (8.*M_PI*x)*sin (8.*M_PI*y))
+    V = (sin (8.*M_PI*x)*cos (8.*M_PI*y))
   }
   OutputScalarNorm { istep = 1 } divLEVEL { v = Divergence }
   OutputScalarSum { istep = 1 } kineticLEVEL { v = Velocity2 }
diff --git a/test/euler/reynolds/div5.ref b/test/euler/reynolds/box/div5.ref
similarity index 100%
copy from test/euler/reynolds/div5.ref
copy to test/euler/reynolds/box/div5.ref
diff --git a/test/euler/reynolds/div6.ref b/test/euler/reynolds/box/div6.ref
similarity index 100%
copy from test/euler/reynolds/div6.ref
copy to test/euler/reynolds/box/div6.ref
diff --git a/test/euler/reynolds/div7.ref b/test/euler/reynolds/box/div7.ref
similarity index 100%
copy from test/euler/reynolds/div7.ref
copy to test/euler/reynolds/box/div7.ref
diff --git a/test/euler/reynolds/reynolds.ref b/test/euler/reynolds/box/reynolds.ref
similarity index 100%
copy from test/euler/reynolds/reynolds.ref
copy to test/euler/reynolds/box/reynolds.ref
diff --git a/test/euler/reynolds/reynolds.gfs b/test/euler/reynolds/reynolds.gfs
index 8574161..9ca4fa3 100644
--- a/test/euler/reynolds/reynolds.gfs
+++ b/test/euler/reynolds/reynolds.gfs
@@ -2,34 +2,59 @@
 #
 # Description:
 #
+# The velocity field is initialised with an exact stationary solution of
+# the Euler equations in a periodic 2D domain. An exact Euler solver
+# would not change this field, however any numerical solver will
+# introduce numerical dissipation which will slowly dissipate the
+# kinetic energy of the initial solution. By monitoring the evolution of
+# the kinetic energy, the dissipative properties of the numerical scheme
+# can be measured.
+#
+# Figures \ref{divmax} and figure \ref{divL2} illustrate the evolution
+# of the divergence of the velocity field with time. This is a check of
+# the stability of the approximate projection and should remain bounded.
+#
+# Figures \ref{kinetic} and \ref{reynolds} illustrates the evolution of
+# the kinetic energy and the corresponding equivalent Reynolds number as
+# a function of resolution. The higher the Reynolds number, the less
+# dissipative the scheme.
+#
 # \begin{figure}[htbp]
 # \begin{center}
 # \includegraphics[width=0.8\hsize]{divmax.eps}
 # \end{center}
+# \caption{Evolution of the maximum divergence.}
+# \label{divmax}
 # \end{figure}
 #
 # \begin{figure}[htbp]
 # \begin{center}
 # \includegraphics[width=0.8\hsize]{divL2.eps}
 # \end{center}
+# \caption{Evolution of the L2 norm of the divergence.}
+# \label{divL2}
 # \end{figure}
 #
 # \begin{figure}[htbp]
 # \begin{center}
 # \includegraphics[width=0.8\hsize]{kinetic.eps}
 # \end{center}
+# \caption{Evolution of the kinetic energy.}
+# \label{kinetic}
 # \end{figure}
 #
 # \begin{figure}[htbp]
 # \begin{center}
 # \includegraphics[width=0.8\hsize]{reynolds.eps}
 # \end{center}
+# \caption{Equivalent Reynolds number as a function of resolution.}
+# \label{reynolds}
 # \end{figure}
 #
 # Author: St\'ephane Popinet
-# Command: sh reynolds.sh reynolds.gfs
+# Command: sh reynolds.sh reynolds.gfs 1
 # Version: 0.6.4
-# Required files: reynolds.sh div5.ref div6.ref div7.ref reynolds.ref check.py
+# Required files: reynolds.sh div5.ref div6.ref div7.ref reynolds.ref
 # Running time: 3 minutes
 # Generated files: divmax.eps reynolds.eps divL2.eps kinetic.eps
 #
diff --git a/test/euler/reynolds/reynolds.sh b/test/euler/reynolds/reynolds.sh
index 0096413..d071531 100644
--- a/test/euler/reynolds/reynolds.sh
+++ b/test/euler/reynolds/reynolds.sh
@@ -1,19 +1,22 @@
 rm -f reynolds
 
 for level in 5 6 7; do
- sed "s/LEVEL/$level/" < $1 | gerris2D - | awk -v m=1 -v level=$level '{
-   time = $3
-   ke = $5
-   if (time == 0)
-     ke0 = ke;
- }END{
-   a = -log(ke/ke0)/time
-   nu = a/(4.*(2.*m*3.14159265359)^2)
-   print level " " 1./nu
- }' >> reynolds
+  if sed "s/LEVEL/$level/g" < $1 | $gerris2D - | awk -v m=$2 -v level=$level '{
+    time = $3
+    ke = $5
+    if (time == 0)
+      ke0 = ke;
+  }END{
+    a = -log(ke/ke0)/time
+    nu = a/(4.*(2.*m*3.14159265359)^2)
+    print level " " 1./nu
+  }' >> reynolds; then :
+  else
+      exit 1
+  fi
 done
 
-cat <<EOF | gnuplot
+if cat <<EOF | gnuplot ; then :
     set term postscript eps color solid 20
     set output 'divmax.eps'
     set xlabel 'Time'
@@ -31,6 +34,9 @@ cat <<EOF | gnuplot
     set logscale y
     plot 'reynolds' u 1:2 t "" w lp lw 2, 'reynolds.ref' u 1:2 t "ref" w lp lw 2
 EOF
+else
+    exit 1
+fi
 
 if cat <<EOF | python ; then :
 from check import *
@@ -45,5 +51,5 @@ if (Curve('div5',3,9) - Curve('div5.ref',3,9)).max() > 0.05*Curve('div5.ref',3,9
    exit(1)
 EOF
 else
-    exit 1
+   exit 1
 fi
diff --git a/test/euler/test.py b/test/euler/test.py
new file mode 100644
index 0000000..13f9661
--- /dev/null
+++ b/test/euler/test.py
@@ -0,0 +1,39 @@
+import sys
+import os
+import os.path
+sys.path.append("../../doc/examples")
+import gfs2tex
+
+env = ""
+for p in ["gerris2D","gerris3D","gerris2D3"]:
+    env += p + "=" + os.getcwd() + "/../../src/" + p + " "
+env += " PYTHONPATH=$PYTHONPATH:" + os.getcwd() + " "
+
+n = 0
+failed = 0
+for start in sys.argv[1:]:
+    for root, dirs, files in os.walk(start,topdown=True):
+        if not ".xvpics" in root:
+            test = gfs2tex.Example(root)
+            status,msg = test.run(env)
+            if status != None:
+                print "FAIL:",root
+                if len(msg) > 0:
+                    print " ".join(msg)
+                print >>open(test.path + "/status",'w'), "{\color{red}FAIL}:"
+                failed += 1
+            else:
+                print "PASS:",root
+                print >>open(test.path + "/status",'w'), "{\color{green}PASS}:"
+            n += 1
+if failed:
+    msg = repr(failed) + " of " + repr(n) + " tests failed"
+else:
+    msg = "All " + repr(n) + " tests passed"
+
+print len(msg)*"="
+print msg
+print len(msg)*"="
+
+if failed:
+    sys.exit(1)

-- 
Gerris Flow Solver



More information about the debian-science-commits mailing list