[8584] | 1 | """Create mesh for UQ wave flume |
---|
| 2 | """ |
---|
| 3 | |
---|
| 4 | |
---|
| 5 | from anuga.pmesh.mesh import * |
---|
| 6 | from anuga.coordinate_transforms.geo_reference import Geo_reference |
---|
| 7 | |
---|
| 8 | |
---|
| 9 | def generate(mesh_filename, flume_length, is_course = False): |
---|
| 10 | #Basic geometry |
---|
| 11 | |
---|
| 12 | xright = flume_length |
---|
| 13 | ybottom = 0 |
---|
| 14 | ytop = 0.85 |
---|
| 15 | xleft = -2.09 |
---|
| 16 | xtoe = 0 |
---|
| 17 | |
---|
| 18 | #Outline |
---|
| 19 | point_sw = [xleft, ybottom] |
---|
| 20 | point_se = [xright, ybottom] |
---|
| 21 | point_nw = [xleft, ytop] |
---|
| 22 | point_ne = [xright, ytop] |
---|
| 23 | |
---|
| 24 | #beach seperation (left) |
---|
| 25 | point_toe_top = [xtoe, ytop] |
---|
| 26 | point_toe_bottom = [xtoe, ybottom] |
---|
| 27 | |
---|
| 28 | |
---|
| 29 | m = Mesh() |
---|
| 30 | |
---|
| 31 | #Boundary |
---|
| 32 | points = [point_sw, #se |
---|
| 33 | point_nw, |
---|
| 34 | point_toe_top, |
---|
| 35 | point_ne, |
---|
| 36 | point_se, |
---|
| 37 | point_toe_bottom |
---|
| 38 | ] |
---|
| 39 | |
---|
| 40 | segments = [[0,1], [1,2], [2,3], [3,4], [4,5], [5,0], #The outer border |
---|
| 41 | [2,5]] #beach separation |
---|
| 42 | |
---|
| 43 | segment_tags = {'back':[0], 'wall':[1,2,3,4,5]} # '':[6] |
---|
| 44 | |
---|
| 45 | m.add_points_and_segments(points, segments, segment_tags) |
---|
| 46 | |
---|
| 47 | beach = m.add_region(+0.0000001, ytop/2) |
---|
| 48 | # this is the location of the region. |
---|
| 49 | beach.setTag("beach") |
---|
| 50 | |
---|
| 51 | if is_course: |
---|
| 52 | m.generate_mesh(maximum_triangle_area=0.01) |
---|
| 53 | else: |
---|
| 54 | m.generate_mesh(maximum_triangle_area=0.002) |
---|
| 55 | |
---|
| 56 | m.export_mesh_file(mesh_filename) |
---|
| 57 | print "mesh created" |
---|
| 58 | |
---|
| 59 | #------------------------------------------------------------- |
---|
| 60 | if __name__ == "__main__": |
---|
| 61 | generate("aa.tsh", 0.75, is_course = True) |
---|