Index: inundation/parallel/run_advection.py
===================================================================
--- inundation/parallel/run_advection.py	(revision 2132)
+++ inundation/parallel/run_advection.py	(revision 2152)
@@ -15,5 +15,6 @@
 from mesh_factory import rectangular
 
-points, vertices, boundary = rectangular(60, 60)
+#points, vertices, boundary = rectangular(60, 60)
+points, vertices, boundary = rectangular(10, 10)
 
 #Create advection domain with direction (1,-1)
Index: inundation/parallel/run_parallel_merimbula.py
===================================================================
--- inundation/parallel/run_parallel_merimbula.py	(revision 2132)
+++ inundation/parallel/run_parallel_merimbula.py	(revision 2152)
@@ -7,10 +7,4 @@
 # file.
 #
-#  *) The test files currently avaliable are of the form
-# test*.out, eg test_5l_4c.out. The term infront of the l
-# corresponds to the number of levels of refinement
-# required to build the grid, i.e. a higher number
-# corresponds to a finer grid. The term infront of the c
-# corresponds to the number of processors.
 #
 # *) The (new) files that have been added to manage the
Index: inundation/parallel/run_parallel_sw_merimbula.py
===================================================================
--- inundation/parallel/run_parallel_sw_merimbula.py	(revision 2132)
+++ inundation/parallel/run_parallel_sw_merimbula.py	(revision 2152)
@@ -7,10 +7,4 @@
 # file.
 #
-#  *) The test files currently avaliable are of the form
-# test*.out, eg test_5l_4c.out. The term infront of the l
-# corresponds to the number of levels of refinement
-# required to build the grid, i.e. a higher number
-# corresponds to a finer grid. The term infront of the c
-# corresponds to the number of processors.
 #
 # *) The (new) files that have been added to manage the
@@ -40,29 +34,37 @@
 #
 #########################################################
+
 import sys
 import pypar    # The Python-MPI interface
 import time
 
-
 from os import sep
 sys.path.append('..'+sep+'pyvolution')
 
-from Numeric import array
+# Numeric arrays
+
+from Numeric import array, zeros, Float
+
 # pmesh
-
-#from shallow_water import Domain
 
 from shallow_water import Domain
 from parallel_shallow_water import Parallel_Domain
-
-# mesh partition routines
+from pmesh2domain import pmesh_to_domain_instance
+
+# Reuse previous mesh import
+
+from caching import cache
+
+# Mesh partition routines
 
 from pmesh_divide import pmesh_divide, pmesh_divide_steve
-from build_submesh import *
-from build_local import *
-from build_commun import *
-from pmesh2domain import pmesh_to_domain_instance
-
-# read in the processor information
+from build_submesh import build_submesh, extract_hostmesh
+from build_local   import build_local_mesh
+from build_commun  import send_submesh, rec_submesh
+
+
+###############################
+# Read in processor information
+###############################
 
 numprocs = pypar.size()
@@ -70,6 +72,8 @@
 processor_name = pypar.Get_processor_name()
 
-#-------
-# Domain
+############################
+# Set the initial conditions
+############################
+
 rect = zeros( 4, Float) # Buffer for results
 
@@ -86,8 +90,11 @@
         return self.h*((x>self.x0)&(x<self.x1))
 
+#######################
+# Partition the domain
+#######################
 
 if myid == 0:
 
-    # read in the test files
+    # Read in the test files
 
 #    filename = 'test-100.tsh'
@@ -98,35 +105,52 @@
         print "WARNING: number of subboxes is not equal to the number of proc"
 
-    domain_full = pmesh_to_domain_instance(filename, Domain)
-
+    # Build the whole domain
+    
+#    domain_full = pmesh_to_domain_instance(filename, Domain)
+
+    domain_full = cache(pmesh_to_domain_instance,
+               (filename, Domain),
+              dependencies = [filename])
+
+    rect = array(domain_full.xy_extent, Float)
+    
+    # Initialise the wave
+    
 #    domain_full.set_quantity('stage', Set_Stage(200.0,300.0,1.0))
     domain_full.set_quantity('stage', Set_Stage(756000.0,756500.0,2.0))
 
