- Timestamp:
- Feb 10, 2009, 11:11:04 AM (16 years ago)
- Location:
- branches/numpy
- Files:
-
- 1 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/numpy/anuga/abstract_2d_finite_volumes/test_region.py
r6145 r6304 8 8 #from anuga.config import epsilon 9 9 10 import Numericas num10 import numpy as num 11 11 12 12 … … 42 42 43 43 def test_region_tags(self): 44 """ 45 get values based on triangle lists. 46 """ 47 from mesh_factory import rectangular 48 from shallow_water import Domain 49 50 #Create basic mesh 51 points, vertices, boundary = rectangular(1, 3) 52 53 #Create shallow water domain 54 domain = Domain(points, vertices, boundary) 55 domain.build_tagged_elements_dictionary({'bottom':[0,1], 56 'top':[4,5], 57 'all':[0,1,2,3,4,5]}) 58 44 """get values based on triangle lists.""" 45 46 from mesh_factory import rectangular 47 from shallow_water import Domain 48 49 #Create basic mesh 50 points, vertices, boundary = rectangular(1, 3) 51 52 #Create shallow water domain 53 domain = Domain(points, vertices, boundary) 54 domain.build_tagged_elements_dictionary({'bottom': [0,1], 55 'top': [4,5], 56 'all': [0,1,2,3,4,5]}) 59 57 60 58 #Set friction … … 65 63 b = Set_region('top', 'friction', 1.0) 66 64 domain.set_region([a, b]) 67 #print domain.quantities['friction'].get_values() 68 assert num.allclose(domain.quantities['friction'].get_values(),\ 69 [[ 0.09, 0.09, 0.09], 70 [ 0.09, 0.09, 0.09], 71 [ 0.07, 0.07, 0.07], 72 [ 0.07, 0.07, 0.07], 73 [ 1.0, 1.0, 1.0], 74 [ 1.0, 1.0, 1.0]]) 65 66 expected = [[ 0.09, 0.09, 0.09], 67 [ 0.09, 0.09, 0.09], 68 [ 0.07, 0.07, 0.07], 69 [ 0.07, 0.07, 0.07], 70 [ 1.0, 1.0, 1.0], 71 [ 1.0, 1.0, 1.0]] 72 msg = ("\ndomain.quantities['friction']=%s\nexpected value=%s" 73 % (str(domain.quantities['friction'].get_values()), 74 str(expected))) 75 assert num.allclose(domain.quantities['friction'].get_values(), 76 expected), msg 75 77 76 78 #c = Add_Value_To_region('all', 'friction', 10.0) … … 126 128 127 129 def test_unique_vertices(self): 128 """ 129 get values based on triangle lists. 130 """ 130 """get values based on triangle lists.""" 131 131 132 from mesh_factory import rectangular 132 133 from shallow_water import Domain … … 147 148 a = Set_region('bottom', 'friction', 0.09, location = 'unique vertices') 148 149 domain.set_region(a) 149 #print domain.quantities['friction'].get_values() 150 assert num.allclose(domain.quantities['friction'].get_values(),\ 150 assert num.allclose(domain.quantities['friction'].get_values(), 151 151 [[ 0.09, 0.09, 0.09], 152 152 [ 0.09, 0.09, 0.09], … … 217 217 #print domain.quantities['friction'].get_values() 218 218 frict_points = domain.quantities['friction'].get_values() 219 assert num.allclose(frict_points[0],\ 220 [ calc_frict, calc_frict, calc_frict]) 221 assert num.allclose(frict_points[1],\ 222 [ calc_frict, calc_frict, calc_frict]) 219 expected = [calc_frict, calc_frict, calc_frict] 220 msg = ('frict_points[0]=%s\nexpected=%s' % (str(frict_points[0]), 221 str(expected))) 222 assert num.allclose(frict_points[0], expected), msg 223 msg = ('frict_points[1]=%s\nexpected=%s' % (str(frict_points[1]), 224 str(expected))) 225 assert num.allclose(frict_points[1], expected), msg 223 226 224 227 def test_unique_vertices_average_loc_unique_vert(self): … … 262 265 #------------------------------------------------------------- 263 266 if __name__ == "__main__": 264 suite = unittest.makeSuite(Test_Region, 'test')267 suite = unittest.makeSuite(Test_Region, 'test') 265 268 runner = unittest.TextTestRunner() 266 269 runner.run(suite)
Note: See TracChangeset
for help on using the changeset viewer.