Changeset 2501
- Timestamp:
- Mar 8, 2006, 6:30:00 PM (19 years ago)
- Location:
- inundation/pyvolution
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/pyvolution/domain.py
r2494 r2501 8 8 """ 9 9 10 from mesh import Mesh10 from mesh import Neighbour_mesh 11 11 from generic_boundary_conditions import * 12 12 import types 13 13 14 class Domain( Mesh):14 class Domain(Neighbour_mesh): 15 15 16 16 def __init__(self, coordinates, vertices, boundary = None, … … 19 19 use_inscribed_circle=False): 20 20 21 Mesh.__init__(self, coordinates, vertices, boundary,22 tagged_elements, geo_reference, use_inscribed_circle)21 Neighbour_mesh.__init__(self, coordinates, vertices, boundary, 22 tagged_elements, geo_reference, use_inscribed_circle) 23 23 24 24 from Numeric import zeros, Float, Int … … 331 331 #MISC 332 332 def check_integrity(self): 333 Mesh.check_integrity(self)333 Neighbour_mesh.check_integrity(self) 334 334 335 335 for quantity in self.conserved_quantities: -
inundation/pyvolution/least_squares.py
r2447 r2501 23 23 #from general_mesh import General_mesh 24 24 from Numeric import zeros, array, Float, Int, dot, transpose, concatenate, ArrayType 25 from pyvolution.mesh import Mesh25 from pyvolution.mesh import Neighbour_mesh 26 26 27 27 from Numeric import zeros, take, array, Float, Int, dot, transpose, concatenate, ArrayType … … 357 357 else: 358 358 geo = Geo_reference(mesh_origin[0],mesh_origin[1],mesh_origin[2]) 359 self.mesh = Mesh(vertex_coordinates, triangles,360 geo_reference = geo)359 self.mesh = Neighbour_mesh(vertex_coordinates, triangles, 360 geo_reference = geo) 361 361 362 362 self.mesh.check_integrity() -
inundation/pyvolution/mesh.py
r1800 r2501 7 7 from general_mesh import General_mesh 8 8 9 class Mesh(General_mesh):10 """Collection of triangular elements (purely geometric) 9 class Neighbour_mesh(General_mesh): 10 """Collection of triangular elements (purely geometric) with neighbour structure 11 11 12 12 A triangular element is defined in terms of three vertex ids, … … 21 21 22 22 To instantiate: 23 Mesh(coordinates, triangles)23 Neighbour_mesh(coordinates, triangles) 24 24 25 25 where … … 41 41 points = [a, b, c, e] 42 42 triangles = [ [1,0,2], [1,2,3] ] #bac, bce 43 mesh = Mesh(points, triangles)43 mesh = Neighbour_mesh(points, triangles) 44 44 45 45 #creates two triangles: bac and bce 46 46 47 47 48 Mesh takes the optional third argument boundary which is a48 Neighbour_mesh takes the optional third argument boundary which is a 49 49 dictionary mapping from (element_id, edge_id) to boundary tag. 50 50 The default value is None which will assign the default_boundary_tag … … 159 159 160 160 def __repr__(self): 161 return ' Mesh: %d triangles, %d elements, %d boundary segments'\161 return 'Neighbour_mesh: %d triangles, %d elements, %d boundary segments'\ 162 162 %(self.coordinates.shape[0], len(self), len(self.boundary)) 163 163 … … 490 490 that area corresponds to edgelengths, that vertices 491 491 are arranged in a counter-clockwise order, etc etc 492 Neighbour structure will be checked by class Mesh492 Neighbour structure will be checked by class Neighbour_mesh 493 493 """ 494 494 -
inundation/pyvolution/quantity.py
r2491 r2501 20 20 def __init__(self, domain, vertex_values=None): 21 21 22 from mesh import Mesh22 from mesh import Neighbour_mesh 23 23 from Numeric import array, zeros, Float 24 24 25 25 msg = 'First argument in Quantity.__init__ ' 26 msg += 'must be of class Mesh (or a subclass thereof)'27 assert isinstance(domain, Mesh), msg26 msg += 'must be of class Neighbour_mesh (or a subclass thereof)' 27 assert isinstance(domain, Neighbour_mesh), msg 28 28 29 29 if vertex_values is None: … … 196 196 geospatial_data: 197 197 Arbitrary geo spatial dataset in the form of the class 198 Geospatial_data. Mesh points are populated using least squares198 Geospatial_data. Neighbour_mesh points are populated using least squares 199 199 fitting 200 200 -
inundation/pyvolution/test_all.py
r2253 r2501 81 81 82 82 #Attempt to compile all extensions 83 execfile('..' + sep + 'utilities' + sep + 'compile.py')83 #execfile('..' + sep + 'utilities' + sep + 'compile.py') 84 84 85 85 #FIXME: Temporary measure 86 os.chdir('..' + sep + 'utilities')87 execfile('compile.py')88 os.chdir('..' + sep + 'pyvolution')86 #os.chdir('..' + sep + 'utilities') 87 #execfile('compile.py') 88 #os.chdir('..' + sep + 'pyvolution') 89 89 90 90 #FIXME: Temporary measure 91 os.chdir('..' + sep + 'triangle')92 execfile('compile.py')93 os.chdir('..' + sep + 'pyvolution')91 #os.chdir('..' + sep + 'triangle') 92 #execfile('compile.py') 93 #os.chdir('..' + sep + 'pyvolution') 94 94 95 95 #os.system('python compile.py') -
inundation/pyvolution/test_least_squares.py
r2281 r2501 817 817 818 818 def test_fit_and_interpolation(self): 819 from mesh import Mesh819 from mesh import Neighbour_mesh 820 820 821 821 a = [0.0, 0.0] … … 910 910 using another set of points. 911 911 """ 912 from mesh import Mesh912 from mesh import Neighbour_mesh 913 913 914 914 … … 1001 1001 """ 1002 1002 1003 from mesh import Mesh1003 from mesh import Neighbour_mesh 1004 1004 1005 1005 … … 1286 1286 coordinate system as defined by origin. 1287 1287 """ 1288 from mesh import Mesh1288 from mesh import Neighbour_mesh 1289 1289 1290 1290 #Setup mesh used to represent fitted function … … 1415 1415 from coordinate_transforms.geo_reference import Geo_reference 1416 1416 1417 # Mesh1417 #Neighbour_mesh 1418 1418 vertex_coordinates = [[0.76, 0.76], 1419 1419 [0.76, 5.76], -
inundation/pyvolution/test_mesh.py
r1911 r2501 16 16 return sqrt( sum( (array(x)-array(y))**2 )) 17 17 18 class Test_ Mesh(unittest.TestCase):18 class Test_Neighbour_mesh(unittest.TestCase): 19 19 def setUp(self): 20 20 pass … … 28 28 29 29 try: 30 mesh = Mesh(points, vertices)30 mesh = Neighbour_mesh(points, vertices) 31 31 except: 32 32 pass … … 44 44 points = [a, b, c] 45 45 vertices = [[0,1,2]] 46 mesh = Mesh(points, vertices)46 mesh = Neighbour_mesh(points, vertices) 47 47 48 48 #Centroid … … 140 140 points = [a, b, c, centroid] 141 141 vertices = [[0,3,2], [2,3,1], [1,3,0]] 142 new_mesh = Mesh(points, vertices)142 new_mesh = Neighbour_mesh(points, vertices) 143 143 144 144 assert new_mesh.areas[0] == new_mesh.areas[1] … … 158 158 vertices = [[0,1,2]] 159 159 160 mesh = Mesh(points, vertices)160 mesh = Neighbour_mesh(points, vertices) 161 161 centroid = mesh.centroid_coordinates[0] 162 162 … … 203 203 points = [a, b, c, centroid] 204 204 vertices = [[0,3,2], [2,3,1], [1,3,0]] 205 new_mesh = Mesh(points, vertices)205 new_mesh = Neighbour_mesh(points, vertices) 206 206 207 207 assert new_mesh.areas[0] == new_mesh.areas[1] … … 224 224 vertices = [[0,1,2]] 225 225 226 mesh = Mesh(points, vertices,use_inscribed_circle=False)226 mesh = Neighbour_mesh(points, vertices,use_inscribed_circle=False) 227 227 assert allclose(mesh.radii[0],sqrt(3.0)/3),'Steve''s doesn''t work' 228 228 229 mesh = Mesh(points, vertices,use_inscribed_circle=True)229 mesh = Neighbour_mesh(points, vertices,use_inscribed_circle=True) 230 230 assert allclose(mesh.radii[0],sqrt(3.0)/3),'inscribed circle doesn''t work' 231 231 … … 239 239 vertices = [[0,1,2]] 240 240 241 mesh = Mesh(points, vertices,use_inscribed_circle=False)241 mesh = Neighbour_mesh(points, vertices,use_inscribed_circle=False) 242 242 assert allclose(mesh.radii[0],5.0/6),'Steve''s doesn''t work' 243 243 244 mesh = Mesh(points, vertices,use_inscribed_circle=True)244 mesh = Neighbour_mesh(points, vertices,use_inscribed_circle=True) 245 245 assert allclose(mesh.radii[0],1.0),'inscribed circle doesn''t work' 246 246 … … 253 253 points = [a, b, c, e] 254 254 vertices = [ [1,0,2], [1,2,3] ] #bac, bce 255 mesh = Mesh(points, vertices)255 mesh = Neighbour_mesh(points, vertices) 256 256 257 257 assert mesh.areas[0] == 2.0 … … 277 277 #bac, bce, ecf, dbe, daf, dae 278 278 vertices = [ [1,0,2], [1,2,4], [4,2,5], [3,1,4]] 279 mesh = Mesh(points, vertices)279 mesh = Neighbour_mesh(points, vertices) 280 280 281 281 #Test that points are arranged in a counter clock wise order … … 309 309 #bac, bce, ecf, dbe 310 310 vertices = [ [1,0,2], [1,2,4], [4,2,5], [3,1,4] ] 311 mesh = Mesh(points, vertices)311 mesh = Neighbour_mesh(points, vertices) 312 312 313 313 mesh.check_integrity() … … 377 377 [5, 2, 3]] 378 378 try: 379 mesh = Mesh(points, triangles)379 mesh = Neighbour_mesh(points, triangles) 380 380 except: 381 381 pass … … 388 388 389 389 points, vertices, boundary = rectangular(M, N) 390 mesh = Mesh(points, vertices, boundary)390 mesh = Neighbour_mesh(points, vertices, boundary) 391 391 392 392 #Test that points are arranged in a counter clock wise order … … 396 396 N=2 397 397 points, vertices, boundary = rectangular(M, N) 398 mesh = Mesh(points, vertices, boundary)398 mesh = Neighbour_mesh(points, vertices, boundary) 399 399 400 400 #Test that points are arranged in a counter clock wise order … … 410 410 411 411 points, vertices, boundary = rectangular(4, 4) 412 mesh = Mesh(points, vertices, boundary)412 mesh = Neighbour_mesh(points, vertices, boundary) 413 413 414 414 … … 439 439 440 440 points, vertices, boundary = rectangular(M, N, len1, len2) 441 mesh = Mesh(points, vertices, boundary)441 mesh = Neighbour_mesh(points, vertices, boundary) 442 442 443 443 assert len(mesh) == 2*M*N … … 460 460 461 461 points, vertices, boundary = rectangular(2*N, N, len1=10, len2=10) 462 mesh = Mesh(points, vertices, boundary)462 mesh = Neighbour_mesh(points, vertices, boundary) 463 463 464 464 … … 476 476 #bac, bce, ecf, dbe 477 477 vertices = [ [1,0,2], [1,2,4], [4,2,5], [3,1,4] ] 478 mesh = Mesh(points, vertices)478 mesh = Neighbour_mesh(points, vertices) 479 479 mesh.check_integrity() 480 480 … … 527 527 528 528 529 mesh = Mesh(points, vertices, boundary)529 mesh = Neighbour_mesh(points, vertices, boundary) 530 530 mesh.check_integrity() 531 531 … … 559 559 560 560 561 mesh = Mesh(points, vertices, boundary)561 mesh = Neighbour_mesh(points, vertices, boundary) 562 562 mesh.check_integrity() 563 563 … … 592 592 593 593 594 mesh = Mesh(points, vertices) #, boundary)594 mesh = Neighbour_mesh(points, vertices) #, boundary) 595 595 mesh.check_integrity() 596 596 … … 629 629 #Too few points 630 630 try: 631 mesh = Mesh([points[0]], vertices)631 mesh = Neighbour_mesh([points[0]], vertices) 632 632 except AssertionError: 633 633 pass … … 637 637 #Too few points - 1 element 638 638 try: 639 mesh = Mesh([points[0]], [vertices[0]])639 mesh = Neighbour_mesh([points[0]], [vertices[0]]) 640 640 except AssertionError: 641 641 pass … … 645 645 #Wrong dimension of vertices 646 646 try: 647 mesh = Mesh(points, vertices[0])647 mesh = Neighbour_mesh(points, vertices[0]) 648 648 except AssertionError: 649 649 pass … … 653 653 #Unsubscriptable coordinates object raises exception 654 654 try: 655 mesh = Mesh(points[0], [vertices[0]])655 mesh = Neighbour_mesh(points[0], [vertices[0]]) 656 656 except AssertionError: 657 657 pass … … 664 664 #Not specifying all boundary tags 665 665 #try: 666 # mesh = Mesh(points, vertices, {(3,0): 'x'})666 # mesh = Neighbour_mesh(points, vertices, {(3,0): 'x'}) 667 667 #except AssertionError: 668 668 # pass … … 672 672 #Specifying wrong non existing segment 673 673 try: 674 mesh = Mesh(points, vertices, {(5,0): 'x'})674 mesh = Neighbour_mesh(points, vertices, {(5,0): 'x'}) 675 675 except AssertionError: 676 676 pass … … 705 705 def test_boundary_polygon(self): 706 706 from mesh_factory import rectangular 707 from mesh import Mesh707 from mesh import Neighbour_mesh 708 708 from Numeric import zeros, Float 709 709 710 710 #Create basic mesh 711 711 points, vertices, boundary = rectangular(2, 2) 712 mesh = Mesh(points, vertices, boundary)712 mesh = Neighbour_mesh(points, vertices, boundary) 713 713 714 714 … … 725 725 726 726 def test_boundary_polygon_II(self): 727 from mesh import Mesh727 from mesh import Neighbour_mesh 728 728 from Numeric import zeros, Float 729 729 … … 747 747 [4,3,6], [6,7,4], [6,5,8], [6,8,7]] 748 748 749 mesh = Mesh(points, vertices)749 mesh = Neighbour_mesh(points, vertices) 750 750 751 751 mesh.check_integrity() … … 765 765 """ 766 766 767 from mesh import Mesh767 from mesh import Neighbour_mesh 768 768 from Numeric import zeros, Float 769 769 … … 788 788 789 789 790 mesh = Mesh(points, vertices)790 mesh = Neighbour_mesh(points, vertices) 791 791 mesh.check_integrity() 792 792 … … 806 806 """ 807 807 808 from mesh import Mesh808 from mesh import Neighbour_mesh 809 809 from Numeric import zeros, Float 810 810 from mesh_factory import rectangular … … 816 816 817 817 ##### 818 mesh = Mesh(points, vertices)818 mesh = Neighbour_mesh(points, vertices) 819 819 mesh.check_integrity() 820 820 … … 829 829 830 830 ##### 831 mesh = Mesh(points, vertices, boundary)831 mesh = Neighbour_mesh(points, vertices, boundary) 832 832 mesh.check_integrity() 833 833 … … 847 847 #------------------------------------------------------------- 848 848 if __name__ == "__main__": 849 suite = unittest.makeSuite(Test_ Mesh,'test')849 suite = unittest.makeSuite(Test_Neighbour_mesh,'test') 850 850 runner = unittest.TextTestRunner() 851 851 runner.run(suite)
Note: See TracChangeset
for help on using the changeset viewer.