- Timestamp:
- Nov 17, 2005, 4:16:50 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/analytical solutions/Non_symmetrical_dam_break.py
r2034 r2036 4 4 Christopher Zoppou, Stephen Roberts 5 5 Australian National University 6 6 7 7 """ 8 8 … … 15 15 from shallow_water import Domain, Transmissive_boundary, Reflective_boundary,\ 16 16 Dirichlet_boundary 17 from pmesh2domain import pmesh_to_domain_instance17 #from pmesh2domain import pmesh_to_domain_instance 18 18 from util import Polygon_function 19 19 from mesh_factory import rectangular_cross 20 21 22 def cut_out_region(domain): 23 """ 24 To do: make better comments! 25 Deal with passing the boundary info as well 26 """ 27 28 points = domain.coordinates 29 elements = domain.triangles 30 boundary = domain.boundary 31 centroid_coordinates = domain.centroid_coordinates 32 N = domain.number_of_elements 33 34 elements_in = [] 35 elements_out = [] 36 for i in range(N): 37 element = elements[i] 38 #print element 39 [x,y] = centroid_coordinates[i] 40 #print x,y 41 if x>10 and y>10: 42 #print i,'Out region' 43 elements_out.append(i) 44 else: 45 #print i,'In region' 46 elements_in.append(i) 47 48 #print elements_in 49 #print elements_out 50 51 points_in = {} 52 for i in elements_in: 53 #print i 54 [v0,v1,v2] = elements[i] 55 #print v0,v1,v2 56 points_in[v0] = v0 57 points_in[v1] = v1 58 points_in[v2] = v2 59 60 61 new_index = [] 62 for i,value in enumerate(points_in): 63 #print i , value 64 points_in[value] = i 65 66 67 #print points_in 68 new_elements = [] 69 for i in elements_in: 70 #print i 71 [v0,v1,v2] = elements[i] 72 #print v0,v1,v2 73 74 nv0 = points_in[v0] 75 nv1 = points_in[v1] 76 nv2 = points_in[v2] 77 78 new_elements.append([nv0,nv1,nv2]) 79 80 new_points = [] 81 for key,value in points_in.iteritems(): 82 [x,y] = points[key] 83 new_points.append([x,y]) 84 85 #print new_points 86 87 return new_points, new_elements 88 89 90 91 92 20 93 21 94 … … 28 101 #--------------------------------------- 29 102 # Domain 30 n = 1931 m = 4032 delta_x = 5.33 delta_y = 5.103 n = 60 104 m = 60 105 delta_x = .5 106 delta_y = .5 34 107 lenx = delta_x*n 35 108 leny = delta_y*m … … 38 111 points, elements, boundary = rectangular_cross(m, n, lenx, leny, origin) 39 112 domain = Domain(points, elements, boundary) 113 114 new_points, new_elements = cut_out_region(domain) 115 domain = Domain(new_points, new_elements) 116 117 40 118 R = Reflective_boundary(domain) 41 119 T = Transmissive_boundary(domain) 42 120 D = Dirichlet_boundary([h1, 0.0, 0.0]) 43 domain.set_boundary({'left': R, 'right': T, 'top': R, 'bottom': R}) 44 45 n = 2 46 m = 15 47 delta_x = 5. 48 delta_y = 5. 49 lenx = delta_x*n 50 leny = delta_y*m 51 origin = (90.0, 90.0) 52 53 points, elements, boundary = rectangular_cross(m, n, lenx, leny, origin) 54 domain = Domain(points, elements, boundary) 55 R = Reflective_boundary(domain) 56 T = Transmissive_boundary(domain) 57 D = Dirichlet_boundary([h1, 0.0, 0.0]) 58 domain.set_boundary({'left': T, 'right': T, 'top': R, 'bottom': R}) 121 domain.set_boundary({'exterior': R}) 59 122 60 123 61 n = 1962 m = 4063 delta_x = 5.64 delta_y = 5.65 lenx = delta_x*n66 leny = delta_y*m67 origin = (100.0, 0.0)68 124 69 points, elements, boundary = rectangular_cross(m, n, lenx, leny, origin) 70 domain = Domain(points, elements, boundary) 71 R = Reflective_boundary(domain) 72 T = Transmissive_boundary(domain) 73 D = Dirichlet_boundary([h1, 0.0, 0.0]) 74 domain.set_boundary({'left': T, 'right': R, 'top': R, 'bottom': R}) 125 126 127 75 128 76 129 print "Number of triangles = ", len(domain) … … 79 132 #--------------------------------------- 80 133 #Initial condition 81 domain.set_quantity('stage', h0) 82 p0 = [[0.0, 0.0], [100.0, 0.0], [100.0, 200.0], [0.0, 200.0]] 83 domain.set_quantity('stage',Polygon_function([(p0,h1)])) 134 p0 = [[0.0, 0.0], [10.0, 0.0], [10.0, 20.0], [0.0, 20.0]] 135 domain.set_quantity('stage',Polygon_function([(p0,h1)],default = h0)) 84 136 85 137 … … 90 142 domain.filename = 'Non_symetrical_Dam_Break_second_order' 91 143 144 145 # Visualization smoothing 146 domain.smooth=False 147 domain.visualise=True 92 148 93 149 #--------------------------------------- … … 108 164 # Friction 109 165 domain.set_quantity('friction', 0.0) 110 111 166 167 112 168 #-------------------------------------- 113 169 # Evolution 114 170 115 171 yieldstep = 0.1 116 finaltime = 5.0117 172 finaltime = 15.0 173 118 174 domain.default_order = 2 119 175 domain.smooth = True … … 123 179 for t in domain.evolve(yieldstep = yieldstep, finaltime = finaltime): 124 180 domain.write_time() 125 181 126 182 print 'That took %.2f seconds' %(time.time()-t0) 127 183 128
Note: See TracChangeset
for help on using the changeset viewer.