- Timestamp:
- Sep 4, 2008, 2:45:27 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/shallow_water/shallow_water_domain.py
r5672 r5729 83 83 from Numeric import compress, arange 84 84 85 85 from anuga.abstract_2d_finite_volumes.neighbour_mesh import segment_midpoints 86 86 from anuga.abstract_2d_finite_volumes.domain import Domain as Generic_Domain 87 87 from anuga.abstract_2d_finite_volumes.generic_boundary_conditions\ … … 374 374 return self.get_quantity('elevation').\ 375 375 get_maximum_location(indices=wet_elements) 376 377 378 379 380 def get_flow_through_cross_section(self, polyline, 381 verbose=False): 382 """Get the total flow through an arbitrary poly line. 383 384 This is a run-time equivalent of the function with same name in data_manager.py 385 386 Input: 387 polyline: Representation of desired cross section - it may contain 388 multiple sections allowing for complex shapes. Assume 389 absolute UTM coordinates. 390 Format [[x0, y0], [x1, y1], ...] 391 392 Output: 393 Q: Total flow [m^3/s] across given segments. 394 395 396 """ 397 398 # Adjust polyline to mesh spatial origin 399 polyline = self.geo_reference.get_relative(polyline) 400 401 # Find all intersections and associated triangles. 402 segments = self.get_intersecting_segments(polyline, verbose=verbose) 403 404 msg = 'No segments found' 405 assert len(segments) > 0, msg 406 407 # Get midpoints 408 midpoints = segment_midpoints(segments) 409 410 # FIXME (Ole): HACK - need to make midpoints Geospatial instances 411 midpoints = self.geo_reference.get_absolute(midpoints) 412 413 # Compute flow 414 if verbose: print 'Computing flow through specified cross section' 415 416 # Get interpolated values 417 xmomentum = self.get_quantity('xmomentum') 418 ymomentum = self.get_quantity('ymomentum') 419 420 uh = xmomentum.get_values(interpolation_points=midpoints) 421 vh = ymomentum.get_values(interpolation_points=midpoints) 422 423 # Compute and sum flows across each segment 424 total_flow=0 425 for i in range(len(uh)): 426 427 # Inner product of momentum vector with segment normal [m^2/s] 428 normal = segments[i].normal 429 normal_momentum = uh[i]*normal[0] + vh[i]*normal[1] 430 431 # Flow across this segment [m^3/s] 432 segment_flow = normal_momentum*segments[i].length 433 434 # Accumulate 435 total_flow += segment_flow 436 437 438 return total_flow 439 376 440 377 441 def check_integrity(self):
Note: See TracChangeset
for help on using the changeset viewer.