Index: /trunk/anuga_core/source/anuga/operators/examples/run_bed_shear_erosion.py
===================================================================
--- /trunk/anuga_core/source/anuga/operators/examples/run_bed_shear_erosion.py	(revision 9445)
+++ /trunk/anuga_core/source/anuga/operators/examples/run_bed_shear_erosion.py	(revision 9445)
@@ -0,0 +1,126 @@
+"""Simple water flow example using ANUGA
+
+Water flowing down a channel with a topography that varies with time
+"""
+
+#------------------------------------------------------------------------------
+# Import necessary modules
+#------------------------------------------------------------------------------
+from anuga import rectangular_cross
+from anuga import Domain
+from anuga import Reflective_boundary
+from anuga import Dirichlet_boundary
+from anuga import Time_boundary
+
+import numpy as num
+
+#===============================================================================
+# Setup Functions
+#===============================================================================
+
+
+#------------------------------------------------------------------------------
+# Setup initial conditions
+#------------------------------------------------------------------------------
+def topography(x,y):
+    """Complex topography defined by a function of vectors x and y."""
+    print ' Create topography....'
+    z = -x/100
+
+    N = len(x)
+    for i in range(N):
+        # Step
+        if 2 < x[i] < 4:
+            z[i] += 0.4 - 0.05*y[i]
+
+        # Permanent pole
+        if (x[i] - 8)**2 + (y[i] - 2)**2 < 0.4**2:
+            z[i] += 1
+
+        # Dam
+        #if 12 < x[i] < 13:
+        #    z[i] += 1.4
+    # Sloping Embankment Across Channel
+        if 10.6 < x[i] < 12.1:
+            # Cut Out Segment for Culvert face                
+            z[i] +=  1.0*(x[i] -10.6)    # Sloping Segment  U/S Face
+        if 12.0 < x[i] < 13.0:
+           z[i] +=  1.4                    # Flat Crest of Embankment
+        if 12.9 < x[i] < 13.7:
+            z[i] +=  1.4-2.0*(x[i] -12.9) # Sloping D/S Face
+            
+    return z
+
+
+
+#===============================================================================
+# Setup and Run Model
+#===============================================================================
+
+
+#------------------------------------------------------------------------------
+# Setup computational domain
+#------------------------------------------------------------------------------
+print ' Set up Domain first...'
+length = 24.
+width = 5.
+dx = dy = 0.2 #.1           # Resolution: Length of subdivisions on both axes
+
+points, vertices, boundary = rectangular_cross(int(length/dx), int(width/dy),
+                                               len1=length, len2=width)
+domain = Domain(points, vertices, boundary)
+domain.set_flow_algorithm('2_0')
+domain.set_name('bed_shear_erosion') # Output name
+domain.set_store_vertices_uniquely(True)
+
+print domain.statistics()
+
+domain.set_quantities_to_be_stored({'elevation': 2,
+                                    'stage': 2,
+                                    'xmomentum': 2,
+                                    'ymomentum': 2})
+
+
+
+domain.set_quantity('elevation', topography)           # elevation is a function
+domain.set_quantity('friction', 0.01)                  # Constant friction
+domain.set_quantity('stage', expression='elevation')   # Dry initial condition
+
+#------------------------------------------------------------------------------
+# Setup boundary conditions
+#------------------------------------------------------------------------------
+Bi = Dirichlet_boundary([1.5, 0, 0])          # Inflow
+Br = Reflective_boundary(domain)              # Solid reflective wall
+Bo = Dirichlet_boundary([-5, 0, 0])           # Outflow
+
+domain.set_boundary({'left': Bi, 'right': Bo, 'top': Br, 'bottom': Br})
+
+#------------------------------------------------------------------------------
+# Setup erosion operator in the middle of dam
+#------------------------------------------------------------------------------
+print 'Set up Erosion Area to test...'
+
+from rudy_erosion import Bed_shear_erosion_operator
+polygon1 = [ [10.6, 1.0], [13.7, 1.0], [13.7, 4.0], [10.6, 4.0] ]
+
+
+# create operator
+op1 = Bed_shear_erosion_operator(domain, threshold=2.0, shear_factor=1000.0, polygon=polygon1)
+
+
+#------------------------------------------------------------------------------
+# Evolve system through time
+#------------------------------------------------------------------------------
+for t in domain.evolve(yieldstep=0.1, finaltime=15.0):
+    domain.print_timestepping_statistics()
+    #domain.print_operator_timestepping_statistics()
+
+
+
+
+
+
+
+
+
+
Index: /trunk/anuga_core/source/anuga/operators/examples/run_change_elevation.py
===================================================================
--- /trunk/anuga_core/source/anuga/operators/examples/run_change_elevation.py	(revision 9445)
+++ /trunk/anuga_core/source/anuga/operators/examples/run_change_elevation.py	(revision 9445)
@@ -0,0 +1,119 @@
+"""Simple water flow example using ANUGA
+
+Water flowing down a channel with a topography that varies with time
+"""
+
+#------------------------------------------------------------------------------
+# Import necessary modules
+#------------------------------------------------------------------------------
+import numpy
+from anuga import rectangular_cross
+from anuga import Domain
+from anuga import Reflective_boundary
+from anuga import Dirichlet_boundary
+from anuga import Time_boundary
+
+#------------------------------------------------------------------------------
+# Setup computational domain
+#------------------------------------------------------------------------------
+length = 24.
+width = 5.
+dx = dy = 0.2 #.1           # Resolution: Length of subdivisions on both axes
+
+points, vertices, boundary = rectangular_cross(int(length/dx), int(width/dy),
+                                               len1=length, len2=width)
+domain = Domain(points, vertices, boundary)
+domain.set_name()
+print domain.statistics()
+domain.set_quantities_to_be_stored({'elevation': 2,
+                                    'stage': 2,
+                                    'xmomentum': 2,
+                                    'ymomentum': 2})
+
+#------------------------------------------------------------------------------
+# Setup initial conditions
+#------------------------------------------------------------------------------
+def topography_dam(x,y):
+    """Complex topography defined by a function of vectors x and y."""
+
+    z = -x/100
+
+    # Step
+    id = (2 < x) & (x < 4)
+    z[id] += 0.4 - 0.05*y[id]
+
+
+    # Permanent pole
+    #id = (x - 8)**2 + (y - 2)**2 < 0.4**2
+    #z[id] += 1
+
+
+    # Dam
+    id = (12 < x) & (x  < 13)
+    z[id] += 0.4
+
+
+            
+    return z
+
+def topography_dam_break(x,y):
+    """Complex topography defined by a function of vectors x and y."""
+
+    z = -x/100
+    
+    # Step
+    id = (2 < x) & (x < 4)
+    z[id] += 0.4 - 0.05*y[id]
+
+
+    # Permanent pole
+    #id = (x - 8)**2 + (y - 2)**2 < 0.4**2
+    #z[id] += 1
+
+    # Dam with hole
+    id = (12 < x) & (x < 13) and (y > 3.0)
+    z[id] += 0.4
+
+    id = (12 < x) & (x < 13) and (y < 2.0)
+    z[id] += 0.4
+
+
+    return z
+
+
+domain.set_quantity('elevation', topography_dam)       # elevation is a function
+domain.set_quantity('friction', 0.01)                  # Constant friction
+domain.set_quantity('stage', expression='elevation')   # Dry initial condition
+
+#------------------------------------------------------------------------------
+# Setup boundary conditions
+#------------------------------------------------------------------------------
+Bi = Dirichlet_boundary([0.4, 0, 0])          # Inflow
+Br = Reflective_boundary(domain)              # Solid reflective wall
+Bo = Dirichlet_boundary([-5, 0, 0])           # Outflow
+
+domain.set_boundary({'left': Bi, 'right': Bo, 'top': Br, 'bottom': Br})
+
+#------------------------------------------------------------------------------
+# Evolve system through time
+#------------------------------------------------------------------------------
+
+from anuga.operators.set_elevation import Set_elevation
+op1 = Set_elevation(domain, elevation=lambda x,y : -x/100, radius=1.0, center = (12.5,3.0))
+
+
+#dam_break = False
+
+for t in domain.evolve(yieldstep=0.1, finaltime=30.0):
+    domain.print_timestepping_statistics()
+    domain.print_operator_timestepping_statistics()
+
+    if numpy.allclose(t, 10.0):
+        print 'changing elevation'
+        op1()
+
+
+
+
+
+
Index: /trunk/anuga_core/source/anuga/operators/examples/run_collect_max_stage_operator.py
===================================================================
--- /trunk/anuga_core/source/anuga/operators/examples/run_collect_max_stage_operator.py	(revision 9445)
+++ /trunk/anuga_core/source/anuga/operators/examples/run_collect_max_stage_operator.py	(revision 9445)
@@ -0,0 +1,95 @@
+"""Simple water flow example using ANUGA
+
+Water driven up a linear slope and time varying boundary,
+similar to a beach environment
+"""
+
+#------------------------------------------------------------------------------
+# Import necessary modules
+#------------------------------------------------------------------------------
+
+import sys
+import anuga
+
+
+from math import cos
+from numpy import zeros, float, where
+import numpy
+from time import localtime, strftime, gmtime
+
+
+#------------------------------------------------------------------------------
+# Setup domain
+#------------------------------------------------------------------------------
+dx = 1000.
+dy = dx
+L = 100000.
+W = 10*dx
+#W = dx
+
+# structured mesh
+domain = anuga.rectangular_cross_domain(int(L/dx), int(W/dy), L, W, (0.0, -W/2))
+
+domain.set_name() # based on script name
+
+print domain.mesh.statistics(nbins=50)
+
+#------------------------------------------------------------------------------
+# Setup Algorithm
+#------------------------------------------------------------------------------
+domain.set_flow_algorithm('2_0')
+
+#------------------------------------------------------------------------------
+# Setup initial conditions
+#------------------------------------------------------------------------------
+h0 = 10.0
+h1 = 0.0
+
+def elevation(x,y):
+
+    return where(x<=95000.0, 0.0, h0)
+
+def height(x,y):
+
+    return where(x<=50000.0, h0, h1)
+
+domain.set_quantity('elevation',elevation)
+domain.set_quantity('friction', 0.0)
+domain.add_quantity('stage', height)
+
+#-----------------------------------------------------------------------------
+# Setup boundary conditions
+#------------------------------------------------------------------------------
+from math import sin, pi, exp
+Br = anuga.Reflective_boundary(domain)      # Solid reflective wall
+Bt = anuga.Transmissive_boundary(domain)    # Continue all values on boundary 
+Bd = anuga.Dirichlet_boundary([1,0.,0.])    # Constant boundary values
+
+
+# Associate boundary tags with boundary objects
+domain.set_boundary({'left': Br, 'right': Br, 'top': Br, 'bottom': Br})
+
+#-----------------------------------------------------------------------------
+# Setup operators that will be applied each inner timestep
+#------------------------------------------------------------------------------
+from anuga.operators.collect_max_stage_operator import Collect_max_stage_operator
+max_operator = Collect_max_stage_operator(domain)
+
+#------------------------------------------------------------------------------
+# Evolve system through time
+#------------------------------------------------------------------------------
+for t in domain.evolve(yieldstep = 100.0, finaltime = 60*60.):
+    #print domain.timestepping_statistics(track_speeds=True)
+    domain.print_timestepping_statistics()
+    domain.print_operator_timestepping_statistics()
+
+
+# save the max_stage centroid data to a text file
+max_operator.save_centroid_data_to_csv()
+
+# Let's have a look at the max_stage
+#max_operator.plot_quantity()
+
+
+
+
Index: /trunk/anuga_core/source/anuga/operators/examples/run_flat_fill_slice_erosion.py
===================================================================
--- /trunk/anuga_core/source/anuga/operators/examples/run_flat_fill_slice_erosion.py	(revision 9445)
+++ /trunk/anuga_core/source/anuga/operators/examples/run_flat_fill_slice_erosion.py	(revision 9445)
@@ -0,0 +1,134 @@
+"""Simple water flow example using ANUGA
+
+Water flowing down a channel with a topography that varies with time
+"""
+
+#------------------------------------------------------------------------------
+# Import necessary modules
+#------------------------------------------------------------------------------
+from anuga import rectangular_cross
+from anuga import Domain
+from anuga import Reflective_boundary
+from anuga import Dirichlet_boundary
+from anuga import Time_boundary
+
+import numpy as num
+
+#===============================================================================
+# Setup Functions
+#===============================================================================
+
+#------------------------------------------------------------------------------
+# Setup initial conditions
+#------------------------------------------------------------------------------
+def topography(x,y):
+    """Complex topography defined by a function of vectors x and y."""
+    print ' Create topography....'
+    z = -x/100
+
+    N = len(x)
+    for i in range(N):
+        # Step
+        if 2 < x[i] < 4:
+            z[i] += 0.4 - 0.05*y[i]
+
+        # Permanent pole
+        if (x[i] - 8)**2 + (y[i] - 2)**2 < 0.4**2:
+            z[i] += 1
+
+        # Dam
+        #if 12 < x[i] < 13:
+        #    z[i] += 1.4
+    # Sloping Embankment Across Channel
+        if 10.6 < x[i] < 12.1:
+            # Cut Out Segment for Culvert face                
+            z[i] +=  1.0*(x[i] -10.6)    # Sloping Segment  U/S Face
+        if 12.0 < x[i] < 13.0:
+           z[i] +=  1.4                    # Flat Crest of Embankment
+        if 12.9 < x[i] < 13.7:
+            z[i] +=  1.4-2.0*(x[i] -12.9) # Sloping D/S Face
+            
+    return z
+
+
+
+#===============================================================================
+# Setup and Run Model
+#===============================================================================
+
+
+#------------------------------------------------------------------------------
+# Setup computational domain
+#------------------------------------------------------------------------------
+print ' Set up Domain first...'
+length = 24.
+width = 5.
+dx = dy = 0.2 #.1           # Resolution: Length of subdivisions on both axes
+
+points, vertices, boundary = rectangular_cross(int(length/dx), int(width/dy),
+                                               len1=length, len2=width)
+domain = Domain(points, vertices, boundary)
+domain.set_flow_algorithm('DE1')
+domain.set_name('flat_fill_slice_erosion') # Output name
+print domain.statistics()
+
+domain.set_quantities_to_be_stored({'elevation': 2,
+                                    'stage': 2,
+                                    'xmomentum': 2,
+                                    'ymomentum': 2})
+
+
+
+domain.set_quantity('elevation', topography)           # elevation is a function
+domain.set_quantity('friction', 0.01)                  # Constant friction
+domain.set_quantity('stage', expression='elevation')   # Dry initial condition
+
+#------------------------------------------------------------------------------
+# Setup boundary conditions
+#------------------------------------------------------------------------------
+Bi = Dirichlet_boundary([1.5, 0, 0])          # Inflow
+Br = Reflective_boundary(domain)              # Solid reflective wall
+Bo = Dirichlet_boundary([-5, 0, 0])           # Outflow
+
+domain.set_boundary({'left': Bi, 'right': Bo, 'top': Br, 'bottom': Br})
+
+#------------------------------------------------------------------------------
+# Setup erosion operator in the middle of dam
+#------------------------------------------------------------------------------
+print 'Set up Erosion Area to test...'
+
+from anuga import Flat_fill_slice_erosion_operator as Default_erosion_operator
+from anuga import Set_elevation_operator as Default_erosion_operator
+
+polygon1 = [ [10.6, 1.0], [13.7, 1.0], [13.7, 4.0], [10.6, 4.0] ]
+
+# setup interpolated function
+time = num.array([ 5.0 , 8.0])
+elev = num.array([ 1.4,  2.0])
+
+from scipy.interpolate import interp1d
+flevel = interp1d(time,elev)
+
+# create operator
+op1 = Default_erosion_operator(domain, elevation=flevel, polygon=polygon1)
+
+
+
+
+
+#------------------------------------------------------------------------------
+# Evolve system through time
+#------------------------------------------------------------------------------
+for t in domain.evolve(yieldstep=0.1, finaltime=15.0):
+    domain.print_timestepping_statistics()
+    #domain.print_operator_timestepping_statistics()
+
+
+
+
+
+
+
+
+
+
Index: /trunk/anuga_core/source/anuga/operators/examples/run_flat_slice_erosion.py
===================================================================
--- /trunk/anuga_core/source/anuga/operators/examples/run_flat_slice_erosion.py	(revision 9445)
+++ /trunk/anuga_core/source/anuga/operators/examples/run_flat_slice_erosion.py	(revision 9445)
@@ -0,0 +1,133 @@
+"""Simple water flow example using ANUGA
+
+Water flowing down a channel with a topography that varies with time
+"""
+
+#------------------------------------------------------------------------------
+# Import necessary modules
+#------------------------------------------------------------------------------
+from anuga import rectangular_cross
+from anuga import Domain
+from anuga import Reflective_boundary
+from anuga import Dirichlet_boundary
+from anuga import Time_boundary
+
+import numpy as num
+
+#===============================================================================
+# Setup Functions
+#===============================================================================
+
+
+#------------------------------------------------------------------------------
+# Setup initial conditions
+#------------------------------------------------------------------------------
+def topography(x,y):
+    """Complex topography defined by a function of vectors x and y."""
+    print ' Create topography....'
+    z = -x/100
+
+    N = len(x)
+    for i in range(N):
+        # Step
+        if 2 < x[i] < 4:
+            z[i] += 0.4 - 0.05*y[i]
+
+        # Permanent pole
+        if (x[i] - 8)**2 + (y[i] - 2)**2 < 0.4**2:
+            z[i] += 1
+
+        # Dam
+        #if 12 < x[i] < 13:
+        #    z[i] += 1.4
+    # Sloping Embankment Across Channel
+        if 10.6 < x[i] < 12.1:
+            # Cut Out Segment for Culvert face                
+            z[i] +=  1.0*(x[i] -10.6)    # Sloping Segment  U/S Face
+        if 12.0 < x[i] < 13.0:
+           z[i] +=  1.4                    # Flat Crest of Embankment
+        if 12.9 < x[i] < 13.7:
+            z[i] +=  1.4-2.0*(x[i] -12.9) # Sloping D/S Face
+            
+    return z
+
+
+
+#===============================================================================
+# Setup and Run Model
+#===============================================================================
+
+
+#------------------------------------------------------------------------------
+# Setup computational domain
+#------------------------------------------------------------------------------
+print ' Set up Domain first...'
+length = 24.
+width = 5.
+dx = dy = 0.2 #.1           # Resolution: Length of subdivisions on both axes
+
+points, vertices, boundary = rectangular_cross(int(length/dx), int(width/dy),
+                                               len1=length, len2=width)
+domain = Domain(points, vertices, boundary)
+domain.set_flow_algorithm('DE1')
+domain.set_name('flat_slice_erosion') # Output name
+print domain.statistics()
+
+domain.set_quantities_to_be_stored({'elevation': 2,
+                                    'stage': 2,
+                                    'xmomentum': 2,
+                                    'ymomentum': 2})
+
+
+
+domain.set_quantity('elevation', topography)           # elevation is a function
+domain.set_quantity('friction', 0.01)                  # Constant friction
+domain.set_quantity('stage', expression='elevation')   # Dry initial condition
+
+#------------------------------------------------------------------------------
+# Setup boundary conditions
+#------------------------------------------------------------------------------
+Bi = Dirichlet_boundary([1.5, 0, 0])          # Inflow
+Br = Reflective_boundary(domain)              # Solid reflective wall
+Bo = Dirichlet_boundary([-5, 0, 0])           # Outflow
+
+domain.set_boundary({'left': Bi, 'right': Bo, 'top': Br, 'bottom': Br})
+
+#------------------------------------------------------------------------------
+# Setup erosion operator in the middle of dam
+#------------------------------------------------------------------------------
+print 'Set up Erosion Area to test...'
+
+from rudy_erosion import Flat_slice_erosion_operator
+polygon1 = [ [10.6, 1.0], [13.7, 1.0], [13.7, 4.0], [10.6, 4.0] ]
+
+# setup interpolated function
+time = num.array([ 2.0 , 10.0])
+elev = num.array([ 1.4,  -0.1])
+
+from scipy.interpolate import interp1d
+flevel = interp1d(time,elev)
+
+# create operator
+op1 = Flat_slice_erosion_operator(domain, elevation=flevel, polygon=polygon1)
+
+
+
+
+
+#------------------------------------------------------------------------------
+# Evolve system through time
+#------------------------------------------------------------------------------
+for t in domain.evolve(yieldstep=0.1, finaltime=15.0):
+    domain.print_timestepping_statistics()
+    #domain.print_operator_timestepping_statistics()
+
+
+
+
+
+
+
+
+
+
Index: /trunk/anuga_core/source/anuga/operators/examples/run_polygon_erosion.py
===================================================================
--- /trunk/anuga_core/source/anuga/operators/examples/run_polygon_erosion.py	(revision 9445)
+++ /trunk/anuga_core/source/anuga/operators/examples/run_polygon_erosion.py	(revision 9445)
@@ -0,0 +1,163 @@
+"""Simple water flow example using ANUGA
+
+Water flowing down a channel with a topography that varies with time
+"""
+
+#------------------------------------------------------------------------------
+# Import necessary modules
+#------------------------------------------------------------------------------
+from anuga import rectangular_cross
+from anuga import Domain
+from anuga import Reflective_boundary
+from anuga import Dirichlet_boundary
+from anuga import Time_boundary
+
+
+
+#===============================================================================
+# Stick all the class and function definitions here
+#===============================================================================
+
+#-------------------------------------------------------------------------------
+# Here are the def's for defining quantities
+#-------------------------------------------------------------------------------
+def topography(x,y):
+    """Complex topography defined by a function of vectors x and y."""
+
+    z = -x/100
+
+    # Step
+    id = (2 < x) & (x < 4)
+    z[id] += 0.4 - 0.05*y[id]
+
+    # Permanent pole
+    id = (x - 8)**2 + (y - 2)**2 < 0.4**2
+    z[id] += 1
+
+    # Dam
+    id = (12 < x) & (x < 13)
+    z[id] += 0.4
+
+    return z
+
+
+#-------------------------------------------------------------------------------
+# Inherit from erosion operator
+#-------------------------------------------------------------------------------
+from anuga.operators.erosion_operators import Polygonal_erosion_operator
+
+class My_polygon_erosion_operator(Polygonal_erosion_operator):
+    """
+    Local version of erosion confined to a polygon
+
+    """
+
+    def __init__(self, domain,
+                 threshold=0.0,
+                 base=0.0,
+                 polygon=None,
+                 verbose=False):
+
+
+        Polygonal_erosion_operator.__init__(self, domain, threshold, base, polygon, verbose)
+
+
+
+    def update_quantities(self):
+        """Update the vertex values of the quantities to model erosion
+        """
+        import numpy as num
+        
+        t = self.get_time()
+        dt = self.get_timestep()
+
+        updated = True
+
+        if self.indices is None:
+
+            #--------------------------------------
+            # Update all three vertices for each cell
+            #--------------------------------------
+            self.elev_v[:] = self.elev_v + 0.0
+
+        else:
+
+            #--------------------------------------
+            # Update all three vertices for each cell
+            #--------------------------------------
+            ind = self.indices
+            m = num.sqrt(self.xmom_c[ind]**2 + self.ymom_c[ind]**2)
+            m = num.vstack((m,m,m)).T
+            m = num.where(m>self.threshold, m, 0.0)
+            self.elev_v[ind] = num.maximum(self.elev_v[ind] - m*dt, self.base)
+             #num.maximum(self.elev_v[ind] - momentum*dt, Z)
+
+
+        return updated
+
+
+
+#===============================================================================
+# Now to the standard anuga model setup
+#===============================================================================
+
+
+#-------------------------------------------------------------------------------
+# Setup computational domain
+#-------------------------------------------------------------------------------
+length = 24.
+width = 5.
+dx = dy = 0.2 #.1           # Resolution: Length of subdivisions on both axes
+
+points, vertices, boundary = rectangular_cross(int(length/dx), int(width/dy),
+                                               len1=length, len2=width)
+domain = Domain(points, vertices, boundary)
+domain.set_name() # Output name based on script
+print domain.statistics()
+domain.set_quantities_to_be_stored({'elevation': 2,
+                                    'stage': 2,
+                                    'xmomentum': 2,
+                                    'ymomentum': 2})
+
+#-------------------------------------------------------------------------------
+# Setup initial conditions
+#-------------------------------------------------------------------------------
+
+
+domain.set_quantity('elevation', topography)           # elevation is a function
+domain.set_quantity('friction', 0.01)                  # Constant friction
+domain.set_quantity('stage', expression='elevation')   # Dry initial condition
+
+#-------------------------------------------------------------------------------
+# Setup boundary conditions
+#-------------------------------------------------------------------------------
+Bi = Dirichlet_boundary([0.5, 0, 0])          # Inflow
+Br = Reflective_boundary(domain)              # Solid reflective wall
+Bo = Dirichlet_boundary([-5, 0, 0])           # Outflow
+
+domain.set_boundary({'left': Bi, 'right': Bo, 'top': Br, 'bottom': Br})
+
+#-------------------------------------------------------------------------------
+# Setup erosion operator in the middle of dam
+#-------------------------------------------------------------------------------
+polygon1 = [ [12., 0.0], [13., 0.0], [13., 5.0], [12., 5.0] ]
+op1 = My_polygon_erosion_operator(domain, threshold=0.0, base=-0.1, polygon=polygon1)
+
+
+
+
+#-------------------------------------------------------------------------------
+# Evolve system through time
+#-------------------------------------------------------------------------------
+for t in domain.evolve(yieldstep=0.2, finaltime=60.0):
+    domain.print_timestepping_statistics()
+    domain.print_operator_timestepping_statistics()
+
+
+
+
+
+
+
+
+
Index: /trunk/anuga_core/source/anuga/operators/examples/run_rate_operator.py
===================================================================
--- /trunk/anuga_core/source/anuga/operators/examples/run_rate_operator.py	(revision 9445)
+++ /trunk/anuga_core/source/anuga/operators/examples/run_rate_operator.py	(revision 9445)
@@ -0,0 +1,146 @@
+"""Simple water flow example using ANUGA
+
+Water flowing down a channel with a topography that varies with time
+"""
+
+#------------------------------------------------------------------------------
+# Import necessary modules
+#------------------------------------------------------------------------------
+from anuga import rectangular_cross
+from anuga import Domain
+from anuga import Reflective_boundary
+from anuga import Dirichlet_boundary
+from anuga import Time_boundary
+import os
+
+
+#------------------------------------------------------------------------------
+# Setup computational domain
+#------------------------------------------------------------------------------
+length = 24.
+width = 5.
+dx = dy = 0.2 #.1           # Resolution: Length of subdivisions on both axes
+
+points, vertices, boundary = rectangular_cross(int(length/dx), int(width/dy),
+                                               len1=length, len2=width)
+domain = Domain(points, vertices, boundary)
+domain.set_name() # Output name based on script name. You can add timestamp=True
+print domain.statistics()
+
+
+#------------------------------------------------------------------------------
+# Setup initial conditions
+#------------------------------------------------------------------------------
+def topography(x,y):
+    """Complex topography defined by a function of vectors x and y."""
+
+    z = -x/100
+
+    # Step
+    id = (2 < x) & (x < 4)
+    z[id] += 0.4 - 0.05*y[id]
+
+
+    # Permanent pole
+    #id = (x - 8)**2 + (y - 2)**2 < 0.4**2
+    #z[id] += 1
+
+
+    # Dam
+    #id = (12 < x) & (x  < 13)
+    #z[id] += 0.4
+
+
+
+            
+    return z
+
+
+def pole_increment(x,y,t):
+    """This provides a small increment to a pole located mid stream
+    For use with variable elevation data
+    """
+
+    z = 0.0*x    
+
+    if t<10.0:
+        return z
+    
+
+    # Pole 1
+    id = (x - 12)**2 + (y - 3)**2 < 0.4**2
+    z[id] += 0.1
+
+
+    # Pole 2
+    id = (x - 14)**2 + (y - 2)**2 < 0.4**2
+    z[id] += 0.05
+
+
+    return z
+
+
+def pole(t):
+
+    if t<10:
+        return 0.0
+    elif t>15:
+        return 0.0
+    else:
+        return 0.05
+
+
+domain.set_quantity('elevation', topography)           # elevation is a function
+domain.set_quantity('friction', 0.01)                  # Constant friction
+domain.set_quantity('stage', expression='elevation')   # Dry initial condition
+
+#------------------------------------------------------------------------------
+# Setup boundary conditions
+#------------------------------------------------------------------------------
+Bi = Dirichlet_boundary([0.4, 0, 0])          # Inflow
+Br = Reflective_boundary(domain)              # Solid reflective wall
+Bo = Dirichlet_boundary([-5, 0, 0])           # Outflow
+
+domain.set_boundary({'left': Br, 'right': Br, 'top': Br, 'bottom': Br})
+
+#------------------------------------------------------------------------------
+# Evolve system through time
+#------------------------------------------------------------------------------
+polygon1 = [ [10.0, 0.0], [11.0, 0.0], [11.0, 5.0], [10.0, 5.0] ]
+polygon2 = [ [12.0, 2.0], [13.0, 2.0], [13.0, 3.0], [12.0, 3.0] ]
+
+from anuga.operators.rate_operators import Rate_operator
+
+op1 = Rate_operator(domain, rate=lambda t: 10.0 if (t>=0.0) else 0.0, polygon=polygon2)
+op2 = Rate_operator(domain, rate=lambda t: 10.0 if (t>=0.0) else 0.0, radius=0.5, center=(10.0, 3.0))
+
+
+domain.set_starttime(-0.1)
+for t in domain.evolve(yieldstep=0.01, finaltime=0.0):
+    domain.print_timestepping_statistics()
+    domain.print_operator_timestepping_statistics()
+
+    stage = domain.get_quantity('stage')
+    elev  = domain.get_quantity('elevation')
+    height = stage - elev
+
+    print 'integral = ', height.get_integral()
+
+
+for t in domain.evolve(yieldstep=0.1, duration=5.0):
+
+    domain.print_timestepping_statistics()
+    domain.print_operator_timestepping_statistics()
+
+    stage = domain.get_quantity('stage')
+    elev  = domain.get_quantity('elevation')
+    height = stage - elev
+
+    print 'integral = ', height.get_integral()
+
+
+
+
+
+
+
Index: /trunk/anuga_core/source/anuga/operators/examples/run_rate_spatial_operator.py
===================================================================
--- /trunk/anuga_core/source/anuga/operators/examples/run_rate_spatial_operator.py	(revision 9445)
+++ /trunk/anuga_core/source/anuga/operators/examples/run_rate_spatial_operator.py	(revision 9445)
@@ -0,0 +1,180 @@
+"""Simple water flow example using ANUGA
+
+Water flowing down a channel with a topography that varies with time
+"""
+
+#------------------------------------------------------------------------------
+# Import necessary modules
+#------------------------------------------------------------------------------
+import numpy
+from anuga import rectangular_cross
+from anuga import Domain
+from anuga import Reflective_boundary
+from anuga import Dirichlet_boundary
+from anuga import Time_boundary
+
+from anuga import indent
+
+
+#------------------------------------------------------------------------------
+# Setup computational domain
+#------------------------------------------------------------------------------
+length = 24.
+width = 5.
+dx = dy = 0.2 #.1           # Resolution: Length of subdivisions on both axes
+
+points, vertices, boundary = rectangular_cross(int(length/dx), int(width/dy),
+                                               len1=length, len2=width)
+domain = Domain(points, vertices, boundary)
+domain.set_name() # Output name based on script
+print domain.statistics()
+
+
+#------------------------------------------------------------------------------
+# Setup initial conditions
+#------------------------------------------------------------------------------
+def topography(x,y):
+    """Complex topography defined by a function of vectors x and y."""
+
+    z = -x/100
+
+    N = len(x)
+    for i in range(N):
+        # Step
+        if 2 < x[i] < 4:
+            z[i] += 0.4 - 0.05*y[i]
+
+        # Permanent pole
+        #if (x[i] - 8)**2 + (y[i] - 2)**2 < 0.4**2:
+        #    z[i] += 1
+
+
+#        # Dam
+#        if 12 < x[i] < 13 and y[i] > 3.0:
+#            z[i] += 0.4
+#
+#        if 12 < x[i] < 13 and y[i] < 2.0:
+#            z[i] += 0.4
+
+
+#        # Dam
+#        if 12 < x[i] < 13:
+#            z[i] += 0.4
+
+            
+    return z
+
+
+def pole_increment(x,y,t):
+    """This provides a small increment to a pole located mid stream
+    For use with variable elevation data
+    """
+
+    z = 0.0*x
+    
+    if t<10.0:
+        return z
+    
+    N = len(x)
+    for i in range(N):
+        # Pole 1
+        if (x[i] - 12)**2 + (y[i] - 3)**2 < 0.4**2:
+            z[i] += 0.1
+
+    for i in range(N):
+        # Pole 2
+        if (x[i] - 14)**2 + (y[i] - 2)**2 < 0.4**2:
+            z[i] += 0.05
+
+    return z
+
+
+def pole(t):
+
+    if t<10:
+        return 0.0
+    elif t>15:
+        return 0.0
+    else:
+        return 0.05
+
+
+domain.set_quantity('elevation', topography)           # elevation is a function
+domain.set_quantity('friction', 0.01)                  # Constant friction
+domain.set_quantity('stage', expression='elevation')   # Dry initial condition
+
+#------------------------------------------------------------------------------
+# Setup boundary conditions
+#------------------------------------------------------------------------------
+Bi = Dirichlet_boundary([0.4, 0, 0])          # Inflow
+Br = Reflective_boundary(domain)              # Solid reflective wall
+Bo = Dirichlet_boundary([-5, 0, 0])           # Outflow
+
+domain.set_boundary({'left': Br, 'right': Br, 'top': Br, 'bottom': Br})
+
+#------------------------------------------------------------------------------
+# Evolve system through time
+#------------------------------------------------------------------------------
+polygon1 = [ [10.0, 0.0], [11.0, 0.0], [11.0, 5.0], [10.0, 5.0] ]
+polygon2 = [ [12.0, 2.0], [13.0, 2.0], [13.0, 3.0], [12.0, 3.0] ]
+
+
+from anuga.operators.rate_operators import Rate_operator
+
+op1 = Rate_operator(domain, rate=10.0, polygon=polygon2)
+
+area1 = numpy.sum(domain.areas[op1.indices])
+Q1 = 10.0*area1
+print 'op1 Q ',Q1
+
+op2 = Rate_operator(domain, rate=10.0, radius=0.5, center=(10.0, 3.0))
+
+area2 = numpy.sum(domain.areas[op2.indices])
+Q2 = 10.0*area2
+print 'op2 Q ',Q2
+
+
+def rain(x,y,t):
+    """Function to calculate "rain"
+    input x,y should be considered to be numpy arrays
+    abd t a scalar
+    """
+    if t<=4.0:
+        return (x+y)*1.0
+    else:
+        return 0.0*x
+
+factor = 1e-3
+op3 = Rate_operator(domain, rate = rain, factor=factor)
+Q3 = numpy.sum(op3.get_spatial_rate()*domain.areas)*factor
+
+
+#op3()
+#domain.fractional_step_operators.remove(op3)
+
+
+#------------------------------------------------------------------------------
+# Evolve system through time
+#------------------------------------------------------------------------------
+accum = 0.0
+yieldstep = 0.1
+finaltime = 5.0
+for t in domain.evolve(yieldstep=yieldstep, finaltime=finaltime):
+    domain.print_timestepping_statistics()
+    domain.print_operator_timestepping_statistics()
+
+    stage = domain.get_quantity('stage')
+    elev  = domain.get_quantity('elevation')
+    height = stage - elev
+
+    print indent + 'Integral = ', height.get_integral()
+    print indent + 'Exact accumultion = ', accum
+    
+    dd = max(min(yieldstep,4.0-t),0.0)
+    accum += (Q1+Q2)*yieldstep + dd*Q3
+
+
+
+
+
+
Index: /trunk/anuga_core/source/anuga/operators/examples/run_set_depth_friction.py
===================================================================
--- /trunk/anuga_core/source/anuga/operators/examples/run_set_depth_friction.py	(revision 9445)
+++ /trunk/anuga_core/source/anuga/operators/examples/run_set_depth_friction.py	(revision 9445)
@@ -0,0 +1,109 @@
+"""Simple water flow example using ANUGA
+
+Water flowing down a channel with a topography that varies with time
+"""
+
+#------------------------------------------------------------------------------
+# Import necessary modules
+#------------------------------------------------------------------------------
+from anuga import rectangular_cross
+from anuga import Domain
+from anuga import Reflective_boundary
+from anuga import Dirichlet_boundary
+from anuga import Time_boundary
+from anuga import Region
+from anuga import indent
+
+#------------------------------------------------------------------------------
+# Setup computational domain
+#------------------------------------------------------------------------------
+length = 24.
+width = 5.
+dx = dy = 0.2 #.1           # Resolution: Length of subdivisions on both axes
+
+points, vertices, boundary = rectangular_cross(int(length/dx), int(width/dy),
+                                               len1=length, len2=width)
+domain = Domain(points, vertices, boundary)
+domain.set_name() # Output name
+print domain.statistics()
+
+
+#------------------------------------------------------------------------------
+# Setup initial conditions
+#------------------------------------------------------------------------------
+def topography(x,y):
+    """Complex topography defined by a function of vectors x and y."""
+
+    z = -x/100
+
+    # Step
+    id = ( 2 < x ) & (x < 4)
+    z[id] +=  0.4 - 0.05*y[id]
+
+    # Permanent pole
+    id = (x - 8)**2 + (y - 2)**2 < 0.4**2
+    z[id] += 1
+
+    # Pole 2
+    #id =  (x - 14)**2 + (y - 3.5)**2 < 0.4**2
+    #z[id] += 1.0
+
+
+    return z
+
+
+
+domain.set_quantity('elevation', topography)           # elevation is a function
+domain.set_quantity('friction', 0.01)                  # Constant friction
+domain.set_quantity('stage', expression='elevation')   # Dry initial condition
+
+#------------------------------------------------------------------------------
+# Setup boundary conditions
+#------------------------------------------------------------------------------
+Bi = Dirichlet_boundary([0.4, 0, 0])          # Inflow
+Br = Reflective_boundary(domain)              # Solid reflective wall
+Bo = Dirichlet_boundary([-5, 0, 0])           # Outflow
+
+domain.set_boundary({'left': Bi, 'right': Bo, 'top': Br, 'bottom': Br})
+
+#------------------------------------------------------------------------------
+# Setup operators which are applied each inner step
+#------------------------------------------------------------------------------
+from anuga.operators.set_friction_operators import Depth_friction_operator
+from scipy import interpolate
+
+h = [0.0,     0.2,   0.4,   0.8,   2.0, 99.0]
+n = [0.250, 0.060, 0.045, 0.035, 0.025, 0.025]
+
+friction = interpolate.interp1d(h, n, fill_value=0.025)
+op1 = Depth_friction_operator(domain,friction=friction)
+
+#p1 = [ [12.0, 2.5], [13.5, 2.5], [13.5, 4.0], [12.0, 4.0] ]
+#op2 = Depth_friction_operator(domain,
+#                                  friction = lambda h :10,
+#                                  polygon=p1)
+
+# Setup region for integrating quantities
+p2 = [ [8.0, 2.5], [9.5, 2.5], [9.5, 4.0], [8.0, 4.0] ]
+reg = Region(domain, polygon=p2)
+
+# Some useful aliases
+stage = domain.quantities['stage']
+elev = domain.quantities['elevation']
+
+#------------------------------------------------------------------------------
+# Evolve system through time
+#------------------------------------------------------------------------------
+for t in domain.evolve(yieldstep=0.1, finaltime=10.0):
+    domain.print_timestepping_statistics()
+    domain.print_operator_timestepping_statistics()
+
+    # let calculate the integral of height over a region
+    height = stage-elev
+    print indent+'Int_p2(h) = '+str(height.get_integral(region=reg))
+
+
+
+
+
+
Index: /trunk/anuga_core/source/anuga/operators/examples/run_set_elevation.py
===================================================================
--- /trunk/anuga_core/source/anuga/operators/examples/run_set_elevation.py	(revision 9445)
+++ /trunk/anuga_core/source/anuga/operators/examples/run_set_elevation.py	(revision 9445)
@@ -0,0 +1,137 @@
+"""Simple water flow example using ANUGA
+
+Water flowing down a channel with a topography that varies with time
+"""
+
+import numpy as num
+
+#------------------------------------------------------------------------------
+# Import necessary modules
+#------------------------------------------------------------------------------
+from anuga import rectangular_cross
+from anuga import Domain
+from anuga import Reflective_boundary
+from anuga import Dirichlet_boundary
+from anuga import Time_boundary
+
+
+#------------------------------------------------------------------------------
+# Stage and Elevation Functions
+#------------------------------------------------------------------------------
+def topography(x,y):
+    """Complex topography defined by a function of vectors x and y."""
+
+
+    z = -x/100
+
+
+    # Step
+    id_s = (2 < x) & (x < 4)
+
+    z[id_s] += 0.4 - 0.05*y[id_s]
+
+    # Permanent pole
+    id_p = (x - 8)**2 + (y - 2)**2 < 0.4**2
+
+    z[id_p] += 1
+
+            
+    return z
+
+
+def pole_increment(x,y,t):
+    """This provides a small increment to a pole located mid stream
+    For use with variable elevation data
+    """
+
+
+    z = 0.0*x
+    
+
+    if t<10.0:
+        return z
+    
+
+    N = len(x)
+    for i in range(N):
+        # Pole 1
+        if (x[i] - 12)**2 + (y[i] - 3)**2 < 0.4**2:
+            z[i] += 0.1
+
+    for i in range(N):
+        # Pole 2
+        if (x[i] - 14)**2 + (y[i] - 2)**2 < 0.4**2:
+            z[i] += 0.05
+
+    return z
+
+
+def pole(x,y,t):
+	
+    z = topography(x,y)
+    if t<5:
+        return z
+    elif t>12:
+        return z
+    else:
+        return z+1.0
+
+
+
+#------------------------------------------------------------------------------
+# Setup computational domain
+#------------------------------------------------------------------------------
+length = 24.
+width = 5.
+dx = dy = 0.2 #.1           # Resolution: Length of subdivisions on both axes
+
+points, vertices, boundary = rectangular_cross(int(length/dx), int(width/dy),
+                                               len1=length, len2=width)
+domain = Domain(points, vertices, boundary)
+domain.set_name() # Output name based on script name
+print domain.statistics()
+domain.set_quantities_to_be_stored({'elevation': 2,
+                                    'stage': 2})
+
+#------------------------------------------------------------------------------
+# Setup initial conditions
+#------------------------------------------------------------------------------
+
+domain.set_quantity('elevation', topography)           # elevation is a function
+domain.set_quantity('friction', 0.01)                  # Constant friction
+domain.set_quantity('stage', expression='elevation')   # Dry initial condition
+
+#------------------------------------------------------------------------------
+# Setup boundary conditions
+#------------------------------------------------------------------------------
+Bi = Dirichlet_boundary([0.4, 0, 0])          # Inflow
+Br = Reflective_boundary(domain)              # Solid reflective wall
+Bo = Dirichlet_boundary([-5, 0, 0])           # Outflow
+
+domain.set_boundary({'left': Bi, 'right': Bo, 'top': Br, 'bottom': Br})
+
+#------------------------------------------------------------------------------
+# Evolve system through time
+#------------------------------------------------------------------------------
+
+from anuga import Set_elevation_operator
+op1 = Set_elevation_operator(domain, elevation=pole, radius=0.5, center = (12.0,3.0))
+
+from anuga import Set_elevation
+op2 = Set_elevation(domain, elevation = topography)
+
+growing = False
+shrinking = False
+
+done = False
+for t in domain.evolve(yieldstep=0.1, finaltime=20.0):
+    domain.print_timestepping_statistics()
+    domain.print_operator_timestepping_statistics()
+
+    if num.allclose(15.0, t):
+        op1.set_elevation(None)
+        op2()
+
+
+
+
Index: /trunk/anuga_core/source/anuga/operators/examples/run_set_elevation_polygon.py
===================================================================
--- /trunk/anuga_core/source/anuga/operators/examples/run_set_elevation_polygon.py	(revision 9445)
+++ /trunk/anuga_core/source/anuga/operators/examples/run_set_elevation_polygon.py	(revision 9445)
@@ -0,0 +1,135 @@
+"""Simple water flow example using ANUGA
+
+Water flowing down a channel with a topography that varies with time
+"""
+
+#------------------------------------------------------------------------------
+# Import necessary modules
+#------------------------------------------------------------------------------
+from anuga import rectangular_cross
+from anuga import Domain
+from anuga import Reflective_boundary
+from anuga import Dirichlet_boundary
+from anuga import Time_boundary
+
+#------------------------------------------------------------------------------
+# Setup computational domain
+#------------------------------------------------------------------------------
+length = 24.
+width = 5.
+dx = dy = 0.2 #.1           # Resolution: Length of subdivisions on both axes
+
+points, vertices, boundary = rectangular_cross(int(length/dx), int(width/dy),
+                                               len1=length, len2=width)
+domain = Domain(points, vertices, boundary)
+domain.set_name('set_elevation') # Output name
+print domain.statistics()
+domain.set_quantities_to_be_stored({'elevation': 2,
+                                    'stage': 2})
+
+#------------------------------------------------------------------------------
+# Setup initial conditions
+#------------------------------------------------------------------------------
+def topography_dam(x,y):
+    """Complex topography defined by a function of vectors x and y."""
+
+    z = -x/100
+
+    N = len(x)
+    for i in range(N):
+        # Step
+        if 2 < x[i] < 4:
+            z[i] += 0.4 - 0.05*y[i]
+
+        # Permanent pole
+        if (x[i] - 8)**2 + (y[i] - 2)**2 < 0.4**2:
+            z[i] += 1
+
+
+        # Dam
+        if 12 < x[i] < 13:
+            z[i] += 0.4
+
+            
+    return z
+
+def topography_dam_break(x,y):
+    """Complex topography defined by a function of vectors x and y."""
+
+    z = -x/100
+
+    N = len(x)
+    for i in range(N):
+        # Step
+        if 2 < x[i] < 4:
+            z[i] += 0.4 - 0.05*y[i]
+
+        # Permanent pole
+        if (x[i] - 8)**2 + (y[i] - 2)**2 < 0.4**2:
+            z[i] += 1
+
+
+        # Dam
+        if 12 < x[i] < 13 and y[i] > 3.0:
+            z[i] += 0.4
+
+        if 12 < x[i] < 13 and y[i] < 2.0:
+            z[i] += 0.4
+
+    return z
+
+
+
+def pole(t):
+
+    if t<10:
+        return 0.0
+    elif t>15:
+        return 0.0
+    else:
+        return 0.05
+
+
+domain.set_quantity('elevation', topography_dam)       # elevation is a function
+domain.set_quantity('friction', 0.01)                  # Constant friction
+domain.set_quantity('stage', expression='elevation')   # Dry initial condition
+
+#------------------------------------------------------------------------------
+# Setup boundary conditions
+#------------------------------------------------------------------------------
+Bi = Dirichlet_boundary([0.4, 0, 0])          # Inflow
+Br = Reflective_boundary(domain)              # Solid reflective wall
+Bo = Dirichlet_boundary([-5, 0, 0])           # Outflow
+
+domain.set_boundary({'left': Bi, 'right': Bo, 'top': Br, 'bottom': Br})
+
+#------------------------------------------------------------------------------
+# Evolve system through time
+#------------------------------------------------------------------------------
+
+#from anuga.operators.set_elevation_operators import Circular_set_elevation_operator
+
+#op1 = Circular_set_elevation_operator(domain, elevation=pole, radius=0.5, center = (12.0,3.0))
+
+
+dam_break = False
+
+for t in domain.evolve(yieldstep=0.1, finaltime=40.0):
+    domain.print_timestepping_statistics()
+    domain.print_operator_timestepping_statistics()
+
+    if t >= 10 and not dam_break:
+        print 'changing elevation'
+
+        stage_c = domain.get_quantity('stage').centroid_values
+        elev_c =  domain.get_quantity('elevation').centroid_values
+        height_c = stage_c - elev_c
+        domain.set_quantity('elevation', topography_dam_break)
+        stage_c[:] = elev_c + height_c
+
+        dam_break = True
+
+
+
+
+
Index: /trunk/anuga_core/source/anuga/operators/examples/run_set_stage.py
===================================================================
--- /trunk/anuga_core/source/anuga/operators/examples/run_set_stage.py	(revision 9445)
+++ /trunk/anuga_core/source/anuga/operators/examples/run_set_stage.py	(revision 9445)
@@ -0,0 +1,91 @@
+"""Simple test of setting stage in a circular region
+"""
+
+#------------------------------------------------------------------------------
+# Import necessary modules
+#------------------------------------------------------------------------------
+
+import sys
+import anuga
+
+
+from math import cos
+from numpy import zeros, float, where
+import numpy
+from time import localtime, strftime, gmtime
+
+
+
+#------------------------------------------------------------------------------
+# Setup domain
+#------------------------------------------------------------------------------
+dx = 100.
+dy = dx
+L = 10000.
+W = L
+#W = dx
+
+# structured mesh
+domain = anuga.rectangular_cross_domain(int(L/dx), int(W/dy), L, W, (-L/2.0, -W/2.0))
+
+
+domain.set_name()                
+
+#------------------------------------------------------------------------------
+# Setup Algorithm
+#------------------------------------------------------------------------------
+domain.set_flow_algorithm(2.0)
+
+#------------------------------------------------------------------------------
+# Setup initial conditions
+#------------------------------------------------------------------------------
+h0 = 1000.0
+
+domain.set_quantity('elevation',0.0)
+domain.set_quantity('friction', 0.0)
+domain.add_quantity('stage', h0)
+
+#-----------------------------------------------------------------------------
+# Setup boundary conditions
+#------------------------------------------------------------------------------
+Br = anuga.Reflective_boundary(domain)      # Solid reflective wall
+
+# Associate boundary tags with boundary objects
+domain.set_boundary({'left': Br, 'right': Br, 'top': Br, 'bottom': Br})
+
+#------------------------------------------------------------------------------
+# Setup Operators
+#------------------------------------------------------------------------------
+from anuga.operators.set_stage_operator import Set_stage_operator
+
+import math
+
+stage1 = lambda t: h0 + 20.0 * math.sin(t/3.0)
+#cop1 = Set_stage_operator(domain, stage=stage1, center=(0.0, 0.0), radius=100.0 )
+
+stage2 = lambda t: h0 + 30.0# * math.sin(t/3.0)
+cop2 = Set_stage_operator(domain, stage=stage2, center=(2000.0, 1000.0), radius=100.0 )
+
+#print cop1.statistics()
+#print cop2.statistics()
+
+#------------------------------------------------------------------------------
+# Evolve system through time
+#------------------------------------------------------------------------------
+
+## stage = domain.get_quantity('stage')
+## id = domain.get_triangle_containing_point([2000., 1150.])
+## times = []
+## stages = []
+
+for t in domain.evolve(yieldstep = 1.0, finaltime = 200.0):
+    #print domain.timestepping_statistics(track_speeds=True)
+    domain.print_timestepping_statistics()
+    domain.print_operator_timestepping_statistics()
+    #times.append(t)
+    #stages.append(stage.centroid_values[id])
+
+## import pylab as pl
+
+## pl.plot(times, stages)
+## pl.show()
Index: /trunk/anuga_core/source/anuga/operators/examples/run_set_w_uh_vh.py
===================================================================
--- /trunk/anuga_core/source/anuga/operators/examples/run_set_w_uh_vh.py	(revision 9445)
+++ /trunk/anuga_core/source/anuga/operators/examples/run_set_w_uh_vh.py	(revision 9445)
@@ -0,0 +1,79 @@
+"""Simple test of setting stage in a circular region
+"""
+
+#------------------------------------------------------------------------------
+# Import necessary modules
+#------------------------------------------------------------------------------
+
+import sys
+import anuga
+
+
+from math import cos
+from numpy import zeros, float, where
+import numpy
+from time import localtime, strftime, gmtime
+
+
+
+#------------------------------------------------------------------------------
+# Setup domain
+#------------------------------------------------------------------------------
+dx = 100.
+dy = dx
+L = 10000.
+W = L
+#W = dx
+
+# structured mesh
+domain = anuga.rectangular_cross_domain(int(L/dx), int(W/dy), L, W, (-L/2.0, -W/2.0))
+
+
+domain.set_name()                
+
+#------------------------------------------------------------------------------
+# Setup Algorithm
+#------------------------------------------------------------------------------
+domain.set_flow_algorithm(2.0)
+
+#------------------------------------------------------------------------------
+# Setup initial conditions
+#------------------------------------------------------------------------------
+h0 = 1000.0
+
+domain.set_quantity('elevation',0.0)
+domain.set_quantity('friction', 0.0)
+domain.add_quantity('stage', h0)
+
+#-----------------------------------------------------------------------------
+# Setup boundary conditions
+#------------------------------------------------------------------------------
+Br = anuga.Reflective_boundary(domain)      # Solid reflective wall
+
+# Associate boundary tags with boundary objects
+domain.set_boundary({'left': Br, 'right': Br, 'top': Br, 'bottom': Br})
+
+#------------------------------------------------------------------------------
+# Setup Operators
+#------------------------------------------------------------------------------
+from anuga.operators.set_w_uh_vh_operator import Set_w_uh_vh_operator
+
+import math
+
+wuhvh1 = lambda t: [ h0 + 20.0 * math.sin(t/3.0) ,  20.0 * math.sin(t/3.0),  10.0 * math.sin(t/3.0)]
+cop1 = Set_w_uh_vh_operator(domain, w_uh_vh=wuhvh1, center=(0.0, 0.0), radius=100.0 )
+
+
+print cop1.statistics()
+#print cop2.statistics()
+
+#------------------------------------------------------------------------------
+# Evolve system through time
+#------------------------------------------------------------------------------
+
+for t in domain.evolve(yieldstep = 1.0, finaltime = 40.0):
+    #print domain.timestepping_statistics(track_speeds=True)
+    domain.print_timestepping_statistics()
+    domain.print_operator_timestepping_statistics()
+
+
Index: unk/anuga_core/source/anuga/operators/run_bed_shear_erosion.py
===================================================================
--- /trunk/anuga_core/source/anuga/operators/run_bed_shear_erosion.py	(revision 9444)
+++ 	(revision )
@@ -1,126 +1,0 @@
-"""Simple water flow example using ANUGA
-
-Water flowing down a channel with a topography that varies with time
-"""
-
-#------------------------------------------------------------------------------
-# Import necessary modules
-#------------------------------------------------------------------------------
-from anuga import rectangular_cross
-from anuga import Domain
-from anuga import Reflective_boundary
-from anuga import Dirichlet_boundary
-from anuga import Time_boundary
-
-import numpy as num
-
-#===============================================================================
-# Setup Functions
-#===============================================================================
-
-
-#------------------------------------------------------------------------------
-# Setup initial conditions
-#------------------------------------------------------------------------------
-def topography(x,y):
-    """Complex topography defined by a function of vectors x and y."""
-    print ' Create topography....'
-    z = -x/100
-
-    N = len(x)
-    for i in range(N):
-        # Step
-        if 2 < x[i] < 4:
-            z[i] += 0.4 - 0.05*y[i]
-
-        # Permanent pole
-        if (x[i] - 8)**2 + (y[i] - 2)**2 < 0.4**2:
-            z[i] += 1
-
-        # Dam
-        #if 12 < x[i] < 13:
-        #    z[i] += 1.4
-    # Sloping Embankment Across Channel
-        if 10.6 < x[i] < 12.1:
-            # Cut Out Segment for Culvert face                
-            z[i] +=  1.0*(x[i] -10.6)    # Sloping Segment  U/S Face
-        if 12.0 < x[i] < 13.0:
-           z[i] +=  1.4                    # Flat Crest of Embankment
-        if 12.9 < x[i] < 13.7:
-            z[i] +=  1.4-2.0*(x[i] -12.9) # Sloping D/S Face
-            
-    return z
-
-
-
-#===============================================================================
-# Setup and Run Model
-#===============================================================================
-
-
-#------------------------------------------------------------------------------
-# Setup computational domain
-#------------------------------------------------------------------------------
-print ' Set up Domain first...'
-length = 24.
-width = 5.
-dx = dy = 0.2 #.1           # Resolution: Length of subdivisions on both axes
-
-points, vertices, boundary = rectangular_cross(int(length/dx), int(width/dy),
-                                               len1=length, len2=width)
-domain = Domain(points, vertices, boundary)
-domain.set_flow_algorithm('2_0')
-domain.set_name('bed_shear_erosion') # Output name
-domain.set_store_vertices_uniquely(True)
-
-print domain.statistics()
-
-domain.set_quantities_to_be_stored({'elevation': 2,
-                                    'stage': 2,
-                                    'xmomentum': 2,
-                                    'ymomentum': 2})
-
-
-
-domain.set_quantity('elevation', topography)           # elevation is a function
-domain.set_quantity('friction', 0.01)                  # Constant friction
-domain.set_quantity('stage', expression='elevation')   # Dry initial condition
-
-#------------------------------------------------------------------------------
-# Setup boundary conditions
-#------------------------------------------------------------------------------
-Bi = Dirichlet_boundary([1.5, 0, 0])          # Inflow
-Br = Reflective_boundary(domain)              # Solid reflective wall
-Bo = Dirichlet_boundary([-5, 0, 0])           # Outflow
-
-domain.set_boundary({'left': Bi, 'right': Bo, 'top': Br, 'bottom': Br})
-
-#------------------------------------------------------------------------------
-# Setup erosion operator in the middle of dam
-#------------------------------------------------------------------------------
-print 'Set up Erosion Area to test...'
-
-from rudy_erosion import Bed_shear_erosion_operator
-polygon1 = [ [10.6, 1.0], [13.7, 1.0], [13.7, 4.0], [10.6, 4.0] ]
-
-
-# create operator
-op1 = Bed_shear_erosion_operator(domain, threshold=2.0, shear_factor=1000.0, polygon=polygon1)
-
-
-#------------------------------------------------------------------------------
-# Evolve system through time
-#------------------------------------------------------------------------------
-for t in domain.evolve(yieldstep=0.1, finaltime=15.0):
-    domain.print_timestepping_statistics()
-    #domain.print_operator_timestepping_statistics()
-
-
-
-
-
-
-
-
-
-
Index: unk/anuga_core/source/anuga/operators/run_change_elevation.py
===================================================================
--- /trunk/anuga_core/source/anuga/operators/run_change_elevation.py	(revision 9444)
+++ 	(revision )
@@ -1,119 +1,0 @@
-"""Simple water flow example using ANUGA
-
-Water flowing down a channel with a topography that varies with time
-"""
-
-#------------------------------------------------------------------------------
-# Import necessary modules
-#------------------------------------------------------------------------------
-import numpy
-from anuga import rectangular_cross
-from anuga import Domain
-from anuga import Reflective_boundary
-from anuga import Dirichlet_boundary
-from anuga import Time_boundary
-
-#------------------------------------------------------------------------------
-# Setup computational domain
-#------------------------------------------------------------------------------
-length = 24.
-width = 5.
-dx = dy = 0.2 #.1           # Resolution: Length of subdivisions on both axes
-
-points, vertices, boundary = rectangular_cross(int(length/dx), int(width/dy),
-                                               len1=length, len2=width)
-domain = Domain(points, vertices, boundary)
-domain.set_name()
-print domain.statistics()
-domain.set_quantities_to_be_stored({'elevation': 2,
-                                    'stage': 2,
-                                    'xmomentum': 2,
-                                    'ymomentum': 2})
-
-#------------------------------------------------------------------------------
-# Setup initial conditions
-#------------------------------------------------------------------------------
-def topography_dam(x,y):
-    """Complex topography defined by a function of vectors x and y."""
-
-    z = -x/100
-
-    # Step
-    id = (2 < x) & (x < 4)
-    z[id] += 0.4 - 0.05*y[id]
-
-
-    # Permanent pole
-    #id = (x - 8)**2 + (y - 2)**2 < 0.4**2
-    #z[id] += 1
-
-
-    # Dam
-    id = (12 < x) & (x  < 13)
-    z[id] += 0.4
-
-
-            
-    return z
-
-def topography_dam_break(x,y):
-    """Complex topography defined by a function of vectors x and y."""
-
-    z = -x/100
-    
-    # Step
-    id = (2 < x) & (x < 4)
-    z[id] += 0.4 - 0.05*y[id]
-
-
-    # Permanent pole
-    #id = (x - 8)**2 + (y - 2)**2 < 0.4**2
-    #z[id] += 1
-
-    # Dam with hole
-    id = (12 < x) & (x < 13) and (y > 3.0)
-    z[id] += 0.4
-
-    id = (12 < x) & (x < 13) and (y < 2.0)
-    z[id] += 0.4
-
-
-    return z
-
-
-domain.set_quantity('elevation', topography_dam)       # elevation is a function
-domain.set_quantity('friction', 0.01)                  # Constant friction
-domain.set_quantity('stage', expression='elevation')   # Dry initial condition
-
-#------------------------------------------------------------------------------
-# Setup boundary conditions
-#------------------------------------------------------------------------------
-Bi = Dirichlet_boundary([0.4, 0, 0])          # Inflow
-Br = Reflective_boundary(domain)              # Solid reflective wall
-Bo = Dirichlet_boundary([-5, 0, 0])           # Outflow
-
-domain.set_boundary({'left': Bi, 'right': Bo, 'top': Br, 'bottom': Br})
-
-#------------------------------------------------------------------------------
-# Evolve system through time
-#------------------------------------------------------------------------------
-
-from anuga.operators.set_elevation import Set_elevation
-op1 = Set_elevation(domain, elevation=lambda x,y : -x/100, radius=1.0, center = (12.5,3.0))
-
-
-#dam_break = False
-
-for t in domain.evolve(yieldstep=0.1, finaltime=30.0):
-    domain.print_timestepping_statistics()
-    domain.print_operator_timestepping_statistics()
-
-    if numpy.allclose(t, 10.0):
-        print 'changing elevation'
-        op1()
-
-
-
-
-
-
Index: unk/anuga_core/source/anuga/operators/run_collect_max_stage_operator.py
===================================================================
--- /trunk/anuga_core/source/anuga/operators/run_collect_max_stage_operator.py	(revision 9444)
+++ 	(revision )
@@ -1,95 +1,0 @@
-"""Simple water flow example using ANUGA
-
-Water driven up a linear slope and time varying boundary,
-similar to a beach environment
-"""
-
-#------------------------------------------------------------------------------
-# Import necessary modules
-#------------------------------------------------------------------------------
-
-import sys
-import anuga
-
-
-from math import cos
-from numpy import zeros, float, where
-import numpy
-from time import localtime, strftime, gmtime
-
-
-#------------------------------------------------------------------------------
-# Setup domain
-#------------------------------------------------------------------------------
-dx = 1000.
-dy = dx
-L = 100000.
-W = 10*dx
-#W = dx
-
-# structured mesh
-domain = anuga.rectangular_cross_domain(int(L/dx), int(W/dy), L, W, (0.0, -W/2))
-
-domain.set_name() # based on script name
-
-print domain.mesh.statistics(nbins=50)
-
-#------------------------------------------------------------------------------
-# Setup Algorithm
-#------------------------------------------------------------------------------
-domain.set_flow_algorithm('2_0')
-
-#------------------------------------------------------------------------------
-# Setup initial conditions
-#------------------------------------------------------------------------------
-h0 = 10.0
-h1 = 0.0
-
-def elevation(x,y):
-
-    return where(x<=95000.0, 0.0, h0)
-
-def height(x,y):
-
-    return where(x<=50000.0, h0, h1)
-
-domain.set_quantity('elevation',elevation)
-domain.set_quantity('friction', 0.0)
-domain.add_quantity('stage', height)
-
-#-----------------------------------------------------------------------------
-# Setup boundary conditions
-#------------------------------------------------------------------------------
-from math import sin, pi, exp
-Br = anuga.Reflective_boundary(domain)      # Solid reflective wall
-Bt = anuga.Transmissive_boundary(domain)    # Continue all values on boundary 
-Bd = anuga.Dirichlet_boundary([1,0.,0.])    # Constant boundary values
-
-
-# Associate boundary tags with boundary objects
-domain.set_boundary({'left': Br, 'right': Br, 'top': Br, 'bottom': Br})
-
-#-----------------------------------------------------------------------------
-# Setup operators that will be applied each inner timestep
-#------------------------------------------------------------------------------
-from anuga.operators.collect_max_stage_operator import Collect_max_stage_operator
-max_operator = Collect_max_stage_operator(domain)
-
-#------------------------------------------------------------------------------
-# Evolve system through time
-#------------------------------------------------------------------------------
-for t in domain.evolve(yieldstep = 100.0, finaltime = 60*60.):
-    #print domain.timestepping_statistics(track_speeds=True)
-    domain.print_timestepping_statistics()
-    domain.print_operator_timestepping_statistics()
-
-
-# save the max_stage centroid data to a text file
-max_operator.save_centroid_data_to_csv()
-
-# Let's have a look at the max_stage
-#max_operator.plot_quantity()
-
-
-
-
Index: unk/anuga_core/source/anuga/operators/run_flat_fill_slice_erosion.py
===================================================================
--- /trunk/anuga_core/source/anuga/operators/run_flat_fill_slice_erosion.py	(revision 9444)
+++ 	(revision )
@@ -1,134 +1,0 @@
-"""Simple water flow example using ANUGA
-
-Water flowing down a channel with a topography that varies with time
-"""
-
-#------------------------------------------------------------------------------
-# Import necessary modules
-#------------------------------------------------------------------------------
-from anuga import rectangular_cross
-from anuga import Domain
-from anuga import Reflective_boundary
-from anuga import Dirichlet_boundary
-from anuga import Time_boundary
-
-import numpy as num
-
-#===============================================================================
-# Setup Functions
-#===============================================================================
-
-#------------------------------------------------------------------------------
-# Setup initial conditions
-#------------------------------------------------------------------------------
-def topography(x,y):
-    """Complex topography defined by a function of vectors x and y."""
-    print ' Create topography....'
-    z = -x/100
-
-    N = len(x)
-    for i in range(N):
-        # Step
-        if 2 < x[i] < 4:
-            z[i] += 0.4 - 0.05*y[i]
-
-        # Permanent pole
-        if (x[i] - 8)**2 + (y[i] - 2)**2 < 0.4**2:
-            z[i] += 1
-
-        # Dam
-        #if 12 < x[i] < 13:
-        #    z[i] += 1.4
-    # Sloping Embankment Across Channel
-        if 10.6 < x[i] < 12.1:
-            # Cut Out Segment for Culvert face                
-            z[i] +=  1.0*(x[i] -10.6)    # Sloping Segment  U/S Face
-        if 12.0 < x[i] < 13.0:
-           z[i] +=  1.4                    # Flat Crest of Embankment
-        if 12.9 < x[i] < 13.7:
-            z[i] +=  1.4-2.0*(x[i] -12.9) # Sloping D/S Face
-            
-    return z
-
-
-
-#===============================================================================
-# Setup and Run Model
-#===============================================================================
-
-
-#------------------------------------------------------------------------------
-# Setup computational domain
-#------------------------------------------------------------------------------
-print ' Set up Domain first...'
-length = 24.
-width = 5.
-dx = dy = 0.2 #.1           # Resolution: Length of subdivisions on both axes
-
-points, vertices, boundary = rectangular_cross(int(length/dx), int(width/dy),
-                                               len1=length, len2=width)
-domain = Domain(points, vertices, boundary)
-domain.set_flow_algorithm('DE1')
-domain.set_name('flat_fill_slice_erosion') # Output name
-print domain.statistics()
-
-domain.set_quantities_to_be_stored({'elevation': 2,
-                                    'stage': 2,
-                                    'xmomentum': 2,
-                                    'ymomentum': 2})
-
-
-
-domain.set_quantity('elevation', topography)           # elevation is a function
-domain.set_quantity('friction', 0.01)                  # Constant friction
-domain.set_quantity('stage', expression='elevation')   # Dry initial condition
-
-#------------------------------------------------------------------------------
-# Setup boundary conditions
-#------------------------------------------------------------------------------
-Bi = Dirichlet_boundary([1.5, 0, 0])          # Inflow
-Br = Reflective_boundary(domain)              # Solid reflective wall
-Bo = Dirichlet_boundary([-5, 0, 0])           # Outflow
-
-domain.set_boundary({'left': Bi, 'right': Bo, 'top': Br, 'bottom': Br})
-
-#------------------------------------------------------------------------------
-# Setup erosion operator in the middle of dam
-#------------------------------------------------------------------------------
-print 'Set up Erosion Area to test...'
-
-from anuga import Flat_fill_slice_erosion_operator as Default_erosion_operator
-from anuga import Set_elevation_operator as Default_erosion_operator
-
-polygon1 = [ [10.6, 1.0], [13.7, 1.0], [13.7, 4.0], [10.6, 4.0] ]
-
-# setup interpolated function
-time = num.array([ 5.0 , 8.0])
-elev = num.array([ 1.4,  2.0])
-
-from scipy.interpolate import interp1d
-flevel = interp1d(time,elev)
-
-# create operator
-op1 = Default_erosion_operator(domain, elevation=flevel, polygon=polygon1)
-
-
-
-
-
-#------------------------------------------------------------------------------
-# Evolve system through time
-#------------------------------------------------------------------------------
-for t in domain.evolve(yieldstep=0.1, finaltime=15.0):
-    domain.print_timestepping_statistics()
-    #domain.print_operator_timestepping_statistics()
-
-
-
-
-
-
-
-
-
-
Index: unk/anuga_core/source/anuga/operators/run_flat_slice_erosion.py
===================================================================
--- /trunk/anuga_core/source/anuga/operators/run_flat_slice_erosion.py	(revision 9444)
+++ 	(revision )
@@ -1,133 +1,0 @@
-"""Simple water flow example using ANUGA
-
-Water flowing down a channel with a topography that varies with time
-"""
-
-#------------------------------------------------------------------------------
-# Import necessary modules
-#------------------------------------------------------------------------------
-from anuga import rectangular_cross
-from anuga import Domain
-from anuga import Reflective_boundary
-from anuga import Dirichlet_boundary
-from anuga import Time_boundary
-
-import numpy as num
-
-#===============================================================================
-# Setup Functions
-#===============================================================================
-
-
-#------------------------------------------------------------------------------
-# Setup initial conditions
-#------------------------------------------------------------------------------
-def topography(x,y):
-    """Complex topography defined by a function of vectors x and y."""
-    print ' Create topography....'
-    z = -x/100
-
-    N = len(x)
-    for i in range(N):
-        # Step
-        if 2 < x[i] < 4:
-            z[i] += 0.4 - 0.05*y[i]
-
-        # Permanent pole
-        if (x[i] - 8)**2 + (y[i] - 2)**2 < 0.4**2:
-            z[i] += 1
-
-        # Dam
-        #if 12 < x[i] < 13:
-        #    z[i] += 1.4
-    # Sloping Embankment Across Channel
-        if 10.6 < x[i] < 12.1:
-            # Cut Out Segment for Culvert face                
-            z[i] +=  1.0*(x[i] -10.6)    # Sloping Segment  U/S Face
-        if 12.0 < x[i] < 13.0:
-           z[i] +=  1.4                    # Flat Crest of Embankment
-        if 12.9 < x[i] < 13.7:
-            z[i] +=  1.4-2.0*(x[i] -12.9) # Sloping D/S Face
-            
-    return z
-
-
-
-#===============================================================================
-# Setup and Run Model
-#===============================================================================
-
-
-#------------------------------------------------------------------------------
-# Setup computational domain
-#------------------------------------------------------------------------------
-print ' Set up Domain first...'
-length = 24.
-width = 5.
-dx = dy = 0.2 #.1           # Resolution: Length of subdivisions on both axes
-
-points, vertices, boundary = rectangular_cross(int(length/dx), int(width/dy),
-                                               len1=length, len2=width)
-domain = Domain(points, vertices, boundary)
-domain.set_flow_algorithm('DE1')
-domain.set_name('flat_slice_erosion') # Output name
-print domain.statistics()
-
-domain.set_quantities_to_be_stored({'elevation': 2,
-                                    'stage': 2,
-                                    'xmomentum': 2,
-                                    'ymomentum': 2})
-
-
-
-domain.set_quantity('elevation', topography)           # elevation is a function
-domain.set_quantity('friction', 0.01)                  # Constant friction
-domain.set_quantity('stage', expression='elevation')   # Dry initial condition
-
-#------------------------------------------------------------------------------
-# Setup boundary conditions
-#------------------------------------------------------------------------------
-Bi = Dirichlet_boundary([1.5, 0, 0])          # Inflow
-Br = Reflective_boundary(domain)              # Solid reflective wall
-Bo = Dirichlet_boundary([-5, 0, 0])           # Outflow
-
-domain.set_boundary({'left': Bi, 'right': Bo, 'top': Br, 'bottom': Br})
-
-#------------------------------------------------------------------------------
-# Setup erosion operator in the middle of dam
-#------------------------------------------------------------------------------
-print 'Set up Erosion Area to test...'
-
-from rudy_erosion import Flat_slice_erosion_operator
-polygon1 = [ [10.6, 1.0], [13.7, 1.0], [13.7, 4.0], [10.6, 4.0] ]
-
-# setup interpolated function
-time = num.array([ 2.0 , 10.0])
-elev = num.array([ 1.4,  -0.1])
-
-from scipy.interpolate import interp1d
-flevel = interp1d(time,elev)
-
-# create operator
-op1 = Flat_slice_erosion_operator(domain, elevation=flevel, polygon=polygon1)
-
-
-
-
-
-#------------------------------------------------------------------------------
-# Evolve system through time
-#------------------------------------------------------------------------------
-for t in domain.evolve(yieldstep=0.1, finaltime=15.0):
-    domain.print_timestepping_statistics()
-    #domain.print_operator_timestepping_statistics()
-
-
-
-
-
-
-
-
-
-
Index: unk/anuga_core/source/anuga/operators/run_polygon_erosion.py
===================================================================
--- /trunk/anuga_core/source/anuga/operators/run_polygon_erosion.py	(revision 9444)
+++ 	(revision )
@@ -1,163 +1,0 @@
-"""Simple water flow example using ANUGA
-
-Water flowing down a channel with a topography that varies with time
-"""
-
-#------------------------------------------------------------------------------
-# Import necessary modules
-#------------------------------------------------------------------------------
-from anuga import rectangular_cross
-from anuga import Domain
-from anuga import Reflective_boundary
-from anuga import Dirichlet_boundary
-from anuga import Time_boundary
-
-
-
-#===============================================================================
-# Stick all the class and function definitions here
-#===============================================================================
-
-#-------------------------------------------------------------------------------
-# Here are the def's for defining quantities
-#-------------------------------------------------------------------------------
-def topography(x,y):
-    """Complex topography defined by a function of vectors x and y."""
-
-    z = -x/100
-
-    # Step
-    id = (2 < x) & (x < 4)
-    z[id] += 0.4 - 0.05*y[id]
-
-    # Permanent pole
-    id = (x - 8)**2 + (y - 2)**2 < 0.4**2
-    z[id] += 1
-
-    # Dam
-    id = (12 < x) & (x < 13)
-    z[id] += 0.4
-
-    return z
-
-
-#-------------------------------------------------------------------------------
-# Inherit from erosion operator
-#-------------------------------------------------------------------------------
-from anuga.operators.erosion_operators import Polygonal_erosion_operator
-
-class My_polygon_erosion_operator(Polygonal_erosion_operator):
-    """
-    Local version of erosion confined to a polygon
-
-    """
-
-    def __init__(self, domain,
-                 threshold=0.0,
-                 base=0.0,
-                 polygon=None,
-                 verbose=False):
-
-
-        Polygonal_erosion_operator.__init__(self, domain, threshold, base, polygon, verbose)
-
-
-
-    def update_quantities(self):
-        """Update the vertex values of the quantities to model erosion
-        """
-        import numpy as num
-        
-        t = self.get_time()
-        dt = self.get_timestep()
-
-        updated = True
-
-        if self.indices is None:
-
-            #--------------------------------------
-            # Update all three vertices for each cell
-            #--------------------------------------
-            self.elev_v[:] = self.elev_v + 0.0
-
-        else:
-
-            #--------------------------------------
-            # Update all three vertices for each cell
-            #--------------------------------------
-            ind = self.indices
-            m = num.sqrt(self.xmom_c[ind]**2 + self.ymom_c[ind]**2)
-            m = num.vstack((m,m,m)).T
-            m = num.where(m>self.threshold, m, 0.0)
-            self.elev_v[ind] = num.maximum(self.elev_v[ind] - m*dt, self.base)
-             #num.maximum(self.elev_v[ind] - momentum*dt, Z)
-
-
-        return updated
-
-
-
-#===============================================================================
-# Now to the standard anuga model setup
-#===============================================================================
-
-
-#-------------------------------------------------------------------------------
-# Setup computational domain
-#-------------------------------------------------------------------------------
-length = 24.
-width = 5.
-dx = dy = 0.2 #.1           # Resolution: Length of subdivisions on both axes
-
-points, vertices, boundary = rectangular_cross(int(length/dx), int(width/dy),
-                                               len1=length, len2=width)
-domain = Domain(points, vertices, boundary)
-domain.set_name() # Output name based on script
-print domain.statistics()
-domain.set_quantities_to_be_stored({'elevation': 2,
-                                    'stage': 2,
-                                    'xmomentum': 2,
-                                    'ymomentum': 2})
-
-#-------------------------------------------------------------------------------
-# Setup initial conditions
-#-------------------------------------------------------------------------------
-
-
-domain.set_quantity('elevation', topography)           # elevation is a function
-domain.set_quantity('friction', 0.01)                  # Constant friction
-domain.set_quantity('stage', expression='elevation')   # Dry initial condition
-
-#-------------------------------------------------------------------------------
-# Setup boundary conditions
-#-------------------------------------------------------------------------------
-Bi = Dirichlet_boundary([0.5, 0, 0])          # Inflow
-Br = Reflective_boundary(domain)              # Solid reflective wall
-Bo = Dirichlet_boundary([-5, 0, 0])           # Outflow
-
-domain.set_boundary({'left': Bi, 'right': Bo, 'top': Br, 'bottom': Br})
-
-#-------------------------------------------------------------------------------
-# Setup erosion operator in the middle of dam
-#-------------------------------------------------------------------------------
-polygon1 = [ [12., 0.0], [13., 0.0], [13., 5.0], [12., 5.0] ]
-op1 = My_polygon_erosion_operator(domain, threshold=0.0, base=-0.1, polygon=polygon1)
-
-
-
-
-#-------------------------------------------------------------------------------
-# Evolve system through time
-#-------------------------------------------------------------------------------
-for t in domain.evolve(yieldstep=0.2, finaltime=60.0):
-    domain.print_timestepping_statistics()
-    domain.print_operator_timestepping_statistics()
-
-
-
-
-
-
-
-
-
Index: unk/anuga_core/source/anuga/operators/run_rate_operator.py
===================================================================
--- /trunk/anuga_core/source/anuga/operators/run_rate_operator.py	(revision 9444)
+++ 	(revision )
@@ -1,146 +1,0 @@
-"""Simple water flow example using ANUGA
-
-Water flowing down a channel with a topography that varies with time
-"""
-
-#------------------------------------------------------------------------------
-# Import necessary modules
-#------------------------------------------------------------------------------
-from anuga import rectangular_cross
-from anuga import Domain
-from anuga import Reflective_boundary
-from anuga import Dirichlet_boundary
-from anuga import Time_boundary
-import os
-
-
-#------------------------------------------------------------------------------
-# Setup computational domain
-#------------------------------------------------------------------------------
-length = 24.
-width = 5.
-dx = dy = 0.2 #.1           # Resolution: Length of subdivisions on both axes
-
-points, vertices, boundary = rectangular_cross(int(length/dx), int(width/dy),
-                                               len1=length, len2=width)
-domain = Domain(points, vertices, boundary)
-domain.set_name() # Output name based on script name. You can add timestamp=True
-print domain.statistics()
-
-
-#------------------------------------------------------------------------------
-# Setup initial conditions
-#------------------------------------------------------------------------------
-def topography(x,y):
-    """Complex topography defined by a function of vectors x and y."""
-
-    z = -x/100
-
-    # Step
-    id = (2 < x) & (x < 4)
-    z[id] += 0.4 - 0.05*y[id]
-
-
-    # Permanent pole
-    #id = (x - 8)**2 + (y - 2)**2 < 0.4**2
-    #z[id] += 1
-
-
-    # Dam
-    #id = (12 < x) & (x  < 13)
-    #z[id] += 0.4
-
-
-
-            
-    return z
-
-
-def pole_increment(x,y,t):
-    """This provides a small increment to a pole located mid stream
-    For use with variable elevation data
-    """
-
-    z = 0.0*x    
-
-    if t<10.0:
-        return z
-    
-
-    # Pole 1
-    id = (x - 12)**2 + (y - 3)**2 < 0.4**2
-    z[id] += 0.1
-
-
-    # Pole 2
-    id = (x - 14)**2 + (y - 2)**2 < 0.4**2
-    z[id] += 0.05
-
-
-    return z
-
-
-def pole(t):
-
-    if t<10:
-        return 0.0
-    elif t>15:
-        return 0.0
-    else:
-        return 0.05
-
-
-domain.set_quantity('elevation', topography)           # elevation is a function
-domain.set_quantity('friction', 0.01)                  # Constant friction
-domain.set_quantity('stage', expression='elevation')   # Dry initial condition
-
-#------------------------------------------------------------------------------
-# Setup boundary conditions
-#------------------------------------------------------------------------------
-Bi = Dirichlet_boundary([0.4, 0, 0])          # Inflow
-Br = Reflective_boundary(domain)              # Solid reflective wall
-Bo = Dirichlet_boundary([-5, 0, 0])           # Outflow
-
-domain.set_boundary({'left': Br, 'right': Br, 'top': Br, 'bottom': Br})
-
-#------------------------------------------------------------------------------
-# Evolve system through time
-#------------------------------------------------------------------------------
-polygon1 = [ [10.0, 0.0], [11.0, 0.0], [11.0, 5.0], [10.0, 5.0] ]
-polygon2 = [ [12.0, 2.0], [13.0, 2.0], [13.0, 3.0], [12.0, 3.0] ]
-
-from anuga.operators.rate_operators import Rate_operator
-
-op1 = Rate_operator(domain, rate=lambda t: 10.0 if (t>=0.0) else 0.0, polygon=polygon2)
-op2 = Rate_operator(domain, rate=lambda t: 10.0 if (t>=0.0) else 0.0, radius=0.5, center=(10.0, 3.0))
-
-
-domain.set_starttime(-0.1)
-for t in domain.evolve(yieldstep=0.01, finaltime=0.0):
-    domain.print_timestepping_statistics()
-    domain.print_operator_timestepping_statistics()
-
-    stage = domain.get_quantity('stage')
-    elev  = domain.get_quantity('elevation')
-    height = stage - elev
-
-    print 'integral = ', height.get_integral()
-
-
-for t in domain.evolve(yieldstep=0.1, duration=5.0):
-
-    domain.print_timestepping_statistics()
-    domain.print_operator_timestepping_statistics()
-
-    stage = domain.get_quantity('stage')
-    elev  = domain.get_quantity('elevation')
-    height = stage - elev
-
-    print 'integral = ', height.get_integral()
-
-
-
-
-
-
-
Index: unk/anuga_core/source/anuga/operators/run_rate_spatial_operator.py
===================================================================
--- /trunk/anuga_core/source/anuga/operators/run_rate_spatial_operator.py	(revision 9444)
+++ 	(revision )
@@ -1,180 +1,0 @@
-"""Simple water flow example using ANUGA
-
-Water flowing down a channel with a topography that varies with time
-"""
-
-#------------------------------------------------------------------------------
-# Import necessary modules
-#------------------------------------------------------------------------------
-import numpy
-from anuga import rectangular_cross
-from anuga import Domain
-from anuga import Reflective_boundary
-from anuga import Dirichlet_boundary
-from anuga import Time_boundary
-
-from anuga import indent
-
-
-#------------------------------------------------------------------------------
-# Setup computational domain
-#------------------------------------------------------------------------------
-length = 24.
-width = 5.
-dx = dy = 0.2 #.1           # Resolution: Length of subdivisions on both axes
-
-points, vertices, boundary = rectangular_cross(int(length/dx), int(width/dy),
-                                               len1=length, len2=width)
-domain = Domain(points, vertices, boundary)
-domain.set_name() # Output name based on script
-print domain.statistics()
-
-
-#------------------------------------------------------------------------------
-# Setup initial conditions
-#------------------------------------------------------------------------------
-def topography(x,y):
-    """Complex topography defined by a function of vectors x and y."""
-
-    z = -x/100
-
-    N = len(x)
-    for i in range(N):
-        # Step
-        if 2 < x[i] < 4:
-            z[i] += 0.4 - 0.05*y[i]
-
-        # Permanent pole
-        #if (x[i] - 8)**2 + (y[i] - 2)**2 < 0.4**2:
-        #    z[i] += 1
-
-
-#        # Dam
-#        if 12 < x[i] < 13 and y[i] > 3.0:
-#            z[i] += 0.4
-#
-#        if 12 < x[i] < 13 and y[i] < 2.0:
-#            z[i] += 0.4
-
-
-#        # Dam
-#        if 12 < x[i] < 13:
-#            z[i] += 0.4
-
-            
-    return z
-
-
-def pole_increment(x,y,t):
-    """This provides a small increment to a pole located mid stream
-    For use with variable elevation data
-    """
-
-    z = 0.0*x
-    
-    if t<10.0:
-        return z
-    
-    N = len(x)
-    for i in range(N):
-        # Pole 1
-        if (x[i] - 12)**2 + (y[i] - 3)**2 < 0.4**2:
-            z[i] += 0.1
-
-    for i in range(N):
-        # Pole 2
-        if (x[i] - 14)**2 + (y[i] - 2)**2 < 0.4**2:
-            z[i] += 0.05
-
-    return z
-
-
-def pole(t):
-
-    if t<10:
-        return 0.0
-    elif t>15:
-        return 0.0
-    else:
-        return 0.05
-
-
-domain.set_quantity('elevation', topography)           # elevation is a function
-domain.set_quantity('friction', 0.01)                  # Constant friction
-domain.set_quantity('stage', expression='elevation')   # Dry initial condition
-
-#------------------------------------------------------------------------------
-# Setup boundary conditions
-#------------------------------------------------------------------------------
-Bi = Dirichlet_boundary([0.4, 0, 0])          # Inflow
-Br = Reflective_boundary(domain)              # Solid reflective wall
-Bo = Dirichlet_boundary([-5, 0, 0])           # Outflow
-
-domain.set_boundary({'left': Br, 'right': Br, 'top': Br, 'bottom': Br})
-
-#------------------------------------------------------------------------------
-# Evolve system through time
-#------------------------------------------------------------------------------
-polygon1 = [ [10.0, 0.0], [11.0, 0.0], [11.0, 5.0], [10.0, 5.0] ]
-polygon2 = [ [12.0, 2.0], [13.0, 2.0], [13.0, 3.0], [12.0, 3.0] ]
-
-
-from anuga.operators.rate_operators import Rate_operator
-
-op1 = Rate_operator(domain, rate=10.0, polygon=polygon2)
-
-area1 = numpy.sum(domain.areas[op1.indices])
-Q1 = 10.0*area1
-print 'op1 Q ',Q1
-
-op2 = Rate_operator(domain, rate=10.0, radius=0.5, center=(10.0, 3.0))
-
-area2 = numpy.sum(domain.areas[op2.indices])
-Q2 = 10.0*area2
-print 'op2 Q ',Q2
-
-
-def rain(x,y,t):
-    """Function to calculate "rain"
-    input x,y should be considered to be numpy arrays
-    abd t a scalar
-    """
-    if t<=4.0:
-        return (x+y)*1.0
-    else:
-        return 0.0*x
-
-factor = 1e-3
-op3 = Rate_operator(domain, rate = rain, factor=factor)
-Q3 = numpy.sum(op3.get_spatial_rate()*domain.areas)*factor
-
-
-#op3()
-#domain.fractional_step_operators.remove(op3)
-
-
-#------------------------------------------------------------------------------
-# Evolve system through time
-#------------------------------------------------------------------------------
-accum = 0.0
-yieldstep = 0.1
-finaltime = 5.0
-for t in domain.evolve(yieldstep=yieldstep, finaltime=finaltime):
-    domain.print_timestepping_statistics()
-    domain.print_operator_timestepping_statistics()
-
-    stage = domain.get_quantity('stage')
-    elev  = domain.get_quantity('elevation')
-    height = stage - elev
-
-    print indent + 'Integral = ', height.get_integral()
-    print indent + 'Exact accumultion = ', accum
-    
-    dd = max(min(yieldstep,4.0-t),0.0)
-    accum += (Q1+Q2)*yieldstep + dd*Q3
-
-
-
-
-
-
Index: unk/anuga_core/source/anuga/operators/run_set_depth_friction.py
===================================================================
--- /trunk/anuga_core/source/anuga/operators/run_set_depth_friction.py	(revision 9444)
+++ 	(revision )
@@ -1,109 +1,0 @@
-"""Simple water flow example using ANUGA
-
-Water flowing down a channel with a topography that varies with time
-"""
-
-#------------------------------------------------------------------------------
-# Import necessary modules
-#------------------------------------------------------------------------------
-from anuga import rectangular_cross
-from anuga import Domain
-from anuga import Reflective_boundary
-from anuga import Dirichlet_boundary
-from anuga import Time_boundary
-from anuga import Region
-from anuga import indent
-
-#------------------------------------------------------------------------------
-# Setup computational domain
-#------------------------------------------------------------------------------
-length = 24.
-width = 5.
-dx = dy = 0.2 #.1           # Resolution: Length of subdivisions on both axes
-
-points, vertices, boundary = rectangular_cross(int(length/dx), int(width/dy),
-                                               len1=length, len2=width)
-domain = Domain(points, vertices, boundary)
-domain.set_name() # Output name
-print domain.statistics()
-
-
-#------------------------------------------------------------------------------
-# Setup initial conditions
-#------------------------------------------------------------------------------
-def topography(x,y):
-    """Complex topography defined by a function of vectors x and y."""
-
-    z = -x/100
-
-    # Step
-    id = ( 2 < x ) & (x < 4)
-    z[id] +=  0.4 - 0.05*y[id]
-
-    # Permanent pole
-    id = (x - 8)**2 + (y - 2)**2 < 0.4**2
-    z[id] += 1
-
-    # Pole 2
-    #id =  (x - 14)**2 + (y - 3.5)**2 < 0.4**2
-    #z[id] += 1.0
-
-
-    return z
-
-
-
-domain.set_quantity('elevation', topography)           # elevation is a function
-domain.set_quantity('friction', 0.01)                  # Constant friction
-domain.set_quantity('stage', expression='elevation')   # Dry initial condition
-
-#------------------------------------------------------------------------------
-# Setup boundary conditions
-#------------------------------------------------------------------------------
-Bi = Dirichlet_boundary([0.4, 0, 0])          # Inflow
-Br = Reflective_boundary(domain)              # Solid reflective wall
-Bo = Dirichlet_boundary([-5, 0, 0])           # Outflow
-
-domain.set_boundary({'left': Bi, 'right': Bo, 'top': Br, 'bottom': Br})
-
-#------------------------------------------------------------------------------
-# Setup operators which are applied each inner step
-#------------------------------------------------------------------------------
-from anuga.operators.set_friction_operators import Depth_friction_operator
-from scipy import interpolate
-
-h = [0.0,     0.2,   0.4,   0.8,   2.0, 99.0]
-n = [0.250, 0.060, 0.045, 0.035, 0.025, 0.025]
-
-friction = interpolate.interp1d(h, n, fill_value=0.025)
-op1 = Depth_friction_operator(domain,friction=friction)
-
-#p1 = [ [12.0, 2.5], [13.5, 2.5], [13.5, 4.0], [12.0, 4.0] ]
-#op2 = Depth_friction_operator(domain,
-#                                  friction = lambda h :10,
-#                                  polygon=p1)
-
-# Setup region for integrating quantities
-p2 = [ [8.0, 2.5], [9.5, 2.5], [9.5, 4.0], [8.0, 4.0] ]
-reg = Region(domain, polygon=p2)
-
-# Some useful aliases
-stage = domain.quantities['stage']
-elev = domain.quantities['elevation']
-
-#------------------------------------------------------------------------------
-# Evolve system through time
-#------------------------------------------------------------------------------
-for t in domain.evolve(yieldstep=0.1, finaltime=10.0):
-    domain.print_timestepping_statistics()
-    domain.print_operator_timestepping_statistics()
-
-    # let calculate the integral of height over a region
-    height = stage-elev
-    print indent+'Int_p2(h) = '+str(height.get_integral(region=reg))
-
-
-
-
-
-
Index: unk/anuga_core/source/anuga/operators/run_set_elevation.py
===================================================================
--- /trunk/anuga_core/source/anuga/operators/run_set_elevation.py	(revision 9444)
+++ 	(revision )
@@ -1,137 +1,0 @@
-"""Simple water flow example using ANUGA
-
-Water flowing down a channel with a topography that varies with time
-"""
-
-import numpy as num
-
-#------------------------------------------------------------------------------
-# Import necessary modules
-#------------------------------------------------------------------------------
-from anuga import rectangular_cross
-from anuga import Domain
-from anuga import Reflective_boundary
-from anuga import Dirichlet_boundary
-from anuga import Time_boundary
-
-
-#------------------------------------------------------------------------------
-# Stage and Elevation Functions
-#------------------------------------------------------------------------------
-def topography(x,y):
-    """Complex topography defined by a function of vectors x and y."""
-
-
-    z = -x/100
-
-
-    # Step
-    id_s = (2 < x) & (x < 4)
-
-    z[id_s] += 0.4 - 0.05*y[id_s]
-
-    # Permanent pole
-    id_p = (x - 8)**2 + (y - 2)**2 < 0.4**2
-
-    z[id_p] += 1
-
-            
-    return z
-
-
-def pole_increment(x,y,t):
-    """This provides a small increment to a pole located mid stream
-    For use with variable elevation data
-    """
-
-
-    z = 0.0*x
-    
-
-    if t<10.0:
-        return z
-    
-
-    N = len(x)
-    for i in range(N):
-        # Pole 1
-        if (x[i] - 12)**2 + (y[i] - 3)**2 < 0.4**2:
-            z[i] += 0.1
-
-    for i in range(N):
-        # Pole 2
-        if (x[i] - 14)**2 + (y[i] - 2)**2 < 0.4**2:
-            z[i] += 0.05
-
-    return z
-
-
-def pole(x,y,t):
-	
-    z = topography(x,y)
-    if t<5:
-        return z
-    elif t>12:
-        return z
-    else:
-        return z+1.0
-
-
-
-#------------------------------------------------------------------------------
-# Setup computational domain
-#------------------------------------------------------------------------------
-length = 24.
-width = 5.
-dx = dy = 0.2 #.1           # Resolution: Length of subdivisions on both axes
-
-points, vertices, boundary = rectangular_cross(int(length/dx), int(width/dy),
-                                               len1=length, len2=width)
-domain = Domain(points, vertices, boundary)
-domain.set_name() # Output name based on script name
-print domain.statistics()
-domain.set_quantities_to_be_stored({'elevation': 2,
-                                    'stage': 2})
-
-#------------------------------------------------------------------------------
-# Setup initial conditions
-#------------------------------------------------------------------------------
-
-domain.set_quantity('elevation', topography)           # elevation is a function
-domain.set_quantity('friction', 0.01)                  # Constant friction
-domain.set_quantity('stage', expression='elevation')   # Dry initial condition
-
-#------------------------------------------------------------------------------
-# Setup boundary conditions
-#------------------------------------------------------------------------------
-Bi = Dirichlet_boundary([0.4, 0, 0])          # Inflow
-Br = Reflective_boundary(domain)              # Solid reflective wall
-Bo = Dirichlet_boundary([-5, 0, 0])           # Outflow
-
-domain.set_boundary({'left': Bi, 'right': Bo, 'top': Br, 'bottom': Br})
-
-#------------------------------------------------------------------------------
-# Evolve system through time
-#------------------------------------------------------------------------------
-
-from anuga import Set_elevation_operator
-op1 = Set_elevation_operator(domain, elevation=pole, radius=0.5, center = (12.0,3.0))
-
-from anuga import Set_elevation
-op2 = Set_elevation(domain, elevation = topography)
-
-growing = False
-shrinking = False
-
-done = False
-for t in domain.evolve(yieldstep=0.1, finaltime=20.0):
-    domain.print_timestepping_statistics()
-    domain.print_operator_timestepping_statistics()
-
-    if num.allclose(15.0, t):
-        op1.set_elevation(None)
-        op2()
-
-
-
-
Index: unk/anuga_core/source/anuga/operators/run_set_elevation_polygon.py
===================================================================
--- /trunk/anuga_core/source/anuga/operators/run_set_elevation_polygon.py	(revision 9444)
+++ 	(revision )
@@ -1,135 +1,0 @@
-"""Simple water flow example using ANUGA
-
-Water flowing down a channel with a topography that varies with time
-"""
-
-#------------------------------------------------------------------------------
-# Import necessary modules
-#------------------------------------------------------------------------------
-from anuga import rectangular_cross
-from anuga import Domain
-from anuga import Reflective_boundary
-from anuga import Dirichlet_boundary
-from anuga import Time_boundary
-
-#------------------------------------------------------------------------------
-# Setup computational domain
-#------------------------------------------------------------------------------
-length = 24.
-width = 5.
-dx = dy = 0.2 #.1           # Resolution: Length of subdivisions on both axes
-
-points, vertices, boundary = rectangular_cross(int(length/dx), int(width/dy),
-                                               len1=length, len2=width)
-domain = Domain(points, vertices, boundary)
-domain.set_name('set_elevation') # Output name
-print domain.statistics()
-domain.set_quantities_to_be_stored({'elevation': 2,
-                                    'stage': 2})
-
-#------------------------------------------------------------------------------
-# Setup initial conditions
-#------------------------------------------------------------------------------
-def topography_dam(x,y):
-    """Complex topography defined by a function of vectors x and y."""
-
-    z = -x/100
-
-    N = len(x)
-    for i in range(N):
-        # Step
-        if 2 < x[i] < 4:
-            z[i] += 0.4 - 0.05*y[i]
-
-        # Permanent pole
-        if (x[i] - 8)**2 + (y[i] - 2)**2 < 0.4**2:
-            z[i] += 1
-
-
-        # Dam
-        if 12 < x[i] < 13:
-            z[i] += 0.4
-
-            
-    return z
-
-def topography_dam_break(x,y):
-    """Complex topography defined by a function of vectors x and y."""
-
-    z = -x/100
-
-    N = len(x)
-    for i in range(N):
-        # Step
-        if 2 < x[i] < 4:
-            z[i] += 0.4 - 0.05*y[i]
-
-        # Permanent pole
-        if (x[i] - 8)**2 + (y[i] - 2)**2 < 0.4**2:
-            z[i] += 1
-
-
-        # Dam
-        if 12 < x[i] < 13 and y[i] > 3.0:
-            z[i] += 0.4
-
-        if 12 < x[i] < 13 and y[i] < 2.0:
-            z[i] += 0.4
-
-    return z
-
-
-
-def pole(t):
-
-    if t<10:
-        return 0.0
-    elif t>15:
-        return 0.0
-    else:
-        return 0.05
-
-
-domain.set_quantity('elevation', topography_dam)       # elevation is a function
-domain.set_quantity('friction', 0.01)                  # Constant friction
-domain.set_quantity('stage', expression='elevation')   # Dry initial condition
-
-#------------------------------------------------------------------------------
-# Setup boundary conditions
-#------------------------------------------------------------------------------
-Bi = Dirichlet_boundary([0.4, 0, 0])          # Inflow
-Br = Reflective_boundary(domain)              # Solid reflective wall
-Bo = Dirichlet_boundary([-5, 0, 0])           # Outflow
-
-domain.set_boundary({'left': Bi, 'right': Bo, 'top': Br, 'bottom': Br})
-
-#------------------------------------------------------------------------------
-# Evolve system through time
-#------------------------------------------------------------------------------
-
-#from anuga.operators.set_elevation_operators import Circular_set_elevation_operator
-
-#op1 = Circular_set_elevation_operator(domain, elevation=pole, radius=0.5, center = (12.0,3.0))
-
-
-dam_break = False
-
-for t in domain.evolve(yieldstep=0.1, finaltime=40.0):
-    domain.print_timestepping_statistics()
-    domain.print_operator_timestepping_statistics()
-
-    if t >= 10 and not dam_break:
-        print 'changing elevation'
-
-        stage_c = domain.get_quantity('stage').centroid_values
-        elev_c =  domain.get_quantity('elevation').centroid_values
-        height_c = stage_c - elev_c
-        domain.set_quantity('elevation', topography_dam_break)
-        stage_c[:] = elev_c + height_c
-
-        dam_break = True
-
-
-
-
-
Index: unk/anuga_core/source/anuga/operators/run_set_stage.py
===================================================================
--- /trunk/anuga_core/source/anuga/operators/run_set_stage.py	(revision 9444)
+++ 	(revision )
@@ -1,91 +1,0 @@
-"""Simple test of setting stage in a circular region
-"""
-
-#------------------------------------------------------------------------------
-# Import necessary modules
-#------------------------------------------------------------------------------
-
-import sys
-import anuga
-
-
-from math import cos
-from numpy import zeros, float, where
-import numpy
-from time import localtime, strftime, gmtime
-
-
-
-#------------------------------------------------------------------------------
-# Setup domain
-#------------------------------------------------------------------------------
-dx = 100.
-dy = dx
-L = 10000.
-W = L
-#W = dx
-
-# structured mesh
-domain = anuga.rectangular_cross_domain(int(L/dx), int(W/dy), L, W, (-L/2.0, -W/2.0))
-
-
-domain.set_name()                
-
-#------------------------------------------------------------------------------
-# Setup Algorithm
-#------------------------------------------------------------------------------
-domain.set_flow_algorithm(2.0)
-
-#------------------------------------------------------------------------------
-# Setup initial conditions
-#------------------------------------------------------------------------------
-h0 = 1000.0
-
-domain.set_quantity('elevation',0.0)
-domain.set_quantity('friction', 0.0)
-domain.add_quantity('stage', h0)
-
-#-----------------------------------------------------------------------------
-# Setup boundary conditions
-#------------------------------------------------------------------------------
-Br = anuga.Reflective_boundary(domain)      # Solid reflective wall
-
-# Associate boundary tags with boundary objects
-domain.set_boundary({'left': Br, 'right': Br, 'top': Br, 'bottom': Br})
-
-#------------------------------------------------------------------------------
-# Setup Operators
-#------------------------------------------------------------------------------
-from anuga.operators.set_stage_operator import Set_stage_operator
-
-import math
-
-stage1 = lambda t: h0 + 20.0 * math.sin(t/3.0)
-#cop1 = Set_stage_operator(domain, stage=stage1, center=(0.0, 0.0), radius=100.0 )
-
-stage2 = lambda t: h0 + 30.0# * math.sin(t/3.0)
-cop2 = Set_stage_operator(domain, stage=stage2, center=(2000.0, 1000.0), radius=100.0 )
-
-#print cop1.statistics()
-#print cop2.statistics()
-
-#------------------------------------------------------------------------------
-# Evolve system through time
-#------------------------------------------------------------------------------
-
-## stage = domain.get_quantity('stage')
-## id = domain.get_triangle_containing_point([2000., 1150.])
-## times = []
-## stages = []
-
-for t in domain.evolve(yieldstep = 1.0, finaltime = 200.0):
-    #print domain.timestepping_statistics(track_speeds=True)
-    domain.print_timestepping_statistics()
-    domain.print_operator_timestepping_statistics()
-    #times.append(t)
-    #stages.append(stage.centroid_values[id])
-
-## import pylab as pl
-
-## pl.plot(times, stages)
-## pl.show()
Index: unk/anuga_core/source/anuga/operators/run_set_w_uh_vh.py
===================================================================
--- /trunk/anuga_core/source/anuga/operators/run_set_w_uh_vh.py	(revision 9444)
+++ 	(revision )
@@ -1,79 +1,0 @@
-"""Simple test of setting stage in a circular region
-"""
-
-#------------------------------------------------------------------------------
-# Import necessary modules
-#------------------------------------------------------------------------------
-
-import sys
-import anuga
-
-
-from math import cos
-from numpy import zeros, float, where
-import numpy
-from time import localtime, strftime, gmtime
-
-
-
-#------------------------------------------------------------------------------
-# Setup domain
-#------------------------------------------------------------------------------
-dx = 100.
-dy = dx
-L = 10000.
-W = L
-#W = dx
-
-# structured mesh
-domain = anuga.rectangular_cross_domain(int(L/dx), int(W/dy), L, W, (-L/2.0, -W/2.0))
-
-
-domain.set_name()                
-
-#------------------------------------------------------------------------------
-# Setup Algorithm
-#------------------------------------------------------------------------------
-domain.set_flow_algorithm(2.0)
-
-#------------------------------------------------------------------------------
-# Setup initial conditions
-#------------------------------------------------------------------------------
-h0 = 1000.0
-
-domain.set_quantity('elevation',0.0)
-domain.set_quantity('friction', 0.0)
-domain.add_quantity('stage', h0)
-
-#-----------------------------------------------------------------------------
-# Setup boundary conditions
-#------------------------------------------------------------------------------
-Br = anuga.Reflective_boundary(domain)      # Solid reflective wall
-
-# Associate boundary tags with boundary objects
-domain.set_boundary({'left': Br, 'right': Br, 'top': Br, 'bottom': Br})
-
-#------------------------------------------------------------------------------
-# Setup Operators
-#------------------------------------------------------------------------------
-from anuga.operators.set_w_uh_vh_operator import Set_w_uh_vh_operator
-
-import math
-
-wuhvh1 = lambda t: [ h0 + 20.0 * math.sin(t/3.0) ,  20.0 * math.sin(t/3.0),  10.0 * math.sin(t/3.0)]
-cop1 = Set_w_uh_vh_operator(domain, w_uh_vh=wuhvh1, center=(0.0, 0.0), radius=100.0 )
-
-
-print cop1.statistics()
-#print cop2.statistics()
-
-#------------------------------------------------------------------------------
-# Evolve system through time
-#------------------------------------------------------------------------------
-
-for t in domain.evolve(yieldstep = 1.0, finaltime = 40.0):
-    #print domain.timestepping_statistics(track_speeds=True)
-    domain.print_timestepping_statistics()
-    domain.print_operator_timestepping_statistics()
-
-
Index: /trunk/anuga_core/source/anuga/operators/test/test_all.py
===================================================================
--- /trunk/anuga_core/source/anuga/operators/test/test_all.py	(revision 9445)
+++ /trunk/anuga_core/source/anuga/operators/test/test_all.py	(revision 9445)
@@ -0,0 +1,83 @@
+"""Regression testing framework
+This module will search for scripts in the same directory named
+test_*.py.  Each such script should be a test suite that tests a
+module through PyUnit. This script will aggregate all
+found test suites into one big test suite and run them all at once.
+"""
+
+# Author: Mark Pilgrim
+# Modified by Ole Nielsen
+
+import unittest
+import os
+
+
+#List files that should be excluded from the testing process.
+#E.g. if they are known to fail and under development
+exclude = [] 
+
+
+def get_test_files(path):
+
+    import sys
+
+    files = os.listdir(path)
+
+    #Check sub directories
+    test_files = []
+    for file in files:
+        if os.path.isdir(file):
+            sys.path.append(file)
+            #print 'Recursing into', file
+            test_files += get_test_files(path + os.sep + file)
+        elif file[:5] == 'test_' and file[-2:] == 'py':
+            #print 'Appending', file
+            test_files.append(file)
+        else:
+            pass
+    return test_files
+
+
+
+def regressionTest():
+    import sys, os, re, unittest
+    path = os.path.split(sys.argv[0])[0] or os.getcwd()
+
+
+    files = get_test_files(path)
+
+
+
+    #test = re.compile('^test_[\w]*.py$', re.IGNORECASE)
+    #files = filter(test.search, files)
+
+
+    try:
+        files.remove(__file__)  #Remove self from list (Ver 2.3. or later)
+    except:
+        files.remove('test_all.py')
+
+    print 'Testing:'
+    for file in files:
+        print '  ' + file
+
+    if globals().has_key('exclude'):
+        for file in exclude:
+            files.remove(file)
+            print 'WARNING: File '+ file + ' excluded from testing'
+
+
+    filenameToModuleName = lambda f: os.path.splitext(f)[0]
+    #print "files",files 
+    moduleNames = map(filenameToModuleName, files)
+    #print "moduleNames",moduleNames
+    modules = map(__import__, moduleNames)
+    load = unittest.defaultTestLoader.loadTestsFromModule
+    return unittest.TestSuite(map(load, modules))
+
+################################################################################
+
+if __name__ == '__main__':   
+    suite = regressionTest()
+    runner = unittest.TextTestRunner() #verbosity=2)
+    runner.run(suite)
Index: /trunk/anuga_core/source/anuga/operators/test/test_base_operator.py
===================================================================
--- /trunk/anuga_core/source/anuga/operators/test/test_base_operator.py	(revision 9445)
+++ /trunk/anuga_core/source/anuga/operators/test/test_base_operator.py	(revision 9445)
@@ -0,0 +1,51 @@
+from anuga import Domain
+from anuga import Dirichlet_boundary
+from anuga import Operator
+
+import numpy as num
+import unittest
+
+class Test_Operator(unittest.TestCase):
+    def setUp(self):
+        pass
+
+    def tearDown(self):
+        pass
+
+    def test_create_operator(self):
+        points = num.array([[0.0,0.0],[1.0,0.0],[0.0,1.0]])
+        
+        elements = num.array([[0,1,2]])
+        boundary_map = {}
+        boundary_map[(0,0)] = 'edge0'
+        boundary_map[(0,1)] = 'edge1'
+        boundary_map[(0,2)] = 'edge2'
+
+        domain = Domain(points, elements, boundary_map)
+
+        operator = Operator(domain)
+
+        message = operator.statistics()
+        assert message == 'You need to implement operator statistics for your operator'
+
+        message = operator.timestepping_statistics()
+        assert message == 'You need to implement timestepping statistics for your operator'
+
+        domain.timestep = 3.0
+
+        assert operator.get_timestep() == domain.get_timestep()
+        
+        try:
+            operator()
+        except:
+            pass
+        else:
+            raise Exception('should have raised an exception')
+
+
+################################################################################
+
+if __name__ == "__main__":
+    suite = unittest.makeSuite(Test_Operator, 'test')
+    runner = unittest.TextTestRunner()
+    runner.run(suite)
Index: /trunk/anuga_core/source/anuga/operators/test/test_boundary_flux_integral_operator.py
===================================================================
--- /trunk/anuga_core/source/anuga/operators/test/test_boundary_flux_integral_operator.py	(revision 9445)
+++ /trunk/anuga_core/source/anuga/operators/test/test_boundary_flux_integral_operator.py	(revision 9445)
@@ -0,0 +1,98 @@
+import unittest
+import anuga
+import numpy
+import os
+
+boundaryPolygon=[ [0., 0.], [0., 100.], [100.0, 100.0], [100.0, 0.0]]
+
+verbose=False
+
+class Test_boundary_flux_integral_operator(unittest.TestCase):
+    def setUp(self):
+        pass
+
+    def tearDown(self):
+        try:
+            os.remove('test_boundaryfluxintegral.msh')
+        except:
+            pass
+
+
+        try:
+            os.remove('test_boundaryfluxintegral.sww')
+        except:
+            pass
+
+    def create_domain(self, flowalg):
+        # Riverwall = list of lists, each with a set of x,y,z (and optional QFactor) values
+
+        # Make the domain
+        anuga.create_mesh_from_regions(boundaryPolygon, 
+                                 boundary_tags={'left': [0],
+                                                'top': [1],
+                                                'right': [2],
+                                                'bottom': [3]},
+                                   maximum_triangle_area = 200.,
+                                   minimum_triangle_angle = 28.0,
+                                   filename = 'test_boundaryfluxintegral.msh',
+                                   use_cache=False,
+                                   verbose=verbose)
+
+        domain=anuga.create_domain_from_file('test_boundaryfluxintegral.msh')
+
+        # 05/05/2014 -- riverwalls only work with DE0 and DE1
+        domain.set_flow_algorithm(flowalg)
+        domain.set_name('test_boundaryfluxintegral')
+
+        domain.set_store_vertices_uniquely()
+       
+        def topography(x,y):
+            return -x/150. 
+
+        # NOTE: Setting quantities at centroids is important for exactness of tests
+        domain.set_quantity('elevation',topography,location='centroids')     
+        domain.set_quantity('friction',0.03)             
+        domain.set_quantity('stage', topography,location='centroids')            
+       
+        # Boundary conditions
+        Br=anuga.Reflective_boundary(domain)
+        Bd=anuga.Dirichlet_boundary([0., 0., 0.])
+        domain.set_boundary({'left': Br, 'right': Bd, 'top': Br, 'bottom':Br})
+
+        return domain
+
+    def test_boundary_flux_operator_DE0(self):
+        """
+        A (the) boundary flux operator is instantiated when a domain is created.
+        This tests the calculation for euler timestepping 
+        """
+        
+        domain=self.create_domain('DE0')
+        for t in domain.evolve(yieldstep=0.1,finaltime=1.0):
+            pass
+        # The domain was initially dry
+        vol=domain.get_water_volume()
+        boundaryFluxInt=domain.get_boundary_flux_integral()
+
+        assert(numpy.allclose(vol,boundaryFluxInt))
+    
+    def test_boundary_flux_operator_DE1(self):
+        """
+        A (the) boundary flux operator is instantiated when a domain is created.
+        This tests the calculation for rk2 timestepping 
+        """
+        
+        domain=self.create_domain('DE1')
+        for t in domain.evolve(yieldstep=0.1,finaltime=1.0):
+            pass
+        # The domain was initially dry
+        vol=domain.get_water_volume()
+        boundaryFluxInt=domain.get_boundary_flux_integral()
+
+        assert(numpy.allclose(vol,boundaryFluxInt))
+
+if __name__ == "__main__":
+    suite = unittest.makeSuite(Test_boundary_flux_integral_operator, 'test')
+    runner = unittest.TextTestRunner(verbosity=1)
+    runner.run(suite)
+
Index: /trunk/anuga_core/source/anuga/operators/test/test_erosion_operators.py
===================================================================
--- /trunk/anuga_core/source/anuga/operators/test/test_erosion_operators.py	(revision 9445)
+++ /trunk/anuga_core/source/anuga/operators/test/test_erosion_operators.py	(revision 9445)
@@ -0,0 +1,344 @@
+"""  Test erosion operators
+"""
+
+import unittest, os
+import anuga
+from anuga import Domain
+from anuga import Reflective_boundary
+from anuga import rectangular_cross_domain
+from anuga import file_function
+
+from anuga.config import netcdf_mode_r, netcdf_mode_w, netcdf_mode_a
+from anuga.file_conversion.file_conversion import timefile2netcdf
+from anuga.config import time_format
+
+from anuga.operators.erosion_operators import Erosion_operator
+
+import numpy as num
+import warnings
+import time
+
+
+
+class Test_erosion_operators(unittest.TestCase):
+    def setUp(self):
+        pass
+
+    def tearDown(self):
+        pass
+
+
+
+    def test_erosion_operator_simple(self):
+        from anuga.config import rho_a, rho_w, eta_w
+        from math import pi, cos, sin
+
+        a = [0.0, 0.0]
+        b = [0.0, 2.0]
+        c = [2.0, 0.0]
+        d = [0.0, 4.0]
+        e = [2.0, 2.0]
+        f = [4.0, 0.0]
+
+        points = [a, b, c, d, e, f]
+        #             bac,     bce,     ecf,     dbe
+        vertices = [[1,0,2], [1,2,4], [4,2,5], [3,1,4]]
+
+        domain = Domain(points, vertices)
+
+        #Flat surface with 1m of water
+        domain.set_quantity('elevation', 0.5)
+        domain.set_quantity('stage', 1.0)
+        domain.set_quantity('friction', 0)
+        domain.set_quantity('xmomentum',2.0)
+        domain.set_quantity('ymomentum',3.0)
+
+        Stage = domain.quantities['stage'].centroid_values
+        Elevation = domain.quantities['elevation'].centroid_values
+
+        Height = Stage - Elevation
+
+        sum1 = num.sum(Height)
+
+        Br = Reflective_boundary(domain)
+        domain.set_boundary({'exterior': Br})
+
+
+#        print domain.quantities['stage'].centroid_values
+#        print domain.quantities['xmomentum'].centroid_values
+#        print domain.quantities['ymomentum'].centroid_values
+
+        # Apply operator to these triangles
+        indices = [0,1,3]
+
+
+        operator = Erosion_operator(domain, indices=indices, logging=True)
+
+        # Apply Operator
+        domain.timestep = 2.0
+        operator()
+
+        elev_ex  = [ 0.05555556,  0.11111111,  0.27777778,  0.05555556]
+        stage_ex = [ 0.55555556,  0.61111111,  0.77777778,  0.55555556]
+
+        Stage = domain.quantities['stage'].centroid_values
+        Elevation = domain.quantities['elevation'].centroid_values
+
+        Height = Stage - Elevation
+
+        sum2 = num.sum(Height)
+        
+        #print domain.quantities['elevation'].centroid_values
+        #print domain.quantities['stage'].centroid_values
+        #print domain.quantities['xmomentum'].centroid_values
+        #print domain.quantities['ymomentum'].centroid_values
+
+        assert sum1 == sum2
+        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
+        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 2.0)
+        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 3.0)
+
+
+
+#    def test_rate_operator_rate_from_file(self):
+#        from anuga.config import rho_a, rho_w, eta_w
+#        from math import pi, cos, sin
+#
+#        a = [0.0, 0.0]
+#        b = [0.0, 2.0]
+#        c = [2.0, 0.0]
+#        d = [0.0, 4.0]
+#        e = [2.0, 2.0]
+#        f = [4.0, 0.0]
+#
+#        points = [a, b, c, d, e, f]
+#        #             bac,     bce,     ecf,     dbe
+#        vertices = [[1,0,2], [1,2,4], [4,2,5], [3,1,4]]
+#
+#
+#        #---------------------------------
+#        #Typical ASCII file
+#        #---------------------------------
+#        finaltime = 1200
+#        filename = 'test_file_function'
+#        fid = open(filename + '.txt', 'w')
+#        start = time.mktime(time.strptime('2000', '%Y'))
+#        dt = 60  #One minute intervals
+#        t = 0.0
+#        while t <= finaltime:
+#            t_string = time.strftime(time_format, time.gmtime(t+start))
+#            fid.write('%s, %f %f %f\n' %(t_string, 2*t, t**2, sin(t*pi/600)))
+#            t += dt
+#
+#        fid.close()
+#
+#        #Convert ASCII file to NetCDF (Which is what we really like!)
+#        timefile2netcdf(filename+'.txt')
+#
+#
+#        #Create file function from time series
+#        F = file_function(filename + '.tms',
+#                          quantities = ['Attribute0',
+#                                        'Attribute1',
+#                                        'Attribute2'])
+#
+#        #Now try interpolation
+#        for i in range(20):
+#            t = i*10
+#            q = F(t)
+#
+#            #Exact linear intpolation
+#            assert num.allclose(q[0], 2*t)
+#            if i%6 == 0:
+#                assert num.allclose(q[1], t**2)
+#                assert num.allclose(q[2], sin(t*pi/600))
+#
+#        #Check non-exact
+#
+#        t = 90 #Halfway between 60 and 120
+#        q = F(t)
+#        assert num.allclose( (120**2 + 60**2)/2, q[1] )
+#        assert num.allclose( (sin(120*pi/600) + sin(60*pi/600))/2, q[2] )
+#
+#
+#        t = 100 #Two thirds of the way between between 60 and 120
+#        q = F(t)
+#        assert num.allclose( 2*120**2/3 + 60**2/3, q[1] )
+#        assert num.allclose( 2*sin(120*pi/600)/3 + sin(60*pi/600)/3, q[2] )
+#
+#        #os.remove(filename + '.txt')
+#        #os.remove(filename + '.tms')
+#
+#
+#        domain = Domain(points, vertices)
+#
+#        #Flat surface with 1m of water
+#        domain.set_quantity('elevation', 0)
+#        domain.set_quantity('stage', 1.0)
+#        domain.set_quantity('friction', 0)
+#
+#        Br = Reflective_boundary(domain)
+#        domain.set_boundary({'exterior': Br})
+#
+##        print domain.quantities['elevation'].centroid_values
+##        print domain.quantities['stage'].centroid_values
+##        print domain.quantities['xmomentum'].centroid_values
+##        print domain.quantities['ymomentum'].centroid_values
+#
+#        # Apply operator to these triangles
+#        indices = [0,1,3]
+#
+#
+#        rate = file_function('test_file_function.tms', quantities=['Attribute1'])
+#
+#        factor = 1000.0
+#        default_rate= 17.7
+#
+#        operator = Rate_operator(domain, rate=rate, factor=factor, \
+#                      indices=indices, default_rate = default_rate)
+#
+#
+#        # Apply Operator
+#        domain.set_starttime(360.0)
+#        domain.timestep = 1.0
+#
+#        operator()
+#
+#
+#        d = domain.get_time()**2 * factor + 1.0
+#        stage_ex0 = [ d,  d,   1.,  d]
+#
+##        print d, domain.get_time(), F(360.0)
+#
+##        print domain.quantities['elevation'].centroid_values
+##        print domain.quantities['stage'].centroid_values
+##        print domain.quantities['xmomentum'].centroid_values
+##        print domain.quantities['ymomentum'].centroid_values
+#
+#        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex0)
+#        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
+#        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
+#
+#
+#        domain.set_starttime(-10.0)
+#        domain.timestep = 1.0
+#
+#        try:
+#            operator()
+#        except:
+#            pass
+#        else:
+#            raise Exception('Should have raised an exception, time too early')
+#
+#
+#        domain.set_starttime(1300.0)
+#        domain.timestep = 1.0
+#
+#        operator()
+#
+#        d = default_rate*factor + d
+#        stage_ex1 = [ d,  d,   1.,  d]
+#
+##        print domain.quantities['elevation'].centroid_values
+##        print domain.quantities['stage'].centroid_values
+##        print domain.quantities['xmomentum'].centroid_values
+##        print domain.quantities['ymomentum'].centroid_values
+#
+#        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex1)
+#        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
+#        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
+
+
+#    def test_rate_operator_functions_rate_default_rate(self):
+#        from anuga.config import rho_a, rho_w, eta_w
+#        from math import pi, cos, sin
+#
+#        a = [0.0, 0.0]
+#        b = [0.0, 2.0]
+#        c = [2.0, 0.0]
+#        d = [0.0, 4.0]
+#        e = [2.0, 2.0]
+#        f = [4.0, 0.0]
+#
+#        points = [a, b, c, d, e, f]
+#        #             bac,     bce,     ecf,     dbe
+#        vertices = [[1,0,2], [1,2,4], [4,2,5], [3,1,4]]
+#
+#        domain = Domain(points, vertices)
+#
+#        #Flat surface with 1m of water
+#        domain.set_quantity('elevation', 0)
+#        domain.set_quantity('stage', 1.0)
+#        domain.set_quantity('friction', 0)
+#
+#        Br = Reflective_boundary(domain)
+#        domain.set_boundary({'exterior': Br})
+#
+#        verbose = False
+#
+#        if verbose:
+#            print domain.quantities['elevation'].centroid_values
+#            print domain.quantities['stage'].centroid_values
+#            print domain.quantities['xmomentum'].centroid_values
+#            print domain.quantities['ymomentum'].centroid_values
+#
+#        # Apply operator to these triangles
+#        indices = [0,1,3]
+#        factor = 10.0
+#
+#
+#        def main_rate(t):
+#            if t > 20:
+#                msg = 'Model time exceeded.'
+#                raise Modeltime_too_late, msg
+#            else:
+#                return 3.0 * t + 7.0
+#
+#        default_rate = lambda t: 3*t + 7
+#
+#
+#        operator = Rate_operator(domain, rate=main_rate, factor=factor, \
+#                      indices=indices, default_rate = default_rate)
+#
+#
+#        # Apply Operator
+#        domain.timestep = 2.0
+#        operator()
+#
+#        t = operator.get_time()
+#        d = operator.get_timestep()*main_rate(t)*factor + 1
+#        stage_ex = [ d,  d,   1.,  d]
+#
+#        if verbose:
+#            print domain.quantities['elevation'].centroid_values
+#            print domain.quantities['stage'].centroid_values
+#            print domain.quantities['xmomentum'].centroid_values
+#            print domain.quantities['ymomentum'].centroid_values
+#
+#        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
+#        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
+#        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
+#
+#        domain.set_starttime(30.0)
+#        domain.timestep = 1.0
+#        operator()
+#
+#        t = operator.get_time()
+#        d = operator.get_timestep()*default_rate(t)*factor + d
+#        stage_ex = [ d,  d,   1.,  d]
+#
+#        if verbose:
+#            print domain.quantities['elevation'].centroid_values
+#            print domain.quantities['stage'].centroid_values
+#            print domain.quantities['xmomentum'].centroid_values
+#            print domain.quantities['ymomentum'].centroid_values
+#
+#        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
+#        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
+#        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
+
+            
+if __name__ == "__main__":
+    suite = unittest.makeSuite(Test_erosion_operators, 'test')
+    runner = unittest.TextTestRunner(verbosity=1)
+    runner.run(suite)
Index: /trunk/anuga_core/source/anuga/operators/test/test_kinematic_viscosity_operator.py
===================================================================
--- /trunk/anuga_core/source/anuga/operators/test/test_kinematic_viscosity_operator.py	(revision 9445)
+++ /trunk/anuga_core/source/anuga/operators/test/test_kinematic_viscosity_operator.py	(revision 9445)
@@ -0,0 +1,1366 @@
+import operator
+from anuga import Domain
+from anuga import Quantity
+from anuga import Dirichlet_boundary
+from kinematic_viscosity_operator import Kinematic_viscosity_operator
+
+import numpy as num
+from math import sqrt
+import unittest
+import os
+
+class Test_kinematic_viscosity(unittest.TestCase):
+    
+    def setUp(self):
+        pass
+
+    def tearDown(self):
+        try:
+            os.remove('domain.sww')
+        except:
+            pass
+
+        try:
+            os.remove('anuga.log')
+        except:
+            pass
+        
+    #First test operator class (1 triangle)
+    def operator1(self):
+        points = num.array([[0.0,0.0],[1.0,0.0],[0.0,1.0]])
+        elements = num.array([[0,1,2]])
+        boundary_map = {}
+        boundary_map[(0,0)] = 'edge0'
+        boundary_map[(0,1)] = 'edge1'
+        boundary_map[(0,2)] = 'edge2'
+        domain = Domain(coordinates=points,vertices=elements,boundary=boundary_map)
+
+        D0 = Dirichlet_boundary([1,0,3])
+        D1 = Dirichlet_boundary([2,1,0])
+        D2 = Dirichlet_boundary([3,1,2])
+        domain.set_boundary({'edge0': D0, 'edge1': D1, 'edge2': D2})
+
+        domain.set_quantity('stage', lambda x,y : x+2*y )
+        domain.set_quantity('elevation', lambda x,y : 3*x+5*y )
+
+
+
+        #print domain.quantities['stage'].vertex_values
+
+        #print domain.quantities['stage'].edge_values
+
+        domain.update_boundary()
+
+
+        #print domain.quantities['stage'].boundary_values
+        
+        return Kinematic_viscosity_operator(domain)
+
+    #Second test operator class (2 triangles)
+    def operator2(self):
+        points = num.array([[0.0,0.0],[1.0,0.0],[1.0,1.0],[0.0,1.0]])
+        elements = num.array([[0,1,3],[1,2,3]])
+        boundary_map = {}
+        boundary_map[(0,1)] = 'edge0'
+        boundary_map[(0,2)] = 'edge1'
+        boundary_map[(1,0)] = 'edge2'
+        boundary_map[(1,2)] = 'edge3'
+        domain = Domain(coordinates=points,vertices=elements,boundary=boundary_map)
+
+        D0 = Dirichlet_boundary([1,1,2])
+        D1 = Dirichlet_boundary([1,2,2])
+        D2 = Dirichlet_boundary([1,1,0])
+        D3 = Dirichlet_boundary([1,2,1])
+
+        domain.set_boundary({'edge0': D0, 'edge1': D1, 'edge2': D2, 'edge3': D3})
+        domain.update_boundary()
+
+
+
+        return Kinematic_viscosity_operator(domain)
+
+    def test_enumerate_boundary(self):
+        operator1 = self.operator1()
+        boundary_enumeration = operator1.domain.boundary_enumeration
+
+        assert boundary_enumeration[(0,0)] == 0
+        assert boundary_enumeration[(0,1)] == 1
+        assert boundary_enumeration[(0,2)] == 2
+
+        operator2 = self.operator2()
+        boundary_enumeration = operator2.domain.boundary_enumeration
+
+
+        assert boundary_enumeration[(0,1)] == 0
+        assert boundary_enumeration[(0,2)] == 1
+        assert boundary_enumeration[(1,0)] == 2
+        assert boundary_enumeration[(1,2)] == 3
+
+    def test_geo_structure(self):
+        operator1 = self.operator1()
+        indices = operator1.geo_structure_indices
+        values = operator1.geo_structure_values
+
+        assert num.allclose(indices, num.array([[1, 2, 3]]))
+        assert num.allclose(values, num.array([[-6.0, -6.0/sqrt(5), -6.0/sqrt(5)]]))
+
+        operator2 = self.operator2()
+        indices = operator2.geo_structure_indices
+        values = operator2.geo_structure_values
+        assert num.allclose(indices, num.array([[1,2,3],[4,0,5]]))
+        assert num.allclose(values, num.array([[-3.0,-6.0/sqrt(5),-6.0/sqrt(5)],[-6.0/sqrt(5),-3.0,-6.0/sqrt(5)]]))
+
+    def test_elliptic_matrix_one_triangle(self):
+
+        operator = self.operator1()
+        domain = operator.domain
+
+        a = Quantity(operator.domain)
+        a.set_values(1.0)
+        a.set_boundary_values(1.0)
+        
+        operator.update_elliptic_matrix(a)
+
+        A = operator.elliptic_matrix
+
+        assert num.allclose(A.todense(), num.array([-6.0-12.0/sqrt(5), 6.0,  6.0/sqrt(5), 6.0/sqrt(5)]))
+
+        a.set_values(10.0)
+        a.set_boundary_values(10.0)
+        
+        operator.update_elliptic_matrix(a)
+
+        assert num.allclose(A.todense(), 10*num.array([-6.0-12.0/sqrt(5), 6.0,  6.0/sqrt(5), 6.0/sqrt(5)]))
+    
+
+    def test_elliptic_matrix_two_triangles(self):
+
+
+        operator = self.operator2()
+
+        domain = operator.domain
+
+        a = Quantity(operator.domain)
+        a.set_values(1.0)
+        a.set_boundary_values(1.0)
+        operator.update_elliptic_matrix(a)
+
+        A = operator.elliptic_matrix
+
+    
+        A0 = num.array([[-3.0,3.0,0.0,0.0,0.0,0.0],
+                        [0.0,-6.0/sqrt(5.0),0.0,0.0,6.0/sqrt(5.0),0.0]])
+        A1 = num.array([[-6.0/sqrt(5.0),0.0,6.0/sqrt(5.0),0.0,0.0,0.0],\
+                        [3.0,-3.0,0.0,0.0,0.0,0.0]])
+        A2 = num.array([[-6.0/sqrt(5.0),0.0,0.0,6.0/sqrt(5.0),0.0,0.0],\
+                        [0.0, -6.0/sqrt(5.0), 0.0, 0.0, 0.0, 6.0/sqrt(5.0)]])
+
+
+        assert num.allclose(A.todense(), A0+A1+A2)
+
+        a.set_values([2.0, 1.0], location = 'centroids')
+        a.set_boundary_values(1.0)
+        operator.update_elliptic_matrix(a)
+
+        A = operator.elliptic_matrix
+        
+
+        assert num.allclose(A.todense()[0,:], 1.5*A0[0,:]+1.5*A1[0,:]+1.5*A2[0,:])
+        assert num.allclose(A.todense()[1,:], A0[1,:]+1.5*A1[1,:]+A2[1,:])
+
+        # Either negative values we set matrix row to zero
+        a.set_values([-2.0, -2.0], location = 'centroids')
+        a.set_boundary_values(1.0)
+        operator.update_elliptic_matrix(a)
+
+
+
+        assert num.allclose(A.todense()[0,:], 0.0)
+        assert num.allclose(A.todense()[1,:], 0.0)
+
+    def test_elliptic_multiply_include_boundary_one_triangle(self):
+        operator = self.operator1()
+        operator.set_triangle_areas(False)
+
+        print operator.apply_triangle_areas
+
+        a = Quantity(operator.domain)
+        a.set_values(1.0)
+        a.set_boundary_values(1.0)
+
+        operator.update_elliptic_matrix()
+
+        
+
+        q_in = Quantity(operator.domain)
+        q_in.set_values(1.0)
+        q_in.set_boundary_values(1.0)
+        
+        n = operator.n
+        
+        A = num.array([-6.0-12.0/sqrt(5), 6.0,  6.0/sqrt(5), 6.0/sqrt(5)])
+
+
+        q_1 = operator.elliptic_multiply(q_in)
+
+        q_2 = operator.elliptic_multiply(q_in, quantity_out = q_in)
+
+        assert id(q_in) == id(q_2)
+
+        assert num.allclose(q_1.centroid_values,q_2.centroid_values)
+
+        assert num.allclose( num.zeros((n,), num.float), q_1.centroid_values )
+
+        #Now have different boundary values
+
+        q_in.set_values(1.0)
+        q_in.set_boundary_values(0.0)
+        operator.update_elliptic_matrix(a)
+
+
+        A = num.array([-6.0-12.0/sqrt(5), 6.0,  6.0/sqrt(5), 6.0/sqrt(5)])
+
+
+        q_1 = operator.elliptic_multiply(q_in)
+
+        assert num.allclose( [-6.0-12.0/sqrt(5)], q_1.centroid_values )
+        
+    def test_elliptic_multiply_exclude_boundary_one_triangle(self):
+        operator = self.operator1()
+        operator.set_triangle_areas(False)
+
+        print operator.apply_triangle_areas
+        #n = operator.n
+
+        q_in = Quantity(operator.domain)
+        q_in.set_values(1.0)
+        q_in.set_boundary_values(1.0)
+        operator.update_elliptic_matrix()
+
+
+        A = num.array([-6.0-12.0/sqrt(5), 6.0,  6.0/sqrt(5), 6.0/sqrt(5)])
+
+
+        q_1 = operator.elliptic_multiply(q_in, include_boundary=False)
+
+
+        assert num.allclose( [-6.0-12.0/sqrt(5)], q_1.centroid_values )
+
+    def test_elliptic_multiply_include_boundary_one_triangle(self):
+        operator = self.operator1()
+        operator.set_triangle_areas(True)
+
+        n = operator.n
+
+        q_in = Quantity(operator.domain)
+        q_in.set_values(1.0)
+        q_in.set_boundary_values(1.0)
+        
+        operator.update_elliptic_matrix()
+
+
+        A = num.array([-6.0-12.0/sqrt(5), 6.0,  6.0/sqrt(5), 6.0/sqrt(5)])
+
+
+        q_1 = operator.elliptic_multiply(q_in)
+
+        q_2 = operator.elliptic_multiply(q_in, output = q_in)
+
+        assert id(q_in) == id(q_2)
+
+        assert num.allclose(q_1.centroid_values,q_2.centroid_values)
+
+        assert num.allclose( [-12.0-24.0/sqrt(5)], q_1.centroid_values )
+
+        #Now have different boundary values
+
+        q_in.set_values(1.0)
+        q_in.set_boundary_values(0.0)
+        operator.update_elliptic_matrix()
+
+
+        A = num.array([-6.0-12.0/sqrt(5), 6.0,  6.0/sqrt(5), 6.0/sqrt(5)])
+
+
+        q_1 = operator.elliptic_multiply(q_in)
+
+        assert num.allclose( [-12.0-24.0/sqrt(5)], q_1.centroid_values )
+
+    def test_elliptic_multiply_exclude_boundary_one_triangle(self):
+        operator = self.operator1()
+        operator.set_triangle_areas(True)
+
+        q_in = Quantity(operator.domain)
+        q_in.set_values(1.0)
+        q_in.set_boundary_values(1.0)
+        operator.update_elliptic_matrix()
+
+
+        A = num.array([-6.0-12.0/sqrt(5), 6.0,  6.0/sqrt(5), 6.0/sqrt(5)])
+
+
+        q_1 = operator.elliptic_multiply(q_in)
+
+
+        assert num.allclose( [-12.0-24.0/sqrt(5)], q_1.centroid_values )
+
+    def test_mul_arg(self):
+        operator = self.operator1()
+
+        u = Quantity(operator.domain)
+        u.set_values(2.0)
+        #q boundary_values should equal 0.0
+
+
+
+        operator.update_elliptic_boundary_term(u)
+
+        r = 2.0
+
+        try:
+            q_out = operator * 2.0
+        except TypeError:
+            pass
+        else:
+            raise Exception('Should have caught an TypeError')
+
+
+    def test_mul(self):
+        operator = self.operator1()
+
+        u = Quantity(operator.domain)
+        u.set_values(2.0)
+        #q boundary_values should equal 0.0
+
+        operator.update_elliptic_matrix()
+
+        operator.update_elliptic_boundary_term(u)
+
+        A = num.array([-6.0-12.0/sqrt(5), 6.0,  6.0/sqrt(5), 6.0/sqrt(5)])
+        V1 = num.array([2.0]) #u=2
+        U1 = num.array([[2.0],[0.0],[0.0],[0.0]])
+
+        q_out = operator * u
+        
+        assert num.allclose(q_out.centroid_values, 2*num.array(num.mat(A)*num.mat(U1)).reshape(1,))
+
+    def test_elliptic_solve_one_triangle(self):
+
+        operator = self.operator1()
+        n = operator.n
+        
+        U = num.array([2.0,2.0,1.0,1.0])
+
+        u_in = Quantity(operator.domain)
+        u_in.set_values(U[:1], location='centroids')
+        u_in.set_boundary_values(U[1:])
+
+        a = Quantity(operator.domain)
+        a.set_values(1.0)
+        a.set_boundary_values(1.0)
+
+        # Do this to get access to the matrix
+        # This is also called inside elliptic_solve
+        operator.update_elliptic_matrix(a)
+
+        V = num.array([2.0]) #h=1, u=2
+        A = num.array([-6.0-12.0/sqrt(5), 6.0,  6.0/sqrt(5), 6.0/sqrt(5)])
+        #U = num.array([[2.0,2.0],[2.0,1.0],[1.0,2.0],[1.0,0.0]])
+
+        #Setup up rhs as b = A u
+        X = num.array(2*num.mat(A)*num.mat(U.reshape(4,1))).reshape(1,)
+        b = Quantity(operator.domain)
+        b.set_values(X, location='centroids')
+
+        u_in.set_values(0.0)
+
+        u_out = operator.elliptic_solve(u_in, b, a, iprint=1)
+
+        assert num.allclose(u_out.centroid_values, U[:n])
+
+
+    def test_elliptic_solve_two_triangle(self):
+
+        operator = self.operator2()
+        n = operator.n
+        
+        U = num.array([2.0,3.0,1.0,1.0,4.0,3.0])
+
+        u_in = Quantity(operator.domain)
+        u_in.set_values(U[:2], location='centroids')
+        u_in.set_boundary_values(U[2:])
+
+        a = Quantity(operator.domain)
+        a.set_values(1.0)
+        a.set_boundary_values(1.0)
+
+        # Do this to get access to the matrix
+        # This is also called inside elliptic_solve
+        operator.update_elliptic_matrix(a)
+
+        V1 = U[:n]
+        V2 = U[n:]
+
+        A = num.mat(operator.elliptic_matrix.todense())
+        U = num.mat(U.reshape(6,1))
+
+        #Setup up rhs as b = A u
+        X = num.array(2*A*U).reshape(2,)
+
+        b = Quantity(operator.domain)
+        b.set_values(X, location='centroids')
+
+        u_in.set_values(0.0)
+
+        u_out = operator.elliptic_solve(u_in, b, a, iprint=1)
+
+        assert num.allclose(u_out.centroid_values, V1)
+        assert num.allclose(u_out.boundary_values, V2)
+
+    def test_elliptic_solve_rectangular_cross(self):
+
+        from anuga import rectangular_cross_domain
+
+        m1 = 10
+        n1 = 10
+        domain = rectangular_cross_domain(m1,n1)
+
+        # Diffusivity
+        a = Quantity(domain)
+        a.set_values(1.0)
+        a.set_boundary_values(1.0)
+
+        # Quantity to solve
+        u = Quantity(domain)
+        u.set_values(0.0)
+        u.set_boundary_values(1.0)
+
+        # Quantity for rhs
+        b = Quantity(domain)
+        b.set_values(0.0)
+        b.set_boundary_values(0.0)
+
+        operator = Kinematic_viscosity_operator(domain)
+
+        n = operator.n
+        tot_len = operator.tot_len
+
+        u_out = operator.elliptic_solve(u, b, a, iprint=1)
+    
+        assert num.allclose(u_out.centroid_values, num.ones_like(u_out.centroid_values))
+        assert num.allclose(u_out.boundary_values, num.ones_like(u_out.boundary_values))
+
+
+
+    def test_parabolic_solve_one_triangle(self):
+        operator = self.operator1()
+        n = operator.n
+        dt = operator.dt
+
+        U = num.array([2.0,2.0,1.0,1.0])
+        U_mod = num.array([10.0, 2.0, 1.0, 1.0])
+
+        u_in = Quantity(operator.domain)
+        u_in.set_values(U[:n], location='centroids')
+        u_in.set_boundary_values(U_mod[n:])
+
+        a = Quantity(operator.domain)
+        a.set_values(1.0)
+        a.set_boundary_values(1.0)
+
+
+        V = num.array([2.0])
+        A = num.array([-6.0-12.0/sqrt(5), 6.0,  6.0/sqrt(5), 6.0/sqrt(5)])
+
+        #Setup up rhs
+        X = U_mod[:n] - dt*2*num.array(num.mat(A)*num.mat(U_mod.reshape(4,1))).reshape(n,)
+        b = Quantity(operator.domain)
+        b.set_values(X, location='centroids')
+
+
+        u_out = operator.parabolic_solve(u_in, b, a, iprint=1)
+
+
+        assert num.allclose(u_out.centroid_values, U_mod[:n])
+
+
+    def test_parabolic_solve_two_triangles(self):
+        operator = self.operator2()
+        n = operator.n
+        nt = operator.tot_len
+
+        dt = operator.dt
+
+        U = num.array([2.0,3.0,1.0,1.0,4.0,3.0])
+        U_mod = num.array([4.0,2.0,1.0,1.0,4.0,3.0])
+
+
+        u_in = Quantity(operator.domain)
+        u_in.set_values(U[:n], location='centroids')
+        u_in.set_boundary_values(U_mod[n:])
+
+        a = Quantity(operator.domain)
+        a.set_values(1.0)
+        a.set_boundary_values(1.0)
+
+        operator.update_elliptic_matrix(a)
+
+
+        A = num.array([[-8.36656315,  3., 2.68328157,  2.68328157,  0.,  0. ],
+                       [ 3., -8.36656315 , 0. , 0. ,  2.68328157,  2.68328157]])
+
+        assert num.allclose(A,operator.elliptic_matrix.todense())
+
+
+
+        #Setup up rhs
+        X = U_mod[:n] - dt*2*num.array(num.mat(A)*num.mat(U_mod.reshape(nt,1))).reshape(n,)
+        b = Quantity(operator.domain)
+        b.set_values(X, location='centroids')
+
+
+        u_out = operator.parabolic_solve(u_in, b, a, iprint=1)
+
+
+        assert num.allclose(u_out.centroid_values, U_mod[:n])
+
+    def test_parabolic_solve_rectangular_cross(self):
+
+        from anuga import rectangular_cross_domain
+
+        m1 = 10
+        n1 = 10
+        domain = rectangular_cross_domain(m1,n1)
+
+        # Diffusivity
+        a = Quantity(domain)
+        a.set_values(1.0)
+        a.set_boundary_values(1.0)
+
+        # Quantity initial condition
+        u_in = Quantity(domain)
+        #u_in.set_values( 0.0 )
+        u_in.set_values(lambda x,y : 16.0*x*(1-x)*y*(1-y))
+        u_in.set_boundary_values(0.0)
+
+        # Quantity to solve
+        u_mod = Quantity(domain)
+        u_mod.set_values(lambda x,y : 15.9*x*(1-x)*y*(1-y) )
+        u_mod.set_boundary_values(0.0)
+
+        # Quantity for rhs
+        b = Quantity(domain)
+        b.set_values(0.0)
+        b.set_boundary_values(0.0)
+
+        operator = Kinematic_viscosity_operator(domain)
+
+        dt = 0.01
+        operator.dt = dt
+        n = operator.n
+        nt = operator.tot_len
+
+        operator.update_elliptic_matrix(a)
+
+        A = num.mat(operator.elliptic_matrix.todense())
+        D = num.mat(operator.triangle_areas.todense())
+        U_mod = num.concatenate( (u_mod.centroid_values, u_mod.boundary_values) )
+
+
+        #Setup up rhs
+        X = U_mod[:n] - dt*num.array(D*A*num.mat(U_mod.reshape(nt,1))).reshape(n,)
+        b = Quantity(operator.domain)
+        b.set_values(X, location='centroids')
+
+
+        u_out = operator.parabolic_solve(u_in, b, a, iprint=1, use_dt_tol=False)
+
+        assert num.allclose(u_out.centroid_values, U_mod[:n])
+
+
+    def test_elliptic_solve_rectangular_cross_velocities(self):
+
+        from anuga import rectangular_cross_domain
+        from anuga import Reflective_boundary
+
+        m1 = 10
+        n1 = 10
+        domain = rectangular_cross_domain(m1,n1)
+
+        #
+        domain.set_quantity('elevation', expression='x')
+        domain.set_quantity('friction', 0.03)
+        domain.set_quantity('stage',expression='elevation + 2*x')
+        domain.set_quantity('xmomentum', expression='2*x+3*y')
+        domain.set_quantity('ymomentum', expression='5*x+7*y')
+
+
+        B = Reflective_boundary(domain)
+        domain.set_boundary( {'left': B, 'right': B, 'top': B, 'bottom': B})
+
+        domain.update_boundary()
+        domain.update_centroids_of_velocities_and_height()
+
+
+        a = domain.quantities['height']
+
+        # Quantity to solve
+        u = domain.quantities['xvelocity']
+        u.set_boundary_values(1.0)
+
+
+        v = domain.quantities['yvelocity']
+        v.set_boundary_values(2.0)
+
+        # Quantity for rhs
+        b = Quantity(domain)
+        b.set_values(0.0)
+        b.set_boundary_values(0.0)
+
+        kv = Kinematic_viscosity_operator(domain)
+
+        n = kv.n
+        tot_len = kv.tot_len
+
+        kv.update_elliptic_matrix(a)
+
+        u_out = kv.elliptic_solve(u, b, a, update_matrix=False, iprint=1)
+
+        v_out = kv.elliptic_solve(v, b, a, update_matrix=False, iprint=1)
+
+        assert num.allclose(u_out.centroid_values, num.ones_like(u_out.centroid_values))
+        assert num.allclose(u_out.boundary_values, num.ones_like(u_out.boundary_values))
+
+    def test_parabolic_solve_rectangular_cross_velocities(self):
+
+        from anuga import rectangular_cross_domain
+        from anuga import Reflective_boundary
+
+        m1 = 10
+        n1 = 10
+        domain = rectangular_cross_domain(m1,n1)
+
+        #
+        domain.set_quantity('elevation', expression='x')
+        domain.set_quantity('friction', 0.03)
+        domain.set_quantity('stage',expression='elevation + 2*x')
+        domain.set_quantity('xmomentum', expression='2*x+3*y')
+        domain.set_quantity('ymomentum', expression='5*x+7*y')
+
+
+        B = Reflective_boundary(domain)
+        domain.set_boundary( {'left': B, 'right': B, 'top': B, 'bottom': B})
+
+        domain.update_boundary()
+        domain.update_centroids_of_velocities_and_height()
+
+
+
+
+        h = domain.quantities['height']
+
+        # Quantity to solve
+        u = domain.quantities['xvelocity']
+        u.set_boundary_values(1.0)
+
+
+        v = domain.quantities['yvelocity']
+        v.set_boundary_values(2.0)
+
+        kv = Kinematic_viscosity_operator(domain)
+
+
+        # let's make timestep large so that the final solution will look like
+        #the solution of hte elliptic problem. In this case u -> 1, v -> 2.
+
+        dt = 100.0
+        kv.dt = dt
+        n = kv.n
+        nt = kv.tot_len
+
+        kv.update_elliptic_matrix(h)
+
+        kv.parabolic_solve(u, u, h, u_out=u, update_matrix=False, iprint=1, use_dt_tol=False)
+
+        kv.parabolic_solve(v, v, h, u_out=v, update_matrix=False, iprint=1, use_dt_tol=False)
+
+
+        #print u.centroid_values
+        #print u.boundary_values
+        assert num.allclose(u.centroid_values, num.ones_like(u.centroid_values), rtol=1.0e-1)
+        assert num.allclose(u.boundary_values, num.ones_like(u.boundary_values))
+
+        assert num.allclose(v.centroid_values, 2.0*num.ones_like(v.centroid_values), rtol=1.0e-1)
+        assert num.allclose(v.boundary_values, 2.0*num.ones_like(v.boundary_values))
+
+
+        domain.update_centroids_of_momentum_from_velocity()
+
+        uh = domain.quantities['xmomentum']
+        vh = domain.quantities['ymomentum']
+
+        assert num.allclose(uh.centroid_values, u.centroid_values*h.centroid_values )
+        assert num.allclose(vh.centroid_values, v.centroid_values*h.centroid_values )
+
+
+    def test_parabolic_solve_rectangular_cross_velocities_zero_h(self):
+
+        from anuga import rectangular_cross_domain
+        from anuga import Reflective_boundary
+
+        m1 = 5
+        n1 = 5
+        domain = rectangular_cross_domain(m1,n1)
+
+        #
+        domain.set_quantity('elevation', expression='x')
+        domain.set_quantity('friction', 0.03)
+        domain.set_quantity('stage',expression='elevation + 2*(x-0.5)')
+        domain.set_quantity('xmomentum', expression='2*x+3*y')
+        domain.set_quantity('ymomentum', expression='5*x+7*y')
+
+ 
+        w = domain.quantities['stage']
+
+        #print w.centroid_values
+        #print w.boundary_values
+
+        domain.distribute_to_vertices_and_edges()
+
+        #print w.centroid_values
+        #print w.boundary_values
+        
+        B = Reflective_boundary(domain)
+        domain.set_boundary( {'left': B, 'right': B, 'top': B, 'bottom': B})
+
+        domain.update_boundary()
+
+        #print w.centroid_values
+        #print w.boundary_values
+
+        domain.update_centroids_of_velocities_and_height()
+
+
+
+
+        h = domain.quantities['height']
+
+        #print 'h'
+        #print h.centroid_values
+        #print h.boundary_values
+        
+        # Quantity to solve
+        u = domain.quantities['xvelocity']
+        u.set_boundary_values(1.0)
+
+
+        #print 'u'
+        #print u.centroid_values
+        #print u.boundary_values
+
+        v = domain.quantities['yvelocity']
+        v.set_boundary_values(2.0)
+
+        kv = Kinematic_viscosity_operator(domain)
+
+
+        # let's make timestep large so that the final solution will look like
+        #the solution of hte elliptic problem. In this case u -> 1, v -> 2.
+
+        dt = 1000.0
+        kv.dt = dt
+        n = kv.n
+        nt = kv.tot_len
+
+        kv.update_elliptic_matrix(h)
+
+        kv.parabolic_solve(u, u, h, u_out=u, update_matrix=False, iprint=1, use_dt_tol=False)
+
+        kv.parabolic_solve(v, v, h, u_out=v, update_matrix=False, iprint=1, use_dt_tol=False)
+
+        assert num.allclose(u.centroid_values, num.where(h.centroid_values > 0.0, 1.0, 0.0), rtol=1.0e-1)
+        assert num.allclose(u.boundary_values, num.ones_like(u.boundary_values))
+
+        assert num.allclose(v.centroid_values, num.where(h.centroid_values > 0.0, 2.0, 0.0), rtol=1.0e-1)
+        assert num.allclose(v.boundary_values, 2.0*num.ones_like(v.boundary_values))
+
+
+        domain.update_centroids_of_momentum_from_velocity()
+
+        domain.distribute_to_vertices_and_edges()
+        
+        uh = domain.quantities['xmomentum']
+        vh = domain.quantities['ymomentum']
+
+        #print 'uh'
+        #print uh.centroid_values
+        #print uh.boundary_values
+
+        assert num.allclose(uh.centroid_values, u.centroid_values*h.centroid_values )
+        assert num.allclose(vh.centroid_values, v.centroid_values*h.centroid_values )
+
+    def test_kinematic_operator_default(self):
+
+        from anuga import rectangular_cross_domain
+        from anuga import Reflective_boundary
+
+        m1 = 10
+        n1 = 10
+        domain = rectangular_cross_domain(m1,n1)
+
+        #domain.set_flow_algorithm('2_0')
+
+        #
+        domain.set_quantity('elevation', expression='x')
+        domain.set_quantity('friction', 0.03)
+        domain.set_quantity('stage',expression='elevation + 2*(x-0.5)')
+        domain.set_quantity('xmomentum', expression='2*x+3*y')
+        domain.set_quantity('ymomentum', expression='5*x+7*y')
+
+        B = Reflective_boundary(domain)
+        domain.set_boundary( {'left': B, 'right': B, 'top': B, 'bottom': B})
+
+        # kill off the wave with viscosity
+        kv = Kinematic_viscosity_operator(domain)
+
+
+        # let's make timestep large so that the final solution will look like
+        #the solution of hte elliptic problem. In this case u -> 1, v -> 2.
+
+
+        for t in domain.evolve(yieldstep = 1.0, finaltime = 10.0):
+            #domain.write_time()
+            #domain.print_operator_timestepping_statistics()
+            pass
+
+#
+        w  = domain.quantities['stage']
+        uh = domain.quantities['xmomentum']
+        vh = domain.quantities['ymomentum']
+
+        #print 'uh'
+        #print uh.centroid_values
+        #print uh.boundary_values
+
+        #print 'w'
+        #print w.centroid_values
+
+        #from pprint import pprint
+        #pprint(w.centroid_values)
+
+
+        wc = num.array([
+        0.70714365,  0.70714416,  0.70714295,  0.70714222,  0.70714486,
+        0.70714507,  0.70714374,  0.70714601,  0.70714492,  0.70714425,
+        0.70714595,  0.70714437,  0.70714797,  0.70714691,  0.70714697,
+        0.70714845,  0.70714793,  0.70714793,  0.70715033,  0.70714852,
+        0.70715244,  0.70715018,  0.70715176,  0.70715224,  0.70715211,
+        0.70715265,  0.70715351,  0.7071531 ,  0.70715433,  0.70715309,
+        0.70715351,  0.70715472,  0.70715429,  0.70715433,  0.70715487,
+        0.70715523,  0.7071545 ,  0.70715446,  0.70715317,  0.70715564,
+        0.70714142,  0.70714198,  0.70714079,  0.70714299,  0.70714482,
+        0.70714378,  0.70714344,  0.70714377,  0.7071443 ,  0.70714533,
+        0.70714579,  0.70714574,  0.70714906,  0.70714717,  0.70714819,
+        0.70714822,  0.70714976,  0.70714952,  0.70715093,  0.70715077,
+        0.70715217,  0.70715094,  0.70715291,  0.70715188,  0.70715352,
+        0.70715278,  0.707154  ,  0.70715429,  0.70715376,  0.70715309,
+        0.70715446,  0.70715422,  0.70715366,  0.70715453,  0.70715413,
+        0.70715539,  0.70715385,  0.70715412,  0.70715154,  0.70715306,
+        0.70714038,  0.70713905,  0.7071358 ,  0.70713972,  0.70714303,
+        0.7071419 ,  0.70714066,  0.70714219,  0.7071459 ,  0.70714505,
+        0.70714639,  0.70714648,  0.70714833,  0.70714827,  0.70715147,
+        0.70715013,  0.70715194,  0.70715133,  0.70715542,  0.70715345,
+        0.70715296,  0.70715417,  0.70715676,  0.70715521,  0.70715526,
+        0.7071548 ,  0.70715717,  0.70715512,  0.70715381,  0.70715523,
+        0.70715556,  0.70715486,  0.70715482,  0.70715338,  0.70715307,
+        0.70715381,  0.70715132,  0.70715182,  0.70714789,  0.70715086,
+        0.70713443,  0.70713559,  0.70713539,  0.70713615,  0.70714057,
+        0.70713978,  0.70714091,  0.70714102,  0.70714618,  0.70714338,
+        0.70714803,  0.70714858,  0.7071519 ,  0.70715029,  0.70715343,
+        0.70715461,  0.70715589,  0.70715519,  0.7071565 ,  0.70715796,
+        0.70715738,  0.70715845,  0.7071601 ,  0.70715829,  0.70715711,
+        0.70715903,  0.70716011,  0.70715714,  0.7071565 ,  0.70715756,
+        0.70715885,  0.7071556 ,  0.70715386,  0.70715406,  0.70715653,
+        0.70715532,  0.70714813,  0.7071515 ,  0.70715242,  0.70715269,
+        0.70713191,  0.70712961,  0.70712505,  0.70712841,  0.70714097,
+        0.70713808,  0.70713862,  0.7071431 ,  0.70714966,  0.7071463 ,
+        0.70715775,  0.70715666,  0.70715566,  0.7071554 ,  0.7071632 ,
+        0.70716353,  0.70715928,  0.70716244,  0.70716736,  0.70716495,
+        0.70716301,  0.70716635,  0.70717088,  0.70716792,  0.70716369,
+        0.70717007,  0.7071741 ,  0.70716769,  0.70716166,  0.70716991,
+        0.70717294,  0.70716167,  0.70715775,  0.70716057,  0.70715687,
+        0.70715535,  0.70715014,  0.70714766,  0.70714559,  0.70714992,
+        0.7071149 ,  0.70708741,  0.706984  ,  0.70711096,  0.70714367,
+        0.70714831,  0.70713519,  0.7071811 ,  0.70716622,  0.70716603,
+        0.70714155,  0.7071748 ,  0.70716885,  0.70716897,  0.70713548,
+        0.70716966,  0.70716924,  0.70716978,  0.70713561,  0.7071717 ,
+        0.70717389,  0.7071726 ,  0.70713926,  0.70717593,  0.70718002,
+        0.70717761,  0.70714428,  0.70718053,  0.70718062,  0.70718719,
+        0.70715731,  0.70718271,  0.70716238,  0.7071992 ,  0.70715496,
+        0.70716834,  0.70713531,  0.70713099,  0.70700665,  0.7071098 ,
+        0.70634397,  0.70524618,  0.70297607,  0.70514658,  0.70658259,
+        0.70506628,  0.70244401,  0.70497884,  0.70657086,  0.70498266,
+        0.70239779,  0.70496243,  0.7065572 ,  0.7049646 ,  0.70239608,
+        0.70496008,  0.70655538,  0.70496125,  0.70239685,  0.70496177,
+        0.70655883,  0.70496295,  0.70239957,  0.70496624,  0.70656625,
+        0.70496724,  0.70240482,  0.7049756 ,  0.70658803,  0.70497608,
+        0.70241139,  0.70500006,  0.70660425,  0.70499778,  0.70246225,
+        0.70508764,  0.70636798,  0.70516922,  0.70299639,  0.70526838,
+        0.71780931,  0.7506157 ,  0.78399529,  0.75061024,  0.71769206,
+        0.75059929,  0.78398287,  0.75059279,  0.71768281,  0.75059112,
+        0.78397863,  0.75059025,  0.71768261,  0.75058996,  0.78397777,
+        0.75058981,  0.71768268,  0.75058969,  0.78397749,  0.75058967,
+        0.7176832 ,  0.75058972,  0.78397772,  0.75058986,  0.71768421,
+        0.7505901 ,  0.78397859,  0.75059043,  0.71768534,  0.7505909 ,
+        0.78398028,  0.750592  ,  0.71769545,  0.75059388,  0.78398545,
+        0.75060056,  0.71781337,  0.75061163,  0.78399848,  0.75061714,
+        0.81739069,  0.85076296,  0.8841241 ,  0.85076174,  0.81738381,
+        0.85075988,  0.88412183,  0.85075808,  0.81738087,  0.85075718,
+        0.88412031,  0.85075635,  0.81737996,  0.85075599,  0.88411952,
+        0.85075563,  0.81737963,  0.85075548,  0.88411919,  0.8507555 ,
+        0.81738003,  0.85075569,  0.88411972,  0.85075629,  0.81738134,
+        0.85075692,  0.88412133,  0.85075812,  0.81738361,  0.85075914,
+        0.88412387,  0.85076103,  0.81738807,  0.85076269,  0.88412739,
+        0.85076547,  0.81739598,  0.85076786,  0.88413107,  0.85076949,
+        0.91748914,  0.95083916,  0.98417801,  0.95083906,  0.91748809,
+        0.95083882,  0.98417779,  0.95083863,  0.91748731,  0.95083843,
+        0.98417752,  0.9508382 ,  0.91748674,  0.950838  ,  0.9841771 ,
+        0.95083776,  0.91748646,  0.95083764,  0.98417686,  0.95083771,
+        0.91748702,  0.95083794,  0.98417744,  0.95083859,  0.91748864,
+        0.95083927,  0.98417906,  0.95084046,  0.91749107,  0.95084145,
+        0.98418138,  0.95084291,  0.91749397,  0.95084401,  0.98418384,
+        0.95084538,  0.91749653,  0.95084626,  0.98418563,  0.95084686])
+
+
+        #print w.centroid_values - wc
+
+        #print max(w.centroid_values - wc)
+
+        assert num.allclose(w.centroid_values, wc, rtol=2.0e-3)
+
+    def test_kinematic_operator_quantity(self):
+
+        from anuga import rectangular_cross_domain
+        from anuga import Reflective_boundary
+
+        m1 = 10
+        n1 = 10
+        domain = rectangular_cross_domain(m1,n1)
+
+        #domain.set_flow_algorithm('2_0')
+
+        #
+        domain.set_quantity('elevation', expression='x')
+        domain.set_quantity('friction', 0.03)
+        domain.set_quantity('stage',expression='elevation + 2*(x-0.5)')
+        domain.set_quantity('xmomentum', expression='2*x+3*y')
+        domain.set_quantity('ymomentum', expression='5*x+7*y')
+
+        B = Reflective_boundary(domain)
+        domain.set_boundary( {'left': B, 'right': B, 'top': B, 'bottom': B})
+
+
+        Q = Quantity(domain)
+        Q = 2.0
+        # kill off the wave with viscosity
+        kv = Kinematic_viscosity_operator(domain, diffusivity = Q)
+
+
+        # let's make timestep large so that the final solution will look like
+        #the solution of hte elliptic problem. In this case u -> 1, v -> 2.
+
+
+        for t in domain.evolve(yieldstep = 1.0, finaltime = 10.0):
+            #domain.write_time()
+            #domain.print_operator_timestepping_statistics()
+            pass
+
+#
+        w  = domain.quantities['stage']
+        uh = domain.quantities['xmomentum']
+        vh = domain.quantities['ymomentum']
+
+        #print 'uh'
+        #print uh.centroid_values
+        #print uh.boundary_values
+
+        #print 'w'
+        #print w.centroid_values
+
+        #from pprint import pprint
+        #pprint(w.centroid_values)
+
+
+        wc = num.array([
+        0.71624029,  0.71622927,  0.71621675,  0.71623888,  0.71624236,
+        0.71624536,  0.71625157,  0.71625028,  0.71625679,  0.71626609,
+        0.71630233,  0.71627457,  0.71627721,  0.71628666,  0.71633484,
+        0.71629002,  0.71628494,  0.716295  ,  0.7163438 ,  0.71629656,
+        0.71628493,  0.71629656,  0.71634379,  0.71629497,  0.71627716,
+        0.71628999,  0.71633481,  0.7162866 ,  0.71625666,  0.71627448,
+        0.71630224,  0.71626596,  0.71624212,  0.7162501 ,  0.7162514 ,
+        0.71624512,  0.71624   ,  0.7162386 ,  0.71621644,  0.71622896,
+        0.71619869,  0.71615658,  0.71609423,  0.71619602,  0.71627164,
+        0.71623926,  0.71625039,  0.71633719,  0.71638922,  0.71642539,
+        0.71652642,  0.71649892,  0.71646671,  0.71653525,  0.71670614,
+        0.71661869,  0.71649067,  0.71663318,  0.71682302,  0.71665878,
+        0.71649066,  0.71665876,  0.71682295,  0.71663309,  0.71646665,
+        0.71661859,  0.71670596,  0.71653511,  0.71638911,  0.71649877,
+        0.71652622,  0.71642523,  0.71627151,  0.716337  ,  0.71625001,
+        0.71623888,  0.7161983 ,  0.71619554,  0.71609371,  0.71615611,
+        0.71587901,  0.71555375,  0.71521927,  0.71573946,  0.71615663,
+        0.71586493,  0.7156413 ,  0.71615004,  0.71653474,  0.71632223,
+        0.71618825,  0.7165586 ,  0.7168124 ,  0.71668994,  0.71661036,
+        0.7168446 ,  0.71694587,  0.71689337,  0.7167922 ,  0.71693225,
+        0.71694582,  0.71693224,  0.71679212,  0.71689325,  0.71681216,
+        0.71684437,  0.71661004,  0.71668963,  0.71653449,  0.71655826,
+        0.71618788,  0.71632191,  0.71615622,  0.71614967,  0.71564092,
+        0.71586446,  0.7158785 ,  0.71573897,  0.71521879,  0.71555323,
+        0.71415117,  0.71304803,  0.71200401,  0.71333356,  0.71459491,
+        0.71350761,  0.71272705,  0.7140006 ,  0.71526042,  0.71418365,
+        0.71337479,  0.7146592 ,  0.71582149,  0.71478585,  0.71378284,
+        0.7150456 ,  0.71605221,  0.71509271,  0.71396254,  0.71516103,
+        0.71605211,  0.71516102,  0.71396249,  0.71509256,  0.71582115,
+        0.7150454 ,  0.71378271,  0.71478555,  0.71526005,  0.71465889,
+        0.71337454,  0.71418329,  0.71459453,  0.71400022,  0.71272682,
+        0.71350725,  0.71415077,  0.71333321,  0.71200389,  0.71304774,
+        0.70944126,  0.70705883,  0.70442227,  0.70714215,  0.70999341,
+        0.70722667,  0.70436187,  0.70745337,  0.71044978,  0.70748596,
+        0.70427781,  0.70768146,  0.71082549,  0.70772906,  0.70426793,
+        0.70786303,  0.71099495,  0.70788365,  0.70424722,  0.70791928,
+        0.71099502,  0.70791937,  0.70424774,  0.70788396,  0.71082556,
+        0.70786332,  0.70426849,  0.70772935,  0.71044982,  0.70768178,
+        0.7042786 ,  0.70748637,  0.70999356,  0.70745385,  0.70436311,
+        0.70722738,  0.70944169,  0.70714295,  0.70442389,  0.70705981,
+        0.69895933,  0.69463188,  0.68921358,  0.693824  ,  0.698153  ,
+        0.69349963,  0.68725093,  0.69221842,  0.69728195,  0.69180649,
+        0.68463972,  0.69053046,  0.69673179,  0.69018397,  0.68236173,
+        0.68940762,  0.69650961,  0.68925397,  0.68125059,  0.68902719,
+        0.69651034,  0.68902736,  0.6812516 ,  0.68925556,  0.69673305,
+        0.6894096 ,  0.6823656 ,  0.69018707,  0.69728407,  0.69053386,
+        0.68464522,  0.69181074,  0.69815588,  0.69222279,  0.68725717,
+        0.69350432,  0.69896255,  0.69382873,  0.68922015,  0.69463687,
+        0.68375896,  0.6882601 ,  0.69595562,  0.68766298,  0.68105558,
+        0.68673658,  0.69502847,  0.68542815,  0.67770965,  0.68435344,
+        0.69409778,  0.68310537,  0.67491515,  0.68222458,  0.69337943,
+        0.68140117,  0.67356609,  0.68097711,  0.69301997,  0.68071631,
+        0.67356716,  0.68071666,  0.69302027,  0.68097852,  0.6749196 ,
+        0.68140363,  0.69338045,  0.68222808,  0.6777162 ,  0.68310954,
+        0.69409929,  0.68435822,  0.68106317,  0.68543327,  0.69503026,
+        0.68674199,  0.68376697,  0.68766854,  0.69595754,  0.68826575,
+        0.71760631,  0.75094294,  0.78427898,  0.75094168,  0.71760193,
+        0.75093986,  0.78427453,  0.75093415,  0.71758272,  0.7509278 ,
+        0.78426295,  0.75091754,  0.7175572 ,  0.75090919,  0.78424795,
+        0.75089856,  0.71753518,  0.75089163,  0.78423642,  0.75088684,
+        0.71753524,  0.75088686,  0.78423643,  0.75089171,  0.7175573 ,
+        0.75089864,  0.78424798,  0.75090931,  0.71758285,  0.75091768,
+        0.78426303,  0.75092799,  0.7176021 ,  0.75093438,  0.78427472,
+        0.75094013,  0.71760652,  0.75094199,  0.78427929,  0.75094328,
+        0.81761649,  0.85095268,  0.88428788,  0.85095192,  0.81761311,
+        0.8509508 ,  0.88428574,  0.85094833,  0.81760513,  0.8509458 ,
+        0.88428131,  0.85094197,  0.81759506,  0.85093883,  0.88427596,
+        0.85093514,  0.81758753,  0.85093282,  0.88427212,  0.85093123,
+        0.81758749,  0.8509312 ,  0.88427198,  0.85093269,  0.81759494,
+        0.85093494,  0.8842756 ,  0.85093857,  0.81760502,  0.8509417 ,
+        0.88428088,  0.85094557,  0.81761314,  0.85094816,  0.88428543,
+        0.85095073,  0.81761667,  0.85095193,  0.88428775,  0.85095275,
+        0.91762366,  0.95095836,  0.98429205,  0.95095804,  0.91762217,
+        0.95095754,  0.98429102,  0.95095658,  0.91761918,  0.95095558,
+        0.98428903,  0.95095416,  0.91761561,  0.95095297,  0.98428667,
+        0.95095164,  0.91761304,  0.95095078,  0.98428497,  0.95095015,
+        0.91761286,  0.95095007,  0.98428475,  0.95095045,  0.9176151 ,
+        0.95095115,  0.98428605,  0.95095231,  0.91761853,  0.95095342,
+        0.9842882 ,  0.9509548 ,  0.91762161,  0.95095583,  0.98429026,
+        0.95095688,  0.91762327,  0.95095746,  0.98429146,  0.95095784])
+
+
+        #print max(w.centroid_values- wc)
+        assert num.allclose(w.centroid_values, wc, rtol=0.05)
+
+    def test_kinematic_operator_number(self):
+
+        from anuga import rectangular_cross_domain
+        from anuga import Reflective_boundary
+
+        m1 = 10
+        n1 = 10
+        domain = rectangular_cross_domain(m1,n1)
+
+        #domain.set_flow_algorithm('2_0')
+
+        #
+        domain.set_quantity('elevation', expression='x')
+        domain.set_quantity('friction', 0.03)
+        domain.set_quantity('stage',expression='elevation + 2*(x-0.5)')
+        domain.set_quantity('xmomentum', expression='2*x+3*y')
+        domain.set_quantity('ymomentum', expression='5*x+7*y')
+
+        B = Reflective_boundary(domain)
+        domain.set_boundary( {'left': B, 'right': B, 'top': B, 'bottom': B})
+
+        # kill off the wave with viscosity
+        kv = Kinematic_viscosity_operator(domain, diffusivity=2.0)
+
+
+        # let's make timestep large so that the final solution will look like
+        #the solution of hte elliptic problem. In this case u -> 1, v -> 2.
+
+
+        for t in domain.evolve(yieldstep = 1.0, finaltime = 10.0):
+            #domain.write_time()
+            #domain.print_operator_timestepping_statistics()
+            pass
+
+#
+        w  = domain.quantities['stage']
+        uh = domain.quantities['xmomentum']
+        vh = domain.quantities['ymomentum']
+
+        #print 'uh'
+        #print uh.centroid_values
+        #print uh.boundary_values
+
+        #print 'w'
+        #print w.centroid_values
+
+        #from pprint import pprint
+        #pprint(w.centroid_values)
+
+
+        wc = num.array([
+        0.71624029,  0.71622927,  0.71621675,  0.71623888,  0.71624236,
+        0.71624536,  0.71625157,  0.71625028,  0.71625679,  0.71626609,
+        0.71630233,  0.71627457,  0.71627721,  0.71628666,  0.71633484,
+        0.71629002,  0.71628494,  0.716295  ,  0.7163438 ,  0.71629656,
+        0.71628493,  0.71629656,  0.71634379,  0.71629497,  0.71627716,
+        0.71628999,  0.71633481,  0.7162866 ,  0.71625666,  0.71627448,
+        0.71630224,  0.71626596,  0.71624212,  0.7162501 ,  0.7162514 ,
+        0.71624512,  0.71624   ,  0.7162386 ,  0.71621644,  0.71622896,
+        0.71619869,  0.71615658,  0.71609423,  0.71619602,  0.71627164,
+        0.71623926,  0.71625039,  0.71633719,  0.71638922,  0.71642539,
+        0.71652642,  0.71649892,  0.71646671,  0.71653525,  0.71670614,
+        0.71661869,  0.71649067,  0.71663318,  0.71682302,  0.71665878,
+        0.71649066,  0.71665876,  0.71682295,  0.71663309,  0.71646665,
+        0.71661859,  0.71670596,  0.71653511,  0.71638911,  0.71649877,
+        0.71652622,  0.71642523,  0.71627151,  0.716337  ,  0.71625001,
+        0.71623888,  0.7161983 ,  0.71619554,  0.71609371,  0.71615611,
+        0.71587901,  0.71555375,  0.71521927,  0.71573946,  0.71615663,
+        0.71586493,  0.7156413 ,  0.71615004,  0.71653474,  0.71632223,
+        0.71618825,  0.7165586 ,  0.7168124 ,  0.71668994,  0.71661036,
+        0.7168446 ,  0.71694587,  0.71689337,  0.7167922 ,  0.71693225,
+        0.71694582,  0.71693224,  0.71679212,  0.71689325,  0.71681216,
+        0.71684437,  0.71661004,  0.71668963,  0.71653449,  0.71655826,
+        0.71618788,  0.71632191,  0.71615622,  0.71614967,  0.71564092,
+        0.71586446,  0.7158785 ,  0.71573897,  0.71521879,  0.71555323,
+        0.71415117,  0.71304803,  0.71200401,  0.71333356,  0.71459491,
+        0.71350761,  0.71272705,  0.7140006 ,  0.71526042,  0.71418365,
+        0.71337479,  0.7146592 ,  0.71582149,  0.71478585,  0.71378284,
+        0.7150456 ,  0.71605221,  0.71509271,  0.71396254,  0.71516103,
+        0.71605211,  0.71516102,  0.71396249,  0.71509256,  0.71582115,
+        0.7150454 ,  0.71378271,  0.71478555,  0.71526005,  0.71465889,
+        0.71337454,  0.71418329,  0.71459453,  0.71400022,  0.71272682,
+        0.71350725,  0.71415077,  0.71333321,  0.71200389,  0.71304774,
+        0.70944126,  0.70705883,  0.70442227,  0.70714215,  0.70999341,
+        0.70722667,  0.70436187,  0.70745337,  0.71044978,  0.70748596,
+        0.70427781,  0.70768146,  0.71082549,  0.70772906,  0.70426793,
+        0.70786303,  0.71099495,  0.70788365,  0.70424722,  0.70791928,
+        0.71099502,  0.70791937,  0.70424774,  0.70788396,  0.71082556,
+        0.70786332,  0.70426849,  0.70772935,  0.71044982,  0.70768178,
+        0.7042786 ,  0.70748637,  0.70999356,  0.70745385,  0.70436311,
+        0.70722738,  0.70944169,  0.70714295,  0.70442389,  0.70705981,
+        0.69895933,  0.69463188,  0.68921358,  0.693824  ,  0.698153  ,
+        0.69349963,  0.68725093,  0.69221842,  0.69728195,  0.69180649,
+        0.68463972,  0.69053046,  0.69673179,  0.69018397,  0.68236173,
+        0.68940762,  0.69650961,  0.68925397,  0.68125059,  0.68902719,
+        0.69651034,  0.68902736,  0.6812516 ,  0.68925556,  0.69673305,
+        0.6894096 ,  0.6823656 ,  0.69018707,  0.69728407,  0.69053386,
+        0.68464522,  0.69181074,  0.69815588,  0.69222279,  0.68725717,
+        0.69350432,  0.69896255,  0.69382873,  0.68922015,  0.69463687,
+        0.68375896,  0.6882601 ,  0.69595562,  0.68766298,  0.68105558,
+        0.68673658,  0.69502847,  0.68542815,  0.67770965,  0.68435344,
+        0.69409778,  0.68310537,  0.67491515,  0.68222458,  0.69337943,
+        0.68140117,  0.67356609,  0.68097711,  0.69301997,  0.68071631,
+        0.67356716,  0.68071666,  0.69302027,  0.68097852,  0.6749196 ,
+        0.68140363,  0.69338045,  0.68222808,  0.6777162 ,  0.68310954,
+        0.69409929,  0.68435822,  0.68106317,  0.68543327,  0.69503026,
+        0.68674199,  0.68376697,  0.68766854,  0.69595754,  0.68826575,
+        0.71760631,  0.75094294,  0.78427898,  0.75094168,  0.71760193,
+        0.75093986,  0.78427453,  0.75093415,  0.71758272,  0.7509278 ,
+        0.78426295,  0.75091754,  0.7175572 ,  0.75090919,  0.78424795,
+        0.75089856,  0.71753518,  0.75089163,  0.78423642,  0.75088684,
+        0.71753524,  0.75088686,  0.78423643,  0.75089171,  0.7175573 ,
+        0.75089864,  0.78424798,  0.75090931,  0.71758285,  0.75091768,
+        0.78426303,  0.75092799,  0.7176021 ,  0.75093438,  0.78427472,
+        0.75094013,  0.71760652,  0.75094199,  0.78427929,  0.75094328,
+        0.81761649,  0.85095268,  0.88428788,  0.85095192,  0.81761311,
+        0.8509508 ,  0.88428574,  0.85094833,  0.81760513,  0.8509458 ,
+        0.88428131,  0.85094197,  0.81759506,  0.85093883,  0.88427596,
+        0.85093514,  0.81758753,  0.85093282,  0.88427212,  0.85093123,
+        0.81758749,  0.8509312 ,  0.88427198,  0.85093269,  0.81759494,
+        0.85093494,  0.8842756 ,  0.85093857,  0.81760502,  0.8509417 ,
+        0.88428088,  0.85094557,  0.81761314,  0.85094816,  0.88428543,
+        0.85095073,  0.81761667,  0.85095193,  0.88428775,  0.85095275,
+        0.91762366,  0.95095836,  0.98429205,  0.95095804,  0.91762217,
+        0.95095754,  0.98429102,  0.95095658,  0.91761918,  0.95095558,
+        0.98428903,  0.95095416,  0.91761561,  0.95095297,  0.98428667,
+        0.95095164,  0.91761304,  0.95095078,  0.98428497,  0.95095015,
+        0.91761286,  0.95095007,  0.98428475,  0.95095045,  0.9176151 ,
+        0.95095115,  0.98428605,  0.95095231,  0.91761853,  0.95095342,
+        0.9842882 ,  0.9509548 ,  0.91762161,  0.95095583,  0.98429026,
+        0.95095688,  0.91762327,  0.95095746,  0.98429146,  0.95095784])
+
+
+
+
+        #print w.centroid_values - wc
+
+        #print max(w.centroid_values - wc)
+        assert num.allclose(w.centroid_values, wc, rtol=0.05)
+
+
+
+
+    def test_kinematic_operator_string(self):
+
+        from anuga import rectangular_cross_domain
+        from anuga import Reflective_boundary
+
+        m1 = 10
+        n1 = 10
+        domain = rectangular_cross_domain(m1,n1)
+
+        #domain.set_flow_algorithm('2_0')
+
+        #
+        domain.set_quantity('elevation', expression='x')
+        domain.set_quantity('friction', 0.03)
+        domain.set_quantity('stage',expression='elevation + 2*(x-0.5)')
+        domain.set_quantity('xmomentum', expression='2*x+3*y')
+        domain.set_quantity('ymomentum', expression='5*x+7*y')
+
+        B = Reflective_boundary(domain)
+        domain.set_boundary( {'left': B, 'right': B, 'top': B, 'bottom': B})
+
+        # kill off the wave with viscosity
+        kv = Kinematic_viscosity_operator(domain, diffusivity = 'height')
+
+
+        # let's make timestep large so that the final solution will look like
+        #the solution of hte elliptic problem. In this case u -> 1, v -> 2.
+
+
+        for t in domain.evolve(yieldstep = 1.0, finaltime = 10.0):
+            #domain.write_time()
+            #domain.print_operator_timestepping_statistics()
+            pass
+
+#
+        w  = domain.quantities['stage']
+        uh = domain.quantities['xmomentum']
+        vh = domain.quantities['ymomentum']
+
+        #print 'uh'
+        #print uh.centroid_values
+        #print uh.boundary_values
+
+        #print 'w'
+        #print w.centroid_values
+
+        #from pprint import pprint
+        #pprint(w.centroid_values)
+
+
+        wc = num.array([
+        0.70714365,  0.70714416,  0.70714295,  0.70714222,  0.70714486,
+        0.70714507,  0.70714374,  0.70714601,  0.70714492,  0.70714425,
+        0.70714595,  0.70714437,  0.70714797,  0.70714691,  0.70714697,
+        0.70714845,  0.70714793,  0.70714793,  0.70715033,  0.70714852,
+        0.70715244,  0.70715018,  0.70715176,  0.70715224,  0.70715211,
+        0.70715265,  0.70715351,  0.7071531 ,  0.70715433,  0.70715309,
+        0.70715351,  0.70715472,  0.70715429,  0.70715433,  0.70715487,
+        0.70715523,  0.7071545 ,  0.70715446,  0.70715317,  0.70715564,
+        0.70714142,  0.70714198,  0.70714079,  0.70714299,  0.70714482,
+        0.70714378,  0.70714344,  0.70714377,  0.7071443 ,  0.70714533,
+        0.70714579,  0.70714574,  0.70714906,  0.70714717,  0.70714819,
+        0.70714822,  0.70714976,  0.70714952,  0.70715093,  0.70715077,
+        0.70715217,  0.70715094,  0.70715291,  0.70715188,  0.70715352,
+        0.70715278,  0.707154  ,  0.70715429,  0.70715376,  0.70715309,
+        0.70715446,  0.70715422,  0.70715366,  0.70715453,  0.70715413,
+        0.70715539,  0.70715385,  0.70715412,  0.70715154,  0.70715306,
+        0.70714038,  0.70713905,  0.7071358 ,  0.70713972,  0.70714303,
+        0.7071419 ,  0.70714066,  0.70714219,  0.7071459 ,  0.70714505,
+        0.70714639,  0.70714648,  0.70714833,  0.70714827,  0.70715147,
+        0.70715013,  0.70715194,  0.70715133,  0.70715542,  0.70715345,
+        0.70715296,  0.70715417,  0.70715676,  0.70715521,  0.70715526,
+        0.7071548 ,  0.70715717,  0.70715512,  0.70715381,  0.70715523,
+        0.70715556,  0.70715486,  0.70715482,  0.70715338,  0.70715307,
+        0.70715381,  0.70715132,  0.70715182,  0.70714789,  0.70715086,
+        0.70713443,  0.70713559,  0.70713539,  0.70713615,  0.70714057,
+        0.70713978,  0.70714091,  0.70714102,  0.70714618,  0.70714338,
+        0.70714803,  0.70714858,  0.7071519 ,  0.70715029,  0.70715343,
+        0.70715461,  0.70715589,  0.70715519,  0.7071565 ,  0.70715796,
+        0.70715738,  0.70715845,  0.7071601 ,  0.70715829,  0.70715711,
+        0.70715903,  0.70716011,  0.70715714,  0.7071565 ,  0.70715756,
+        0.70715885,  0.7071556 ,  0.70715386,  0.70715406,  0.70715653,
+        0.70715532,  0.70714813,  0.7071515 ,  0.70715242,  0.70715269,
+        0.70713191,  0.70712961,  0.70712505,  0.70712841,  0.70714097,
+        0.70713808,  0.70713862,  0.7071431 ,  0.70714966,  0.7071463 ,
+        0.70715775,  0.70715666,  0.70715566,  0.7071554 ,  0.7071632 ,
+        0.70716353,  0.70715928,  0.70716244,  0.70716736,  0.70716495,
+        0.70716301,  0.70716635,  0.70717088,  0.70716792,  0.70716369,
+        0.70717007,  0.7071741 ,  0.70716769,  0.70716166,  0.70716991,
+        0.70717294,  0.70716167,  0.70715775,  0.70716057,  0.70715687,
+        0.70715535,  0.70715014,  0.70714766,  0.70714559,  0.70714992,
+        0.7071149 ,  0.70708741,  0.706984  ,  0.70711096,  0.70714367,
+        0.70714831,  0.70713519,  0.7071811 ,  0.70716622,  0.70716603,
+        0.70714155,  0.7071748 ,  0.70716885,  0.70716897,  0.70713548,
+        0.70716966,  0.70716924,  0.70716978,  0.70713561,  0.7071717 ,
+        0.70717389,  0.7071726 ,  0.70713926,  0.70717593,  0.70718002,
+        0.70717761,  0.70714428,  0.70718053,  0.70718062,  0.70718719,
+        0.70715731,  0.70718271,  0.70716238,  0.7071992 ,  0.70715496,
+        0.70716834,  0.70713531,  0.70713099,  0.70700665,  0.7071098 ,
+        0.70634397,  0.70524618,  0.70297607,  0.70514658,  0.70658259,
+        0.70506628,  0.70244401,  0.70497884,  0.70657086,  0.70498266,
+        0.70239779,  0.70496243,  0.7065572 ,  0.7049646 ,  0.70239608,
+        0.70496008,  0.70655538,  0.70496125,  0.70239685,  0.70496177,
+        0.70655883,  0.70496295,  0.70239957,  0.70496624,  0.70656625,
+        0.70496724,  0.70240482,  0.7049756 ,  0.70658803,  0.70497608,
+        0.70241139,  0.70500006,  0.70660425,  0.70499778,  0.70246225,
+        0.70508764,  0.70636798,  0.70516922,  0.70299639,  0.70526838,
+        0.71780931,  0.7506157 ,  0.78399529,  0.75061024,  0.71769206,
+        0.75059929,  0.78398287,  0.75059279,  0.71768281,  0.75059112,
+        0.78397863,  0.75059025,  0.71768261,  0.75058996,  0.78397777,
+        0.75058981,  0.71768268,  0.75058969,  0.78397749,  0.75058967,
+        0.7176832 ,  0.75058972,  0.78397772,  0.75058986,  0.71768421,
+        0.7505901 ,  0.78397859,  0.75059043,  0.71768534,  0.7505909 ,
+        0.78398028,  0.750592  ,  0.71769545,  0.75059388,  0.78398545,
+        0.75060056,  0.71781337,  0.75061163,  0.78399848,  0.75061714,
+        0.81739069,  0.85076296,  0.8841241 ,  0.85076174,  0.81738381,
+        0.85075988,  0.88412183,  0.85075808,  0.81738087,  0.85075718,
+        0.88412031,  0.85075635,  0.81737996,  0.85075599,  0.88411952,
+        0.85075563,  0.81737963,  0.85075548,  0.88411919,  0.8507555 ,
+        0.81738003,  0.85075569,  0.88411972,  0.85075629,  0.81738134,
+        0.85075692,  0.88412133,  0.85075812,  0.81738361,  0.85075914,
+        0.88412387,  0.85076103,  0.81738807,  0.85076269,  0.88412739,
+        0.85076547,  0.81739598,  0.85076786,  0.88413107,  0.85076949,
+        0.91748914,  0.95083916,  0.98417801,  0.95083906,  0.91748809,
+        0.95083882,  0.98417779,  0.95083863,  0.91748731,  0.95083843,
+        0.98417752,  0.9508382 ,  0.91748674,  0.950838  ,  0.9841771 ,
+        0.95083776,  0.91748646,  0.95083764,  0.98417686,  0.95083771,
+        0.91748702,  0.95083794,  0.98417744,  0.95083859,  0.91748864,
+        0.95083927,  0.98417906,  0.95084046,  0.91749107,  0.95084145,
+        0.98418138,  0.95084291,  0.91749397,  0.95084401,  0.98418384,
+        0.95084538,  0.91749653,  0.95084626,  0.98418563,  0.95084686])
+
+
+        #print max(w.centroid_values - wc)
+
+        assert num.allclose(w.centroid_values, wc, rtol=2.0e-3)
+
+
+################################################################################
+
+if __name__ == "__main__":
+    suite = unittest.makeSuite(Test_kinematic_viscosity, 'test')
+    runner = unittest.TextTestRunner()
+    runner.run(suite)
Index: /trunk/anuga_core/source/anuga/operators/test/test_rate_operators.py
===================================================================
--- /trunk/anuga_core/source/anuga/operators/test/test_rate_operators.py	(revision 9445)
+++ /trunk/anuga_core/source/anuga/operators/test/test_rate_operators.py	(revision 9445)
@@ -0,0 +1,888 @@
+"""  Test environmental forcing - rain, wind, etc.
+"""
+import operator
+
+import unittest, os
+import anuga
+import numpy
+from anuga import Domain
+from anuga import Reflective_boundary
+from anuga import rectangular_cross_domain
+from anuga import file_function
+
+from anuga.config import netcdf_mode_r, netcdf_mode_w, netcdf_mode_a
+from anuga.file_conversion.file_conversion import timefile2netcdf
+from anuga.config import time_format
+
+from anuga.fit_interpolate.interpolate import Modeltime_too_early
+from anuga.fit_interpolate.interpolate import Modeltime_too_late
+
+from rate_operators import *
+
+import numpy as num
+import warnings
+import time
+import os
+
+
+warnings.simplefilter("ignore")
+
+
+class Test_rate_operators(unittest.TestCase):
+    def setUp(self):
+        pass
+
+    def tearDown(self):
+        try:
+            os.remove('test_file_function.txt')
+        except:
+            pass
+
+        try:
+            os.remove('test_file_function.tms')
+        except:
+            pass
+
+
+    def test_rate_operator_simple(self):
+        from anuga.config import rho_a, rho_w, eta_w
+        from math import pi, cos, sin
+
+        a = [0.0, 0.0]
+        b = [0.0, 2.0]
+        c = [2.0, 0.0]
+        d = [0.0, 4.0]
+        e = [2.0, 2.0]
+        f = [4.0, 0.0]
+
+        points = [a, b, c, d, e, f]
+        #             bac,     bce,     ecf,     dbe
+        vertices = [[1,0,2], [1,2,4], [4,2,5], [3,1,4]]
+
+        domain = Domain(points, vertices)
+
+        #Flat surface with 1m of water
+        domain.set_quantity('elevation', 0)
+        domain.set_quantity('stage', 1.0)
+        domain.set_quantity('friction', 0)
+
+        Br = Reflective_boundary(domain)
+        domain.set_boundary({'exterior': Br})
+
+
+#        print domain.quantities['stage'].centroid_values
+#        print domain.quantities['xmomentum'].centroid_values
+#        print domain.quantities['ymomentum'].centroid_values
+
+        # Apply operator to these triangles
+        indices = [0,1,3]
+
+        rate = 1.0
+        factor = 10.0
+        default_rate= 0.0
+
+        operator = Rate_operator(domain, rate=rate, factor=factor, \
+                      indices=indices, default_rate = default_rate)
+        
+        # Apply Operator
+        domain.timestep = 2.0
+        operator()
+
+        stage_ex = [ 21.,  21.,   1.,  21.]
+
+#        print domain.quantities['stage'].centroid_values
+#        print domain.quantities['xmomentum'].centroid_values
+#        print domain.quantities['ymomentum'].centroid_values
+
+        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
+        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
+        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
+        assert num.allclose(domain.fractional_step_volume_integral, factor*domain.timestep*(rate*domain.areas[indices]).sum())
+
+ 
+    def test_rate_operator_negative_rate(self):
+        from anuga.config import rho_a, rho_w, eta_w
+        from math import pi, cos, sin
+
+        a = [0.0, 0.0]
+        b = [0.0, 2.0]
+        c = [2.0, 0.0]
+        d = [0.0, 4.0]
+        e = [2.0, 2.0]
+        f = [4.0, 0.0]
+
+        points = [a, b, c, d, e, f]
+        #             bac,     bce,     ecf,     dbe
+        vertices = [[1,0,2], [1,2,4], [4,2,5], [3,1,4]]
+
+        domain = Domain(points, vertices)
+
+        #Flat surface with 1m of water
+        domain.set_quantity('elevation', 0)
+        domain.set_quantity('stage', 1.0)
+        domain.set_quantity('friction', 0)
+
+        Br = Reflective_boundary(domain)
+        domain.set_boundary({'exterior': Br})
+
+#        print domain.quantities['elevation'].centroid_values
+#        print domain.quantities['stage'].centroid_values
+#        print domain.quantities['xmomentum'].centroid_values
+#        print domain.quantities['ymomentum'].centroid_values
+
+        # Apply operator to these triangles
+        indices = [0,1,3]
+
+
+
+        #Catchment_Rain_Polygon = read_polygon(join('CatchmentBdy.csv'))
+        #rainfall = file_function(join('1y120m.tms'), quantities=['rainfall'])
+        rate = -1.0
+        factor = 10.0
+        default_rate= 0.0
+
+        operator = Rate_operator(domain, rate=rate, factor=factor, \
+                      indices=indices, default_rate = default_rate)
+
+
+        # Apply Operator
+        domain.timestep = 2.0
+        operator()
+
+        stage_ex = [ 0.,  0.,   1.,  0.]
+        step_integral = -6.0
+
+        #print domain.quantities['elevation'].centroid_values
+        #print domain.quantities['stage'].centroid_values
+        #print domain.quantities['xmomentum'].centroid_values
+        #print domain.quantities['ymomentum'].centroid_values
+        #print domain.fractional_step_volume_integral
+        #print factor*domain.timestep*(rate*domain.areas[indices]).sum()
+        
+        #increment = factor*domain.timestep*rate*domain.areas
+        
+        
+
+        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
+        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
+        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
+        assert num.allclose(domain.fractional_step_volume_integral, step_integral)
+
+    def test_rate_operator_negative_rate_full(self):
+        from anuga.config import rho_a, rho_w, eta_w
+        from math import pi, cos, sin
+
+        a = [0.0, 0.0]
+        b = [0.0, 2.0]
+        c = [2.0, 0.0]
+        d = [0.0, 4.0]
+        e = [2.0, 2.0]
+        f = [4.0, 0.0]
+
+        points = [a, b, c, d, e, f]
+        #             bac,     bce,     ecf,     dbe
+        vertices = [[1,0,2], [1,2,4], [4,2,5], [3,1,4]]
+
+        domain = Domain(points, vertices)
+
+        #Flat surface with 1m of water
+        domain.set_quantity('elevation', 0)
+        domain.set_quantity('stage', 10.0)
+        domain.set_quantity('friction', 0)
+
+        Br = Reflective_boundary(domain)
+        domain.set_boundary({'exterior': Br})
+
+#        print domain.quantities['elevation'].centroid_values
+#        print domain.quantities['stage'].centroid_values
+#        print domain.quantities['xmomentum'].centroid_values
+#        print domain.quantities['ymomentum'].centroid_values
+
+        # Apply operator to these triangles
+        indices = [0,1,3]
+
+
+
+        #Catchment_Rain_Polygon = read_polygon(join('CatchmentBdy.csv'))
+        #rainfall = file_function(join('1y120m.tms'), quantities=['rainfall'])
+        rate = -1.0
+        factor = 10.0
+        default_rate= 0.0
+
+        operator = Rate_operator(domain, rate=rate, factor=factor, \
+                      indices=None, default_rate = default_rate)
+
+
+        # Apply Operator
+        domain.timestep = 2.0
+        operator()
+
+        stage_ex = [ 0.,  0.,   0.,  0.]
+        step_integral = -80.0
+
+        #print domain.quantities['elevation'].centroid_values
+        #print domain.quantities['stage'].centroid_values
+        #print domain.quantities['xmomentum'].centroid_values
+        #print domain.quantities['ymomentum'].centroid_values
+        #print domain.fractional_step_volume_integral
+
+
+        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
+        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
+        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
+        assert num.allclose(domain.fractional_step_volume_integral, step_integral)
+        
+    def test_rate_operator_rate_from_file(self):
+        from anuga.config import rho_a, rho_w, eta_w
+        from math import pi, cos, sin
+
+        a = [0.0, 0.0]
+        b = [0.0, 2.0]
+        c = [2.0, 0.0]
+        d = [0.0, 4.0]
+        e = [2.0, 2.0]
+        f = [4.0, 0.0]
+
+        points = [a, b, c, d, e, f]
+        #             bac,     bce,     ecf,     dbe
+        vertices = [[1,0,2], [1,2,4], [4,2,5], [3,1,4]]
+
+
+        #---------------------------------
+        #Typical ASCII file
+        #---------------------------------
+        finaltime = 1200
+        filename = 'test_file_function'
+        fid = open(filename + '.txt', 'w')
+        start = time.mktime(time.strptime('2000', '%Y'))
+        dt = 60  #One minute intervals
+        t = 0.0
+        while t <= finaltime:
+            t_string = time.strftime(time_format, time.gmtime(t+start))
+            fid.write('%s, %f %f %f\n' %(t_string, 2*t, t**2, sin(t*pi/600)))
+            t += dt
+
+        fid.close()
+
+        #Convert ASCII file to NetCDF (Which is what we really like!)
+        timefile2netcdf(filename+'.txt')
+
+
+        #Create file function from time series
+        F = file_function(filename + '.tms',
+                          quantities = ['Attribute0',
+                                        'Attribute1',
+                                        'Attribute2'])
+
+
+        #Now try interpolation
+        for i in range(20):
+            t = i*10
+            q = F(t)
+
+            #Exact linear intpolation
+            assert num.allclose(q[0], 2*t)
+            if i%6 == 0:
+                assert num.allclose(q[1], t**2)
+                assert num.allclose(q[2], sin(t*pi/600))
+
+        #Check non-exact
+
+        t = 90 #Halfway between 60 and 120
+        q = F(t)
+        assert num.allclose( (120**2 + 60**2)/2, q[1] )
+        assert num.allclose( (sin(120*pi/600) + sin(60*pi/600))/2, q[2] )
+
+
+        t = 100 #Two thirds of the way between between 60 and 120
+        q = F(t)
+        assert num.allclose( 2*120**2/3 + 60**2/3, q[1] )
+        assert num.allclose( 2*sin(120*pi/600)/3 + sin(60*pi/600)/3, q[2] )
+
+        #os.remove(filename + '.txt')
+        #os.remove(filename + '.tms')
+
+
+        domain = Domain(points, vertices)
+
+        #Flat surface with 1m of water
+        domain.set_quantity('elevation', 0)
+        domain.set_quantity('stage', 1.0)
+        domain.set_quantity('friction', 0)
+
+        Br = Reflective_boundary(domain)
+        domain.set_boundary({'exterior': Br})
+
+#        print domain.quantities['elevation'].centroid_values
+#        print domain.quantities['stage'].centroid_values
+#        print domain.quantities['xmomentum'].centroid_values
+#        print domain.quantities['ymomentum'].centroid_values
+
+        # Apply operator to these triangles
+        indices = [0,1,3]
+
+
+        rate = file_function('test_file_function.tms', quantities=['Attribute1'])
+
+        factor = 1000.0
+        default_rate= 17.7
+
+        operator = Rate_operator(domain, rate=rate, factor=factor, \
+                      indices=indices, default_rate = default_rate)
+
+
+        # Apply Operator
+        domain.set_starttime(360.0)
+        domain.timestep = 1.0
+
+        operator()
+
+
+        d = domain.get_time()**2 * factor + 1.0
+        stage_ex0 = [ d,  d,   1.,  d]
+
+#        print d, domain.get_time(), F(360.0)
+
+#        print domain.quantities['elevation'].centroid_values
+#        print domain.quantities['stage'].centroid_values
+#        print domain.quantities['xmomentum'].centroid_values
+#        print domain.quantities['ymomentum'].centroid_values
+
+        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex0)
+        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
+        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
+        assert num.allclose(domain.fractional_step_volume_integral, ((d-1.)*domain.areas[indices]).sum())
+
+
+        domain.set_starttime(-10.0)
+        domain.timestep = 1.0
+
+        try:
+            operator()
+        except:
+            pass
+        else:
+            raise Exception('Should have raised an exception, time too early')
+
+
+        domain.set_starttime(1300.0)
+        domain.timestep = 1.0
+
+        operator()
+
+        d = default_rate*factor + d
+        stage_ex1 = [ d,  d,   1.,  d]
+
+#        print domain.quantities['elevation'].centroid_values
+#        print domain.quantities['stage'].centroid_values
+#        print domain.quantities['xmomentum'].centroid_values
+#        print domain.quantities['ymomentum'].centroid_values
+
+        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex1)
+        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
+        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
+        assert num.allclose(domain.fractional_step_volume_integral, ((d-1.)*domain.areas[indices]).sum())
+
+
+    def test_rate_operator_functions_rate_default_rate(self):
+        from anuga.config import rho_a, rho_w, eta_w
+        from math import pi, cos, sin
+
+        a = [0.0, 0.0]
+        b = [0.0, 2.0]
+        c = [2.0, 0.0]
+        d = [0.0, 4.0]
+        e = [2.0, 2.0]
+        f = [4.0, 0.0]
+
+        points = [a, b, c, d, e, f]
+        #             bac,     bce,     ecf,     dbe
+        vertices = [[1,0,2], [1,2,4], [4,2,5], [3,1,4]]
+
+        domain = Domain(points, vertices)
+
+        #Flat surface with 1m of water
+        domain.set_quantity('elevation', 0)
+        domain.set_quantity('stage', 1.0)
+        domain.set_quantity('friction', 0)
+
+        Br = Reflective_boundary(domain)
+        domain.set_boundary({'exterior': Br})
+
+        verbose = False
+        
+        if verbose:
+            print domain.quantities['elevation'].centroid_values
+            print domain.quantities['stage'].centroid_values
+            print domain.quantities['xmomentum'].centroid_values
+            print domain.quantities['ymomentum'].centroid_values
+
+        # Apply operator to these triangles
+        indices = [0,1,3]
+        factor = 10.0
+
+
+        def main_rate(t):
+            if t > 20:
+                msg = 'Model time exceeded.'
+                raise Modeltime_too_late, msg
+            else:
+                return 3.0 * t + 7.0
+
+        default_rate = lambda t: 3*t + 7
+
+
+        operator = Rate_operator(domain, rate=main_rate, factor=factor, \
+                      indices=indices, default_rate = default_rate)
+
+
+        # Apply Operator
+        domain.timestep = 2.0
+        operator()
+
+        t = operator.get_time()
+        d = operator.get_timestep()*main_rate(t)*factor + 1
+        stage_ex = [ d,  d,   1.,  d]
+
+        if verbose:
+            print domain.quantities['elevation'].centroid_values
+            print domain.quantities['stage'].centroid_values
+            print domain.quantities['xmomentum'].centroid_values
+            print domain.quantities['ymomentum'].centroid_values
+
+        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
+        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
+        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
+        assert num.allclose(domain.fractional_step_volume_integral, ((d-1.)*domain.areas[indices]).sum())
+
+        domain.set_starttime(30.0)
+        domain.timestep = 1.0
+        operator()
+
+        t = operator.get_time()
+        d = operator.get_timestep()*default_rate(t)*factor + d
+        stage_ex = [ d,  d,   1.,  d]
+
+        if verbose:
+            print domain.quantities['elevation'].centroid_values
+            print domain.quantities['stage'].centroid_values
+            print domain.quantities['xmomentum'].centroid_values
+            print domain.quantities['ymomentum'].centroid_values
+
+        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
+        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
+        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
+
+
+    def test_rate_operator_functions_spatial(self):
+        from anuga.config import rho_a, rho_w, eta_w
+        from math import pi, cos, sin
+
+        a = [0.0, 0.0]
+        b = [0.0, 2.0]
+        c = [2.0, 0.0]
+        d = [0.0, 4.0]
+        e = [2.0, 2.0]
+        f = [4.0, 0.0]
+
+        points = [a, b, c, d, e, f]
+        #             bac,     bce,     ecf,     dbe
+        vertices = [[1,0,2], [1,2,4], [4,2,5], [3,1,4]]
+
+        domain = Domain(points, vertices)
+
+
+        area = numpy.sum(domain.areas)
+
+        #Flat surface with 1m of water
+        domain.set_quantity('elevation', 0.0)
+        domain.set_quantity('stage', 1.0)
+        domain.set_quantity('friction', 0.0)
+
+        Br = Reflective_boundary(domain)
+        domain.set_boundary({'exterior': Br})
+
+        verbose = False
+
+        if verbose:
+            print domain.quantities['elevation'].centroid_values
+            print domain.quantities['stage'].centroid_values
+            print domain.quantities['xmomentum'].centroid_values
+            print domain.quantities['ymomentum'].centroid_values
+
+        # Apply operator to these triangles
+        factor = 10.0
+
+
+        def main_spatial_rate(x,y,t):
+            # x and y should be an n by 1 array
+            return x + y
+
+        default_rate = 0.0
+
+
+        operator = Rate_operator(domain, rate=main_spatial_rate, factor=factor, \
+                      default_rate = default_rate)
+
+
+        # Apply Operator
+        domain.timestep = 2.0
+        operator()
+
+
+        t = operator.get_time()
+        Q = operator.get_Q()
+        x = operator.coord_c[:,0]
+        y = operator.coord_c[:,1]
+        rate = main_spatial_rate(x,y,t)*factor
+        Q_ex = num.sum(domain.areas*rate)
+        d = operator.get_timestep()*rate + 1
+
+        #print "d"
+        #print d
+        #print area, Q, Q_ex
+        stage_ex = num.array([ 1.0,  1.0,   1.0,  1.0])
+        stage_ex[:] = d
+
+        if verbose:
+            print domain.quantities['elevation'].centroid_values
+            print domain.quantities['stage'].centroid_values
+            print domain.quantities['xmomentum'].centroid_values
+            print domain.quantities['ymomentum'].centroid_values
+
+        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
+        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
+        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
+        assert num.allclose(Q_ex, Q)
+
+    def test_rate_operator_functions_spatial_with_ghost(self):
+        from anuga.config import rho_a, rho_w, eta_w
+        from math import pi, cos, sin
+
+        a = [0.0, 0.0]
+        b = [0.0, 2.0]
+        c = [2.0, 0.0]
+        d = [0.0, 4.0]
+        e = [2.0, 2.0]
+        f = [4.0, 0.0]
+
+        points = [a, b, c, d, e, f]
+        #             bac,     bce,     ecf,     dbe
+        vertices = [[1,0,2], [1,2,4], [4,2,5], [3,1,4]]
+
+        domain = Domain(points, vertices)
+
+
+        area = numpy.sum(domain.areas)
+
+        #Flat surface with 1m of water
+        domain.set_quantity('elevation', 0.0)
+        domain.set_quantity('stage', 1.0)
+        domain.set_quantity('friction', 0.0)
+
+        Br = Reflective_boundary(domain)
+        domain.set_boundary({'exterior': Br})
+
+        verbose = False
+
+        if verbose:
+            print domain.quantities['elevation'].centroid_values
+            print domain.quantities['stage'].centroid_values
+            print domain.quantities['xmomentum'].centroid_values
+            print domain.quantities['ymomentum'].centroid_values
+
+        # Apply operator to these triangles
+        factor = 10.0
+
+
+        def main_spatial_rate(x,y,t):
+            # x and y should be an n by 1 array
+            return x + y
+
+        default_rate = 0.0
+
+        # kludge to make a ghost cell
+        domain.tri_full_flag[1] = 0
+
+        operator = Rate_operator(domain, rate=main_spatial_rate, factor=factor, \
+                      default_rate = default_rate)
+
+  
+        # Apply Operator
+        domain.timestep = 2.0
+        operator()
+
+
+        t = operator.get_time()
+        Q_all = operator.get_Q(full_only=False)
+        Q_full = operator.get_Q()
+        x = operator.coord_c[:,0]
+        y = operator.coord_c[:,1]
+        rate = main_spatial_rate(x,y,t)*factor
+        Q_ex_all = num.sum(domain.areas*rate)
+        Q_ex_full = num.sum(num.where(domain.tri_full_flag==1,domain.areas*rate,0.0))
+        d = operator.get_timestep()*rate + 1
+
+        #print "d"
+        #print d
+        #print Q_ex_full, Q_ex_all
+        stage_ex = num.array([ 1.0,  1.0,   1.0,  1.0])
+        stage_ex[:] = d
+
+        if verbose:
+            print domain.quantities['elevation'].centroid_values
+            print domain.quantities['stage'].centroid_values
+            print domain.quantities['xmomentum'].centroid_values
+            print domain.quantities['ymomentum'].centroid_values
+
+        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
+        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
+        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
+        assert num.allclose(Q_ex_all, Q_all)
+        assert num.allclose(Q_ex_full, Q_full)
+        assert num.allclose(domain.fractional_step_volume_integral, ((d-1.)*domain.areas*domain.tri_full_flag).sum())
+
+    def test_rate_operator_functions_spatial_indices(self):
+        from anuga.config import rho_a, rho_w, eta_w
+        from math import pi, cos, sin
+
+        a = [0.0, 0.0]
+        b = [0.0, 2.0]
+        c = [2.0, 0.0]
+        d = [0.0, 4.0]
+        e = [2.0, 2.0]
+        f = [4.0, 0.0]
+
+        points = [a, b, c, d, e, f]
+        #             bac,     bce,     ecf,     dbe
+        vertices = [[1,0,2], [1,2,4], [4,2,5], [3,1,4]]
+
+        domain = Domain(points, vertices)
+
+        #Flat surface with 1m of water
+        domain.set_quantity('elevation', 0.0)
+        domain.set_quantity('stage', 1.0)
+        domain.set_quantity('friction', 0.0)
+
+        Br = Reflective_boundary(domain)
+        domain.set_boundary({'exterior': Br})
+
+        verbose = False
+
+        if verbose:
+            print domain.quantities['elevation'].centroid_values
+            print domain.quantities['stage'].centroid_values
+            print domain.quantities['xmomentum'].centroid_values
+            print domain.quantities['ymomentum'].centroid_values
+
+        # Apply operator to these triangles
+        indices = [0,1,3]
+        factor = 10.0
+
+
+        def main_spatial_rate(x,y,t):
+            # x and y should be an n by 1 array
+            return x + y
+
+        default_rate = 0.0
+
+
+        operator = Rate_operator(domain, rate=main_spatial_rate, factor=factor, \
+                      indices=indices, default_rate = default_rate)
+
+
+        # Apply Operator
+        domain.timestep = 2.0
+        operator()
+
+        t = operator.get_time()
+        Q = operator.get_Q()
+        x = operator.coord_c[indices,0]
+        y = operator.coord_c[indices,1]
+        rate = main_spatial_rate(x,y,t)*factor
+        Q_ex = num.sum(domain.areas[indices]*rate)
+        d = operator.get_timestep()*rate + 1
+
+
+        #print "d"
+        #print d
+        stage_ex = num.array([ 1.0,  1.0,   1.0,  1.0])
+        stage_ex[indices] = d
+
+        if verbose:
+            print domain.quantities['elevation'].centroid_values
+            print domain.quantities['stage'].centroid_values
+            print domain.quantities['xmomentum'].centroid_values
+            print domain.quantities['ymomentum'].centroid_values
+
+        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
+        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
+        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
+        assert num.allclose(Q_ex, Q)
+        assert num.allclose(domain.fractional_step_volume_integral, ((d-1.)*domain.areas[indices]).sum())
+
+
+    def test_rate_operator_rate_quantity(self):
+        from anuga.config import rho_a, rho_w, eta_w
+        from math import pi, cos, sin
+
+        a = [0.0, 0.0]
+        b = [0.0, 2.0]
+        c = [2.0, 0.0]
+        d = [0.0, 4.0]
+        e = [2.0, 2.0]
+        f = [4.0, 0.0]
+
+        points = [a, b, c, d, e, f]
+        #             bac,     bce,     ecf,     dbe
+        vertices = [[1,0,2], [1,2,4], [4,2,5], [3,1,4]]
+
+        domain = Domain(points, vertices)
+
+        #Flat surface with 1m of water
+        domain.set_quantity('elevation', 0.0)
+        domain.set_quantity('stage', 1.0)
+        domain.set_quantity('friction', 0.0)
+
+        Br = Reflective_boundary(domain)
+        domain.set_boundary({'exterior': Br})
+
+        verbose = False
+
+        if verbose:
+            print domain.quantities['elevation'].centroid_values
+            print domain.quantities['stage'].centroid_values
+            print domain.quantities['xmomentum'].centroid_values
+            print domain.quantities['ymomentum'].centroid_values
+
+        # Apply operator to these triangles
+        indices = [0,1,3]
+        factor = 10.0
+
+
+        from anuga import Quantity
+        rate_Q = Quantity(domain)
+        rate_Q.set_values(1.0)
+
+        operator = Rate_operator(domain, rate=rate_Q, factor=factor, \
+                                 indices=indices)
+
+
+        # Apply Operator
+        domain.timestep = 2.0
+        operator()
+        rate = rate_Q.centroid_values[indices]
+        t = operator.get_time()
+        Q = operator.get_Q()
+
+        rate = rate*factor
+        Q_ex = num.sum(domain.areas[indices]*rate)
+        d = operator.get_timestep()*rate + 1
+
+
+        #print "d"
+        #print d
+        #print Q_ex
+        #print Q
+        stage_ex = num.array([ 1.0,  1.0,   1.0,  1.0])
+        stage_ex[indices] = d
+        
+        verbose = False
+        
+        if verbose:
+            print domain.quantities['elevation'].centroid_values
+            print domain.quantities['stage'].centroid_values
+            print domain.quantities['xmomentum'].centroid_values
+            print domain.quantities['ymomentum'].centroid_values
+
+        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
+        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
+        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
+        assert num.allclose(Q_ex, Q)
+        assert num.allclose(domain.fractional_step_volume_integral, ((d-1.)*domain.areas[indices]).sum())
+
+
+    def test_rate_operator_functions_empty_indices(self):
+        from anuga.config import rho_a, rho_w, eta_w
+        from math import pi, cos, sin
+
+        a = [0.0, 0.0]
+        b = [0.0, 2.0]
+        c = [2.0, 0.0]
+        d = [0.0, 4.0]
+        e = [2.0, 2.0]
+        f = [4.0, 0.0]
+
+        points = [a, b, c, d, e, f]
+        #             bac,     bce,     ecf,     dbe
+        vertices = [[1,0,2], [1,2,4], [4,2,5], [3,1,4]]
+
+        domain = Domain(points, vertices)
+
+        #Flat surface with 1m of water
+        domain.set_quantity('elevation', 0.0)
+        domain.set_quantity('stage', 1.0)
+        domain.set_quantity('friction', 0.0)
+
+        Br = Reflective_boundary(domain)
+        domain.set_boundary({'exterior': Br})
+
+        verbose = False
+
+        if verbose:
+            print domain.quantities['elevation'].centroid_values
+            print domain.quantities['stage'].centroid_values
+            print domain.quantities['xmomentum'].centroid_values
+            print domain.quantities['ymomentum'].centroid_values
+
+        # Apply operator to these triangles
+        indices = []
+        factor = 10.0
+
+
+        def main_spatial_rate(x,y,t):
+            # x and y should be an n by 1 array
+            return x + y
+
+        default_rate = 0.0
+
+        domain.tri_full_flag[0] = 0
+        operator = Rate_operator(domain, rate=main_spatial_rate, factor=factor, \
+                      indices=indices, default_rate = default_rate)
+
+
+        # Apply Operator
+        domain.timestep = 2.0
+        operator()
+
+        t = operator.get_time()
+        Q = operator.get_Q()
+        x = operator.coord_c[indices,0]
+        y = operator.coord_c[indices,1]
+        rate = main_spatial_rate(x,y,t)*factor
+        Q_ex = num.sum(domain.areas[indices]*rate)
+        d = operator.get_timestep()*rate + 1
+
+        #print Q_ex, Q
+        #print indices
+        #print "d"
+        #print d
+        stage_ex = num.array([ 1.0,  1.0,   1.0,  1.0])
+        stage_ex[indices] = d
+
+        if verbose:
+            print domain.quantities['elevation'].centroid_values
+            print domain.quantities['stage'].centroid_values
+            print domain.quantities['xmomentum'].centroid_values
+            print domain.quantities['ymomentum'].centroid_values
+
+        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
+        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
+        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
+        assert num.allclose(Q_ex, Q)
+        assert num.allclose(domain.fractional_step_volume_integral, ((d-1.)*domain.areas[indices]).sum())
+
+if __name__ == "__main__":
+    suite = unittest.makeSuite(Test_rate_operators, 'test')
+    runner = unittest.TextTestRunner(verbosity=1)
+    runner.run(suite)
Index: /trunk/anuga_core/source/anuga/operators/test/test_set_elevation_operator.py
===================================================================
--- /trunk/anuga_core/source/anuga/operators/test/test_set_elevation_operator.py	(revision 9445)
+++ /trunk/anuga_core/source/anuga/operators/test/test_set_elevation_operator.py	(revision 9445)
@@ -0,0 +1,1034 @@
+"""  Test set operators - stage elevation erosion.
+"""
+
+import unittest, os
+import anuga
+from anuga import Domain
+from anuga import Reflective_boundary
+from anuga import rectangular_cross_domain
+from anuga import file_function
+
+from anuga.config import netcdf_mode_r, netcdf_mode_w, netcdf_mode_a
+from anuga.file_conversion.file_conversion import timefile2netcdf
+from anuga.config import time_format
+
+from set_elevation_operator import *
+
+import numpy as num
+import warnings
+import time
+
+
+
+class Test_set_elevation_operator(unittest.TestCase):
+    def setUp(self):
+        pass
+
+    def tearDown(self):
+        pass
+
+
+    def test_set_elevation_operator_simple(self):
+        from anuga.config import rho_a, rho_w, eta_w
+        from math import pi, cos, sin
+
+        a = [0.0, 0.0]
+        b = [0.0, 2.0]
+        c = [2.0, 0.0]
+        d = [0.0, 4.0]
+        e = [2.0, 2.0]
+        f = [4.0, 0.0]
+
+        points = [a, b, c, d, e, f]
+        #             bac,     bce,     ecf,     dbe
+        vertices = [[1,0,2], [1,2,4], [4,2,5], [3,1,4]]
+
+        domain = Domain(points, vertices)
+
+        #Flat surface with 1m of water
+        domain.set_quantity('elevation', 0)
+        domain.set_quantity('stage', 1.0)
+        domain.set_quantity('friction', 0)
+
+        stage_c = domain.quantities['stage'].centroid_values
+        elev_c = domain.quantities['elevation'].centroid_values
+
+        height_c = stage_c - elev_c
+
+        integral0 = num.sum(height_c)
+
+        Br = Reflective_boundary(domain)
+        domain.set_boundary({'exterior': Br})
+
+
+#        print domain.quantities['stage'].centroid_values
+#        print domain.quantities['xmomentum'].centroid_values
+#        print domain.quantities['ymomentum'].centroid_values
+
+        # Apply operator to these triangles
+        indices = [0,1,3]
+
+        elev = 3.0
+
+
+        operator = Set_elevation_operator(domain, elevation=elev, indices=indices)
+        
+        # Apply Operator
+        domain.timestep = 2.0
+        operator()
+
+
+        height_c = stage_c - elev_c
+
+        integral1 = num.sum(height_c)
+
+        assert integral0 == integral1
+
+        stage_ex = [ 3.66666667,  3.33333333,  2.33333333,  3.66666667]
+
+        elev_ex = [ 2.66666667,  2.33333333,  1.33333333,  2.66666667]
+        
+
+#        print domain.quantities['elevation'].centroid_values
+#        print domain.quantities['stage'].centroid_values
+#        print domain.quantities['xmomentum'].centroid_values
+#        print domain.quantities['ymomentum'].centroid_values
+
+        assert num.allclose(domain.quantities['elevation'].centroid_values, elev_ex)
+        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
+        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
+        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
+
+ 
+    def test_set_elevation_operator_negative(self):
+        from anuga.config import rho_a, rho_w, eta_w
+        from math import pi, cos, sin
+
+        a = [0.0, 0.0]
+        b = [0.0, 2.0]
+        c = [2.0, 0.0]
+        d = [0.0, 4.0]
+        e = [2.0, 2.0]
+        f = [4.0, 0.0]
+
+        points = [a, b, c, d, e, f]
+        #             bac,     bce,     ecf,     dbe
+        vertices = [[1,0,2], [1,2,4], [4,2,5], [3,1,4]]
+
+        domain = Domain(points, vertices)
+
+        #Flat surface with 1m of water
+        domain.set_quantity('elevation', lambda x,y : -2*x)
+        domain.set_quantity('stage', 1.0)
+        domain.set_quantity('friction', 0)
+
+
+        stage_c = domain.quantities['stage'].centroid_values
+        elev_c = domain.quantities['elevation'].centroid_values
+
+        height_c = stage_c - elev_c
+
+        integral0 = num.sum(height_c)
+
+
+        Br = Reflective_boundary(domain)
+        domain.set_boundary({'exterior': Br})
+
+#        print domain.quantities['elevation'].centroid_values
+#        print domain.quantities['stage'].centroid_values
+#        print domain.quantities['xmomentum'].centroid_values
+#        print domain.quantities['ymomentum'].centroid_values
+
+        # Apply operator to these triangles
+        indices = [0,1,3]
+
+
+
+        #Catchment_Rain_Polygon = read_polygon(join('CatchmentBdy.csv'))
+        #rainfall = file_function(join('1y120m.tms'), quantities=['rainfall'])
+        elev = -5.0
+
+
+        operator = Set_elevation_operator(domain, elevation=elev, indices=indices)
+
+
+        # Apply Operator
+        domain.timestep = 2.0
+        operator()
+        
+        height_c = stage_c - elev_c
+        integral1 = num.sum(height_c)
+        assert integral0 == integral1
+
+        elev_ex  = [-4.88888889, -4.77777778, -5.77777778, -4.88888889]
+        stage_ex = [-2.55555556, -1.11111111,  0.55555556, -2.55555556]
+
+
+#        print domain.quantities['elevation'].centroid_values
+#        print domain.quantities['stage'].centroid_values
+#        print domain.quantities['xmomentum'].centroid_values
+#        print domain.quantities['ymomentum'].centroid_values
+
+        assert num.allclose(domain.quantities['elevation'].centroid_values, elev_ex)
+        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
+        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
+        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
+
+
+    def test_set_elevation_operator_small_function(self):
+        from anuga.config import rho_a, rho_w, eta_w
+        from math import pi, cos, sin
+
+        a = [0.0, 0.0]
+        b = [0.0, 2.0]
+        c = [2.0, 0.0]
+        d = [0.0, 4.0]
+        e = [2.0, 2.0]
+        f = [4.0, 0.0]
+
+
+
+
+
+        points = [a, b, c, d, e, f]
+        #             bac,     bce,     ecf,     dbe
+        vertices = [[1,0,2], [1,2,4], [4,2,5], [3,1,4]]
+
+        domain = Domain(points, vertices)
+
+        #Flat surface with 1m of water
+        domain.set_quantity('elevation', 0.0)
+        domain.set_quantity('stage', 1.0)
+        domain.set_quantity('friction', 0)
+
+        Br = Reflective_boundary(domain)
+        domain.set_boundary({'exterior': Br})
+
+
+#        print domain.quantities['stage'].centroid_values
+#        print domain.quantities['xmomentum'].centroid_values
+#        print domain.quantities['ymomentum'].centroid_values
+
+        # Apply operator to these triangles
+        indices = [0,1,3]
+
+
+        def elev(t):
+            if t < 10.0:
+                return 5.0
+            else:
+                return 7.0
+
+        operator = Set_elevation_operator(domain, elevation=elev, indices=indices)
+
+        # Apply Operator at time t=1.0
+        domain.set_time(1.0)
+        operator()
+
+
+        elev_ex  = [ 4.44444444,  3.88888889, 2.22222222,  4.44444444]
+        stage_ex = [ 5.44444444,  4.88888889,  3.22222222,  5.44444444]
+
+#        print domain.quantities['elevation'].centroid_values
+#        print domain.quantities['stage'].centroid_values
+#        print domain.quantities['xmomentum'].centroid_values
+#        print domain.quantities['ymomentum'].centroid_values
+
+        assert num.allclose(domain.quantities['elevation'].centroid_values, elev_ex)
+        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
+        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
+        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
+
+        # Apply Operator at time t=15.0
+        domain.set_time(15.0)
+        operator()
+
+
+        elev_ex =  [ 6.59259259,  6.18518519,  3.85185185,  6.59259259]
+        stage_ex = [ 7.59259259,  7.18518519,  4.85185185,  7.59259259]
+
+#        print domain.quantities['elevation'].centroid_values
+#        print domain.quantities['stage'].centroid_values
+#        print domain.quantities['xmomentum'].centroid_values
+#        print domain.quantities['ymomentum'].centroid_values
+
+        assert num.allclose(domain.quantities['elevation'].centroid_values, elev_ex)
+        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
+        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
+        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
+
+
+
+    def test_set_polygonal_elevation_operator_large_function(self):
+        from anuga.config import rho_a, rho_w, eta_w
+        from math import pi, cos, sin
+
+
+        length = 2.0
+        width = 2.0
+        dx = dy = 0.5
+        domain = rectangular_cross_domain(int(length/dx), int(width/dy),
+                                              len1=length, len2=width)
+
+
+        #Flat surface with 1m of water
+        domain.set_quantity('elevation', 0.0)
+        domain.set_quantity('stage', 1.0)
+        domain.set_quantity('friction', 0)
+
+        R = Reflective_boundary(domain)
+        domain.set_boundary( {'left': R, 'right': R, 'bottom': R, 'top': R} )
+
+
+#        print domain.quantities['stage'].centroid_values
+#        print domain.quantities['xmomentum'].centroid_values
+#        print domain.quantities['ymomentum'].centroid_values
+
+        # Apply operator to these triangles
+        indices = [0,1,3]
+
+
+        def elev(t):
+            if t < 10.0:
+                return 5.0
+            else:
+                return 7.0
+
+        polygon = [(0.5,0.5), (1.5,0.5), (1.5,1.5), (0.5,1.5)]
+        operator = Polygonal_set_elevation_operator(domain, elevation=elev, polygon=polygon)
+
+        # Apply Operator at time t=1.0
+        domain.set_time(1.0)
+        operator()
+
+
+
+
+        elev_ex = [ 0.        ,  0.        ,  0.41666667,  0.41666667,  0.        ,
+        0.41666667,  1.25      ,  0.83333333,  0.        ,  0.83333333,
+        1.25      ,  0.41666667,  0.        ,  0.41666667,  0.41666667,
+        0.        ,  0.41666667,  0.        ,  0.83333333,  1.25      ,
+        2.91666667,  2.91666667,  4.16666667,  4.16666667,  2.91666667,
+        4.16666667,  4.16666667,  2.91666667,  0.41666667,  1.25      ,
+        0.83333333,  0.        ,  0.83333333,  0.        ,  0.41666667,
+        1.25      ,  4.16666667,  2.91666667,  2.91666667,  4.16666667,
+        4.16666667,  4.16666667,  2.91666667,  2.91666667,  0.83333333,
+        1.25      ,  0.41666667,  0.        ,  0.41666667,  0.        ,
+        0.        ,  0.41666667,  1.25      ,  0.41666667,  0.        ,
+        0.83333333,  1.25      ,  0.83333333,  0.        ,  0.41666667,
+        0.41666667,  0.41666667,  0.        ,  0.        ]
+
+        stage_ex = [ 1.        ,  1.        ,  1.41666667,  1.41666667,  1.        ,
+        1.41666667,  2.25      ,  1.83333333,  1.        ,  1.83333333,
+        2.25      ,  1.41666667,  1.        ,  1.41666667,  1.41666667,
+        1.        ,  1.41666667,  1.        ,  1.83333333,  2.25      ,
+        3.91666667,  3.91666667,  5.16666667,  5.16666667,  3.91666667,
+        5.16666667,  5.16666667,  3.91666667,  1.41666667,  2.25      ,
+        1.83333333,  1.        ,  1.83333333,  1.        ,  1.41666667,
+        2.25      ,  5.16666667,  3.91666667,  3.91666667,  5.16666667,
+        5.16666667,  5.16666667,  3.91666667,  3.91666667,  1.83333333,
+        2.25      ,  1.41666667,  1.        ,  1.41666667,  1.        ,
+        1.        ,  1.41666667,  2.25      ,  1.41666667,  1.        ,
+        1.83333333,  2.25      ,  1.83333333,  1.        ,  1.41666667,
+        1.41666667,  1.41666667,  1.        ,  1.        ]
+
+
+
+
+
+#        from pprint import pprint
+#        pprint (domain.quantities['elevation'].centroid_values)
+#        pprint (domain.quantities['stage'].centroid_values)
+#        print domain.quantities['xmomentum'].centroid_values
+#        print domain.quantities['ymomentum'].centroid_values
+
+        assert num.allclose(domain.quantities['elevation'].centroid_values, elev_ex)
+        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
+        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
+        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
+
+        # Apply Operator at time t=15.0
+        domain.set_time(15.0)
+        operator()
+
+
+
+
+        elev_ex = [ 0.        ,  0.        ,  0.89583333,  0.89583333,  0.        ,
+        0.89583333,  2.47916667,  1.58333333,  0.        ,  1.58333333,
+        2.47916667,  0.89583333,  0.        ,  0.89583333,  0.89583333,
+        0.        ,  0.89583333,  0.        ,  1.58333333,  2.47916667,
+        4.8125    ,  4.8125    ,  6.25      ,  6.25      ,  4.8125    ,
+        6.25      ,  6.25      ,  4.8125    ,  0.89583333,  2.47916667,
+        1.58333333,  0.        ,  1.58333333,  0.        ,  0.89583333,
+        2.47916667,  6.25      ,  4.8125    ,  4.8125    ,  6.25      ,
+        6.25      ,  6.25      ,  4.8125    ,  4.8125    ,  1.58333333,
+        2.47916667,  0.89583333,  0.        ,  0.89583333,  0.        ,
+        0.        ,  0.89583333,  2.47916667,  0.89583333,  0.        ,
+        1.58333333,  2.47916667,  1.58333333,  0.        ,  0.89583333,
+        0.89583333,  0.89583333,  0.        ,  0.        ]
+
+        stage_ex = [ 1.        ,  1.        ,  1.89583333,  1.89583333,  1.        ,
+        1.89583333,  3.47916667,  2.58333333,  1.        ,  2.58333333,
+        3.47916667,  1.89583333,  1.        ,  1.89583333,  1.89583333,
+        1.        ,  1.89583333,  1.        ,  2.58333333,  3.47916667,
+        5.8125    ,  5.8125    ,  7.25      ,  7.25      ,  5.8125    ,
+        7.25      ,  7.25      ,  5.8125    ,  1.89583333,  3.47916667,
+        2.58333333,  1.        ,  2.58333333,  1.        ,  1.89583333,
+        3.47916667,  7.25      ,  5.8125    ,  5.8125    ,  7.25      ,
+        7.25      ,  7.25      ,  5.8125    ,  5.8125    ,  2.58333333,
+        3.47916667,  1.89583333,  1.        ,  1.89583333,  1.        ,
+        1.        ,  1.89583333,  3.47916667,  1.89583333,  1.        ,
+        2.58333333,  3.47916667,  2.58333333,  1.        ,  1.89583333,
+        1.89583333,  1.89583333,  1.        ,  1.        ]
+
+#        pprint (domain.quantities['elevation'].centroid_values)
+#        pprint (domain.quantities['stage'].centroid_values)
+#        print domain.quantities['xmomentum'].centroid_values
+#        print domain.quantities['ymomentum'].centroid_values
+
+        assert num.allclose(domain.quantities['elevation'].centroid_values, elev_ex)
+        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
+        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
+        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
+
+
+    def test_set_elevation_operator_large_function(self):
+        from anuga.config import rho_a, rho_w, eta_w
+        from math import pi, cos, sin
+
+
+        length = 2.0
+        width = 2.0
+        dx = dy = 0.5
+        domain = rectangular_cross_domain(int(length/dx), int(width/dy),
+                                              len1=length, len2=width)
+
+
+        #Flat surface with 1m of water
+        domain.set_quantity('elevation', 0.0)
+        domain.set_quantity('stage', 1.0)
+        domain.set_quantity('friction', 0)
+
+        R = Reflective_boundary(domain)
+        domain.set_boundary( {'left': R, 'right': R, 'bottom': R, 'top': R} )
+
+
+#        print domain.quantities['stage'].centroid_values
+#        print domain.quantities['xmomentum'].centroid_values
+#        print domain.quantities['ymomentum'].centroid_values
+
+        # Apply operator to these triangles
+        indices = [0,1,3]
+
+
+        def elev(t):
+            if t < 10.0:
+                return 5.0
+            else:
+                return 7.0
+
+        polygon = [(0.5,0.5), (1.5,0.5), (1.5,1.5), (0.5,1.5)]
+        operator = Set_elevation_operator(domain, elevation=elev, polygon=polygon)
+
+        # Apply Operator at time t=1.0
+        domain.set_time(1.0)
+        operator()
+
+        stage_ex = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
+                     0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
+                     0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
+                     0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
+                     0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
+                     0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
+
+
+        elev_ex = [ 0.        ,  0.        ,  0.41666667,  0.41666667,  0.        ,
+        0.41666667,  1.25      ,  0.83333333,  0.        ,  0.83333333,
+        1.25      ,  0.41666667,  0.        ,  0.41666667,  0.41666667,
+        0.        ,  0.41666667,  0.        ,  0.83333333,  1.25      ,
+        2.91666667,  2.91666667,  4.16666667,  4.16666667,  2.91666667,
+        4.16666667,  4.16666667,  2.91666667,  0.41666667,  1.25      ,
+        0.83333333,  0.        ,  0.83333333,  0.        ,  0.41666667,
+        1.25      ,  4.16666667,  2.91666667,  2.91666667,  4.16666667,
+        4.16666667,  4.16666667,  2.91666667,  2.91666667,  0.83333333,
+        1.25      ,  0.41666667,  0.        ,  0.41666667,  0.        ,
+        0.        ,  0.41666667,  1.25      ,  0.41666667,  0.        ,
+        0.83333333,  1.25      ,  0.83333333,  0.        ,  0.41666667,
+        0.41666667,  0.41666667,  0.        ,  0.        ]
+
+        stage_ex = [ 1.        ,  1.        ,  1.41666667,  1.41666667,  1.        ,
+        1.41666667,  2.25      ,  1.83333333,  1.        ,  1.83333333,
+        2.25      ,  1.41666667,  1.        ,  1.41666667,  1.41666667,
+        1.        ,  1.41666667,  1.        ,  1.83333333,  2.25      ,
+        3.91666667,  3.91666667,  5.16666667,  5.16666667,  3.91666667,
+        5.16666667,  5.16666667,  3.91666667,  1.41666667,  2.25      ,
+        1.83333333,  1.        ,  1.83333333,  1.        ,  1.41666667,
+        2.25      ,  5.16666667,  3.91666667,  3.91666667,  5.16666667,
+        5.16666667,  5.16666667,  3.91666667,  3.91666667,  1.83333333,
+        2.25      ,  1.41666667,  1.        ,  1.41666667,  1.        ,
+        1.        ,  1.41666667,  2.25      ,  1.41666667,  1.        ,
+        1.83333333,  2.25      ,  1.83333333,  1.        ,  1.41666667,
+        1.41666667,  1.41666667,  1.        ,  1.        ]
+
+
+
+
+
+#        from pprint import pprint
+#        pprint (domain.quantities['elevation'].centroid_values)
+#        pprint (domain.quantities['stage'].centroid_values)
+#        print domain.quantities['xmomentum'].centroid_values
+#        print domain.quantities['ymomentum'].centroid_values
+
+        assert num.allclose(domain.quantities['elevation'].centroid_values, elev_ex)
+        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
+        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
+        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
+
+        # Apply Operator at time t=15.0
+        domain.set_time(15.0)
+        operator()
+
+        stage_ex = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
+                     0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
+                     0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
+                     0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
+                     0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
+                     0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
+
+
+        elev_ex = [ 0.        ,  0.        ,  0.89583333,  0.89583333,  0.        ,
+        0.89583333,  2.47916667,  1.58333333,  0.        ,  1.58333333,
+        2.47916667,  0.89583333,  0.        ,  0.89583333,  0.89583333,
+        0.        ,  0.89583333,  0.        ,  1.58333333,  2.47916667,
+        4.8125    ,  4.8125    ,  6.25      ,  6.25      ,  4.8125    ,
+        6.25      ,  6.25      ,  4.8125    ,  0.89583333,  2.47916667,
+        1.58333333,  0.        ,  1.58333333,  0.        ,  0.89583333,
+        2.47916667,  6.25      ,  4.8125    ,  4.8125    ,  6.25      ,
+        6.25      ,  6.25      ,  4.8125    ,  4.8125    ,  1.58333333,
+        2.47916667,  0.89583333,  0.        ,  0.89583333,  0.        ,
+        0.        ,  0.89583333,  2.47916667,  0.89583333,  0.        ,
+        1.58333333,  2.47916667,  1.58333333,  0.        ,  0.89583333,
+        0.89583333,  0.89583333,  0.        ,  0.        ]
+
+        stage_ex = [ 1.        ,  1.        ,  1.89583333,  1.89583333,  1.        ,
+        1.89583333,  3.47916667,  2.58333333,  1.        ,  2.58333333,
+        3.47916667,  1.89583333,  1.        ,  1.89583333,  1.89583333,
+        1.        ,  1.89583333,  1.        ,  2.58333333,  3.47916667,
+        5.8125    ,  5.8125    ,  7.25      ,  7.25      ,  5.8125    ,
+        7.25      ,  7.25      ,  5.8125    ,  1.89583333,  3.47916667,
+        2.58333333,  1.        ,  2.58333333,  1.        ,  1.89583333,
+        3.47916667,  7.25      ,  5.8125    ,  5.8125    ,  7.25      ,
+        7.25      ,  7.25      ,  5.8125    ,  5.8125    ,  2.58333333,
+        3.47916667,  1.89583333,  1.        ,  1.89583333,  1.        ,
+        1.        ,  1.89583333,  3.47916667,  1.89583333,  1.        ,
+        2.58333333,  3.47916667,  2.58333333,  1.        ,  1.89583333,
+        1.89583333,  1.89583333,  1.        ,  1.        ]
+
+#        pprint (domain.quantities['elevation'].centroid_values)
+#        pprint (domain.quantities['stage'].centroid_values)
+#        print domain.quantities['xmomentum'].centroid_values
+#        print domain.quantities['ymomentum'].centroid_values
+
+        assert num.allclose(domain.quantities['elevation'].centroid_values, elev_ex)
+        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
+        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
+        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
+
+
+    def test_set_circular_elevation_operator_large_function(self):
+        from anuga.config import rho_a, rho_w, eta_w
+        from math import pi, cos, sin
+
+
+        length = 2.0
+        width = 2.0
+        dx = dy = 0.5
+        domain = rectangular_cross_domain(int(length/dx), int(width/dy),
+                                              len1=length, len2=width)
+
+
+        #Flat surface with 1m of water
+        domain.set_quantity('elevation', 0.0)
+        domain.set_quantity('stage', 1.0)
+        domain.set_quantity('friction', 0)
+
+        R = Reflective_boundary(domain)
+        domain.set_boundary( {'left': R, 'right': R, 'bottom': R, 'top': R} )
+
+
+#        print domain.quantities['stage'].centroid_values
+#        print domain.quantities['xmomentum'].centroid_values
+#        print domain.quantities['ymomentum'].centroid_values
+
+        # Apply operator to these triangles
+
+
+        def elev(t):
+            if t < 10.0:
+                return 5.0
+            else:
+                return 7.0
+
+        operator = Circular_set_elevation_operator(domain, elevation=elev, center=[1.0,1.0], radius=1.0)
+
+        # Apply Operator at time t=1.0
+        domain.set_time(1.0)
+        operator()
+
+
+
+
+        elev_ex = [ 2.08333333,  2.08333333,  3.75      ,  3.75      ,  4.58333333,
+        4.58333333,  5.        ,  5.        ,  4.58333333,  5.        ,
+        5.        ,  4.58333333,  2.08333333,  3.75      ,  3.75      ,
+        2.08333333,  4.58333333,  4.58333333,  5.        ,  5.        ,
+        5.        ,  5.        ,  5.        ,  5.        ,  5.        ,
+        5.        ,  5.        ,  5.        ,  4.58333333,  5.        ,
+        5.        ,  4.58333333,  5.        ,  4.58333333,  4.58333333,
+        5.        ,  5.        ,  5.        ,  5.        ,  5.        ,
+        5.        ,  5.        ,  5.        ,  5.        ,  5.        ,
+        5.        ,  4.58333333,  4.58333333,  3.75      ,  2.08333333,
+        2.08333333,  3.75      ,  5.        ,  4.58333333,  4.58333333,
+        5.        ,  5.        ,  5.        ,  4.58333333,  4.58333333,
+        3.75      ,  3.75      ,  2.08333333,  2.08333333]
+
+
+
+
+        stage_ex = [ 3.08333333,  3.08333333,  4.75      ,  4.75      ,  5.58333333,
+        5.58333333,  6.        ,  6.        ,  5.58333333,  6.        ,
+        6.        ,  5.58333333,  3.08333333,  4.75      ,  4.75      ,
+        3.08333333,  5.58333333,  5.58333333,  6.        ,  6.        ,
+        6.        ,  6.        ,  6.        ,  6.        ,  6.        ,
+        6.        ,  6.        ,  6.        ,  5.58333333,  6.        ,
+        6.        ,  5.58333333,  6.        ,  5.58333333,  5.58333333,
+        6.        ,  6.        ,  6.        ,  6.        ,  6.        ,
+        6.        ,  6.        ,  6.        ,  6.        ,  6.        ,
+        6.        ,  5.58333333,  5.58333333,  4.75      ,  3.08333333,
+        3.08333333,  4.75      ,  6.        ,  5.58333333,  5.58333333,
+        6.        ,  6.        ,  6.        ,  5.58333333,  5.58333333,
+        4.75      ,  4.75      ,  3.08333333,  3.08333333]
+
+
+
+
+
+#        from pprint import pprint
+#        pprint (domain.quantities['elevation'].centroid_values)
+#        pprint (domain.quantities['stage'].centroid_values)
+#        print domain.quantities['xmomentum'].centroid_values
+#        print domain.quantities['ymomentum'].centroid_values
+
+        assert num.allclose(domain.quantities['elevation'].centroid_values, elev_ex)
+        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
+        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
+        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
+
+        # Apply Operator at time t=15.0
+        domain.set_time(15.0)
+        operator()
+
+
+
+
+        elev_ex = [ 3.64583333,  3.64583333,  5.97916667,  5.97916667,  6.72916667,
+        6.72916667,  7.        ,  7.        ,  6.72916667,  7.        ,
+        7.        ,  6.72916667,  3.64583333,  5.97916667,  5.97916667,
+        3.64583333,  6.72916667,  6.72916667,  7.        ,  7.        ,
+        7.        ,  7.        ,  7.        ,  7.        ,  7.        ,
+        7.        ,  7.        ,  7.        ,  6.72916667,  7.        ,
+        7.        ,  6.72916667,  7.        ,  6.72916667,  6.72916667,
+        7.        ,  7.        ,  7.        ,  7.        ,  7.        ,
+        7.        ,  7.        ,  7.        ,  7.        ,  7.        ,
+        7.        ,  6.72916667,  6.72916667,  5.97916667,  3.64583333,
+        3.64583333,  5.97916667,  7.        ,  6.72916667,  6.72916667,
+        7.        ,  7.        ,  7.        ,  6.72916667,  6.72916667,
+        5.97916667,  5.97916667,  3.64583333,  3.64583333]
+
+
+        stage_ex = [ 4.64583333,  4.64583333,  6.97916667,  6.97916667,  7.72916667,
+        7.72916667,  8.        ,  8.        ,  7.72916667,  8.        ,
+        8.        ,  7.72916667,  4.64583333,  6.97916667,  6.97916667,
+        4.64583333,  7.72916667,  7.72916667,  8.        ,  8.        ,
+        8.        ,  8.        ,  8.        ,  8.        ,  8.        ,
+        8.        ,  8.        ,  8.        ,  7.72916667,  8.        ,
+        8.        ,  7.72916667,  8.        ,  7.72916667,  7.72916667,
+        8.        ,  8.        ,  8.        ,  8.        ,  8.        ,
+        8.        ,  8.        ,  8.        ,  8.        ,  8.        ,
+        8.        ,  7.72916667,  7.72916667,  6.97916667,  4.64583333,
+        4.64583333,  6.97916667,  8.        ,  7.72916667,  7.72916667,
+        8.        ,  8.        ,  8.        ,  7.72916667,  7.72916667,
+        6.97916667,  6.97916667,  4.64583333,  4.64583333]
+
+
+#        from pprint import pprint
+#        pprint (domain.quantities['elevation'].centroid_values)
+#        pprint (domain.quantities['stage'].centroid_values)
+#        pprint (domain.quantities['xmomentum'].centroid_values)
+#        pprint (domain.quantities['ymomentum'].centroid_values)
+
+        assert num.allclose(domain.quantities['elevation'].centroid_values, elev_ex)
+        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
+        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
+        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
+
+    def test_set_elevation_operator_center_radius(self):
+        from math import pi, cos, sin
+
+
+        length = 2.0
+        width = 2.0
+        dx = dy = 0.5
+        domain = rectangular_cross_domain(int(length/dx), int(width/dy),
+                                              len1=length, len2=width)
+
+
+        #Flat surface with 1m of water
+        domain.set_quantity('elevation', 0.0)
+        domain.set_quantity('stage', 1.0)
+        domain.set_quantity('friction', 0)
+
+        R = Reflective_boundary(domain)
+        domain.set_boundary( {'left': R, 'right': R, 'bottom': R, 'top': R} )
+
+        from pprint import pprint
+        #pprint(domain.quantities['stage'].centroid_values)
+#        print domain.quantities['xmomentum'].centroid_values
+#        print domain.quantities['ymomentum'].centroid_values
+
+        # Apply operator to these triangles
+
+
+        def elev(t):
+            if t < 10.0:
+                return 5.0
+            else:
+                return 7.0
+
+        operator = Set_elevation_operator(domain, elevation=elev, center=[1.0,1.0], radius=1.0)
+
+        # Apply Operator at time t=1.0
+        domain.set_time(1.0)
+        operator()
+
+
+        #pprint(domain.quantities['elevation'].centroid_values)
+
+        elev_ex = [ 2.08333333,  2.08333333,  3.75      ,  3.75      ,  4.58333333,
+        4.58333333,  5.        ,  5.        ,  4.58333333,  5.        ,
+        5.        ,  4.58333333,  2.08333333,  3.75      ,  3.75      ,
+        2.08333333,  4.58333333,  4.58333333,  5.        ,  5.        ,
+        5.        ,  5.        ,  5.        ,  5.        ,  5.        ,
+        5.        ,  5.        ,  5.        ,  4.58333333,  5.        ,
+        5.        ,  4.58333333,  5.        ,  4.58333333,  4.58333333,
+        5.        ,  5.        ,  5.        ,  5.        ,  5.        ,
+        5.        ,  5.        ,  5.        ,  5.        ,  5.        ,
+        5.        ,  4.58333333,  4.58333333,  3.75      ,  2.08333333,
+        2.08333333,  3.75      ,  5.        ,  4.58333333,  4.58333333,
+        5.        ,  5.        ,  5.        ,  4.58333333,  4.58333333,
+        3.75      ,  3.75      ,  2.08333333,  2.08333333]
+
+
+
+
+        #pprint(domain.quantities['stage'].centroid_values)
+        
+        stage_ex = [ 3.08333333,  3.08333333,  4.75      ,  4.75      ,  5.58333333,
+        5.58333333,  6.        ,  6.        ,  5.58333333,  6.        ,
+        6.        ,  5.58333333,  3.08333333,  4.75      ,  4.75      ,
+        3.08333333,  5.58333333,  5.58333333,  6.        ,  6.        ,
+        6.        ,  6.        ,  6.        ,  6.        ,  6.        ,
+        6.        ,  6.        ,  6.        ,  5.58333333,  6.        ,
+        6.        ,  5.58333333,  6.        ,  5.58333333,  5.58333333,
+        6.        ,  6.        ,  6.        ,  6.        ,  6.        ,
+        6.        ,  6.        ,  6.        ,  6.        ,  6.        ,
+        6.        ,  5.58333333,  5.58333333,  4.75      ,  3.08333333,
+        3.08333333,  4.75      ,  6.        ,  5.58333333,  5.58333333,
+        6.        ,  6.        ,  6.        ,  5.58333333,  5.58333333,
+        4.75      ,  4.75      ,  3.08333333,  3.08333333]
+
+
+
+#        from pprint import pprint
+#        pprint (domain.quantities['elevation'].centroid_values)
+#        pprint (domain.quantities['stage'].centroid_values)
+#        print domain.quantities['xmomentum'].centroid_values
+#        print domain.quantities['ymomentum'].centroid_values
+
+        assert num.allclose(domain.quantities['elevation'].centroid_values, elev_ex)
+        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
+        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
+        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
+
+        # Apply Operator at time t=15.0
+        domain.set_time(15.0)
+        operator()
+
+
+
+
+        elev_ex = [ 3.64583333,  3.64583333,  5.97916667,  5.97916667,  6.72916667,
+        6.72916667,  7.        ,  7.        ,  6.72916667,  7.        ,
+        7.        ,  6.72916667,  3.64583333,  5.97916667,  5.97916667,
+        3.64583333,  6.72916667,  6.72916667,  7.        ,  7.        ,
+        7.        ,  7.        ,  7.        ,  7.        ,  7.        ,
+        7.        ,  7.        ,  7.        ,  6.72916667,  7.        ,
+        7.        ,  6.72916667,  7.        ,  6.72916667,  6.72916667,
+        7.        ,  7.        ,  7.        ,  7.        ,  7.        ,
+        7.        ,  7.        ,  7.        ,  7.        ,  7.        ,
+        7.        ,  6.72916667,  6.72916667,  5.97916667,  3.64583333,
+        3.64583333,  5.97916667,  7.        ,  6.72916667,  6.72916667,
+        7.        ,  7.        ,  7.        ,  6.72916667,  6.72916667,
+        5.97916667,  5.97916667,  3.64583333,  3.64583333]
+
+
+        stage_ex = [ 4.64583333,  4.64583333,  6.97916667,  6.97916667,  7.72916667,
+        7.72916667,  8.        ,  8.        ,  7.72916667,  8.        ,
+        8.        ,  7.72916667,  4.64583333,  6.97916667,  6.97916667,
+        4.64583333,  7.72916667,  7.72916667,  8.        ,  8.        ,
+        8.        ,  8.        ,  8.        ,  8.        ,  8.        ,
+        8.        ,  8.        ,  8.        ,  7.72916667,  8.        ,
+        8.        ,  7.72916667,  8.        ,  7.72916667,  7.72916667,
+        8.        ,  8.        ,  8.        ,  8.        ,  8.        ,
+        8.        ,  8.        ,  8.        ,  8.        ,  8.        ,
+        8.        ,  7.72916667,  7.72916667,  6.97916667,  4.64583333,
+        4.64583333,  6.97916667,  8.        ,  7.72916667,  7.72916667,
+        8.        ,  8.        ,  8.        ,  7.72916667,  7.72916667,
+        6.97916667,  6.97916667,  4.64583333,  4.64583333]
+
+
+#        from pprint import pprint
+#        pprint (domain.quantities['elevation'].centroid_values)
+#        pprint (domain.quantities['stage'].centroid_values)
+#        pprint (domain.quantities['xmomentum'].centroid_values)
+#        pprint (domain.quantities['ymomentum'].centroid_values)
+
+        assert num.allclose(domain.quantities['elevation'].centroid_values, elev_ex)
+        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
+        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
+        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
+
+        operator = Set_elevation(domain, elevation=0.0)
+
+
+        #print operator.value_type
+        
+        operator()
+
+        #from pprint import pprint
+        #pprint (domain.quantities['elevation'].centroid_values)
+#        pprint (domain.quantities['stage'].centroid_values)
+#        pprint (domain.quantities['xmomentum'].centroid_values)
+#        pprint (domain.quantities['ymomentum'].centroid_values)
+
+        assert num.allclose(domain.quantities['elevation'].centroid_values, 0.0)
+        assert num.allclose(domain.quantities['stage'].centroid_values, 1.0)
+        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
+        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
+
+
+        operator = Set_elevation(domain, elevation=lambda t: t, indices = [0,1,3])
+
+        operator()
+
+
+
+        elev_ex = [ 11.25 ,  10.   ,   5.625,   6.875,   2.5  ,   3.125,   0.625,
+         0.   ,   0.   ,   0.   ,   0.   ,   0.   ,   0.   ,   0.   ,
+         0.   ,   0.   ,   1.875,   1.25 ,   0.   ,   0.625,   0.625,
+         0.625,   0.   ,   0.   ,   0.   ,   0.   ,   0.   ,   0.   ,
+         0.   ,   0.   ,   0.   ,   0.   ,   0.   ,   0.   ,   0.   ,
+         0.   ,   0.   ,   0.   ,   0.   ,   0.   ,   0.   ,   0.   ,
+         0.   ,   0.   ,   0.   ,   0.   ,   0.   ,   0.   ,   0.   ,
+         0.   ,   0.   ,   0.   ,   0.   ,   0.   ,   0.   ,   0.   ,
+         0.   ,   0.   ,   0.   ,   0.   ,   0.   ,   0.   ,   0.   ,   0.   ]
+
+        stage_ex = [ 12.25 ,  11.   ,   6.625,   7.875,   3.5  ,   4.125,   1.625,
+         1.   ,   1.   ,   1.   ,   1.   ,   1.   ,   1.   ,   1.   ,
+         1.   ,   1.   ,   2.875,   2.25 ,   1.   ,   1.625,   1.625,
+         1.625,   1.   ,   1.   ,   1.   ,   1.   ,   1.   ,   1.   ,
+         1.   ,   1.   ,   1.   ,   1.   ,   1.   ,   1.   ,   1.   ,
+         1.   ,   1.   ,   1.   ,   1.   ,   1.   ,   1.   ,   1.   ,
+         1.   ,   1.   ,   1.   ,   1.   ,   1.   ,   1.   ,   1.   ,
+         1.   ,   1.   ,   1.   ,   1.   ,   1.   ,   1.   ,   1.   ,
+         1.   ,   1.   ,   1.   ,   1.   ,   1.   ,   1.   ,   1.   ,   1.   ]
+
+
+
+#        from pprint import pprint
+#        pprint (domain.quantities['elevation'].centroid_values)
+#        pprint (domain.quantities['stage'].centroid_values)
+#        pprint (domain.quantities['xmomentum'].centroid_values)
+#        pprint (domain.quantities['ymomentum'].centroid_values)
+
+        assert num.allclose(domain.quantities['elevation'].centroid_values, elev_ex)
+        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
+        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
+        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
+
+    def test_set_elevation_operator_center_radius_de1(self):
+        from math import pi, cos, sin
+
+
+        length = 2.0
+        width = 2.0
+        dx = dy = 0.5
+        domain = rectangular_cross_domain(int(length/dx), int(width/dy),
+                                              len1=length, len2=width)
+
+
+        #Flat surface with 1m of water
+        domain.set_flow_algorithm('DE1')
+        domain.set_quantity('elevation', 0.0)
+        domain.set_quantity('stage', 1.0)
+        domain.set_quantity('friction', 0)
+
+        R = Reflective_boundary(domain)
+        domain.set_boundary( {'left': R, 'right': R, 'bottom': R, 'top': R} )
+
+        from pprint import pprint
+        #pprint(domain.quantities['stage'].centroid_values)
+#        print domain.quantities['xmomentum'].centroid_values
+#        print domain.quantities['ymomentum'].centroid_values
+
+        # Apply operator to these triangles
+
+
+        def elev(t):
+            if t < 10.0:
+                return 5.0
+            else:
+                return 7.0
+
+        operator = Set_elevation_operator(domain, elevation=elev, center=[1.0,1.0], radius=1.0)
+
+        # Apply Operator at time t=1.0
+        domain.set_time(1.0)
+        operator()
+
+
+        #pprint(domain.quantities['elevation'].centroid_values)
+
+        elev_ex = [ 0.,  0.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  0.,
+        5.,  5.,  0.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,
+        5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,
+        5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  0.,  0.,  5.,
+        5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  0.,  0.]
+
+
+        #pprint(domain.quantities['stage'].centroid_values)
+        
+        stage_ex = [ 1.,  1.,  6.,  6.,  6.,  6.,  6.,  6.,  6.,  6.,  6.,  6.,  1.,
+        6.,  6.,  1.,  6.,  6.,  6.,  6.,  6.,  6.,  6.,  6.,  6.,  6.,
+        6.,  6.,  6.,  6.,  6.,  6.,  6.,  6.,  6.,  6.,  6.,  6.,  6.,
+        6.,  6.,  6.,  6.,  6.,  6.,  6.,  6.,  6.,  6.,  1.,  1.,  6.,
+        6.,  6.,  6.,  6.,  6.,  6.,  6.,  6.,  6.,  6.,  1.,  1.]
+
+
+
+#        from pprint import pprint
+#        pprint (domain.quantities['elevation'].centroid_values)
+#        pprint (domain.quantities['stage'].centroid_values)
+#        print domain.quantities['xmomentum'].centroid_values
+#        print domain.quantities['ymomentum'].centroid_values
+
+        assert num.allclose(domain.quantities['elevation'].centroid_values, elev_ex)
+        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
+        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
+        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
+
+        # Apply Operator at time t=15.0
+        domain.set_time(15.0)
+        operator()
+
+
+        #pprint(domain.quantities['elevation'].centroid_values)
+
+        elev_ex = [ 0.,  0.,  7.,  7.,  7.,  7.,  7.,  7.,  7.,  7.,  7.,  7.,  0.,
+        7.,  7.,  0.,  7.,  7.,  7.,  7.,  7.,  7.,  7.,  7.,  7.,  7.,
+        7.,  7.,  7.,  7.,  7.,  7.,  7.,  7.,  7.,  7.,  7.,  7.,  7.,
+        7.,  7.,  7.,  7.,  7.,  7.,  7.,  7.,  7.,  7.,  0.,  0.,  7.,
+        7.,  7.,  7.,  7.,  7.,  7.,  7.,  7.,  7.,  7.,  0.,  0.]
+
+
+        #pprint(domain.quantities['stage'].centroid_values)
+
+        stage_ex = [ 1.,  1.,  8.,  8.,  8.,  8.,  8.,  8.,  8.,  8.,  8.,  8.,  1.,
+        8.,  8.,  1.,  8.,  8.,  8.,  8.,  8.,  8.,  8.,  8.,  8.,  8.,
+        8.,  8.,  8.,  8.,  8.,  8.,  8.,  8.,  8.,  8.,  8.,  8.,  8.,
+        8.,  8.,  8.,  8.,  8.,  8.,  8.,  8.,  8.,  8.,  1.,  1.,  8.,
+        8.,  8.,  8.,  8.,  8.,  8.,  8.,  8.,  8.,  8.,  1.,  1.]
+        
+
+#        from pprint import pprint
+#        pprint (domain.quantities['elevation'].centroid_values)
+#        pprint (domain.quantities['stage'].centroid_values)
+#        pprint (domain.quantities['xmomentum'].centroid_values)
+#        pprint (domain.quantities['ymomentum'].centroid_values)
+
+        assert num.allclose(domain.quantities['elevation'].centroid_values, elev_ex)
+        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
+        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
+        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
+
+        operator = Set_elevation(domain, elevation=0.0)
+
+
+        #print operator.value_type
+        
+        operator()
+
+        #from pprint import pprint
+#        pprint (domain.quantities['elevation'].centroid_values)
+#        pprint (domain.quantities['stage'].centroid_values)
+#        pprint (domain.quantities['xmomentum'].centroid_values)
+#        pprint (domain.quantities['ymomentum'].centroid_values)
+
+        assert num.allclose(domain.quantities['elevation'].centroid_values, 0.0)
+        assert num.allclose(domain.quantities['stage'].centroid_values, 1.0)
+        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
+        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
+
+
+        operator = Set_elevation(domain, elevation=lambda t: t, indices = [0,1,3])
+
+        operator()
+
+        #pprint (domain.quantities['elevation'].centroid_values)
+        #pprint (domain.quantities['stage'].centroid_values)
+
+        elev_ex = [ 15.,  15.,   0.,  15.,   0.,   0.,   0.,   0.,   0.,   0.,   0.,
+         0.,   0.,   0.,   0.,   0.,   0.,   0.,   0.,   0.,   0.,   0.,
+         0.,   0.,   0.,   0.,   0.,   0.,   0.,   0.,   0.,   0.,   0.,
+         0.,   0.,   0.,   0.,   0.,   0.,   0.,   0.,   0.,   0.,   0.,
+         0.,   0.,   0.,   0.,   0.,   0.,   0.,   0.,   0.,   0.,   0.,
+         0.,   0.,   0.,   0.,   0.,   0.,   0.,   0.,   0.]
+
+
+
+        stage_ex = [ 16.,  16.,   1.,  16.,   1.,   1.,   1.,   1.,   1.,   1.,   1.,
+         1.,   1.,   1.,   1.,   1.,   1.,   1.,   1.,   1.,   1.,   1.,
+         1.,   1.,   1.,   1.,   1.,   1.,   1.,   1.,   1.,   1.,   1.,
+         1.,   1.,   1.,   1.,   1.,   1.,   1.,   1.,   1.,   1.,   1.,
+         1.,   1.,   1.,   1.,   1.,   1.,   1.,   1.,   1.,   1.,   1.,
+         1.,   1.,   1.,   1.,   1.,   1.,   1.,   1.,   1.]
+        
+
+#        from pprint import pprint
+#        pprint (domain.quantities['elevation'].centroid_values)
+#        pprint (domain.quantities['stage'].centroid_values)
+#        pprint (domain.quantities['xmomentum'].centroid_values)
+#        pprint (domain.quantities['ymomentum'].centroid_values)
+
+        assert num.allclose(domain.quantities['elevation'].centroid_values, elev_ex)
+        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
+        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
+        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
+
+            
+if __name__ == "__main__":
+    suite = unittest.makeSuite(Test_set_elevation_operator, 'test')
+    runner = unittest.TextTestRunner(verbosity=1)
+    runner.run(suite)
Index: /trunk/anuga_core/source/anuga/operators/test/test_set_quantity.py
===================================================================
--- /trunk/anuga_core/source/anuga/operators/test/test_set_quantity.py	(revision 9445)
+++ /trunk/anuga_core/source/anuga/operators/test/test_set_quantity.py	(revision 9445)
@@ -0,0 +1,511 @@
+"""  Test set_quantity
+"""
+
+import unittest, os
+import anuga
+from anuga import Domain
+from anuga import Reflective_boundary
+from anuga import rectangular_cross_domain
+from anuga import file_function
+
+from anuga.config import netcdf_mode_r, netcdf_mode_w, netcdf_mode_a
+from anuga.file_conversion.file_conversion import timefile2netcdf
+from anuga.config import time_format
+
+from set_quantity import *
+from set_stage import *
+
+import numpy as num
+from pprint import pprint
+import warnings
+import time
+
+
+
+class Test_set_quantity(unittest.TestCase):
+    def setUp(self):
+        pass
+
+    def tearDown(self):
+        pass
+
+
+    def test_set_quantity_simple(self):
+        from anuga.config import rho_a, rho_w, eta_w
+        from math import pi, cos, sin
+
+        a = [0.0, 0.0]
+        b = [0.0, 2.0]
+        c = [2.0, 0.0]
+        d = [0.0, 4.0]
+        e = [2.0, 2.0]
+        f = [4.0, 0.0]
+
+        points = [a, b, c, d, e, f]
+        #             bac,     bce,     ecf,     dbe
+        vertices = [[1,0,2], [1,2,4], [4,2,5], [3,1,4]]
+
+        domain = Domain(points, vertices)
+
+        #Flat surface with 1m of water
+        domain.set_quantity('elevation', 0)
+        domain.set_quantity('stage', 1.0)
+        domain.set_quantity('friction', 0)
+
+        Br = Reflective_boundary(domain)
+        domain.set_boundary({'exterior': Br})
+
+
+#        print domain.quantities['stage'].centroid_values
+#        print domain.quantities['xmomentum'].centroid_values
+#        print domain.quantities['ymomentum'].centroid_values
+
+        # Apply operator to these triangles
+        indices = [0,1,3]
+
+        stage = 3.0
+
+
+        update_stage = Set_quantity(domain, "stage", value=stage, indices=indices, test_stage=False)
+        
+        # Apply Operator
+        update_stage()
+
+        stage_ex = [ 3.,  3.,   1.,  3.]
+
+
+        #print domain.quantities['stage'].centroid_values
+        #print domain.quantities['xmomentum'].centroid_values
+        #print domain.quantities['ymomentum'].centroid_values
+
+        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
+        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
+        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
+
+ 
+    def test_set_quantity_negative(self):
+        from anuga.config import rho_a, rho_w, eta_w
+        from math import pi, cos, sin
+
+        a = [0.0, 0.0]
+        b = [0.0, 2.0]
+        c = [2.0, 0.0]
+        d = [0.0, 4.0]
+        e = [2.0, 2.0]
+        f = [4.0, 0.0]
+
+        points = [a, b, c, d, e, f]
+        #             bac,     bce,     ecf,     dbe
+        vertices = [[1,0,2], [1,2,4], [4,2,5], [3,1,4]]
+
+        domain = Domain(points, vertices)
+
+        #Flat surface with 1m of water
+        domain.set_quantity('elevation', lambda x,y : -2*x)
+        domain.set_quantity('stage', 1.0)
+        domain.set_quantity('friction', 0)
+
+        Br = Reflective_boundary(domain)
+        domain.set_boundary({'exterior': Br})
+
+#        print domain.quantities['elevation'].centroid_values
+#        print domain.quantities['stage'].centroid_values
+#        print domain.quantities['xmomentum'].centroid_values
+#        print domain.quantities['ymomentum'].centroid_values
+
+        # Apply operator to these triangles
+        indices = [0,1,3]
+
+
+
+        #Catchment_Rain_Polygon = read_polygon(join('CatchmentBdy.csv'))
+        #rainfall = file_function(join('1y120m.tms'), quantities=['rainfall'])
+        stage = -5.0
+
+
+        try:
+            update_stage = Set_quantity(domain, 'stage', value=stage, indices=indices)
+        except AssertionError:
+            pass
+        except e:
+            self.fail('Unexpected exception thrown:', e)
+        else:
+            self.fail('ExpectedException not thrown')
+
+
+        update_stage = Set_quantity(domain, 'stage', value=stage, indices=indices, test_stage=False)
+        # Apply Operator
+        domain.timestep = 2.0
+        update_stage()
+
+        stage_ex = [ -5.,  -5.,   1.,  -5.]
+
+        #print domain.quantities['elevation'].centroid_values
+        #print domain.quantities['stage'].centroid_values
+        #print domain.quantities['xmomentum'].centroid_values
+        #print domain.quantities['ymomentum'].centroid_values
+
+        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
+        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
+        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
+        
+        update_stage = Set_stage(domain, stage=stage, indices=indices)
+        domain.timestep = 2.0
+        update_stage() 
+        
+        stage_ex = [-1.33333333, -2.66666667,  1.,         -1.33333333]
+        
+
+        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
+        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
+        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)      
+
+
+    def test_set_quantity_function(self):
+        from anuga.config import rho_a, rho_w, eta_w
+        from math import pi, cos, sin
+
+        a = [0.0, 0.0]
+        b = [0.0, 2.0]
+        c = [2.0, 0.0]
+        d = [0.0, 4.0]
+        e = [2.0, 2.0]
+        f = [4.0, 0.0]
+
+
+
+
+
+        points = [a, b, c, d, e, f]
+        #             bac,     bce,     ecf,     dbe
+        vertices = [[1,0,2], [1,2,4], [4,2,5], [3,1,4]]
+
+        domain = Domain(points, vertices)
+
+        #Flat surface with 1m of water
+        domain.set_quantity('elevation', 0)
+        domain.set_quantity('stage', 1.0)
+        domain.set_quantity('friction', 0)
+
+        Br = Reflective_boundary(domain)
+        domain.set_boundary({'exterior': Br})
+
+
+#        print domain.quantities['stage'].centroid_values
+#        print domain.quantities['xmomentum'].centroid_values
+#        print domain.quantities['ymomentum'].centroid_values
+
+        # Apply operator to these triangles
+        indices = [0,1,3]
+
+
+        def stage(t):
+            if t < 10.0:
+                return 5.0
+            else:
+                return 10.0
+
+        operator = Set_quantity(domain, 'stage', value=stage, indices=indices, test_stage=False)
+
+        # Apply Operator at time t=1.0
+        domain.set_time(1.0)
+        operator()
+
+        stage_ex = [ 5.,  5.,   1.,  5.]
+
+
+#        print domain.quantities['stage'].centroid_values
+#        print domain.quantities['xmomentum'].centroid_values
+#        print domain.quantities['ymomentum'].centroid_values
+
+        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
+        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
+        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
+
+        # Apply Operator at time t=15.0
+        domain.set_time(15.0)
+        operator()
+
+        stage_ex = [ 10.,  10.,   1.,  10.]
+
+
+#        print domain.quantities['stage'].centroid_values
+#        print domain.quantities['xmomentum'].centroid_values
+#        print domain.quantities['ymomentum'].centroid_values
+
+        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
+        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
+        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
+
+
+    def test_set_quantity_large_mesh_function(self):
+        from anuga.config import rho_a, rho_w, eta_w
+        from math import pi, cos, sin
+
+
+        length = 2.0
+        width = 2.0
+        dx = dy = 0.5
+        #dx = dy = 0.1
+        domain = rectangular_cross_domain(int(length/dx), int(width/dy),
+                                              len1=length, len2=width)
+
+
+        #Flat surface with 1m of water
+        domain.set_quantity('elevation', 0.0)
+        domain.set_quantity('stage', 1.0)
+        domain.set_quantity('friction', 0)
+
+        R = Reflective_boundary(domain)
+        domain.set_boundary( {'left': R, 'right': R, 'bottom': R, 'top': R} )
+
+
+#        print domain.quantities['stage'].centroid_values
+#        print domain.quantities['xmomentum'].centroid_values
+#        print domain.quantities['ymomentum'].centroid_values
+
+
+
+        def stage(t):
+            if t < 10.0:
+                return 5.0
+            else:
+                return 7.0
+
+        polygon = [(0.5,0.5), (1.5,0.5), (1.5,1.5), (0.5,1.5)]
+        #operator = Polygonal_set_stage_operator(domain, stage=stage, polygon=polygon)
+        operator = operator = Set_quantity(domain, 'stage', value=stage, polygon=polygon, test_stage=False)
+        
+
+
+        #operator.plot_region()
+        
+        # Apply Operator at time t=1.0
+        domain.set_time(1.0)
+        operator()
+
+
+        stage_ex_expanded = \
+                   [ 1.,  1.,  5.,  5.,  1.,  5.,  5.,  5.,  1.,  5.,  5.,  5.,  1.,
+                     5.,  5.,  1.,  5.,  1.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,
+                     5.,  5.,  5.,  5.,  5.,  1.,  5.,  1.,  5.,  5.,  5.,  5.,  5.,
+                     5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  1.,  5.,  1.,  1.,  5.,
+                     5.,  5.,  1.,  5.,  5.,  5.,  1.,  5.,  5.,  5.,  1.,  1.]
+
+        stage_ex = [ 1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,
+                     1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,
+                     5.0,  5.0,  5.0,  5.0,  5.0,  5.0,  5.0,  5.0,  1.0,  1.0,
+                     1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  5.0,  5.0,  5.0,  5.0,
+                     5.0,  5.0,  5.0,  5.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,
+                     1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,
+                     1.0,  1.0,  1.0,  1.0]
+
+
+#        print domain.quantities['elevation'].centroid_values
+#        pprint(domain.quantities['stage'].centroid_values)
+#        print domain.quantities['xmomentum'].centroid_values
+#        print domain.quantities['ymomentum'].centroid_values
+
+        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
+        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
+        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
+
+        # Apply Operator at time t=15.0
+        domain.set_time(15.0)
+        operator()
+
+        stage_ex_expanded = \
+                   [ 1.,  1.,  7.,  7.,  1.,  7.,  7.,  7.,  1.,  7.,  7.,  7.,  1.,
+                     7.,  7.,  1.,  7.,  1.,  7.,  7.,  7.,  7.,  7.,  7.,  7.,  7.,
+                     7.,  7.,  7.,  7.,  7.,  1.,  7.,  1.,  7.,  7.,  7.,  7.,  7.,
+                     7.,  7.,  7.,  7.,  7.,  7.,  7.,  7.,  1.,  7.,  1.,  1.,  7.,
+                     7.,  7.,  1.,  7.,  7.,  7.,  1.,  7.,  7.,  7.,  1.,  1.]
+
+
+        stage_ex = [ 1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,
+                     1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,
+                     7.0,  7.0,  7.0,  7.0,  7.0,  7.0,  7.0,  7.0,  1.0,  1.0,
+                     1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  7.0,  7.0,  7.0,  7.0,
+                     7.0,  7.0,  7.0,  7.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,
+                     1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,
+                     1.0,  1.0,  1.0,  1.0]
+
+
+#        pprint(domain.quantities['stage'].centroid_values)
+#        print domain.quantities['xmomentum'].centroid_values
+#        print domain.quantities['ymomentum'].centroid_values
+
+        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
+        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
+        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
+
+
+    def test_set_stage_operator_line(self):
+        
+        from math import pi, cos, sin
+
+
+        length = 2.0
+        width = 2.0
+        dx = dy = 0.5
+        #dx = dy = 0.1
+        domain = rectangular_cross_domain(int(length/dx), int(width/dy),
+                                              len1=length, len2=width)
+
+
+        #Flat surface with 1m of water
+        domain.set_quantity('elevation', -10.0)
+        domain.set_quantity('stage', -1.0)
+        domain.set_quantity('friction', 0)
+
+        R = Reflective_boundary(domain)
+        domain.set_boundary( {'left': R, 'right': R, 'bottom': R, 'top': R} )
+
+
+#        print domain.quantities['stage'].centroid_values
+#        print domain.quantities['xmomentum'].centroid_values
+#        print domain.quantities['ymomentum'].centroid_values
+
+
+
+        def stage(x,y, t):
+            #print x,y
+            if t < 10.0:
+                return x
+            else:
+                return y
+
+        line = [(0.5,0.5), (1.5,0.75)]
+        
+        operator = Set_quantity(domain, 'stage', value=stage, line=line, test_stage=False)
+
+
+        #print 'stage at 1',stage(3.0,4.0,1.0) # return x value
+        #print 'stage at 15', stage(3.0,4.0,15.0) # return y value
+        #print operator.indices
+        #print operator.value_type
+        
+        
+        # Apply Operator at time t=1.0
+        domain.set_time(1.0)
+        operator()
+
+
+
+
+        stage_ex = [-1.        , -1.        ,  0.41666667,  0.25      , -1.        ,
+        0.25      ,  0.41666667, -1.        , -1.        , -1.        ,
+       -1.        , -1.        , -1.        , -1.        , -1.        ,
+       -1.        ,  0.58333333, -1.        , -1.        ,  0.75      ,
+        0.58333333,  0.75      ,  0.91666667, -1.        , -1.        ,
+       -1.        , -1.        , -1.        , -1.        , -1.        ,
+       -1.        , -1.        , -1.        , -1.        , -1.        ,
+       -1.        ,  1.08333333,  1.25      ,  1.41666667, -1.        ,
+       -1.        , -1.        , -1.        , -1.        , -1.        ,
+       -1.        , -1.        , -1.        , -1.        , -1.        ,
+       -1.        , -1.        ,  1.58333333, -1.        , -1.        ,
+       -1.        , -1.        , -1.        , -1.        , -1.        ,
+       -1.        , -1.        , -1.        , -1.        ]
+
+
+        #from pprint import pprint
+#         pprint(domain.quantities['stage'].centroid_values)
+#        pprint(domain.quantities['stage'].centroid_values)
+
+
+        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
+        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
+        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
+
+        # Apply Operator at time t=15.0
+        domain.set_time(15.0)
+        operator()
+
+
+
+
+        stage_ex = [-1.        , -1.        ,  0.25      ,  0.41666667, -1.        ,
+        0.58333333,  0.75      , -1.        , -1.        , -1.        ,
+       -1.        , -1.        , -1.        , -1.        , -1.        ,
+       -1.        ,  0.25      , -1.        , -1.        ,  0.41666667,
+        0.75      ,  0.58333333,  0.75      , -1.        , -1.        ,
+       -1.        , -1.        , -1.        , -1.        , -1.        ,
+       -1.        , -1.        , -1.        , -1.        , -1.        ,
+       -1.        ,  0.75      ,  0.58333333,  0.75      , -1.        ,
+       -1.        , -1.        , -1.        , -1.        , -1.        ,
+       -1.        , -1.        , -1.        , -1.        , -1.        ,
+       -1.        , -1.        ,  0.75      , -1.        , -1.        ,
+       -1.        , -1.        , -1.        , -1.        , -1.        ,
+       -1.        , -1.        , -1.        , -1.        ]
+
+
+
+
+
+                
+               
+        Plot = False
+        if Plot:
+            operator.plot_region()
+            
+            cellsize = 0.01
+            domain.quantities['stage'].extrapolate_second_order_and_limit_by_vertex()
+            
+            from pprint import pprint
+        
+            pprint(domain.quantities['stage'].centroid_values)
+            
+            x,y,z = domain.quantities['stage'].save_to_array(cellsize=cellsize, smooth=False) 
+            
+            #pprint(z)
+            
+            import pylab
+            import numpy
+            #a = numpy.where(a == -9999, numpy.nan, a)
+            #a = numpy.where(a > 10.0, numpy.nan, a)
+        
+            #z = z[::-1,:]
+
+            """
+            print z
+            print z.shape
+            print x
+            print y
+            """
+            
+            nrows = z.shape[0]
+            ncols = z.shape[1]            
+            
+            
+            ratio = float(nrows)/float(ncols)
+            print ratio
+            
+            #y = numpy.arange(nrows)*cellsize
+            #x = numpy.arange(ncols)*cellsize
+        
+            #Setup fig size to correpond to array size
+            fig = pylab.figure(figsize=(10, 10*ratio))
+        
+            levels = numpy.arange(-2.0, 2, 0.01)
+            CF = pylab.contourf(x,y,z, levels=levels)
+            CB = pylab.colorbar(CF, shrink=0.8, extend='both')
+            #CC = pylab.contour(x,y,a, levels=levels)
+            
+            pylab.show()
+        
+
+        from pprint import pprint
+        #pprint(domain.quantities['stage'].centroid_values)
+#        print domain.quantities['xmomentum'].centroid_values
+#        print domain.quantities['ymomentum'].centroid_values
+
+        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
+        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
+        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
+
+
+
+if __name__ == "__main__":
+    suite = unittest.makeSuite(Test_set_quantity, 'test')
+    runner = unittest.TextTestRunner(verbosity=1)
+    runner.run(suite)
Index: /trunk/anuga_core/source/anuga/operators/test/test_set_stage_operator.py
===================================================================
--- /trunk/anuga_core/source/anuga/operators/test/test_set_stage_operator.py	(revision 9445)
+++ /trunk/anuga_core/source/anuga/operators/test/test_set_stage_operator.py	(revision 9445)
@@ -0,0 +1,491 @@
+"""  Test set operators - stage elevation erosion.
+"""
+
+import unittest, os
+import anuga
+from anuga import Domain
+from anuga import Reflective_boundary
+from anuga import rectangular_cross_domain
+from anuga import file_function
+
+from anuga.config import netcdf_mode_r, netcdf_mode_w, netcdf_mode_a
+from anuga.file_conversion.file_conversion import timefile2netcdf
+from anuga.config import time_format
+
+from set_stage_operator import *
+
+import numpy as num
+from pprint import pprint
+import warnings
+import time
+
+
+
+class Test_set_stage_operators(unittest.TestCase):
+    def setUp(self):
+        pass
+
+    def tearDown(self):
+        pass
+
+
+    def test_set_stage_operator_simple(self):
+        from anuga.config import rho_a, rho_w, eta_w
+        from math import pi, cos, sin
+
+        a = [0.0, 0.0]
+        b = [0.0, 2.0]
+        c = [2.0, 0.0]
+        d = [0.0, 4.0]
+        e = [2.0, 2.0]
+        f = [4.0, 0.0]
+
+        points = [a, b, c, d, e, f]
+        #             bac,     bce,     ecf,     dbe
+        vertices = [[1,0,2], [1,2,4], [4,2,5], [3,1,4]]
+
+        domain = Domain(points, vertices)
+
+        #Flat surface with 1m of water
+        domain.set_quantity('elevation', 0)
+        domain.set_quantity('stage', 1.0)
+        domain.set_quantity('friction', 0)
+
+        Br = Reflective_boundary(domain)
+        domain.set_boundary({'exterior': Br})
+
+
+#        print domain.quantities['stage'].centroid_values
+#        print domain.quantities['xmomentum'].centroid_values
+#        print domain.quantities['ymomentum'].centroid_values
+
+        # Apply operator to these triangles
+        indices = [0,1,3]
+
+        stage = 3.0
+
+
+        operator = Set_stage_operator(domain, stage=stage, indices=indices)
+        
+        # Apply Operator
+        domain.timestep = 2.0
+        operator()
+
+        stage_ex = [ 3.,  3.,   1.,  3.]
+
+
+        #print domain.quantities['stage'].centroid_values
+        #print domain.quantities['xmomentum'].centroid_values
+        #print domain.quantities['ymomentum'].centroid_values
+
+        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
+        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
+        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
+
+ 
+    def test_set_stage_operator_negative(self):
+        from anuga.config import rho_a, rho_w, eta_w
+        from math import pi, cos, sin
+
+        a = [0.0, 0.0]
+        b = [0.0, 2.0]
+        c = [2.0, 0.0]
+        d = [0.0, 4.0]
+        e = [2.0, 2.0]
+        f = [4.0, 0.0]
+
+        points = [a, b, c, d, e, f]
+        #             bac,     bce,     ecf,     dbe
+        vertices = [[1,0,2], [1,2,4], [4,2,5], [3,1,4]]
+
+        domain = Domain(points, vertices)
+
+        #Flat surface with 1m of water
+        domain.set_quantity('elevation', lambda x,y : -2*x)
+        domain.set_quantity('stage', 1.0)
+        domain.set_quantity('friction', 0)
+
+        Br = Reflective_boundary(domain)
+        domain.set_boundary({'exterior': Br})
+
+#        print domain.quantities['elevation'].centroid_values
+#        print domain.quantities['stage'].centroid_values
+#        print domain.quantities['xmomentum'].centroid_values
+#        print domain.quantities['ymomentum'].centroid_values
+
+        # Apply operator to these triangles
+        indices = [0,1,3]
+
+
+
+        #Catchment_Rain_Polygon = read_polygon(join('CatchmentBdy.csv'))
+        #rainfall = file_function(join('1y120m.tms'), quantities=['rainfall'])
+        stage = -5.0
+
+
+        operator = Set_stage_operator(domain, stage=stage, indices=indices)
+
+
+        # Apply Operator
+        domain.timestep = 2.0
+        operator()
+
+        stage_ex = [ -5.,  -5.,   1.,  -5.]
+
+        #print domain.quantities['elevation'].centroid_values
+        #print domain.quantities['stage'].centroid_values
+        #print domain.quantities['xmomentum'].centroid_values
+        #print domain.quantities['ymomentum'].centroid_values
+
+        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
+        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
+        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
+
+
+    def test_set_stage_operator_function(self):
+        from anuga.config import rho_a, rho_w, eta_w
+        from math import pi, cos, sin
+
+        a = [0.0, 0.0]
+        b = [0.0, 2.0]
+        c = [2.0, 0.0]
+        d = [0.0, 4.0]
+        e = [2.0, 2.0]
+        f = [4.0, 0.0]
+
+
+
+
+
+        points = [a, b, c, d, e, f]
+        #             bac,     bce,     ecf,     dbe
+        vertices = [[1,0,2], [1,2,4], [4,2,5], [3,1,4]]
+
+        domain = Domain(points, vertices)
+
+        #Flat surface with 1m of water
+        domain.set_quantity('elevation', 0)
+        domain.set_quantity('stage', 1.0)
+        domain.set_quantity('friction', 0)
+
+        Br = Reflective_boundary(domain)
+        domain.set_boundary({'exterior': Br})
+
+
+#        print domain.quantities['stage'].centroid_values
+#        print domain.quantities['xmomentum'].centroid_values
+#        print domain.quantities['ymomentum'].centroid_values
+
+        # Apply operator to these triangles
+        indices = [0,1,3]
+
+
+        def stage(t):
+            if t < 10.0:
+                return 5.0
+            else:
+                return 10.0
+
+        operator = Set_stage_operator(domain, stage=stage, indices=indices)
+
+        # Apply Operator at time t=1.0
+        domain.set_time(1.0)
+        operator()
+
+        stage_ex = [ 5.,  5.,   1.,  5.]
+
+
+#        print domain.quantities['stage'].centroid_values
+#        print domain.quantities['xmomentum'].centroid_values
+#        print domain.quantities['ymomentum'].centroid_values
+
+        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
+        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
+        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
+
+        # Apply Operator at time t=15.0
+        domain.set_time(15.0)
+        operator()
+
+        stage_ex = [ 10.,  10.,   1.,  10.]
+
+
+#        print domain.quantities['stage'].centroid_values
+#        print domain.quantities['xmomentum'].centroid_values
+#        print domain.quantities['ymomentum'].centroid_values
+
+        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
+        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
+        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
+
+
+    def test_set_stage_operator_large_function(self):
+        from anuga.config import rho_a, rho_w, eta_w
+        from math import pi, cos, sin
+
+
+        length = 2.0
+        width = 2.0
+        dx = dy = 0.5
+        #dx = dy = 0.1
+        domain = rectangular_cross_domain(int(length/dx), int(width/dy),
+                                              len1=length, len2=width)
+
+
+        #Flat surface with 1m of water
+        domain.set_quantity('elevation', 0.0)
+        domain.set_quantity('stage', 1.0)
+        domain.set_quantity('friction', 0)
+
+        R = Reflective_boundary(domain)
+        domain.set_boundary( {'left': R, 'right': R, 'bottom': R, 'top': R} )
+
+
+#        print domain.quantities['stage'].centroid_values
+#        print domain.quantities['xmomentum'].centroid_values
+#        print domain.quantities['ymomentum'].centroid_values
+
+
+
+        def stage(t):
+            if t < 10.0:
+                return 5.0
+            else:
+                return 7.0
+
+        polygon = [(0.5,0.5), (1.5,0.5), (1.5,1.5), (0.5,1.5)]
+        #operator = Polygonal_set_stage_operator(domain, stage=stage, polygon=polygon)
+        operator = Polygonal_set_stage_operator(domain, stage=stage, polygon=polygon)
+
+
+        #operator.plot_region()
+        
+        # Apply Operator at time t=1.0
+        domain.set_time(1.0)
+        operator()
+
+
+        stage_ex_expanded = \
+                   [ 1.,  1.,  5.,  5.,  1.,  5.,  5.,  5.,  1.,  5.,  5.,  5.,  1.,
+                     5.,  5.,  1.,  5.,  1.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,
+                     5.,  5.,  5.,  5.,  5.,  1.,  5.,  1.,  5.,  5.,  5.,  5.,  5.,
+                     5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  1.,  5.,  1.,  1.,  5.,
+                     5.,  5.,  1.,  5.,  5.,  5.,  1.,  5.,  5.,  5.,  1.,  1.]
+
+        stage_ex = [ 1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,
+                     1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,
+                     5.0,  5.0,  5.0,  5.0,  5.0,  5.0,  5.0,  5.0,  1.0,  1.0,
+                     1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  5.0,  5.0,  5.0,  5.0,
+                     5.0,  5.0,  5.0,  5.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,
+                     1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,
+                     1.0,  1.0,  1.0,  1.0]
+
+
+#        print domain.quantities['elevation'].centroid_values
+#        pprint(domain.quantities['stage'].centroid_values)
+#        print domain.quantities['xmomentum'].centroid_values
+#        print domain.quantities['ymomentum'].centroid_values
+
+        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
+        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
+        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
+
+        # Apply Operator at time t=15.0
+        domain.set_time(15.0)
+        operator()
+
+        stage_ex_expanded = \
+                   [ 1.,  1.,  7.,  7.,  1.,  7.,  7.,  7.,  1.,  7.,  7.,  7.,  1.,
+                     7.,  7.,  1.,  7.,  1.,  7.,  7.,  7.,  7.,  7.,  7.,  7.,  7.,
+                     7.,  7.,  7.,  7.,  7.,  1.,  7.,  1.,  7.,  7.,  7.,  7.,  7.,
+                     7.,  7.,  7.,  7.,  7.,  7.,  7.,  7.,  1.,  7.,  1.,  1.,  7.,
+                     7.,  7.,  1.,  7.,  7.,  7.,  1.,  7.,  7.,  7.,  1.,  1.]
+
+
+        stage_ex = [ 1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,
+                     1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,
+                     7.0,  7.0,  7.0,  7.0,  7.0,  7.0,  7.0,  7.0,  1.0,  1.0,
+                     1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  7.0,  7.0,  7.0,  7.0,
+                     7.0,  7.0,  7.0,  7.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,
+                     1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,
+                     1.0,  1.0,  1.0,  1.0]
+
+
+#        pprint(domain.quantities['stage'].centroid_values)
+#        print domain.quantities['xmomentum'].centroid_values
+#        print domain.quantities['ymomentum'].centroid_values
+
+        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
+        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
+        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
+
+
+    def test_set_stage_operator_line(self):
+        
+        from math import pi, cos, sin
+
+
+        length = 2.0
+        width = 2.0
+        dx = dy = 0.5
+        #dx = dy = 0.1
+        domain = rectangular_cross_domain(int(length/dx), int(width/dy),
+                                              len1=length, len2=width)
+
+
+        #Flat surface with 1m of water
+        domain.set_quantity('elevation', -10.0)
+        domain.set_quantity('stage', -1.0)
+        domain.set_quantity('friction', 0)
+
+        R = Reflective_boundary(domain)
+        domain.set_boundary( {'left': R, 'right': R, 'bottom': R, 'top': R} )
+
+
+#        print domain.quantities['stage'].centroid_values
+#        print domain.quantities['xmomentum'].centroid_values
+#        print domain.quantities['ymomentum'].centroid_values
+
+
+
+        def stage(x,y, t):
+            #print x,y
+            if t < 10.0:
+                return x
+            else:
+                return y
+
+        line = [(0.5,0.5), (1.5,0.75)]
+        
+        operator = Set_stage_operator(domain, stage=stage, line=line)
+
+
+        #print 'stage at 1',stage(3.0,4.0,1.0) # return x value
+        #print 'stage at 15', stage(3.0,4.0,15.0) # return y value
+        #print operator.indices
+        #print operator.value_type
+        
+        
+        # Apply Operator at time t=1.0
+        domain.set_time(1.0)
+        operator()
+
+
+
+
+        stage_ex = [-1.        , -1.        ,  0.41666667,  0.25      , -1.        ,
+        0.25      ,  0.41666667, -1.        , -1.        , -1.        ,
+       -1.        , -1.        , -1.        , -1.        , -1.        ,
+       -1.        ,  0.58333333, -1.        , -1.        ,  0.75      ,
+        0.58333333,  0.75      ,  0.91666667, -1.        , -1.        ,
+       -1.        , -1.        , -1.        , -1.        , -1.        ,
+       -1.        , -1.        , -1.        , -1.        , -1.        ,
+       -1.        ,  1.08333333,  1.25      ,  1.41666667, -1.        ,
+       -1.        , -1.        , -1.        , -1.        , -1.        ,
+       -1.        , -1.        , -1.        , -1.        , -1.        ,
+       -1.        , -1.        ,  1.58333333, -1.        , -1.        ,
+       -1.        , -1.        , -1.        , -1.        , -1.        ,
+       -1.        , -1.        , -1.        , -1.        ]
+
+
+        #from pprint import pprint
+#         pprint(domain.quantities['stage'].centroid_values)
+#        pprint(domain.quantities['stage'].centroid_values)
+
+
+        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
+        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
+        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
+
+        # Apply Operator at time t=15.0
+        domain.set_time(15.0)
+        operator()
+
+
+
+
+        stage_ex = [-1.        , -1.        ,  0.25      ,  0.41666667, -1.        ,
+        0.58333333,  0.75      , -1.        , -1.        , -1.        ,
+       -1.        , -1.        , -1.        , -1.        , -1.        ,
+       -1.        ,  0.25      , -1.        , -1.        ,  0.41666667,
+        0.75      ,  0.58333333,  0.75      , -1.        , -1.        ,
+       -1.        , -1.        , -1.        , -1.        , -1.        ,
+       -1.        , -1.        , -1.        , -1.        , -1.        ,
+       -1.        ,  0.75      ,  0.58333333,  0.75      , -1.        ,
+       -1.        , -1.        , -1.        , -1.        , -1.        ,
+       -1.        , -1.        , -1.        , -1.        , -1.        ,
+       -1.        , -1.        ,  0.75      , -1.        , -1.        ,
+       -1.        , -1.        , -1.        , -1.        , -1.        ,
+       -1.        , -1.        , -1.        , -1.        ]
+
+
+
+
+
+                
+               
+        Plot = False
+        if Plot:
+            operator.plot_region()
+            
+            cellsize = 0.01
+            domain.quantities['stage'].extrapolate_second_order_and_limit_by_vertex()
+            
+            from pprint import pprint
+        
+            pprint(domain.quantities['stage'].centroid_values)
+            
+            x,y,z = domain.quantities['stage'].save_to_array(cellsize=cellsize, smooth=False) 
+            
+            #pprint(z)
+            
+            import pylab
+            import numpy
+            #a = numpy.where(a == -9999, numpy.nan, a)
+            #a = numpy.where(a > 10.0, numpy.nan, a)
+        
+            #z = z[::-1,:]
+
+            """
+            print z
+            print z.shape
+            print x
+            print y
+            """
+            
+            nrows = z.shape[0]
+            ncols = z.shape[1]            
+            
+            
+            ratio = float(nrows)/float(ncols)
+            print ratio
+            
+            #y = numpy.arange(nrows)*cellsize
+            #x = numpy.arange(ncols)*cellsize
+        
+            #Setup fig size to correpond to array size
+            fig = pylab.figure(figsize=(10, 10*ratio))
+        
+            levels = numpy.arange(-2.0, 2, 0.01)
+            CF = pylab.contourf(x,y,z, levels=levels)
+            CB = pylab.colorbar(CF, shrink=0.8, extend='both')
+            #CC = pylab.contour(x,y,a, levels=levels)
+            
+            pylab.show()
+        
+
+        from pprint import pprint
+        #pprint(domain.quantities['stage'].centroid_values)
+#        print domain.quantities['xmomentum'].centroid_values
+#        print domain.quantities['ymomentum'].centroid_values
+
+        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
+        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
+        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
+
+
+
+if __name__ == "__main__":
+    suite = unittest.makeSuite(Test_set_stage_operators, 'test')
+    runner = unittest.TextTestRunner(verbosity=1)
+    runner.run(suite)
Index: /trunk/anuga_core/source/anuga/operators/test/test_set_w_uh_vh_operators.py
===================================================================
--- /trunk/anuga_core/source/anuga/operators/test/test_set_w_uh_vh_operators.py	(revision 9445)
+++ /trunk/anuga_core/source/anuga/operators/test/test_set_w_uh_vh_operators.py	(revision 9445)
@@ -0,0 +1,211 @@
+"""  Test set operators - w_uh_vh elevation erosion.
+"""
+
+import unittest, os
+import anuga
+from anuga import Domain
+from anuga import Reflective_boundary
+from anuga import rectangular_cross_domain
+from anuga import file_function
+
+from anuga.config import netcdf_mode_r, netcdf_mode_w, netcdf_mode_a
+from anuga.file_conversion.file_conversion import timefile2netcdf
+from anuga.config import time_format
+
+from set_w_uh_vh_operator import *
+
+import numpy as num
+import warnings
+import time
+
+
+
+class Test_set_w_uh_vh_operators(unittest.TestCase):
+    def setUp(self):
+        pass
+
+    def tearDown(self):
+        pass
+
+
+    def test_set_w_uh_vh_operator_simple(self):
+        from anuga.config import rho_a, rho_w, eta_w
+        from math import pi, cos, sin
+
+        a = [0.0, 0.0]
+        b = [0.0, 2.0]
+        c = [2.0, 0.0]
+        d = [0.0, 4.0]
+        e = [2.0, 2.0]
+        f = [4.0, 0.0]
+
+        points = [a, b, c, d, e, f]
+        #             bac,     bce,     ecf,     dbe
+        vertices = [[1,0,2], [1,2,4], [4,2,5], [3,1,4]]
+
+        domain = Domain(points, vertices)
+
+        #Flat surface with 1m of water
+        domain.set_quantity('elevation', 0)
+        domain.set_quantity('stage', 1.0)
+        domain.set_quantity('xmomentum', 7.0)
+        domain.set_quantity('ymomentum', 8.0)
+        domain.set_quantity('friction', 0)
+
+        Br = Reflective_boundary(domain)
+        domain.set_boundary({'exterior': Br})
+
+
+#        print domain.quantities['w_uh_vh'].centroid_values
+#        print domain.quantities['xmomentum'].centroid_values
+#        print domain.quantities['ymomentum'].centroid_values
+
+        # Apply operator to these triangles
+        indices = [0,1,3]
+
+        w_uh_vh = [3.0, 4.0, 5.0]
+
+
+        operator = Set_w_uh_vh_operator(domain, w_uh_vh=w_uh_vh, indices=indices)
+        
+        # Apply Operator
+        domain.timestep = 2.0
+        operator()
+
+        stage_ex = [ 3.,  3.,   1.,  3.]
+        xmom_ex = [ 4.,  4.,   7.,  4.]
+        ymom_ex = [ 5.,  5.,   8.,  5.]
+
+
+        #print domain.quantities['stage'].centroid_values
+        #print domain.quantities['xmomentum'].centroid_values
+        #print domain.quantities['ymomentum'].centroid_values
+
+        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
+        assert num.allclose(domain.quantities['xmomentum'].centroid_values, xmom_ex)
+        assert num.allclose(domain.quantities['ymomentum'].centroid_values, ymom_ex)
+
+    def test_set_w_uh_vh_operator_simple_time(self):
+        from anuga.config import rho_a, rho_w, eta_w
+        from math import pi, cos, sin
+
+        a = [0.0, 0.0]
+        b = [0.0, 2.0]
+        c = [2.0, 0.0]
+        d = [0.0, 4.0]
+        e = [2.0, 2.0]
+        f = [4.0, 0.0]
+
+        points = [a, b, c, d, e, f]
+        #             bac,     bce,     ecf,     dbe
+        vertices = [[1,0,2], [1,2,4], [4,2,5], [3,1,4]]
+
+        domain = Domain(points, vertices)
+
+        #Flat surface with 1m of water
+        domain.set_quantity('elevation', 0)
+        domain.set_quantity('stage', 1.0)
+        domain.set_quantity('xmomentum', 7.0)
+        domain.set_quantity('ymomentum', 8.0)
+        domain.set_quantity('friction', 0)
+
+        Br = Reflective_boundary(domain)
+        domain.set_boundary({'exterior': Br})
+
+
+#        print domain.quantities['w_uh_vh'].centroid_values
+#        print domain.quantities['xmomentum'].centroid_values
+#        print domain.quantities['ymomentum'].centroid_values
+
+        # Apply operator to these triangles
+        indices = [0,1,3]
+
+        w_uh_vh = lambda t : [3.0, 4.0, 5.0]
+
+
+        operator = Set_w_uh_vh_operator(domain, w_uh_vh=w_uh_vh, indices=indices)
+        
+        # Apply Operator
+        domain.timestep = 2.0
+        operator()
+
+        stage_ex = [ 3.,  3.,   1.,  3.]
+        xmom_ex = [ 4.,  4.,   7.,  4.]
+        ymom_ex = [ 5.,  5.,   8.,  5.]
+
+
+        #print domain.quantities['stage'].centroid_values
+        #print domain.quantities['xmomentum'].centroid_values
+        #print domain.quantities['ymomentum'].centroid_values
+
+        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
+        assert num.allclose(domain.quantities['xmomentum'].centroid_values, xmom_ex)
+        assert num.allclose(domain.quantities['ymomentum'].centroid_values, ymom_ex)
+
+
+    def test_set_w_uh_vh_operator_time(self):
+        from anuga.config import rho_a, rho_w, eta_w
+        from math import pi, cos, sin
+
+        a = [0.0, 0.0]
+        b = [0.0, 2.0]
+        c = [2.0, 0.0]
+        d = [0.0, 4.0]
+        e = [2.0, 2.0]
+        f = [4.0, 0.0]
+
+        points = [a, b, c, d, e, f]
+        #             bac,     bce,     ecf,     dbe
+        vertices = [[1,0,2], [1,2,4], [4,2,5], [3,1,4]]
+
+        domain = Domain(points, vertices)
+
+        #Flat surface with 1m of water
+        domain.set_quantity('elevation', 0)
+        domain.set_quantity('stage', 1.0)
+        domain.set_quantity('xmomentum', 7.0)
+        domain.set_quantity('ymomentum', 8.0)
+        domain.set_quantity('friction', 0)
+
+        Br = Reflective_boundary(domain)
+        domain.set_boundary({'exterior': Br})
+
+
+#        print domain.quantities['w_uh_vh'].centroid_values
+#        print domain.quantities['xmomentum'].centroid_values
+#        print domain.quantities['ymomentum'].centroid_values
+
+        # Apply operator to these triangles
+        indices = [0,1,3]
+
+        w_uh_vh = lambda t : [t, t+1, t+2]
+
+
+        operator = Set_w_uh_vh_operator(domain, w_uh_vh=w_uh_vh, indices=indices)
+        
+        # Apply Operator
+        domain.timestep = 2.0
+        domain.time = 1.0
+        operator()
+
+        t = domain.time
+        stage_ex = [ t,  t,   1.,  t]
+        xmom_ex = [ t+1,  t+1,   7.,  t+1]
+        ymom_ex = [ t+2,  t+2,   8.,  t+2]
+
+
+        #print domain.quantities['stage'].centroid_values
+        #print domain.quantities['xmomentum'].centroid_values
+        #print domain.quantities['ymomentum'].centroid_values
+
+        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
+        assert num.allclose(domain.quantities['xmomentum'].centroid_values, xmom_ex)
+        assert num.allclose(domain.quantities['ymomentum'].centroid_values, ymom_ex)
+
+
+
+
+if __name__ == "__main__":
+    suite = unittest.makeSuite(Test_set_w_uh_vh_operators, 'test')
+    runner = unittest.TextTestRunner(verbosity=1)
+    runner.run(suite)
Index: unk/anuga_core/source/anuga/operators/test_all.py
===================================================================
--- /trunk/anuga_core/source/anuga/operators/test_all.py	(revision 9444)
+++ 	(revision )
@@ -1,83 +1,0 @@
-"""Regression testing framework
-This module will search for scripts in the same directory named
-test_*.py.  Each such script should be a test suite that tests a
-module through PyUnit. This script will aggregate all
-found test suites into one big test suite and run them all at once.
-"""
-
-# Author: Mark Pilgrim
-# Modified by Ole Nielsen
-
-import unittest
-import os
-
-
-#List files that should be excluded from the testing process.
-#E.g. if they are known to fail and under development
-exclude = [] 
-
-
-def get_test_files(path):
-
-    import sys
-
-    files = os.listdir(path)
-
-    #Check sub directories
-    test_files = []
-    for file in files:
-        if os.path.isdir(file):
-            sys.path.append(file)
-            #print 'Recursing into', file
-            test_files += get_test_files(path + os.sep + file)
-        elif file[:5] == 'test_' and file[-2:] == 'py':
-            #print 'Appending', file
-            test_files.append(file)
-        else:
-            pass
-    return test_files
-
-
-
-def regressionTest():
-    import sys, os, re, unittest
-    path = os.path.split(sys.argv[0])[0] or os.getcwd()
-
-
-    files = get_test_files(path)
-
-
-
-    #test = re.compile('^test_[\w]*.py$', re.IGNORECASE)
-    #files = filter(test.search, files)
-
-
-    try:
-        files.remove(__file__)  #Remove self from list (Ver 2.3. or later)
-    except:
-        files.remove('test_all.py')
-
-    print 'Testing:'
-    for file in files:
-        print '  ' + file
-
-    if globals().has_key('exclude'):
-        for file in exclude:
-            files.remove(file)
-            print 'WARNING: File '+ file + ' excluded from testing'
-
-
-    filenameToModuleName = lambda f: os.path.splitext(f)[0]
-    #print "files",files 
-    moduleNames = map(filenameToModuleName, files)
-    #print "moduleNames",moduleNames
-    modules = map(__import__, moduleNames)
-    load = unittest.defaultTestLoader.loadTestsFromModule
-    return unittest.TestSuite(map(load, modules))
-
-################################################################################
-
-if __name__ == '__main__':   
-    suite = regressionTest()
-    runner = unittest.TextTestRunner() #verbosity=2)
-    runner.run(suite)
Index: unk/anuga_core/source/anuga/operators/test_base_operator.py
===================================================================
--- /trunk/anuga_core/source/anuga/operators/test_base_operator.py	(revision 9444)
+++ 	(revision )
@@ -1,51 +1,0 @@
-from anuga import Domain
-from anuga import Dirichlet_boundary
-from anuga import Operator
-
-import numpy as num
-import unittest
-
-class Test_Operator(unittest.TestCase):
-    def setUp(self):
-        pass
-
-    def tearDown(self):
-        pass
-
-    def test_create_operator(self):
-        points = num.array([[0.0,0.0],[1.0,0.0],[0.0,1.0]])
-        
-        elements = num.array([[0,1,2]])
-        boundary_map = {}
-        boundary_map[(0,0)] = 'edge0'
-        boundary_map[(0,1)] = 'edge1'
-        boundary_map[(0,2)] = 'edge2'
-
-        domain = Domain(points, elements, boundary_map)
-
-        operator = Operator(domain)
-
-        message = operator.statistics()
-        assert message == 'You need to implement operator statistics for your operator'
-
-        message = operator.timestepping_statistics()
-        assert message == 'You need to implement timestepping statistics for your operator'
-
-        domain.timestep = 3.0
-
-        assert operator.get_timestep() == domain.get_timestep()
-        
-        try:
-            operator()
-        except:
-            pass
-        else:
-            raise Exception('should have raised an exception')
-
-
-################################################################################
-
-if __name__ == "__main__":
-    suite = unittest.makeSuite(Test_Operator, 'test')
-    runner = unittest.TextTestRunner()
-    runner.run(suite)
Index: unk/anuga_core/source/anuga/operators/test_boundary_flux_integral_operator.py
===================================================================
--- /trunk/anuga_core/source/anuga/operators/test_boundary_flux_integral_operator.py	(revision 9444)
+++ 	(revision )
@@ -1,88 +1,0 @@
-import unittest
-import anuga
-import numpy
-
-boundaryPolygon=[ [0., 0.], [0., 100.], [100.0, 100.0], [100.0, 0.0]]
-
-verbose=False
-
-class Test_boundary_flux_integral_operator(unittest.TestCase):
-    def setUp(self):
-        pass
-
-    def tearDown(self):
-        pass
-
-    def create_domain(self, flowalg):
-        # Riverwall = list of lists, each with a set of x,y,z (and optional QFactor) values
-
-        # Make the domain
-        anuga.create_mesh_from_regions(boundaryPolygon, 
-                                 boundary_tags={'left': [0],
-                                                'top': [1],
-                                                'right': [2],
-                                                'bottom': [3]},
-                                   maximum_triangle_area = 200.,
-                                   minimum_triangle_angle = 28.0,
-                                   filename = 'test_boundaryfluxintegral.msh',
-                                   use_cache=False,
-                                   verbose=verbose)
-
-        domain=anuga.create_domain_from_file('test_boundaryfluxintegral.msh')
-
-        # 05/05/2014 -- riverwalls only work with DE0 and DE1
-        domain.set_flow_algorithm(flowalg)
-        domain.set_name('test_boundaryfluxintegral')
-
-        domain.set_store_vertices_uniquely()
-       
-        def topography(x,y):
-            return -x/150. 
-
-        # NOTE: Setting quantities at centroids is important for exactness of tests
-        domain.set_quantity('elevation',topography,location='centroids')     
-        domain.set_quantity('friction',0.03)             
-        domain.set_quantity('stage', topography,location='centroids')            
-       
-        # Boundary conditions
-        Br=anuga.Reflective_boundary(domain)
-        Bd=anuga.Dirichlet_boundary([0., 0., 0.])
-        domain.set_boundary({'left': Br, 'right': Bd, 'top': Br, 'bottom':Br})
-
-        return domain
-
-    def test_boundary_flux_operator_DE0(self):
-        """
-        A (the) boundary flux operator is instantiated when a domain is created.
-        This tests the calculation for euler timestepping 
-        """
-        
-        domain=self.create_domain('DE0')
-        for t in domain.evolve(yieldstep=0.1,finaltime=1.0):
-            pass
-        # The domain was initially dry
-        vol=domain.get_water_volume()
-        boundaryFluxInt=domain.get_boundary_flux_integral()
-
-        assert(numpy.allclose(vol,boundaryFluxInt))
-    
-    def test_boundary_flux_operator_DE1(self):
-        """
-        A (the) boundary flux operator is instantiated when a domain is created.
-        This tests the calculation for rk2 timestepping 
-        """
-        
-        domain=self.create_domain('DE1')
-        for t in domain.evolve(yieldstep=0.1,finaltime=1.0):
-            pass
-        # The domain was initially dry
-        vol=domain.get_water_volume()
-        boundaryFluxInt=domain.get_boundary_flux_integral()
-
-        assert(numpy.allclose(vol,boundaryFluxInt))
-
-if __name__ == "__main__":
-    suite = unittest.makeSuite(Test_boundary_flux_integral_operator, 'test')
-    runner = unittest.TextTestRunner(verbosity=1)
-    runner.run(suite)
-
Index: unk/anuga_core/source/anuga/operators/test_erosion_operators.py
===================================================================
--- /trunk/anuga_core/source/anuga/operators/test_erosion_operators.py	(revision 9444)
+++ 	(revision )
@@ -1,344 +1,0 @@
-"""  Test erosion operators
-"""
-
-import unittest, os
-import anuga
-from anuga import Domain
-from anuga import Reflective_boundary
-from anuga import rectangular_cross_domain
-from anuga import file_function
-
-from anuga.config import netcdf_mode_r, netcdf_mode_w, netcdf_mode_a
-from anuga.file_conversion.file_conversion import timefile2netcdf
-from anuga.config import time_format
-
-from anuga.operators.erosion_operators import Erosion_operator
-
-import numpy as num
-import warnings
-import time
-
-
-
-class Test_erosion_operators(unittest.TestCase):
-    def setUp(self):
-        pass
-
-    def tearDown(self):
-        pass
-
-
-
-    def test_erosion_operator_simple(self):
-        from anuga.config import rho_a, rho_w, eta_w
-        from math import pi, cos, sin
-
-        a = [0.0, 0.0]
-        b = [0.0, 2.0]
-        c = [2.0, 0.0]
-        d = [0.0, 4.0]
-        e = [2.0, 2.0]
-        f = [4.0, 0.0]
-
-        points = [a, b, c, d, e, f]
-        #             bac,     bce,     ecf,     dbe
-        vertices = [[1,0,2], [1,2,4], [4,2,5], [3,1,4]]
-
-        domain = Domain(points, vertices)
-
-        #Flat surface with 1m of water
-        domain.set_quantity('elevation', 0.5)
-        domain.set_quantity('stage', 1.0)
-        domain.set_quantity('friction', 0)
-        domain.set_quantity('xmomentum',2.0)
-        domain.set_quantity('ymomentum',3.0)
-
-        Stage = domain.quantities['stage'].centroid_values
-        Elevation = domain.quantities['elevation'].centroid_values
-
-        Height = Stage - Elevation
-
-        sum1 = num.sum(Height)
-
-        Br = Reflective_boundary(domain)
-        domain.set_boundary({'exterior': Br})
-
-
-#        print domain.quantities['stage'].centroid_values
-#        print domain.quantities['xmomentum'].centroid_values
-#        print domain.quantities['ymomentum'].centroid_values
-
-        # Apply operator to these triangles
-        indices = [0,1,3]
-
-
-        operator = Erosion_operator(domain, indices=indices, logging=True)
-
-        # Apply Operator
-        domain.timestep = 2.0
-        operator()
-
-        elev_ex  = [ 0.05555556,  0.11111111,  0.27777778,  0.05555556]
-        stage_ex = [ 0.55555556,  0.61111111,  0.77777778,  0.55555556]
-
-        Stage = domain.quantities['stage'].centroid_values
-        Elevation = domain.quantities['elevation'].centroid_values
-
-        Height = Stage - Elevation
-
-        sum2 = num.sum(Height)
-        
-        #print domain.quantities['elevation'].centroid_values
-        #print domain.quantities['stage'].centroid_values
-        #print domain.quantities['xmomentum'].centroid_values
-        #print domain.quantities['ymomentum'].centroid_values
-
-        assert sum1 == sum2
-        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
-        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 2.0)
-        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 3.0)
-
-
-
-#    def test_rate_operator_rate_from_file(self):
-#        from anuga.config import rho_a, rho_w, eta_w
-#        from math import pi, cos, sin
-#
-#        a = [0.0, 0.0]
-#        b = [0.0, 2.0]
-#        c = [2.0, 0.0]
-#        d = [0.0, 4.0]
-#        e = [2.0, 2.0]
-#        f = [4.0, 0.0]
-#
-#        points = [a, b, c, d, e, f]
-#        #             bac,     bce,     ecf,     dbe
-#        vertices = [[1,0,2], [1,2,4], [4,2,5], [3,1,4]]
-#
-#
-#        #---------------------------------
-#        #Typical ASCII file
-#        #---------------------------------
-#        finaltime = 1200
-#        filename = 'test_file_function'
-#        fid = open(filename + '.txt', 'w')
-#        start = time.mktime(time.strptime('2000', '%Y'))
-#        dt = 60  #One minute intervals
-#        t = 0.0
-#        while t <= finaltime:
-#            t_string = time.strftime(time_format, time.gmtime(t+start))
-#            fid.write('%s, %f %f %f\n' %(t_string, 2*t, t**2, sin(t*pi/600)))
-#            t += dt
-#
-#        fid.close()
-#
-#        #Convert ASCII file to NetCDF (Which is what we really like!)
-#        timefile2netcdf(filename+'.txt')
-#
-#
-#        #Create file function from time series
-#        F = file_function(filename + '.tms',
-#                          quantities = ['Attribute0',
-#                                        'Attribute1',
-#                                        'Attribute2'])
-#
-#        #Now try interpolation
-#        for i in range(20):
-#            t = i*10
-#            q = F(t)
-#
-#            #Exact linear intpolation
-#            assert num.allclose(q[0], 2*t)
-#            if i%6 == 0:
-#                assert num.allclose(q[1], t**2)
-#                assert num.allclose(q[2], sin(t*pi/600))
-#
-#        #Check non-exact
-#
-#        t = 90 #Halfway between 60 and 120
-#        q = F(t)
-#        assert num.allclose( (120**2 + 60**2)/2, q[1] )
-#        assert num.allclose( (sin(120*pi/600) + sin(60*pi/600))/2, q[2] )
-#
-#
-#        t = 100 #Two thirds of the way between between 60 and 120
-#        q = F(t)
-#        assert num.allclose( 2*120**2/3 + 60**2/3, q[1] )
-#        assert num.allclose( 2*sin(120*pi/600)/3 + sin(60*pi/600)/3, q[2] )
-#
-#        #os.remove(filename + '.txt')
-#        #os.remove(filename + '.tms')
-#
-#
-#        domain = Domain(points, vertices)
-#
-#        #Flat surface with 1m of water
-#        domain.set_quantity('elevation', 0)
-#        domain.set_quantity('stage', 1.0)
-#        domain.set_quantity('friction', 0)
-#
-#        Br = Reflective_boundary(domain)
-#        domain.set_boundary({'exterior': Br})
-#
-##        print domain.quantities['elevation'].centroid_values
-##        print domain.quantities['stage'].centroid_values
-##        print domain.quantities['xmomentum'].centroid_values
-##        print domain.quantities['ymomentum'].centroid_values
-#
-#        # Apply operator to these triangles
-#        indices = [0,1,3]
-#
-#
-#        rate = file_function('test_file_function.tms', quantities=['Attribute1'])
-#
-#        factor = 1000.0
-#        default_rate= 17.7
-#
-#        operator = Rate_operator(domain, rate=rate, factor=factor, \
-#                      indices=indices, default_rate = default_rate)
-#
-#
-#        # Apply Operator
-#        domain.set_starttime(360.0)
-#        domain.timestep = 1.0
-#
-#        operator()
-#
-#
-#        d = domain.get_time()**2 * factor + 1.0
-#        stage_ex0 = [ d,  d,   1.,  d]
-#
-##        print d, domain.get_time(), F(360.0)
-#
-##        print domain.quantities['elevation'].centroid_values
-##        print domain.quantities['stage'].centroid_values
-##        print domain.quantities['xmomentum'].centroid_values
-##        print domain.quantities['ymomentum'].centroid_values
-#
-#        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex0)
-#        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
-#        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
-#
-#
-#        domain.set_starttime(-10.0)
-#        domain.timestep = 1.0
-#
-#        try:
-#            operator()
-#        except:
-#            pass
-#        else:
-#            raise Exception('Should have raised an exception, time too early')
-#
-#
-#        domain.set_starttime(1300.0)
-#        domain.timestep = 1.0
-#
-#        operator()
-#
-#        d = default_rate*factor + d
-#        stage_ex1 = [ d,  d,   1.,  d]
-#
-##        print domain.quantities['elevation'].centroid_values
-##        print domain.quantities['stage'].centroid_values
-##        print domain.quantities['xmomentum'].centroid_values
-##        print domain.quantities['ymomentum'].centroid_values
-#
-#        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex1)
-#        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
-#        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
-
-
-#    def test_rate_operator_functions_rate_default_rate(self):
-#        from anuga.config import rho_a, rho_w, eta_w
-#        from math import pi, cos, sin
-#
-#        a = [0.0, 0.0]
-#        b = [0.0, 2.0]
-#        c = [2.0, 0.0]
-#        d = [0.0, 4.0]
-#        e = [2.0, 2.0]
-#        f = [4.0, 0.0]
-#
-#        points = [a, b, c, d, e, f]
-#        #             bac,     bce,     ecf,     dbe
-#        vertices = [[1,0,2], [1,2,4], [4,2,5], [3,1,4]]
-#
-#        domain = Domain(points, vertices)
-#
-#        #Flat surface with 1m of water
-#        domain.set_quantity('elevation', 0)
-#        domain.set_quantity('stage', 1.0)
-#        domain.set_quantity('friction', 0)
-#
-#        Br = Reflective_boundary(domain)
-#        domain.set_boundary({'exterior': Br})
-#
-#        verbose = False
-#
-#        if verbose:
-#            print domain.quantities['elevation'].centroid_values
-#            print domain.quantities['stage'].centroid_values
-#            print domain.quantities['xmomentum'].centroid_values
-#            print domain.quantities['ymomentum'].centroid_values
-#
-#        # Apply operator to these triangles
-#        indices = [0,1,3]
-#        factor = 10.0
-#
-#
-#        def main_rate(t):
-#            if t > 20:
-#                msg = 'Model time exceeded.'
-#                raise Modeltime_too_late, msg
-#            else:
-#                return 3.0 * t + 7.0
-#
-#        default_rate = lambda t: 3*t + 7
-#
-#
-#        operator = Rate_operator(domain, rate=main_rate, factor=factor, \
-#                      indices=indices, default_rate = default_rate)
-#
-#
-#        # Apply Operator
-#        domain.timestep = 2.0
-#        operator()
-#
-#        t = operator.get_time()
-#        d = operator.get_timestep()*main_rate(t)*factor + 1
-#        stage_ex = [ d,  d,   1.,  d]
-#
-#        if verbose:
-#            print domain.quantities['elevation'].centroid_values
-#            print domain.quantities['stage'].centroid_values
-#            print domain.quantities['xmomentum'].centroid_values
-#            print domain.quantities['ymomentum'].centroid_values
-#
-#        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
-#        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
-#        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
-#
-#        domain.set_starttime(30.0)
-#        domain.timestep = 1.0
-#        operator()
-#
-#        t = operator.get_time()
-#        d = operator.get_timestep()*default_rate(t)*factor + d
-#        stage_ex = [ d,  d,   1.,  d]
-#
-#        if verbose:
-#            print domain.quantities['elevation'].centroid_values
-#            print domain.quantities['stage'].centroid_values
-#            print domain.quantities['xmomentum'].centroid_values
-#            print domain.quantities['ymomentum'].centroid_values
-#
-#        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
-#        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
-#        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
-
-            
-if __name__ == "__main__":
-    suite = unittest.makeSuite(Test_erosion_operators, 'test')
-    runner = unittest.TextTestRunner(verbosity=1)
-    runner.run(suite)
Index: unk/anuga_core/source/anuga/operators/test_kinematic_viscosity_operator.py
===================================================================
--- /trunk/anuga_core/source/anuga/operators/test_kinematic_viscosity_operator.py	(revision 9444)
+++ 	(revision )
@@ -1,1357 +1,0 @@
-import operator
-from anuga import Domain
-from anuga import Quantity
-from anuga import Dirichlet_boundary
-from kinematic_viscosity_operator import Kinematic_viscosity_operator
-
-import numpy as num
-from math import sqrt
-import unittest
-
-class Test_kinematic_viscosity(unittest.TestCase):
-    
-    def setUp(self):
-        pass
-
-    def tearDown(self):
-        pass
-    
-    #First test operator class (1 triangle)
-    def operator1(self):
-        points = num.array([[0.0,0.0],[1.0,0.0],[0.0,1.0]])
-        elements = num.array([[0,1,2]])
-        boundary_map = {}
-        boundary_map[(0,0)] = 'edge0'
-        boundary_map[(0,1)] = 'edge1'
-        boundary_map[(0,2)] = 'edge2'
-        domain = Domain(coordinates=points,vertices=elements,boundary=boundary_map)
-
-        D0 = Dirichlet_boundary([1,0,3])
-        D1 = Dirichlet_boundary([2,1,0])
-        D2 = Dirichlet_boundary([3,1,2])
-        domain.set_boundary({'edge0': D0, 'edge1': D1, 'edge2': D2})
-
-        domain.set_quantity('stage', lambda x,y : x+2*y )
-        domain.set_quantity('elevation', lambda x,y : 3*x+5*y )
-
-
-
-        #print domain.quantities['stage'].vertex_values
-
-        #print domain.quantities['stage'].edge_values
-
-        domain.update_boundary()
-
-
-        #print domain.quantities['stage'].boundary_values
-        
-        return Kinematic_viscosity_operator(domain)
-
-    #Second test operator class (2 triangles)
-    def operator2(self):
-        points = num.array([[0.0,0.0],[1.0,0.0],[1.0,1.0],[0.0,1.0]])
-        elements = num.array([[0,1,3],[1,2,3]])
-        boundary_map = {}
-        boundary_map[(0,1)] = 'edge0'
-        boundary_map[(0,2)] = 'edge1'
-        boundary_map[(1,0)] = 'edge2'
-        boundary_map[(1,2)] = 'edge3'
-        domain = Domain(coordinates=points,vertices=elements,boundary=boundary_map)
-
-        D0 = Dirichlet_boundary([1,1,2])
-        D1 = Dirichlet_boundary([1,2,2])
-        D2 = Dirichlet_boundary([1,1,0])
-        D3 = Dirichlet_boundary([1,2,1])
-
-        domain.set_boundary({'edge0': D0, 'edge1': D1, 'edge2': D2, 'edge3': D3})
-        domain.update_boundary()
-
-
-
-        return Kinematic_viscosity_operator(domain)
-
-    def test_enumerate_boundary(self):
-        operator1 = self.operator1()
-        boundary_enumeration = operator1.domain.boundary_enumeration
-
-        assert boundary_enumeration[(0,0)] == 0
-        assert boundary_enumeration[(0,1)] == 1
-        assert boundary_enumeration[(0,2)] == 2
-
-        operator2 = self.operator2()
-        boundary_enumeration = operator2.domain.boundary_enumeration
-
-
-        assert boundary_enumeration[(0,1)] == 0
-        assert boundary_enumeration[(0,2)] == 1
-        assert boundary_enumeration[(1,0)] == 2
-        assert boundary_enumeration[(1,2)] == 3
-
-    def test_geo_structure(self):
-        operator1 = self.operator1()
-        indices = operator1.geo_structure_indices
-        values = operator1.geo_structure_values
-
-        assert num.allclose(indices, num.array([[1, 2, 3]]))
-        assert num.allclose(values, num.array([[-6.0, -6.0/sqrt(5), -6.0/sqrt(5)]]))
-
-        operator2 = self.operator2()
-        indices = operator2.geo_structure_indices
-        values = operator2.geo_structure_values
-        assert num.allclose(indices, num.array([[1,2,3],[4,0,5]]))
-        assert num.allclose(values, num.array([[-3.0,-6.0/sqrt(5),-6.0/sqrt(5)],[-6.0/sqrt(5),-3.0,-6.0/sqrt(5)]]))
-
-    def test_elliptic_matrix_one_triangle(self):
-
-        operator = self.operator1()
-        domain = operator.domain
-
-        a = Quantity(operator.domain)
-        a.set_values(1.0)
-        a.set_boundary_values(1.0)
-        
-        operator.update_elliptic_matrix(a)
-
-        A = operator.elliptic_matrix
-
-        assert num.allclose(A.todense(), num.array([-6.0-12.0/sqrt(5), 6.0,  6.0/sqrt(5), 6.0/sqrt(5)]))
-
-        a.set_values(10.0)
-        a.set_boundary_values(10.0)
-        
-        operator.update_elliptic_matrix(a)
-
-        assert num.allclose(A.todense(), 10*num.array([-6.0-12.0/sqrt(5), 6.0,  6.0/sqrt(5), 6.0/sqrt(5)]))
-    
-
-    def test_elliptic_matrix_two_triangles(self):
-
-
-        operator = self.operator2()
-
-        domain = operator.domain
-
-        a = Quantity(operator.domain)
-        a.set_values(1.0)
-        a.set_boundary_values(1.0)
-        operator.update_elliptic_matrix(a)
-
-        A = operator.elliptic_matrix
-
-    
-        A0 = num.array([[-3.0,3.0,0.0,0.0,0.0,0.0],
-                        [0.0,-6.0/sqrt(5.0),0.0,0.0,6.0/sqrt(5.0),0.0]])
-        A1 = num.array([[-6.0/sqrt(5.0),0.0,6.0/sqrt(5.0),0.0,0.0,0.0],\
-                        [3.0,-3.0,0.0,0.0,0.0,0.0]])
-        A2 = num.array([[-6.0/sqrt(5.0),0.0,0.0,6.0/sqrt(5.0),0.0,0.0],\
-                        [0.0, -6.0/sqrt(5.0), 0.0, 0.0, 0.0, 6.0/sqrt(5.0)]])
-
-
-        assert num.allclose(A.todense(), A0+A1+A2)
-
-        a.set_values([2.0, 1.0], location = 'centroids')
-        a.set_boundary_values(1.0)
-        operator.update_elliptic_matrix(a)
-
-        A = operator.elliptic_matrix
-        
-
-        assert num.allclose(A.todense()[0,:], 1.5*A0[0,:]+1.5*A1[0,:]+1.5*A2[0,:])
-        assert num.allclose(A.todense()[1,:], A0[1,:]+1.5*A1[1,:]+A2[1,:])
-
-        # Either negative values we set matrix row to zero
-        a.set_values([-2.0, -2.0], location = 'centroids')
-        a.set_boundary_values(1.0)
-        operator.update_elliptic_matrix(a)
-
-
-
-        assert num.allclose(A.todense()[0,:], 0.0)
-        assert num.allclose(A.todense()[1,:], 0.0)
-
-    def test_elliptic_multiply_include_boundary_one_triangle(self):
-        operator = self.operator1()
-        operator.set_triangle_areas(False)
-
-        print operator.apply_triangle_areas
-
-        a = Quantity(operator.domain)
-        a.set_values(1.0)
-        a.set_boundary_values(1.0)
-
-        operator.update_elliptic_matrix()
-
-        
-
-        q_in = Quantity(operator.domain)
-        q_in.set_values(1.0)
-        q_in.set_boundary_values(1.0)
-        
-        n = operator.n
-        
-        A = num.array([-6.0-12.0/sqrt(5), 6.0,  6.0/sqrt(5), 6.0/sqrt(5)])
-
-
-        q_1 = operator.elliptic_multiply(q_in)
-
-        q_2 = operator.elliptic_multiply(q_in, quantity_out = q_in)
-
-        assert id(q_in) == id(q_2)
-
-        assert num.allclose(q_1.centroid_values,q_2.centroid_values)
-
-        assert num.allclose( num.zeros((n,), num.float), q_1.centroid_values )
-
-        #Now have different boundary values
-
-        q_in.set_values(1.0)
-        q_in.set_boundary_values(0.0)
-        operator.update_elliptic_matrix(a)
-
-
-        A = num.array([-6.0-12.0/sqrt(5), 6.0,  6.0/sqrt(5), 6.0/sqrt(5)])
-
-
-        q_1 = operator.elliptic_multiply(q_in)
-
-        assert num.allclose( [-6.0-12.0/sqrt(5)], q_1.centroid_values )
-        
-    def test_elliptic_multiply_exclude_boundary_one_triangle(self):
-        operator = self.operator1()
-        operator.set_triangle_areas(False)
-
-        print operator.apply_triangle_areas
-        #n = operator.n
-
-        q_in = Quantity(operator.domain)
-        q_in.set_values(1.0)
-        q_in.set_boundary_values(1.0)
-        operator.update_elliptic_matrix()
-
-
-        A = num.array([-6.0-12.0/sqrt(5), 6.0,  6.0/sqrt(5), 6.0/sqrt(5)])
-
-
-        q_1 = operator.elliptic_multiply(q_in, include_boundary=False)
-
-
-        assert num.allclose( [-6.0-12.0/sqrt(5)], q_1.centroid_values )
-
-    def test_elliptic_multiply_include_boundary_one_triangle(self):
-        operator = self.operator1()
-        operator.set_triangle_areas(True)
-
-        n = operator.n
-
-        q_in = Quantity(operator.domain)
-        q_in.set_values(1.0)
-        q_in.set_boundary_values(1.0)
-        
-        operator.update_elliptic_matrix()
-
-
-        A = num.array([-6.0-12.0/sqrt(5), 6.0,  6.0/sqrt(5), 6.0/sqrt(5)])
-
-
-        q_1 = operator.elliptic_multiply(q_in)
-
-        q_2 = operator.elliptic_multiply(q_in, output = q_in)
-
-        assert id(q_in) == id(q_2)
-
-        assert num.allclose(q_1.centroid_values,q_2.centroid_values)
-
-        assert num.allclose( [-12.0-24.0/sqrt(5)], q_1.centroid_values )
-
-        #Now have different boundary values
-
-        q_in.set_values(1.0)
-        q_in.set_boundary_values(0.0)
-        operator.update_elliptic_matrix()
-
-
-        A = num.array([-6.0-12.0/sqrt(5), 6.0,  6.0/sqrt(5), 6.0/sqrt(5)])
-
-
-        q_1 = operator.elliptic_multiply(q_in)
-
-        assert num.allclose( [-12.0-24.0/sqrt(5)], q_1.centroid_values )
-
-    def test_elliptic_multiply_exclude_boundary_one_triangle(self):
-        operator = self.operator1()
-        operator.set_triangle_areas(True)
-
-        q_in = Quantity(operator.domain)
-        q_in.set_values(1.0)
-        q_in.set_boundary_values(1.0)
-        operator.update_elliptic_matrix()
-
-
-        A = num.array([-6.0-12.0/sqrt(5), 6.0,  6.0/sqrt(5), 6.0/sqrt(5)])
-
-
-        q_1 = operator.elliptic_multiply(q_in)
-
-
-        assert num.allclose( [-12.0-24.0/sqrt(5)], q_1.centroid_values )
-
-    def test_mul_arg(self):
-        operator = self.operator1()
-
-        u = Quantity(operator.domain)
-        u.set_values(2.0)
-        #q boundary_values should equal 0.0
-
-
-
-        operator.update_elliptic_boundary_term(u)
-
-        r = 2.0
-
-        try:
-            q_out = operator * 2.0
-        except TypeError:
-            pass
-        else:
-            raise Exception('Should have caught an TypeError')
-
-
-    def test_mul(self):
-        operator = self.operator1()
-
-        u = Quantity(operator.domain)
-        u.set_values(2.0)
-        #q boundary_values should equal 0.0
-
-        operator.update_elliptic_matrix()
-
-        operator.update_elliptic_boundary_term(u)
-
-        A = num.array([-6.0-12.0/sqrt(5), 6.0,  6.0/sqrt(5), 6.0/sqrt(5)])
-        V1 = num.array([2.0]) #u=2
-        U1 = num.array([[2.0],[0.0],[0.0],[0.0]])
-
-        q_out = operator * u
-        
-        assert num.allclose(q_out.centroid_values, 2*num.array(num.mat(A)*num.mat(U1)).reshape(1,))
-
-    def test_elliptic_solve_one_triangle(self):
-
-        operator = self.operator1()
-        n = operator.n
-        
-        U = num.array([2.0,2.0,1.0,1.0])
-
-        u_in = Quantity(operator.domain)
-        u_in.set_values(U[:1], location='centroids')
-        u_in.set_boundary_values(U[1:])
-
-        a = Quantity(operator.domain)
-        a.set_values(1.0)
-        a.set_boundary_values(1.0)
-
-        # Do this to get access to the matrix
-        # This is also called inside elliptic_solve
-        operator.update_elliptic_matrix(a)
-
-        V = num.array([2.0]) #h=1, u=2
-        A = num.array([-6.0-12.0/sqrt(5), 6.0,  6.0/sqrt(5), 6.0/sqrt(5)])
-        #U = num.array([[2.0,2.0],[2.0,1.0],[1.0,2.0],[1.0,0.0]])
-
-        #Setup up rhs as b = A u
-        X = num.array(2*num.mat(A)*num.mat(U.reshape(4,1))).reshape(1,)
-        b = Quantity(operator.domain)
-        b.set_values(X, location='centroids')
-
-        u_in.set_values(0.0)
-
-        u_out = operator.elliptic_solve(u_in, b, a, iprint=1)
-
-        assert num.allclose(u_out.centroid_values, U[:n])
-
-
-    def test_elliptic_solve_two_triangle(self):
-
-        operator = self.operator2()
-        n = operator.n
-        
-        U = num.array([2.0,3.0,1.0,1.0,4.0,3.0])
-
-        u_in = Quantity(operator.domain)
-        u_in.set_values(U[:2], location='centroids')
-        u_in.set_boundary_values(U[2:])
-
-        a = Quantity(operator.domain)
-        a.set_values(1.0)
-        a.set_boundary_values(1.0)
-
-        # Do this to get access to the matrix
-        # This is also called inside elliptic_solve
-        operator.update_elliptic_matrix(a)
-
-        V1 = U[:n]
-        V2 = U[n:]
-
-        A = num.mat(operator.elliptic_matrix.todense())
-        U = num.mat(U.reshape(6,1))
-
-        #Setup up rhs as b = A u
-        X = num.array(2*A*U).reshape(2,)
-
-        b = Quantity(operator.domain)
-        b.set_values(X, location='centroids')
-
-        u_in.set_values(0.0)
-
-        u_out = operator.elliptic_solve(u_in, b, a, iprint=1)
-
-        assert num.allclose(u_out.centroid_values, V1)
-        assert num.allclose(u_out.boundary_values, V2)
-
-    def test_elliptic_solve_rectangular_cross(self):
-
-        from anuga import rectangular_cross_domain
-
-        m1 = 10
-        n1 = 10
-        domain = rectangular_cross_domain(m1,n1)
-
-        # Diffusivity
-        a = Quantity(domain)
-        a.set_values(1.0)
-        a.set_boundary_values(1.0)
-
-        # Quantity to solve
-        u = Quantity(domain)
-        u.set_values(0.0)
-        u.set_boundary_values(1.0)
-
-        # Quantity for rhs
-        b = Quantity(domain)
-        b.set_values(0.0)
-        b.set_boundary_values(0.0)
-
-        operator = Kinematic_viscosity_operator(domain)
-
-        n = operator.n
-        tot_len = operator.tot_len
-
-        u_out = operator.elliptic_solve(u, b, a, iprint=1)
-    
-        assert num.allclose(u_out.centroid_values, num.ones_like(u_out.centroid_values))
-        assert num.allclose(u_out.boundary_values, num.ones_like(u_out.boundary_values))
-
-
-
-    def test_parabolic_solve_one_triangle(self):
-        operator = self.operator1()
-        n = operator.n
-        dt = operator.dt
-
-        U = num.array([2.0,2.0,1.0,1.0])
-        U_mod = num.array([10.0, 2.0, 1.0, 1.0])
-
-        u_in = Quantity(operator.domain)
-        u_in.set_values(U[:n], location='centroids')
-        u_in.set_boundary_values(U_mod[n:])
-
-        a = Quantity(operator.domain)
-        a.set_values(1.0)
-        a.set_boundary_values(1.0)
-
-
-        V = num.array([2.0])
-        A = num.array([-6.0-12.0/sqrt(5), 6.0,  6.0/sqrt(5), 6.0/sqrt(5)])
-
-        #Setup up rhs
-        X = U_mod[:n] - dt*2*num.array(num.mat(A)*num.mat(U_mod.reshape(4,1))).reshape(n,)
-        b = Quantity(operator.domain)
-        b.set_values(X, location='centroids')
-
-
-        u_out = operator.parabolic_solve(u_in, b, a, iprint=1)
-
-
-        assert num.allclose(u_out.centroid_values, U_mod[:n])
-
-
-    def test_parabolic_solve_two_triangles(self):
-        operator = self.operator2()
-        n = operator.n
-        nt = operator.tot_len
-
-        dt = operator.dt
-
-        U = num.array([2.0,3.0,1.0,1.0,4.0,3.0])
-        U_mod = num.array([4.0,2.0,1.0,1.0,4.0,3.0])
-
-
-        u_in = Quantity(operator.domain)
-        u_in.set_values(U[:n], location='centroids')
-        u_in.set_boundary_values(U_mod[n:])
-
-        a = Quantity(operator.domain)
-        a.set_values(1.0)
-        a.set_boundary_values(1.0)
-
-        operator.update_elliptic_matrix(a)
-
-
-        A = num.array([[-8.36656315,  3., 2.68328157,  2.68328157,  0.,  0. ],
-                       [ 3., -8.36656315 , 0. , 0. ,  2.68328157,  2.68328157]])
-
-        assert num.allclose(A,operator.elliptic_matrix.todense())
-
-
-
-        #Setup up rhs
-        X = U_mod[:n] - dt*2*num.array(num.mat(A)*num.mat(U_mod.reshape(nt,1))).reshape(n,)
-        b = Quantity(operator.domain)
-        b.set_values(X, location='centroids')
-
-
-        u_out = operator.parabolic_solve(u_in, b, a, iprint=1)
-
-
-        assert num.allclose(u_out.centroid_values, U_mod[:n])
-
-    def test_parabolic_solve_rectangular_cross(self):
-
-        from anuga import rectangular_cross_domain
-
-        m1 = 10
-        n1 = 10
-        domain = rectangular_cross_domain(m1,n1)
-
-        # Diffusivity
-        a = Quantity(domain)
-        a.set_values(1.0)
-        a.set_boundary_values(1.0)
-
-        # Quantity initial condition
-        u_in = Quantity(domain)
-        #u_in.set_values( 0.0 )
-        u_in.set_values(lambda x,y : 16.0*x*(1-x)*y*(1-y))
-        u_in.set_boundary_values(0.0)
-
-        # Quantity to solve
-        u_mod = Quantity(domain)
-        u_mod.set_values(lambda x,y : 15.9*x*(1-x)*y*(1-y) )
-        u_mod.set_boundary_values(0.0)
-
-        # Quantity for rhs
-        b = Quantity(domain)
-        b.set_values(0.0)
-        b.set_boundary_values(0.0)
-
-        operator = Kinematic_viscosity_operator(domain)
-
-        dt = 0.01
-        operator.dt = dt
-        n = operator.n
-        nt = operator.tot_len
-
-        operator.update_elliptic_matrix(a)
-
-        A = num.mat(operator.elliptic_matrix.todense())
-        D = num.mat(operator.triangle_areas.todense())
-        U_mod = num.concatenate( (u_mod.centroid_values, u_mod.boundary_values) )
-
-
-        #Setup up rhs
-        X = U_mod[:n] - dt*num.array(D*A*num.mat(U_mod.reshape(nt,1))).reshape(n,)
-        b = Quantity(operator.domain)
-        b.set_values(X, location='centroids')
-
-
-        u_out = operator.parabolic_solve(u_in, b, a, iprint=1, use_dt_tol=False)
-
-        assert num.allclose(u_out.centroid_values, U_mod[:n])
-
-
-    def test_elliptic_solve_rectangular_cross_velocities(self):
-
-        from anuga import rectangular_cross_domain
-        from anuga import Reflective_boundary
-
-        m1 = 10
-        n1 = 10
-        domain = rectangular_cross_domain(m1,n1)
-
-        #
-        domain.set_quantity('elevation', expression='x')
-        domain.set_quantity('friction', 0.03)
-        domain.set_quantity('stage',expression='elevation + 2*x')
-        domain.set_quantity('xmomentum', expression='2*x+3*y')
-        domain.set_quantity('ymomentum', expression='5*x+7*y')
-
-
-        B = Reflective_boundary(domain)
-        domain.set_boundary( {'left': B, 'right': B, 'top': B, 'bottom': B})
-
-        domain.update_boundary()
-        domain.update_centroids_of_velocities_and_height()
-
-
-        a = domain.quantities['height']
-
-        # Quantity to solve
-        u = domain.quantities['xvelocity']
-        u.set_boundary_values(1.0)
-
-
-        v = domain.quantities['yvelocity']
-        v.set_boundary_values(2.0)
-
-        # Quantity for rhs
-        b = Quantity(domain)
-        b.set_values(0.0)
-        b.set_boundary_values(0.0)
-
-        kv = Kinematic_viscosity_operator(domain)
-
-        n = kv.n
-        tot_len = kv.tot_len
-
-        kv.update_elliptic_matrix(a)
-
-        u_out = kv.elliptic_solve(u, b, a, update_matrix=False, iprint=1)
-
-        v_out = kv.elliptic_solve(v, b, a, update_matrix=False, iprint=1)
-
-        assert num.allclose(u_out.centroid_values, num.ones_like(u_out.centroid_values))
-        assert num.allclose(u_out.boundary_values, num.ones_like(u_out.boundary_values))
-
-    def test_parabolic_solve_rectangular_cross_velocities(self):
-
-        from anuga import rectangular_cross_domain
-        from anuga import Reflective_boundary
-
-        m1 = 10
-        n1 = 10
-        domain = rectangular_cross_domain(m1,n1)
-
-        #
-        domain.set_quantity('elevation', expression='x')
-        domain.set_quantity('friction', 0.03)
-        domain.set_quantity('stage',expression='elevation + 2*x')
-        domain.set_quantity('xmomentum', expression='2*x+3*y')
-        domain.set_quantity('ymomentum', expression='5*x+7*y')
-
-
-        B = Reflective_boundary(domain)
-        domain.set_boundary( {'left': B, 'right': B, 'top': B, 'bottom': B})
-
-        domain.update_boundary()
-        domain.update_centroids_of_velocities_and_height()
-
-
-
-
-        h = domain.quantities['height']
-
-        # Quantity to solve
-        u = domain.quantities['xvelocity']
-        u.set_boundary_values(1.0)
-
-
-        v = domain.quantities['yvelocity']
-        v.set_boundary_values(2.0)
-
-        kv = Kinematic_viscosity_operator(domain)
-
-
-        # let's make timestep large so that the final solution will look like
-        #the solution of hte elliptic problem. In this case u -> 1, v -> 2.
-
-        dt = 100.0
-        kv.dt = dt
-        n = kv.n
-        nt = kv.tot_len
-
-        kv.update_elliptic_matrix(h)
-
-        kv.parabolic_solve(u, u, h, u_out=u, update_matrix=False, iprint=1, use_dt_tol=False)
-
-        kv.parabolic_solve(v, v, h, u_out=v, update_matrix=False, iprint=1, use_dt_tol=False)
-
-
-        #print u.centroid_values
-        #print u.boundary_values
-        assert num.allclose(u.centroid_values, num.ones_like(u.centroid_values), rtol=1.0e-1)
-        assert num.allclose(u.boundary_values, num.ones_like(u.boundary_values))
-
-        assert num.allclose(v.centroid_values, 2.0*num.ones_like(v.centroid_values), rtol=1.0e-1)
-        assert num.allclose(v.boundary_values, 2.0*num.ones_like(v.boundary_values))
-
-
-        domain.update_centroids_of_momentum_from_velocity()
-
-        uh = domain.quantities['xmomentum']
-        vh = domain.quantities['ymomentum']
-
-        assert num.allclose(uh.centroid_values, u.centroid_values*h.centroid_values )
-        assert num.allclose(vh.centroid_values, v.centroid_values*h.centroid_values )
-
-
-    def test_parabolic_solve_rectangular_cross_velocities_zero_h(self):
-
-        from anuga import rectangular_cross_domain
-        from anuga import Reflective_boundary
-
-        m1 = 5
-        n1 = 5
-        domain = rectangular_cross_domain(m1,n1)
-
-        #
-        domain.set_quantity('elevation', expression='x')
-        domain.set_quantity('friction', 0.03)
-        domain.set_quantity('stage',expression='elevation + 2*(x-0.5)')
-        domain.set_quantity('xmomentum', expression='2*x+3*y')
-        domain.set_quantity('ymomentum', expression='5*x+7*y')
-
- 
-        w = domain.quantities['stage']
-
-        #print w.centroid_values
-        #print w.boundary_values
-
-        domain.distribute_to_vertices_and_edges()
-
-        #print w.centroid_values
-        #print w.boundary_values
-        
-        B = Reflective_boundary(domain)
-        domain.set_boundary( {'left': B, 'right': B, 'top': B, 'bottom': B})
-
-        domain.update_boundary()
-
-        #print w.centroid_values
-        #print w.boundary_values
-
-        domain.update_centroids_of_velocities_and_height()
-
-
-
-
-        h = domain.quantities['height']
-
-        #print 'h'
-        #print h.centroid_values
-        #print h.boundary_values
-        
-        # Quantity to solve
-        u = domain.quantities['xvelocity']
-        u.set_boundary_values(1.0)
-
-
-        #print 'u'
-        #print u.centroid_values
-        #print u.boundary_values
-
-        v = domain.quantities['yvelocity']
-        v.set_boundary_values(2.0)
-
-        kv = Kinematic_viscosity_operator(domain)
-
-
-        # let's make timestep large so that the final solution will look like
-        #the solution of hte elliptic problem. In this case u -> 1, v -> 2.
-
-        dt = 1000.0
-        kv.dt = dt
-        n = kv.n
-        nt = kv.tot_len
-
-        kv.update_elliptic_matrix(h)
-
-        kv.parabolic_solve(u, u, h, u_out=u, update_matrix=False, iprint=1, use_dt_tol=False)
-
-        kv.parabolic_solve(v, v, h, u_out=v, update_matrix=False, iprint=1, use_dt_tol=False)
-
-        assert num.allclose(u.centroid_values, num.where(h.centroid_values > 0.0, 1.0, 0.0), rtol=1.0e-1)
-        assert num.allclose(u.boundary_values, num.ones_like(u.boundary_values))
-
-        assert num.allclose(v.centroid_values, num.where(h.centroid_values > 0.0, 2.0, 0.0), rtol=1.0e-1)
-        assert num.allclose(v.boundary_values, 2.0*num.ones_like(v.boundary_values))
-
-
-        domain.update_centroids_of_momentum_from_velocity()
-
-        domain.distribute_to_vertices_and_edges()
-        
-        uh = domain.quantities['xmomentum']
-        vh = domain.quantities['ymomentum']
-
-        #print 'uh'
-        #print uh.centroid_values
-        #print uh.boundary_values
-
-        assert num.allclose(uh.centroid_values, u.centroid_values*h.centroid_values )
-        assert num.allclose(vh.centroid_values, v.centroid_values*h.centroid_values )
-
-    def test_kinematic_operator_default(self):
-
-        from anuga import rectangular_cross_domain
-        from anuga import Reflective_boundary
-
-        m1 = 10
-        n1 = 10
-        domain = rectangular_cross_domain(m1,n1)
-
-        #domain.set_flow_algorithm('2_0')
-
-        #
-        domain.set_quantity('elevation', expression='x')
-        domain.set_quantity('friction', 0.03)
-        domain.set_quantity('stage',expression='elevation + 2*(x-0.5)')
-        domain.set_quantity('xmomentum', expression='2*x+3*y')
-        domain.set_quantity('ymomentum', expression='5*x+7*y')
-
-        B = Reflective_boundary(domain)
-        domain.set_boundary( {'left': B, 'right': B, 'top': B, 'bottom': B})
-
-        # kill off the wave with viscosity
-        kv = Kinematic_viscosity_operator(domain)
-
-
-        # let's make timestep large so that the final solution will look like
-        #the solution of hte elliptic problem. In this case u -> 1, v -> 2.
-
-
-        for t in domain.evolve(yieldstep = 1.0, finaltime = 10.0):
-            #domain.write_time()
-            #domain.print_operator_timestepping_statistics()
-            pass
-
-#
-        w  = domain.quantities['stage']
-        uh = domain.quantities['xmomentum']
-        vh = domain.quantities['ymomentum']
-
-        #print 'uh'
-        #print uh.centroid_values
-        #print uh.boundary_values
-
-        #print 'w'
-        #print w.centroid_values
-
-        #from pprint import pprint
-        #pprint(w.centroid_values)
-
-
-        wc = num.array([
-        0.70714365,  0.70714416,  0.70714295,  0.70714222,  0.70714486,
-        0.70714507,  0.70714374,  0.70714601,  0.70714492,  0.70714425,
-        0.70714595,  0.70714437,  0.70714797,  0.70714691,  0.70714697,
-        0.70714845,  0.70714793,  0.70714793,  0.70715033,  0.70714852,
-        0.70715244,  0.70715018,  0.70715176,  0.70715224,  0.70715211,
-        0.70715265,  0.70715351,  0.7071531 ,  0.70715433,  0.70715309,
-        0.70715351,  0.70715472,  0.70715429,  0.70715433,  0.70715487,
-        0.70715523,  0.7071545 ,  0.70715446,  0.70715317,  0.70715564,
-        0.70714142,  0.70714198,  0.70714079,  0.70714299,  0.70714482,
-        0.70714378,  0.70714344,  0.70714377,  0.7071443 ,  0.70714533,
-        0.70714579,  0.70714574,  0.70714906,  0.70714717,  0.70714819,
-        0.70714822,  0.70714976,  0.70714952,  0.70715093,  0.70715077,
-        0.70715217,  0.70715094,  0.70715291,  0.70715188,  0.70715352,
-        0.70715278,  0.707154  ,  0.70715429,  0.70715376,  0.70715309,
-        0.70715446,  0.70715422,  0.70715366,  0.70715453,  0.70715413,
-        0.70715539,  0.70715385,  0.70715412,  0.70715154,  0.70715306,
-        0.70714038,  0.70713905,  0.7071358 ,  0.70713972,  0.70714303,
-        0.7071419 ,  0.70714066,  0.70714219,  0.7071459 ,  0.70714505,
-        0.70714639,  0.70714648,  0.70714833,  0.70714827,  0.70715147,
-        0.70715013,  0.70715194,  0.70715133,  0.70715542,  0.70715345,
-        0.70715296,  0.70715417,  0.70715676,  0.70715521,  0.70715526,
-        0.7071548 ,  0.70715717,  0.70715512,  0.70715381,  0.70715523,
-        0.70715556,  0.70715486,  0.70715482,  0.70715338,  0.70715307,
-        0.70715381,  0.70715132,  0.70715182,  0.70714789,  0.70715086,
-        0.70713443,  0.70713559,  0.70713539,  0.70713615,  0.70714057,
-        0.70713978,  0.70714091,  0.70714102,  0.70714618,  0.70714338,
-        0.70714803,  0.70714858,  0.7071519 ,  0.70715029,  0.70715343,
-        0.70715461,  0.70715589,  0.70715519,  0.7071565 ,  0.70715796,
-        0.70715738,  0.70715845,  0.7071601 ,  0.70715829,  0.70715711,
-        0.70715903,  0.70716011,  0.70715714,  0.7071565 ,  0.70715756,
-        0.70715885,  0.7071556 ,  0.70715386,  0.70715406,  0.70715653,
-        0.70715532,  0.70714813,  0.7071515 ,  0.70715242,  0.70715269,
-        0.70713191,  0.70712961,  0.70712505,  0.70712841,  0.70714097,
-        0.70713808,  0.70713862,  0.7071431 ,  0.70714966,  0.7071463 ,
-        0.70715775,  0.70715666,  0.70715566,  0.7071554 ,  0.7071632 ,
-        0.70716353,  0.70715928,  0.70716244,  0.70716736,  0.70716495,
-        0.70716301,  0.70716635,  0.70717088,  0.70716792,  0.70716369,
-        0.70717007,  0.7071741 ,  0.70716769,  0.70716166,  0.70716991,
-        0.70717294,  0.70716167,  0.70715775,  0.70716057,  0.70715687,
-        0.70715535,  0.70715014,  0.70714766,  0.70714559,  0.70714992,
-        0.7071149 ,  0.70708741,  0.706984  ,  0.70711096,  0.70714367,
-        0.70714831,  0.70713519,  0.7071811 ,  0.70716622,  0.70716603,
-        0.70714155,  0.7071748 ,  0.70716885,  0.70716897,  0.70713548,
-        0.70716966,  0.70716924,  0.70716978,  0.70713561,  0.7071717 ,
-        0.70717389,  0.7071726 ,  0.70713926,  0.70717593,  0.70718002,
-        0.70717761,  0.70714428,  0.70718053,  0.70718062,  0.70718719,
-        0.70715731,  0.70718271,  0.70716238,  0.7071992 ,  0.70715496,
-        0.70716834,  0.70713531,  0.70713099,  0.70700665,  0.7071098 ,
-        0.70634397,  0.70524618,  0.70297607,  0.70514658,  0.70658259,
-        0.70506628,  0.70244401,  0.70497884,  0.70657086,  0.70498266,
-        0.70239779,  0.70496243,  0.7065572 ,  0.7049646 ,  0.70239608,
-        0.70496008,  0.70655538,  0.70496125,  0.70239685,  0.70496177,
-        0.70655883,  0.70496295,  0.70239957,  0.70496624,  0.70656625,
-        0.70496724,  0.70240482,  0.7049756 ,  0.70658803,  0.70497608,
-        0.70241139,  0.70500006,  0.70660425,  0.70499778,  0.70246225,
-        0.70508764,  0.70636798,  0.70516922,  0.70299639,  0.70526838,
-        0.71780931,  0.7506157 ,  0.78399529,  0.75061024,  0.71769206,
-        0.75059929,  0.78398287,  0.75059279,  0.71768281,  0.75059112,
-        0.78397863,  0.75059025,  0.71768261,  0.75058996,  0.78397777,
-        0.75058981,  0.71768268,  0.75058969,  0.78397749,  0.75058967,
-        0.7176832 ,  0.75058972,  0.78397772,  0.75058986,  0.71768421,
-        0.7505901 ,  0.78397859,  0.75059043,  0.71768534,  0.7505909 ,
-        0.78398028,  0.750592  ,  0.71769545,  0.75059388,  0.78398545,
-        0.75060056,  0.71781337,  0.75061163,  0.78399848,  0.75061714,
-        0.81739069,  0.85076296,  0.8841241 ,  0.85076174,  0.81738381,
-        0.85075988,  0.88412183,  0.85075808,  0.81738087,  0.85075718,
-        0.88412031,  0.85075635,  0.81737996,  0.85075599,  0.88411952,
-        0.85075563,  0.81737963,  0.85075548,  0.88411919,  0.8507555 ,
-        0.81738003,  0.85075569,  0.88411972,  0.85075629,  0.81738134,
-        0.85075692,  0.88412133,  0.85075812,  0.81738361,  0.85075914,
-        0.88412387,  0.85076103,  0.81738807,  0.85076269,  0.88412739,
-        0.85076547,  0.81739598,  0.85076786,  0.88413107,  0.85076949,
-        0.91748914,  0.95083916,  0.98417801,  0.95083906,  0.91748809,
-        0.95083882,  0.98417779,  0.95083863,  0.91748731,  0.95083843,
-        0.98417752,  0.9508382 ,  0.91748674,  0.950838  ,  0.9841771 ,
-        0.95083776,  0.91748646,  0.95083764,  0.98417686,  0.95083771,
-        0.91748702,  0.95083794,  0.98417744,  0.95083859,  0.91748864,
-        0.95083927,  0.98417906,  0.95084046,  0.91749107,  0.95084145,
-        0.98418138,  0.95084291,  0.91749397,  0.95084401,  0.98418384,
-        0.95084538,  0.91749653,  0.95084626,  0.98418563,  0.95084686])
-
-
-        #print w.centroid_values - wc
-
-        #print max(w.centroid_values - wc)
-
-        assert num.allclose(w.centroid_values, wc, rtol=2.0e-3)
-
-    def test_kinematic_operator_quantity(self):
-
-        from anuga import rectangular_cross_domain
-        from anuga import Reflective_boundary
-
-        m1 = 10
-        n1 = 10
-        domain = rectangular_cross_domain(m1,n1)
-
-        #domain.set_flow_algorithm('2_0')
-
-        #
-        domain.set_quantity('elevation', expression='x')
-        domain.set_quantity('friction', 0.03)
-        domain.set_quantity('stage',expression='elevation + 2*(x-0.5)')
-        domain.set_quantity('xmomentum', expression='2*x+3*y')
-        domain.set_quantity('ymomentum', expression='5*x+7*y')
-
-        B = Reflective_boundary(domain)
-        domain.set_boundary( {'left': B, 'right': B, 'top': B, 'bottom': B})
-
-
-        Q = Quantity(domain)
-        Q = 2.0
-        # kill off the wave with viscosity
-        kv = Kinematic_viscosity_operator(domain, diffusivity = Q)
-
-
-        # let's make timestep large so that the final solution will look like
-        #the solution of hte elliptic problem. In this case u -> 1, v -> 2.
-
-
-        for t in domain.evolve(yieldstep = 1.0, finaltime = 10.0):
-            #domain.write_time()
-            #domain.print_operator_timestepping_statistics()
-            pass
-
-#
-        w  = domain.quantities['stage']
-        uh = domain.quantities['xmomentum']
-        vh = domain.quantities['ymomentum']
-
-        #print 'uh'
-        #print uh.centroid_values
-        #print uh.boundary_values
-
-        #print 'w'
-        #print w.centroid_values
-
-        #from pprint import pprint
-        #pprint(w.centroid_values)
-
-
-        wc = num.array([
-        0.71624029,  0.71622927,  0.71621675,  0.71623888,  0.71624236,
-        0.71624536,  0.71625157,  0.71625028,  0.71625679,  0.71626609,
-        0.71630233,  0.71627457,  0.71627721,  0.71628666,  0.71633484,
-        0.71629002,  0.71628494,  0.716295  ,  0.7163438 ,  0.71629656,
-        0.71628493,  0.71629656,  0.71634379,  0.71629497,  0.71627716,
-        0.71628999,  0.71633481,  0.7162866 ,  0.71625666,  0.71627448,
-        0.71630224,  0.71626596,  0.71624212,  0.7162501 ,  0.7162514 ,
-        0.71624512,  0.71624   ,  0.7162386 ,  0.71621644,  0.71622896,
-        0.71619869,  0.71615658,  0.71609423,  0.71619602,  0.71627164,
-        0.71623926,  0.71625039,  0.71633719,  0.71638922,  0.71642539,
-        0.71652642,  0.71649892,  0.71646671,  0.71653525,  0.71670614,
-        0.71661869,  0.71649067,  0.71663318,  0.71682302,  0.71665878,
-        0.71649066,  0.71665876,  0.71682295,  0.71663309,  0.71646665,
-        0.71661859,  0.71670596,  0.71653511,  0.71638911,  0.71649877,
-        0.71652622,  0.71642523,  0.71627151,  0.716337  ,  0.71625001,
-        0.71623888,  0.7161983 ,  0.71619554,  0.71609371,  0.71615611,
-        0.71587901,  0.71555375,  0.71521927,  0.71573946,  0.71615663,
-        0.71586493,  0.7156413 ,  0.71615004,  0.71653474,  0.71632223,
-        0.71618825,  0.7165586 ,  0.7168124 ,  0.71668994,  0.71661036,
-        0.7168446 ,  0.71694587,  0.71689337,  0.7167922 ,  0.71693225,
-        0.71694582,  0.71693224,  0.71679212,  0.71689325,  0.71681216,
-        0.71684437,  0.71661004,  0.71668963,  0.71653449,  0.71655826,
-        0.71618788,  0.71632191,  0.71615622,  0.71614967,  0.71564092,
-        0.71586446,  0.7158785 ,  0.71573897,  0.71521879,  0.71555323,
-        0.71415117,  0.71304803,  0.71200401,  0.71333356,  0.71459491,
-        0.71350761,  0.71272705,  0.7140006 ,  0.71526042,  0.71418365,
-        0.71337479,  0.7146592 ,  0.71582149,  0.71478585,  0.71378284,
-        0.7150456 ,  0.71605221,  0.71509271,  0.71396254,  0.71516103,
-        0.71605211,  0.71516102,  0.71396249,  0.71509256,  0.71582115,
-        0.7150454 ,  0.71378271,  0.71478555,  0.71526005,  0.71465889,
-        0.71337454,  0.71418329,  0.71459453,  0.71400022,  0.71272682,
-        0.71350725,  0.71415077,  0.71333321,  0.71200389,  0.71304774,
-        0.70944126,  0.70705883,  0.70442227,  0.70714215,  0.70999341,
-        0.70722667,  0.70436187,  0.70745337,  0.71044978,  0.70748596,
-        0.70427781,  0.70768146,  0.71082549,  0.70772906,  0.70426793,
-        0.70786303,  0.71099495,  0.70788365,  0.70424722,  0.70791928,
-        0.71099502,  0.70791937,  0.70424774,  0.70788396,  0.71082556,
-        0.70786332,  0.70426849,  0.70772935,  0.71044982,  0.70768178,
-        0.7042786 ,  0.70748637,  0.70999356,  0.70745385,  0.70436311,
-        0.70722738,  0.70944169,  0.70714295,  0.70442389,  0.70705981,
-        0.69895933,  0.69463188,  0.68921358,  0.693824  ,  0.698153  ,
-        0.69349963,  0.68725093,  0.69221842,  0.69728195,  0.69180649,
-        0.68463972,  0.69053046,  0.69673179,  0.69018397,  0.68236173,
-        0.68940762,  0.69650961,  0.68925397,  0.68125059,  0.68902719,
-        0.69651034,  0.68902736,  0.6812516 ,  0.68925556,  0.69673305,
-        0.6894096 ,  0.6823656 ,  0.69018707,  0.69728407,  0.69053386,
-        0.68464522,  0.69181074,  0.69815588,  0.69222279,  0.68725717,
-        0.69350432,  0.69896255,  0.69382873,  0.68922015,  0.69463687,
-        0.68375896,  0.6882601 ,  0.69595562,  0.68766298,  0.68105558,
-        0.68673658,  0.69502847,  0.68542815,  0.67770965,  0.68435344,
-        0.69409778,  0.68310537,  0.67491515,  0.68222458,  0.69337943,
-        0.68140117,  0.67356609,  0.68097711,  0.69301997,  0.68071631,
-        0.67356716,  0.68071666,  0.69302027,  0.68097852,  0.6749196 ,
-        0.68140363,  0.69338045,  0.68222808,  0.6777162 ,  0.68310954,
-        0.69409929,  0.68435822,  0.68106317,  0.68543327,  0.69503026,
-        0.68674199,  0.68376697,  0.68766854,  0.69595754,  0.68826575,
-        0.71760631,  0.75094294,  0.78427898,  0.75094168,  0.71760193,
-        0.75093986,  0.78427453,  0.75093415,  0.71758272,  0.7509278 ,
-        0.78426295,  0.75091754,  0.7175572 ,  0.75090919,  0.78424795,
-        0.75089856,  0.71753518,  0.75089163,  0.78423642,  0.75088684,
-        0.71753524,  0.75088686,  0.78423643,  0.75089171,  0.7175573 ,
-        0.75089864,  0.78424798,  0.75090931,  0.71758285,  0.75091768,
-        0.78426303,  0.75092799,  0.7176021 ,  0.75093438,  0.78427472,
-        0.75094013,  0.71760652,  0.75094199,  0.78427929,  0.75094328,
-        0.81761649,  0.85095268,  0.88428788,  0.85095192,  0.81761311,
-        0.8509508 ,  0.88428574,  0.85094833,  0.81760513,  0.8509458 ,
-        0.88428131,  0.85094197,  0.81759506,  0.85093883,  0.88427596,
-        0.85093514,  0.81758753,  0.85093282,  0.88427212,  0.85093123,
-        0.81758749,  0.8509312 ,  0.88427198,  0.85093269,  0.81759494,
-        0.85093494,  0.8842756 ,  0.85093857,  0.81760502,  0.8509417 ,
-        0.88428088,  0.85094557,  0.81761314,  0.85094816,  0.88428543,
-        0.85095073,  0.81761667,  0.85095193,  0.88428775,  0.85095275,
-        0.91762366,  0.95095836,  0.98429205,  0.95095804,  0.91762217,
-        0.95095754,  0.98429102,  0.95095658,  0.91761918,  0.95095558,
-        0.98428903,  0.95095416,  0.91761561,  0.95095297,  0.98428667,
-        0.95095164,  0.91761304,  0.95095078,  0.98428497,  0.95095015,
-        0.91761286,  0.95095007,  0.98428475,  0.95095045,  0.9176151 ,
-        0.95095115,  0.98428605,  0.95095231,  0.91761853,  0.95095342,
-        0.9842882 ,  0.9509548 ,  0.91762161,  0.95095583,  0.98429026,
-        0.95095688,  0.91762327,  0.95095746,  0.98429146,  0.95095784])
-
-
-        #print max(w.centroid_values- wc)
-        assert num.allclose(w.centroid_values, wc, rtol=0.05)
-
-    def test_kinematic_operator_number(self):
-
-        from anuga import rectangular_cross_domain
-        from anuga import Reflective_boundary
-
-        m1 = 10
-        n1 = 10
-        domain = rectangular_cross_domain(m1,n1)
-
-        #domain.set_flow_algorithm('2_0')
-
-        #
-        domain.set_quantity('elevation', expression='x')
-        domain.set_quantity('friction', 0.03)
-        domain.set_quantity('stage',expression='elevation + 2*(x-0.5)')
-        domain.set_quantity('xmomentum', expression='2*x+3*y')
-        domain.set_quantity('ymomentum', expression='5*x+7*y')
-
-        B = Reflective_boundary(domain)
-        domain.set_boundary( {'left': B, 'right': B, 'top': B, 'bottom': B})
-
-        # kill off the wave with viscosity
-        kv = Kinematic_viscosity_operator(domain, diffusivity=2.0)
-
-
-        # let's make timestep large so that the final solution will look like
-        #the solution of hte elliptic problem. In this case u -> 1, v -> 2.
-
-
-        for t in domain.evolve(yieldstep = 1.0, finaltime = 10.0):
-            #domain.write_time()
-            #domain.print_operator_timestepping_statistics()
-            pass
-
-#
-        w  = domain.quantities['stage']
-        uh = domain.quantities['xmomentum']
-        vh = domain.quantities['ymomentum']
-
-        #print 'uh'
-        #print uh.centroid_values
-        #print uh.boundary_values
-
-        #print 'w'
-        #print w.centroid_values
-
-        #from pprint import pprint
-        #pprint(w.centroid_values)
-
-
-        wc = num.array([
-        0.71624029,  0.71622927,  0.71621675,  0.71623888,  0.71624236,
-        0.71624536,  0.71625157,  0.71625028,  0.71625679,  0.71626609,
-        0.71630233,  0.71627457,  0.71627721,  0.71628666,  0.71633484,
-        0.71629002,  0.71628494,  0.716295  ,  0.7163438 ,  0.71629656,
-        0.71628493,  0.71629656,  0.71634379,  0.71629497,  0.71627716,
-        0.71628999,  0.71633481,  0.7162866 ,  0.71625666,  0.71627448,
-        0.71630224,  0.71626596,  0.71624212,  0.7162501 ,  0.7162514 ,
-        0.71624512,  0.71624   ,  0.7162386 ,  0.71621644,  0.71622896,
-        0.71619869,  0.71615658,  0.71609423,  0.71619602,  0.71627164,
-        0.71623926,  0.71625039,  0.71633719,  0.71638922,  0.71642539,
-        0.71652642,  0.71649892,  0.71646671,  0.71653525,  0.71670614,
-        0.71661869,  0.71649067,  0.71663318,  0.71682302,  0.71665878,
-        0.71649066,  0.71665876,  0.71682295,  0.71663309,  0.71646665,
-        0.71661859,  0.71670596,  0.71653511,  0.71638911,  0.71649877,
-        0.71652622,  0.71642523,  0.71627151,  0.716337  ,  0.71625001,
-        0.71623888,  0.7161983 ,  0.71619554,  0.71609371,  0.71615611,
-        0.71587901,  0.71555375,  0.71521927,  0.71573946,  0.71615663,
-        0.71586493,  0.7156413 ,  0.71615004,  0.71653474,  0.71632223,
-        0.71618825,  0.7165586 ,  0.7168124 ,  0.71668994,  0.71661036,
-        0.7168446 ,  0.71694587,  0.71689337,  0.7167922 ,  0.71693225,
-        0.71694582,  0.71693224,  0.71679212,  0.71689325,  0.71681216,
-        0.71684437,  0.71661004,  0.71668963,  0.71653449,  0.71655826,
-        0.71618788,  0.71632191,  0.71615622,  0.71614967,  0.71564092,
-        0.71586446,  0.7158785 ,  0.71573897,  0.71521879,  0.71555323,
-        0.71415117,  0.71304803,  0.71200401,  0.71333356,  0.71459491,
-        0.71350761,  0.71272705,  0.7140006 ,  0.71526042,  0.71418365,
-        0.71337479,  0.7146592 ,  0.71582149,  0.71478585,  0.71378284,
-        0.7150456 ,  0.71605221,  0.71509271,  0.71396254,  0.71516103,
-        0.71605211,  0.71516102,  0.71396249,  0.71509256,  0.71582115,
-        0.7150454 ,  0.71378271,  0.71478555,  0.71526005,  0.71465889,
-        0.71337454,  0.71418329,  0.71459453,  0.71400022,  0.71272682,
-        0.71350725,  0.71415077,  0.71333321,  0.71200389,  0.71304774,
-        0.70944126,  0.70705883,  0.70442227,  0.70714215,  0.70999341,
-        0.70722667,  0.70436187,  0.70745337,  0.71044978,  0.70748596,
-        0.70427781,  0.70768146,  0.71082549,  0.70772906,  0.70426793,
-        0.70786303,  0.71099495,  0.70788365,  0.70424722,  0.70791928,
-        0.71099502,  0.70791937,  0.70424774,  0.70788396,  0.71082556,
-        0.70786332,  0.70426849,  0.70772935,  0.71044982,  0.70768178,
-        0.7042786 ,  0.70748637,  0.70999356,  0.70745385,  0.70436311,
-        0.70722738,  0.70944169,  0.70714295,  0.70442389,  0.70705981,
-        0.69895933,  0.69463188,  0.68921358,  0.693824  ,  0.698153  ,
-        0.69349963,  0.68725093,  0.69221842,  0.69728195,  0.69180649,
-        0.68463972,  0.69053046,  0.69673179,  0.69018397,  0.68236173,
-        0.68940762,  0.69650961,  0.68925397,  0.68125059,  0.68902719,
-        0.69651034,  0.68902736,  0.6812516 ,  0.68925556,  0.69673305,
-        0.6894096 ,  0.6823656 ,  0.69018707,  0.69728407,  0.69053386,
-        0.68464522,  0.69181074,  0.69815588,  0.69222279,  0.68725717,
-        0.69350432,  0.69896255,  0.69382873,  0.68922015,  0.69463687,
-        0.68375896,  0.6882601 ,  0.69595562,  0.68766298,  0.68105558,
-        0.68673658,  0.69502847,  0.68542815,  0.67770965,  0.68435344,
-        0.69409778,  0.68310537,  0.67491515,  0.68222458,  0.69337943,
-        0.68140117,  0.67356609,  0.68097711,  0.69301997,  0.68071631,
-        0.67356716,  0.68071666,  0.69302027,  0.68097852,  0.6749196 ,
-        0.68140363,  0.69338045,  0.68222808,  0.6777162 ,  0.68310954,
-        0.69409929,  0.68435822,  0.68106317,  0.68543327,  0.69503026,
-        0.68674199,  0.68376697,  0.68766854,  0.69595754,  0.68826575,
-        0.71760631,  0.75094294,  0.78427898,  0.75094168,  0.71760193,
-        0.75093986,  0.78427453,  0.75093415,  0.71758272,  0.7509278 ,
-        0.78426295,  0.75091754,  0.7175572 ,  0.75090919,  0.78424795,
-        0.75089856,  0.71753518,  0.75089163,  0.78423642,  0.75088684,
-        0.71753524,  0.75088686,  0.78423643,  0.75089171,  0.7175573 ,
-        0.75089864,  0.78424798,  0.75090931,  0.71758285,  0.75091768,
-        0.78426303,  0.75092799,  0.7176021 ,  0.75093438,  0.78427472,
-        0.75094013,  0.71760652,  0.75094199,  0.78427929,  0.75094328,
-        0.81761649,  0.85095268,  0.88428788,  0.85095192,  0.81761311,
-        0.8509508 ,  0.88428574,  0.85094833,  0.81760513,  0.8509458 ,
-        0.88428131,  0.85094197,  0.81759506,  0.85093883,  0.88427596,
-        0.85093514,  0.81758753,  0.85093282,  0.88427212,  0.85093123,
-        0.81758749,  0.8509312 ,  0.88427198,  0.85093269,  0.81759494,
-        0.85093494,  0.8842756 ,  0.85093857,  0.81760502,  0.8509417 ,
-        0.88428088,  0.85094557,  0.81761314,  0.85094816,  0.88428543,
-        0.85095073,  0.81761667,  0.85095193,  0.88428775,  0.85095275,
-        0.91762366,  0.95095836,  0.98429205,  0.95095804,  0.91762217,
-        0.95095754,  0.98429102,  0.95095658,  0.91761918,  0.95095558,
-        0.98428903,  0.95095416,  0.91761561,  0.95095297,  0.98428667,
-        0.95095164,  0.91761304,  0.95095078,  0.98428497,  0.95095015,
-        0.91761286,  0.95095007,  0.98428475,  0.95095045,  0.9176151 ,
-        0.95095115,  0.98428605,  0.95095231,  0.91761853,  0.95095342,
-        0.9842882 ,  0.9509548 ,  0.91762161,  0.95095583,  0.98429026,
-        0.95095688,  0.91762327,  0.95095746,  0.98429146,  0.95095784])
-
-
-
-
-        #print w.centroid_values - wc
-
-        #print max(w.centroid_values - wc)
-        assert num.allclose(w.centroid_values, wc, rtol=0.05)
-
-
-
-
-    def test_kinematic_operator_string(self):
-
-        from anuga import rectangular_cross_domain
-        from anuga import Reflective_boundary
-
-        m1 = 10
-        n1 = 10
-        domain = rectangular_cross_domain(m1,n1)
-
-        #domain.set_flow_algorithm('2_0')
-
-        #
-        domain.set_quantity('elevation', expression='x')
-        domain.set_quantity('friction', 0.03)
-        domain.set_quantity('stage',expression='elevation + 2*(x-0.5)')
-        domain.set_quantity('xmomentum', expression='2*x+3*y')
-        domain.set_quantity('ymomentum', expression='5*x+7*y')
-
-        B = Reflective_boundary(domain)
-        domain.set_boundary( {'left': B, 'right': B, 'top': B, 'bottom': B})
-
-        # kill off the wave with viscosity
-        kv = Kinematic_viscosity_operator(domain, diffusivity = 'height')
-
-
-        # let's make timestep large so that the final solution will look like
-        #the solution of hte elliptic problem. In this case u -> 1, v -> 2.
-
-
-        for t in domain.evolve(yieldstep = 1.0, finaltime = 10.0):
-            #domain.write_time()
-            #domain.print_operator_timestepping_statistics()
-            pass
-
-#
-        w  = domain.quantities['stage']
-        uh = domain.quantities['xmomentum']
-        vh = domain.quantities['ymomentum']
-
-        #print 'uh'
-        #print uh.centroid_values
-        #print uh.boundary_values
-
-        #print 'w'
-        #print w.centroid_values
-
-        #from pprint import pprint
-        #pprint(w.centroid_values)
-
-
-        wc = num.array([
-        0.70714365,  0.70714416,  0.70714295,  0.70714222,  0.70714486,
-        0.70714507,  0.70714374,  0.70714601,  0.70714492,  0.70714425,
-        0.70714595,  0.70714437,  0.70714797,  0.70714691,  0.70714697,
-        0.70714845,  0.70714793,  0.70714793,  0.70715033,  0.70714852,
-        0.70715244,  0.70715018,  0.70715176,  0.70715224,  0.70715211,
-        0.70715265,  0.70715351,  0.7071531 ,  0.70715433,  0.70715309,
-        0.70715351,  0.70715472,  0.70715429,  0.70715433,  0.70715487,
-        0.70715523,  0.7071545 ,  0.70715446,  0.70715317,  0.70715564,
-        0.70714142,  0.70714198,  0.70714079,  0.70714299,  0.70714482,
-        0.70714378,  0.70714344,  0.70714377,  0.7071443 ,  0.70714533,
-        0.70714579,  0.70714574,  0.70714906,  0.70714717,  0.70714819,
-        0.70714822,  0.70714976,  0.70714952,  0.70715093,  0.70715077,
-        0.70715217,  0.70715094,  0.70715291,  0.70715188,  0.70715352,
-        0.70715278,  0.707154  ,  0.70715429,  0.70715376,  0.70715309,
-        0.70715446,  0.70715422,  0.70715366,  0.70715453,  0.70715413,
-        0.70715539,  0.70715385,  0.70715412,  0.70715154,  0.70715306,
-        0.70714038,  0.70713905,  0.7071358 ,  0.70713972,  0.70714303,
-        0.7071419 ,  0.70714066,  0.70714219,  0.7071459 ,  0.70714505,
-        0.70714639,  0.70714648,  0.70714833,  0.70714827,  0.70715147,
-        0.70715013,  0.70715194,  0.70715133,  0.70715542,  0.70715345,
-        0.70715296,  0.70715417,  0.70715676,  0.70715521,  0.70715526,
-        0.7071548 ,  0.70715717,  0.70715512,  0.70715381,  0.70715523,
-        0.70715556,  0.70715486,  0.70715482,  0.70715338,  0.70715307,
-        0.70715381,  0.70715132,  0.70715182,  0.70714789,  0.70715086,
-        0.70713443,  0.70713559,  0.70713539,  0.70713615,  0.70714057,
-        0.70713978,  0.70714091,  0.70714102,  0.70714618,  0.70714338,
-        0.70714803,  0.70714858,  0.7071519 ,  0.70715029,  0.70715343,
-        0.70715461,  0.70715589,  0.70715519,  0.7071565 ,  0.70715796,
-        0.70715738,  0.70715845,  0.7071601 ,  0.70715829,  0.70715711,
-        0.70715903,  0.70716011,  0.70715714,  0.7071565 ,  0.70715756,
-        0.70715885,  0.7071556 ,  0.70715386,  0.70715406,  0.70715653,
-        0.70715532,  0.70714813,  0.7071515 ,  0.70715242,  0.70715269,
-        0.70713191,  0.70712961,  0.70712505,  0.70712841,  0.70714097,
-        0.70713808,  0.70713862,  0.7071431 ,  0.70714966,  0.7071463 ,
-        0.70715775,  0.70715666,  0.70715566,  0.7071554 ,  0.7071632 ,
-        0.70716353,  0.70715928,  0.70716244,  0.70716736,  0.70716495,
-        0.70716301,  0.70716635,  0.70717088,  0.70716792,  0.70716369,
-        0.70717007,  0.7071741 ,  0.70716769,  0.70716166,  0.70716991,
-        0.70717294,  0.70716167,  0.70715775,  0.70716057,  0.70715687,
-        0.70715535,  0.70715014,  0.70714766,  0.70714559,  0.70714992,
-        0.7071149 ,  0.70708741,  0.706984  ,  0.70711096,  0.70714367,
-        0.70714831,  0.70713519,  0.7071811 ,  0.70716622,  0.70716603,
-        0.70714155,  0.7071748 ,  0.70716885,  0.70716897,  0.70713548,
-        0.70716966,  0.70716924,  0.70716978,  0.70713561,  0.7071717 ,
-        0.70717389,  0.7071726 ,  0.70713926,  0.70717593,  0.70718002,
-        0.70717761,  0.70714428,  0.70718053,  0.70718062,  0.70718719,
-        0.70715731,  0.70718271,  0.70716238,  0.7071992 ,  0.70715496,
-        0.70716834,  0.70713531,  0.70713099,  0.70700665,  0.7071098 ,
-        0.70634397,  0.70524618,  0.70297607,  0.70514658,  0.70658259,
-        0.70506628,  0.70244401,  0.70497884,  0.70657086,  0.70498266,
-        0.70239779,  0.70496243,  0.7065572 ,  0.7049646 ,  0.70239608,
-        0.70496008,  0.70655538,  0.70496125,  0.70239685,  0.70496177,
-        0.70655883,  0.70496295,  0.70239957,  0.70496624,  0.70656625,
-        0.70496724,  0.70240482,  0.7049756 ,  0.70658803,  0.70497608,
-        0.70241139,  0.70500006,  0.70660425,  0.70499778,  0.70246225,
-        0.70508764,  0.70636798,  0.70516922,  0.70299639,  0.70526838,
-        0.71780931,  0.7506157 ,  0.78399529,  0.75061024,  0.71769206,
-        0.75059929,  0.78398287,  0.75059279,  0.71768281,  0.75059112,
-        0.78397863,  0.75059025,  0.71768261,  0.75058996,  0.78397777,
-        0.75058981,  0.71768268,  0.75058969,  0.78397749,  0.75058967,
-        0.7176832 ,  0.75058972,  0.78397772,  0.75058986,  0.71768421,
-        0.7505901 ,  0.78397859,  0.75059043,  0.71768534,  0.7505909 ,
-        0.78398028,  0.750592  ,  0.71769545,  0.75059388,  0.78398545,
-        0.75060056,  0.71781337,  0.75061163,  0.78399848,  0.75061714,
-        0.81739069,  0.85076296,  0.8841241 ,  0.85076174,  0.81738381,
-        0.85075988,  0.88412183,  0.85075808,  0.81738087,  0.85075718,
-        0.88412031,  0.85075635,  0.81737996,  0.85075599,  0.88411952,
-        0.85075563,  0.81737963,  0.85075548,  0.88411919,  0.8507555 ,
-        0.81738003,  0.85075569,  0.88411972,  0.85075629,  0.81738134,
-        0.85075692,  0.88412133,  0.85075812,  0.81738361,  0.85075914,
-        0.88412387,  0.85076103,  0.81738807,  0.85076269,  0.88412739,
-        0.85076547,  0.81739598,  0.85076786,  0.88413107,  0.85076949,
-        0.91748914,  0.95083916,  0.98417801,  0.95083906,  0.91748809,
-        0.95083882,  0.98417779,  0.95083863,  0.91748731,  0.95083843,
-        0.98417752,  0.9508382 ,  0.91748674,  0.950838  ,  0.9841771 ,
-        0.95083776,  0.91748646,  0.95083764,  0.98417686,  0.95083771,
-        0.91748702,  0.95083794,  0.98417744,  0.95083859,  0.91748864,
-        0.95083927,  0.98417906,  0.95084046,  0.91749107,  0.95084145,
-        0.98418138,  0.95084291,  0.91749397,  0.95084401,  0.98418384,
-        0.95084538,  0.91749653,  0.95084626,  0.98418563,  0.95084686])
-
-
-        #print max(w.centroid_values - wc)
-
-        assert num.allclose(w.centroid_values, wc, rtol=2.0e-3)
-
-
-################################################################################
-
-if __name__ == "__main__":
-    suite = unittest.makeSuite(Test_kinematic_viscosity, 'test')
-    runner = unittest.TextTestRunner()
-    runner.run(suite)
Index: unk/anuga_core/source/anuga/operators/test_rate_operators.py
===================================================================
--- /trunk/anuga_core/source/anuga/operators/test_rate_operators.py	(revision 9444)
+++ 	(revision )
@@ -1,879 +1,0 @@
-"""  Test environmental forcing - rain, wind, etc.
-"""
-import operator
-
-import unittest, os
-import anuga
-import numpy
-from anuga import Domain
-from anuga import Reflective_boundary
-from anuga import rectangular_cross_domain
-from anuga import file_function
-
-from anuga.config import netcdf_mode_r, netcdf_mode_w, netcdf_mode_a
-from anuga.file_conversion.file_conversion import timefile2netcdf
-from anuga.config import time_format
-
-from anuga.fit_interpolate.interpolate import Modeltime_too_early
-from anuga.fit_interpolate.interpolate import Modeltime_too_late
-
-from rate_operators import *
-
-import numpy as num
-import warnings
-import time
-
-
-warnings.simplefilter("ignore")
-
-
-class Test_rate_operators(unittest.TestCase):
-    def setUp(self):
-        pass
-
-    def tearDown(self):
-        pass
-
-
-    def test_rate_operator_simple(self):
-        from anuga.config import rho_a, rho_w, eta_w
-        from math import pi, cos, sin
-
-        a = [0.0, 0.0]
-        b = [0.0, 2.0]
-        c = [2.0, 0.0]
-        d = [0.0, 4.0]
-        e = [2.0, 2.0]
-        f = [4.0, 0.0]
-
-        points = [a, b, c, d, e, f]
-        #             bac,     bce,     ecf,     dbe
-        vertices = [[1,0,2], [1,2,4], [4,2,5], [3,1,4]]
-
-        domain = Domain(points, vertices)
-
-        #Flat surface with 1m of water
-        domain.set_quantity('elevation', 0)
-        domain.set_quantity('stage', 1.0)
-        domain.set_quantity('friction', 0)
-
-        Br = Reflective_boundary(domain)
-        domain.set_boundary({'exterior': Br})
-
-
-#        print domain.quantities['stage'].centroid_values
-#        print domain.quantities['xmomentum'].centroid_values
-#        print domain.quantities['ymomentum'].centroid_values
-
-        # Apply operator to these triangles
-        indices = [0,1,3]
-
-        rate = 1.0
-        factor = 10.0
-        default_rate= 0.0
-
-        operator = Rate_operator(domain, rate=rate, factor=factor, \
-                      indices=indices, default_rate = default_rate)
-        
-        # Apply Operator
-        domain.timestep = 2.0
-        operator()
-
-        stage_ex = [ 21.,  21.,   1.,  21.]
-
-#        print domain.quantities['stage'].centroid_values
-#        print domain.quantities['xmomentum'].centroid_values
-#        print domain.quantities['ymomentum'].centroid_values
-
-        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
-        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
-        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
-        assert num.allclose(domain.fractional_step_volume_integral, factor*domain.timestep*(rate*domain.areas[indices]).sum())
-
- 
-    def test_rate_operator_negative_rate(self):
-        from anuga.config import rho_a, rho_w, eta_w
-        from math import pi, cos, sin
-
-        a = [0.0, 0.0]
-        b = [0.0, 2.0]
-        c = [2.0, 0.0]
-        d = [0.0, 4.0]
-        e = [2.0, 2.0]
-        f = [4.0, 0.0]
-
-        points = [a, b, c, d, e, f]
-        #             bac,     bce,     ecf,     dbe
-        vertices = [[1,0,2], [1,2,4], [4,2,5], [3,1,4]]
-
-        domain = Domain(points, vertices)
-
-        #Flat surface with 1m of water
-        domain.set_quantity('elevation', 0)
-        domain.set_quantity('stage', 1.0)
-        domain.set_quantity('friction', 0)
-
-        Br = Reflective_boundary(domain)
-        domain.set_boundary({'exterior': Br})
-
-#        print domain.quantities['elevation'].centroid_values
-#        print domain.quantities['stage'].centroid_values
-#        print domain.quantities['xmomentum'].centroid_values
-#        print domain.quantities['ymomentum'].centroid_values
-
-        # Apply operator to these triangles
-        indices = [0,1,3]
-
-
-
-        #Catchment_Rain_Polygon = read_polygon(join('CatchmentBdy.csv'))
-        #rainfall = file_function(join('1y120m.tms'), quantities=['rainfall'])
-        rate = -1.0
-        factor = 10.0
-        default_rate= 0.0
-
-        operator = Rate_operator(domain, rate=rate, factor=factor, \
-                      indices=indices, default_rate = default_rate)
-
-
-        # Apply Operator
-        domain.timestep = 2.0
-        operator()
-
-        stage_ex = [ 0.,  0.,   1.,  0.]
-        step_integral = -6.0
-
-        #print domain.quantities['elevation'].centroid_values
-        #print domain.quantities['stage'].centroid_values
-        #print domain.quantities['xmomentum'].centroid_values
-        #print domain.quantities['ymomentum'].centroid_values
-        #print domain.fractional_step_volume_integral
-        #print factor*domain.timestep*(rate*domain.areas[indices]).sum()
-        
-        #increment = factor*domain.timestep*rate*domain.areas
-        
-        
-
-        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
-        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
-        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
-        assert num.allclose(domain.fractional_step_volume_integral, step_integral)
-
-    def test_rate_operator_negative_rate_full(self):
-        from anuga.config import rho_a, rho_w, eta_w
-        from math import pi, cos, sin
-
-        a = [0.0, 0.0]
-        b = [0.0, 2.0]
-        c = [2.0, 0.0]
-        d = [0.0, 4.0]
-        e = [2.0, 2.0]
-        f = [4.0, 0.0]
-
-        points = [a, b, c, d, e, f]
-        #             bac,     bce,     ecf,     dbe
-        vertices = [[1,0,2], [1,2,4], [4,2,5], [3,1,4]]
-
-        domain = Domain(points, vertices)
-
-        #Flat surface with 1m of water
-        domain.set_quantity('elevation', 0)
-        domain.set_quantity('stage', 10.0)
-        domain.set_quantity('friction', 0)
-
-        Br = Reflective_boundary(domain)
-        domain.set_boundary({'exterior': Br})
-
-#        print domain.quantities['elevation'].centroid_values
-#        print domain.quantities['stage'].centroid_values
-#        print domain.quantities['xmomentum'].centroid_values
-#        print domain.quantities['ymomentum'].centroid_values
-
-        # Apply operator to these triangles
-        indices = [0,1,3]
-
-
-
-        #Catchment_Rain_Polygon = read_polygon(join('CatchmentBdy.csv'))
-        #rainfall = file_function(join('1y120m.tms'), quantities=['rainfall'])
-        rate = -1.0
-        factor = 10.0
-        default_rate= 0.0
-
-        operator = Rate_operator(domain, rate=rate, factor=factor, \
-                      indices=None, default_rate = default_rate)
-
-
-        # Apply Operator
-        domain.timestep = 2.0
-        operator()
-
-        stage_ex = [ 0.,  0.,   0.,  0.]
-        step_integral = -80.0
-
-        #print domain.quantities['elevation'].centroid_values
-        #print domain.quantities['stage'].centroid_values
-        #print domain.quantities['xmomentum'].centroid_values
-        #print domain.quantities['ymomentum'].centroid_values
-        #print domain.fractional_step_volume_integral
-
-
-        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
-        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
-        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
-        assert num.allclose(domain.fractional_step_volume_integral, step_integral)
-        
-    def test_rate_operator_rate_from_file(self):
-        from anuga.config import rho_a, rho_w, eta_w
-        from math import pi, cos, sin
-
-        a = [0.0, 0.0]
-        b = [0.0, 2.0]
-        c = [2.0, 0.0]
-        d = [0.0, 4.0]
-        e = [2.0, 2.0]
-        f = [4.0, 0.0]
-
-        points = [a, b, c, d, e, f]
-        #             bac,     bce,     ecf,     dbe
-        vertices = [[1,0,2], [1,2,4], [4,2,5], [3,1,4]]
-
-
-        #---------------------------------
-        #Typical ASCII file
-        #---------------------------------
-        finaltime = 1200
-        filename = 'test_file_function'
-        fid = open(filename + '.txt', 'w')
-        start = time.mktime(time.strptime('2000', '%Y'))
-        dt = 60  #One minute intervals
-        t = 0.0
-        while t <= finaltime:
-            t_string = time.strftime(time_format, time.gmtime(t+start))
-            fid.write('%s, %f %f %f\n' %(t_string, 2*t, t**2, sin(t*pi/600)))
-            t += dt
-
-        fid.close()
-
-        #Convert ASCII file to NetCDF (Which is what we really like!)
-        timefile2netcdf(filename+'.txt')
-
-
-        #Create file function from time series
-        F = file_function(filename + '.tms',
-                          quantities = ['Attribute0',
-                                        'Attribute1',
-                                        'Attribute2'])
-
-
-        #Now try interpolation
-        for i in range(20):
-            t = i*10
-            q = F(t)
-
-            #Exact linear intpolation
-            assert num.allclose(q[0], 2*t)
-            if i%6 == 0:
-                assert num.allclose(q[1], t**2)
-                assert num.allclose(q[2], sin(t*pi/600))
-
-        #Check non-exact
-
-        t = 90 #Halfway between 60 and 120
-        q = F(t)
-        assert num.allclose( (120**2 + 60**2)/2, q[1] )
-        assert num.allclose( (sin(120*pi/600) + sin(60*pi/600))/2, q[2] )
-
-
-        t = 100 #Two thirds of the way between between 60 and 120
-        q = F(t)
-        assert num.allclose( 2*120**2/3 + 60**2/3, q[1] )
-        assert num.allclose( 2*sin(120*pi/600)/3 + sin(60*pi/600)/3, q[2] )
-
-        #os.remove(filename + '.txt')
-        #os.remove(filename + '.tms')
-
-
-        domain = Domain(points, vertices)
-
-        #Flat surface with 1m of water
-        domain.set_quantity('elevation', 0)
-        domain.set_quantity('stage', 1.0)
-        domain.set_quantity('friction', 0)
-
-        Br = Reflective_boundary(domain)
-        domain.set_boundary({'exterior': Br})
-
-#        print domain.quantities['elevation'].centroid_values
-#        print domain.quantities['stage'].centroid_values
-#        print domain.quantities['xmomentum'].centroid_values
-#        print domain.quantities['ymomentum'].centroid_values
-
-        # Apply operator to these triangles
-        indices = [0,1,3]
-
-
-        rate = file_function('test_file_function.tms', quantities=['Attribute1'])
-
-        factor = 1000.0
-        default_rate= 17.7
-
-        operator = Rate_operator(domain, rate=rate, factor=factor, \
-                      indices=indices, default_rate = default_rate)
-
-
-        # Apply Operator
-        domain.set_starttime(360.0)
-        domain.timestep = 1.0
-
-        operator()
-
-
-        d = domain.get_time()**2 * factor + 1.0
-        stage_ex0 = [ d,  d,   1.,  d]
-
-#        print d, domain.get_time(), F(360.0)
-
-#        print domain.quantities['elevation'].centroid_values
-#        print domain.quantities['stage'].centroid_values
-#        print domain.quantities['xmomentum'].centroid_values
-#        print domain.quantities['ymomentum'].centroid_values
-
-        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex0)
-        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
-        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
-        assert num.allclose(domain.fractional_step_volume_integral, ((d-1.)*domain.areas[indices]).sum())
-
-
-        domain.set_starttime(-10.0)
-        domain.timestep = 1.0
-
-        try:
-            operator()
-        except:
-            pass
-        else:
-            raise Exception('Should have raised an exception, time too early')
-
-
-        domain.set_starttime(1300.0)
-        domain.timestep = 1.0
-
-        operator()
-
-        d = default_rate*factor + d
-        stage_ex1 = [ d,  d,   1.,  d]
-
-#        print domain.quantities['elevation'].centroid_values
-#        print domain.quantities['stage'].centroid_values
-#        print domain.quantities['xmomentum'].centroid_values
-#        print domain.quantities['ymomentum'].centroid_values
-
-        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex1)
-        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
-        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
-        assert num.allclose(domain.fractional_step_volume_integral, ((d-1.)*domain.areas[indices]).sum())
-
-
-    def test_rate_operator_functions_rate_default_rate(self):
-        from anuga.config import rho_a, rho_w, eta_w
-        from math import pi, cos, sin
-
-        a = [0.0, 0.0]
-        b = [0.0, 2.0]
-        c = [2.0, 0.0]
-        d = [0.0, 4.0]
-        e = [2.0, 2.0]
-        f = [4.0, 0.0]
-
-        points = [a, b, c, d, e, f]
-        #             bac,     bce,     ecf,     dbe
-        vertices = [[1,0,2], [1,2,4], [4,2,5], [3,1,4]]
-
-        domain = Domain(points, vertices)
-
-        #Flat surface with 1m of water
-        domain.set_quantity('elevation', 0)
-        domain.set_quantity('stage', 1.0)
-        domain.set_quantity('friction', 0)
-
-        Br = Reflective_boundary(domain)
-        domain.set_boundary({'exterior': Br})
-
-        verbose = False
-        
-        if verbose:
-            print domain.quantities['elevation'].centroid_values
-            print domain.quantities['stage'].centroid_values
-            print domain.quantities['xmomentum'].centroid_values
-            print domain.quantities['ymomentum'].centroid_values
-
-        # Apply operator to these triangles
-        indices = [0,1,3]
-        factor = 10.0
-
-
-        def main_rate(t):
-            if t > 20:
-                msg = 'Model time exceeded.'
-                raise Modeltime_too_late, msg
-            else:
-                return 3.0 * t + 7.0
-
-        default_rate = lambda t: 3*t + 7
-
-
-        operator = Rate_operator(domain, rate=main_rate, factor=factor, \
-                      indices=indices, default_rate = default_rate)
-
-
-        # Apply Operator
-        domain.timestep = 2.0
-        operator()
-
-        t = operator.get_time()
-        d = operator.get_timestep()*main_rate(t)*factor + 1
-        stage_ex = [ d,  d,   1.,  d]
-
-        if verbose:
-            print domain.quantities['elevation'].centroid_values
-            print domain.quantities['stage'].centroid_values
-            print domain.quantities['xmomentum'].centroid_values
-            print domain.quantities['ymomentum'].centroid_values
-
-        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
-        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
-        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
-        assert num.allclose(domain.fractional_step_volume_integral, ((d-1.)*domain.areas[indices]).sum())
-
-        domain.set_starttime(30.0)
-        domain.timestep = 1.0
-        operator()
-
-        t = operator.get_time()
-        d = operator.get_timestep()*default_rate(t)*factor + d
-        stage_ex = [ d,  d,   1.,  d]
-
-        if verbose:
-            print domain.quantities['elevation'].centroid_values
-            print domain.quantities['stage'].centroid_values
-            print domain.quantities['xmomentum'].centroid_values
-            print domain.quantities['ymomentum'].centroid_values
-
-        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
-        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
-        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
-
-
-    def test_rate_operator_functions_spatial(self):
-        from anuga.config import rho_a, rho_w, eta_w
-        from math import pi, cos, sin
-
-        a = [0.0, 0.0]
-        b = [0.0, 2.0]
-        c = [2.0, 0.0]
-        d = [0.0, 4.0]
-        e = [2.0, 2.0]
-        f = [4.0, 0.0]
-
-        points = [a, b, c, d, e, f]
-        #             bac,     bce,     ecf,     dbe
-        vertices = [[1,0,2], [1,2,4], [4,2,5], [3,1,4]]
-
-        domain = Domain(points, vertices)
-
-
-        area = numpy.sum(domain.areas)
-
-        #Flat surface with 1m of water
-        domain.set_quantity('elevation', 0.0)
-        domain.set_quantity('stage', 1.0)
-        domain.set_quantity('friction', 0.0)
-
-        Br = Reflective_boundary(domain)
-        domain.set_boundary({'exterior': Br})
-
-        verbose = False
-
-        if verbose:
-            print domain.quantities['elevation'].centroid_values
-            print domain.quantities['stage'].centroid_values
-            print domain.quantities['xmomentum'].centroid_values
-            print domain.quantities['ymomentum'].centroid_values
-
-        # Apply operator to these triangles
-        factor = 10.0
-
-
-        def main_spatial_rate(x,y,t):
-            # x and y should be an n by 1 array
-            return x + y
-
-        default_rate = 0.0
-
-
-        operator = Rate_operator(domain, rate=main_spatial_rate, factor=factor, \
-                      default_rate = default_rate)
-
-
-        # Apply Operator
-        domain.timestep = 2.0
-        operator()
-
-
-        t = operator.get_time()
-        Q = operator.get_Q()
-        x = operator.coord_c[:,0]
-        y = operator.coord_c[:,1]
-        rate = main_spatial_rate(x,y,t)*factor
-        Q_ex = num.sum(domain.areas*rate)
-        d = operator.get_timestep()*rate + 1
-
-        #print "d"
-        #print d
-        #print area, Q, Q_ex
-        stage_ex = num.array([ 1.0,  1.0,   1.0,  1.0])
-        stage_ex[:] = d
-
-        if verbose:
-            print domain.quantities['elevation'].centroid_values
-            print domain.quantities['stage'].centroid_values
-            print domain.quantities['xmomentum'].centroid_values
-            print domain.quantities['ymomentum'].centroid_values
-
-        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
-        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
-        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
-        assert num.allclose(Q_ex, Q)
-
-    def test_rate_operator_functions_spatial_with_ghost(self):
-        from anuga.config import rho_a, rho_w, eta_w
-        from math import pi, cos, sin
-
-        a = [0.0, 0.0]
-        b = [0.0, 2.0]
-        c = [2.0, 0.0]
-        d = [0.0, 4.0]
-        e = [2.0, 2.0]
-        f = [4.0, 0.0]
-
-        points = [a, b, c, d, e, f]
-        #             bac,     bce,     ecf,     dbe
-        vertices = [[1,0,2], [1,2,4], [4,2,5], [3,1,4]]
-
-        domain = Domain(points, vertices)
-
-
-        area = numpy.sum(domain.areas)
-
-        #Flat surface with 1m of water
-        domain.set_quantity('elevation', 0.0)
-        domain.set_quantity('stage', 1.0)
-        domain.set_quantity('friction', 0.0)
-
-        Br = Reflective_boundary(domain)
-        domain.set_boundary({'exterior': Br})
-
-        verbose = False
-
-        if verbose:
-            print domain.quantities['elevation'].centroid_values
-            print domain.quantities['stage'].centroid_values
-            print domain.quantities['xmomentum'].centroid_values
-            print domain.quantities['ymomentum'].centroid_values
-
-        # Apply operator to these triangles
-        factor = 10.0
-
-
-        def main_spatial_rate(x,y,t):
-            # x and y should be an n by 1 array
-            return x + y
-
-        default_rate = 0.0
-
-        # kludge to make a ghost cell
-        domain.tri_full_flag[1] = 0
-
-        operator = Rate_operator(domain, rate=main_spatial_rate, factor=factor, \
-                      default_rate = default_rate)
-
-  
-        # Apply Operator
-        domain.timestep = 2.0
-        operator()
-
-
-        t = operator.get_time()
-        Q_all = operator.get_Q(full_only=False)
-        Q_full = operator.get_Q()
-        x = operator.coord_c[:,0]
-        y = operator.coord_c[:,1]
-        rate = main_spatial_rate(x,y,t)*factor
-        Q_ex_all = num.sum(domain.areas*rate)
-        Q_ex_full = num.sum(num.where(domain.tri_full_flag==1,domain.areas*rate,0.0))
-        d = operator.get_timestep()*rate + 1
-
-        #print "d"
-        #print d
-        #print Q_ex_full, Q_ex_all
-        stage_ex = num.array([ 1.0,  1.0,   1.0,  1.0])
-        stage_ex[:] = d
-
-        if verbose:
-            print domain.quantities['elevation'].centroid_values
-            print domain.quantities['stage'].centroid_values
-            print domain.quantities['xmomentum'].centroid_values
-            print domain.quantities['ymomentum'].centroid_values
-
-        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
-        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
-        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
-        assert num.allclose(Q_ex_all, Q_all)
-        assert num.allclose(Q_ex_full, Q_full)
-        assert num.allclose(domain.fractional_step_volume_integral, ((d-1.)*domain.areas*domain.tri_full_flag).sum())
-
-    def test_rate_operator_functions_spatial_indices(self):
-        from anuga.config import rho_a, rho_w, eta_w
-        from math import pi, cos, sin
-
-        a = [0.0, 0.0]
-        b = [0.0, 2.0]
-        c = [2.0, 0.0]
-        d = [0.0, 4.0]
-        e = [2.0, 2.0]
-        f = [4.0, 0.0]
-
-        points = [a, b, c, d, e, f]
-        #             bac,     bce,     ecf,     dbe
-        vertices = [[1,0,2], [1,2,4], [4,2,5], [3,1,4]]
-
-        domain = Domain(points, vertices)
-
-        #Flat surface with 1m of water
-        domain.set_quantity('elevation', 0.0)
-        domain.set_quantity('stage', 1.0)
-        domain.set_quantity('friction', 0.0)
-
-        Br = Reflective_boundary(domain)
-        domain.set_boundary({'exterior': Br})
-
-        verbose = False
-
-        if verbose:
-            print domain.quantities['elevation'].centroid_values
-            print domain.quantities['stage'].centroid_values
-            print domain.quantities['xmomentum'].centroid_values
-            print domain.quantities['ymomentum'].centroid_values
-
-        # Apply operator to these triangles
-        indices = [0,1,3]
-        factor = 10.0
-
-
-        def main_spatial_rate(x,y,t):
-            # x and y should be an n by 1 array
-            return x + y
-
-        default_rate = 0.0
-
-
-        operator = Rate_operator(domain, rate=main_spatial_rate, factor=factor, \
-                      indices=indices, default_rate = default_rate)
-
-
-        # Apply Operator
-        domain.timestep = 2.0
-        operator()
-
-        t = operator.get_time()
-        Q = operator.get_Q()
-        x = operator.coord_c[indices,0]
-        y = operator.coord_c[indices,1]
-        rate = main_spatial_rate(x,y,t)*factor
-        Q_ex = num.sum(domain.areas[indices]*rate)
-        d = operator.get_timestep()*rate + 1
-
-
-        #print "d"
-        #print d
-        stage_ex = num.array([ 1.0,  1.0,   1.0,  1.0])
-        stage_ex[indices] = d
-
-        if verbose:
-            print domain.quantities['elevation'].centroid_values
-            print domain.quantities['stage'].centroid_values
-            print domain.quantities['xmomentum'].centroid_values
-            print domain.quantities['ymomentum'].centroid_values
-
-        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
-        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
-        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
-        assert num.allclose(Q_ex, Q)
-        assert num.allclose(domain.fractional_step_volume_integral, ((d-1.)*domain.areas[indices]).sum())
-
-
-    def test_rate_operator_rate_quantity(self):
-        from anuga.config import rho_a, rho_w, eta_w
-        from math import pi, cos, sin
-
-        a = [0.0, 0.0]
-        b = [0.0, 2.0]
-        c = [2.0, 0.0]
-        d = [0.0, 4.0]
-        e = [2.0, 2.0]
-        f = [4.0, 0.0]
-
-        points = [a, b, c, d, e, f]
-        #             bac,     bce,     ecf,     dbe
-        vertices = [[1,0,2], [1,2,4], [4,2,5], [3,1,4]]
-
-        domain = Domain(points, vertices)
-
-        #Flat surface with 1m of water
-        domain.set_quantity('elevation', 0.0)
-        domain.set_quantity('stage', 1.0)
-        domain.set_quantity('friction', 0.0)
-
-        Br = Reflective_boundary(domain)
-        domain.set_boundary({'exterior': Br})
-
-        verbose = False
-
-        if verbose:
-            print domain.quantities['elevation'].centroid_values
-            print domain.quantities['stage'].centroid_values
-            print domain.quantities['xmomentum'].centroid_values
-            print domain.quantities['ymomentum'].centroid_values
-
-        # Apply operator to these triangles
-        indices = [0,1,3]
-        factor = 10.0
-
-
-        from anuga import Quantity
-        rate_Q = Quantity(domain)
-        rate_Q.set_values(1.0)
-
-        operator = Rate_operator(domain, rate=rate_Q, factor=factor, \
-                                 indices=indices)
-
-
-        # Apply Operator
-        domain.timestep = 2.0
-        operator()
-        rate = rate_Q.centroid_values[indices]
-        t = operator.get_time()
-        Q = operator.get_Q()
-
-        rate = rate*factor
-        Q_ex = num.sum(domain.areas[indices]*rate)
-        d = operator.get_timestep()*rate + 1
-
-
-        #print "d"
-        #print d
-        #print Q_ex
-        #print Q
-        stage_ex = num.array([ 1.0,  1.0,   1.0,  1.0])
-        stage_ex[indices] = d
-        
-        verbose = False
-        
-        if verbose:
-            print domain.quantities['elevation'].centroid_values
-            print domain.quantities['stage'].centroid_values
-            print domain.quantities['xmomentum'].centroid_values
-            print domain.quantities['ymomentum'].centroid_values
-
-        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
-        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
-        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
-        assert num.allclose(Q_ex, Q)
-        assert num.allclose(domain.fractional_step_volume_integral, ((d-1.)*domain.areas[indices]).sum())
-
-
-    def test_rate_operator_functions_empty_indices(self):
-        from anuga.config import rho_a, rho_w, eta_w
-        from math import pi, cos, sin
-
-        a = [0.0, 0.0]
-        b = [0.0, 2.0]
-        c = [2.0, 0.0]
-        d = [0.0, 4.0]
-        e = [2.0, 2.0]
-        f = [4.0, 0.0]
-
-        points = [a, b, c, d, e, f]
-        #             bac,     bce,     ecf,     dbe
-        vertices = [[1,0,2], [1,2,4], [4,2,5], [3,1,4]]
-
-        domain = Domain(points, vertices)
-
-        #Flat surface with 1m of water
-        domain.set_quantity('elevation', 0.0)
-        domain.set_quantity('stage', 1.0)
-        domain.set_quantity('friction', 0.0)
-
-        Br = Reflective_boundary(domain)
-        domain.set_boundary({'exterior': Br})
-
-        verbose = False
-
-        if verbose:
-            print domain.quantities['elevation'].centroid_values
-            print domain.quantities['stage'].centroid_values
-            print domain.quantities['xmomentum'].centroid_values
-            print domain.quantities['ymomentum'].centroid_values
-
-        # Apply operator to these triangles
-        indices = []
-        factor = 10.0
-
-
-        def main_spatial_rate(x,y,t):
-            # x and y should be an n by 1 array
-            return x + y
-
-        default_rate = 0.0
-
-        domain.tri_full_flag[0] = 0
-        operator = Rate_operator(domain, rate=main_spatial_rate, factor=factor, \
-                      indices=indices, default_rate = default_rate)
-
-
-        # Apply Operator
-        domain.timestep = 2.0
-        operator()
-
-        t = operator.get_time()
-        Q = operator.get_Q()
-        x = operator.coord_c[indices,0]
-        y = operator.coord_c[indices,1]
-        rate = main_spatial_rate(x,y,t)*factor
-        Q_ex = num.sum(domain.areas[indices]*rate)
-        d = operator.get_timestep()*rate + 1
-
-        #print Q_ex, Q
-        #print indices
-        #print "d"
-        #print d
-        stage_ex = num.array([ 1.0,  1.0,   1.0,  1.0])
-        stage_ex[indices] = d
-
-        if verbose:
-            print domain.quantities['elevation'].centroid_values
-            print domain.quantities['stage'].centroid_values
-            print domain.quantities['xmomentum'].centroid_values
-            print domain.quantities['ymomentum'].centroid_values
-
-        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
-        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
-        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
-        assert num.allclose(Q_ex, Q)
-        assert num.allclose(domain.fractional_step_volume_integral, ((d-1.)*domain.areas[indices]).sum())
-
-if __name__ == "__main__":
-    suite = unittest.makeSuite(Test_rate_operators, 'test')
-    runner = unittest.TextTestRunner(verbosity=1)
-    runner.run(suite)
Index: unk/anuga_core/source/anuga/operators/test_set_elevation_operator.py
===================================================================
--- /trunk/anuga_core/source/anuga/operators/test_set_elevation_operator.py	(revision 9444)
+++ 	(revision )
@@ -1,1034 +1,0 @@
-"""  Test set operators - stage elevation erosion.
-"""
-
-import unittest, os
-import anuga
-from anuga import Domain
-from anuga import Reflective_boundary
-from anuga import rectangular_cross_domain
-from anuga import file_function
-
-from anuga.config import netcdf_mode_r, netcdf_mode_w, netcdf_mode_a
-from anuga.file_conversion.file_conversion import timefile2netcdf
-from anuga.config import time_format
-
-from set_elevation_operator import *
-
-import numpy as num
-import warnings
-import time
-
-
-
-class Test_set_elevation_operator(unittest.TestCase):
-    def setUp(self):
-        pass
-
-    def tearDown(self):
-        pass
-
-
-    def test_set_elevation_operator_simple(self):
-        from anuga.config import rho_a, rho_w, eta_w
-        from math import pi, cos, sin
-
-        a = [0.0, 0.0]
-        b = [0.0, 2.0]
-        c = [2.0, 0.0]
-        d = [0.0, 4.0]
-        e = [2.0, 2.0]
-        f = [4.0, 0.0]
-
-        points = [a, b, c, d, e, f]
-        #             bac,     bce,     ecf,     dbe
-        vertices = [[1,0,2], [1,2,4], [4,2,5], [3,1,4]]
-
-        domain = Domain(points, vertices)
-
-        #Flat surface with 1m of water
-        domain.set_quantity('elevation', 0)
-        domain.set_quantity('stage', 1.0)
-        domain.set_quantity('friction', 0)
-
-        stage_c = domain.quantities['stage'].centroid_values
-        elev_c = domain.quantities['elevation'].centroid_values
-
-        height_c = stage_c - elev_c
-
-        integral0 = num.sum(height_c)
-
-        Br = Reflective_boundary(domain)
-        domain.set_boundary({'exterior': Br})
-
-
-#        print domain.quantities['stage'].centroid_values
-#        print domain.quantities['xmomentum'].centroid_values
-#        print domain.quantities['ymomentum'].centroid_values
-
-        # Apply operator to these triangles
-        indices = [0,1,3]
-
-        elev = 3.0
-
-
-        operator = Set_elevation_operator(domain, elevation=elev, indices=indices)
-        
-        # Apply Operator
-        domain.timestep = 2.0
-        operator()
-
-
-        height_c = stage_c - elev_c
-
-        integral1 = num.sum(height_c)
-
-        assert integral0 == integral1
-
-        stage_ex = [ 3.66666667,  3.33333333,  2.33333333,  3.66666667]
-
-        elev_ex = [ 2.66666667,  2.33333333,  1.33333333,  2.66666667]
-        
-
-#        print domain.quantities['elevation'].centroid_values
-#        print domain.quantities['stage'].centroid_values
-#        print domain.quantities['xmomentum'].centroid_values
-#        print domain.quantities['ymomentum'].centroid_values
-
-        assert num.allclose(domain.quantities['elevation'].centroid_values, elev_ex)
-        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
-        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
-        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
-
- 
-    def test_set_elevation_operator_negative(self):
-        from anuga.config import rho_a, rho_w, eta_w
-        from math import pi, cos, sin
-
-        a = [0.0, 0.0]
-        b = [0.0, 2.0]
-        c = [2.0, 0.0]
-        d = [0.0, 4.0]
-        e = [2.0, 2.0]
-        f = [4.0, 0.0]
-
-        points = [a, b, c, d, e, f]
-        #             bac,     bce,     ecf,     dbe
-        vertices = [[1,0,2], [1,2,4], [4,2,5], [3,1,4]]
-
-        domain = Domain(points, vertices)
-
-        #Flat surface with 1m of water
-        domain.set_quantity('elevation', lambda x,y : -2*x)
-        domain.set_quantity('stage', 1.0)
-        domain.set_quantity('friction', 0)
-
-
-        stage_c = domain.quantities['stage'].centroid_values
-        elev_c = domain.quantities['elevation'].centroid_values
-
-        height_c = stage_c - elev_c
-
-        integral0 = num.sum(height_c)
-
-
-        Br = Reflective_boundary(domain)
-        domain.set_boundary({'exterior': Br})
-
-#        print domain.quantities['elevation'].centroid_values
-#        print domain.quantities['stage'].centroid_values
-#        print domain.quantities['xmomentum'].centroid_values
-#        print domain.quantities['ymomentum'].centroid_values
-
-        # Apply operator to these triangles
-        indices = [0,1,3]
-
-
-
-        #Catchment_Rain_Polygon = read_polygon(join('CatchmentBdy.csv'))
-        #rainfall = file_function(join('1y120m.tms'), quantities=['rainfall'])
-        elev = -5.0
-
-
-        operator = Set_elevation_operator(domain, elevation=elev, indices=indices)
-
-
-        # Apply Operator
-        domain.timestep = 2.0
-        operator()
-        
-        height_c = stage_c - elev_c
-        integral1 = num.sum(height_c)
-        assert integral0 == integral1
-
-        elev_ex  = [-4.88888889, -4.77777778, -5.77777778, -4.88888889]
-        stage_ex = [-2.55555556, -1.11111111,  0.55555556, -2.55555556]
-
-
-#        print domain.quantities['elevation'].centroid_values
-#        print domain.quantities['stage'].centroid_values
-#        print domain.quantities['xmomentum'].centroid_values
-#        print domain.quantities['ymomentum'].centroid_values
-
-        assert num.allclose(domain.quantities['elevation'].centroid_values, elev_ex)
-        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
-        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
-        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
-
-
-    def test_set_elevation_operator_small_function(self):
-        from anuga.config import rho_a, rho_w, eta_w
-        from math import pi, cos, sin
-
-        a = [0.0, 0.0]
-        b = [0.0, 2.0]
-        c = [2.0, 0.0]
-        d = [0.0, 4.0]
-        e = [2.0, 2.0]
-        f = [4.0, 0.0]
-
-
-
-
-
-        points = [a, b, c, d, e, f]
-        #             bac,     bce,     ecf,     dbe
-        vertices = [[1,0,2], [1,2,4], [4,2,5], [3,1,4]]
-
-        domain = Domain(points, vertices)
-
-        #Flat surface with 1m of water
-        domain.set_quantity('elevation', 0.0)
-        domain.set_quantity('stage', 1.0)
-        domain.set_quantity('friction', 0)
-
-        Br = Reflective_boundary(domain)
-        domain.set_boundary({'exterior': Br})
-
-
-#        print domain.quantities['stage'].centroid_values
-#        print domain.quantities['xmomentum'].centroid_values
-#        print domain.quantities['ymomentum'].centroid_values
-
-        # Apply operator to these triangles
-        indices = [0,1,3]
-
-
-        def elev(t):
-            if t < 10.0:
-                return 5.0
-            else:
-                return 7.0
-
-        operator = Set_elevation_operator(domain, elevation=elev, indices=indices)
-
-        # Apply Operator at time t=1.0
-        domain.set_time(1.0)
-        operator()
-
-
-        elev_ex  = [ 4.44444444,  3.88888889, 2.22222222,  4.44444444]
-        stage_ex = [ 5.44444444,  4.88888889,  3.22222222,  5.44444444]
-
-#        print domain.quantities['elevation'].centroid_values
-#        print domain.quantities['stage'].centroid_values
-#        print domain.quantities['xmomentum'].centroid_values
-#        print domain.quantities['ymomentum'].centroid_values
-
-        assert num.allclose(domain.quantities['elevation'].centroid_values, elev_ex)
-        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
-        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
-        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
-
-        # Apply Operator at time t=15.0
-        domain.set_time(15.0)
-        operator()
-
-
-        elev_ex =  [ 6.59259259,  6.18518519,  3.85185185,  6.59259259]
-        stage_ex = [ 7.59259259,  7.18518519,  4.85185185,  7.59259259]
-
-#        print domain.quantities['elevation'].centroid_values
-#        print domain.quantities['stage'].centroid_values
-#        print domain.quantities['xmomentum'].centroid_values
-#        print domain.quantities['ymomentum'].centroid_values
-
-        assert num.allclose(domain.quantities['elevation'].centroid_values, elev_ex)
-        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
-        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
-        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
-
-
-
-    def test_set_polygonal_elevation_operator_large_function(self):
-        from anuga.config import rho_a, rho_w, eta_w
-        from math import pi, cos, sin
-
-
-        length = 2.0
-        width = 2.0
-        dx = dy = 0.5
-        domain = rectangular_cross_domain(int(length/dx), int(width/dy),
-                                              len1=length, len2=width)
-
-
-        #Flat surface with 1m of water
-        domain.set_quantity('elevation', 0.0)
-        domain.set_quantity('stage', 1.0)
-        domain.set_quantity('friction', 0)
-
-        R = Reflective_boundary(domain)
-        domain.set_boundary( {'left': R, 'right': R, 'bottom': R, 'top': R} )
-
-
-#        print domain.quantities['stage'].centroid_values
-#        print domain.quantities['xmomentum'].centroid_values
-#        print domain.quantities['ymomentum'].centroid_values
-
-        # Apply operator to these triangles
-        indices = [0,1,3]
-
-
-        def elev(t):
-            if t < 10.0:
-                return 5.0
-            else:
-                return 7.0
-
-        polygon = [(0.5,0.5), (1.5,0.5), (1.5,1.5), (0.5,1.5)]
-        operator = Polygonal_set_elevation_operator(domain, elevation=elev, polygon=polygon)
-
-        # Apply Operator at time t=1.0
-        domain.set_time(1.0)
-        operator()
-
-
-
-
-        elev_ex = [ 0.        ,  0.        ,  0.41666667,  0.41666667,  0.        ,
-        0.41666667,  1.25      ,  0.83333333,  0.        ,  0.83333333,
-        1.25      ,  0.41666667,  0.        ,  0.41666667,  0.41666667,
-        0.        ,  0.41666667,  0.        ,  0.83333333,  1.25      ,
-        2.91666667,  2.91666667,  4.16666667,  4.16666667,  2.91666667,
-        4.16666667,  4.16666667,  2.91666667,  0.41666667,  1.25      ,
-        0.83333333,  0.        ,  0.83333333,  0.        ,  0.41666667,
-        1.25      ,  4.16666667,  2.91666667,  2.91666667,  4.16666667,
-        4.16666667,  4.16666667,  2.91666667,  2.91666667,  0.83333333,
-        1.25      ,  0.41666667,  0.        ,  0.41666667,  0.        ,
-        0.        ,  0.41666667,  1.25      ,  0.41666667,  0.        ,
-        0.83333333,  1.25      ,  0.83333333,  0.        ,  0.41666667,
-        0.41666667,  0.41666667,  0.        ,  0.        ]
-
-        stage_ex = [ 1.        ,  1.        ,  1.41666667,  1.41666667,  1.        ,
-        1.41666667,  2.25      ,  1.83333333,  1.        ,  1.83333333,
-        2.25      ,  1.41666667,  1.        ,  1.41666667,  1.41666667,
-        1.        ,  1.41666667,  1.        ,  1.83333333,  2.25      ,
-        3.91666667,  3.91666667,  5.16666667,  5.16666667,  3.91666667,
-        5.16666667,  5.16666667,  3.91666667,  1.41666667,  2.25      ,
-        1.83333333,  1.        ,  1.83333333,  1.        ,  1.41666667,
-        2.25      ,  5.16666667,  3.91666667,  3.91666667,  5.16666667,
-        5.16666667,  5.16666667,  3.91666667,  3.91666667,  1.83333333,
-        2.25      ,  1.41666667,  1.        ,  1.41666667,  1.        ,
-        1.        ,  1.41666667,  2.25      ,  1.41666667,  1.        ,
-        1.83333333,  2.25      ,  1.83333333,  1.        ,  1.41666667,
-        1.41666667,  1.41666667,  1.        ,  1.        ]
-
-
-
-
-
-#        from pprint import pprint
-#        pprint (domain.quantities['elevation'].centroid_values)
-#        pprint (domain.quantities['stage'].centroid_values)
-#        print domain.quantities['xmomentum'].centroid_values
-#        print domain.quantities['ymomentum'].centroid_values
-
-        assert num.allclose(domain.quantities['elevation'].centroid_values, elev_ex)
-        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
-        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
-        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
-
-        # Apply Operator at time t=15.0
-        domain.set_time(15.0)
-        operator()
-
-
-
-
-        elev_ex = [ 0.        ,  0.        ,  0.89583333,  0.89583333,  0.        ,
-        0.89583333,  2.47916667,  1.58333333,  0.        ,  1.58333333,
-        2.47916667,  0.89583333,  0.        ,  0.89583333,  0.89583333,
-        0.        ,  0.89583333,  0.        ,  1.58333333,  2.47916667,
-        4.8125    ,  4.8125    ,  6.25      ,  6.25      ,  4.8125    ,
-        6.25      ,  6.25      ,  4.8125    ,  0.89583333,  2.47916667,
-        1.58333333,  0.        ,  1.58333333,  0.        ,  0.89583333,
-        2.47916667,  6.25      ,  4.8125    ,  4.8125    ,  6.25      ,
-        6.25      ,  6.25      ,  4.8125    ,  4.8125    ,  1.58333333,
-        2.47916667,  0.89583333,  0.        ,  0.89583333,  0.        ,
-        0.        ,  0.89583333,  2.47916667,  0.89583333,  0.        ,
-        1.58333333,  2.47916667,  1.58333333,  0.        ,  0.89583333,
-        0.89583333,  0.89583333,  0.        ,  0.        ]
-
-        stage_ex = [ 1.        ,  1.        ,  1.89583333,  1.89583333,  1.        ,
-        1.89583333,  3.47916667,  2.58333333,  1.        ,  2.58333333,
-        3.47916667,  1.89583333,  1.        ,  1.89583333,  1.89583333,
-        1.        ,  1.89583333,  1.        ,  2.58333333,  3.47916667,
-        5.8125    ,  5.8125    ,  7.25      ,  7.25      ,  5.8125    ,
-        7.25      ,  7.25      ,  5.8125    ,  1.89583333,  3.47916667,
-        2.58333333,  1.        ,  2.58333333,  1.        ,  1.89583333,
-        3.47916667,  7.25      ,  5.8125    ,  5.8125    ,  7.25      ,
-        7.25      ,  7.25      ,  5.8125    ,  5.8125    ,  2.58333333,
-        3.47916667,  1.89583333,  1.        ,  1.89583333,  1.        ,
-        1.        ,  1.89583333,  3.47916667,  1.89583333,  1.        ,
-        2.58333333,  3.47916667,  2.58333333,  1.        ,  1.89583333,
-        1.89583333,  1.89583333,  1.        ,  1.        ]
-
-#        pprint (domain.quantities['elevation'].centroid_values)
-#        pprint (domain.quantities['stage'].centroid_values)
-#        print domain.quantities['xmomentum'].centroid_values
-#        print domain.quantities['ymomentum'].centroid_values
-
-        assert num.allclose(domain.quantities['elevation'].centroid_values, elev_ex)
-        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
-        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
-        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
-
-
-    def test_set_elevation_operator_large_function(self):
-        from anuga.config import rho_a, rho_w, eta_w
-        from math import pi, cos, sin
-
-
-        length = 2.0
-        width = 2.0
-        dx = dy = 0.5
-        domain = rectangular_cross_domain(int(length/dx), int(width/dy),
-                                              len1=length, len2=width)
-
-
-        #Flat surface with 1m of water
-        domain.set_quantity('elevation', 0.0)
-        domain.set_quantity('stage', 1.0)
-        domain.set_quantity('friction', 0)
-
-        R = Reflective_boundary(domain)
-        domain.set_boundary( {'left': R, 'right': R, 'bottom': R, 'top': R} )
-
-
-#        print domain.quantities['stage'].centroid_values
-#        print domain.quantities['xmomentum'].centroid_values
-#        print domain.quantities['ymomentum'].centroid_values
-
-        # Apply operator to these triangles
-        indices = [0,1,3]
-
-
-        def elev(t):
-            if t < 10.0:
-                return 5.0
-            else:
-                return 7.0
-
-        polygon = [(0.5,0.5), (1.5,0.5), (1.5,1.5), (0.5,1.5)]
-        operator = Set_elevation_operator(domain, elevation=elev, polygon=polygon)
-
-        # Apply Operator at time t=1.0
-        domain.set_time(1.0)
-        operator()
-
-        stage_ex = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
-                     0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
-                     0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
-                     0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
-                     0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
-                     0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
-
-
-        elev_ex = [ 0.        ,  0.        ,  0.41666667,  0.41666667,  0.        ,
-        0.41666667,  1.25      ,  0.83333333,  0.        ,  0.83333333,
-        1.25      ,  0.41666667,  0.        ,  0.41666667,  0.41666667,
-        0.        ,  0.41666667,  0.        ,  0.83333333,  1.25      ,
-        2.91666667,  2.91666667,  4.16666667,  4.16666667,  2.91666667,
-        4.16666667,  4.16666667,  2.91666667,  0.41666667,  1.25      ,
-        0.83333333,  0.        ,  0.83333333,  0.        ,  0.41666667,
-        1.25      ,  4.16666667,  2.91666667,  2.91666667,  4.16666667,
-        4.16666667,  4.16666667,  2.91666667,  2.91666667,  0.83333333,
-        1.25      ,  0.41666667,  0.        ,  0.41666667,  0.        ,
-        0.        ,  0.41666667,  1.25      ,  0.41666667,  0.        ,
-        0.83333333,  1.25      ,  0.83333333,  0.        ,  0.41666667,
-        0.41666667,  0.41666667,  0.        ,  0.        ]
-
-        stage_ex = [ 1.        ,  1.        ,  1.41666667,  1.41666667,  1.        ,
-        1.41666667,  2.25      ,  1.83333333,  1.        ,  1.83333333,
-        2.25      ,  1.41666667,  1.        ,  1.41666667,  1.41666667,
-        1.        ,  1.41666667,  1.        ,  1.83333333,  2.25      ,
-        3.91666667,  3.91666667,  5.16666667,  5.16666667,  3.91666667,
-        5.16666667,  5.16666667,  3.91666667,  1.41666667,  2.25      ,
-        1.83333333,  1.        ,  1.83333333,  1.        ,  1.41666667,
-        2.25      ,  5.16666667,  3.91666667,  3.91666667,  5.16666667,
-        5.16666667,  5.16666667,  3.91666667,  3.91666667,  1.83333333,
-        2.25      ,  1.41666667,  1.        ,  1.41666667,  1.        ,
-        1.        ,  1.41666667,  2.25      ,  1.41666667,  1.        ,
-        1.83333333,  2.25      ,  1.83333333,  1.        ,  1.41666667,
-        1.41666667,  1.41666667,  1.        ,  1.        ]
-
-
-
-
-
-#        from pprint import pprint
-#        pprint (domain.quantities['elevation'].centroid_values)
-#        pprint (domain.quantities['stage'].centroid_values)
-#        print domain.quantities['xmomentum'].centroid_values
-#        print domain.quantities['ymomentum'].centroid_values
-
-        assert num.allclose(domain.quantities['elevation'].centroid_values, elev_ex)
-        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
-        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
-        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
-
-        # Apply Operator at time t=15.0
-        domain.set_time(15.0)
-        operator()
-
-        stage_ex = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
-                     0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
-                     0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
-                     0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
-                     0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
-                     0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
-
-
-        elev_ex = [ 0.        ,  0.        ,  0.89583333,  0.89583333,  0.        ,
-        0.89583333,  2.47916667,  1.58333333,  0.        ,  1.58333333,
-        2.47916667,  0.89583333,  0.        ,  0.89583333,  0.89583333,
-        0.        ,  0.89583333,  0.        ,  1.58333333,  2.47916667,
-        4.8125    ,  4.8125    ,  6.25      ,  6.25      ,  4.8125    ,
-        6.25      ,  6.25      ,  4.8125    ,  0.89583333,  2.47916667,
-        1.58333333,  0.        ,  1.58333333,  0.        ,  0.89583333,
-        2.47916667,  6.25      ,  4.8125    ,  4.8125    ,  6.25      ,
-        6.25      ,  6.25      ,  4.8125    ,  4.8125    ,  1.58333333,
-        2.47916667,  0.89583333,  0.        ,  0.89583333,  0.        ,
-        0.        ,  0.89583333,  2.47916667,  0.89583333,  0.        ,
-        1.58333333,  2.47916667,  1.58333333,  0.        ,  0.89583333,
-        0.89583333,  0.89583333,  0.        ,  0.        ]
-
-        stage_ex = [ 1.        ,  1.        ,  1.89583333,  1.89583333,  1.        ,
-        1.89583333,  3.47916667,  2.58333333,  1.        ,  2.58333333,
-        3.47916667,  1.89583333,  1.        ,  1.89583333,  1.89583333,
-        1.        ,  1.89583333,  1.        ,  2.58333333,  3.47916667,
-        5.8125    ,  5.8125    ,  7.25      ,  7.25      ,  5.8125    ,
-        7.25      ,  7.25      ,  5.8125    ,  1.89583333,  3.47916667,
-        2.58333333,  1.        ,  2.58333333,  1.        ,  1.89583333,
-        3.47916667,  7.25      ,  5.8125    ,  5.8125    ,  7.25      ,
-        7.25      ,  7.25      ,  5.8125    ,  5.8125    ,  2.58333333,
-        3.47916667,  1.89583333,  1.        ,  1.89583333,  1.        ,
-        1.        ,  1.89583333,  3.47916667,  1.89583333,  1.        ,
-        2.58333333,  3.47916667,  2.58333333,  1.        ,  1.89583333,
-        1.89583333,  1.89583333,  1.        ,  1.        ]
-
-#        pprint (domain.quantities['elevation'].centroid_values)
-#        pprint (domain.quantities['stage'].centroid_values)
-#        print domain.quantities['xmomentum'].centroid_values
-#        print domain.quantities['ymomentum'].centroid_values
-
-        assert num.allclose(domain.quantities['elevation'].centroid_values, elev_ex)
-        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
-        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
-        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
-
-
-    def test_set_circular_elevation_operator_large_function(self):
-        from anuga.config import rho_a, rho_w, eta_w
-        from math import pi, cos, sin
-
-
-        length = 2.0
-        width = 2.0
-        dx = dy = 0.5
-        domain = rectangular_cross_domain(int(length/dx), int(width/dy),
-                                              len1=length, len2=width)
-
-
-        #Flat surface with 1m of water
-        domain.set_quantity('elevation', 0.0)
-        domain.set_quantity('stage', 1.0)
-        domain.set_quantity('friction', 0)
-
-        R = Reflective_boundary(domain)
-        domain.set_boundary( {'left': R, 'right': R, 'bottom': R, 'top': R} )
-
-
-#        print domain.quantities['stage'].centroid_values
-#        print domain.quantities['xmomentum'].centroid_values
-#        print domain.quantities['ymomentum'].centroid_values
-
-        # Apply operator to these triangles
-
-
-        def elev(t):
-            if t < 10.0:
-                return 5.0
-            else:
-                return 7.0
-
-        operator = Circular_set_elevation_operator(domain, elevation=elev, center=[1.0,1.0], radius=1.0)
-
-        # Apply Operator at time t=1.0
-        domain.set_time(1.0)
-        operator()
-
-
-
-
-        elev_ex = [ 2.08333333,  2.08333333,  3.75      ,  3.75      ,  4.58333333,
-        4.58333333,  5.        ,  5.        ,  4.58333333,  5.        ,
-        5.        ,  4.58333333,  2.08333333,  3.75      ,  3.75      ,
-        2.08333333,  4.58333333,  4.58333333,  5.        ,  5.        ,
-        5.        ,  5.        ,  5.        ,  5.        ,  5.        ,
-        5.        ,  5.        ,  5.        ,  4.58333333,  5.        ,
-        5.        ,  4.58333333,  5.        ,  4.58333333,  4.58333333,
-        5.        ,  5.        ,  5.        ,  5.        ,  5.        ,
-        5.        ,  5.        ,  5.        ,  5.        ,  5.        ,
-        5.        ,  4.58333333,  4.58333333,  3.75      ,  2.08333333,
-        2.08333333,  3.75      ,  5.        ,  4.58333333,  4.58333333,
-        5.        ,  5.        ,  5.        ,  4.58333333,  4.58333333,
-        3.75      ,  3.75      ,  2.08333333,  2.08333333]
-
-
-
-
-        stage_ex = [ 3.08333333,  3.08333333,  4.75      ,  4.75      ,  5.58333333,
-        5.58333333,  6.        ,  6.        ,  5.58333333,  6.        ,
-        6.        ,  5.58333333,  3.08333333,  4.75      ,  4.75      ,
-        3.08333333,  5.58333333,  5.58333333,  6.        ,  6.        ,
-        6.        ,  6.        ,  6.        ,  6.        ,  6.        ,
-        6.        ,  6.        ,  6.        ,  5.58333333,  6.        ,
-        6.        ,  5.58333333,  6.        ,  5.58333333,  5.58333333,
-        6.        ,  6.        ,  6.        ,  6.        ,  6.        ,
-        6.        ,  6.        ,  6.        ,  6.        ,  6.        ,
-        6.        ,  5.58333333,  5.58333333,  4.75      ,  3.08333333,
-        3.08333333,  4.75      ,  6.        ,  5.58333333,  5.58333333,
-        6.        ,  6.        ,  6.        ,  5.58333333,  5.58333333,
-        4.75      ,  4.75      ,  3.08333333,  3.08333333]
-
-
-
-
-
-#        from pprint import pprint
-#        pprint (domain.quantities['elevation'].centroid_values)
-#        pprint (domain.quantities['stage'].centroid_values)
-#        print domain.quantities['xmomentum'].centroid_values
-#        print domain.quantities['ymomentum'].centroid_values
-
-        assert num.allclose(domain.quantities['elevation'].centroid_values, elev_ex)
-        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
-        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
-        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
-
-        # Apply Operator at time t=15.0
-        domain.set_time(15.0)
-        operator()
-
-
-
-
-        elev_ex = [ 3.64583333,  3.64583333,  5.97916667,  5.97916667,  6.72916667,
-        6.72916667,  7.        ,  7.        ,  6.72916667,  7.        ,
-        7.        ,  6.72916667,  3.64583333,  5.97916667,  5.97916667,
-        3.64583333,  6.72916667,  6.72916667,  7.        ,  7.        ,
-        7.        ,  7.        ,  7.        ,  7.        ,  7.        ,
-        7.        ,  7.        ,  7.        ,  6.72916667,  7.        ,
-        7.        ,  6.72916667,  7.        ,  6.72916667,  6.72916667,
-        7.        ,  7.        ,  7.        ,  7.        ,  7.        ,
-        7.        ,  7.        ,  7.        ,  7.        ,  7.        ,
-        7.        ,  6.72916667,  6.72916667,  5.97916667,  3.64583333,
-        3.64583333,  5.97916667,  7.        ,  6.72916667,  6.72916667,
-        7.        ,  7.        ,  7.        ,  6.72916667,  6.72916667,
-        5.97916667,  5.97916667,  3.64583333,  3.64583333]
-
-
-        stage_ex = [ 4.64583333,  4.64583333,  6.97916667,  6.97916667,  7.72916667,
-        7.72916667,  8.        ,  8.        ,  7.72916667,  8.        ,
-        8.        ,  7.72916667,  4.64583333,  6.97916667,  6.97916667,
-        4.64583333,  7.72916667,  7.72916667,  8.        ,  8.        ,
-        8.        ,  8.        ,  8.        ,  8.        ,  8.        ,
-        8.        ,  8.        ,  8.        ,  7.72916667,  8.        ,
-        8.        ,  7.72916667,  8.        ,  7.72916667,  7.72916667,
-        8.        ,  8.        ,  8.        ,  8.        ,  8.        ,
-        8.        ,  8.        ,  8.        ,  8.        ,  8.        ,
-        8.        ,  7.72916667,  7.72916667,  6.97916667,  4.64583333,
-        4.64583333,  6.97916667,  8.        ,  7.72916667,  7.72916667,
-        8.        ,  8.        ,  8.        ,  7.72916667,  7.72916667,
-        6.97916667,  6.97916667,  4.64583333,  4.64583333]
-
-
-#        from pprint import pprint
-#        pprint (domain.quantities['elevation'].centroid_values)
-#        pprint (domain.quantities['stage'].centroid_values)
-#        pprint (domain.quantities['xmomentum'].centroid_values)
-#        pprint (domain.quantities['ymomentum'].centroid_values)
-
-        assert num.allclose(domain.quantities['elevation'].centroid_values, elev_ex)
-        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
-        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
-        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
-
-    def test_set_elevation_operator_center_radius(self):
-        from math import pi, cos, sin
-
-
-        length = 2.0
-        width = 2.0
-        dx = dy = 0.5
-        domain = rectangular_cross_domain(int(length/dx), int(width/dy),
-                                              len1=length, len2=width)
-
-
-        #Flat surface with 1m of water
-        domain.set_quantity('elevation', 0.0)
-        domain.set_quantity('stage', 1.0)
-        domain.set_quantity('friction', 0)
-
-        R = Reflective_boundary(domain)
-        domain.set_boundary( {'left': R, 'right': R, 'bottom': R, 'top': R} )
-
-        from pprint import pprint
-        #pprint(domain.quantities['stage'].centroid_values)
-#        print domain.quantities['xmomentum'].centroid_values
-#        print domain.quantities['ymomentum'].centroid_values
-
-        # Apply operator to these triangles
-
-
-        def elev(t):
-            if t < 10.0:
-                return 5.0
-            else:
-                return 7.0
-
-        operator = Set_elevation_operator(domain, elevation=elev, center=[1.0,1.0], radius=1.0)
-
-        # Apply Operator at time t=1.0
-        domain.set_time(1.0)
-        operator()
-
-
-        #pprint(domain.quantities['elevation'].centroid_values)
-
-        elev_ex = [ 2.08333333,  2.08333333,  3.75      ,  3.75      ,  4.58333333,
-        4.58333333,  5.        ,  5.        ,  4.58333333,  5.        ,
-        5.        ,  4.58333333,  2.08333333,  3.75      ,  3.75      ,
-        2.08333333,  4.58333333,  4.58333333,  5.        ,  5.        ,
-        5.        ,  5.        ,  5.        ,  5.        ,  5.        ,
-        5.        ,  5.        ,  5.        ,  4.58333333,  5.        ,
-        5.        ,  4.58333333,  5.        ,  4.58333333,  4.58333333,
-        5.        ,  5.        ,  5.        ,  5.        ,  5.        ,
-        5.        ,  5.        ,  5.        ,  5.        ,  5.        ,
-        5.        ,  4.58333333,  4.58333333,  3.75      ,  2.08333333,
-        2.08333333,  3.75      ,  5.        ,  4.58333333,  4.58333333,
-        5.        ,  5.        ,  5.        ,  4.58333333,  4.58333333,
-        3.75      ,  3.75      ,  2.08333333,  2.08333333]
-
-
-
-
-        #pprint(domain.quantities['stage'].centroid_values)
-        
-        stage_ex = [ 3.08333333,  3.08333333,  4.75      ,  4.75      ,  5.58333333,
-        5.58333333,  6.        ,  6.        ,  5.58333333,  6.        ,
-        6.        ,  5.58333333,  3.08333333,  4.75      ,  4.75      ,
-        3.08333333,  5.58333333,  5.58333333,  6.        ,  6.        ,
-        6.        ,  6.        ,  6.        ,  6.        ,  6.        ,
-        6.        ,  6.        ,  6.        ,  5.58333333,  6.        ,
-        6.        ,  5.58333333,  6.        ,  5.58333333,  5.58333333,
-        6.        ,  6.        ,  6.        ,  6.        ,  6.        ,
-        6.        ,  6.        ,  6.        ,  6.        ,  6.        ,
-        6.        ,  5.58333333,  5.58333333,  4.75      ,  3.08333333,
-        3.08333333,  4.75      ,  6.        ,  5.58333333,  5.58333333,
-        6.        ,  6.        ,  6.        ,  5.58333333,  5.58333333,
-        4.75      ,  4.75      ,  3.08333333,  3.08333333]
-
-
-
-#        from pprint import pprint
-#        pprint (domain.quantities['elevation'].centroid_values)
-#        pprint (domain.quantities['stage'].centroid_values)
-#        print domain.quantities['xmomentum'].centroid_values
-#        print domain.quantities['ymomentum'].centroid_values
-
-        assert num.allclose(domain.quantities['elevation'].centroid_values, elev_ex)
-        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
-        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
-        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
-
-        # Apply Operator at time t=15.0
-        domain.set_time(15.0)
-        operator()
-
-
-
-
-        elev_ex = [ 3.64583333,  3.64583333,  5.97916667,  5.97916667,  6.72916667,
-        6.72916667,  7.        ,  7.        ,  6.72916667,  7.        ,
-        7.        ,  6.72916667,  3.64583333,  5.97916667,  5.97916667,
-        3.64583333,  6.72916667,  6.72916667,  7.        ,  7.        ,
-        7.        ,  7.        ,  7.        ,  7.        ,  7.        ,
-        7.        ,  7.        ,  7.        ,  6.72916667,  7.        ,
-        7.        ,  6.72916667,  7.        ,  6.72916667,  6.72916667,
-        7.        ,  7.        ,  7.        ,  7.        ,  7.        ,
-        7.        ,  7.        ,  7.        ,  7.        ,  7.        ,
-        7.        ,  6.72916667,  6.72916667,  5.97916667,  3.64583333,
-        3.64583333,  5.97916667,  7.        ,  6.72916667,  6.72916667,
-        7.        ,  7.        ,  7.        ,  6.72916667,  6.72916667,
-        5.97916667,  5.97916667,  3.64583333,  3.64583333]
-
-
-        stage_ex = [ 4.64583333,  4.64583333,  6.97916667,  6.97916667,  7.72916667,
-        7.72916667,  8.        ,  8.        ,  7.72916667,  8.        ,
-        8.        ,  7.72916667,  4.64583333,  6.97916667,  6.97916667,
-        4.64583333,  7.72916667,  7.72916667,  8.        ,  8.        ,
-        8.        ,  8.        ,  8.        ,  8.        ,  8.        ,
-        8.        ,  8.        ,  8.        ,  7.72916667,  8.        ,
-        8.        ,  7.72916667,  8.        ,  7.72916667,  7.72916667,
-        8.        ,  8.        ,  8.        ,  8.        ,  8.        ,
-        8.        ,  8.        ,  8.        ,  8.        ,  8.        ,
-        8.        ,  7.72916667,  7.72916667,  6.97916667,  4.64583333,
-        4.64583333,  6.97916667,  8.        ,  7.72916667,  7.72916667,
-        8.        ,  8.        ,  8.        ,  7.72916667,  7.72916667,
-        6.97916667,  6.97916667,  4.64583333,  4.64583333]
-
-
-#        from pprint import pprint
-#        pprint (domain.quantities['elevation'].centroid_values)
-#        pprint (domain.quantities['stage'].centroid_values)
-#        pprint (domain.quantities['xmomentum'].centroid_values)
-#        pprint (domain.quantities['ymomentum'].centroid_values)
-
-        assert num.allclose(domain.quantities['elevation'].centroid_values, elev_ex)
-        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
-        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
-        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
-
-        operator = Set_elevation(domain, elevation=0.0)
-
-
-        #print operator.value_type
-        
-        operator()
-
-        #from pprint import pprint
-        #pprint (domain.quantities['elevation'].centroid_values)
-#        pprint (domain.quantities['stage'].centroid_values)
-#        pprint (domain.quantities['xmomentum'].centroid_values)
-#        pprint (domain.quantities['ymomentum'].centroid_values)
-
-        assert num.allclose(domain.quantities['elevation'].centroid_values, 0.0)
-        assert num.allclose(domain.quantities['stage'].centroid_values, 1.0)
-        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
-        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
-
-
-        operator = Set_elevation(domain, elevation=lambda t: t, indices = [0,1,3])
-
-        operator()
-
-
-
-        elev_ex = [ 11.25 ,  10.   ,   5.625,   6.875,   2.5  ,   3.125,   0.625,
-         0.   ,   0.   ,   0.   ,   0.   ,   0.   ,   0.   ,   0.   ,
-         0.   ,   0.   ,   1.875,   1.25 ,   0.   ,   0.625,   0.625,
-         0.625,   0.   ,   0.   ,   0.   ,   0.   ,   0.   ,   0.   ,
-         0.   ,   0.   ,   0.   ,   0.   ,   0.   ,   0.   ,   0.   ,
-         0.   ,   0.   ,   0.   ,   0.   ,   0.   ,   0.   ,   0.   ,
-         0.   ,   0.   ,   0.   ,   0.   ,   0.   ,   0.   ,   0.   ,
-         0.   ,   0.   ,   0.   ,   0.   ,   0.   ,   0.   ,   0.   ,
-         0.   ,   0.   ,   0.   ,   0.   ,   0.   ,   0.   ,   0.   ,   0.   ]
-
-        stage_ex = [ 12.25 ,  11.   ,   6.625,   7.875,   3.5  ,   4.125,   1.625,
-         1.   ,   1.   ,   1.   ,   1.   ,   1.   ,   1.   ,   1.   ,
-         1.   ,   1.   ,   2.875,   2.25 ,   1.   ,   1.625,   1.625,
-         1.625,   1.   ,   1.   ,   1.   ,   1.   ,   1.   ,   1.   ,
-         1.   ,   1.   ,   1.   ,   1.   ,   1.   ,   1.   ,   1.   ,
-         1.   ,   1.   ,   1.   ,   1.   ,   1.   ,   1.   ,   1.   ,
-         1.   ,   1.   ,   1.   ,   1.   ,   1.   ,   1.   ,   1.   ,
-         1.   ,   1.   ,   1.   ,   1.   ,   1.   ,   1.   ,   1.   ,
-         1.   ,   1.   ,   1.   ,   1.   ,   1.   ,   1.   ,   1.   ,   1.   ]
-
-
-
-#        from pprint import pprint
-#        pprint (domain.quantities['elevation'].centroid_values)
-#        pprint (domain.quantities['stage'].centroid_values)
-#        pprint (domain.quantities['xmomentum'].centroid_values)
-#        pprint (domain.quantities['ymomentum'].centroid_values)
-
-        assert num.allclose(domain.quantities['elevation'].centroid_values, elev_ex)
-        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
-        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
-        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
-
-    def test_set_elevation_operator_center_radius_de1(self):
-        from math import pi, cos, sin
-
-
-        length = 2.0
-        width = 2.0
-        dx = dy = 0.5
-        domain = rectangular_cross_domain(int(length/dx), int(width/dy),
-                                              len1=length, len2=width)
-
-
-        #Flat surface with 1m of water
-        domain.set_flow_algorithm('DE1')
-        domain.set_quantity('elevation', 0.0)
-        domain.set_quantity('stage', 1.0)
-        domain.set_quantity('friction', 0)
-
-        R = Reflective_boundary(domain)
-        domain.set_boundary( {'left': R, 'right': R, 'bottom': R, 'top': R} )
-
-        from pprint import pprint
-        #pprint(domain.quantities['stage'].centroid_values)
-#        print domain.quantities['xmomentum'].centroid_values
-#        print domain.quantities['ymomentum'].centroid_values
-
-        # Apply operator to these triangles
-
-
-        def elev(t):
-            if t < 10.0:
-                return 5.0
-            else:
-                return 7.0
-
-        operator = Set_elevation_operator(domain, elevation=elev, center=[1.0,1.0], radius=1.0)
-
-        # Apply Operator at time t=1.0
-        domain.set_time(1.0)
-        operator()
-
-
-        #pprint(domain.quantities['elevation'].centroid_values)
-
-        elev_ex = [ 0.,  0.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  0.,
-        5.,  5.,  0.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,
-        5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,
-        5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  0.,  0.,  5.,
-        5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  0.,  0.]
-
-
-        #pprint(domain.quantities['stage'].centroid_values)
-        
-        stage_ex = [ 1.,  1.,  6.,  6.,  6.,  6.,  6.,  6.,  6.,  6.,  6.,  6.,  1.,
-        6.,  6.,  1.,  6.,  6.,  6.,  6.,  6.,  6.,  6.,  6.,  6.,  6.,
-        6.,  6.,  6.,  6.,  6.,  6.,  6.,  6.,  6.,  6.,  6.,  6.,  6.,
-        6.,  6.,  6.,  6.,  6.,  6.,  6.,  6.,  6.,  6.,  1.,  1.,  6.,
-        6.,  6.,  6.,  6.,  6.,  6.,  6.,  6.,  6.,  6.,  1.,  1.]
-
-
-
-#        from pprint import pprint
-#        pprint (domain.quantities['elevation'].centroid_values)
-#        pprint (domain.quantities['stage'].centroid_values)
-#        print domain.quantities['xmomentum'].centroid_values
-#        print domain.quantities['ymomentum'].centroid_values
-
-        assert num.allclose(domain.quantities['elevation'].centroid_values, elev_ex)
-        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
-        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
-        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
-
-        # Apply Operator at time t=15.0
-        domain.set_time(15.0)
-        operator()
-
-
-        #pprint(domain.quantities['elevation'].centroid_values)
-
-        elev_ex = [ 0.,  0.,  7.,  7.,  7.,  7.,  7.,  7.,  7.,  7.,  7.,  7.,  0.,
-        7.,  7.,  0.,  7.,  7.,  7.,  7.,  7.,  7.,  7.,  7.,  7.,  7.,
-        7.,  7.,  7.,  7.,  7.,  7.,  7.,  7.,  7.,  7.,  7.,  7.,  7.,
-        7.,  7.,  7.,  7.,  7.,  7.,  7.,  7.,  7.,  7.,  0.,  0.,  7.,
-        7.,  7.,  7.,  7.,  7.,  7.,  7.,  7.,  7.,  7.,  0.,  0.]
-
-
-        #pprint(domain.quantities['stage'].centroid_values)
-
-        stage_ex = [ 1.,  1.,  8.,  8.,  8.,  8.,  8.,  8.,  8.,  8.,  8.,  8.,  1.,
-        8.,  8.,  1.,  8.,  8.,  8.,  8.,  8.,  8.,  8.,  8.,  8.,  8.,
-        8.,  8.,  8.,  8.,  8.,  8.,  8.,  8.,  8.,  8.,  8.,  8.,  8.,
-        8.,  8.,  8.,  8.,  8.,  8.,  8.,  8.,  8.,  8.,  1.,  1.,  8.,
-        8.,  8.,  8.,  8.,  8.,  8.,  8.,  8.,  8.,  8.,  1.,  1.]
-        
-
-#        from pprint import pprint
-#        pprint (domain.quantities['elevation'].centroid_values)
-#        pprint (domain.quantities['stage'].centroid_values)
-#        pprint (domain.quantities['xmomentum'].centroid_values)
-#        pprint (domain.quantities['ymomentum'].centroid_values)
-
-        assert num.allclose(domain.quantities['elevation'].centroid_values, elev_ex)
-        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
-        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
-        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
-
-        operator = Set_elevation(domain, elevation=0.0)
-
-
-        #print operator.value_type
-        
-        operator()
-
-        #from pprint import pprint
-#        pprint (domain.quantities['elevation'].centroid_values)
-#        pprint (domain.quantities['stage'].centroid_values)
-#        pprint (domain.quantities['xmomentum'].centroid_values)
-#        pprint (domain.quantities['ymomentum'].centroid_values)
-
-        assert num.allclose(domain.quantities['elevation'].centroid_values, 0.0)
-        assert num.allclose(domain.quantities['stage'].centroid_values, 1.0)
-        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
-        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
-
-
-        operator = Set_elevation(domain, elevation=lambda t: t, indices = [0,1,3])
-
-        operator()
-
-        #pprint (domain.quantities['elevation'].centroid_values)
-        #pprint (domain.quantities['stage'].centroid_values)
-
-        elev_ex = [ 15.,  15.,   0.,  15.,   0.,   0.,   0.,   0.,   0.,   0.,   0.,
-         0.,   0.,   0.,   0.,   0.,   0.,   0.,   0.,   0.,   0.,   0.,
-         0.,   0.,   0.,   0.,   0.,   0.,   0.,   0.,   0.,   0.,   0.,
-         0.,   0.,   0.,   0.,   0.,   0.,   0.,   0.,   0.,   0.,   0.,
-         0.,   0.,   0.,   0.,   0.,   0.,   0.,   0.,   0.,   0.,   0.,
-         0.,   0.,   0.,   0.,   0.,   0.,   0.,   0.,   0.]
-
-
-
-        stage_ex = [ 16.,  16.,   1.,  16.,   1.,   1.,   1.,   1.,   1.,   1.,   1.,
-         1.,   1.,   1.,   1.,   1.,   1.,   1.,   1.,   1.,   1.,   1.,
-         1.,   1.,   1.,   1.,   1.,   1.,   1.,   1.,   1.,   1.,   1.,
-         1.,   1.,   1.,   1.,   1.,   1.,   1.,   1.,   1.,   1.,   1.,
-         1.,   1.,   1.,   1.,   1.,   1.,   1.,   1.,   1.,   1.,   1.,
-         1.,   1.,   1.,   1.,   1.,   1.,   1.,   1.,   1.]
-        
-
-#        from pprint import pprint
-#        pprint (domain.quantities['elevation'].centroid_values)
-#        pprint (domain.quantities['stage'].centroid_values)
-#        pprint (domain.quantities['xmomentum'].centroid_values)
-#        pprint (domain.quantities['ymomentum'].centroid_values)
-
-        assert num.allclose(domain.quantities['elevation'].centroid_values, elev_ex)
-        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
-        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
-        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
-
-            
-if __name__ == "__main__":
-    suite = unittest.makeSuite(Test_set_elevation_operator, 'test')
-    runner = unittest.TextTestRunner(verbosity=1)
-    runner.run(suite)
Index: unk/anuga_core/source/anuga/operators/test_set_quantity.py
===================================================================
--- /trunk/anuga_core/source/anuga/operators/test_set_quantity.py	(revision 9444)
+++ 	(revision )
@@ -1,511 +1,0 @@
-"""  Test set_quantity
-"""
-
-import unittest, os
-import anuga
-from anuga import Domain
-from anuga import Reflective_boundary
-from anuga import rectangular_cross_domain
-from anuga import file_function
-
-from anuga.config import netcdf_mode_r, netcdf_mode_w, netcdf_mode_a
-from anuga.file_conversion.file_conversion import timefile2netcdf
-from anuga.config import time_format
-
-from set_quantity import *
-from set_stage import *
-
-import numpy as num
-from pprint import pprint
-import warnings
-import time
-
-
-
-class Test_set_quantity(unittest.TestCase):
-    def setUp(self):
-        pass
-
-    def tearDown(self):
-        pass
-
-
-    def test_set_quantity_simple(self):
-        from anuga.config import rho_a, rho_w, eta_w
-        from math import pi, cos, sin
-
-        a = [0.0, 0.0]
-        b = [0.0, 2.0]
-        c = [2.0, 0.0]
-        d = [0.0, 4.0]
-        e = [2.0, 2.0]
-        f = [4.0, 0.0]
-
-        points = [a, b, c, d, e, f]
-        #             bac,     bce,     ecf,     dbe
-        vertices = [[1,0,2], [1,2,4], [4,2,5], [3,1,4]]
-
-        domain = Domain(points, vertices)
-
-        #Flat surface with 1m of water
-        domain.set_quantity('elevation', 0)
-        domain.set_quantity('stage', 1.0)
-        domain.set_quantity('friction', 0)
-
-        Br = Reflective_boundary(domain)
-        domain.set_boundary({'exterior': Br})
-
-
-#        print domain.quantities['stage'].centroid_values
-#        print domain.quantities['xmomentum'].centroid_values
-#        print domain.quantities['ymomentum'].centroid_values
-
-        # Apply operator to these triangles
-        indices = [0,1,3]
-
-        stage = 3.0
-
-
-        update_stage = Set_quantity(domain, "stage", value=stage, indices=indices, test_stage=False)
-        
-        # Apply Operator
-        update_stage()
-
-        stage_ex = [ 3.,  3.,   1.,  3.]
-
-
-        #print domain.quantities['stage'].centroid_values
-        #print domain.quantities['xmomentum'].centroid_values
-        #print domain.quantities['ymomentum'].centroid_values
-
-        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
-        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
-        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
-
- 
-    def test_set_quantity_negative(self):
-        from anuga.config import rho_a, rho_w, eta_w
-        from math import pi, cos, sin
-
-        a = [0.0, 0.0]
-        b = [0.0, 2.0]
-        c = [2.0, 0.0]
-        d = [0.0, 4.0]
-        e = [2.0, 2.0]
-        f = [4.0, 0.0]
-
-        points = [a, b, c, d, e, f]
-        #             bac,     bce,     ecf,     dbe
-        vertices = [[1,0,2], [1,2,4], [4,2,5], [3,1,4]]
-
-        domain = Domain(points, vertices)
-
-        #Flat surface with 1m of water
-        domain.set_quantity('elevation', lambda x,y : -2*x)
-        domain.set_quantity('stage', 1.0)
-        domain.set_quantity('friction', 0)
-
-        Br = Reflective_boundary(domain)
-        domain.set_boundary({'exterior': Br})
-
-#        print domain.quantities['elevation'].centroid_values
-#        print domain.quantities['stage'].centroid_values
-#        print domain.quantities['xmomentum'].centroid_values
-#        print domain.quantities['ymomentum'].centroid_values
-
-        # Apply operator to these triangles
-        indices = [0,1,3]
-
-
-
-        #Catchment_Rain_Polygon = read_polygon(join('CatchmentBdy.csv'))
-        #rainfall = file_function(join('1y120m.tms'), quantities=['rainfall'])
-        stage = -5.0
-
-
-        try:
-            update_stage = Set_quantity(domain, 'stage', value=stage, indices=indices)
-        except AssertionError:
-            pass
-        except e:
-            self.fail('Unexpected exception thrown:', e)
-        else:
-            self.fail('ExpectedException not thrown')
-
-
-        update_stage = Set_quantity(domain, 'stage', value=stage, indices=indices, test_stage=False)
-        # Apply Operator
-        domain.timestep = 2.0
-        update_stage()
-
-        stage_ex = [ -5.,  -5.,   1.,  -5.]
-
-        #print domain.quantities['elevation'].centroid_values
-        #print domain.quantities['stage'].centroid_values
-        #print domain.quantities['xmomentum'].centroid_values
-        #print domain.quantities['ymomentum'].centroid_values
-
-        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
-        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
-        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
-        
-        update_stage = Set_stage(domain, stage=stage, indices=indices)
-        domain.timestep = 2.0
-        update_stage() 
-        
-        stage_ex = [-1.33333333, -2.66666667,  1.,         -1.33333333]
-        
-
-        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
-        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
-        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)      
-
-
-    def test_set_quantity_function(self):
-        from anuga.config import rho_a, rho_w, eta_w
-        from math import pi, cos, sin
-
-        a = [0.0, 0.0]
-        b = [0.0, 2.0]
-        c = [2.0, 0.0]
-        d = [0.0, 4.0]
-        e = [2.0, 2.0]
-        f = [4.0, 0.0]
-
-
-
-
-
-        points = [a, b, c, d, e, f]
-        #             bac,     bce,     ecf,     dbe
-        vertices = [[1,0,2], [1,2,4], [4,2,5], [3,1,4]]
-
-        domain = Domain(points, vertices)
-
-        #Flat surface with 1m of water
-        domain.set_quantity('elevation', 0)
-        domain.set_quantity('stage', 1.0)
-        domain.set_quantity('friction', 0)
-
-        Br = Reflective_boundary(domain)
-        domain.set_boundary({'exterior': Br})
-
-
-#        print domain.quantities['stage'].centroid_values
-#        print domain.quantities['xmomentum'].centroid_values
-#        print domain.quantities['ymomentum'].centroid_values
-
-        # Apply operator to these triangles
-        indices = [0,1,3]
-
-
-        def stage(t):
-            if t < 10.0:
-                return 5.0
-            else:
-                return 10.0
-
-        operator = Set_quantity(domain, 'stage', value=stage, indices=indices, test_stage=False)
-
-        # Apply Operator at time t=1.0
-        domain.set_time(1.0)
-        operator()
-
-        stage_ex = [ 5.,  5.,   1.,  5.]
-
-
-#        print domain.quantities['stage'].centroid_values
-#        print domain.quantities['xmomentum'].centroid_values
-#        print domain.quantities['ymomentum'].centroid_values
-
-        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
-        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
-        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
-
-        # Apply Operator at time t=15.0
-        domain.set_time(15.0)
-        operator()
-
-        stage_ex = [ 10.,  10.,   1.,  10.]
-
-
-#        print domain.quantities['stage'].centroid_values
-#        print domain.quantities['xmomentum'].centroid_values
-#        print domain.quantities['ymomentum'].centroid_values
-
-        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
-        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
-        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
-
-
-    def test_set_quantity_large_mesh_function(self):
-        from anuga.config import rho_a, rho_w, eta_w
-        from math import pi, cos, sin
-
-
-        length = 2.0
-        width = 2.0
-        dx = dy = 0.5
-        #dx = dy = 0.1
-        domain = rectangular_cross_domain(int(length/dx), int(width/dy),
-                                              len1=length, len2=width)
-
-
-        #Flat surface with 1m of water
-        domain.set_quantity('elevation', 0.0)
-        domain.set_quantity('stage', 1.0)
-        domain.set_quantity('friction', 0)
-
-        R = Reflective_boundary(domain)
-        domain.set_boundary( {'left': R, 'right': R, 'bottom': R, 'top': R} )
-
-
-#        print domain.quantities['stage'].centroid_values
-#        print domain.quantities['xmomentum'].centroid_values
-#        print domain.quantities['ymomentum'].centroid_values
-
-
-
-        def stage(t):
-            if t < 10.0:
-                return 5.0
-            else:
-                return 7.0
-
-        polygon = [(0.5,0.5), (1.5,0.5), (1.5,1.5), (0.5,1.5)]
-        #operator = Polygonal_set_stage_operator(domain, stage=stage, polygon=polygon)
-        operator = operator = Set_quantity(domain, 'stage', value=stage, polygon=polygon, test_stage=False)
-        
-
-
-        #operator.plot_region()
-        
-        # Apply Operator at time t=1.0
-        domain.set_time(1.0)
-        operator()
-
-
-        stage_ex_expanded = \
-                   [ 1.,  1.,  5.,  5.,  1.,  5.,  5.,  5.,  1.,  5.,  5.,  5.,  1.,
-                     5.,  5.,  1.,  5.,  1.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,
-                     5.,  5.,  5.,  5.,  5.,  1.,  5.,  1.,  5.,  5.,  5.,  5.,  5.,
-                     5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  1.,  5.,  1.,  1.,  5.,
-                     5.,  5.,  1.,  5.,  5.,  5.,  1.,  5.,  5.,  5.,  1.,  1.]
-
-        stage_ex = [ 1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,
-                     1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,
-                     5.0,  5.0,  5.0,  5.0,  5.0,  5.0,  5.0,  5.0,  1.0,  1.0,
-                     1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  5.0,  5.0,  5.0,  5.0,
-                     5.0,  5.0,  5.0,  5.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,
-                     1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,
-                     1.0,  1.0,  1.0,  1.0]
-
-
-#        print domain.quantities['elevation'].centroid_values
-#        pprint(domain.quantities['stage'].centroid_values)
-#        print domain.quantities['xmomentum'].centroid_values
-#        print domain.quantities['ymomentum'].centroid_values
-
-        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
-        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
-        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
-
-        # Apply Operator at time t=15.0
-        domain.set_time(15.0)
-        operator()
-
-        stage_ex_expanded = \
-                   [ 1.,  1.,  7.,  7.,  1.,  7.,  7.,  7.,  1.,  7.,  7.,  7.,  1.,
-                     7.,  7.,  1.,  7.,  1.,  7.,  7.,  7.,  7.,  7.,  7.,  7.,  7.,
-                     7.,  7.,  7.,  7.,  7.,  1.,  7.,  1.,  7.,  7.,  7.,  7.,  7.,
-                     7.,  7.,  7.,  7.,  7.,  7.,  7.,  7.,  1.,  7.,  1.,  1.,  7.,
-                     7.,  7.,  1.,  7.,  7.,  7.,  1.,  7.,  7.,  7.,  1.,  1.]
-
-
-        stage_ex = [ 1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,
-                     1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,
-                     7.0,  7.0,  7.0,  7.0,  7.0,  7.0,  7.0,  7.0,  1.0,  1.0,
-                     1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  7.0,  7.0,  7.0,  7.0,
-                     7.0,  7.0,  7.0,  7.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,
-                     1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,
-                     1.0,  1.0,  1.0,  1.0]
-
-
-#        pprint(domain.quantities['stage'].centroid_values)
-#        print domain.quantities['xmomentum'].centroid_values
-#        print domain.quantities['ymomentum'].centroid_values
-
-        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
-        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
-        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
-
-
-    def test_set_stage_operator_line(self):
-        
-        from math import pi, cos, sin
-
-
-        length = 2.0
-        width = 2.0
-        dx = dy = 0.5
-        #dx = dy = 0.1
-        domain = rectangular_cross_domain(int(length/dx), int(width/dy),
-                                              len1=length, len2=width)
-
-
-        #Flat surface with 1m of water
-        domain.set_quantity('elevation', -10.0)
-        domain.set_quantity('stage', -1.0)
-        domain.set_quantity('friction', 0)
-
-        R = Reflective_boundary(domain)
-        domain.set_boundary( {'left': R, 'right': R, 'bottom': R, 'top': R} )
-
-
-#        print domain.quantities['stage'].centroid_values
-#        print domain.quantities['xmomentum'].centroid_values
-#        print domain.quantities['ymomentum'].centroid_values
-
-
-
-        def stage(x,y, t):
-            #print x,y
-            if t < 10.0:
-                return x
-            else:
-                return y
-
-        line = [(0.5,0.5), (1.5,0.75)]
-        
-        operator = Set_quantity(domain, 'stage', value=stage, line=line, test_stage=False)
-
-
-        #print 'stage at 1',stage(3.0,4.0,1.0) # return x value
-        #print 'stage at 15', stage(3.0,4.0,15.0) # return y value
-        #print operator.indices
-        #print operator.value_type
-        
-        
-        # Apply Operator at time t=1.0
-        domain.set_time(1.0)
-        operator()
-
-
-
-
-        stage_ex = [-1.        , -1.        ,  0.41666667,  0.25      , -1.        ,
-        0.25      ,  0.41666667, -1.        , -1.        , -1.        ,
-       -1.        , -1.        , -1.        , -1.        , -1.        ,
-       -1.        ,  0.58333333, -1.        , -1.        ,  0.75      ,
-        0.58333333,  0.75      ,  0.91666667, -1.        , -1.        ,
-       -1.        , -1.        , -1.        , -1.        , -1.        ,
-       -1.        , -1.        , -1.        , -1.        , -1.        ,
-       -1.        ,  1.08333333,  1.25      ,  1.41666667, -1.        ,
-       -1.        , -1.        , -1.        , -1.        , -1.        ,
-       -1.        , -1.        , -1.        , -1.        , -1.        ,
-       -1.        , -1.        ,  1.58333333, -1.        , -1.        ,
-       -1.        , -1.        , -1.        , -1.        , -1.        ,
-       -1.        , -1.        , -1.        , -1.        ]
-
-
-        #from pprint import pprint
-#         pprint(domain.quantities['stage'].centroid_values)
-#        pprint(domain.quantities['stage'].centroid_values)
-
-
-        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
-        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
-        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
-
-        # Apply Operator at time t=15.0
-        domain.set_time(15.0)
-        operator()
-
-
-
-
-        stage_ex = [-1.        , -1.        ,  0.25      ,  0.41666667, -1.        ,
-        0.58333333,  0.75      , -1.        , -1.        , -1.        ,
-       -1.        , -1.        , -1.        , -1.        , -1.        ,
-       -1.        ,  0.25      , -1.        , -1.        ,  0.41666667,
-        0.75      ,  0.58333333,  0.75      , -1.        , -1.        ,
-       -1.        , -1.        , -1.        , -1.        , -1.        ,
-       -1.        , -1.        , -1.        , -1.        , -1.        ,
-       -1.        ,  0.75      ,  0.58333333,  0.75      , -1.        ,
-       -1.        , -1.        , -1.        , -1.        , -1.        ,
-       -1.        , -1.        , -1.        , -1.        , -1.        ,
-       -1.        , -1.        ,  0.75      , -1.        , -1.        ,
-       -1.        , -1.        , -1.        , -1.        , -1.        ,
-       -1.        , -1.        , -1.        , -1.        ]
-
-
-
-
-
-                
-               
-        Plot = False
-        if Plot:
-            operator.plot_region()
-            
-            cellsize = 0.01
-            domain.quantities['stage'].extrapolate_second_order_and_limit_by_vertex()
-            
-            from pprint import pprint
-        
-            pprint(domain.quantities['stage'].centroid_values)
-            
-            x,y,z = domain.quantities['stage'].save_to_array(cellsize=cellsize, smooth=False) 
-            
-            #pprint(z)
-            
-            import pylab
-            import numpy
-            #a = numpy.where(a == -9999, numpy.nan, a)
-            #a = numpy.where(a > 10.0, numpy.nan, a)
-        
-            #z = z[::-1,:]
-
-            """
-            print z
-            print z.shape
-            print x
-            print y
-            """
-            
-            nrows = z.shape[0]
-            ncols = z.shape[1]            
-            
-            
-            ratio = float(nrows)/float(ncols)
-            print ratio
-            
-            #y = numpy.arange(nrows)*cellsize
-            #x = numpy.arange(ncols)*cellsize
-        
-            #Setup fig size to correpond to array size
-            fig = pylab.figure(figsize=(10, 10*ratio))
-        
-            levels = numpy.arange(-2.0, 2, 0.01)
-            CF = pylab.contourf(x,y,z, levels=levels)
-            CB = pylab.colorbar(CF, shrink=0.8, extend='both')
-            #CC = pylab.contour(x,y,a, levels=levels)
-            
-            pylab.show()
-        
-
-        from pprint import pprint
-        #pprint(domain.quantities['stage'].centroid_values)
-#        print domain.quantities['xmomentum'].centroid_values
-#        print domain.quantities['ymomentum'].centroid_values
-
-        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
-        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
-        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
-
-
-
-if __name__ == "__main__":
-    suite = unittest.makeSuite(Test_set_quantity, 'test')
-    runner = unittest.TextTestRunner(verbosity=1)
-    runner.run(suite)
Index: unk/anuga_core/source/anuga/operators/test_set_stage_operator.py
===================================================================
--- /trunk/anuga_core/source/anuga/operators/test_set_stage_operator.py	(revision 9444)
+++ 	(revision )
@@ -1,491 +1,0 @@
-"""  Test set operators - stage elevation erosion.
-"""
-
-import unittest, os
-import anuga
-from anuga import Domain
-from anuga import Reflective_boundary
-from anuga import rectangular_cross_domain
-from anuga import file_function
-
-from anuga.config import netcdf_mode_r, netcdf_mode_w, netcdf_mode_a
-from anuga.file_conversion.file_conversion import timefile2netcdf
-from anuga.config import time_format
-
-from set_stage_operator import *
-
-import numpy as num
-from pprint import pprint
-import warnings
-import time
-
-
-
-class Test_set_stage_operators(unittest.TestCase):
-    def setUp(self):
-        pass
-
-    def tearDown(self):
-        pass
-
-
-    def test_set_stage_operator_simple(self):
-        from anuga.config import rho_a, rho_w, eta_w
-        from math import pi, cos, sin
-
-        a = [0.0, 0.0]
-        b = [0.0, 2.0]
-        c = [2.0, 0.0]
-        d = [0.0, 4.0]
-        e = [2.0, 2.0]
-        f = [4.0, 0.0]
-
-        points = [a, b, c, d, e, f]
-        #             bac,     bce,     ecf,     dbe
-        vertices = [[1,0,2], [1,2,4], [4,2,5], [3,1,4]]
-
-        domain = Domain(points, vertices)
-
-        #Flat surface with 1m of water
-        domain.set_quantity('elevation', 0)
-        domain.set_quantity('stage', 1.0)
-        domain.set_quantity('friction', 0)
-
-        Br = Reflective_boundary(domain)
-        domain.set_boundary({'exterior': Br})
-
-
-#        print domain.quantities['stage'].centroid_values
-#        print domain.quantities['xmomentum'].centroid_values
-#        print domain.quantities['ymomentum'].centroid_values
-
-        # Apply operator to these triangles
-        indices = [0,1,3]
-
-        stage = 3.0
-
-
-        operator = Set_stage_operator(domain, stage=stage, indices=indices)
-        
-        # Apply Operator
-        domain.timestep = 2.0
-        operator()
-
-        stage_ex = [ 3.,  3.,   1.,  3.]
-
-
-        #print domain.quantities['stage'].centroid_values
-        #print domain.quantities['xmomentum'].centroid_values
-        #print domain.quantities['ymomentum'].centroid_values
-
-        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
-        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
-        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
-
- 
-    def test_set_stage_operator_negative(self):
-        from anuga.config import rho_a, rho_w, eta_w
-        from math import pi, cos, sin
-
-        a = [0.0, 0.0]
-        b = [0.0, 2.0]
-        c = [2.0, 0.0]
-        d = [0.0, 4.0]
-        e = [2.0, 2.0]
-        f = [4.0, 0.0]
-
-        points = [a, b, c, d, e, f]
-        #             bac,     bce,     ecf,     dbe
-        vertices = [[1,0,2], [1,2,4], [4,2,5], [3,1,4]]
-
-        domain = Domain(points, vertices)
-
-        #Flat surface with 1m of water
-        domain.set_quantity('elevation', lambda x,y : -2*x)
-        domain.set_quantity('stage', 1.0)
-        domain.set_quantity('friction', 0)
-
-        Br = Reflective_boundary(domain)
-        domain.set_boundary({'exterior': Br})
-
-#        print domain.quantities['elevation'].centroid_values
-#        print domain.quantities['stage'].centroid_values
-#        print domain.quantities['xmomentum'].centroid_values
-#        print domain.quantities['ymomentum'].centroid_values
-
-        # Apply operator to these triangles
-        indices = [0,1,3]
-
-
-
-        #Catchment_Rain_Polygon = read_polygon(join('CatchmentBdy.csv'))
-        #rainfall = file_function(join('1y120m.tms'), quantities=['rainfall'])
-        stage = -5.0
-
-
-        operator = Set_stage_operator(domain, stage=stage, indices=indices)
-
-
-        # Apply Operator
-        domain.timestep = 2.0
-        operator()
-
-        stage_ex = [ -5.,  -5.,   1.,  -5.]
-
-        #print domain.quantities['elevation'].centroid_values
-        #print domain.quantities['stage'].centroid_values
-        #print domain.quantities['xmomentum'].centroid_values
-        #print domain.quantities['ymomentum'].centroid_values
-
-        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
-        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
-        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
-
-
-    def test_set_stage_operator_function(self):
-        from anuga.config import rho_a, rho_w, eta_w
-        from math import pi, cos, sin
-
-        a = [0.0, 0.0]
-        b = [0.0, 2.0]
-        c = [2.0, 0.0]
-        d = [0.0, 4.0]
-        e = [2.0, 2.0]
-        f = [4.0, 0.0]
-
-
-
-
-
-        points = [a, b, c, d, e, f]
-        #             bac,     bce,     ecf,     dbe
-        vertices = [[1,0,2], [1,2,4], [4,2,5], [3,1,4]]
-
-        domain = Domain(points, vertices)
-
-        #Flat surface with 1m of water
-        domain.set_quantity('elevation', 0)
-        domain.set_quantity('stage', 1.0)
-        domain.set_quantity('friction', 0)
-
-        Br = Reflective_boundary(domain)
-        domain.set_boundary({'exterior': Br})
-
-
-#        print domain.quantities['stage'].centroid_values
-#        print domain.quantities['xmomentum'].centroid_values
-#        print domain.quantities['ymomentum'].centroid_values
-
-        # Apply operator to these triangles
-        indices = [0,1,3]
-
-
-        def stage(t):
-            if t < 10.0:
-                return 5.0
-            else:
-                return 10.0
-
-        operator = Set_stage_operator(domain, stage=stage, indices=indices)
-
-        # Apply Operator at time t=1.0
-        domain.set_time(1.0)
-        operator()
-
-        stage_ex = [ 5.,  5.,   1.,  5.]
-
-
-#        print domain.quantities['stage'].centroid_values
-#        print domain.quantities['xmomentum'].centroid_values
-#        print domain.quantities['ymomentum'].centroid_values
-
-        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
-        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
-        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
-
-        # Apply Operator at time t=15.0
-        domain.set_time(15.0)
-        operator()
-
-        stage_ex = [ 10.,  10.,   1.,  10.]
-
-
-#        print domain.quantities['stage'].centroid_values
-#        print domain.quantities['xmomentum'].centroid_values
-#        print domain.quantities['ymomentum'].centroid_values
-
-        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
-        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
-        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
-
-
-    def test_set_stage_operator_large_function(self):
-        from anuga.config import rho_a, rho_w, eta_w
-        from math import pi, cos, sin
-
-
-        length = 2.0
-        width = 2.0
-        dx = dy = 0.5
-        #dx = dy = 0.1
-        domain = rectangular_cross_domain(int(length/dx), int(width/dy),
-                                              len1=length, len2=width)
-
-
-        #Flat surface with 1m of water
-        domain.set_quantity('elevation', 0.0)
-        domain.set_quantity('stage', 1.0)
-        domain.set_quantity('friction', 0)
-
-        R = Reflective_boundary(domain)
-        domain.set_boundary( {'left': R, 'right': R, 'bottom': R, 'top': R} )
-
-
-#        print domain.quantities['stage'].centroid_values
-#        print domain.quantities['xmomentum'].centroid_values
-#        print domain.quantities['ymomentum'].centroid_values
-
-
-
-        def stage(t):
-            if t < 10.0:
-                return 5.0
-            else:
-                return 7.0
-
-        polygon = [(0.5,0.5), (1.5,0.5), (1.5,1.5), (0.5,1.5)]
-        #operator = Polygonal_set_stage_operator(domain, stage=stage, polygon=polygon)
-        operator = Polygonal_set_stage_operator(domain, stage=stage, polygon=polygon)
-
-
-        #operator.plot_region()
-        
-        # Apply Operator at time t=1.0
-        domain.set_time(1.0)
-        operator()
-
-
-        stage_ex_expanded = \
-                   [ 1.,  1.,  5.,  5.,  1.,  5.,  5.,  5.,  1.,  5.,  5.,  5.,  1.,
-                     5.,  5.,  1.,  5.,  1.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,
-                     5.,  5.,  5.,  5.,  5.,  1.,  5.,  1.,  5.,  5.,  5.,  5.,  5.,
-                     5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  1.,  5.,  1.,  1.,  5.,
-                     5.,  5.,  1.,  5.,  5.,  5.,  1.,  5.,  5.,  5.,  1.,  1.]
-
-        stage_ex = [ 1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,
-                     1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,
-                     5.0,  5.0,  5.0,  5.0,  5.0,  5.0,  5.0,  5.0,  1.0,  1.0,
-                     1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  5.0,  5.0,  5.0,  5.0,
-                     5.0,  5.0,  5.0,  5.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,
-                     1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,
-                     1.0,  1.0,  1.0,  1.0]
-
-
-#        print domain.quantities['elevation'].centroid_values
-#        pprint(domain.quantities['stage'].centroid_values)
-#        print domain.quantities['xmomentum'].centroid_values
-#        print domain.quantities['ymomentum'].centroid_values
-
-        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
-        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
-        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
-
-        # Apply Operator at time t=15.0
-        domain.set_time(15.0)
-        operator()
-
-        stage_ex_expanded = \
-                   [ 1.,  1.,  7.,  7.,  1.,  7.,  7.,  7.,  1.,  7.,  7.,  7.,  1.,
-                     7.,  7.,  1.,  7.,  1.,  7.,  7.,  7.,  7.,  7.,  7.,  7.,  7.,
-                     7.,  7.,  7.,  7.,  7.,  1.,  7.,  1.,  7.,  7.,  7.,  7.,  7.,
-                     7.,  7.,  7.,  7.,  7.,  7.,  7.,  7.,  1.,  7.,  1.,  1.,  7.,
-                     7.,  7.,  1.,  7.,  7.,  7.,  1.,  7.,  7.,  7.,  1.,  1.]
-
-
-        stage_ex = [ 1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,
-                     1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,
-                     7.0,  7.0,  7.0,  7.0,  7.0,  7.0,  7.0,  7.0,  1.0,  1.0,
-                     1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  7.0,  7.0,  7.0,  7.0,
-                     7.0,  7.0,  7.0,  7.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,
-                     1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,  1.0,
-                     1.0,  1.0,  1.0,  1.0]
-
-
-#        pprint(domain.quantities['stage'].centroid_values)
-#        print domain.quantities['xmomentum'].centroid_values
-#        print domain.quantities['ymomentum'].centroid_values
-
-        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
-        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
-        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
-
-
-    def test_set_stage_operator_line(self):
-        
-        from math import pi, cos, sin
-
-
-        length = 2.0
-        width = 2.0
-        dx = dy = 0.5
-        #dx = dy = 0.1
-        domain = rectangular_cross_domain(int(length/dx), int(width/dy),
-                                              len1=length, len2=width)
-
-
-        #Flat surface with 1m of water
-        domain.set_quantity('elevation', -10.0)
-        domain.set_quantity('stage', -1.0)
-        domain.set_quantity('friction', 0)
-
-        R = Reflective_boundary(domain)
-        domain.set_boundary( {'left': R, 'right': R, 'bottom': R, 'top': R} )
-
-
-#        print domain.quantities['stage'].centroid_values
-#        print domain.quantities['xmomentum'].centroid_values
-#        print domain.quantities['ymomentum'].centroid_values
-
-
-
-        def stage(x,y, t):
-            #print x,y
-            if t < 10.0:
-                return x
-            else:
-                return y
-
-        line = [(0.5,0.5), (1.5,0.75)]
-        
-        operator = Set_stage_operator(domain, stage=stage, line=line)
-
-
-        #print 'stage at 1',stage(3.0,4.0,1.0) # return x value
-        #print 'stage at 15', stage(3.0,4.0,15.0) # return y value
-        #print operator.indices
-        #print operator.value_type
-        
-        
-        # Apply Operator at time t=1.0
-        domain.set_time(1.0)
-        operator()
-
-
-
-
-        stage_ex = [-1.        , -1.        ,  0.41666667,  0.25      , -1.        ,
-        0.25      ,  0.41666667, -1.        , -1.        , -1.        ,
-       -1.        , -1.        , -1.        , -1.        , -1.        ,
-       -1.        ,  0.58333333, -1.        , -1.        ,  0.75      ,
-        0.58333333,  0.75      ,  0.91666667, -1.        , -1.        ,
-       -1.        , -1.        , -1.        , -1.        , -1.        ,
-       -1.        , -1.        , -1.        , -1.        , -1.        ,
-       -1.        ,  1.08333333,  1.25      ,  1.41666667, -1.        ,
-       -1.        , -1.        , -1.        , -1.        , -1.        ,
-       -1.        , -1.        , -1.        , -1.        , -1.        ,
-       -1.        , -1.        ,  1.58333333, -1.        , -1.        ,
-       -1.        , -1.        , -1.        , -1.        , -1.        ,
-       -1.        , -1.        , -1.        , -1.        ]
-
-
-        #from pprint import pprint
-#         pprint(domain.quantities['stage'].centroid_values)
-#        pprint(domain.quantities['stage'].centroid_values)
-
-
-        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
-        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
-        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
-
-        # Apply Operator at time t=15.0
-        domain.set_time(15.0)
-        operator()
-
-
-
-
-        stage_ex = [-1.        , -1.        ,  0.25      ,  0.41666667, -1.        ,
-        0.58333333,  0.75      , -1.        , -1.        , -1.        ,
-       -1.        , -1.        , -1.        , -1.        , -1.        ,
-       -1.        ,  0.25      , -1.        , -1.        ,  0.41666667,
-        0.75      ,  0.58333333,  0.75      , -1.        , -1.        ,
-       -1.        , -1.        , -1.        , -1.        , -1.        ,
-       -1.        , -1.        , -1.        , -1.        , -1.        ,
-       -1.        ,  0.75      ,  0.58333333,  0.75      , -1.        ,
-       -1.        , -1.        , -1.        , -1.        , -1.        ,
-       -1.        , -1.        , -1.        , -1.        , -1.        ,
-       -1.        , -1.        ,  0.75      , -1.        , -1.        ,
-       -1.        , -1.        , -1.        , -1.        , -1.        ,
-       -1.        , -1.        , -1.        , -1.        ]
-
-
-
-
-
-                
-               
-        Plot = False
-        if Plot:
-            operator.plot_region()
-            
-            cellsize = 0.01
-            domain.quantities['stage'].extrapolate_second_order_and_limit_by_vertex()
-            
-            from pprint import pprint
-        
-            pprint(domain.quantities['stage'].centroid_values)
-            
-            x,y,z = domain.quantities['stage'].save_to_array(cellsize=cellsize, smooth=False) 
-            
-            #pprint(z)
-            
-            import pylab
-            import numpy
-            #a = numpy.where(a == -9999, numpy.nan, a)
-            #a = numpy.where(a > 10.0, numpy.nan, a)
-        
-            #z = z[::-1,:]
-
-            """
-            print z
-            print z.shape
-            print x
-            print y
-            """
-            
-            nrows = z.shape[0]
-            ncols = z.shape[1]            
-            
-            
-            ratio = float(nrows)/float(ncols)
-            print ratio
-            
-            #y = numpy.arange(nrows)*cellsize
-            #x = numpy.arange(ncols)*cellsize
-        
-            #Setup fig size to correpond to array size
-            fig = pylab.figure(figsize=(10, 10*ratio))
-        
-            levels = numpy.arange(-2.0, 2, 0.01)
-            CF = pylab.contourf(x,y,z, levels=levels)
-            CB = pylab.colorbar(CF, shrink=0.8, extend='both')
-            #CC = pylab.contour(x,y,a, levels=levels)
-            
-            pylab.show()
-        
-
-        from pprint import pprint
-        #pprint(domain.quantities['stage'].centroid_values)
-#        print domain.quantities['xmomentum'].centroid_values
-#        print domain.quantities['ymomentum'].centroid_values
-
-        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
-        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
-        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
-
-
-
-if __name__ == "__main__":
-    suite = unittest.makeSuite(Test_set_stage_operators, 'test')
-    runner = unittest.TextTestRunner(verbosity=1)
-    runner.run(suite)
Index: unk/anuga_core/source/anuga/operators/test_set_w_uh_vh_operators.py
===================================================================
--- /trunk/anuga_core/source/anuga/operators/test_set_w_uh_vh_operators.py	(revision 9444)
+++ 	(revision )
@@ -1,211 +1,0 @@
-"""  Test set operators - w_uh_vh elevation erosion.
-"""
-
-import unittest, os
-import anuga
-from anuga import Domain
-from anuga import Reflective_boundary
-from anuga import rectangular_cross_domain
-from anuga import file_function
-
-from anuga.config import netcdf_mode_r, netcdf_mode_w, netcdf_mode_a
-from anuga.file_conversion.file_conversion import timefile2netcdf
-from anuga.config import time_format
-
-from set_w_uh_vh_operator import *
-
-import numpy as num
-import warnings
-import time
-
-
-
-class Test_set_w_uh_vh_operators(unittest.TestCase):
-    def setUp(self):
-        pass
-
-    def tearDown(self):
-        pass
-
-
-    def test_set_w_uh_vh_operator_simple(self):
-        from anuga.config import rho_a, rho_w, eta_w
-        from math import pi, cos, sin
-
-        a = [0.0, 0.0]
-        b = [0.0, 2.0]
-        c = [2.0, 0.0]
-        d = [0.0, 4.0]
-        e = [2.0, 2.0]
-        f = [4.0, 0.0]
-
-        points = [a, b, c, d, e, f]
-        #             bac,     bce,     ecf,     dbe
-        vertices = [[1,0,2], [1,2,4], [4,2,5], [3,1,4]]
-
-        domain = Domain(points, vertices)
-
-        #Flat surface with 1m of water
-        domain.set_quantity('elevation', 0)
-        domain.set_quantity('stage', 1.0)
-        domain.set_quantity('xmomentum', 7.0)
-        domain.set_quantity('ymomentum', 8.0)
-        domain.set_quantity('friction', 0)
-
-        Br = Reflective_boundary(domain)
-        domain.set_boundary({'exterior': Br})
-
-
-#        print domain.quantities['w_uh_vh'].centroid_values
-#        print domain.quantities['xmomentum'].centroid_values
-#        print domain.quantities['ymomentum'].centroid_values
-
-        # Apply operator to these triangles
-        indices = [0,1,3]
-
-        w_uh_vh = [3.0, 4.0, 5.0]
-
-
-        operator = Set_w_uh_vh_operator(domain, w_uh_vh=w_uh_vh, indices=indices)
-        
-        # Apply Operator
-        domain.timestep = 2.0
-        operator()
-
-        stage_ex = [ 3.,  3.,   1.,  3.]
-        xmom_ex = [ 4.,  4.,   7.,  4.]
-        ymom_ex = [ 5.,  5.,   8.,  5.]
-
-
-        #print domain.quantities['stage'].centroid_values
-        #print domain.quantities['xmomentum'].centroid_values
-        #print domain.quantities['ymomentum'].centroid_values
-
-        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
-        assert num.allclose(domain.quantities['xmomentum'].centroid_values, xmom_ex)
-        assert num.allclose(domain.quantities['ymomentum'].centroid_values, ymom_ex)
-
-    def test_set_w_uh_vh_operator_simple_time(self):
-        from anuga.config import rho_a, rho_w, eta_w
-        from math import pi, cos, sin
-
-        a = [0.0, 0.0]
-        b = [0.0, 2.0]
-        c = [2.0, 0.0]
-        d = [0.0, 4.0]
-        e = [2.0, 2.0]
-        f = [4.0, 0.0]
-
-        points = [a, b, c, d, e, f]
-        #             bac,     bce,     ecf,     dbe
-        vertices = [[1,0,2], [1,2,4], [4,2,5], [3,1,4]]
-
-        domain = Domain(points, vertices)
-
-        #Flat surface with 1m of water
-        domain.set_quantity('elevation', 0)
-        domain.set_quantity('stage', 1.0)
-        domain.set_quantity('xmomentum', 7.0)
-        domain.set_quantity('ymomentum', 8.0)
-        domain.set_quantity('friction', 0)
-
-        Br = Reflective_boundary(domain)
-        domain.set_boundary({'exterior': Br})
-
-
-#        print domain.quantities['w_uh_vh'].centroid_values
-#        print domain.quantities['xmomentum'].centroid_values
-#        print domain.quantities['ymomentum'].centroid_values
-
-        # Apply operator to these triangles
-        indices = [0,1,3]
-
-        w_uh_vh = lambda t : [3.0, 4.0, 5.0]
-
-
-        operator = Set_w_uh_vh_operator(domain, w_uh_vh=w_uh_vh, indices=indices)
-        
-        # Apply Operator
-        domain.timestep = 2.0
-        operator()
-
-        stage_ex = [ 3.,  3.,   1.,  3.]
-        xmom_ex = [ 4.,  4.,   7.,  4.]
-        ymom_ex = [ 5.,  5.,   8.,  5.]
-
-
-        #print domain.quantities['stage'].centroid_values
-        #print domain.quantities['xmomentum'].centroid_values
-        #print domain.quantities['ymomentum'].centroid_values
-
-        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
-        assert num.allclose(domain.quantities['xmomentum'].centroid_values, xmom_ex)
-        assert num.allclose(domain.quantities['ymomentum'].centroid_values, ymom_ex)
-
-
-    def test_set_w_uh_vh_operator_time(self):
-        from anuga.config import rho_a, rho_w, eta_w
-        from math import pi, cos, sin
-
-        a = [0.0, 0.0]
-        b = [0.0, 2.0]
-        c = [2.0, 0.0]
-        d = [0.0, 4.0]
-        e = [2.0, 2.0]
-        f = [4.0, 0.0]
-
-        points = [a, b, c, d, e, f]
-        #             bac,     bce,     ecf,     dbe
-        vertices = [[1,0,2], [1,2,4], [4,2,5], [3,1,4]]
-
-        domain = Domain(points, vertices)
-
-        #Flat surface with 1m of water
-        domain.set_quantity('elevation', 0)
-        domain.set_quantity('stage', 1.0)
-        domain.set_quantity('xmomentum', 7.0)
-        domain.set_quantity('ymomentum', 8.0)
-        domain.set_quantity('friction', 0)
-
-        Br = Reflective_boundary(domain)
-        domain.set_boundary({'exterior': Br})
-
-
-#        print domain.quantities['w_uh_vh'].centroid_values
-#        print domain.quantities['xmomentum'].centroid_values
-#        print domain.quantities['ymomentum'].centroid_values
-
-        # Apply operator to these triangles
-        indices = [0,1,3]
-
-        w_uh_vh = lambda t : [t, t+1, t+2]
-
-
-        operator = Set_w_uh_vh_operator(domain, w_uh_vh=w_uh_vh, indices=indices)
-        
-        # Apply Operator
-        domain.timestep = 2.0
-        domain.time = 1.0
-        operator()
-
-        t = domain.time
-        stage_ex = [ t,  t,   1.,  t]
-        xmom_ex = [ t+1,  t+1,   7.,  t+1]
-        ymom_ex = [ t+2,  t+2,   8.,  t+2]
-
-
-        #print domain.quantities['stage'].centroid_values
-        #print domain.quantities['xmomentum'].centroid_values
-        #print domain.quantities['ymomentum'].centroid_values
-
-        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex)
-        assert num.allclose(domain.quantities['xmomentum'].centroid_values, xmom_ex)
-        assert num.allclose(domain.quantities['ymomentum'].centroid_values, ymom_ex)
-
-
-
-
-if __name__ == "__main__":
-    suite = unittest.makeSuite(Test_set_w_uh_vh_operators, 'test')
-    runner = unittest.TextTestRunner(verbosity=1)
-    runner.run(suite)
