Index: inundation/ga/storm_surge/examples/beach.poly
===================================================================
--- inundation/ga/storm_surge/examples/beach.poly	(revision 653)
+++ inundation/ga/storm_surge/examples/beach.poly	(revision 653)
@@ -0,0 +1,4 @@
+25, 25
+25, 75
+75, 25
+75, 75
Index: inundation/ga/storm_surge/examples/beach.py
===================================================================
--- inundation/ga/storm_surge/examples/beach.py	(revision 653)
+++ inundation/ga/storm_surge/examples/beach.py	(revision 653)
@@ -0,0 +1,119 @@
+"""Example of the inundationmodel.
+
+A wave of water is washed up ontp a hypothetical beach.
+
+To run:
+
+python beach.py
+"""
+
+######################
+# Module imports 
+#
+
+import sys
+from os import sep, path
+sys.path.append('..'+sep+'pyvolution')
+
+from shallow_water import Domain, Reflective_boundary, Dirichlet_boundary,\
+     Transmissive_boundary, Time_boundary, Constant_height, Weir
+
+from pmesh2domain import pmesh_to_domain_instance
+from config import data_dir
+
+######################
+# Domain
+name = 'beach'
+print 'Creating domain from %s.tsh' %name
+domain = pmesh_to_domain_instance(name + '.tsh', Domain)
+
+#HACK to remove internal boundary (until we get a solution)
+for b in domain.boundary.keys():
+    if domain.boundary[b] == 'internal':
+        del domain.boundary[b]
+
+domain = Domain(domain.coordinates, domain.triangles, domain.boundary)
+print "Number of triangles = ", len(domain)
+
+domain.store = True
+domain.set_name(name)
+print "Output being written to " + data_dir + sep + \
+      domain.filename + "." + domain.format
+
+
+def x_slope(x, y):
+    from Numeric import choose, greater, ones
+    cut = 65
+    
+    return choose( greater(x, cut), (-x/3, -cut/3*ones(x.shape) )) + cut/3 - 5
+
+
+def inside(p,polygon):
+    return True
+
+def friction(x, y):
+    """Read friction from polygon file and set accordingly
+    """
+
+    from Numeric import array
+    x = array(x).astype('f')
+    y = array(y).astype('f')    
+    
+    #Get polygon
+    fid = open('beach.poly')
+    lines = fid.readlines()
+    fid.close()
+    polygon = []
+    for line in lines:
+        fields = line.split(',')
+        polygon.append( [float(fields[0]), float(fields[1])] )
+
+    print polygon
+
+    z = 0*x
+    for i in range(len(x)):
+        if inside( (x[i], y[i]), polygon):
+            z[i] = 1
+        else:
+            z[i] = 0
+
+friction([0],[1])    
+
+domain.set_quantity('elevation', x_slope)
+domain.set_quantity('level', x_slope)
+domain.set_quantity('friction', 0.07)
+
+print domain.get_extent()
+import sys; sys.exit()
+
+######################
+# Boundary conditions
+
+print 'Boundaries'
+Br = Reflective_boundary(domain)
+Bt = Transmissive_boundary(domain)
+
+#Constant inflow
+Bd = Dirichlet_boundary([0.0, -1.0, 0.0])
+
+print 'Available boundary tags are', domain.get_boundary_tags()
+
+#Set boundary conditions
+tags = {}
+tags['ocean'] = Bd
+tags['wall'] = Br 
+tags['exterior'] = Br
+tags['external'] = Br 
+domain.set_boundary(tags)
+
+
+domain.check_integrity()
+
+######################
+#Evolution
+for t in domain.evolve(yieldstep = 0.5, finaltime = 100):
+    domain.write_time()
+    
+print 'Done'
+
+    
Index: inundation/ga/storm_surge/examples/beach.tsh
===================================================================
--- inundation/ga/storm_surge/examples/beach.tsh	(revision 653)
+++ inundation/ga/storm_surge/examples/beach.tsh	(revision 653)
@@ -0,0 +1,282 @@
+68 0 # <vertex #> <x> <y> [attributes] ...Triangulation Vertices...
+0 0.0 0.0 
+1 0.0 100.0 
+2 100.0 0.0 
+3 100.0 100.0 
+4 49.5837790759 87.6140562311 
+5 54.1570402528 86.8919623611 
+6 53.4349463827 83.0407950542 
+7 49.1023831625 83.7628889243 
+8 40.4372567221 78.708231834 
+9 44.7698199423 79.9117216174 
+10 45.4919138123 76.0605543105 
+11 41.4000485488 75.0977624838 
+12 49.1023831625 70.2838033503 
+13 53.6756443394 70.7651992636 
+14 58.489603473 71.246595177 
+15 58.7303014297 68.1175217401 
+16 58.7303014297 64.7477503466 
+17 49.1023831625 68.1175217401 
+18 53.6756443394 68.1175217401 
+19 54.1570402528 64.9884483033 
+20 64.50705239 99.6489540651 
+21 64.2663544333 50.5465709026 
+22 26.7174731914 49.8244770325 
+23 13.9604814874 0.240697956679 
+24 0.0 50.0 
+25 64.3501915295 67.6493385257 
+26 32.253526195 99.8244770325 
+27 0.0 75.0 
+28 64.4286219597 83.6491462954 
+29 43.0698906233 69.2006625452 
+30 30.1236572974 74.0243317355 
+31 42.7145154319 50.1321124602 
+32 100.0 50.0 
+33 48.3802892925 99.7367155488 
+34 53.4904349326 50.3393416814 
+35 56.9802407437 0.12034897834 
+36 48.5922352319 24.7682044878 
+37 40.1459919678 88.1571436376 
+38 0.0 32.0 
+39 20.3389773394 25.0325874946 
+40 100.0 75.0 
+41 56.0591484015 57.5621729709 
+42 35.6720986273 75.5039160901 
+43 30.2956575289 84.5224505385 
+44 44.4662196401 59.6370529989 
+45 52.9466145842 94.0689737886 
+46 34.93071799 67.1409738091 
+47 0.0 16.0 
+48 16.1267630975 99.9122385163 
+49 21.5199993472 62.8956745908 
+50 15.2239911023 79.5189149421 
+51 13.3730257409 52.0872806711 
+52 23.5282252654 37.4285322635 
+53 0.0 62.5 
+54 11.9768441592 33.7922498237 
+55 9.17787305696 22.7491475656 
+56 17.1497294134 12.6366427256 
+57 29.9604188785 0.195937684846 
+58 34.4748458809 56.7511681538 
+59 0.0 87.5 
+60 0.0 41.0 
+61 7.43904432762 8.5267831543 
+62 8.02960798669 93.75 
+63 24.1532277537 93.0846303982 
+64 20.9871115538 72.1977631481 
+65 10.6819813774 66.9411061894 
+66 15.5134979147 42.7231408884 
+67 15.9006728326 88.7950714859 
+# attribute column titles ...Triangulation Vertex Titles...
+104 # <triangle #> [<vertex #>] [<neigbouring triangle #>] [attribute of region] ...Triangulation Triangles...
+0 38 47 55 83 70 -1  run
+1 46 30 49 61 68 60  run
+2 44 17 29 5 20 56  run
+3 56 39 55 82 81 53  run
+4 12 10 29 7 5 6  run
+5 12 29 17 2 -1 4  run
+6 12 13 10 33 4 -1  run
+7 29 10 11 -1 63 4  run
+8 21 36 2 47 42 28  course
+9 11 8 42 38 12 -1  run
+10 8 9 37 13 59 -1  run
+11 22 58 49 68 75 85  run
+12 42 46 11 63 9 60  run
+13 9 7 37 14 10 17  run
+14 4 37 7 13 -1 51  run
+15 6 7 10 17 33 -1  run
+16 28 5 6 -1 32 37  run
+17 7 9 10 -1 15 13  run
+18 33 26 37 52 51 -1  run
+19 27 50 59 93 -1 97  run
+20 44 29 46 63 87 2  run
+21 44 41 19 24 56 44  run
+22 40 28 25 39 57 29  course
+23 19 18 17 -1 56 -1  run
+24 19 41 16 30 -1 21  run
+25 32 25 21 27 42 57  course
+26 20 28 3 29 -1 37  course
+27 25 16 21 30 25 36  run
+28 36 21 34 58 49 8  course
+29 40 3 28 26 22 -1  course
+30 21 16 41 24 58 27  run
+31 31 44 58 87 85 64  run
+32 6 14 28 39 16 34  run
+33 6 10 13 6 34 15  run
+34 14 6 13 33 -1 32  run
+35 15 25 14 39 -1 36  run
+36 15 16 25 27 35 -1  run
+37 20 5 28 16 26 65  run
+38 43 42 8 9 59 43  run
+39 28 14 25 35 22 32  run
+40 53 51 65 72 78 79  run
+41 33 4 45 46 66 51  run
+42 21 2 32 -1 25 8  course
+43 42 43 30 96 60 38  run
+44 34 41 44 21 64 58  run
+45 36 31 52 48 77 49  course
+46 45 4 5 -1 65 41  run
+47 36 35 2 -1 8 84  course
+48 52 31 22 85 100 45  course
+49 36 34 31 64 45 28  course
+50 39 57 36 84 77 53  course
+51 33 37 4 14 41 18  run
+52 37 26 43 71 59 18  run
+53 57 39 56 3 86 50  course
+54 66 22 51 75 101 100  run
+55 61 0 23 -1 91 88  run
+56 19 17 44 2 21 23  run
+57 25 32 40 -1 22 25  course
+58 21 41 34 44 28 30  run
+59 43 8 37 10 52 38  run
+60 42 30 46 1 12 43  run
+61 64 49 30 1 96 98  run
+62 62 48 1 -1 92 95  run
+63 46 29 11 7 12 20  run
+64 44 31 34 49 44 31  run
+65 5 20 45 66 46 37  run
+66 20 33 45 41 65 -1  run
+67 64 43 50 102 99 96  run
+68 58 46 49 1 11 87  run
+69 43 63 67 103 102 71  run
+70 38 55 54 82 74 0  run
+71 43 26 63 94 69 52  run
+72 65 51 49 75 98 40  run
+73 39 52 54 80 82 77  run
+74 54 60 38 -1 70 90  run
+75 22 49 51 72 54 11  run
+76 60 66 24 101 -1 90  run
+77 39 36 52 45 73 50  course
+78 27 53 65 40 97 -1  run
+79 24 51 53 40 -1 101  run
+80 66 54 52 73 100 90  run
+81 55 61 56 91 3 83  run
+82 39 54 55 70 3 73  run
+83 61 55 47 0 88 81  run
+84 36 57 35 -1 47 50  course
+85 31 58 22 11 48 31  run
+86 56 23 57 -1 53 91  course
+87 44 46 58 68 31 20  run
+88 0 61 47 83 -1 55  run
+89 67 62 59 92 93 95  run
+90 60 54 66 80 76 74  run
+91 23 56 61 81 55 86  run
+92 1 59 62 89 62 -1  run
+93 67 59 50 19 102 89  run
+94 26 48 63 103 71 -1  run
+95 48 62 67 89 103 62  run
+96 43 64 30 61 43 67  run
+97 50 27 65 78 99 19  run
+98 49 64 65 99 72 61  run
+99 65 64 50 67 97 98  run
+100 22 66 52 80 48 54  run
+101 66 51 24 79 76 54  run
+102 43 67 50 93 67 69  run
+103 48 67 63 69 94 95  run
+46 # <segment #> <vertex #>  <vertex #> [boundary marker] ...Triangulation Segments...
+0 3 40 ocean
+1 0 47 exterior
+2 9 8 wall
+3 10 9 wall
+4 10 11 wall
+5 11 8 wall
+6 5 4 wall
+7 5 6 wall
+8 6 7 wall
+9 7 4 wall
+10 12 13 wall
+11 13 14 wall
+12 14 15 wall
+13 16 15 wall
+14 19 16 wall
+15 18 19 wall
+16 17 18 wall
+17 17 12 wall
+18 52 22 internal
+19 21 34 internal
+20 20 28 internal
+21 2 35 external
+22 23 0 external
+23 1 48 external
+24 3 20 external
+25 24 53 exterior
+26 25 21 internal
+27 26 33 external
+28 28 25 internal
+29 31 22 internal
+30 32 2 ocean
+31 33 20 external
+32 34 31 internal
+33 35 57 external
+34 38 60 exterior
+35 39 56 internal
+36 40 32 ocean
+37 47 38 exterior
+38 48 26 external
+39 27 59 exterior
+40 52 39 internal
+41 53 27 exterior
+42 56 23 internal
+43 57 23 external
+44 59 1 exterior
+45 60 24 exterior
+24 0 # <vertex #> <x> <y> [attributes] ...Mesh Vertices...
+0 0.0 0.0 
+1 0.0 100.0 
+2 100.0 0.0 
+3 100.0 100.0 
+4 49.5837790759 87.6140562311 
+5 54.1570402528 86.8919623611 
+6 53.4349463827 83.0407950542 
+7 49.1023831625 83.7628889243 
+8 40.4372567221 78.708231834 
+9 44.7698199423 79.9117216174 
+10 45.4919138123 76.0605543105 
+11 41.4000485488 75.0977624838 
+12 49.1023831625 70.2838033503 
+13 53.6756443394 70.7651992636 
+14 58.489603473 71.246595177 
+15 58.7303014297 68.1175217401 
+16 58.7303014297 64.7477503466 
+17 49.1023831625 68.1175217401 
+18 53.6756443394 68.1175217401 
+19 54.1570402528 64.9884483033 
+20 64.50705239 99.6489540651 
+21 64.2663544333 50.5465709026 
+22 26.7174731914 49.8244770325 
+23 13.9604814874 0.240697956679 
+25 # <segment #> <vertex #>  <vertex #> [boundary marker] ...Mesh Segments...
+0 2 3 ocean
+1 0 1 exterior
+2 9 8 wall
+3 10 9 wall
+4 11 10 wall
+5 8 11 wall
+6 5 4 wall
+7 6 5 wall
+8 7 6 wall
+9 4 7 wall
+10 13 12 wall
+11 14 13 wall
+12 15 14 wall
+13 16 15 wall
+14 19 16 wall
+15 18 19 wall
+16 17 18 wall
+17 12 17 wall
+18 22 23 
+19 21 22 
+20 20 21 
+21 23 2 
+22 0 23 
+23 20 1 
+24 3 20 
+3 # <Hole #> <x> <y> ...Mesh Holes...
+0 56.0826239062 68.1175217401
+1 43.0849342455 77.7454400073
+2 51.5093627293 85.6884725777
+2 # <Region #> <x> <y> <tag>...Mesh Regions...
+0 75.5791583972 39.715162852 course
+1 14.4418774007 78.708231834 run
+0 1000.0
+1 100.0
