Index: /trunk/anuga_core/documentation/user_manual/demos/cairns/runcairns.py
===================================================================
--- /trunk/anuga_core/documentation/user_manual/demos/cairns/runcairns.py	(revision 8537)
+++ /trunk/anuga_core/documentation/user_manual/demos/cairns/runcairns.py	(revision 8538)
@@ -69,5 +69,7 @@
 tide = 0.0
 domain.set_quantity('stage', tide)
-domain.set_quantity('friction', 0.0) 
+domain.set_quantity('friction', 0.0)
+
+
 domain.set_quantity('elevation', 
                     filename=project.name_stem + '.pts',
Index: /trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/generic_boundary_conditions.py
===================================================================
--- /trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/generic_boundary_conditions.py	(revision 8537)
+++ /trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/generic_boundary_conditions.py	(revision 8538)
@@ -35,4 +35,7 @@
         Evaluate boundary condition at edges of a domain in a list
         defined by segment_edges
+        
+        segment_edges are a sublist of the list of edges definded by the
+        arrays domain.boundary_cells  and domain.boundary_edges
 
         Go through list of boundary objects and update boundary values
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 8537)
+++ /trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/generic_domain.py	(revision 8538)
@@ -53,5 +53,6 @@
                        numproc=1,
                        number_of_full_nodes=None,
-                       number_of_full_triangles=None):
+                       number_of_full_triangles=None,
+                       ghost_layer_width=2):
 
         """Instantiate generic computational Domain.
@@ -204,4 +205,5 @@
         self.processor = processor
         self.numproc = numproc
+        self.ghost_layer_width = ghost_layer_width
 
         # Setup Communication Buffers
@@ -1532,9 +1534,10 @@
         #self.update_special_conditions()
 
-        # Update ghosts
-        self.update_ghosts()
-
         # Update time
         self.set_time(self.get_time() + self.timestep)
+
+        # Update ghosts
+        if self.ghost_layer_width < 4:
+            self.update_ghosts()
 
         # Update vertex and edge values
@@ -1605,9 +1608,9 @@
         #self.update_special_conditions()
 
+        # Update time
+        self.set_time(self.time + self.timestep)
+
         # Update ghosts
         self.update_ghosts()
-
-        # Update time
-        self.set_time(self.time + self.timestep)
 
         # Update vertex and edge values
@@ -1641,13 +1644,12 @@
         self.saxpy_conserved_quantities(0.25, 0.75)
 
-
         # Update special conditions
         #self.update_special_conditions()
 
+        # Set substep time
+        self.set_time(initial_time + self.timestep*0.5)
+
         # Update ghosts
         self.update_ghosts()
-
-        # Set substep time
-        self.set_time(initial_time + self.timestep*0.5)
 
         # Update vertex and edge values
Index: /trunk/anuga_core/source/anuga/config.py
===================================================================
--- /trunk/anuga_core/source/anuga/config.py	(revision 8537)
+++ /trunk/anuga_core/source/anuga/config.py	(revision 8538)
@@ -95,6 +95,10 @@
 
 # Option to setup compute_fluxes_method
-# Currently "original' and 'wb_1' to 'wb_3'
+# Currently "original' and 'wb_1' to 'wb_3' and 'tsunami'
 compute_fluxes_method = 'wb_2'
+
+# Option to setup distribute_to_vertices_and_edges_method
+# Currently "original' and 'tsunami'
+distribute_to_vertices_and_edges_method = 'original'
 
 ################################################################################
Index: /trunk/anuga_core/source/anuga/shallow_water/boundaries.py
===================================================================
--- /trunk/anuga_core/source/anuga/shallow_water/boundaries.py	(revision 8537)
+++ /trunk/anuga_core/source/anuga/shallow_water/boundaries.py	(revision 8538)
@@ -89,4 +89,7 @@
 
     def evaluate_segment(self, domain, segment_edges):
+        """Apply reflective BC on the boundary edges defined by
+        segment_edges
+        """
 
         if segment_edges is None:
@@ -120,5 +123,5 @@
         n2  = Normals[vol_ids,2*edge_ids+1]
 
-        # Transfer these quantities
+        # Transfer these quantities to the boundary array
         Stage.boundary_values[ids]  = Stage.edge_values[vol_ids,edge_ids]
         Elev.boundary_values[ids]   = Elev.edge_values[vol_ids,edge_ids]
@@ -128,8 +131,4 @@
         q1 = Xmom.edge_values[vol_ids,edge_ids]
         q2 = Ymom.edge_values[vol_ids,edge_ids]
-
-        # Rotate
-        #q[1] = n1 * q1 - n2*q2;
-        #q[2] = n2 * q1 + n1*q2;
 
         r1 = -q1*n1 - q2*n2
Index: /trunk/anuga_core/source/anuga/shallow_water/shallow_water_domain.py
===================================================================
--- /trunk/anuga_core/source/anuga/shallow_water/shallow_water_domain.py	(revision 8537)
+++ /trunk/anuga_core/source/anuga/shallow_water/shallow_water_domain.py	(revision 8538)
@@ -109,5 +109,6 @@
                  numproc=1,
                  number_of_full_nodes=None,
-                 number_of_full_triangles=None):
+                 number_of_full_triangles=None,
+                 ghost_layer_width=2):
         """
             Instantiate a shallow water domain.
@@ -163,5 +164,6 @@
                             numproc,
                             number_of_full_nodes=number_of_full_nodes,
-                            number_of_full_triangles=number_of_full_triangles)
+                            number_of_full_triangles=number_of_full_triangles,
+                            ghost_layer_width=ghost_layer_width)
 
         self.set_defaults()
@@ -226,4 +228,5 @@
         from anuga.config import use_centroid_velocities
         from anuga.config import compute_fluxes_method
+        from anuga.config import distribute_to_vertices_and_edges_method
         from anuga.config import sloped_mannings_function
         from anuga.config import flow_algorithm
@@ -255,5 +258,5 @@
 
     def get_algorithm_parameters(self):
-        """Get the standard parameter that arecurently set (as a dictionary)
+        """Get the standard parameter that are currently set (as a dictionary)
         """
 
@@ -271,4 +274,6 @@
         parameters['use_sloped_mannings']     = self.use_sloped_mannings
         parameters['compute_fluxes_method']   = self.get_compute_fluxes_method()
+        parameters['distribute_to_vertices_and_edges_method'] = \
+                         self.get_distribute_to_vertices_and_edges_method()
         parameters['flow_algorithm']          = self.get_flow_algorithm()
         parameters['CFL']                     = self.get_CFL()
@@ -352,6 +357,7 @@
            wb_2
            wb_3
-        """
-        compute_fluxes_methods = ['original', 'wb_1', 'wb_2', 'wb_3']
+           tsunami
+        """
+        compute_fluxes_methods = ['original', 'wb_1', 'wb_2', 'wb_3', 'tsunami']
 
         if flag in compute_fluxes_methods:
@@ -375,4 +381,35 @@
 
 
+
+    def set_distribute_to_vertices_and_edges_method(self, flag='original'):
+        """Set method for computing fluxes.
+
+        Currently
+           original
+           tsunami
+        """
+        distribute_to_vertices_and_edges_methods = ['original',  'tsunami']
+
+        if flag in distribute_to_vertices_and_edges_methods:
+            self.distribute_to_vertices_and_edges_method = flag
+        else:
+            msg = 'Unknown distribute_to_vertices_and_edges_method. \nPossible choices are:\n'+ \
+            ', '.join(distribute_to_vertices_and_edges_methods)+'.'
+            raise Exception(msg)
+
+
+
+
+
+    def get_distribute_to_vertices_and_edges_method(self):
+        """Get method for distribute_to_vertices_and_edges.
+
+        See set_distribute_to_vertices_and_edges_method for possible choices.
+        """
+
+        return self.distribute_to_vertices_and_edges_method
+
+
+
     def set_flow_algorithm(self, flag=1.5):
         """Set combination of slope limiting and time stepping
