Index: /anuga_core/source/anuga_parallel/parallel_api.py
===================================================================
--- /anuga_core/source/anuga_parallel/parallel_api.py	(revision 3592)
+++ /anuga_core/source/anuga_parallel/parallel_api.py	(revision 3593)
@@ -21,4 +21,52 @@
 processor_name = pypar.Get_processor_name()
 print 'I am processor %d of %d on node %s' %(myid, numprocs, processor_name)
+
+
+
+
+def distribute(domain):
+
+    if myid == 0:
+        #-------------------------------------------------------------------
+        # Distribute the domain
+        #-------------------------------------------------------------------
+
+        points, vertices, boundary, quantities,\
+                ghost_recv_dict, full_send_dict,\
+                = distribute_mesh(domain)
+        print 'Communication done'        
+        
+    else:
+        # Read in the mesh partition that belongs to this
+        # processor (note that the information is in the
+        # correct form for the GA data structure)
+
+        points, vertices, boundary, quantities,\
+                ghost_recv_dict, full_send_dict,\
+                = rec_submesh(0)
+
+    #------------------------------------------------------------------------
+    # Start the computations on each subpartion
+    #------------------------------------------------------------------------
+
+    # Build the domain for this processor
+    domain = Parallel_Domain(points, vertices, boundary,
+                             full_send_dict  = full_send_dict,
+                             ghost_recv_dict = ghost_recv_dict)
+
+    #------------------------------------------------------------------------
+    # Setup initial conditions
+    #------------------------------------------------------------------------
+    for q in quantities:
+        domain.set_quantity(q, quantities[q]) # Distribute all quantities    
+
+
+    #------------------------------------------------------------------------
+    # Return parallel domain to all nodes
+    #------------------------------------------------------------------------
+    return domain    
+
+
+
 
 
Index: /anuga_core/source/anuga_parallel/test_parallel_sw_runup.py
===================================================================
--- /anuga_core/source/anuga_parallel/test_parallel_sw_runup.py	(revision 3592)
+++ /anuga_core/source/anuga_parallel/test_parallel_sw_runup.py	(revision 3593)
@@ -25,101 +25,33 @@
 from parallel_api import *
 
-#------------------------------------------------------------------------------
-# Read in processor information
-#------------------------------------------------------------------------------
 
-numprocs = pypar.size()
-myid = pypar.rank()
-processor_name = pypar.Get_processor_name()
-print 'I am processor %d of %d on node %s' %(myid, numprocs, processor_name)
+#--------------------------------------------------------------------------
+# Setup computational domain
+#--------------------------------------------------------------------------
+points, vertices, boundary = rectangular_cross(10, 10) # Basic mesh
+domain = Domain(points, vertices, boundary) # Create domain
+domain.set_name('runup')                    # Set sww filename
 
 
-#------------------------------------------------------------------------------
-# Initialise 
-#------------------------------------------------------------------------------
+#--------------------------------------------------------------------------
+# Setup initial conditions
+#--------------------------------------------------------------------------
 
-if myid == 0:
-    #--------------------------------------------------------------------------
-    # Setup computational domain
-    #--------------------------------------------------------------------------
+def topography(x,y): 
+    return -x/2                              # linear bed slope
 
-    points, vertices, boundary = rectangular_cross(10, 10) # Basic mesh
-    
-    domain = Domain(points, vertices, boundary) # Create domain
+domain.set_quantity('elevation', topography) # Use function for elevation
+domain.set_quantity('friction', 0.1)         # Constant friction 
+domain.set_quantity('stage', -.4)            # Constant initial stage
 
 
-    # Unstructured mesh
-    #polygon = [[1,1],[0,1],[0,0],[1,0]]
-    #meshname = 'runup.msh'
-    #create_mesh_from_regions(polygon,
-    #                         boundary_tags={'top': [0],
-    #                                        'left': [1],
-    #                                        'bottom': [2],
-    #                                        'right': [3]},
-    #                         maximum_triangle_area=0.01, 
-    #                         filename=meshname)
-    #domain = Domain(meshname, use_cache=True, verbose = True)
+#--------------------------------------------------------------------------
+# Create the parallel domain
+#--------------------------------------------------------------------------
+domain = distribute(domain)
 
 
-    
-    domain.set_name('runup')                    # Set sww filename
-    
 
-    #------------ -------------------------------------------------------------
-    # Setup initial conditions
-    #--------------------------------------------------------------------------
-
-    def topography(x,y): 
-        return -x/2                              # linear bed slope
-
-    domain.set_quantity('elevation', topography) # Use function for elevation
-    domain.set_quantity('friction', 0.1)         # Constant friction 
-    domain.set_quantity('stage', -.4)            # Constant initial stage
-
-
-    #------------ -------------------------------------------------------------
-    # Distribute the domain
-    #--------------------------------------------------------------------------
-    
-    # Subdivide the mesh
-    print 'Subdivide mesh'
-    nodes, triangles, boundary, triangles_per_proc, quantities = \
-           pmesh_divide_metis(domain, numprocs)
-
-    # Build the mesh that should be assigned to each processor,
-    # this includes ghost nodes and the communicaiton pattern
-    print 'Build submeshes'    
-    submesh = build_submesh(nodes, triangles, boundary,\
-                            quantities, triangles_per_proc)
-
-    # Send the mesh partition to the appropriate processor
-    print 'Distribute submeshes'        
-    for p in range(1, numprocs):
-      send_submesh(submesh, triangles_per_proc, p)
-
-
-    # Build the local mesh for processor 0
-    points, vertices, boundary, quantities, ghost_recv_dict, full_send_dict = \
-              extract_hostmesh(submesh, triangles_per_proc)
-
-    print 'Communication done'        
-
-    
-else:
-    # Read in the mesh partition that belongs to this
-    # processor (note that the information is in the
-    # correct form for the GA data structure)
-
-    points, vertices, boundary, quantities, ghost_recv_dict, full_send_dict, \
-            = rec_submesh(0)
-
-#------------------------------------------------------------------------------
-# Start the computations on each subpartion
-#------------------------------------------------------------------------------
-
-# Build the domain for this processor
-domain = Parallel_Domain(points, vertices, boundary,
-                         full_send_dict  = full_send_dict,
-                         ghost_recv_dict = ghost_recv_dict)
+# TODO: Communicate all attributes of domain including boundary conditions
 
 # Name and dir, etc currently has to be set here as they are not
@@ -127,10 +59,4 @@
 domain.set_name('runup')                    # Set sww filename
 
-
-#------------------------------------------------------------------------------
-# Setup initial conditions
-#------------------------------------------------------------------------------
-for q in quantities:
-    domain.set_quantity(q, quantities[q]) # Distribute all quantities    
 
 
@@ -144,6 +70,4 @@
 
 # Associate boundary tags with boundary objects
-#domain.set_boundary({'left': Br, 'right': Bd, 'top': Br, 'bottom': Br,
-#                     'ghost': None, 'exterior': Bd})
 domain.set_boundary({'left': Br, 'right': Bd, 'top': Br, 'bottom': Br,
                      'ghost': None})
