Changeset 8048


Ignore:
Timestamp:
Oct 21, 2010, 3:37:57 PM (13 years ago)
Author:
habili
Message:

Changed from using polygons to polylines. The inlets are now represented by triangles that intersect or contain a polyline.

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
     1from anuga.geometry.polygon import inside_polygon, is_inside_polygon, polygon_overlap, polyline_overlap
    22from anuga.config import velocity_protection, g
    33import math
     
    99    """
    1010
    11     def __init__(self, domain, polygon, enquiry_pt,  outward_culvert_vector=None, verbose=False):
     11    def __init__(self, domain, polyline, enquiry_pt,  outward_culvert_vector=None, verbose=False):
    1212
    1313        self.domain = domain
    1414        self.domain_bounding_polygon = self.domain.get_boundary_polygon()
    15         self.polygon = polygon
     15        self.polyline = polyline
    1616        self.enquiry_pt = enquiry_pt
    1717        self.outward_culvert_vector = outward_culvert_vector
     
    2929        vertex_coordinates = self.domain.get_vertex_coordinates(absolute=True)
    3030
    31         # Check that polygon lies within the mesh.
    32         for point in self.polygon
     31        # Check that polyline lies within the mesh.
     32        for point in self.polyline
    3333                msg = 'Point %s ' %  str(point)
    3434                msg += ' did not fall within the domain boundary.'
     
    4040        assert is_inside_polygon(point, bounding_polygon), msg
    4141
    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)
    4443
    4544        if len(self.triangle_indices) == 0:
    46             region = 'Inlet polygon=%s' % (self.polygon)
     45            region = 'Inlet polyline=%s' % (self.polyline)
    4746            msg = 'No triangles have been identified in region '
    4847            raise Exception, msg
     
    5453       
    5554        # Compute inlet area as the sum of areas of triangles identified
    56         # by polygon. Must be called after compute_inlet_triangle_indices().
     55        # by polyline. Must be called after compute_inlet_triangle_indices().
    5756        if len(self.triangle_indices) == 0:
    58             region = 'Inlet polygon=%s' % (self.inlet_polygon)
     57            region = 'Inlet polyline=%s' % (self.inlet_polyline)
    5958            msg = 'No triangles have been identified in region '
    6059            raise Exception, msg
  • trunk/anuga_core/source/anuga/structures/structure_operator.py

    r8035 r8048  
    8686
    8787        self.inlets = []
    88         polygon0 = self.inlet_polygons[0]
     88        polyline0 = self.inlet_polylines[0]
    8989        enquiry_point0 = self.inlet_equiry_points[0]
    9090        outward_vector0 = self.culvert_vector
    91         self.inlets.append(inlet.Inlet(self.domain, polygon0, enquiry_point0, outward_vector0))
    92 
    93         polygon1 = self.inlet_polygons[1]
    94         exchange_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]
    9595        outward_vector1  = - self.culvert_vector
    96         self.inlets.append(inlet.Inlet(self.domain, polygon1, exchange_polygon1, outward_vector1))
     96        self.inlets.append(inlet.Inlet(self.domain, polyline1, enquiry_point1, outward_vector1))
    9797
    9898        self.set_logging(logging)
     
    196196    def __create_exchange_polygons(self):
    197197
    198         """Create polygons at the end of a culvert inlet and outlet.
    199         At either end two polygons will be created; one for the actual flow to pass through and one a little further away
     198        """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
    200200        for enquiring the total energy at both ends of the culvert and transferring flow.
    201201        """
     
    218218        # Short hands
    219219        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 the
     220        #h = self.apron*self.culvert_vector    # Vector of length=height in the
    221221                             # direction of the culvert
    222222
    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 = []
    226227        self.inlet_equiry_points = []
    227228
     
    231232            p0 = self.end_points[i] + w
    232233            p1 = self.end_points[i] - w
    233             p2 = p1 + i0*h
    234             p3 = p0 + i0*h
    235234            ep = self.end_points[i] + i0*gap
    236235
    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)           
    254238   
    255239    def discharge_routine(self):
     
    284268
    285269            message += 'polygon\n'
    286             message += '%s' % inlet.polygon
     270            message += '%s' % inlet.polyline
    287271            message += '\n'
    288272
Note: See TracChangeset for help on using the changeset viewer.