[5370] | 1 | """Create mesh for Jon Hinwoods wave flume |
---|
[5076] | 2 | """ |
---|
| 3 | |
---|
| 4 | |
---|
| 5 | from anuga.pmesh.mesh import * |
---|
| 6 | from anuga.coordinate_transforms.geo_reference import Geo_reference |
---|
| 7 | |
---|
[5577] | 8 | def generate(mesh_filename, slope, width, |
---|
| 9 | maximum_triangle_area=0.01): |
---|
[5076] | 10 | """ |
---|
[5370] | 11 | Generate mesh for Monash University wave generation flume. |
---|
[5076] | 12 | |
---|
[5370] | 13 | Origin of x coordinate is the toe of the beach, x measured |
---|
| 14 | positive shorewards. |
---|
| 15 | |
---|
[5076] | 16 | """ |
---|
| 17 | |
---|
[5370] | 18 | xleft = slope['xleft'][0] |
---|
| 19 | xtoe = slope['xtoe'][0] |
---|
| 20 | xbeach = slope['xbeach'][0] |
---|
| 21 | xright = slope['xright'][0] |
---|
[5577] | 22 | ytop = width/2.0 |
---|
| 23 | ybottom = -ytop |
---|
[5076] | 24 | |
---|
| 25 | #Outline |
---|
| 26 | point_sw = [xleft, ybottom] |
---|
| 27 | point_se = [xright, ybottom] |
---|
| 28 | point_nw = [xleft, ytop] |
---|
| 29 | point_ne = [xright, ytop] |
---|
| 30 | |
---|
| 31 | |
---|
[5370] | 32 | # 1st slope seperation (middle) |
---|
| 33 | point_toe_top = [xtoe, ytop] |
---|
| 34 | point_toe_bottom = [xtoe, ybottom] |
---|
[5076] | 35 | |
---|
[5370] | 36 | # 2nd slope seperation (middle) |
---|
| 37 | point_beach_top = [xbeach, ytop] |
---|
| 38 | point_beach_bottom = [xbeach, ybottom] |
---|
| 39 | |
---|
[5076] | 40 | m = Mesh() |
---|
| 41 | |
---|
| 42 | #Boundary |
---|
| 43 | points = [point_sw, #se |
---|
| 44 | point_nw, |
---|
[5370] | 45 | point_toe_top, # 2 |
---|
| 46 | point_beach_top, # 3 |
---|
[5076] | 47 | point_ne, |
---|
| 48 | point_se, |
---|
[5370] | 49 | point_beach_bottom, # 6 |
---|
| 50 | point_toe_bottom # 7 |
---|
[5076] | 51 | ] |
---|
| 52 | |
---|
| 53 | segments = [ |
---|
| 54 | [0,1], |
---|
| 55 | [1,2], |
---|
| 56 | [2,3], |
---|
| 57 | [3,4], |
---|
| 58 | [4,5], |
---|
[5370] | 59 | [5,6], |
---|
| 60 | [6,7], |
---|
| 61 | [7,0], #The outer border |
---|
| 62 | [2,7], # toe separator |
---|
| 63 | [3,6] # _beach separator |
---|
[5076] | 64 | ] |
---|
| 65 | |
---|
[5370] | 66 | segment_tags = {'wall':[1,2,3,4,5,6,7], |
---|
[5076] | 67 | 'wave':[0]} # '':[6] |
---|
| 68 | |
---|
| 69 | m.add_points_and_segments(points, segments, segment_tags) |
---|
| 70 | |
---|
| 71 | m.generate_mesh(maximum_triangle_area=maximum_triangle_area) |
---|
| 72 | |
---|
| 73 | m.export_mesh_file(mesh_filename) |
---|
| 74 | print "mesh created" |
---|
| 75 | |
---|
| 76 | #------------------------------------------------------------- |
---|
| 77 | if __name__ == "__main__": |
---|
| 78 | generate("aa.tsh") |
---|