+    # Subdivide the domain
+    
     nodes, triangles, boundary, triangles_per_proc, quantities = \
          pmesh_divide_steve(domain_full, nx, ny)
 
-    rect = array(domain_full.xy_extent, Float)
-
     submesh = build_submesh(nodes, triangles, boundary,\
                             quantities, triangles_per_proc)
     
-    # send the mesh partition to the appropriate processor
+    # Send the mesh partition to the appropriate processor
 
     for p in range(1, numprocs):
       send_submesh(submesh, triangles_per_proc, p)
 
+    # Build the local mesh for processor 0
+
     hostmesh = extract_hostmesh(submesh)
-    
-    points, vertices, boundary, quantities, ghost_recv_dict, full_send_dict = \
-             build_local_mesh(hostmesh, 0, triangles_per_proc[0], numprocs)
-
-# read in the mesh partition that belongs to this
+    points, vertices, boundary, quantities, ghost_recv_dict, \
+            full_send_dict = build_local_mesh(hostmesh, 0, \
+                                              triangles_per_proc[0], \
+                                              numprocs)
+
+# Read in the mesh partition that belongs to this
 # processor (note that the information is in the
 # correct form for the GA data structure
 
 else:
-    points, vertices, boundary, quantities, ghost_recv_dict, full_send_dict \
-            = rec_submesh(0)
-
+    points, vertices, boundary, quantities, ghost_recv_dict, \
+            full_send_dict = rec_submesh(0)
+
+
+###########################################
+# Start the computations on each subpartion
+###########################################
 
 ##    ########### start profile testing
@@ -149,12 +173,13 @@
 ######## end profile testing
     
-    
+
+# The visualiser needs to know the size of the whole domain
+
 pypar.broadcast(rect,0)
-#print rect
+
 
 domain = Parallel_Domain(points, vertices, boundary,
                          full_send_dict  = full_send_dict,
                          ghost_recv_dict = ghost_recv_dict)
-
 
 try:
Index: inundation/parallel/run_parallel_sw_merimbula_metis.py
===================================================================
--- inundation/parallel/run_parallel_sw_merimbula_metis.py	(revision 2132)
+++ inundation/parallel/run_parallel_sw_merimbula_metis.py	(revision 2152)
@@ -10,10 +10,4 @@
 # file.
 #
-#  *) The test files currently avaliable are of the form
-# test*.out, eg test_5l_4c.out. The term infront of the l
-# corresponds to the number of levels of refinement
-# required to build the grid, i.e. a higher number
-# corresponds to a finer grid. The term infront of the c
-# corresponds to the number of processors.
 #
 # *) The (new) files that have been added to manage the
@@ -51,21 +45,28 @@
 sys.path.append('..'+sep+'pyvolution')
 
-from Numeric import array
+# Numeric arrays
+
+from Numeric import array, zeros, Float
+
 # pmesh
-
-#from shallow_water import Domain
 
 from shallow_water import Domain
 from parallel_shallow_water import Parallel_Domain
-
-# mesh partition routines
+from pmesh2domain import pmesh_to_domain_instance
+
+# Reuse previous mesh import
+
+from caching import cache
+
+# Mesh partition routines
 
 from pmesh_divide import pmesh_divide_metis
-from build_submesh import *
-from build_local import *
-from build_commun import *
-from pmesh2domain import pmesh_to_domain_instance
-
-# read in the processor information
+from build_submesh import build_submesh, extract_hostmesh
+from build_local   import build_local_mesh
+from build_commun  import send_submesh, rec_submesh
+
+###############################
+# Read in processor information
+###############################
 
 numprocs = pypar.size()
@@ -73,6 +74,8 @@
 processor_name = pypar.Get_processor_name()
 
-#-------
-# Domain
+############################
+# Set the initial conditions
+############################
+
 rect = zeros( 4, Float) # Buffer for results
 
@@ -89,16 +92,31 @@
         return self.h*((x>self.x0)&(x<self.x1))
 
