Index: /anuga_core/source/anuga/config.py
===================================================================
--- /anuga_core/source/anuga/config.py	(revision 5289)
+++ /anuga_core/source/anuga/config.py	(revision 5290)
@@ -88,4 +88,10 @@
 tight_slope_limiters = True
 
+# Use centroid velocities to reconstruct momentum at vertices
+# This option has a firts order flavour to it, but we still have second order
+# reconstruction of stage and this option speeds ANUGA up
+#
+# This option must be used with tight_slope_limiters.
+use_centroid_velocities = True
 
 
Index: /anuga_core/source/anuga/shallow_water/shallow_water_domain.py
===================================================================
--- /anuga_core/source/anuga/shallow_water/shallow_water_domain.py	(revision 5289)
+++ /anuga_core/source/anuga/shallow_water/shallow_water_domain.py	(revision 5290)
@@ -105,4 +105,6 @@
 from anuga.config import optimised_gradient_limiter
 from anuga.config import use_edge_limiter
+from anuga.config import use_centroid_velocities
+
 
 #---------------------
@@ -181,7 +183,7 @@
         # Limiters
         self.use_edge_limiter = use_edge_limiter
-
         self.optimised_gradient_limiter = optimised_gradient_limiter
-                
+        self.use_centroid_velocities = use_centroid_velocities
+
 
     def set_all_limiters(self, beta):
@@ -741,5 +743,6 @@
               Ymom.vertex_values,
               Elevation.vertex_values,
-              int(domain.optimise_dry_cells))
+              int(domain.optimise_dry_cells),
+              int(domain.use_centroid_velocities))
 
 
@@ -800,8 +803,8 @@
 
 
-    #Take bed elevation into account when water heights are small
+    # Take bed elevation into account when water heights are small
     balance_deep_and_shallow(domain)
 
-    #Compute edge values by interpolation
+    # Compute edge values by interpolation
     for name in domain.conserved_quantities:
         Q = domain.quantities[name]
Index: /anuga_core/source/anuga/shallow_water/shallow_water_ext.c
===================================================================
--- /anuga_core/source/anuga/shallow_water/shallow_water_ext.c	(revision 5289)
+++ /anuga_core/source/anuga/shallow_water/shallow_water_ext.c	(revision 5290)
@@ -144,5 +144,6 @@
 			  
   // Compute Froude number; v/sqrt(gh)
-  
+  // FIXME (Ole): Not currently in use
+    
   double froude_number;
   
@@ -549,13 +550,13 @@
 			      double H0,
 			      int tight_slope_limiters,
