Changeset 8048
- Timestamp:
- Oct 21, 2010, 3:37:57 PM (14 years ago)
- Location:
- trunk/anuga_core/source/anuga/structures
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_core/source/anuga/structures/inlet.py
r8042 r8048 1 from anuga.geometry.polygon import inside_polygon, is_inside_polygon, polygon_overlap 1 from anuga.geometry.polygon import inside_polygon, is_inside_polygon, polygon_overlap, polyline_overlap 2 2 from anuga.config import velocity_protection, g 3 3 import math … … 9 9 """ 10 10 11 def __init__(self, domain, poly gon, enquiry_pt, outward_culvert_vector=None, verbose=False):11 def __init__(self, domain, polyline, enquiry_pt, outward_culvert_vector=None, verbose=False): 12 12 13 13 self.domain = domain 14 14 self.domain_bounding_polygon = self.domain.get_boundary_polygon() 15 self.poly gon = polygon15 self.polyline = polyline 16 16 self.enquiry_pt = enquiry_pt 17 17 self.outward_culvert_vector = outward_culvert_vector … … 29 29 vertex_coordinates = self.domain.get_vertex_coordinates(absolute=True) 30 30 31 # Check that poly gonlies within the mesh.32 for point in self.poly gon:31 # Check that polyline lies within the mesh. 32 for point in self.polyline: 33 33 msg = 'Point %s ' % str(point) 34 34 msg += ' did not fall within the domain boundary.' … … 40 40 assert is_inside_polygon(point, bounding_polygon), msg 41 41 42 self.triangle_indices = polygon_overlap(vertex_coordinates, self.polygon) 43 #self.triangle_indices_cen = inside_polygon(domain_centroids, self.polygon, verbose=self.verbose) 42 self.triangle_indices = polyline_overlap(vertex_coordinates, self.polyline) 44 43 45 44 if len(self.triangle_indices) == 0: 46 region = 'Inlet poly gon=%s' % (self.polygon)45 region = 'Inlet polyline=%s' % (self.polyline) 47 46 msg = 'No triangles have been identified in region ' 48 47 raise Exception, msg … … 54 53 55 54 # Compute inlet area as the sum of areas of triangles identified 56 # by poly gon. Must be called after compute_inlet_triangle_indices().55 # by polyline. Must be called after compute_inlet_triangle_indices(). 57 56 if len(self.triangle_indices) == 0: 58 region = 'Inlet poly gon=%s' % (self.inlet_polygon)57 region = 'Inlet polyline=%s' % (self.inlet_polyline) 59 58 msg = 'No triangles have been identified in region ' 60 59 raise Exception, msg -
trunk/anuga_core/source/anuga/structures/structure_operator.py
r8035 r8048 86 86 87 87 self.inlets = [] 88 poly gon0 = self.inlet_polygons[0]88 polyline0 = self.inlet_polylines[0] 89 89 enquiry_point0 = self.inlet_equiry_points[0] 90 90 outward_vector0 = self.culvert_vector 91 self.inlets.append(inlet.Inlet(self.domain, poly gon0, enquiry_point0, outward_vector0))92 93 poly gon1 = self.inlet_polygons[1]94 e xchange_polygon1 = self.inlet_equiry_points[1]91 self.inlets.append(inlet.Inlet(self.domain, polyline0, enquiry_point0, outward_vector0)) 92 93 polyline1 = self.inlet_polylines[1] 94 enquiry_point1 = self.inlet_equiry_points[1] 95 95 outward_vector1 = - self.culvert_vector 96 self.inlets.append(inlet.Inlet(self.domain, poly gon1, exchange_polygon1, outward_vector1))96 self.inlets.append(inlet.Inlet(self.domain, polyline1, enquiry_point1, outward_vector1)) 97 97 98 98 self.set_logging(logging) … … 196 196 def __create_exchange_polygons(self): 197 197 198 """Create poly gons at the end of a culvert inlet and outlet.199 At either end two poly gons will be created; one for the actual flow to pass through and one a little further away198 """Create polylines at the end of a culvert inlet and outlet. 199 At either end two polylines will be created; one for the actual flow to pass through and one a little further away 200 200 for enquiring the total energy at both ends of the culvert and transferring flow. 201 201 """ … … 218 218 # Short hands 219 219 w = 0.5*self.width*self.culvert_normal # Perpendicular vector of 1/2 width 220 h = self.apron*self.culvert_vector # Vector of length=height in the220 #h = self.apron*self.culvert_vector # Vector of length=height in the 221 221 # direction of the culvert 222 222 223 gap = 1.5*h + self.enquiry_gap 224 225 self.inlet_polygons = [] 223 #gap = 1.5*h + self.enquiry_gap 224 gap = 1.5*self.culvert_vector + self.enquiry_gap 225 226 self.inlet_polylines = [] 226 227 self.inlet_equiry_points = [] 227 228 … … 231 232 p0 = self.end_points[i] + w 232 233 p1 = self.end_points[i] - w 233 p2 = p1 + i0*h234 p3 = p0 + i0*h235 234 ep = self.end_points[i] + i0*gap 236 235 237 self.inlet_polygons.append(num.array([p0, p1, p2, p3])) 238 self.inlet_equiry_points.append(ep) 239 240 # Check that enquiry points are outside inlet polygons 241 for i in [0,1]: 242 polygon = self.inlet_polygons[i] 243 ep = self.inlet_equiry_points[i] 244 245 area = anuga.polygon_area(polygon) 246 247 msg = 'Polygon %s ' %(polygon) 248 msg += ' has area = %f' % area 249 assert area > 0.0, msg 250 251 msg = 'Enquiry point falls inside an exchange polygon.' 252 assert not anuga.inside_polygon(ep, polygon), msg 253 236 self.inlet_polylines.append(num.array([p0, p1])) 237 self.inlet_equiry_points.append(ep) 254 238 255 239 def discharge_routine(self): … … 284 268 285 269 message += 'polygon\n' 286 message += '%s' % inlet.poly gon270 message += '%s' % inlet.polyline 287 271 message += '\n' 288 272
Note: See TracChangeset
for help on using the changeset viewer.