Index: /trunk/anuga_core/source/anuga_validation_tests/analytical_exact/avalanche_wet/plot_results.py
===================================================================
--- /trunk/anuga_core/source/anuga_validation_tests/analytical_exact/avalanche_wet/plot_results.py	(revision 8916)
+++ /trunk/anuga_core/source/anuga_validation_tests/analytical_exact/avalanche_wet/plot_results.py	(revision 8917)
@@ -13,17 +13,35 @@
 v2=(p2_st.y==v)
 
-u0,h0,w0,z0,p0 = analytical_sol(p2_st.x[v2], p2_st.time[0])
-u20,h20,w20,z20,p20 = analytical_sol(p2_st.x[v2], p2_st.time[20])
-u40,h40,w40,z40,p40 = analytical_sol(p2_st.x[v2], p2_st.time[40])
+x_n = p2_st.x[v2]
+
+u0,h0,w0,z0,p0 = analytical_sol(x_n, p2_st.time[0])
+u20,h20,w20,z20,p20 = analytical_sol(x_n, p2_st.time[20])
+u40,h40,w40,z40,p40 = analytical_sol(x_n, p2_st.time[40])
+
+
+
+w0_n  = p2_st.stage[0,v2]
+w20_n = p2_st.stage[20,v2]
+w40_n = p2_st.stage[40,v2]
+
+z_n = p2_st.elev[v2]
+
+uh0_n  = p2_st.xmom[0,v2]
+uh20_n = p2_st.xmom[20,v2]
+uh40_n = p2_st.xmom[40,v2]
+
+u0_n  = p2_st.xvel[0,v2]
+u20_n = p2_st.xvel[20,v2]
+u40_n = p2_st.xvel[40,v2]
 
 #Plot stages
 pyplot.clf()
-pyplot.plot(p2_st.x[v2], p2_st.stage[0,v2],'b.-', label='numerical stage')
-pyplot.plot(p2_st.x[v2], p2_st.stage[20,v2], 'b.-')
-pyplot.plot(p2_st.x[v2], p2_st.stage[40,v2], 'b.-')
-pyplot.plot(p2_st.x[v2], w0,'r-', label='analytical stage')
-pyplot.plot(p2_st.x[v2], w20,'r-')
-pyplot.plot(p2_st.x[v2], w40,'r-')
-pyplot.plot(p2_st.x[v2], p2_st.elev[v2],'k-', label='bed elevation')
+pyplot.plot(x_n, w0_n,'b.-', label='numerical stage')
+pyplot.plot(x_n, w20_n, 'b.-')
+pyplot.plot(x_n, w40_n, 'b.-')
+pyplot.plot(x_n, w0,'r-', label='analytical stage')
+pyplot.plot(x_n, w20,'r-')
+pyplot.plot(x_n, w40,'r-')
+pyplot.plot(x_n, p2_st.elev[v2],'k-', label='bed elevation')
 pyplot.title('Stage at several instants in time')
 pyplot.legend(loc='best')
@@ -36,10 +54,10 @@
 #Plot xmomentum
 pyplot.clf()
-pyplot.plot(p2_st.x[v2], p2_st.xmom[0,v2], 'b.-', label='numerical')
-pyplot.plot(p2_st.x[v2], p2_st.xmom[20,v2], 'b.-')
-pyplot.plot(p2_st.x[v2], p2_st.xmom[40,v2],'b.-')
-pyplot.plot(p2_st.x[v2], u0*h0,'r-', label='analytical')
-pyplot.plot(p2_st.x[v2], u20*h20,'r-')
-pyplot.plot(p2_st.x[v2], u40*h40,'r-')
+pyplot.plot(x_n, uh0_n, 'b.-', label='numerical')
+pyplot.plot(x_n, uh20_n, 'b.-')
+pyplot.plot(x_n, uh40_n,'b.-')
+pyplot.plot(x_n, u0*h0,'r-', label='analytical')
+pyplot.plot(x_n, u20*h20,'r-')
+pyplot.plot(x_n, u40*h40,'r-')
 pyplot.title('Xmomentum at several instants in time')
 pyplot.legend(loc='best')
@@ -51,10 +69,10 @@
 #Plot velocities
 pyplot.clf()
-pyplot.plot(p2_st.x[v2], p2_st.xvel[0,v2], 'b.-', label='numerical')
-pyplot.plot(p2_st.x[v2], p2_st.xvel[20,v2], 'b.-')
-pyplot.plot(p2_st.x[v2], p2_st.xvel[40,v2],'b.-')
-pyplot.plot(p2_st.x[v2], u0,'r-', label='analytical')
-pyplot.plot(p2_st.x[v2], u20,'r-')
-pyplot.plot(p2_st.x[v2], u40,'r-')
+pyplot.plot(x_n, u0_n, 'b.-', label='numerical')
+pyplot.plot(x_n, u20_n, 'b.-')
+pyplot.plot(x_n, u40_n,'b.-')
+pyplot.plot(x_n, u0,'r-', label='analytical')
+pyplot.plot(x_n, u20,'r-')
+pyplot.plot(x_n, u40,'r-')
 pyplot.title('Xvelocity at several instants in time')
 pyplot.legend(loc='best')
