Changeset 5288 for anuga_core/source/anuga/shallow_water/data_manager.py
- Timestamp:
- May 7, 2008, 4:01:52 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/shallow_water/data_manager.py
r5276 r5288 5621 5621 filename: Name of sww file 5622 5622 polyline: Representation of desired cross section - it may contain multiple 5623 sections allowing for complex shapes. 5623 sections allowing for complex shapes. Assume absolute UTM coordinates. 5624 Format [[x0, y0], [x1, y1], ...] 5624 5625 5625 5626 Output: 5626 time: All stored times 5627 time: All stored times in sww file 5627 5628 Q: Hydrograph of total flow across given segments for all stored times. 5628 5629 5629 5630 The normal flow is computed for each triangle intersected by the polyline and 5630 added up. multiple segments at different angles are specified the normal flows5631 added up. Multiple segments at different angles are specified the normal flows 5631 5632 may partially cancel each other. 5632 5633 5633 """ 5634 The typical usage of this function would be to get flow through a channel, 5635 and the polyline would then be a cross section perpendicular to the flow. 5636 5637 """ 5638 5639 from anuga.fit_interpolate.interpolate import Interpolation_function 5640 5641 quantity_names =['elevation', 5642 'stage', 5643 'xmomentum', 5644 'ymomentum'] 5634 5645 5635 5646 # Get mesh and quantities from sww file 5636 5647 X = get_mesh_and_quantities_from_file(filename, 5637 quantities=['elevation', 5638 'stage', 5639 'xmomentum', 5640 'ymomentum'], 5648 quantities=quantity_names, 5641 5649 verbose=verbose) 5642 5650 mesh, quantities, time = X 5643 5651 5644 5652 5653 # Adjust polyline to mesh spatial origin 5654 polyline = mesh.geo_reference.get_relative(polyline) 5645 5655 5646 5656 # Find all intersections and associated triangles. 5647 5648 mesh.get_intersecting_segments(polyline) 5657 segments = mesh.get_intersecting_segments(polyline) 5658 #print 5659 #for x in segments: 5660 # print x 5661 5649 5662 5650 5663 # Then store for each triangle the length of the intersecting segment(s), 5651 # right hand normal(s) and midpoints. 5664 # right hand normal(s) and midpoints as interpolation_points. 5665 interpolation_points = [] 5666 for segment in segments: 5667 midpoint = sum(array(segment.segment))/2 5668 interpolation_points.append(midpoint) 5669 5670 5671 I = Interpolation_function(time, 5672 quantities, 5673 quantity_names=quantity_names, 5674 vertex_coordinates=mesh.nodes, 5675 triangles=mesh.triangles, 5676 interpolation_points=interpolation_points, 5677 verbose=verbose) 5678 5679 # Compute hydrograph 5680 Q = [] 5681 for t in time: 5682 total_flow=0 5683 for i, p in enumerate(interpolation_points): 5684 elevation, stage, uh, vh = I(t, point_id=i) 5685 normal = segments[i].normal 5686 5687 # Inner product of momentum vector with segment normal [m^2/s] 5688 normal_momentum = uh*normal[0] + vh*normal[1] 5689 5690 # Flow across this segment [m^3/s] 5691 segment_flow = normal_momentum*segments[i].length 5692 5693 # Accumulate 5694 total_flow += segment_flow 5695 5696 5697 # Store flow at this timestep 5698 Q.append(total_flow) 5699 5700 5652 5701 5653 5702 return time, Q
Note: See TracChangeset
for help on using the changeset viewer.