Index: development/pyvolution-1d/shallow_water_1d.py
===================================================================
--- development/pyvolution-1d/shallow_water_1d.py	(revision 3425)
+++ development/pyvolution-1d/shallow_water_1d.py	(revision 3510)
@@ -64,5 +64,5 @@
         #forcing terms not included in 1d domain ?WHy?
         self.forcing_terms.append(gravity)
-        self.forcing_terms.append(manning_friction)
+        #self.forcing_terms.append(manning_friction)
         #print "\nI have Removed forcing terms line 64 1dsw"
 
@@ -283,7 +283,5 @@
 
 
-# Flux computation
-#def flux_function(normal, ql, qr, zl, zr):
-def flux_function(normal, ql, qr, zl, zr):
+def flux_function_unsplit(normal, ql, qr, zl, zr):
     """Compute fluxes between volumes for the shallow water wave equation
     cast in terms of w = h+z using the 'central scheme' as described in
@@ -376,4 +374,84 @@
 
     return edgeflux, max_speed
+
+def flux_function_split(normal, ql, qr, zl, zr):
+    from config import g, epsilon
+    from math import sqrt
+    from Numeric import array
+
+    #print 'ql',ql
+
+    #Align momentums with x-axis
+    #q_left  = rotate(ql, normal, direction = 1)
+    #q_right = rotate(qr, normal, direction = 1)
+    q_left = ql
+    q_left[1] = q_left[1]*normal
+    q_right = qr
+    q_right[1] = q_right[1]*normal
+
+    #z = (zl+zr)/2 #Take average of field values
+    z = 0.5*(zl+zr) #Take average of field values
+
+    w_left  = q_left[0]   #w=h+z
+    h_left  = w_left-z
+    uh_left = q_left[1]
+
+    if h_left < epsilon:
+        u_left = 0.0  #Could have been negative
+        h_left = 0.0
+    else:
+        u_left  = uh_left/h_left
+
+
+    w_right  = q_right[0]  #w=h+z
+    h_right  = w_right-z
+    uh_right = q_right[1]
+
+
+    if h_right < epsilon:
+        u_right = 0.0  #Could have been negative
+        h_right = 0.0
+    else:
+        u_right  = uh_right/h_right
+
+    #vh_left  = q_left[2]
+    #vh_right = q_right[2]
+
+    #soundspeed_left  = sqrt(g*h_left)
+    #soundspeed_right = sqrt(g*h_right)
+
+    #Maximal wave speed
+    #s_max = max(u_left+soundspeed_left, u_right+soundspeed_right, 0)
+    s_max = max(u_left, u_right, 0)
+    
+    #Minimal wave speed
+    #s_min = min(u_left-soundspeed_left, u_right-soundspeed_right, 0)
+    s_min = min(u_left, u_right, 0)
+    
+    #Flux computation
+
+    #flux_left  = array([u_left*h_left,
+    #                    u_left*uh_left + 0.5*g*h_left*h_left])
+    #flux_right = array([u_right*h_right,
+    #                    u_right*uh_right + 0.5*g*h_right*h_right])
+    flux_left  = array([u_left*h_left,
+                        u_left*uh_left])# + 0.5*g*h_left*h_left])
+    flux_right = array([u_right*h_right,
+                        u_right*uh_right])# + 0.5*g*h_right*h_right])
+    
+    denom = s_max-s_min
+    if denom == 0.0:
+        edgeflux = array([0.0, 0.0])
+        max_speed = 0.0
+    else:
+        edgeflux = (s_max*flux_left - s_min*flux_right)/denom
+        edgeflux += s_max*s_min*(q_right-q_left)/denom
+        
+        edgeflux[1] = edgeflux[1]*normal
+
+        max_speed = max(abs(s_max), abs(s_min))
+
+    return edgeflux, max_speed    
+
 
 def compute_fluxes(domain):
@@ -471,5 +549,9 @@
             #print 'qr',qr
             
-            edgeflux, max_speed = flux_function(normal, ql, qr, zl, zr)
+
+            if domain.fluxfunc == "unsplit":
+                edgeflux, max_speed = flux_function_unsplit(normal, ql, qr, zl, zr)
+            elif domain.fluxfunc == "split":
+                edgeflux, max_speed = flux_function_split(normal, ql, qr, zl, zr)
             #print 'edgeflux', edgeflux
 
@@ -480,22 +562,5 @@
             try:
                 #timestep = min(timestep, 0.5*domain.radii[k]/max_speed)
-                #timestep = 0.01
-            
                 timestep = min(timestep, domain.cfl*0.5*domain.areas[k]/max_speed)
-                if (timestep < 1e-6) & (enter == True):
-                    #print "domain.order", domain.order
-                    #domain.write_time()
-                    print "cell number", k
-                    print "timestep", timestep
-                    print 'max_speed', max_speed
-                    s = domain.quantities['stage']
-                    s = s.centroid_values
-                    xm = domain.quantities['xmomentum']
-                    xm = xm.centroid_values
-                    print 'h', s[k]
-                    print 'xm', xm[k]
-                    print 'u', xm[k]/s[k]
-                    enter = False
-            
             except ZeroDivisionError:
                 pass
@@ -504,5 +569,5 @@
         #quantities get updated
         flux /= domain.areas[k]
-        # ADD ABOVE LINE AGAIN
+
         Stage.explicit_update[k] = flux[0]
         Xmom.explicit_update[k] = flux[1]
@@ -608,5 +673,5 @@
 
     #Remove very thin layers of water
-    ##protect_against_infinitesimal_and_negative_heights(domain)
+    protect_against_infinitesimal_and_negative_heights(domain)
 
     #Extrapolate all conserved quantities
@@ -1001,5 +1066,6 @@
     #h = Stage.edge_values - Elevation.edge_values
     h = Stage.vertex_values - Elevation.vertex_values
-    v = Elevation.vertex_values
+    b = Elevation.vertex_values
+    w = Stage.vertex_values
 
     x = domain.get_vertex_coordinates()
@@ -1014,11 +1080,17 @@
         x0, x1 = x[k,:]
         #z0, z1, z2 = v[k,:]
-        z0, z1 = v[k,:]
+        b0, b1 = b[k,:]
+
+        w0, w1 = w[k,:]
+        wx = gradient(x0, x1, w0, w1)
 
         #zx, zy = gradient(x0, y0, x1, y1, x2, y2, z0, z1, z2)
-        zx = gradient(x0, x1, z0, z1)
+        bx = gradient(x0, x1, b0, b1)
         
         #Update momentum
-        xmom[k] += -g*zx*avg_h
+        if domain.fluxfunc == "unsplit":
+            xmom[k] += -g*bx*avg_h
+        elif domain.fluxfunc == "split":
+            xmom[k] += -g*wx*avg_h
 #        ymom[k] += -g*zy*avg_h
 
