Changeset 4579
- Timestamp:
- Jul 3, 2007, 1:30:49 PM (18 years ago)
- Location:
- anuga_core/source/anuga
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/abstract_2d_finite_volumes/quantity.py
r4569 r4579 179 179 alpha = None, 180 180 location = 'vertices', 181 polygon = None, 181 182 indices = None, 182 183 verbose = False, … … 262 263 will be left undefined. 263 264 265 266 polygon: Restrict update of quantity to locations that fall 267 inside polygon. Polygon works by selecting indices 268 and calling set_values recursively. 269 270 indices: Restrict update of quantity to locations that are 271 identified by indices (e.g. node ids if location 272 is 'vertices') 273 264 274 verbose: True means that output to stdout is generated 265 275 … … 278 288 from types import FloatType, IntType, LongType, ListType, NoneType 279 289 from Numeric import ArrayType 290 291 292 # Polygon situation 293 #if polygon is not None: 294 # if indices is not None: 295 # msg = 'Only one of polygon and indices can be specified' 296 # raise Exception, msg 297 # 298 # Need to get candidate points. I think we should 299 # simplify this whole thing a bit. Do we really need location? 300 # point_indices = inside_polygon(points, polygon) 301 302 280 303 281 304 #General input checks … … 388 411 """ 389 412 413 # FIXME (Ole): Somehow indices refer to centroids 414 # rather than vertices as default. See unit test 415 # test_set_vertex_values_using_general_interface_with_subset(self): 416 390 417 391 418 if location == 'centroids': -
anuga_core/source/anuga/abstract_2d_finite_volumes/test_quantity.py
r4252 r4579 377 377 378 378 379 def test_set_vertex_values_using_general_interface_with_subset(self): 380 """test_set_vertex_values_using_general_interface_with_subset(self): 381 Test that indices and polygon works 382 """ 383 384 quantity = Quantity(self.mesh4) 385 386 387 quantity.set_values([0,2,3,5], indices=[0,2,3,5]) 388 assert allclose(quantity.vertex_values, 389 [[0,0,2], [0,2,0], [0,2,5], [3,0,0]]) 390 391 392 # Constant 393 quantity.set_values(0.0) 394 quantity.set_values(3.14, indices=[0,2], location='vertices') 395 396 # Indices refer to triangle numbers here - not vertices (why?) 397 assert allclose(quantity.vertex_values, 398 [[3.14,3.14,3.14], [0,0,0], 399 [3.14,3.14,3.14], [0,0,0]]) 400 401 402 403 # FIXME: Not done yet 404 # Now try with polygon (pick points where y>2) 405 #polygon = [[0,2.1], [4,2.1], [4,7], [0,7]] 406 #quantity.set_values(0.0) 407 #quantity.set_values(3.14, polygon=polygon, location='vertices') 408 # 409 #print quantity.vertex_values 410 # 411 ## Indices refer to triangle numbers here - not vertices (why?) 412 #assert allclose(quantity.vertex_values, 413 # [[0,0,0], [0,0,0], [0,0,0], 414 # [3.14,3.14,3.14]]) 415 416 379 417 380 418 -
anuga_core/source/anuga/utilities/polygon.py
r4574 r4579 622 622 return z 623 623 624 def read_polygon(filename,split=','): 624 625 def read_polygon(filename, split=','): 625 626 """Read points assumed to form a polygon. 626 627 There must be exactly two numbers in each line separated by a comma. … … 639 640 return polygon 640 641 641 def populate_polygon(polygon, number_of_points, seed = None, exclude = None): 642 643 def populate_polygon(polygon, number_of_points, seed=None, exclude=None): 642 644 """Populate given polygon with uniformly distributed points. 643 645 … … 694 696 695 697 return points 698 696 699 697 700 def point_in_polygon(polygon, delta=1e-8): … … 739 742 return point 740 743 744 741 745 def number_mesh_triangles(interior_regions, bounding_poly, remainder_res): 742 """Calcalutes the approximate number of triangles inside the bounding polygon743 and the other interior regions746 """Calcalutes the approximate number of triangles inside the 747 bounding polygon and the other interior regions 744 748 745 749 Polygon areas are converted to square Kms
Note: See TracChangeset
for help on using the changeset viewer.