[4928] | 1 | """Create mesh for lwru2 validation of the Oshiri island tsunami |
---|
| 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, gate_position, is_course = False): |
---|
| 10 | #Basic geometry |
---|
| 11 | |
---|
| 12 | xright = gate_position |
---|
| 13 | ybottom = 0 |
---|
| 14 | ytop = 0.4 |
---|
| 15 | xdam = 0.0 |
---|
| 16 | xleft = gate_position - 3.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 | # Dam seperation (left) |
---|
| 25 | point_dam_top = [xdam, ytop] |
---|
| 26 | point_dam_bottom = [xdam, ybottom] |
---|
| 27 | |
---|
| 28 | m = Mesh() |
---|
| 29 | |
---|
| 30 | #Boundary |
---|
| 31 | points = [point_sw, #se |
---|
| 32 | point_nw, |
---|
| 33 | point_dam_top, |
---|
| 34 | point_ne, |
---|
| 35 | point_se, |
---|
| 36 | point_dam_bottom |
---|
| 37 | ] |
---|
| 38 | |
---|
| 39 | segments = [[0,1], [1,2], [2,3], |
---|
| 40 | [3,4 ],[4,5], [5,0], #The outer border |
---|
| 41 | [2,5]] #dam Separator |
---|
| 42 | |
---|
| 43 | segment_tags = {'wall':[0,1,2,4,5],'edge':[3]} # '':[6] |
---|
| 44 | |
---|
| 45 | m.add_points_and_segments(points, segments, segment_tags) |
---|
| 46 | |
---|
| 47 | dam = m.add_region(-0.0000001,(ytop - ybottom)/2) |
---|
| 48 | # this is the location of the region. |
---|
| 49 | dam.setTag("dam") |
---|
| 50 | |
---|
| 51 | if is_course: |
---|
| 52 | m.generate_mesh(maximum_triangle_area=0.01) |
---|
| 53 | else: |
---|
| 54 | m.generate_mesh(maximum_triangle_area=0.001) |
---|
| 55 | |
---|
| 56 | m.export_mesh_file(mesh_filename) |
---|
| 57 | print "mesh created" |
---|
| 58 | |
---|
| 59 | #------------------------------------------------------------- |
---|
| 60 | if __name__ == "__main__": |
---|
| 61 | generate("aa.tsh", 0.75, 3.0, is_course = True) |
---|