@@ -383,4 +420,5 @@
            2
            2.5
+           tsunami
         """
 
@@ -390,5 +428,5 @@
             flag = str(float(str(flag))).replace(".","_")
 
-        flow_algorithms = ['1_0', '1_5', '1_75', '2_0', '2_5']
+        flow_algorithms = ['1_0', '1_5', '1_75', '2_0', '2_5', 'tsunami']
 
         if flag in flow_algorithms:
@@ -404,4 +442,6 @@
             self.set_default_order(1)
             self.set_CFL(1.0)
+
+
 
         if self.flow_algorithm == '1_5':
@@ -416,4 +456,7 @@
             self.set_betas(beta_w, beta_w_dry, beta_uh, beta_uh_dry, beta_vh, beta_vh_dry)
             self.set_CFL(1.0)
+            self.set_compute_fluxes_method('wb_2')
+            self.set_extrapolate_velocity()
+
 
 
@@ -429,4 +472,6 @@
             self.set_betas(beta_w, beta_w_dry, beta_uh, beta_uh_dry, beta_vh, beta_vh_dry)
             self.set_CFL(0.75)
+            self.set_compute_fluxes_method('wb_2')
+            self.set_extrapolate_velocity()
 
 
@@ -442,4 +487,24 @@
             self.set_betas(beta_w, beta_w_dry, beta_uh, beta_uh_dry, beta_vh, beta_vh_dry)
             self.set_CFL(1.0)
+            self.set_compute_fluxes_method('wb_2')
+            self.set_extrapolate_velocity()
+
+
+        if self.flow_algorithm == 'tsunami':
+            self.set_timestepping_method(2)
+            self.set_default_order(2)
+            beta_w      = 1.9
+            beta_w_dry  = 0.2
+            beta_uh     = 1.9
+            beta_uh_dry = 0.2
+            beta_vh     = 1.9
+            beta_vh_dry = 0.2
+            self.set_betas(beta_w, beta_w_dry, beta_uh, beta_uh_dry, beta_vh, beta_vh_dry)
+            self.set_CFL(1.0)
+            self.set_compute_fluxes_method('wb_2')
+            self.set_extrapolate_velocity()
+            self.set_distribute_to_vertices_and_edges_method('tsunami')
+
+
 
         if self.flow_algorithm == '2_5':
@@ -454,5 +519,6 @@
             self.set_betas(beta_w, beta_w_dry, beta_uh, beta_uh_dry, beta_vh, beta_vh_dry)
             self.set_CFL(1.0)
-
+            self.set_compute_fluxes_method('wb_2')
+            self.set_extrapolate_velocity()
 
 
@@ -469,4 +535,5 @@
     def set_gravity_method(self):
         """Gravity method is determined by the compute_fluxes_method
