Ignore:
Timestamp:
Jul 25, 2008, 1:35:45 PM (16 years ago)
Author:
ole
Message:

Added input tests regarding polygons and points

File:
1 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/shallow_water/shallow_water_domain.py

    r5506 r5570  
    108108
    109109
    110 from anuga.utilities.polygon import inside_polygon, polygon_area       
     110from anuga.utilities.polygon import inside_polygon, polygon_area, is_inside_polygon
    111111
    112112
     
    15011501           
    15021502                     
    1503         from math import pi
     1503        from math import pi, cos, sin
    15041504
    15051505        self.domain = domain
     
    15131513                         # previous timestep in order to obtain rate
    15141514
     1515                         
     1516        bounding_polygon = domain.get_boundary_polygon()
     1517
     1518
    15151519        # Update area if applicable
    15161520        self.exchange_area = None       
     
    15211525
    15221526            self.exchange_area = radius**2*pi
     1527
     1528            # Check that circle center lies within the mesh.
     1529            msg = 'Center %s specified for forcing term did not' %(str(center))
     1530            msg += 'fall within the domain boundary.'
     1531            assert is_inside_polygon(center, bounding_polygon), msg
     1532
     1533            # Check that circle periphery lies within the mesh.
     1534            N = 100
     1535            periphery_points = []
     1536            for i in range(N):
     1537
     1538                theta = 2*pi*i/100
     1539               
     1540                x = center[0] + radius*cos(theta)
     1541                y = center[1] + radius*sin(theta)
     1542
     1543                periphery_points.append([x,y])
     1544
     1545
     1546            for point in periphery_points:
     1547                msg = 'Point %s on periphery for forcing term did not' %(str(point))
     1548                msg += ' fall within the domain boundary.'
     1549                assert is_inside_polygon(point, bounding_polygon), msg
     1550
    15231551       
    15241552        if polygon is not None:
    15251553            self.exchange_area = polygon_area(self.polygon)
     1554
     1555            # Check that polygon lies within the mesh.
     1556            for point in self.polygon:
     1557                msg = 'Point %s in polygon for forcing term did not' %(str(point))
     1558                msg += 'fall within the domain boundary.'
     1559                assert is_inside_polygon(point, bounding_polygon), msg
     1560       
     1561
     1562
     1563           
    15261564
    15271565
Note: See TracChangeset for help on using the changeset viewer.