+			      int use_centroid_velocities,			      
 			      double alpha_balance) {
 
-  int k, k3, i, excessive_froude_number=0;
+  int k, k3, i; //, excessive_froude_number=0;
 
   double dz, hmin, alpha, h_diff, hc_k;
   double epsilon = 1.0e-6; // FIXME: Temporary measure
-  double g = 9.81; // FIXME: Temporary measure
-  double hv[3], h; // Depths at vertices
-  double Fx, Fy; // Froude numbers
+  double hv[3]; // Depths at vertices
+  //double Fx, Fy; // Froude numbers
   double uc, vc; // Centroid speeds
 
@@ -701,4 +702,5 @@
     if (alpha < 1) {      
       for (i=0; i<3; i++) {
+      
 	// FIXME (Ole): Simplify when (if) hvbar gets retired	    
 	if (beta_h > epsilon) {	  
@@ -709,18 +711,8 @@
 
 	// Update momentum at vertices
-
-
-	// Update momentum at vertices
-	// Update momentum as a linear combination of
-	// xmomc and ymomc (shallow) and momentum
-	// from extrapolator xmomv and ymomv (deep).
-
-
-	//xmomv[k3+i] = (1-alpha)*xmomc[k] + alpha*xmomv[k3+i];
-	//ymomv[k3+i] = (1-alpha)*ymomc[k] + alpha*ymomv[k3+i];
-
-	if (tight_slope_limiters == 1) {
-	  // FIXME(Ole): Here's what I think (as of 17 Nov 2007)
-	  // we need to do. Simple and efficient:
+	if (use_centroid_velocities == 1) {
+	  // This is a simple, efficient and robust option
+	  // It uses first order approximation of velocities, but retains
+	  // the order used by stage.
 	
 	  // Speeds at centroids
@@ -738,10 +730,12 @@
 	  xmomv[k3+i] = uc*hv[i];
 	  ymomv[k3+i] = vc*hv[i];
+	  
 	} else {
 	  // Update momentum as a linear combination of
 	  // xmomc and ymomc (shallow) and momentum
 	  // from extrapolator xmomv and ymomv (deep).
-	  // FIXME (Ole): Is this really needed? Could we use the above
-	  // instead?
+	  // This assumes that values from xmomv and ymomv have
+	  // been established e.g. by the gradient limiter.
+
 	  
 	  xmomv[k3+i] = (1-alpha)*xmomc[k] + alpha*xmomv[k3+i];
@@ -749,51 +743,4 @@
 	
 	}
-      }
-    }
-	
-
-	
-    if (0) {  // FIXME(Ole): Disabled while testing balancing of velocities above
-      //if (tight_slope_limiters == 1) {     		
-    
-      // Ensure that the Froude number is kept realistic at vertices
-      // FIXME (Ole): I think it could be used to adjust alpha down
-      // whenever Fr is too large. Possible make sure it doesn't deviate 
-      // too much from the value at the centroid. I like this idea!
-      
-      // FIXME (Ole): currently only used with tights_SL
-      
-      // FIXME (Ole): may not be necessary now
-
-      excessive_froude_number=0;    
-      for (i=0; i<3; i++) {    
-      
-	// Recalculate depth at vertex i
-	h = wv[k3+i] - zv[k3+i];
-	
-	Fx = compute_froude_number(xmomv[k3+i], h, g, epsilon);
-	Fy = compute_froude_number(ymomv[k3+i], h, g, epsilon);
-	
-	if ( (fabs(Fx) > 100.0) || (fabs(Fy) > 100.0)) {
-	  // FIXME: use max_froude - or base it on centroid value of F
-	  // printf("Excessive Froude number detected: %f or %f\n", Fx, Fy);
-	  excessive_froude_number=1;          
-	}
-      }
-     
-      if (excessive_froude_number) { 
-    
-	// printf("Adjusting momentum to first order.\n"); 
-	// Go back to first order (alpha = 0) for this triangle
-	for (i=0; i<3; i++) {          
-	  xmomv[k3+i] = xmomc[k];
-	  ymomv[k3+i] = ymomc[k];
-	  
-	  if (beta_h > epsilon) {	  
-	    wv[k3+i] = zv[k3+i] + hvbar[k3+i];
-	  } else {
-	    wv[k3+i] = zv[k3+i] + hc_k;	
-	  }
-	}	
       }
     }
@@ -1094,5 +1041,6 @@
 				  double* ymom_vertex_values,
 				  double* elevation_vertex_values,
-				  int optimise_dry_cells) {
+				  int optimise_dry_cells,
+				  int use_centroid_velocities) {
 				  
 				  
@@ -1359,5 +1307,5 @@
       // One internal neighbour and gradient is in direction of the neighbour's centroid
       
-      // Find the only internal neighbour
+      // Find the only internal neighbour (k1?)
       for (k2=k3;k2<k3+3;k2++){
 	// Find internal neighbour of triangle k      
@@ -1367,4 +1315,5 @@
 	  break;
       }
+      
       if ((k2==k3+3)) {
 	// If we didn't find an internal neighbour
@@ -1396,5 +1345,4 @@
       dy2=dx2*dy1;
       dx2*=dx1;
-      
       
       
@@ -1561,10 +1509,10 @@
   double beta_w, beta_w_dry, beta_uh, beta_uh_dry, beta_vh, beta_vh_dry;    
   double minimum_allowed_height, epsilon;
-  int optimise_dry_cells, number_of_elements, e;
+  int optimise_dry_cells, number_of_elements, e, use_centroid_velocities;
   
   // Provisional jumps from centroids to v'tices and safety factor re limiting
   // by which these jumps are limited
   // Convert Python arguments to C
-  if (!PyArg_ParseTuple(args, "OOOOOOOOOOOOOi",
+  if (!PyArg_ParseTuple(args, "OOOOOOOOOOOOOii",
 			&domain,
 			&surrogate_neighbours,
@@ -1580,5 +1528,6 @@
 			&ymom_vertex_values,
 			&elevation_vertex_values,
-			&optimise_dry_cells)) {			
+			&optimise_dry_cells,
+			&use_centroid_velocities)) {			
 			
     PyErr_SetString(PyExc_RuntimeError, 
@@ -1625,5 +1574,6 @@
 				   (double*) ymom_vertex_values -> data,
 				   (double*) elevation_vertex_values -> data,
-				   optimise_dry_cells);
+				   optimise_dry_cells,
+				   use_centroid_velocities);
   if (e == -1) {
     // Use error string set inside computational routine
@@ -2271,5 +2221,5 @@
   double H0, beta_h;
 
-  int N, tight_slope_limiters; //, err;
+  int N, tight_slope_limiters, use_centroid_velocities; //, err;
 
   // Convert Python arguments to C
@@ -2318,4 +2268,14 @@
   
   
+  Tmp = PyObject_GetAttrString(domain, "use_centroid_velocities");
+  if (!Tmp) {
+    PyErr_SetString(PyExc_RuntimeError, "shallow_water_ext.c: balance_deep_and_shallow could not obtain object use_centroid_velocities from domain");
+    return NULL;
+  }  
+  use_centroid_velocities = PyInt_AsLong(Tmp);
+  Py_DECREF(Tmp);
+  
+  
+  
   N = wc -> dimensions[0];
   _balance_deep_and_shallow(N,
@@ -2332,4 +2292,5 @@
 			    H0,
 			    (int) tight_slope_limiters,
+			    (int) use_centroid_velocities,			    
 			    alpha_balance);
 
Index: /anuga_core/source/anuga/shallow_water/test_data_manager.py
===================================================================
--- /anuga_core/source/anuga/shallow_water/test_data_manager.py	(revision 5289)
+++ /anuga_core/source/anuga/shallow_water/test_data_manager.py	(revision 5290)
@@ -235,4 +235,6 @@
 
         self.domain.tight_slope_limiters = 0 # Backwards compatibility
+        self.domain.use_centroid_velocities = 0 # Backwards compatibility (7/5/8)
+        
         
         sww = get_dataobject(self.domain)        
@@ -309,4 +311,6 @@
         #domain.tight_slope_limiters = 1
         domain.tight_slope_limiters = 0 # Backwards compatibility
+        domain.use_centroid_velocities = 0 # Backwards compatibility (7/5/8)
+        
         
         sww = get_dataobject(domain)
@@ -7318,5 +7322,6 @@
         # Look at sww file and see what happens when
         # domain.tight_slope_limiters = 1
-        domain.tight_slope_limiters = 0 
+        domain.tight_slope_limiters = 0
+        domain.use_centroid_velocities = 0 # Backwards compatibility (7/5/8)        
         
         Br = Reflective_boundary(domain)
@@ -7434,7 +7439,7 @@
         # Create basic mesh (100m x 5m)
         width = 5
-        length = 100
+        length = 50
         t_end = 10
-        points, vertices, boundary = rectangular(length, width, 100, 5)
+        points, vertices, boundary = rectangular(length, width, 50, 5)
 
         # Create shallow water domain
@@ -7522,5 +7527,5 @@
         # Create basic mesh (100m x 5m)
         width = 5
-        length = 100
+        length = 50
         t_end = 3
         points, vertices, boundary = rectangular(length, width,
@@ -7651,5 +7656,5 @@
         # Create basic mesh (100m x 5m)
         width = 5
-        length = 100
+        length = 50
         t_end = 1
         points, vertices, boundary = rectangular(length, width,
Index: /anuga_core/source/anuga/shallow_water/test_shallow_water_domain.py
===================================================================
--- /anuga_core/source/anuga/shallow_water/test_shallow_water_domain.py	(revision 5289)
+++ /anuga_core/source/anuga/shallow_water/test_shallow_water_domain.py	(revision 5290)
@@ -1437,4 +1437,6 @@
         domain.H0 = 0 # Backwards compatibility (6/2/7)
         domain.beta_h = 0.2 # Backwards compatibility (14/2/7)
+        domain.use_centroid_velocities = 0 # Backwards compatibility (7/5/8)
+        
 
         #-----------------------------------------------------------------
@@ -2657,4 +2659,5 @@
         # FIXME (Ole): Need tests where this is commented out
         domain.tight_slope_limiters = 0 # Backwards compatibility (14/4/7)                 
+        domain.use_centroid_velocities = 0 # Backwards compatibility (7/5/8)
         
                 
@@ -3869,5 +3872,6 @@
         # FIXME (Ole): Need tests where these two are commented out
         domain.H0 = 0        # Backwards compatibility (6/2/7)        
-        domain.tight_slope_limiters = 0 # Backwards compatibility (14/4/7)         
+        domain.tight_slope_limiters = 0 # Backwards compatibility (14/4/7)
+        domain.use_centroid_velocities = 0 # Backwards compatibility (7/5/8)                 
 
         #Bed-slope and friction
@@ -3941,5 +3945,6 @@
         
         # FIXME (Ole): Need tests where this is commented out
-        domain.tight_slope_limiters = 0 # Backwards compatibility (14/4/7)         
+        domain.tight_slope_limiters = 0 # Backwards compatibility (14/4/7)
+        domain.use_centroid_velocities = 0 # Backwards compatibility (7/5/8)      
         
         #Bed-slope and friction at vertices (and interpolated elsewhere)
@@ -4038,5 +4043,7 @@
         # FIXME (Ole): Need tests where this is commented out
         domain.tight_slope_limiters = 0 # Backwards compatibility (14/4/7)                 
-        domain.H0 = 0 # Backwards compatibility (6/2/7)        
+        domain.H0 = 0 # Backwards compatibility (6/2/7)
+        domain.use_centroid_velocities = 0 # Backwards compatibility (7/5/8)
+        
 
         #Bed-slope and friction at vertices (and interpolated elsewhere)
@@ -4141,4 +4148,6 @@
         domain.tight_slope_limiters = 0 # Backwards compatibility (14/4/7)                 
         domain.H0 = 0 # Backwards compatibility (6/2/7)
+        domain.use_centroid_velocities = 0 # Backwards compatibility (7/5/8)
+        
 
         #Bed-slope and friction at vertices (and interpolated elsewhere)
@@ -4240,4 +4249,5 @@
         domain.H0 = 0        # Backwards compatibility (6/2/7)        
         domain.tight_slope_limiters = 0 # Backwards compatibility (14/4/7)                 
+        domain.use_centroid_velocities = 0 # Backwards compatibility (7/5/8)
         
                 
@@ -4504,5 +4514,6 @@
         # FIXME (Ole): Need tests where these two are commented out
         domain.H0 = 0        # Backwards compatibility (6/2/7)        
-        domain.tight_slope_limiters = 0 # Backwards compatibility (14/4/7)                         
+        domain.tight_slope_limiters = 0 # Backwards compatibility (14/4/7)
+        domain.use_centroid_velocities = 0 # Backwards compatibility (7/5/8)        
         
 
@@ -5674,6 +5685,5 @@
     suite = unittest.makeSuite(Test_Shallow_Water,'test')
 
-    #suite = unittest.makeSuite(Test_Shallow_Water,'test_balance_deep_and_shallow_Froude')
-    
+    #suite = unittest.makeSuite(Test_Shallow_Water,'test_bedslope_problem_first_order_moresteps')    
     #suite = unittest.makeSuite(Test_Shallow_Water,'test_fitting_using_shallow_water_domain')    
     #suite = unittest.makeSuite(Test_Shallow_Water,'test_tight_slope_limiters')
Index: /anuga_validation/automated_validation_tests/fitting/validate_benchmark_fit.py
===================================================================
--- /anuga_validation/automated_validation_tests/fitting/validate_benchmark_fit.py	(revision 5289)
+++ /anuga_validation/automated_validation_tests/fitting/validate_benchmark_fit.py	(revision 5290)
@@ -7,5 +7,5 @@
 memory is measured here. What is actually happening is the mesh
 generation is using less memory, in version 4917.  In version 4897
-mesh gen uses and frees up more memory, so phython asks for less extra
+mesh gen uses and frees up more memory, so python asks for less extra
 memory in the fitting stage.  So overall version 4917 is an
 improvement.
@@ -65,5 +65,5 @@
             self.assert_(time<time_standard*1.2)
             mem_standard = 302404 
-            # 
+            #
             self.assert_(mem<mem_standard*1.2)
             
@@ -90,6 +90,7 @@
             time_standard = 14.2
             self.assert_(time<time_standard*1.2)
-            mem_standard = 21008 # this will need to be updated, see top notes
-            self.assert_(mem<mem_standard*1.2)            
+            mem_standard = 30000 # Updated by Ole 20080507
+            msg = 'Memory used was %d, mem_standard is %d' %(mem, mem_standard)            
+            assert mem < mem_standard*1.2, msg            
 
         elif host.find('pc-31569') == 0: # DSG's PC
Index: /anuga_validation/automated_validation_tests/validate_all.py
===================================================================
--- /anuga_validation/automated_validation_tests/validate_all.py	(revision 5289)
+++ /anuga_validation/automated_validation_tests/validate_all.py	(revision 5290)
@@ -2,5 +2,5 @@
 """
 
-import os
+import os, time
 
 
@@ -28,4 +28,8 @@
 
 
+print 
+print '----------------------------------------------------------'
+print 'Running all validation tests - this may take several hours'
+print '----------------------------------------------------------'
 
 for path, filename in validation_dirs_and_files:
@@ -33,7 +37,9 @@
 
     os.chdir(path)
-    s = 'python %s' %( filename)
+    s = 'python %s' %(filename)
+    print s
+    t0 = time.time()
     os.system(s)
-    # print 'current dir', os.getcwd() 
+    print 'That took %.2f seconds' %(time.time()-t0)
     
     # Back to parent directory