+        This is now not used, as gravity is combine in the compute_fluxes method
         """
 
@@ -513,5 +580,4 @@
         elif flag is False:
             self.optimise_dry_cells = int(False)
-
 
 
Index: /trunk/anuga_core/source/anuga_parallel/distribute_mesh.py
===================================================================
--- /trunk/anuga_core/source/anuga_parallel/distribute_mesh.py	(revision 8537)
+++ /trunk/anuga_core/source/anuga_parallel/distribute_mesh.py	(revision 8538)
@@ -266,7 +266,12 @@
 #########################################################
 
-def submesh_full(nodes, triangles, boundary, triangles_per_proc):
+def submesh_full(mesh, triangles_per_proc):
 
     # Initialise
+
+
+    nodes = mesh.nodes
+    triangles = mesh.triangles
+    boundary = mesh.boundary
 
     tlower = 0
@@ -353,13 +358,14 @@
 #########################################################
 
-def ghost_layer(submesh, mesh, p, tupper, tlower):
+def ghost_layer(submesh, mesh, p, tupper, tlower, parameters = None):
 
     ncoord = mesh.number_of_nodes
     ntriangles = mesh.number_of_triangles
 
-
-    layer_width = config.ghost_layer_width
-
-    print layer_width
+    if parameters is None:
+        layer_width  = 2
+    else:
+        layer_width = parameters['ghost_layer_width']
+
 
     trianglemap = num.zeros(ntriangles, 'i')
@@ -443,5 +449,5 @@
     # Return the triangles and vertices sitting on the boundary layer
 
-    return subnodes, subtriangles
+    return subnodes, subtriangles, layer_width
 
 #########################################################
@@ -479,8 +485,14 @@
 def ghost_bnd_layer(ghosttri, tlower, tupper, mesh, p):
 
+
+    boundary = mesh.boundary
+
     ghost_list = []
     subboundary = {}
 
 
+    # FIXME SR: For larger layers need to pass through the correct
+    # boundary tag!
+
     for t in ghosttri:
         ghost_list.append(t[0])
@@ -490,13 +502,24 @@
         n = mesh.neighbours[t[0], 0]
         if not is_in_processor(ghost_list, tlower, tupper, n):
-            subboundary[t[0], 0] = 'ghost'
+            if boundary.has_key( (t[0], 0) ):
+                subboundary[t[0], 0] = boundary[t[0],0]
+            else:
+                subboundary[t[0], 0] = 'ghost'
+
 
         n = mesh.neighbours[t[0], 1]
         if not is_in_processor(ghost_list, tlower, tupper, n):
-            subboundary[t[0], 1] = 'ghost'
+            if boundary.has_key( (t[0], 1) ):
+                subboundary[t[0], 1] = boundary[t[0],1]
+            else:
+                subboundary[t[0], 1] = 'ghost'
+
 
         n = mesh.neighbours[t[0], 2]
         if not is_in_processor(ghost_list, tlower, tupper, n):
-            subboundary[t[0], 2] = 'ghost'
+            if boundary.has_key( (t[0], 2) ):
+                subboundary[t[0], 2] = boundary[t[0],2]
+            else:
+                subboundary[t[0], 2] = 'ghost'
             
     return subboundary
@@ -629,5 +652,5 @@
 #########################################################
 
-def submesh_ghost(submesh, mesh, triangles_per_proc):
+def submesh_ghost(submesh, mesh, triangles_per_proc, parameters = None):
 
     nproc = len(triangles_per_proc)
@@ -637,4 +660,5 @@
     ghost_commun = []
     ghost_bnd = []
+    ghost_layer_width = []
 
     # Loop over the processors
@@ -648,6 +672,7 @@
         # Build the ghost boundary layer
 
-        [subnodes, subtri] = \
-                   ghost_layer(submesh, mesh, p, tupper, tlower)
+        [subnodes, subtri, layer_width] = \
+                   ghost_layer(submesh, mesh, p, tupper, tlower, parameters)
+        ghost_layer_width.append(layer_width)
         ghost_triangles.append(subtri)
         ghost_nodes.append(subnodes)
@@ -671,5 +696,5 @@
 
     # Record the ghost layer and communication pattern
-
+    submesh["ghost_layer_width"] = ghost_layer_width
     submesh["ghost_nodes"] = ghost_nodes
     submesh["ghost_triangles"] = ghost_triangles
@@ -760,11 +785,11 @@
 #########################################################
 
-def build_submesh(nodes, triangles, edges, quantities,
-                  triangles_per_proc):
+def build_submesh(nodes, triangles, boundary, quantities,
+                  triangles_per_proc, parameters = None):
 
     # Temporarily build the mesh to find the neighbouring
     # triangles and true boundary polygon
 
-    mesh = Mesh(nodes, triangles)
+    mesh = Mesh(nodes, triangles, boundary)
     boundary_polygon = mesh.get_boundary_polygon()
     
@@ -772,10 +797,9 @@
     # Subdivide into non-overlapping partitions
 
-    submeshf = submesh_full(nodes, triangles, edges, \
-                            triangles_per_proc)
+    submeshf = submesh_full(mesh, triangles_per_proc)
     
     # Add any extra ghost boundary layer information
 
-    submeshg = submesh_ghost(submeshf, mesh, triangles_per_proc)
+    submeshg = submesh_ghost(submeshf, mesh, triangles_per_proc, parameters)
 
     # Order the quantities information to be the same as the triangle
@@ -957,4 +981,6 @@
     nodes = num.concatenate((submesh["full_nodes"], \
                          submesh["ghost_nodes"]))
+
+    ghost_layer_width = submesh["ghost_layer_width"]
     
     # Combine the full triangles and ghost triangles
@@ -1009,5 +1035,5 @@
 
     return GAnodes, GAtriangles, GAboundary, quantities, ghost_rec, \
-           full_send, tri_map, node_map
+           full_send, tri_map, node_map, ghost_layer_width
 
 
@@ -1051,5 +1077,5 @@
     myid = pypar.rank()
     
-    if verbose: print 'process %d sending submesh to process %d' %(myid, p)
+    if verbose: print 'P%d: Sending submesh to P%d' %(myid, p)
     
     # build and send the tagmap for the boundary conditions
@@ -1078,4 +1104,8 @@
     pypar.send(triangles_per_proc, p)
 
+    # ghost layer width
+
+    pypar.send(submesh["ghost_layer_width"][p], p)
+
     # compress full_commun
 
@@ -1185,4 +1215,8 @@
     triangles_per_proc = pypar.receive(p)
 
+    # ghost layer width
+
+    submesh_cell["ghost_layer_width"] = pypar.receive(p)
+
     # recieve information about the array sizes
 
@@ -1303,5 +1337,5 @@
 
     [GAnodes, GAtriangles, boundary, quantities, \
-     ghost_rec, full_send, tri_map, node_map] = \
+     ghost_rec, full_send, tri_map, node_map, ghost_layer_width] = \
               build_local_mesh(submesh_cell, lower_t, upper_t, \
                                numproc)
@@ -1309,5 +1343,6 @@
     return GAnodes, GAtriangles, boundary, quantities,\
            ghost_rec, full_send,\
-           number_of_full_nodes, number_of_full_triangles, tri_map, node_map
+           number_of_full_nodes, number_of_full_triangles, tri_map, node_map,\
+           ghost_layer_width
           
 
@@ -1332,4 +1367,5 @@
     
     submesh_cell = {}
+    submesh_cell["ghost_layer_width"] = submesh["ghost_layer_width"][0]
     submesh_cell["full_nodes"] = submesh["full_nodes"][0]
     submesh_cell["ghost_nodes"] = submesh["ghost_nodes"][0]
@@ -1348,10 +1384,10 @@
     numprocs = len(triangles_per_proc)
     points, vertices, boundary, quantities, ghost_recv_dict, \
-            full_send_dict, tri_map, node_map = \
+            full_send_dict, tri_map, node_map, ghost_layer_width = \
             build_local_mesh(submesh_cell, 0, triangles_per_proc[0], numprocs)
 
 
     return  points, vertices, boundary, quantities, ghost_recv_dict, \
-           full_send_dict, tri_map, node_map
+           full_send_dict, tri_map, node_map, ghost_layer_width
            
 
Index: unk/anuga_core/source/anuga_parallel/local_config.py
===================================================================
--- /trunk/anuga_core/source/anuga_parallel/local_config.py	(revision 8537)
+++ 	(revision )
@@ -1,14 +1,0 @@
-#! /usr/bin/python
-
-# To change this template, choose Tools | Templates
-# and open the template in the editor.
-
-__author__="stephen"
-__date__ ="$27/08/2012 8:58:23 PM$"
-
-
-ghost_layer_width = 2
-
-
-if __name__ == "__main__":
-    print "Hello World";
Index: /trunk/anuga_core/source/anuga_parallel/parallel_api.py
===================================================================
--- /trunk/anuga_core/source/anuga_parallel/parallel_api.py	(revision 8537)
+++ /trunk/anuga_core/source/anuga_parallel/parallel_api.py	(revision 8538)
@@ -36,5 +36,5 @@
 
 
-def distribute(domain, verbose=False, debug=False):
+def distribute(domain, verbose=False, debug=False, parameters = None):
     """ Distribute the domain to all processes
     """
@@ -112,10 +112,6 @@
                 ghost_recv_dict, full_send_dict,\
                 number_of_full_nodes, number_of_full_triangles,\
-                s2p_map, p2s_map, tri_map, node_map =\
-                distribute_mesh(domain, verbose=verbose, debug=debug)
-
-
-
-
+                s2p_map, p2s_map, tri_map, node_map, ghost_layer_width =\
+                distribute_mesh(domain, verbose=verbose, debug=debug, parameters=parameters)
             
         # Extract l2g maps
@@ -146,5 +142,5 @@
                 ghost_recv_dict, full_send_dict,\
                 number_of_full_nodes, number_of_full_triangles, \
-                tri_map, node_map =\
+                tri_map, node_map, ghost_layer_width =\
                 rec_submesh(0, verbose)
 
@@ -178,5 +174,6 @@
                              p2s_map = p2s_map, ## jj added this
                              tri_l2g = tri_l2g, ## SR added this
-                             node_l2g = node_l2g)
+                             node_l2g = node_l2g,
+                             ghost_layer_width = ghost_layer_width)
 
     #------------------------------------------------------------------------
@@ -213,5 +210,5 @@
 
 
-def distribute_mesh(domain, verbose=False, debug=False):
+def distribute_mesh(domain, verbose=False, debug=False, parameters=None):
 
 
@@ -236,5 +233,5 @@
     if verbose: print 'Build submeshes'    
     submesh = build_submesh(nodes, triangles, boundary,\
-                            quantities, triangles_per_proc)
+                            quantities, triangles_per_proc, parameters)
 
     if verbose:
@@ -257,5 +254,5 @@
     # Build the local mesh for processor 0
     points, vertices, boundary, quantities, \
-            ghost_recv_dict, full_send_dict, tri_map, node_map =\
+            ghost_recv_dict, full_send_dict, tri_map, node_map, ghost_layer_width =\
               extract_hostmesh(submesh, triangles_per_proc)
 
@@ -294,5 +291,5 @@
            ghost_recv_dict, full_send_dict,\
            number_of_full_nodes, number_of_full_triangles, \
-           s2p_map, p2s_map, tri_map, node_map
+           s2p_map, p2s_map, tri_map, node_map, ghost_layer_width
     
 
Index: /trunk/anuga_core/source/anuga_parallel/parallel_shallow_water.py
===================================================================
--- /trunk/anuga_core/source/anuga_parallel/parallel_shallow_water.py	(revision 8537)
+++ /trunk/anuga_core/source/anuga_parallel/parallel_shallow_water.py	(revision 8538)
@@ -41,5 +41,6 @@
                  p2s_map=None, #jj added this
                  tri_l2g = None, ## SR added this
-                 node_l2g = None): ## SR added this
+                 node_l2g = None, #): ## SR added this
+                 ghost_layer_width = 2):
 
         Domain.__init__(self,
@@ -53,7 +54,7 @@
                         number_of_full_nodes=number_of_full_nodes,
                         number_of_full_triangles=number_of_full_triangles,
-                        geo_reference=geo_reference) #jj added this
+                        geo_reference=geo_reference, #) #jj added this
+                        ghost_layer_width = ghost_layer_width)
         
-
 
         self.parallel = True
@@ -89,4 +90,6 @@
         self.node_l2g = node_l2g
 
+        self.ghost_counter = 0
+
 
     def set_name(self, name):
@@ -122,5 +125,5 @@
         receive the information for the ghost cells
         """
