Changeset 5450


Ignore:
Timestamp:
Jun 30, 2008, 10:41:27 AM (14 years ago)
Author:
ole
Message:

Added exception is inlet_region for General flow does not contain any triangles.
An input check was also added.

Location:
anuga_core/source/anuga/shallow_water
Files:
2 edited

Legend:

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

    r5442 r5450  
    14911491                 verbose=False):
    14921492                     
    1493 
     1493        if center is None:
     1494            msg = 'I got radius but no center.'       
     1495            assert radius is None, msg
     1496           
     1497        if radius is None:
     1498            msg += 'I got center but no radius.'       
     1499            assert center is None, msg
     1500           
     1501           
     1502                     
    14941503        from math import pi
    14951504
     
    15291538            # Inlet is circular
    15301539           
     1540            inlet_region = 'center=%s, radius=%s' %(self.center, self.radius)
     1541           
    15311542            self.exchange_indices = []
    15321543            for k in range(N):
     
    15371548        if self.polygon is not None:                   
    15381549            # Inlet is polygon
     1550           
     1551            inlet_region = 'polygon=%s' %(self.polygon)
     1552                       
    15391553            self.exchange_indices = inside_polygon(points, self.polygon)
    15401554           
    1541 
    1542            
     1555           
     1556        if self.exchange_indices is not None:
     1557            #print inlet_region
     1558       
     1559            if len(self.exchange_indices) == 0:
     1560                msg = 'No triangles have been identified in specified region: %s' %inlet_region
     1561                raise Exception, msg
    15431562
    15441563
  • anuga_core/source/anuga/shallow_water/test_shallow_water_domain.py

    r5442 r5450  
    23212321       
    23222322
     2323
     2324
     2325    def test_inflow_catch_too_few_triangles(self):
     2326        """test_inflow_catch_too_few_triangles
     2327       
     2328        Test that exception is thrown if no triangles are covered by the inflow area
     2329        """
     2330        from math import pi, cos, sin
     2331
     2332        a = [0.0, 0.0]
     2333        b = [0.0, 2.0]
     2334        c = [2.0, 0.0]
     2335        d = [0.0, 4.0]
     2336        e = [2.0, 2.0]
     2337        f = [4.0, 0.0]
     2338
     2339        points = [a, b, c, d, e, f]
     2340        #bac, bce, ecf, dbe
     2341        vertices = [ [1,0,2], [1,2,4], [4,2,5], [3,1,4]]
     2342
     2343
     2344        domain = Domain(points, vertices)
     2345
     2346        # Flat surface with 1m of water
     2347        domain.set_quantity('elevation', 0)
     2348        domain.set_quantity('stage', 1.0)
     2349        domain.set_quantity('friction', 0)
     2350
     2351        Br = Reflective_boundary(domain)
     2352        domain.set_boundary({'exterior': Br})
     2353
     2354        # Setup only one forcing term, constant inflow of 2 m^3/s on a circle affecting triangles #0 and #1 (bac and bce)
     2355
     2356        try:
     2357            Inflow(domain, rate=2.0, center=(1,1.1), radius=0.01)
     2358        except:
     2359            pass
     2360        else:
     2361            msg = 'Should have raised exception'
     2362            raise Exception, msg
     2363
     2364
     2365
     2366       
     2367       
    23232368
    23242369    #####################################################
Note: See TracChangeset for help on using the changeset viewer.