+#######################
+# Partition the domain
+#######################
 
 if myid == 0:
 
-    # read in the test files
+    # Read in the test files
 
 #    filename = 'test-100.tsh'
     filename = 'merimbula_10785_1.tsh'
 
-    domain_full = pmesh_to_domain_instance(filename, Domain)
+    # Build the whole domain
+    
+#    domain_full = pmesh_to_domain_instance(filename, Domain)
+
+    domain_full = cache(pmesh_to_domain_instance,
+               (filename, Domain),
+              dependencies = [filename])
+
+    rect = array(domain_full.xy_extent, Float)
+
+    # Initialise the wave
 
 #    domain_full.set_quantity('stage', Set_Stage(200.0,300.0,1.0))
     domain_full.set_quantity('stage', Set_Stage(756000.0,756500.0,2.0))
+
+    # Subdivide the domain
 
     # Note the different arguments compared with pmesh_divide,
@@ -113,8 +131,10 @@
                             quantities, triangles_per_proc)
 
-    # send the mesh partition to the appropriate processor
+    # Send the mesh partition to the appropriate processor
 
     for p in range(1, numprocs):
       send_submesh(submesh, triangles_per_proc, p)
+
+    # Build the local mesh for processor 0
 
     hostmesh = extract_hostmesh(submesh)
@@ -122,5 +142,5 @@
              build_local_mesh(hostmesh, 0, triangles_per_proc[0], numprocs)
 
-# read in the mesh partition that belongs to this
+# Read in the mesh partition that belongs to this
 # processor (note that the information is in the
 # correct form for the GA data structure
@@ -129,4 +149,9 @@
     points, vertices, boundary, quantities, ghost_recv_dict, full_send_dict \
             = rec_submesh(0)
+
+
+###########################################
+# Start the computations on each subpartion
+###########################################
 
 #if myid == 0:
@@ -138,7 +163,7 @@
 #    print full_send_dict
 
+# The visualiser needs to know the size of the whole domain
 
 pypar.broadcast(rect,0)
-#print rect
 
 domain = Parallel_Domain(points, vertices, boundary,
Index: inundation/parallel/run_parallel_sw_rectangle.py
===================================================================
--- inundation/parallel/run_parallel_sw_rectangle.py	(revision 2132)
+++ inundation/parallel/run_parallel_sw_rectangle.py	(revision 2152)
@@ -1,3 +1,3 @@
-#!/usr/bin/env/python
+#!/usr/bin/env python
 #########################################################
 #
@@ -7,31 +7,5 @@
 # file.
 #
-#  *) The test files currently avaliable are of the form
-# test*.out, eg test_5l_4c.out. The term infront of the l
-# corresponds to the number of levels of refinement
-# required to build the grid, i.e. a higher number
-# corresponds to a finer grid. The term infront of the c
-# corresponds to the number of processors.
 #
-# *) The (new) files that have been added to manage the
-# grid partitioning are
-#    +) pmesh_divide.py: subdivide a pmesh
-#    +) build_submesh.py: build the submeshes on the host
-# processor.
-#    +) build_local.py: build the GA mesh datastructure
-# on each processor.
-#    +) build_commun.py: handle the communication between
-# the host and processors
-#
-# *) Things still to do:
-#    +) Overlap the communication and computation: The
-# communication routines in build_commun.py should be
-# interdispersed in the build_submesh.py and build_local.py
-# files. This will overlap the communication and
-# computation and will be far more efficient. This should
-# be done after more testing and there more confidence in
-# the subpartioning.
-#    +) Much more testing especially with large numbers of
-# processors.
 #  Authors: Linda Stals, Steve Roberts and Matthew Hardy,
 # June 2005
@@ -62,8 +36,4 @@
 
 from pmesh_divide import pmesh_divide, pmesh_divide_steve
-from build_submesh import *
-from build_local import *
-from build_commun import *
-from pmesh2domain import pmesh_to_domain_instance
 
 # read in the processor information
@@ -72,8 +42,4 @@
 myid = pypar.rank()
 processor_name = pypar.Get_processor_name()
-
-
-
-
 
 M = 20