-
+            
         generic_comms.communicate_ghosts_asynchronous(self)
         #generic_comms.communicate_ghosts_blocking(self)
Index: /trunk/anuga_core/source/anuga_parallel/run_parallel_sw_rectangular_cross.py
===================================================================
--- /trunk/anuga_core/source/anuga_parallel/run_parallel_sw_rectangular_cross.py	(revision 8537)
+++ /trunk/anuga_core/source/anuga_parallel/run_parallel_sw_rectangular_cross.py	(revision 8538)
@@ -52,8 +52,15 @@
 
 
-if myid == 0 and verbose: print 'DISTRIBUTING DOMAIN'
-domain = distribute(domain,verbose=verbose)
+if myid == 0 and verbose: 
+    print 'DISTRIBUTING DOMAIN'
+    sys.stdout.flush()
+    
+barrier()
 
-print 'after parallel domain'
+# setup parameters to test using different ghost_layer_widths
+parameters = dict(ghost_layer_width = 4)
+domain = distribute(domain,verbose=verbose, parameters=parameters)
+
+if myid == 0 : print 'after parallel domain'
 
 
@@ -69,10 +76,11 @@
 
 
-print 'after set_boundary'
+if myid == 0 : print 'after set_boundary'
 
 
 
 domain.check_integrity()
-print 'after check_integrity'
+
+if myid == 0 : print 'after check_integrity'
 
 class Set_Stage:
@@ -96,5 +104,5 @@
 
 
-print 'after set quantity'
+if myid == 0 : print 'after set quantity'
 
 # Set Evolve parameters
@@ -142,5 +150,5 @@
 
 
-
+domain.dump_triangulation(filename="rectangular_cross_%g.png"% numprocs)
 
 finalize()
