Index: /anuga_work/development/Hinwood_2008/boundary.csv
===================================================================
--- /anuga_work/development/Hinwood_2008/boundary.csv	(revision 5076)
+++ /anuga_work/development/Hinwood_2008/boundary.csv	(revision 5076)
@@ -0,0 +1,32 @@
+time sec,stage m,"X velocity, m/s","Y velocity, m/s"
+0,0.2,0.23,0.01
+0.5,0.205,0.23,0.01
+1,0.21,0.23,0.01
+1.5,0.215,0.23,0.01
+2,0.22,0.23,0.01
+2.5,0.225,0.23,0.01
+3,0.23,0.23,0.01
+3.5,0.235,0.23,0.01
+4,0.24,0.23,0.01
+4.5,0.245,0.23,0.01
+5,0.25,0.23,0.01
+5.5,0.255,0.23,0.01
+6,0.26,0.23,0.01
+6.5,0.265,0.23,0.01
+7,0.27,0.23,0.01
+7.5,0.27,0.23,0.01
+8,0.265,0.23,0.01
+8.5,0.26,0.23,0.01
+9,0.255,0.23,0.01
+9.5,0.25,0.23,0.01
+10,0.245,0.23,0.01
+10.5,0.24,0.23,0.01
+11,0.235,0.23,0.01
+11.5,0.23,0.23,0.01
+12,0.225,0.23,0.01
+12.5,0.22,0.23,0.01
+13,0.215,0.23,0.01
+13.5,0.21,0.23,0.01
+14,0.205,0.23,0.01
+14.5,0.2,0.23,0.01
+15,0.195,0.23,0.01
Index: /anuga_work/development/Hinwood_2008/create_mesh.py
===================================================================
--- /anuga_work/development/Hinwood_2008/create_mesh.py	(revision 5076)
+++ /anuga_work/development/Hinwood_2008/create_mesh.py	(revision 5076)
@@ -0,0 +1,76 @@
+"""Create mesh for University of Queensland dam break flume
+"""
+
+
+from anuga.pmesh.mesh import *
+from anuga.coordinate_transforms.geo_reference import Geo_reference
+
+
+def generate(mesh_filename, maximum_triangle_area=0.01):
+    """
+    Generate mesh for University of Aberbeen dam break flume.
+    The gate position is the distance from the right wall of the wave tank
+    to the gate. 
+    
+    """
+    #Basic geometry
+    
+    xright  = 19.0
+    ybottom = 0
+    ytop    = 0.45
+    xleft = 0.0
+    xslope = 4.0 
+
+    #Outline 
+    point_sw = [xleft, ybottom]
+    point_se = [xright, ybottom]
+    point_nw = [xleft, ytop]    
+    point_ne = [xright, ytop]
+
+
+    # slope seperation (middle)
+    point_slope_top = [xslope, ytop]
+    point_slope_bottom = [xslope, ybottom]    
+
+    m = Mesh()
+
+    #Boundary
+    points = [point_sw,   #se
+              point_nw,
+              point_slope_top,
+              point_ne, 
+              point_se,
+              point_slope_bottom
+              ]
+    
+    segments = [
+        [0,1],
+        [1,2],
+        [2,3],
+        [3,4],
+        [4,5],
+        [5,0],  #The outer border
+        [2,5]       # slope separator
+        ]    
+    
+    segment_tags = {'wall':[1,2,3,4,5],
+                    'wave':[0]} # '':[6]
+        
+    m.add_points_and_segments(points, segments, segment_tags)
+    
+    dam = m.add_region(xslope - 0.0000001,(ytop - ybottom)/2)
+    # this is the location of the reservoir region.
+    dam.setTag("flat")
+    
+    slope = m.add_region(xslope + 0.0000001,(ytop - ybottom)/2)
+    # this is the location of the slope region.
+    slope.setTag("slope")
+    
+    m.generate_mesh(maximum_triangle_area=maximum_triangle_area)
+
+    m.export_mesh_file(mesh_filename)
+    print "mesh created"
+
+#-------------------------------------------------------------
+if __name__ == "__main__":
+    generate("aa.tsh")
Index: /anuga_work/development/Hinwood_2008/prepare_time_boundary.py
===================================================================
--- /anuga_work/development/Hinwood_2008/prepare_time_boundary.py	(revision 5076)
+++ /anuga_work/development/Hinwood_2008/prepare_time_boundary.py	(revision 5076)
@@ -0,0 +1,82 @@
+"""
+
+Script for running a breaking wave simulation of Jon Hinwoods wave tank.
+Note: this is based on the frinction_ua_flume_2006 structure.
+
+
+Duncan Gray, GA - 2007 
+
+
+
+"""
+
+
+#----------------------------------------------------------------------------
+# Import necessary modules
+#----------------------------------------------------------------------------
+
+from Scientific.IO.NetCDF import NetCDFFile
+from Numeric import array, zeros, Float
+
+from project import boundary_file
+
+def prepare_timeboundary(filename):
+    """Convert benchmark 2 time series to NetCDF tms file.
+    This is a 'throw-away' code taylor made for files like
+    'Benchmark_2_input.txt' from the LWRU2 benchmark
+    """
+
+
+
+    print 'Creating', filename
+
+    # Read the ascii (.csv) version of this file
+    fid = open(filename[:-4] + '.csv')
+
+    # Skip first line
+    line = fid.readline()
+
+    # Read remaining lines
+    lines = fid.readlines()
+    fid.close()
+
+
+    N = len(lines)
+    T = zeros(N, Float)  #Time
+    Q = zeros(N, Float)  #Stage
+    X = zeros(N, Float)  #XMomentum
+    Y = zeros(N, Float)  #YMomentum
+
+    for i, line in enumerate(lines):
+        fields = line.split(',')
+
+        T[i] = float(fields[0])
+        Q[i] = depth = float(fields[1])
+        X[i] = float(fields[2]) * depth
+        Y[i] = float(fields[3]) * depth
+
+
+    # Create tms NetCDF file
+
+    fid = NetCDFFile(filename, 'w')
+    fid.institution = 'Geoscience Australia'
+    fid.description = 'Input wave for Benchmark 2'
+    fid.starttime = 0.0
+    fid.createDimension('number_of_timesteps', len(T))
+    fid.createVariable('time', Float, ('number_of_timesteps',))
+    fid.variables['time'][:] = T
+
+    fid.createVariable('stage', Float, ('number_of_timesteps',))
+    fid.variables['stage'][:] = Q[:]
+
+    fid.createVariable('xmomentum', Float, ('number_of_timesteps',))
+    fid.variables['xmomentum'][:] =  X[:]
+
+    fid.createVariable('ymomentum', Float, ('number_of_timesteps',))
+    fid.variables['ymomentum'][:] =  Y[:]
+
+    fid.close()
+
+#-------------------------------------------------------------
+if __name__ == "__main__":
+    prepare_timeboundary(boundary_file)
Index: /anuga_work/development/Hinwood_2008/project.py
===================================================================
--- /anuga_work/development/Hinwood_2008/project.py	(revision 5076)
+++ /anuga_work/development/Hinwood_2008/project.py	(revision 5076)
@@ -0,0 +1,52 @@
+"""Common filenames and locations for topographic data, meshes and outputs.
+Also includes origin for slump scenario.
+"""
+
+from os import sep, environ, getenv, getcwd
+import sys
+from time import localtime, strftime
+from os import mkdir, access, F_OK
+from anuga.abstract_2d_finite_volumes.util import add_directories, \
+     copy_code_files
+
+from anuga.utilities.system_tools import get_user_name
+
+boundary_file = 'boundary.tsm'
+
+class Project:    
+    def __init__(self,
+                 trunk,
+                 outputdir_name = None,
+                 home = None):
+        
+        self.user = get_user_name()
+        if home is None:
+            home = getenv('INUNDATIONHOME') #Sandpit's parent dir   
+        self.home = home
+        # Create the structure of where the output directories will go
+        scenariodir=add_directories(home, trunk)
+
+        #Derive subdirectories and filenames
+        if outputdir_name is None:
+            #gets time for dir
+            outputdir_name = strftime('%Y%m%d_%H%M%S',localtime()) 
+        general_outputdir = scenariodir+sep+'output'+sep
+        self.outputdir = general_outputdir+outputdir_name+sep
+        self.meshdir = scenariodir+sep+'meshes'+sep
+
+        # creates copy of output dir structure, if it doesn't exist
+        if not access(self.meshdir,F_OK):
+            mkdir (self.meshdir)       
+        if not access(general_outputdir,F_OK):
+            mkdir (general_outputdir)
+        if not access(self.outputdir,F_OK):
+            mkdir (self.outputdir)
+
+        self.codedir = getcwd()+sep
+
+
+#-------------------------------------------------------------
+if __name__ == "__main__":
+    p = Project(['eagle'], 'lego','.')
+    print p.outputdir
+    print p.meshdir
Index: /anuga_work/development/Hinwood_2008/run_dam.py
===================================================================
--- /anuga_work/development/Hinwood_2008/run_dam.py	(revision 5076)
+++ /anuga_work/development/Hinwood_2008/run_dam.py	(revision 5076)
@@ -0,0 +1,180 @@
+"""
+
+Script for running a breaking wave simulation of Jon Hinwoods wave tank.
+Note: this is based on the frinction_ua_flume_2006 structure.
+
+
+Duncan Gray, GA - 2007 
+
+
+
+"""
+
+
+#----------------------------------------------------------------------------
+# Import necessary modules
+#----------------------------------------------------------------------------
+
+# Standard modules
+import time
+from time import localtime, strftime
+import sys
+from shutil import copy
+from os import path, sep
+from os.path import dirname  #, basename
+
+
+# Related major packages
+from anuga.shallow_water import Domain, Reflective_boundary, \
+                            Dirichlet_boundary,  Time_boundary, \
+                            File_boundary, \
+                            Transmissive_Momentum_Set_Stage_boundary
+from anuga.fit_interpolate.interpolate import interpolate_sww2csv
+from anuga.abstract_2d_finite_volumes.util import start_screen_catcher, \
+     copy_code_files, file_function
+from anuga.abstract_2d_finite_volumes.generic_boundary_conditions\
+     import File_boundary_time
+
+# Scenario specific imports
+import project                 # Definition of file names and polygons
+import create_mesh
+
+def elevation_function(x,y):
+    from Numeric import zeros, size, Float
+    slope = 4 ## Bit of a magic Number
+    
+    z = zeros(size(x), Float)
+    for i in range(len(x)):
+        if x[i] < slope:
+            z[i] = 0.0  #WARNING: the code in prepare_time_boundary
+                        # that calc's momentum assumes this is 0.0
+        else:
+            z[i] = (x[i]-slope)*0.1
+    return z 
+
+def main(friction=0.01, outputdir_name=None, is_trial_run=False):
+    basename = 'zz' + str(friction)
+    if is_trial_run is True:
+        outputdir_name += '_test'
+        yieldstep = 0.1
+        finaltime = 15.
+        maximum_triangle_area=0.01
+    else:
+        yieldstep = 0.02
+        finaltime = 15.1
+        maximum_triangle_area=0.0001
+        
+        maximum_triangle_area=0.001
+        
+    pro_instance = project.Project(['data','flumes','Hinwood_2008'],
+                                   outputdir_name=outputdir_name,
+                                   home='.')
+    print "The output dir is", pro_instance.outputdir
+    copy_code_files(pro_instance.outputdir,__file__,
+                    dirname(project.__file__) \
+                    + sep + project.__name__+'.py')
+    copy (pro_instance.codedir + 'run_dam.py',
+          pro_instance.outputdir + 'run_dam.py')
+    copy (pro_instance.codedir + 'create_mesh.py',
+          pro_instance.outputdir + 'create_mesh.py')
+    
+    mesh_filename = pro_instance.meshdir + basename + '.msh'
+
+    #--------------------------------------------------------------------------
+    # Copy scripts to output directory and capture screen
+    # output to file
+    #--------------------------------------------------------------------------
+
+    # creates copy of code in output dir
+    if is_trial_run is False:
+        start_screen_catcher(pro_instance.outputdir, rank, pypar.size())
+
+    print 'USER:    ', pro_instance.user
+    #-------------------------------------------------------------------------
+    # Create the triangular mesh
+    #-------------------------------------------------------------------------
+
+    # this creates the mesh
+    #gate_position = 12.0
+    create_mesh.generate(mesh_filename,
+                         maximum_triangle_area=maximum_triangle_area)
+
+    head,tail = path.split(mesh_filename)
+    copy (mesh_filename,
+          pro_instance.outputdir + tail )
+    #-------------------------------------------------------------------------
+    # Setup computational domain
+    #-------------------------------------------------------------------------
+    domain = Domain(mesh_filename, use_cache = False, verbose = True)
+   
+
+    print 'Number of triangles = ', len(domain)
+    print 'The extent is ', domain.get_extent()
+    print domain.statistics()
+
+    
+    domain.set_name(basename)
+    domain.set_datadir(pro_instance.outputdir)
+    domain.set_quantities_to_be_stored(['stage', 'xmomentum', 'ymomentum'])
+    domain.set_minimum_storable_height(0.001)
+    #domain.set_store_vertices_uniquely(True)  # for writting to sww
+
+    #-------------------------------------------------------------------------
+    # Setup initial conditions
+    #-------------------------------------------------------------------------
+
+    domain.set_quantity('stage', 0.06)
+    domain.set_quantity('friction', friction) 
+    domain.set_quantity('elevation', elevation_function)
+
+    
+    print 'Available boundary tags', domain.get_boundary_tags()
+
+    # Create boundary function from timeseries provided in file
+    #function = file_function(project.boundary_file, domain, verbose=True)
+    #Bts = Transmissive_Momentum_Set_Stage_boundary(domain, function)
+
+    function = file_function(project.boundary_file, domain, verbose=True)
+    Br = Reflective_boundary(domain)
+    #Bd = Dirichlet_boundary([0.3,0,0]) 
+    Bts = Time_boundary(domain, function)
+    domain.set_boundary( {'wall': Br, 'wave': Bts} )
+
+    #-------------------------------------------------------------------------
+    # Evolve system through time
+    #-------------------------------------------------------------------------
+    t0 = time.time()
+
+    for t in domain.evolve(yieldstep, finaltime):
+    
+        domain.write_time()
+        print 'That took %.2f seconds' %(time.time()-t0)
+        print 'finished'
+
+    points = [[2.8,0.225],  #-1.8m from SWL
+              [5.1,0.225],  #0.5m from SWL
+              [6.6,0.225],  #2m from SWL
+              [6.95,0.255], #2.35m from SWL
+              [7.6,0.255],  #3m from SWL
+              [8.2,0.255],  #3.5m from SWL
+              [9.2,0.255]  #4.5m from SWL
+              ]
+
+
+    #-------------------------------------------------------------------------
+    # Calculate gauge info
+    #-------------------------------------------------------------------------
+
+    if False:
+        interpolate_sww2csv(pro_instance.outputdir + basename +".sww",
+                            points,
+                            pro_instance.outputdir + "depth_manning_"+str(friction)+".csv",
+                            pro_instance.outputdir + "velocity_x.csv",
+                            pro_instance.outputdir + "velocity_y.csv")
+  
+    return pro_instance
+
+#-------------------------------------------------------------
+if __name__ == "__main__":
+    main( is_trial_run = True,
+         outputdir_name='Hinwood_draft')
