Changeset 7984 for trunk/anuga_core/source/anuga/structures/inlet.py
- Timestamp:
- Sep 1, 2010, 6:11:25 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_core/source/anuga/structures/inlet.py
r7980 r7984 9 9 """ 10 10 11 def __init__(self, domain, polygon, outward_culvert_vector=None):11 def __init__(self, domain, polygon, 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 15 self.polygon = polygon 16 self.enquiry_pt = enquiry_pt 16 17 self.outward_culvert_vector = outward_culvert_vector 18 self.verbose = verbose 17 19 18 20 # FIXME (SR) Using get_triangle_containing_point which needs to be sped up 19 21 20 self.compute_ triangle_indices()22 self.compute_indices() 21 23 self.compute_area() 22 24 23 25 24 def compute_ triangle_indices(self):26 def compute_indices(self): 25 27 26 28 # Get boundary (in absolute coordinates) … … 28 30 domain_centroids = self.domain.get_centroid_coordinates(absolute=True) 29 31 30 self.inlet_polygon = self.polygon31 32 32 33 # Check that polygon lies within the mesh. 33 for point in self. inlet_polygon:34 msg = 'Point %s in polygon for forcing term' % str(point)34 for point in self.polygon + self.enquiry_pt: 35 msg = 'Point %s ' % str(point) 35 36 msg += ' did not fall within the domain boundary.' 36 37 assert is_inside_polygon(point, bounding_polygon), msg 37 38 38 39 39 self.triangle_indices = inside_polygon(domain_centroids, self. inlet_polygon, verbose=True)40 self.triangle_indices = inside_polygon(domain_centroids, self.polygon, verbose=self.verbose) 40 41 41 42 if len(self.triangle_indices) == 0: 42 region = 'Inlet polygon=%s' % (self.inlet_polygon) 43 msg = 'No triangles have been identified in ' 44 msg += 'specified region: %s' % region 43 region = 'Inlet polygon=%s' % (self.polygon) 44 msg = 'No triangles have been identified in region ' 45 45 raise Exception, msg 46 46 47 self.enquiry_index = self.domain.get_triangle_containing_point(self.enquiry_pt) 47 48 48 49 … … 54 55 if len(self.triangle_indices) == 0: 55 56 region = 'Inlet polygon=%s' % (self.inlet_polygon) 56 msg = 'No triangles have been identified in ' 57 msg += 'specified region: %s' % region 57 msg = 'No triangles have been identified in region ' 58 58 raise Exception, msg 59 59 … … 115 115 return num.sum(self.get_ymoms()*self.get_areas())/self.area 116 116 117 117 118 def get_heights(self): 118 119 … … 175 176 176 177 178 def get_enquiry_stage(self): 179 180 return self.domain.quantities['stage'].centroid_values[self.enquiry_index] 181 182 183 def get_enquiry_xmom(self): 184 185 return self.domain.quantities['xmomentum'].centroid_values[self.enquiry_index] 186 187 def get_enquiry_ymom(self): 188 189 return self.domain.quantities['ymomentum'].centroid_values[self.enquiry_index] 190 191 192 def get_enquiry_elevation(self): 193 194 return self.domain.quantities['elevation'].centroid_values[self.enquiry_index] 195 196 def get_enquiry_height(self): 197 198 return self.get_enquiry_stage() - self.get_enquiry_elevation() 199 200 201 def get_enquiry_velocity(self): 202 203 height = self.get_enquiry_height() 204 u = self.get_enquiry_xmom()/(height + velocity_protection/height) 205 v = self.get_enquiry_ymom()/(height + velocity_protection/height) 206 207 return u, v 208 209 210 def get_enquiry_xvelocity(self): 211 212 height = self.get_enquiry_height() 213 return self.get_enquiry_xmom()/(height + velocity_protection/height) 214 215 def get_enquiry_yvelocity(self): 216 217 height = self.get_enquiry_height() 218 return self.get_enquiry_ymom()/(height + velocity_protection/height) 219 220 221 def get_enquiry_speed(self): 222 223 u, v = self.get_enquiry_velocity() 224 225 return math.sqrt(u**2 + v**2) 226 227 228 def get_enquiry_velocity_head(self): 229 230 return 0.5*self.get_enquiry_speed()**2/g 231 232 233 def get_enquiry_total_energy(self): 234 235 return self.get_enquiry_velocity_head() + self.get_enquiry_stage() 236 237 238 def get_enquiry_specific_energy(self): 239 240 return self.get_enquiry_velocity_head() + self.get_enquiry_height() 241 242 177 243 def set_heights(self,height): 178 244 … … 187 253 def set_xmoms(self,xmom): 188 254 189 self. xmoms=self.domain.quantities['xmomentum'].centroid_values.put(self.triangle_indices, xmom)255 self.domain.quantities['xmomentum'].centroid_values.put(self.triangle_indices, xmom) 190 256 191 257 192 258 def set_ymoms(self,ymom): 193 259 194 self. xmoms=self.domain.quantities['ymomentum'].centroid_values.put(self.triangle_indices, ymom)260 self.domain.quantities['ymomentum'].centroid_values.put(self.triangle_indices, ymom) 195 261 196 262
Note: See TracChangeset
for help on using the changeset viewer.