Index: /trunk/anuga_core/source/anuga_parallel/test_distribute_mesh.py
===================================================================
--- /trunk/anuga_core/source/anuga_parallel/test_distribute_mesh.py	(revision 8537)
+++ /trunk/anuga_core/source/anuga_parallel/test_distribute_mesh.py	(revision 8538)
@@ -47,7 +47,11 @@
 
 
-        true_points = [[0.0, 0.0], [0.0, 0.5], [0.0, 1.0], [0.5, 0.0], [0.5, 0.5], [0.5, 1.0], [1.0, 0.0], [1.0, 0.5], [1.0, 1.0], [0.25, 0.25], [0.25, 0.75], [0.75, 0.25], [0.75, 0.75]]
-
-        true_vertices = [[0, 9, 1], [3, 9, 0], [4, 9, 3], [1, 9, 4], [1, 10, 2], [4, 10, 1], [5, 10, 4], [2, 10, 5], [3, 11, 4], [6, 11, 3], [7, 11, 6], [4, 11, 7], [4, 12, 5], [7, 12, 4], [8, 12, 7], [5, 12, 8]]
+        true_points = [[0.0, 0.0], [0.0, 0.5], [0.0, 1.0], [0.5, 0.0], \
+        [0.5, 0.5], [0.5, 1.0], [1.0, 0.0], [1.0, 0.5], [1.0, 1.0], [0.25, 0.25], \
+        [0.25, 0.75], [0.75, 0.25], [0.75, 0.75]]
+
+        true_vertices = [[0, 9, 1], [3, 9, 0], [4, 9, 3], [1, 9, 4], [1, 10, 2], \
+        [4, 10, 1], [5, 10, 4], [2, 10, 5], [3, 11, 4], [6, 11, 3], [7, 11, 6], [4, 11, 7],
+        [4, 12, 5], [7, 12, 4], [8, 12, 7], [5, 12, 8]]
 
 
@@ -70,7 +74,10 @@
 
 
-        true_nodes = [[0.0, 0.0], [0.0, 0.5], [0.0, 1.0], [0.5, 0.0], [0.5, 0.5], [0.5, 1.0], [1.0, 0.0], [1.0, 0.5], [1.0, 1.0], [0.25, 0.25], [0.25, 0.75], [0.75, 0.25], [0.75, 0.75]]
-
-        true_triangles = [[0, 9, 1], [3, 9, 0], [4, 9, 3], [1, 9, 4], [1, 10, 2], [4, 10, 1], [5, 10, 4], [2, 10, 5], [3, 11, 4], [6, 11, 3], [7, 11, 6], [4, 11, 7], [4, 12, 5], [7, 12, 4], [8, 12, 7], [5, 12, 8]]
+        true_nodes = [[0.0, 0.0], [0.0, 0.5], [0.0, 1.0], [0.5, 0.0], [0.5, 0.5], [0.5, 1.0], \
+        [1.0, 0.0], [1.0, 0.5], [1.0, 1.0], [0.25, 0.25], [0.25, 0.75], [0.75, 0.25], [0.75, 0.75]]
+
+        true_triangles = [[0, 9, 1], [3, 9, 0], [4, 9, 3], [1, 9, 4], [1, 10, 2], [4, 10, 1], \
+        [5, 10, 4], [2, 10, 5], [3, 11, 4], [6, 11, 3], [7, 11, 6], [4, 11, 7], [4, 12, 5], \
+        [7, 12, 4], [8, 12, 7], [5, 12, 8]]
 
 
@@ -90,7 +97,10 @@
 
 
-        true_points = [[0.0, 0.0], [0.0, 0.5], [0.0, 1.0], [0.5, 0.0], [0.5, 0.5], [0.5, 1.0], [1.0, 0.0], [1.0, 0.5], [1.0, 1.0], [0.25, 0.25], [0.25, 0.75], [0.75, 0.25], [0.75, 0.75]]
-
-        true_vertices = [[0, 9, 1], [3, 9, 0], [4, 9, 3], [1, 9, 4], [1, 10, 2], [4, 10, 1], [5, 10, 4], [2, 10, 5], [3, 11, 4], [6, 11, 3], [7, 11, 6], [4, 11, 7], [4, 12, 5], [7, 12, 4], [8, 12, 7], [5, 12, 8]]
+        true_points = [[0.0, 0.0], [0.0, 0.5], [0.0, 1.0], [0.5, 0.0], [0.5, 0.5], [0.5, 1.0], \
+        [1.0, 0.0], [1.0, 0.5], [1.0, 1.0], [0.25, 0.25], [0.25, 0.75], [0.75, 0.25], [0.75, 0.75]]
+
+        true_vertices = [[0, 9, 1], [3, 9, 0], [4, 9, 3], [1, 9, 4], [1, 10, 2], [4, 10, 1], \
+        [5, 10, 4], [2, 10, 5], [3, 11, 4], [6, 11, 3], [7, 11, 6], [4, 11, 7], [4, 12, 5], \
+        [7, 12, 4], [8, 12, 7], [5, 12, 8]]
 
 
@@ -113,8 +123,11 @@
 
 
-        true_nodes = [[0.0, 0.0], [0.0, 0.5], [0.0, 1.0], [0.5, 0.0], [0.5, 0.5], [0.5, 1.0], [1.0, 0.0], [1.0, 0.5], [1.0, 1.0], [0.25, 0.25], [0.25, 0.75], [0.75, 0.25], [0.75, 0.75]]
-
-
-        true_triangles = [[0, 9, 1], [3, 9, 0], [4, 9, 3], [1, 9, 4], [4, 10, 1], [3, 11, 4], [4, 11, 7], [4, 12, 5], [1, 10, 2], [5, 10, 4], [2, 10, 5], [6, 11, 3], [7, 11, 6], [7, 12, 4], [8, 12, 7], [5, 12, 8]]
+        true_nodes = [[0.0, 0.0], [0.0, 0.5], [0.0, 1.0], [0.5, 0.0], [0.5, 0.5], [0.5, 1.0], \
+        [1.0, 0.0], [1.0, 0.5], [1.0, 1.0], [0.25, 0.25], [0.25, 0.75], [0.75, 0.25], [0.75, 0.75]]
+
+
+        true_triangles = [[0, 9, 1], [3, 9, 0], [4, 9, 3], [1, 9, 4], [4, 10, 1], [3, 11, 4], \
+        [4, 11, 7], [4, 12, 5], [1, 10, 2], [5, 10, 4], [2, 10, 5], [6, 11, 3], [7, 11, 6], \
+        [7, 12, 4], [8, 12, 7], [5, 12, 8]]
 
 
@@ -132,11 +145,15 @@
         """
 
-        nodes = [[0.0, 0.0], [0.0, 0.5], [0.0, 1.0], [0.5, 0.0], [0.5, 0.5], [0.5, 1.0], [1.0, 0.0], [1.0, 0.5], [1.0, 1.0], [0.25, 0.25], [0.25, 0.75], [0.75, 0.25], [0.75, 0.75]]
-
-
-        triangles = [[4, 9, 3], [4, 12, 5], [7, 12, 4], [8, 12, 7], [5, 12, 8], [0, 9, 1], [1, 9, 4], [1, 10, 2], [4, 10, 1], [5, 10, 4], [2, 10, 5], [3, 9, 0], [3, 11, 4], [6, 11, 3], [7, 11, 6], [4, 11, 7]]
-
-
-        edges = {(13, 1): 'bottom', (7, 1): 'left', (3, 1): 'right', (14, 1): 'right', (11, 1): 'bottom', (10, 1): 'top', (5, 1): 'left', (4, 1): 'top'}
+        nodes = [[0.0, 0.0], [0.0, 0.5], [0.0, 1.0], [0.5, 0.0], [0.5, 0.5], [0.5, 1.0], [1.0, 0.0], \
+        [1.0, 0.5], [1.0, 1.0], [0.25, 0.25], [0.25, 0.75], [0.75, 0.25], [0.75, 0.75]]
+
+
+        triangles = [[4, 9, 3], [4, 12, 5], [7, 12, 4], [8, 12, 7], [5, 12, 8], [0, 9, 1], \
+        [1, 9, 4], [1, 10, 2], [4, 10, 1], [5, 10, 4], [2, 10, 5], [3, 9, 0], [3, 11, 4], \
+        [6, 11, 3], [7, 11, 6], [4, 11, 7]]
+
+
+        boundary = {(13, 1): 'bottom', (7, 1): 'left', (3, 1): 'right', (14, 1): 'right', \
+        (11, 1): 'bottom', (10, 1): 'top', (5, 1): 'left', (4, 1): 'top'}
 
         triangles_per_proc = [5, 6, 5]
@@ -222,5 +239,7 @@
 
         
-        true_submesh = {'full_boundary': [{(3, 1): 'right', (4, 1): 'top'}, {(5, 1): 'left', (10, 1): 'top', (7, 1): 'left'}, {(13, 1): 'bottom', (14, 1): 'right', (11, 1): 'bottom'}],
+        true_submesh = {'full_boundary': [{(3, 1): 'right', (4, 1): 'top'},\
+        {(5, 1): 'left', (10, 1): 'top', (7, 1): 'left'}, \
+        {(13, 1): 'bottom', (14, 1): 'right', (11, 1): 'bottom'}],
                         'ghost_nodes': [num.array([[  0.  ,   0.  ,   0.  ],
        [  1.  ,   0.  ,   0.5 ],
@@ -275,7 +294,15 @@
        [ 5,  0,  9,  1],
        [ 6,  1,  9,  4]])],
-                        'ghost_boundary': [{(13, 1): 'ghost', (8, 0): 'ghost', (14, 1): 'ghost', (11, 1): 'ghost', (10, 1): 'ghost', (5, 1): 'ghost', (10, 2): 'ghost'}, {(12, 2): 'ghost', (12, 0): 'ghost', (2, 1): 'ghost', (11, 1): 'ghost', (2, 2): 'ghost', (4, 1): 'ghost', (4, 0): 'ghost'}, {(3, 2): 'ghost', (6, 1): 'ghost', (3, 1): 'ghost', (5, 1): 'ghost', (1, 0): 'ghost', (1, 1): 'ghost'}],
-                        'full_triangles': [[[4, 9, 3], [4, 12, 5], [7, 12, 4], [8, 12, 7], [5, 12, 8]], [[0, 9, 1], [1, 9, 4], [1, 10, 2], [4, 10, 1], [5, 10, 4], [2, 10, 5]], [[3, 9, 0], [3, 11, 4], [6, 11, 3], [7, 11, 6], [4, 11, 7]]],
-                        'full_commun': [{0: [1, 2], 1: [1, 2], 2: [1, 2], 3: [2], 4: [1]}, {5: [0, 2], 6: [0, 2], 7: [], 8: [0], 9: [0], 10: [0]}, {11: [0, 1], 12: [0, 1], 13: [0], 14: [0], 15: [0]}],
+                        'ghost_boundary': [{(13, 1): 'ghost', (8, 0): 'ghost', (14, 1): 'ghost', \
+                        (11, 1): 'ghost', (10, 1): 'ghost', (5, 1): 'ghost', (10, 2): 'ghost'}, \
+                        {(12, 2): 'ghost', (12, 0): 'ghost', (2, 1): 'ghost', (11, 1): 'ghost',\
+                        (2, 2): 'ghost', (4, 1): 'ghost', (4, 0): 'ghost'}, {(3, 2): 'ghost', \
+                        (6, 1): 'ghost', (3, 1): 'ghost', (5, 1): 'ghost', (1, 0): 'ghost', (1, 1): 'ghost'}],
+                        'full_triangles': [[[4, 9, 3], [4, 12, 5], [7, 12, 4], [8, 12, 7], [5, 12, 8]], \
+                        [[0, 9, 1], [1, 9, 4], [1, 10, 2], [4, 10, 1], [5, 10, 4], [2, 10, 5]], \
+                        [[3, 9, 0], [3, 11, 4], [6, 11, 3], [7, 11, 6], [4, 11, 7]]],
+                        'full_commun': [{0: [1, 2], 1: [1, 2], 2: [1, 2], 3: [2], 4: [1]}, \
+                        {5: [0, 2], 6: [0, 2], 7: [], 8: [0], 9: [0], 10: [0]}, \
+                        {11: [0, 1], 12: [0, 1], 13: [0], 14: [0], 15: [0]}],
                         'ghost_commun': [num.array([[ 5,  1],
        [ 6,  1],
@@ -462,5 +489,5 @@
         from anuga.abstract_2d_finite_volumes.neighbour_mesh import Mesh
         
-        mesh = Mesh(nodes, triangles)
+        mesh = Mesh(nodes, triangles, boundary)
         boundary_polygon = mesh.get_boundary_polygon()
 
@@ -468,6 +495,5 @@
         # Subdivide into non-overlapping partitions
 
-        submesh = submesh_full(nodes, triangles, edges, \
-                            triangles_per_proc)
+        submesh = submesh_full(mesh, triangles_per_proc)
 
         #print submesh
@@ -509,5 +535,364 @@
 
 
-        #print submesh
+
+    def test_build_submesh_3_layer_4(self):
+        """
+        Test 3 Layer 4 way build_submesh with ghost_layer_width = 4
+        """
+
+        nodes = [[0.0, 0.0], [0.0, 0.5], [0.0, 1.0], [0.5, 0.0], [0.5, 0.5], [0.5, 1.0], \
+        [1.0, 0.0], [1.0, 0.5], [1.0, 1.0], [0.25, 0.25], [0.25, 0.75], [0.75, 0.25], [0.75, 0.75]]
+
+
+        triangles = [[4, 9, 3], [4, 12, 5], [7, 12, 4], [8, 12, 7], [5, 12, 8], [0, 9, 1], \
+        [1, 9, 4], [1, 10, 2], [4, 10, 1], [5, 10, 4], [2, 10, 5], [3, 9, 0], [3, 11, 4], \
+        [6, 11, 3], [7, 11, 6], [4, 11, 7]]
+
+
+        boundary = {(13, 1): 'bottom', (7, 1): 'left', (3, 1): 'right', (14, 1): 'right', \
+        (11, 1): 'bottom', (10, 1): 'top', (5, 1): 'left', (4, 1): 'top'}
+
+        """
+                     top
+            (10,1)       (4,1)
+        2 ---------- 5 ---------- 8
+        | \   10   / | \   04   / |
+        |   \    /   |   \    /   |
+ (7,1)  | 07  10  09 | 01  12  03 | (3,1)
+        |   /    \   |   /    \   |
+        | /   08   \ | /   02   \ |
+ left   1 ---------- 4 ---------- 7  right
+        | \   06   / | \   15   / |
+        |   \    /   |   \    /   |
+ (5,1)  | 05  09  00 | 12  11  14 | (14,1)
+        |   /    \   |   /    \   |
+        | /   11   \ | /   13   \ |
+        0 ---------- 3 ---------- 6
+            (11,1)        (13,1)
+                   bottom
+
+
+        Processor 0 Full Triangles 00,01,02,03,04
+        Processor 1 Full Triangles 05,06,07,08,09,10
+        Processor 2 Full Triangles 11,12,13,14,15
+        """
+
+
+        triangles_per_proc = [5, 6, 5]
+
+
+
+
+        true_submesh = {'full_boundary': [{(3, 1): 'right', (4, 1): 'top'}, {(5, 1): 'left', \
+        (10, 1): 'top', (7, 1): 'left'}, {(13, 1): 'bottom', (14, 1): 'right', (11, 1): 'bottom'}],
+                        'ghost_nodes': [num.array([[  0.  ,   0.  ,   0.  ],
+       [  1.  ,   0.  ,   0.5 ],
+       [  2.  ,   0.  ,   1.  ],
+       [  6.  ,   1.  ,   0.  ],
+       [ 10.  ,   0.25,   0.75],
+       [ 11.  ,   0.75,   0.25]]), num.array([[  3.  ,   0.5 ,   0.  ],
+       [  7.  ,   1.  ,   0.5 ],
+       [  8.  ,   1.  ,   1.  ],
+       [ 11.  ,   0.75,   0.25],
+       [ 12.  ,   0.75,   0.75]]), num.array([[  1.  ,   0.  ,   0.5 ],
+       [  5.  ,   0.5 ,   1.  ],
+       [  8.  ,   1.  ,   1.  ],
+       [ 12.  ,   0.75,   0.75]])],
+                        'full_nodes': [num.array([[  3.  ,   0.5 ,   0.  ],
+       [  4.  ,   0.5 ,   0.5 ],
+       [  5.  ,   0.5 ,   1.  ],
+       [  7.  ,   1.  ,   0.5 ],
+       [  8.  ,   1.  ,   1.  ],
+       [  9.  ,   0.25,   0.25],
+       [ 12.  ,   0.75,   0.75]]), num.array([[  0.  ,   0.  ,   0.  ],
+       [  1.  ,   0.  ,   0.5 ],
+       [  2.  ,   0.  ,   1.  ],
+       [  4.  ,   0.5 ,   0.5 ],
+       [  5.  ,   0.5 ,   1.  ],
+       [  9.  ,   0.25,   0.25],
+       [ 10.  ,   0.25,   0.75]]), num.array([[  0.  ,   0.  ,   0.  ],
+       [  3.  ,   0.5 ,   0.  ],
+       [  4.  ,   0.5 ,   0.5 ],
+       [  6.  ,   1.  ,   0.  ],
+       [  7.  ,   1.  ,   0.5 ],
+       [  9.  ,   0.25,   0.25],
+       [ 11.  ,   0.75,   0.25]])],
+                        'ghost_triangles': [num.array([[ 5,  0,  9,  1],
+       [ 6,  1,  9,  4],
+       [ 8,  4, 10,  1],
+       [ 9,  5, 10,  4],
+       [10,  2, 10,  5],
+       [11,  3,  9,  0],
+       [12,  3, 11,  4],
+       [13,  6, 11,  3],
+       [14,  7, 11,  6],
+       [15,  4, 11,  7]]), num.array([[ 0,  4,  9,  3],
+       [ 1,  4, 12,  5],
+       [ 2,  7, 12,  4],
+       [ 4,  5, 12,  8],
+       [11,  3,  9,  0],
+       [12,  3, 11,  4]]), num.array([[ 0,  4,  9,  3],
+       [ 1,  4, 12,  5],
+       [ 2,  7, 12,  4],
+       [ 3,  8, 12,  7],
+       [ 5,  0,  9,  1],
+       [ 6,  1,  9,  4]])],
+                        'ghost_boundary': [{(13, 1): 'ghost', (8, 0): 'ghost', \
+                        (14, 1): 'ghost', (11, 1): 'ghost', (10, 1): 'ghost', \
+                        (5, 1): 'ghost', (10, 2): 'ghost'}, {(12, 2): 'ghost', \
+                        (12, 0): 'ghost', (2, 1): 'ghost', (11, 1): 'ghost', \
+                        (2, 2): 'ghost', (4, 1): 'ghost', (4, 0): 'ghost'}, \
+                        {(3, 2): 'ghost', (6, 1): 'ghost', (3, 1): 'ghost', \
+                        (5, 1): 'ghost', (1, 0): 'ghost', (1, 1): 'ghost'}],
+                        'full_triangles': [[[4, 9, 3], [4, 12, 5], [7, 12, 4], \
+                        [8, 12, 7], [5, 12, 8]], [[0, 9, 1], [1, 9, 4], [1, 10, 2], \
+                        [4, 10, 1], [5, 10, 4], [2, 10, 5]], [[3, 9, 0], [3, 11, 4], \
+                        [6, 11, 3], [7, 11, 6], [4, 11, 7]]],
+                        'full_commun': [{0: [1, 2], 1: [1, 2], 2: [1, 2], 3: [2], 4: [1]}, \
+                        {5: [0, 2], 6: [0, 2], 7: [], 8: [0], 9: [0], 10: [0]}, \
+                        {11: [0, 1], 12: [0, 1], 13: [0], 14: [0], 15: [0]}],
+                        'ghost_commun': [num.array([[ 5,  1],
+       [ 6,  1],
+       [ 8,  1],
+       [ 9,  1],
+       [10,  1],
+       [11,  2],
+       [12,  2],
+       [13,  2],
+       [14,  2],
+       [15,  2]]), num.array([[ 0,  0],
+       [ 1,  0],
+       [ 2,  0],
+       [ 4,  0],
+       [11,  2],
+       [12,  2]]), num.array([[0, 0],
+       [1, 0],
+       [2, 0],
+       [3, 0],
+       [5, 1],
+       [6, 1]])],  'ghost_quan': {'stage': [num.array([[-0.   , -0.125, -0.   ],
+       [-0.   , -0.125, -0.25 ],
+       [-0.25 , -0.125, -0.   ],
+       [-0.25 , -0.125, -0.25 ],
+       [-0.   , -0.125, -0.25 ],
+       [-0.25 , -0.125, -0.   ],
+       [-0.25 , -0.375, -0.25 ],
+       [-0.5  , -0.375, -0.25 ],
+       [-0.5  , -0.375, -0.5  ],
+       [-0.25 , -0.375, -0.5  ]]), num.array([[-0.25 , -0.125, -0.25 ],
+       [-0.25 , -0.375, -0.25 ],
+       [-0.5  , -0.375, -0.25 ],
+       [-0.25 , -0.375, -0.5  ],
+       [-0.25 , -0.125, -0.   ],
+       [-0.25 , -0.375, -0.25 ]]), num.array([[-0.25 , -0.125, -0.25 ],
+       [-0.25 , -0.375, -0.25 ],
+       [-0.5  , -0.375, -0.25 ],
+       [-0.5  , -0.375, -0.5  ],
+       [-0.   , -0.125, -0.   ],
+       [-0.   , -0.125, -0.25 ]])],  'elevation': [num.array([[-0.   , -0.125, -0.   ],
+       [-0.   , -0.125, -0.25 ],
+       [-0.25 , -0.125, -0.   ],
+       [-0.25 , -0.125, -0.25 ],
+       [-0.   , -0.125, -0.25 ],
+       [-0.25 , -0.125, -0.   ],
+       [-0.25 , -0.375, -0.25 ],
+       [-0.5  , -0.375, -0.25 ],
+       [-0.5  , -0.375, -0.5  ],
+       [-0.25 , -0.375, -0.5  ]]), num.array([[-0.25 , -0.125, -0.25 ],
+       [-0.25 , -0.375, -0.25 ],
+       [-0.5  , -0.375, -0.25 ],
+       [-0.25 , -0.375, -0.5  ],
+       [-0.25 , -0.125, -0.   ],
+       [-0.25 , -0.375, -0.25 ]]), num.array([[-0.25 , -0.125, -0.25 ],
+       [-0.25 , -0.375, -0.25 ],
+       [-0.5  , -0.375, -0.25 ],
+       [-0.5  , -0.375, -0.5  ],
+       [-0.   , -0.125, -0.   ],
+       [-0.   , -0.125, -0.25 ]])],  'ymomentum': [num.array([[ 0.  ,  0.25,  0.5 ],
+       [ 0.5 ,  0.25,  0.5 ],
+       [ 0.5 ,  0.75,  0.5 ],
+       [ 1.  ,  0.75,  0.5 ],
+       [ 1.  ,  0.75,  1.  ],
+       [ 0.  ,  0.25,  0.  ],
+       [ 0.  ,  0.25,  0.5 ],
+       [ 0.  ,  0.25,  0.  ],
+       [ 0.5 ,  0.25,  0.  ],
+       [ 0.5 ,  0.25,  0.5 ]]), num.array([[ 0.5 ,  0.25,  0.  ],
+       [ 0.5 ,  0.75,  1.  ],
+       [ 0.5 ,  0.75,  0.5 ],
+       [ 1.  ,  0.75,  1.  ],
+       [ 0.  ,  0.25,  0.  ],
+       [ 0.  ,  0.25,  0.5 ]]), num.array([[ 0.5 ,  0.25,  0.  ],
+       [ 0.5 ,  0.75,  1.  ],
+       [ 0.5 ,  0.75,  0.5 ],
+       [ 1.  ,  0.75,  0.5 ],
+       [ 0.  ,  0.25,  0.5 ],
+       [ 0.5 ,  0.25,  0.5 ]])],  'friction': [num.array([[ 0.,  0.,  0.],
+       [ 0.,  0.,  0.],
+       [ 0.,  0.,  0.],
+       [ 0.,  0.,  0.],
+       [ 0.,  0.,  0.],
+       [ 0.,  0.,  0.],
+       [ 0.,  0.,  0.],
+       [ 0.,  0.,  0.],
+       [ 0.,  0.,  0.],
+       [ 0.,  0.,  0.]]), num.array([[ 0.,  0.,  0.],
+       [ 0.,  0.,  0.],
+       [ 0.,  0.,  0.],
+       [ 0.,  0.,  0.],
+       [ 0.,  0.,  0.],
+       [ 0.,  0.,  0.]]), num.array([[ 0.,  0.,  0.],
+       [ 0.,  0.,  0.],
+       [ 0.,  0.,  0.],
+       [ 0.,  0.,  0.],
+       [ 0.,  0.,  0.],
+       [ 0.,  0.,  0.]])], 'xmomentum': [num.array([[ 2.,  2.,  2.],
+       [ 2.,  2.,  2.],
+       [ 2.,  2.,  2.],
+       [ 2.,  2.,  2.],
+       [ 2.,  2.,  2.],
+       [ 2.,  2.,  2.],
+       [ 2.,  2.,  2.],
+       [ 2.,  2.,  2.],
+       [ 2.,  2.,  2.],
+       [ 2.,  2.,  2.]]), num.array([[ 2.,  2.,  2.],
+       [ 2.,  2.,  2.],
+       [ 2.,  2.,  2.],
+       [ 2.,  2.,  2.],
+       [ 2.,  2.,  2.],
+       [ 2.,  2.,  2.]]), num.array([[ 2.,  2.,  2.],
+       [ 2.,  2.,  2.],
+       [ 2.,  2.,  2.],
+       [ 2.,  2.,  2.],
+       [ 2.,  2.,  2.],
+       [ 2.,  2.,  2.]])]},  'full_quan': {'stage': [num.array([[-0.25 , -0.125, -0.25 ],
+       [-0.25 , -0.375, -0.25 ],
+       [-0.5  , -0.375, -0.25 ],
+       [-0.5  , -0.375, -0.5  ],
+       [-0.25 , -0.375, -0.5  ]]), num.array([[-0.   , -0.125, -0.   ],
+       [-0.   , -0.125, -0.25 ],
+       [-0.   , -0.125, -0.   ],
+       [-0.25 , -0.125, -0.   ],
+       [-0.25 , -0.125, -0.25 ],
+       [-0.   , -0.125, -0.25 ]]), num.array([[-0.25 , -0.125, -0.   ],
+       [-0.25 , -0.375, -0.25 ],
+       [-0.5  , -0.375, -0.25 ],
+       [-0.5  , -0.375, -0.5  ],
+       [-0.25 , -0.375, -0.5  ]])],  'elevation': [num.array([[-0.25 , -0.125, -0.25 ],
+       [-0.25 , -0.375, -0.25 ],
+       [-0.5  , -0.375, -0.25 ],
+       [-0.5  , -0.375, -0.5  ],
+       [-0.25 , -0.375, -0.5  ]]), num.array([[-0.   , -0.125, -0.   ],
+       [-0.   , -0.125, -0.25 ],
+       [-0.   , -0.125, -0.   ],
+       [-0.25 , -0.125, -0.   ],
+       [-0.25 , -0.125, -0.25 ],
+       [-0.   , -0.125, -0.25 ]]), num.array([[-0.25 , -0.125, -0.   ],
+       [-0.25 , -0.375, -0.25 ],
+       [-0.5  , -0.375, -0.25 ],
+       [-0.5  , -0.375, -0.5  ],
+       [-0.25 , -0.375, -0.5  ]])],  'ymomentum': [num.array([[ 0.5 ,  0.25,  0.  ],
+       [ 0.5 ,  0.75,  1.  ],
+       [ 0.5 ,  0.75,  0.5 ],
+       [ 1.  ,  0.75,  0.5 ],
+       [ 1.  ,  0.75,  1.  ]]), num.array([[ 0.  ,  0.25,  0.5 ],
+       [ 0.5 ,  0.25,  0.5 ],
+       [ 0.5 ,  0.75,  1.  ],
+       [ 0.5 ,  0.75,  0.5 ],
+       [ 1.  ,  0.75,  0.5 ],
+       [ 1.  ,  0.75,  1.  ]]), num.array([[ 0.  ,  0.25,  0.  ],
+       [ 0.  ,  0.25,  0.5 ],
+       [ 0.  ,  0.25,  0.  ],
+       [ 0.5 ,  0.25,  0.  ],
+       [ 0.5 ,  0.25,  0.5 ]])],  'friction': [num.array([[ 0.,  0.,  0.],
+       [ 0.,  0.,  0.],
+       [ 0.,  0.,  0.],
+       [ 0.,  0.,  0.],
+       [ 0.,  0.,  0.]]), num.array([[ 0.,  0.,  0.],
+       [ 0.,  0.,  0.],
+       [ 0.,  0.,  0.],
+       [ 0.,  0.,  0.],
+       [ 0.,  0.,  0.],
+       [ 0.,  0.,  0.]]), num.array([[ 0.,  0.,  0.],
+       [ 0.,  0.,  0.],
+       [ 0.,  0.,  0.],
+       [ 0.,  0.,  0.],
+       [ 0.,  0.,  0.]])],  'xmomentum': [num.array([[ 2.,  2.,  2.],
+       [ 2.,  2.,  2.],
+       [ 2.,  2.,  2.],
+       [ 2.,  2.,  2.],
+       [ 2.,  2.,  2.]]), num.array([[ 2.,  2.,  2.],
+       [ 2.,  2.,  2.],
+       [ 2.,  2.,  2.],
+       [ 2.,  2.,  2.],
+       [ 2.,  2.,  2.],
+       [ 2.,  2.,  2.]]), num.array([[ 2.,  2.,  2.],
+       [ 2.,  2.,  2.],
+       [ 2.,  2.,  2.],
+       [ 2.,  2.,  2.],
+       [ 2.,  2.,  2.]])]}}
+
+
+        # setup parameters to test using different ghost_layer_widths
+        parameters = dict(ghost_layer_width = 1)
+
+        from anuga.abstract_2d_finite_volumes.neighbour_mesh import Mesh
+
+        mesh = Mesh(nodes, triangles, boundary)
+        boundary_polygon = mesh.get_boundary_polygon()
+
+
+        # Subdivide into non-overlapping partitions
+
+        submesh = submesh_full(mesh, triangles_per_proc)
+
+
+
+        for i in range(3):
+            assert num.allclose(true_submesh['full_triangles'][i],submesh['full_triangles'][i])
+            assert num.allclose(true_submesh['full_nodes'][i],submesh['full_nodes'][i])
+        assert true_submesh['full_boundary'] == submesh['full_boundary']
+
+        # Add any extra ghost boundary layer information
+
+        submesh = submesh_ghost(submesh, mesh, triangles_per_proc, parameters)
+
+        print submesh
+
+        print 'ghost_triangles', submesh['ghost_triangles']
+        print 'ghost_boundary[0]', submesh['ghost_boundary'][0]
+        print 'ghost_boundary[1]', submesh['ghost_boundary'][1]
+        print 'ghost_boundary[2]', submesh['ghost_boundary'][2]
+        print 'ghost_nodes', submesh['ghost_nodes']
+        print 'ghost_commun', submesh['ghost_commun']
+        
+        for i in range(3):
+            assert num.allclose(true_submesh['ghost_triangles'][i],submesh['ghost_triangles'][i])
+            assert num.allclose(true_submesh['ghost_nodes'][i],submesh['ghost_nodes'][i])
+            assert num.allclose(true_submesh['ghost_commun'][i],submesh['ghost_commun'][i])
+
+        assert true_submesh['full_commun'] == submesh['full_commun']
+
+
+        # Order the quantities information to be the same as the triangle
+        # information
+
+
+        submesh = submesh_quantities(submesh, quantities, \
+                                 triangles_per_proc)
+
+
+
+        for key, value in true_submesh['ghost_quan'].iteritems():
+            for i in range(3):
+                assert num.allclose(true_submesh['ghost_quan'][key][i],submesh['ghost_quan'][key][i])
+                assert num.allclose(true_submesh['full_quan'][key][i],submesh['full_quan'][key][i])
+
+
+        submesh["boundary_polygon"] = boundary_polygon
+
+
+
+
 
 #-------------------------------------------------------------
Index: /trunk/anuga_work/development/parallel/build_commun.py
===================================================================
--- /trunk/anuga_work/development/parallel/build_commun.py	(revision 8537)
+++ /trunk/anuga_work/development/parallel/build_commun.py	(revision 8538)
@@ -17,6 +17,12 @@
 #########################################################
 
-from Numeric import array, Int, Float, zeros
-import logging, logging.config
+
+
+import numpy as num
+from anuga import indent
+
+from numpy import array, zeros
+import logging
+import logging.config
 logger = logging.getLogger('parallel')
 logger.setLevel(logging.WARNING)
@@ -104,5 +110,5 @@
     # send the triangles
 
-    pypar.send(array(submesh["full_triangles"][p], Int), p, use_buffer=True)
+    pypar.send(array(submesh["full_triangles"][p], num.int), p, use_buffer=True)
     pypar.send(submesh["ghost_triangles"][p], p, use_buffer=True)
 
@@ -156,5 +162,5 @@
     submesh_cell = {}
     
-    print 'process %d receiving submesh from process %d' %(myid, p)
+    print 'P%d: Receiving submesh from P%d' %(myid, p)
 
     # receive the tagmap for the boundary conditions
@@ -185,5 +191,5 @@
 
     no_full_nodes = setup_array[0]
-    full_nodes = zeros((no_full_nodes, 3), Float)
+    full_nodes = zeros((no_full_nodes, 3), num.float)
     submesh_cell["full_nodes"] = pypar.receive(p, full_nodes)
     
@@ -191,5 +197,5 @@
 
     no_ghost_nodes = setup_array[1]
-    ghost_nodes = zeros((no_ghost_nodes, 3), Float)
+    ghost_nodes = zeros((no_ghost_nodes, 3), num.float)
     submesh_cell["ghost_nodes"] = pypar.receive(p, ghost_nodes)
 
@@ -255,17 +261,17 @@
 
     no_quantities = len(qkeys)
-    new_quan = zeros((no_full_triangles, 3), Float)
+    new_quan = zeros((no_full_triangles, 3), num.float)
     submesh_cell["full_quan"]={}
     
     for i in range(no_quantities):
         tmp = pypar.receive(p, new_quan)
-        submesh_cell["full_quan"][qkeys[i]]=zeros((no_full_triangles,3), Float)
+        submesh_cell["full_quan"][qkeys[i]]=zeros((no_full_triangles,3), num.float)
         submesh_cell["full_quan"][qkeys[i]][:] = tmp[:]
 
-    new_quan = zeros((no_ghost_triangles, 3), Float)
+    new_quan = zeros((no_ghost_triangles, 3), num.float)
     submesh_cell["ghost_quan"]={}
     for i in range(no_quantities):
         tmp = pypar.receive(p, new_quan)
-        submesh_cell["ghost_quan"][qkeys[i]]= zeros((no_ghost_triangles,3), Float)
+        submesh_cell["ghost_quan"][qkeys[i]]= zeros((no_ghost_triangles,3), num.float)
         submesh_cell["ghost_quan"][qkeys[i]][:] = tmp[:]
     
