source: anuga_work/development/Hinwood_2008/create_mesh.py @ 7818

Last change on this file since 7818 was 5710, checked in by duncan, 16 years ago

comments

File size: 1.9 KB
Line 
1"""Create mesh for Jon Hinwoods wave flume
2"""
3
4
5from anuga.pmesh.mesh import *
6from anuga.coordinate_transforms.geo_reference import Geo_reference
7
8def generate(mesh_filename, slope, width,
9             maximum_triangle_area=0.01):
10    """
11    Generate mesh for Monash University wave generation flume.
12   
13    Origin of x coordinate is the toe of the beach, x measured
14    positive shorewards.
15   
16    """
17   
18    xleft = slope['xleft'][0]
19    xtoe = slope['xtoe'][0]
20    xbeach = slope['xbeach'][0]
21    xright = slope['xright'][0]
22    ytop    = width/2.0
23    ybottom = -ytop
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
32    # 1st slope seperation (middle)
33    point_toe_top = [xtoe, ytop]
34    point_toe_bottom = [xtoe, ybottom]   
35
36    # 2nd slope seperation (middle)
37    point_beach_top = [xbeach, ytop]
38    point_beach_bottom = [xbeach, ybottom]
39   
40    m = Mesh()
41
42    #Boundary
43    points = [point_sw,   #se
44              point_nw,
45              point_toe_top, # 2
46              point_beach_top, # 3
47              point_ne, 
48              point_se,
49              point_beach_bottom, # 6
50              point_toe_bottom # 7
51              ]
52   
53    segments = [
54        [0,1],
55        [1,2],
56        [2,3],
57        [3,4],
58        [4,5],
59        [5,6],
60        [6,7],
61        [7,0],  #The outer border
62        [2,7],       # toe separator
63        [3,6]       # _beach separator
64        ]   
65   
66    segment_tags = {'wall':[1,2,3,4,5,6,7],
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#-------------------------------------------------------------
77if __name__ == "__main__":
78    generate("aa.tsh")
Note: See TracBrowser for help on using the repository browser.