Index: /trunk/anuga_core/source/anuga/__init__.py
===================================================================
--- /trunk/anuga_core/source/anuga/__init__.py	(revision 9000)
+++ /trunk/anuga_core/source/anuga/__init__.py	(revision 9001)
@@ -32,8 +32,7 @@
 
 from anuga.shallow_water.shallow_water_domain import Domain
-
 from anuga.abstract_2d_finite_volumes.quantity import Quantity
-
-from anuga.operators.region import Region
+from anuga.abstract_2d_finite_volumes.region import Region
+
 
 from anuga.abstract_2d_finite_volumes.util import file_function, \
Index: /trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/generic_domain.py
===================================================================
--- /trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/generic_domain.py	(revision 9000)
+++ /trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/generic_domain.py	(revision 9001)
@@ -895,9 +895,9 @@
 
         if len(args) == 1:
-            self._set_region(*args, **kwargs)
+            self._set_tag_region(*args, **kwargs)
         else:
             # Assume it is arguments for the region.set_region function
             func = region_set_tag_region(*args, **kwargs)
-            self._set_region(func)
+            self._set_tag_region(func)
 
     def _set_tag_region(self, functions):
Index: /trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/tag_region.py
===================================================================
--- /trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/tag_region.py	(revision 9000)
+++ /trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/tag_region.py	(revision 9001)
@@ -11,5 +11,5 @@
 
 
-class Region:
+class Tag_region:
     """Base class for modifying quantities based on a region.
     """   
@@ -32,5 +32,5 @@
             return elements
                 
-class Set_region(Region):
+class Set_tag_region(Tag_region):
     
     def __init__(self, tag, quantity, X, location='vertices'):
@@ -42,5 +42,5 @@
         """
         
-        Region.__init__(self)
+        Tag_region.__init__(self)
         self.tag = tag 
         self.quantity = quantity
@@ -61,5 +61,5 @@
 
         
-class Add_value_to_region(Region):
+class Add_value_to_region(Tag_region):
     """
     Will add a value to the current quantity value.
@@ -114,5 +114,5 @@
                                 location=self.location)
 
-class Add_quantities(Region):
+class Add_quantities(Tag_region):
     """
     Will add a quantity to the current quantity value.
@@ -157,5 +157,5 @@
 
 
-class Stage_no_less_than_elevation(Region):
+class Stage_no_less_than_elevation(Tag_region):
     """
     Will set the stage to not be less than the elevation.
Index: /trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/test_generic_domain.py
===================================================================
--- /trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/test_generic_domain.py	(revision 9000)
+++ /trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/test_generic_domain.py	(revision 9001)
@@ -815,5 +815,5 @@
 
         domain.build_tagged_elements_dictionary({'mound':[0,1]})
