"""Create mesh for University of Queensland dam break flume """ from math import cos, radians from anuga.pmesh.mesh import * from anuga.coordinate_transforms.geo_reference import Geo_reference #Basic geometry xslope = 2.5 def generate(mesh_filename, beach_angle, toe_to_nails_distance, is_coarse = True): """ Generate mesh for Saman's flume flume. The gate position is the distance from the right wall of the wave tank to the gate. """ #Basic geometry xright = 5.25 ybottom = 0 ytop = 0.30 xdam = 0.0 xleft = -0.5 #xslope = self.xslope nails_length_x = 0.15 xnailsleft = xslope + toe_to_nails_distance*cos(radians(beach_angle)) xnailsright = xslope + (toe_to_nails_distance+ nails_length_x) \ *cos(radians(beach_angle)) #Outline point_sw = [xleft, ybottom] point_se = [xright, ybottom] point_nw = [xleft, ytop] point_ne = [xright, ytop] # Dam seperation (left) point_dam_top = [xdam, ytop] point_dam_bottom = [xdam, ybottom] # slope seperation (middle) point_slope_top = [xslope, ytop] point_slope_bottom = [xslope, ybottom] # nail seperation (after slope, left) point_nails_left_top = [xnailsleft, ytop] point_nails_left_bottom = [xnailsleft, ybottom] # nail seperation (after slope, right) point_nails_right_top = [xnailsright, ytop] point_nails_right_bottom = [xnailsright, ybottom] m = Mesh() #Boundary points = [point_sw, #se point_nw, point_dam_top, point_slope_top, point_nails_left_top, point_nails_right_top, point_ne, point_se, point_nails_right_bottom, point_nails_left_bottom, point_slope_bottom, point_dam_bottom ] segments = [[0,1], [1,2], [2,3], [3,4 ],[4,5], [5,6],[6,7],[7,8], [8,9], [9,10],[10,11],[11,0],#The outer border [2,11], #dam Separator [3,10], # slope separator [4,9], # nails left separator [5,8]] # nails right separator segment_tags = {'wall':[0,1,2,3,5,6,7,8,9,10,11],'edge':[4]} m.add_points_and_segments(points, segments, segment_tags) if is_coarse == True: #nails_max_area = 0.001 general_max_area = 0.01 segment_count = 8 nails_x = 2 nails_y = 5 nail_spacing = 0.060 # distance between nail centers nail_radius = 0.01 else: #nails_max_area = 0.000001 general_max_area = 0.0001 segment_count = 20 nails_x = 8 nails_y = 19 nail_spacing = 0.015 # distance between nail centers nail_radius = 0.0025 #Add the nails for x_i in range(1,nails_x + 1): for y_i in range(1,nails_y + 1): center_point = (xnailsleft+(x_i*nail_spacing), y_i*nail_spacing) m.add_circle(center_point, radius = nail_radius, segment_count = segment_count, tag = 'wall', hole = True) # this is the location of the reservoir region. dam = m.add_region(-0.0000001,(ytop - ybottom)/2) dam.setTag("dam") # this is the location of the slope region, before the nails. slope = m.add_region(xslope + 0.0000001,(ytop - ybottom)/2) slope.setTag("slope") # this is the location of the slope region, after the nails. slope = m.add_region(xnailsright + 0.0000001,(ytop - ybottom)/2) slope.setTag("slope") # this is the location of the nails region, after the nails. nails = m.add_region(xnailsleft + 0.0000001,(ytop - ybottom)/2) nails.setTag("nails") #nails.setMaxArea(nails_max_area) m.generate_mesh(maximum_triangle_area=general_max_area) m.export_mesh_file(mesh_filename) print "mesh created" #------------------------------------------------------------- if __name__ == "__main__": generate("aa.tsh", beach_angle = 15, toe_to_nails_distance = 1.0, is_coarse = False)