Changeset 5521
 Timestamp:
 Jul 17, 2008, 10:57:41 PM (15 years ago)
 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
r5520 r5521 368 368 from Numeric import ArrayType 369 369 370 371 370 # Treat special case: Polygon situation 372 371 # Location will be ignored and set to 'centroids' … … 376 375 # FIXME (Ole): Need to compute indices based on polygon (and location) and 377 376 # use existing code after that. 377 378 # Perhaps deprecate 'centroids' as a location option. It is really just a 379 # first order version of what is currently called vertices 378 380 379 381 if polygon is not None: … … 423 425 424 426 425 if location not in ['vertices', 'centroids', 'edges', 426 'unique vertices']: 427 if location == 'edges': 428 msg = 'edges has been deprecated as valid location' 429 raise Exception, msg 430 431 432 if location not in ['vertices', 'centroids', 'unique vertices']: 427 433 msg = 'Invalid location: %s' %location 428 434 raise Exception, msg … … 522 528 self.centroid_values[i] = X 523 529 524 elif location == 'edges':525 if indices is None:526 self.edge_values[:] = X527 else:528 # Brute force529 for i in indices:530 self.edge_values[i] = X530 #elif location == 'edges': 531 # if indices is None: 532 # self.edge_values[:] = X 533 # else: 534 # # Brute force 535 # for i in indices: 536 # self.edge_values[i] = X 531 537 532 538 elif location == 'unique vertices': … … 570 576 values: Numeric array 571 577 location: Where values are to be stored. 572 Permissible options are: vertices, edges,centroid, unique vertices578 Permissible options are: vertices, centroid, unique vertices 573 579 Default is 'vertices' 574 580 … … 621 627 self.centroid_values[indices[i]] = values[i] 622 628 623 elif location == 'edges':624 # FIXME (Ole): No mention of indices here. However, I don't625 # think we ever need to set values at edges anyway626 assert len(values.shape) == 2, 'Values array must be 2d'627 628 msg = 'Number of values must match number of elements'629 assert values.shape[0] == N, msg630 631 msg = 'Array must be N x 3'632 assert values.shape[1] == 3, msg633 634 self.edge_values = values629 #elif location == 'edges': 630 # # FIXME (Ole): No mention of indices here. However, I don't 631 # # think we ever need to set values at edges anyway 632 # assert len(values.shape) == 2, 'Values array must be 2d' 633 # 634 # msg = 'Number of values must match number of elements' 635 # assert values.shape[0] == N, msg 636 # 637 # msg = 'Array must be N x 3' 638 # assert values.shape[1] == 3, msg 639 # 640 # self.edge_values = values 635 641 636 642 elif location == 'unique vertices': … … 692 698 f: x, y > z Function where x, y and z are arrays 693 699 location: Where values are to be stored. 694 Permissible options are: vertices, centroid, edges,700 Permissible options are: vertices, centroid, 695 701 unique vertices 696 702 Default is "vertices" … … 1096 1102 1097 1103 1098 1104 # FIXME (Ole): Consider deprecating 'edges'  but not if it is used 1105 # elsewhere in ANUGA. 1099 1106 if location not in ['vertices', 'centroids', 'edges', 1100 1107 'unique vertices']: 
anuga_core/source/anuga/abstract_2d_finite_volumes/test_quantity.py
r5519 r5521 253 253 254 254 255 # Test default255 # Test default 256 256 quantity.set_values([[1,2,3], [5,5,5], [0,0,9], [6, 3, 3]]) 257 257 assert allclose(quantity.vertex_values, … … 263 263 [3.0, 1.5, 1.5]]) 264 264 265 # Test centroids265 # Test centroids 266 266 quantity.set_values([1,2,3,4], location = 'centroids') 267 267 assert allclose(quantity.centroid_values, [1., 2., 3., 4.]) #Centroid 268 268 269 #Test edges 270 quantity.set_values([[1,2,3], [5,5,5], [0,0,9], [6, 3, 3]], 271 location = 'edges') 272 assert allclose(quantity.edge_values, 273 [[1,2,3], [5,5,5], [0,0,9], [6, 3, 3]]) 274 275 #Test exceptions 269 # Test exceptions 276 270 try: 277 271 quantity.set_values([[1,2,3], [5,5,5], [0,0,9], [6, 3, 3]], … … 306 300 quantity.set_values(2.0, location = 'centroids') 307 301 assert allclose(quantity.centroid_values, [2, 2, 2, 2]) 308 309 quantity.set_values(3.0, location = 'edges')310 assert allclose(quantity.edge_values, [[3, 3, 3],311 [3, 3, 3],312 [3, 3, 3],313 [3, 3, 3]])314 302 315 303
Note: See TracChangeset
for help on using the changeset viewer.