Changeset 4584


Ignore:
Timestamp:
Jul 4, 2007, 11:41:43 AM (17 years ago)
Author:
ole
Message:

A bit more testing of polygons in set_quantity

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

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/abstract_2d_finite_volumes/quantity.py

    r4583 r4584  
    295295
    296296        # Treat special case: Polygon situation
     297        # Location will be ignored and set to 'centroids'
    297298        # FIXME (Ole): This needs to be generalised and
    298299        # perhaps the notion of location and indices simplified
     300       
    299301        if polygon is not None:
    300302            if indices is not None:
    301303                msg = 'Only one of polygon and indices can be specified'
    302304                raise Exception, msg
    303 
    304305
    305306            msg = 'With polygon selected, set_quantity must provide '
  • anuga_core/source/anuga/abstract_2d_finite_volumes/test_quantity.py

    r4583 r4584  
    404404        polygon = [[0,2.1], [4,2.1], [4,7], [0,7]]
    405405        quantity.set_values(0.0)
    406         quantity.set_values(3.14, polygon=polygon, location='vertices')
    407        
    408         # Indices refer to triangle numbers here - not vertices (why?)
     406        quantity.set_values(3.14, polygon=polygon)
     407       
    409408        assert allclose(quantity.vertex_values,
    410409                        [[0,0,0], [0,0,0], [0,0,0],
    411410                         [3.14,3.14,3.14]])               
    412411
    413        
    414 
     412
     413        # Another polygon (pick triangle 1 and 2 (rightmost triangles)
     414        polygon = [[2.1, 0.0], [3.5,0.1], [2,2.2], [0.2,2]]
     415        quantity.set_values(0.0)
     416        quantity.set_values(3.14, polygon=polygon)
     417
     418        assert allclose(quantity.vertex_values,
     419                        [[0,0,0],
     420                         [3.14,3.14,3.14],
     421                         [3.14,3.14,3.14],                         
     422                         [0,0,0]])               
     423
     424
     425
     426        # Test input checking
     427        try:
     428            quantity.set_values(3.14, polygon=polygon, indices = [0,2])
     429        except:
     430            pass
     431        else:
     432            msg = 'Should have caught this'
     433            raise msg
     434
     435           
    415436
    416437    def test_set_values_using_fit(self):
Note: See TracChangeset for help on using the changeset viewer.