1 | """Create mesh for University of Queensland dam break flume |
---|
2 | """ |
---|
3 | |
---|
4 | from math import cos, radians |
---|
5 | from anuga.pmesh.mesh import * |
---|
6 | from anuga.coordinate_transforms.geo_reference import Geo_reference |
---|
7 | |
---|
8 | |
---|
9 | #Basic geometry |
---|
10 | xslope = 2.5 |
---|
11 | |
---|
12 | def generate(mesh_filename, beach_angle, toe_to_nails_distance, |
---|
13 | is_coarse = True): |
---|
14 | """ |
---|
15 | Generate mesh for Saman's flume flume. |
---|
16 | The gate position is the distance from the right wall of the wave tank |
---|
17 | to the gate. |
---|
18 | |
---|
19 | """ |
---|
20 | #Basic geometry |
---|
21 | |
---|
22 | xright = 5.25 |
---|
23 | ybottom = 0 |
---|
24 | ytop = 0.30 |
---|
25 | xdam = 0.0 |
---|
26 | xleft = -0.5 |
---|
27 | #xslope = self.xslope |
---|
28 | |
---|
29 | nails_length_x = 0.15 |
---|
30 | |
---|
31 | xnailsleft = xslope + toe_to_nails_distance*cos(radians(beach_angle)) |
---|
32 | xnailsright = xslope + (toe_to_nails_distance+ nails_length_x) \ |
---|
33 | *cos(radians(beach_angle)) |
---|
34 | |
---|
35 | |
---|
36 | |
---|
37 | #Outline |
---|
38 | point_sw = [xleft, ybottom] |
---|
39 | point_se = [xright, ybottom] |
---|
40 | point_nw = [xleft, ytop] |
---|
41 | point_ne = [xright, ytop] |
---|
42 | |
---|
43 | # Dam seperation (left) |
---|
44 | point_dam_top = [xdam, ytop] |
---|
45 | point_dam_bottom = [xdam, ybottom] |
---|
46 | |
---|
47 | # slope seperation (middle) |
---|
48 | point_slope_top = [xslope, ytop] |
---|
49 | point_slope_bottom = [xslope, ybottom] |
---|
50 | |
---|
51 | # nail seperation (after slope, left) |
---|
52 | point_nails_left_top = [xnailsleft, ytop] |
---|
53 | point_nails_left_bottom = [xnailsleft, ybottom] |
---|
54 | |
---|
55 | # nail seperation (after slope, right) |
---|
56 | point_nails_right_top = [xnailsright, ytop] |
---|
57 | point_nails_right_bottom = [xnailsright, ybottom] |
---|
58 | |
---|
59 | |
---|
60 | m = Mesh() |
---|
61 | |
---|
62 | #Boundary |
---|
63 | points = [point_sw, #se |
---|
64 | point_nw, |
---|
65 | point_dam_top, |
---|
66 | point_slope_top, |
---|
67 | point_nails_left_top, |
---|
68 | point_nails_right_top, |
---|
69 | point_ne, |
---|
70 | point_se, |
---|
71 | point_nails_right_bottom, |
---|
72 | point_nails_left_bottom, |
---|
73 | point_slope_bottom, |
---|
74 | point_dam_bottom |
---|
75 | ] |
---|
76 | |
---|
77 | segments = [[0,1], [1,2], [2,3], |
---|
78 | [3,4 ],[4,5], [5,6],[6,7],[7,8], |
---|
79 | [8,9], [9,10],[10,11],[11,0],#The outer border |
---|
80 | [2,11], #dam Separator |
---|
81 | [3,10], # slope separator |
---|
82 | [4,9], # nails left separator |
---|
83 | [5,8]] # nails right separator |
---|
84 | |
---|
85 | segment_tags = {'wall':[0,1,2,3,5,6,7,8,9,10,11],'edge':[4]} |
---|
86 | |
---|
87 | m.add_points_and_segments(points, segments, segment_tags) |
---|
88 | |
---|
89 | |
---|
90 | if is_coarse == True: |
---|
91 | #nails_max_area = 0.001 |
---|
92 | general_max_area = 0.01 |
---|
93 | segment_count = 8 |
---|
94 | nails_x = 2 |
---|
95 | nails_y = 5 |
---|
96 | nail_spacing = 0.060 # distance between nail centers |
---|
97 | nail_radius = 0.01 |
---|
98 | else: |
---|
99 | #nails_max_area = 0.000001 |
---|
100 | general_max_area = 0.0001 |
---|
101 | segment_count = 20 |
---|
102 | nails_x = 8 |
---|
103 | nails_y = 19 |
---|
104 | nail_spacing = 0.015 # distance between nail centers |
---|
105 | nail_radius = 0.0025 |
---|
106 | |
---|
107 | #Add the nails |
---|
108 | for x_i in range(1,nails_x + 1): |
---|
109 | for y_i in range(1,nails_y + 1): |
---|
110 | center_point = (xnailsleft+(x_i*nail_spacing), y_i*nail_spacing) |
---|
111 | m.add_circle(center_point, radius = nail_radius, |
---|
112 | segment_count = segment_count, |
---|
113 | tag = 'wall', |
---|
114 | hole = True) |
---|
115 | |
---|
116 | |
---|
117 | # this is the location of the reservoir region. |
---|
118 | dam = m.add_region(-0.0000001,(ytop - ybottom)/2) |
---|
119 | dam.setTag("dam") |
---|
120 | |
---|
121 | # this is the location of the slope region, before the nails. |
---|
122 | slope = m.add_region(xslope + 0.0000001,(ytop - ybottom)/2) |
---|
123 | slope.setTag("slope") |
---|
124 | |
---|
125 | # this is the location of the slope region, after the nails. |
---|
126 | slope = m.add_region(xnailsright + 0.0000001,(ytop - ybottom)/2) |
---|
127 | slope.setTag("slope") |
---|
128 | |
---|
129 | # this is the location of the nails region, after the nails. |
---|
130 | nails = m.add_region(xnailsleft + 0.0000001,(ytop - ybottom)/2) |
---|
131 | nails.setTag("nails") |
---|
132 | #nails.setMaxArea(nails_max_area) |
---|
133 | |
---|
134 | |
---|
135 | m.generate_mesh(maximum_triangle_area=general_max_area) |
---|
136 | |
---|
137 | m.export_mesh_file(mesh_filename) |
---|
138 | print "mesh created" |
---|
139 | |
---|
140 | #------------------------------------------------------------- |
---|
141 | if __name__ == "__main__": |
---|
142 | generate("aa.tsh", beach_angle = 15, toe_to_nails_distance = 1.0, |
---|
143 | is_coarse = False) |
---|