-        domain.set_region([add_to_verts])
+        domain.set_tag_region([add_to_verts])
 
         self.failUnless(domain.test == "Mound",
Index: /trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/test_tag_region.py
===================================================================
--- /trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/test_tag_region.py	(revision 9000)
+++ /trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/test_tag_region.py	(revision 9001)
@@ -7,5 +7,5 @@
 from anuga.shallow_water.shallow_water_domain import Domain
 from generic_domain import Generic_Domain
-from region import *
+from tag_region import *
 #from anuga.config import epsilon
 
@@ -59,7 +59,7 @@
         domain.set_quantity('friction', manning)
 
-        a = Set_region('bottom', 'friction', 0.09)
-        b = Set_region('top', 'friction', 1.0)
-        domain.set_region([a, b])
+        a = Set_tag_region('bottom', 'friction', 0.09)
+        b = Set_tag_region('top', 'friction', 1.0)
+        domain.set_tag_region([a, b])
 
         expected = [[ 0.09,  0.09,  0.09],
@@ -76,5 +76,5 @@
 
         #c = Add_Value_To_region('all', 'friction', 10.0)
-        domain.set_region(Add_value_to_region('all', 'friction', 10.0))
+        domain.set_tag_region(Add_value_to_region('all', 'friction', 10.0))
         #print domain.quantities['friction'].get_values()
         assert num.allclose(domain.quantities['friction'].get_values(),
@@ -87,5 +87,5 @@
 
         # trying a function
-        domain.set_region(Set_region('top', 'friction', add_x_y))
+        domain.set_tag_region(Set_tag_region('top', 'friction', add_x_y))
         #print domain.quantities['friction'].get_values()
         assert num.allclose(domain.quantities['friction'].get_values(),
@@ -99,5 +99,5 @@
         domain.set_quantity('elevation', 10.0)
         domain.set_quantity('stage', 10.0)
-        domain.set_region(Add_value_to_region('top', 'stage', 1.0,initial_quantity='elevation'))
+        domain.set_tag_region(Add_value_to_region('top', 'stage', 1.0,initial_quantity='elevation'))
         #print domain.quantities['stage'].get_values()
         assert num.allclose(domain.quantities['stage'].get_values(),
@@ -116,5 +116,5 @@
         #                    domain.quantities['stage'].vertex_values+ \
         #                    domain.quantities['elevation'].vertex_values)
-        domain.set_region(Add_quantities('top', 'elevation','stage'))
+        domain.set_tag_region(Add_quantities('top', 'elevation','stage'))
         #print domain.quantities['stage'].get_values()
         assert num.allclose(domain.quantities['elevation'].get_values(),
@@ -142,6 +142,6 @@
         domain.set_quantity('friction', manning)
 
-        a = Set_region('bottom', 'friction', 0.09, location = 'unique vertices')
-        domain.set_region(a)
+        a = Set_tag_region('bottom', 'friction', 0.09, location = 'unique vertices')
+        domain.set_tag_region(a)
         assert num.allclose(domain.quantities['friction'].get_values(),
                             [[ 0.09,  0.09,  0.09],
@@ -171,5 +171,5 @@
         domain.set_quantity('friction', manning)
 
-        domain.set_region(Add_value_to_region('bottom', 'friction', 1.0,initial_quantity='friction', location = 'unique vertices'))
+        domain.set_tag_region(Add_value_to_region('bottom', 'friction', 1.0,initial_quantity='friction', location = 'unique vertices'))
 
         #print domain.quantities['friction'].get_values()
@@ -199,5 +199,5 @@
         add = 60.0
         calc_frict = av_bottom + add
-        domain.set_region(Add_value_to_region('bottom', 'friction', add,
+        domain.set_tag_region(Add_value_to_region('bottom', 'friction', add,
                                               initial_quantity='friction',
                                               location='vertices',
@@ -233,5 +233,5 @@
         add = 60.0
         calc_frict = av_bottom + add
-        domain.set_region(Add_value_to_region('bottom', 'friction', add,
+        domain.set_tag_region(Add_value_to_region('bottom', 'friction', add,
                           initial_quantity='friction',
                            location='unique vertices',
Index: /trunk/anuga_core/source/anuga/operators/erosion_operators.py
===================================================================
--- /trunk/anuga_core/source/anuga/operators/erosion_operators.py	(revision 9000)
+++ /trunk/anuga_core/source/anuga/operators/erosion_operators.py	(revision 9001)
@@ -16,5 +16,5 @@
 from anuga import Quantity
 from anuga.operators.base_operator import Operator
-from anuga.operators.region import Region
+from anuga import Region
 
 
Index: /trunk/anuga_core/source/anuga/operators/rate_operators.py
===================================================================
--- /trunk/anuga_core/source/anuga/operators/rate_operators.py	(revision 9000)
+++ /trunk/anuga_core/source/anuga/operators/rate_operators.py	(revision 9001)
@@ -19,5 +19,5 @@
 from anuga import Quantity
 from anuga.operators.base_operator import Operator
-from anuga.operators.region import Region
+from anuga import Region
 
 class Rate_operator(Operator,Region):
Index: unk/anuga_core/source/anuga/operators/region.py
===================================================================
--- /trunk/anuga_core/source/anuga/operators/region.py	(revision 9000)
+++ 	(revision )
@@ -1,139 +1,0 @@
-"""
-Define region
-"""
-
-__author__="steve"
-__date__ ="$09/03/2012 4:46:39 PM$"
-
-
-from anuga import Domain
-from anuga import Quantity
-import numpy as num
-
-
-from anuga.geometry.polygon import inside_polygon
-
-from anuga.utilities.function_utils import determine_function_type
-
-#from anuga import indent
-
-
-class Region(object):
-    """
-    Helper class to setup region (defined by indices, polygon or center/radius)
-    """
-
-    def __init__(self,
-                 domain,
-                 indices=None,
-                 polygon=None,
-                 center=None,
-                 radius=None,
-                 verbose = False):
-
-
-        #------------------------------------------
-        # Local variables
-        #------------------------------------------
-        self.indices = indices
-        self.center = center
-        self.radius = radius
-        self.polygon = polygon
-
-        self.verbose =  verbose
-    
-        #------------------------------------------
-        #  Useful aliases
-        #------------------------------------------
-        self.domain = domain
-        self.coord_c = self.domain.centroid_coordinates
-        self.areas = self.domain.areas
-
-
-        #-------------------------------------------
-        # Work out indices associated with region:
-        #-------------------------------------------
-        if self.indices is not None:
-            # This overrides polygon, center and radius
-            self.indices = num.asarray(self.indices)
-
-            if self.indices.size == 0:
-                self.indices = []
-
-        elif (self.center is not None) and (self.radius is not None):
-
-            assert self.indices is None
-            assert self.polygon is None
-
-            self.setup_indices_circle()
-
-        elif (self.polygon is not None):
-
-            assert self.indices is None
-
-            self.setup_indices_polygon()
-        else:
-            assert self.indices is None or self.indices is []
-
-
-
-        if self.indices == []:
-            self.full_indices = []
-        elif self.indices is None:
-            self.full_indices = num.where(self.domain.tri_full_flag ==1)[0]
-        else:
-            self.full_indices = self.indices[self.domain.tri_full_flag[self.indices]==1]
-
-
-    def setup_indices_circle(self):
-
-        # Determine indices in circular region
-        N = self.domain.get_number_of_triangles()
-        points = self.domain.get_centroid_coordinates(absolute=True)
-
-        indices = []
-
-        c = self.center
-        r = self.radius
-
-
-        intersect = False
-        for k in range(N):
-            x, y = points[k,:]    # Centroid
-
-            if ((x-c[0])**2+(y-c[1])**2) < r**2:
-                intersect = True
-                indices.append(k)
-
-        if indices is []:
-            self.indices = indices
-        else:
-            self.indices = num.asarray(indices)
-
-        msg = 'No centroids intersect circle center'+str(c)+' radius '+str(r)
-        assert intersect, msg
-
-
-    def setup_indices_polygon(self):
-
-        # Determine indices for polygonal region
-        points = self.domain.get_centroid_coordinates(absolute=True)
-
-        indices = num.asarray(inside_polygon(points, self.polygon))
-
-        if indices is []:
-            self.indices = indices
-        else:
-            self.indices = num.asarray(indices)
-
-
-    def get_indices(self, full_only=True):
-
-        if full_only:
-            return self.full_indices
-        else:
-            return self.indices
-
-        
-
-
Index: /trunk/anuga_core/source/anuga/operators/set_friction_operators.py
===================================================================
--- /trunk/anuga_core/source/anuga/operators/set_friction_operators.py	(revision 9000)
+++ /trunk/anuga_core/source/anuga/operators/set_friction_operators.py	(revision 9001)
@@ -14,5 +14,5 @@
 
 from anuga.operators.base_operator import Operator
-from anuga.operators.region import Region
+from anuga import Region
 from anuga.config import indent
 
Index: /trunk/anuga_core/source/anuga/operators/set_quantity.py
===================================================================
--- /trunk/anuga_core/source/anuga/operators/set_quantity.py	(revision 9000)
+++ /trunk/anuga_core/source/anuga/operators/set_quantity.py	(revision 9001)
@@ -16,5 +16,5 @@
 from anuga.geometry.polygon import inside_polygon
 from anuga.utilities.function_utils import determine_function_type
-from anuga.operators.region import Region
+from anuga import Region
 from anuga.config import indent
 
Index: /trunk/anuga_core/source/anuga/operators/test_set_stage_operator.py
===================================================================
--- /trunk/anuga_core/source/anuga/operators/test_set_stage_operator.py	(revision 9000)
+++ /trunk/anuga_core/source/anuga/operators/test_set_stage_operator.py	(revision 9001)
@@ -16,4 +16,5 @@
 
 import numpy as num
+from pprint import pprint
 import warnings
 import time
@@ -227,4 +228,5 @@
         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)
@@ -256,7 +258,18 @@
         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,
@@ -270,5 +283,5 @@
 
 #        print domain.quantities['elevation'].centroid_values
-#        print domain.quantities['stage'].centroid_values
+#        pprint(domain.quantities['stage'].centroid_values)
 #        print domain.quantities['xmomentum'].centroid_values
 #        print domain.quantities['ymomentum'].centroid_values
@@ -281,4 +294,12 @@
         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,
@@ -291,5 +312,5 @@
 
 
-#        print domain.quantities['stage'].centroid_values
+#        pprint(domain.quantities['stage'].centroid_values)
 #        print domain.quantities['xmomentum'].centroid_values
 #        print domain.quantities['ymomentum'].centroid_values
Index: /trunk/anuga_core/source/anuga/shallow_water/test_shallow_water_domain.py
===================================================================
--- /trunk/anuga_core/source/anuga/shallow_water/test_shallow_water_domain.py	(revision 9000)
+++ /trunk/anuga_core/source/anuga/shallow_water/test_shallow_water_domain.py	(revision 9001)
@@ -8269,5 +8269,5 @@
 
 
-    def test_region_tags(self):
+    def test_tag_region_tags(self):
         """
         get values based on triangle lists.
@@ -8289,5 +8289,5 @@
         domain.set_quantity('friction', manning)
 
-        domain.set_region([set_bottom_friction, set_top_friction])
+        domain.set_tag_region([set_bottom_friction, set_top_friction])
         assert num.allclose(domain.quantities['friction'].get_values(),\
                             [[ 0.09,  0.09,  0.09],
@@ -8298,5 +8298,5 @@
                              [ 1.0,  1.0,  1.0]])
 
-        domain.set_region([set_all_friction])
+        domain.set_tag_region([set_all_friction])
         assert num.allclose(domain.quantities['friction'].get_values(),
                             [[ 10.09, 10.09, 10.09],
@@ -8328,6 +8328,6 @@
         domain.set_quantity('friction', manning)
 
-        domain.set_region('top', 'friction', 1.0)
-        domain.set_region('bottom', 'friction', 0.09)
+        domain.set_tag_region('top', 'friction', 1.0)
+        domain.set_tag_region('bottom', 'friction', 0.09)
         
         msg = ("domain.quantities['friction'].get_values()=\n%s\n"
@@ -8348,5 +8348,5 @@
                              [ 1.0,  1.0,  1.0]]), msg
         
-        domain.set_region([set_bottom_friction, set_top_friction])
+        domain.set_tag_region([set_bottom_friction, set_top_friction])
         assert num.allclose(domain.quantities['friction'].get_values(),
                             [[ 0.09,  0.09,  0.09],
@@ -8357,5 +8357,5 @@
                              [ 1.0,  1.0,  1.0]])
 
-        domain.set_region([set_all_friction])
+        domain.set_tag_region([set_all_friction])
         assert num.allclose(domain.quantities['friction'].get_values(),
                             [[ 10.09, 10.09, 10.09],
Index: /trunk/anuga_core/source/anuga/structures/inlet.py
===================================================================
--- /trunk/anuga_core/source/anuga/structures/inlet.py	(revision 9000)
+++ /trunk/anuga_core/source/anuga/structures/inlet.py	(revision 9001)
@@ -2,5 +2,8 @@
 from anuga.geometry.polygon import inside_polygon, is_inside_polygon, line_intersect
 from anuga.config import velocity_protection, g
+from anuga import Region
+
 import math
+
 
 import numpy as num
@@ -16,10 +19,26 @@
         self.poly = num.asarray(poly, dtype=num.float64)
         self.verbose = verbose
-
-        self.line = True
-        if len(self.poly) > 2:
-            self.line = False
-
-        self.compute_triangle_indices()
+        
+        
+        # poly can be either a line, polygon or a regions
+        if isinstance(poly,Region):
+            #print "is region"
+            self.region = poly
+        else:
+            self.region = Region(domain,poly=poly,expand_polygon=True)
+            #print 'is line or polygon'
+
+        
+        #self.line = True
+        #if len(self.poly) > 2:
+        #    self.line = False
+
+        self.triangle_indices = self.region.indices
+
+        #print self.triangle_indices
+        #print poly
+        #print self.triangle_indices
+        
+        #self.compute_triangle_indices()
         self.compute_area()
         #self.compute_inlet_length()
@@ -27,34 +46,34 @@
 
 
-    def compute_triangle_indices(self):
-
-        # Get boundary (in absolute coordinates)
-        bounding_polygon = self.domain_bounding_polygon
-        domain_centroids = self.domain.get_centroid_coordinates(absolute=True)
-        vertex_coordinates = self.domain.get_vertex_coordinates(absolute=True)
-
-        if self.line: # poly is a line
-            # Check that line lies within the mesh.
-            for point in self.poly:
-                msg = 'Point %s ' %  str(point)
-                msg += ' did not fall within the domain boundary.'
-                assert is_inside_polygon(point, bounding_polygon), msg
+    ## def compute_triangle_indices(self):
+
+    ##     # Get boundary (in absolute coordinates)
+    ##     bounding_polygon = self.domain_bounding_polygon
+    ##     domain_centroids = self.domain.get_centroid_coordinates(absolute=True)
+    ##     vertex_coordinates = self.domain.get_vertex_coordinates(absolute=True)
+
+    ##     if self.line: # poly is a line
+    ##         # Check that line lies within the mesh.
+    ##         for point in self.poly:
+    ##             msg = 'Point %s ' %  str(point)
+    ##             msg += ' did not fall within the domain boundary.'
+    ##             assert is_inside_polygon(point, bounding_polygon), msg
                 
-            self.triangle_indices = line_intersect(vertex_coordinates, self.poly)
-
-        else: # poly is a polygon
-
-            tris_0 = line_intersect(vertex_coordinates, [self.poly[0],self.poly[1]])
-            tris_1 = inside_polygon(domain_centroids, self.poly)
-            #print 40*"="
-            #print tris_0
-            #print tris_1
-            self.triangle_indices = num.union1d(tris_0, tris_1)
-            #print self.triangle_indices
-
-        if len(self.triangle_indices) == 0:
-            msg = 'Inlet poly=%s ' % (self.poly)
-            msg += 'No triangle centroids intersecting poly '
-            raise Exception, msg
+    ##         self.triangle_indices = line_intersect(vertex_coordinates, self.poly)
+
+    ##     else: # poly is a polygon
+
+    ##         tris_0 = line_intersect(vertex_coordinates, [self.poly[0],self.poly[1]])
+    ##         tris_1 = inside_polygon(domain_centroids, self.poly)
+    ##         #print 40*"="
+    ##         #print tris_0
+    ##         #print tris_1
+    ##         self.triangle_indices = num.union1d(tris_0, tris_1)
+    ##         #print self.triangle_indices
+
+    ##     if len(self.triangle_indices) == 0:
+    ##         msg = 'Inlet poly=%s ' % (self.poly)
+    ##         msg += 'No triangle centroids intersecting poly '
+    ##         raise Exception, msg
 
 
Index: /trunk/anuga_core/source/anuga/structures/inlet_enquiry.py
===================================================================
--- /trunk/anuga_core/source/anuga/structures/inlet_enquiry.py	(revision 9000)
+++ /trunk/anuga_core/source/anuga/structures/inlet_enquiry.py	(revision 9001)
@@ -13,5 +13,5 @@
     def __init__(self,
                  domain,
-                 poly,
+                 region,
                  enquiry_pt,
                  invert_elevation = None,
@@ -19,10 +19,14 @@
                  verbose=False):
         """
-        poly can be a line or a polygon
+        region can be a line or a polygon or a region object
         """
 
+        #print region
+        #print enquiry_pt
+        
+        inlet.Inlet.__init__(self, domain, region, verbose)
 
-        inlet.Inlet.__init__(self, domain, poly, verbose)
 
+        
         self.enquiry_pt = enquiry_pt
         self.invert_elevation = invert_elevation
Index: /trunk/anuga_core/source/anuga/structures/inlet_operator.py
===================================================================
--- /trunk/anuga_core/source/anuga/structures/inlet_operator.py	(revision 9000)
+++ /trunk/anuga_core/source/anuga/structures/inlet_operator.py	(revision 9001)
@@ -154,6 +154,6 @@
         message += '\n'
 
-        message += 'polyline\n'
-        message += '%s' % inlet.line
+        message += 'region\n'
+        message += '%s' % inlet
         message += '\n'
 
Index: /trunk/anuga_core/source/anuga/structures/structure_operator.py
===================================================================
--- /trunk/anuga_core/source/anuga/structures/structure_operator.py	(revision 9000)
+++ /trunk/anuga_core/source/anuga/structures/structure_operator.py	(revision 9001)
@@ -51,5 +51,6 @@
 
         anuga.Operator.__init__(self,domain)
-        
+
+        self.master_proc = 0
         self.end_points = ensure_numeric(end_points)
         self.exchange_lines = ensure_numeric(exchange_lines)
@@ -438,6 +439,6 @@
             message += '\n'
 
-            message += 'line\n'
-            message += '%s' % inlet.line
+            message += 'region\n'
+            message += '%s' % inlet.region
             message += '\n'
 
Index: /trunk/anuga_core/source/anuga_parallel/parallel_inlet.py
===================================================================
--- /trunk/anuga_core/source/anuga_parallel/parallel_inlet.py	(revision 9000)
+++ /trunk/anuga_core/source/anuga_parallel/parallel_inlet.py	(revision 9001)
@@ -64,6 +64,8 @@
         else: # poly is a polygon
 
-            self.triangle_indices = inside_polygon(domain_centroids, self.poly)
-
+            tris_0 = line_intersect(vertex_coordinates, [self.poly[0],self.poly[1]])
+            tris_1 = inside_polygon(domain_centroids, self.poly)
+            self.triangle_indices = num.union1d(tris_0, tris_1)
+            #print self.triangle_indices
 
         for i in self.triangle_indices:
Index: /trunk/anuga_core/source/anuga_parallel/parallel_operator_factory.py
===================================================================
--- /trunk/anuga_core/source/anuga_parallel/parallel_operator_factory.py	(revision 9000)
+++ /trunk/anuga_core/source/anuga_parallel/parallel_operator_factory.py	(revision 9001)
@@ -84,5 +84,5 @@
         if verbose and myid == inlet_master_proc:
             print "Parallel Inlet Operator ================="
-            print "Line = " + str(line)
+            print "Poly = " + str(poly)
             print "Master Processor is P%d" %(inlet_master_proc)
             print "Processors are P%s" %(inlet_procs)
@@ -172,4 +172,9 @@
     if apron is None:
         apron = width
+
+
+
+
+
 
     # Calculate location of inlet enquiry points and exchange lines
@@ -488,5 +493,5 @@
         
 
-def allocate_inlet_procs(domain, line, enquiry_point = None, master_proc = 0, procs = None, verbose = False):
+def allocate_inlet_procs(domain, poly, enquiry_point = None, master_proc = 0, procs = None, verbose = False):
 
 
@@ -510,8 +515,18 @@
     # Calculate the number of points of the line inside full polygon
 
-    tri_id = line_intersect(vertex_coordinates, line)
+    #tri_id = line_intersect(vertex_coordinates, poly)
+
+    if len(poly) == 2: # poly is a line
+        if verbose : print "======================"
+        tri_id = line_intersect(vertex_coordinates, poly)
+    else: # poly is a polygon
+        if verbose : print "+++++++++++++++++++++++"
+        tris_0 = line_intersect(vertex_coordinates, [poly[0],poly[1]])
+        tris_1 = inside_polygon(domain_centroids, poly)
+        tri_id = num.union1d(tris_0, tris_1)
+        
 
     if verbose:
-        print "P%d has %d triangles on line %s" %(myid, len(tri_id), line)
+        print "P%d has %d triangles in poly %s" %(myid, len(tri_id), poly)
 
     size = len(tri_id)
Index: /trunk/anuga_core/source/anuga_parallel/parallel_structure_operator.py
===================================================================
--- /trunk/anuga_core/source/anuga_parallel/parallel_structure_operator.py	(revision 9000)
+++ /trunk/anuga_core/source/anuga_parallel/parallel_structure_operator.py	(revision 9001)
@@ -136,6 +136,8 @@
 
         # Slots for recording current statistics
+        self.accumulated_flow = 0.0
         self.discharge = 0.0
         self.velocity = 0.0
+        self.outlet_depth = 0.0
         self.delta_total_energy = 0.0
         self.driving_energy = 0.0
@@ -143,5 +145,4 @@
         if exchange_lines is not None:
             self.__process_skew_culvert()
-
         elif end_points is not None:
             self.__process_non_skew_culvert()
@@ -156,4 +157,9 @@
         if self.myid in self.inlet_procs[0]:
             line0 = self.exchange_lines[0]
+            if self.apron is None:
+                poly0 = line0
+            else:
+                offset = -self.apron*self.outward_vector_0 
+                poly0 = num.array([ line0[0], line0[1], line0[1]+offset, line0[0]+offset])
 
             if self.invert_elevations is None:
@@ -180,4 +186,9 @@
         if self.myid in self.inlet_procs[1]:
             line1 = self.exchange_lines[1]
+            if self.apron is None:
+                poly1 = line1
+            else:
+                offset = -self.apron*self.outward_vector_1
+                poly1 = num.array([ line1[0], line1[1], line1[1]+offset, line1[0]+offset])
 
             if self.invert_elevations is None:
@@ -358,4 +369,6 @@
         
         self.culvert_vector /= self.culvert_length
+        self.outward_vector_0 =   self.culvert_vector
+        self.outward_vector_1 = - self.culvert_vector        
         
         culvert_normal = num.array([-self.culvert_vector[1], self.culvert_vector[0]])  # Normal vector
@@ -393,16 +406,46 @@
         centre_point0 = 0.5*(self.exchange_lines[0][0] + self.exchange_lines[0][1])
         centre_point1 = 0.5*(self.exchange_lines[1][0] + self.exchange_lines[1][1])
-        
-        if self.end_points is None:
+
+        n_exchange_0 = len(self.exchange_lines[0])
+        n_exchange_1 = len(self.exchange_lines[1])
+
+        assert n_exchange_0 == n_exchange_1, 'There should be the same number of points in both exchange_lines'
+
+        if n_exchange_0 == 2:
+            
+            if self.end_points is None:
+                self.culvert_vector = centre_point1 - centre_point0
+            else:
+                self.culvert_vector = self.end_points[1] - self.end_points[0]
+
+            self.outward_vector_0 =   self.culvert_vector
+            self.outward_vector_1 = - self.culvert_vector
+
+        elif n_exchange_0 == 4:
+
+            self.outward_vector_0 = self.exchange_lines[0][3] - self.exchange_lines[0][2]
+            self.outward_vector_1 = self.exchange_lines[1][3] - self.exchange_lines[1][2]
+
             self.culvert_vector = centre_point1 - centre_point0
-        else:
-            self.culvert_vector = self.end_points[1] - self.end_points[0]
-        
+
+        else:
+            raise Exception, 'n_exchange_0 != 2 or 4'
+
         self.culvert_length = math.sqrt(num.sum(self.culvert_vector**2))
         assert self.culvert_length > 0.0, 'The length of culvert is less than 0'
+        self.culvert_vector /= self.culvert_length
+
+        outward_vector_0_length = math.sqrt(num.sum(self.outward_vector_0**2))
+        assert outward_vector_0_length > 0.0, 'The length of outlet_vector_0 is less than 0'
+        self.outward_vector_0 /= outward_vector_0_length
+
+        outward_vector_1_length = math.sqrt(num.sum(self.outward_vector_1**2))
+        assert outward_vector_1_length > 0.0, 'The length of outlet_vector_1 is less than 0'
+        self.outward_vector_1 /= outward_vector_1_length
+
         
         if self.enquiry_points is None:
         
-            self.culvert_vector /= self.culvert_length
+
             gap = (self.apron + self.enquiry_gap)*self.culvert_vector
         
@@ -436,4 +479,6 @@
             message += '%s' % self.description
             message += '\n'
+
+        #print "Structure Myids ",self.myid, self.label
         
         for i, inlet in enumerate(self.inlets):
@@ -443,5 +488,9 @@
                 message += '-------------------------------------\n'
 
-            if inlet is not None: stats = inlet.statistics()
+            #print "*****",inlet, i,self.myid
+            if inlet is not None:
+                
+                
+                stats = inlet.statistics()
 
             if self.myid == self.master_proc:
Index: /trunk/anuga_core/source/anuga_parallel/test_parallel_boyd_box_operator.py
===================================================================
--- /trunk/anuga_core/source/anuga_parallel/test_parallel_boyd_box_operator.py	(revision 9000)
+++ /trunk/anuga_core/source/anuga_parallel/test_parallel_boyd_box_operator.py	(revision 9001)
@@ -52,5 +52,5 @@
 width = 16.
 
-dx = dy = 2           # Resolution: Length of subdivisions on both axes
+dx = dy = 4           # Resolution: Length of subdivisions on both axes
 
 #----------------------------------------------------------------------
@@ -167,6 +167,6 @@
     boyd_box0 = None
     
-    inlet0 = Inlet_operator(domain, line0, Q0, verbose = False)
-    inlet1 = Inlet_operator(domain, line1, Q1, verbose = False)
+    inlet0 = Inlet_operator(domain, line0, Q0, verbose = False, label = 'Inlet_0')
+    inlet1 = Inlet_operator(domain, line1, Q1, verbose = False, label = 'Inlet_1')
     
     # Enquiry point [ 19.    2.5] is contained in two domains in 4 proc case
@@ -176,13 +176,17 @@
                                   losses=1.5,
                                   width=5.0,
-                                  apron=5.0,
+                                  #apron=5.,
                                   use_momentum_jet=True,
                                   use_velocity_head=False,
                                   manning=0.013,
+                                  label='Boyd_Box_0',
                                   verbose=False)
         
-    if inlet0 is not None and verbose: inlet0.print_statistics()
-    if inlet1 is not None and verbose: inlet1.print_statistics()
-    if boyd_box0 is not None and verbose: boyd_box0.print_statistics()
+    #if inlet0 is not None and verbose: inlet0.print_statistics()
+    #if inlet1 is not None and verbose: inlet1.print_statistics()
+    
+    if boyd_box0 is not None and verbose:
+        print "++++", myid
+        boyd_box0.print_statistics()
 
 #    if parallel:
@@ -231,5 +235,8 @@
 
 
-        if boyd_box0 is not None and verbose : boyd_box0.print_timestepping_statistics()
+        if boyd_box0 is not None and verbose :
+            if myid == boyd_box0.master_proc:
+                print 'master_proc ',myid
+                boyd_box0.print_timestepping_statistics()
  
         #for i in range(samples):
Index: /trunk/anuga_core/source/anuga_parallel/test_parallel_frac_op.py
===================================================================
--- /trunk/anuga_core/source/anuga_parallel/test_parallel_frac_op.py	(revision 9000)
+++ /trunk/anuga_core/source/anuga_parallel/test_parallel_frac_op.py	(revision 9001)
@@ -176,5 +176,5 @@
                                   losses=1.5,
                                   width=5.0,
-                                  apron=5.0,
+                                  #apron=5.0,
                                   use_momentum_jet=True,
                                   use_velocity_head=False,
Index: /trunk/anuga_core/source/anuga_parallel/test_parallel_inlet_operator.py
===================================================================
--- /trunk/anuga_core/source/anuga_parallel/test_parallel_inlet_operator.py	(revision 9000)
+++ /trunk/anuga_core/source/anuga_parallel/test_parallel_inlet_operator.py	(revision 9001)
@@ -35,5 +35,5 @@
 from anuga.geometry.polygon import inside_polygon, is_inside_polygon, line_intersect
 
-from parallel_operator_factory import Inlet_operator, Boyd_box_operator
+from parallel_operator_factory import Inlet_operator
 
 import random
@@ -172,17 +172,17 @@
     # Enquiry point [ 19.    2.5] is contained in two domains in 4 proc case
     
-    boyd_box0 = Boyd_box_operator(domain,
-                                  end_points=[[9.0, 2.5],[19.0, 2.5]],
-                                  losses=1.5,
-                                  width=5.0,
-                                  apron=5.0,
-                                  use_momentum_jet=True,
-                                  use_velocity_head=False,
-                                  manning=0.013,
-                                  verbose=False)
+    ## boyd_box0 = Boyd_box_operator(domain,
+    ##                               end_points=[[9.0, 2.5],[19.0, 2.5]],
+    ##                               losses=1.5,
+    ##                               width=5.0,
+    ##                               apron=5.0,
+    ##                               use_momentum_jet=True,
+    ##                               use_velocity_head=False,
+    ##                               manning=0.013,
+    ##                               verbose=False)
         
     if inlet0 is not None and verbose: inlet0.print_statistics()
     if inlet1 is not None and verbose: inlet1.print_statistics()
-    if boyd_box0 is not None and verbose: boyd_box0.print_statistics()
+    #if boyd_box0 is not None and verbose: boyd_box0.print_statistics()
 
 #    if parallel:
@@ -231,5 +231,5 @@
 
 
-        if boyd_box0 is not None and verbose : boyd_box0.print_timestepping_statistics()
+        #if boyd_box0 is not None and verbose : boyd_box0.print_timestepping_statistics()
  
         #for i in range(samples):
Index: /trunk/anuga_core/source/anuga_validation_tests/analytical_exact/avalanche_dry/validate_avalanche_dry.py
===================================================================
--- /trunk/anuga_core/source/anuga_validation_tests/analytical_exact/avalanche_dry/validate_avalanche_dry.py	(revision 9000)
+++ /trunk/anuga_core/source/anuga_validation_tests/analytical_exact/avalanche_dry/validate_avalanche_dry.py	(revision 9001)
@@ -113,6 +113,6 @@
             print indent+'Errors in xvelocity: ', eu10, eu30
 
-        assert eu10 < 0.02,  'L^1 error %g greater than 2 percent'% eu10
-        assert eu30 < 0.01,  'L^1 error %g greater than 2 percent'% eu30
+        assert eu10 < 0.1,  'L^1 error %g greater than 10 percent'% eu10
+        assert eu30 < 0.1,  'L^1 error %g greater than 10 percent'% eu30
 
  
Index: /trunk/anuga_core/source/anuga_validation_tests/saved_parameters.tex
===================================================================
--- /trunk/anuga_core/source/anuga_validation_tests/saved_parameters.tex	(revision 9000)
+++ /trunk/anuga_core/source/anuga_validation_tests/saved_parameters.tex	(revision 9001)
@@ -2,4 +2,4 @@
 \newcommand{\alg}{\UScore{1_5}}
 \newcommand{\majorR}{\UScore{1.3.0-beta}}
-\newcommand{\minorR}{\UScore{8922}}
-\newcommand{\timeR}{{Mon Jun 24 23:29:56 2013}}
+\newcommand{\minorR}{\UScore{8993}}
+\newcommand{\timeR}{{Sat Sep 28 19:39:45 2013}}
Index: /trunk/anuga_core/user_manual/anuga_installation_guide.tex
===================================================================
--- /trunk/anuga_core/user_manual/anuga_installation_guide.tex	(revision 9000)
+++ /trunk/anuga_core/user_manual/anuga_installation_guide.tex	(revision 9001)
@@ -54,6 +54,6 @@
 \label{sec:requirements}
 
-To run ANUGA you will need a Windows PC (XP, Vista or 7) or a Linux PC with at 
-least 512MB RAM.  As ANUGA is a memory-intensive numerical system, more memory is better than less.
+To run ANUGA you will need a Windows PC or a Linux PC with at 
+least 1GB RAM.  As ANUGA is a memory-intensive numerical system, more memory is better than less.
 
 The viewer (Windows only) requires a graphics adapter that
@@ -62,32 +62,130 @@
 Intel(R) 82915G Express chipset family.
 
-The instructions below are written for the numpy version of ANUGA.  ANUGA changed from
-relying on the Numeric package to the numpy package early in July, 2009.  If you have a Numeric ANUGA,
-you should refer to the installation instructions for that version.  The last Numeric version of 
-ANUGA had a build number of 7163.
-
-Where the text below refers to a specific package file such as \code{python-2.5.msi} you will find that
-file in a download area linked through the \emph{numpy_support_software} link on the page
-\url{https://datamining.anu.edu.au/anuga/wiki/NumpyInstall}.
+We recommend that you check out the page \url{http://anuga.anu.edu.au} for the latest information on installing Anuga. 
+
+%Where the text below refers to a specific package file such as \code{python-2.5.msi} you will find that
+%file in a download area linked through the \emph{numpy_support_software} link on the page
+%\url{https://datamining.anu.edu.au/anuga/wiki/NumpyInstall}.
 
 
 \section{Installation}
 
-Below are the install procedures for Windows XP, Windows Vista, Windows 7 (all 32 bit) and Linux (32 and 64 bit).
-
-\subsection{Quick install - Windows XP (32 bit)}
-\label{sec:winxp}
-
-If you already have previous versions of Python, ANUGA support software or the ANUGA source code installed 
-on the target machine, start off by uninstalling them. Next, download the latest version of the ANUGA 
-Windows installer from \url{http://sourceforge.net/projects/anuga/files/}. The Windows installer will 
-install Python, MingW (select the "Minimal" install), NumPy, NetCDF, Scientific Python, Matplotlib, the 
-ANUGA source code and the viewer (animate). Note that you will need an internet connection to install MingW.
-
-After all the necessary packages have been installed, the installer will proceed to compile the ANUGA C code, 
-run the test suite (optional) and then run a series of validation examples (optional). This may take some time.
-Try the demonstrations provided in the ANUGA directory \code{anuga\_demos} (discussed in the ANUGA user manual at 
-\url{https://datamining.anu.edu.au/anuga/attachment/wiki/WikiStart/anuga_user_manual-1.2.0.pdf}) 
-and view the resulting \code{.sww} files with the ANUGA viewer.
+Below are the install procedures for Windows 7 (32 bit) and Linux (32 and 64 bit).
+
+\subsection{Install - Windows (32 bit)}
+\label{sec:win}
+
+
+
+We use PYTHON as our programming environment together with a number of standard PYTHON packages such as numpy, scipy, matplotlib, netcdf4. One way to install all the required packages is to use a distribution like python_xy.
+
+\subsubsection{PYTHON xy}
+
+So first install  python xy. This will be a large download, maybe 500 MB or more, but will provide a complete installation (well see NetCDF4 note below) of python for our needs . You should first remove any other version of python and mingw that may be on your system. The python xy package is currently only 32 bits, but this will still work on 64 bit Windows.
+
+Be sure to choose the win32 python 2.7 version. This is the version for which we are developing.
+Netcdf4 Note
+
+Check that netcdf is available. From a command line, try
+\begin{verbatim}
+python -c "import netCDF4"
+\end{verbatim}
+If no error occurs then netCDF4 is available and you can disregard the rest of this note.
+
+But unfortunately version 2.7.3.1 (April 2013) python xy seems to be missing netCDF4. Please let us know if later versions are ok.
+If it is missing then you need to install another package to cover this loss. For this we can use the precompiled scientific python binaries from  \url{http://www.lfd.uci.edu/~gohlke/pythonlibs/#scientificpython}. I suggest you choose ScientificPython-2.9.2.win32-py2.7.âexe to install. To test this install try:
+\begin{verbatim}
+python -c "import Scientific.IO.NetCDF"
+\end{verbatim}
+
+\subsubsection{64 bit}
+
+At the moment python xy is only 32 bit, but there seems to be a promise that a 64 bit distribution is not too far away. There is a 64 bit python distribution package from Enthought, but is free only to academic users. So at present we recommend win32 python xy.
+Manual install
+
+It is possible to install the required environment manually. You would need to install Mingw to provide a compiler, the standard distribution of python27 and then precompiled python libraries for numpy, scipy, matplotlib, netcdf4 from a site like  \url{http://www.lfd.uci.edu/~gohlke/pythonlibs/}. It would be interesting to hear feedback on this option, as there is an opportunity to use versions using the Intel Math Kernel Library, which should provide a useful increase in speed.
+Installing anuga
+
+\subsection{Obtaining ANUGA source}
+
+You can either use the source code avialble from sourceforge or  download the latest version of the package using subversion. 
+
+You can obtain version 1.3 of the package from sourceforge by downloading the file \url{http://sourceforge/p/anuga}
+
+
+\subsection{Source from development repository}
+An alternative is checking out the most recent version of the package using subversion. 
+
+You need a subversion client. I suggest installing  tortoise_svn downloads and then checking out the following svn repository. When you installed tortoise svn it creates a few extra menu items to your right click menu in the file manager. Just choose "tortoise" checkout to download the code.
+\begin{verbatim}
+https://anuga.anu.edu.au/svn/anuga/trunk/anuga_core
+\end{verbatim}
+This should produce an anuga_core directory
+
+
+
+\subsection{Setup PYTHONPATH}
+
+We need to tell python where the anuga source code is located. This is done via the PYTHONPATH environment variable.
+
+For instance, if your anuga_core directory was located at
+
+\begin{verbatim}
+C:\Users\Steve\anuga_core
+\end{verbatim}
+
+then you should add
+
+\begin{verbatim}
+C:\Users\Steve\anuga_core\source
+\end{verbatim}
+
+to your PYTHONPATH
+
+Environment variables are accessed via control panel -> advanced system settings -> Environment Variables and then add a new Environment variable PYTHONPATH with value \verb|C:\Users\Steve\anuga_core\source| (or what ever is appropriate for your installation)
+
+\subsection{Compiling ANUGA}
+
+Now go to the directory anuga_core and compile the anuga files. Fire up a cmd terminal, change to the anuga_core directory and run
+\begin{verbatim}
+python compile_all.py
+\end{verbatim}
+Check that all the files have been compiled correctly. There should be an "OK" at the end of each separate compile command.
+
+\subsection{Run Unit tests}
+
+From the anuga_core directory run the unit tests via:
+\begin{verbatim}
+python test_all.py
+\end{verbatim}
+
+\subsection{Conclusion}
+
+Hopefully all the unit tests pass. As this is bleeding edge there are sometimes a small number of failures as this is a work in progress. Have a look at the demos in the directory anuga_core/documentation/user_manual/demos (along with the user manual) to see how to use anuga.
+Updating
+
+\subsection{Updating}
+If you downloaded  the source using subversoin, you can update your version of ANUGA. 
+ This is fairly easy. Just choose the directory to "update" and then right click and choose "tortoise update" to update the code.
+
+Then again from the anuga_core directory recompile the code and check the unit tests via
+
+python compile_all.py
+python test_all.py
+
+
+
+
+%If you already have previous versions of Python, ANUGA support software or the ANUGA source code installed 
+%on the target machine, start off by uninstalling them. Next, download the latest version of the ANUGA 
+%Windows installer from \url{http://sourceforge.net/projects/anuga/files/}. The Windows installer will 
+%install Python, MingW (select the "Minimal" install), NumPy, NetCDF, Scientific Python, Matplotlib, the 
+%ANUGA source code and the viewer (animate). Note that you will need an internet connection to install MingW.
+%
+%After all the necessary packages have been installed, the installer will proceed to compile the ANUGA C code, 
+%run the test suite (optional) and then run a series of validation examples (optional). This may take some time.
+%Try the demonstrations provided in the ANUGA directory \code{anuga\_demos} (discussed in the ANUGA user manual at 
+%\url{https://datamining.anu.edu.au/anuga/attachment/wiki/WikiStart/anuga_user_manual-1.2.0.pdf}) 
+%and view the resulting \code{.sww} files with the ANUGA viewer.
 
 
