Ignore:
Timestamp:
Sep 1, 2010, 6:11:25 PM (14 years ago)
Author:
steve
Message:

Added enquiry points to culverts

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/anuga_core/source/anuga/structures/inlet.py

    r7980 r7984  
    99    """
    1010
    11     def __init__(self, domain, polygon, outward_culvert_vector=None):
     11    def __init__(self, domain, polygon, enquiry_pt,  outward_culvert_vector=None, verbose=False):
    1212
    1313        self.domain = domain
    1414        self.domain_bounding_polygon = self.domain.get_boundary_polygon()
    1515        self.polygon = polygon
     16        self.enquiry_pt = enquiry_pt
    1617        self.outward_culvert_vector = outward_culvert_vector
     18        self.verbose = verbose
    1719
    1820        # FIXME (SR) Using get_triangle_containing_point which needs to be sped up
    1921
    20         self.compute_triangle_indices()
     22        self.compute_indices()
    2123        self.compute_area()
    2224
    2325
    24     def compute_triangle_indices(self):
     26    def compute_indices(self):
    2527
    2628        # Get boundary (in absolute coordinates)
     
    2830        domain_centroids = self.domain.get_centroid_coordinates(absolute=True)
    2931
    30         self.inlet_polygon = self.polygon
    3132
    3233        # 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)
    3536                msg += ' did not fall within the domain boundary.'
    3637                assert is_inside_polygon(point, bounding_polygon), msg
    3738
    3839
    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)
    4041
    4142        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 '
    4545            raise Exception, msg
    4646
     47        self.enquiry_index = self.domain.get_triangle_containing_point(self.enquiry_pt)
    4748
    4849
     
    5455        if len(self.triangle_indices) == 0:
    5556            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 '
    5858            raise Exception, msg
    5959       
     
    115115        return num.sum(self.get_ymoms()*self.get_areas())/self.area
    116116   
     117
    117118    def get_heights(self):
    118119   
     
    175176
    176177
     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
    177243    def set_heights(self,height):
    178244
     
    187253    def set_xmoms(self,xmom):
    188254
    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)
    190256
    191257
    192258    def set_ymoms(self,ymom):
    193259
    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)
    195261
    196262
Note: See TracChangeset for help on using the changeset viewer.