Index: /trunk/anuga_core/source/anuga_validation_tests/analytical_exact/avalanche_wet/validate_results.py
===================================================================
--- /trunk/anuga_core/source/anuga_validation_tests/analytical_exact/avalanche_wet/validate_results.py	(revision 8917)
+++ /trunk/anuga_core/source/anuga_validation_tests/analytical_exact/avalanche_wet/validate_results.py	(revision 8917)
@@ -0,0 +1,122 @@
+"""Automatic verification of ANUGA flows.
+See functions exercised by this wrapper for more details
+"""
+
+import unittest
+import os
+import numpy
+import anuga
+
+indent = anuga.indent
+
+verbose = True
+
+class Test_results(unittest.TestCase):
+    def setUp(self):
+        for file in os.listdir('.'):    
+            if file.endswith('.stdout') or\
+                    file.endswith('.sww') or\
+                    file.endswith('.msh') or\
+                    file.endswith('.png'):
+                os.remove(file)
+                
+        
+    def tearDown(self):
+        pass
+
+    def test_simulation(self):
+    
+
+        if verbose:
+            print
+            print indent+'Running simulation script'
+
+        s = 'produce_results.py'
+        res = os.system('python %s > validate_output.stdout' %s)
+
+        # Test that script runs ok
+        assert res == 0
+
+
+        if verbose:
+            print indent+'Testing accuracy'
+            
+
+        import anuga.utilities.plot_utils as util
+        from matplotlib import pyplot as pyplot
+        from analytical_avalanche_wet import analytical_sol
+
+        p_st = util.get_output('avalanche.sww')
+        p2_st=util.get_centroids(p_st)
+
+        v = p2_st.y[20]
+        v2=(p2_st.y==v)
+
+        x_n = p2_st.x[v2]
+
+        u0,h0,w0,z0,p0 = analytical_sol(x_n, p2_st.time[0])
+        u20,h20,w20,z20,p20 = analytical_sol(x_n, p2_st.time[20])
+        u40,h40,w40,z40,p40 = analytical_sol(x_n, p2_st.time[40])
+
+
+
+        w0_n  = p2_st.stage[0,v2]
+        w20_n = p2_st.stage[20,v2]
+        w40_n = p2_st.stage[40,v2]
+
+        z_n = p2_st.elev[v2]
+
+        uh0_n  = p2_st.xmom[0,v2]
+        uh20_n = p2_st.xmom[20,v2]
+        uh40_n = p2_st.xmom[40,v2]
+
+        u0_n  = p2_st.xvel[0,v2]
+        u20_n = p2_st.xvel[20,v2]
+        u40_n = p2_st.xvel[40,v2]
+
+
+        #Test stages
+        # Calculate L^1 error at times corrsponding to slices 20, 40
+        eh20 = numpy.sum(numpy.abs(w20_n-w20))/numpy.sum(numpy.abs(w20))
+        eh40 = numpy.sum(numpy.abs(w40_n-w40))/numpy.sum(numpy.abs(w40))
+
+
+        if verbose:
+            print indent+'Errors in stage: ',eh20, eh40
+
+        assert eh20 < 0.01,  'L^1 error %g greater than 1 percent'% eh20
+        assert eh40 < 0.01,  'L^1 error %g greater than 1 percent'% eh40
+
+
+        #Test xmomenta
+        # Calculate L^1 error at times corrsponding to slices 20, 40
+        euh20 = numpy.sum(numpy.abs(uh20_n-u20*h20))/numpy.sum(numpy.abs(u20*h20))
+        euh40 = numpy.sum(numpy.abs(uh40_n-u40*h40))/numpy.sum(numpy.abs(u40*h40))
+
+
+        if verbose:
+            print indent+'Errors in xmomentum: ',euh20, euh40
+
+
+        assert euh20 < 0.025,  'L^1 error %g greater than 2.5 percent'% euh20
+        assert euh40 < 0.025,  'L^1 error %g greater than 2.5 percent'% euh40
+
+
+
+        #Test xvelocity
+        # Calculate L^1 error at times corrsponding to slices 20, 40
+        eu20 = numpy.sum(numpy.abs(u20_n-u20))/numpy.sum(numpy.abs(u20))
+        eu40 = numpy.sum(numpy.abs(u40_n-u40))/numpy.sum(numpy.abs(u40))
+
+        if verbose:
+            print indent+'Errors in xvelocity: ', eu20, eu40
+
+        assert eu20 < 0.02,  'L^1 error %g greater than 2 percent'% eu20
+        assert eu40 < 0.01,  'L^1 error %g greater than 2 percent'% eu40
+
+
+#-------------------------------------------------------------
+if __name__ == '__main__':
+    suite = unittest.makeSuite(Test_results, 'test')
+    runner = unittest.TextTestRunner(verbosity=2)
+    runner.run(suite)
