Changeset 3012
- Timestamp:
- May 30, 2006, 11:00:57 AM (19 years ago)
- Location:
- inundation
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/examples/bedslope_bsod_test.py
r2998 r3012 30 30 c3 = [331000, 6267000] 31 31 bound_poly = [c0, c1, c2, c3] 32 # duplicate point, this should fail, i.e. conjugate gradient doesn't converge33 #bound_poly = [c0, c1, c2, c3, c2]34 32 35 33 # set up internal region … … 40 38 interior_polygon = [p0, p1, p2, p3] 41 39 # duplicate point, this should fail, i.e. conjugate gradient doesn't converge 42 #interior_polygon = [p0, p1, p2, p3, p0]40 interior_polygon = [p0, p1, p2, p3, p0] 43 41 44 interior_regions = [[interior_polygon, 25000]] 42 interior_region_area = 2500000000 #25000 43 interior_regions = [[interior_polygon, interior_region_area]] 45 44 46 meshname = 'bedslope_bsod. msh'45 meshname = 'bedslope_bsod.tsh' 47 46 47 exterior_region_area = 10000000000000000 #100000 48 48 # create a mesh 49 49 _ = cache(create_mesh_from_regions, … … 51 51 {'boundary_tags': {'bottom': [0], 'right': [1], 52 52 'top': [2], 'left': [3]}, 53 'maximum_triangle_area': 100000,53 'maximum_triangle_area': exterior_region_area, 54 54 'filename': meshname, 55 55 'interior_regions': interior_regions}, -
inundation/fit_interpolate/fit.py
r2939 r3012 21 21 """ 22 22 23 from Numeric import zeros, Float, ArrayType 23 from Numeric import zeros, Float, ArrayType,take 24 24 25 25 from geospatial_data.geospatial_data import Geospatial_data, ensure_absolute … … 73 73 a mesh origin, since geospatial has its own mesh origin. 74 74 """ 75 76 75 # Initialise variabels 77 #self._A_can_be_reused = False78 #self._point_coordinates = None79 76 80 77 if alpha is None: … … 307 304 geo_reference=point_origin) 308 305 self.build_fit_subset(point_coordinates, z, verbose) 309 306 307 #FIXME: Move this down 310 308 #Check sanity 311 309 m = self.mesh.coordinates.shape[0] #Nbr of basis functions (1/vertex) … … 320 318 321 319 self._build_coefficient_matrix_B(verbose) 320 indexes = range(0,m) 321 loners = self.mesh.get_lone_vertices() 322 #print "loners",loners 323 loners.sort() 324 loners.reverse() 325 #print "loners",loners 326 for lone_index in loners: 327 indexes.pop(lone_index) 328 #print "fit self.Atz",take(self.Atz,indexes) 329 322 330 return conjugate_gradient(self.B, self.Atz, self.Atz, 323 331 imax=2*len(self.Atz) ) -
inundation/fit_interpolate/test_fit.py
r2939 r3012 804 804 os.remove(point_file) 805 805 806 807 def test_smooth_att_to_mesh_with_excess_verts(self): 808 809 a = [0.0, 0.0] 810 b = [0.0, 5.0] 811 c = [5.0, 0.0] 812 d = [1.0, 1.0] 813 e = [18.0, 1000.0] 814 815 points = [a, b, c, d, e] 816 triangles = [ [1,0,2] ] #bac 817 818 d1 = [1.0, 1.0] 819 d2 = [1.0, 2.0] 820 d3 = [3.0,1.0] 821 d4 = [2.0,3.0] 822 d5 = [2.0,2.0] 823 d6 = [1.0,3.0] 824 data_coords = [d1, d2, d3, d4, d5, d6] 825 z = linear_function(data_coords) 826 #print "z",z 827 828 interp = Fit(points, triangles, alpha=0.0) 829 f = interp.fit(data_coords, z) 830 answer = linear_function(points) 831 832 # Removing the bad verts that we don't care about 833 f = f[0:3] 834 answer = answer[0:3] 835 836 #print "f\n",f 837 #print "answer\n",answer 838 839 assert allclose(f, answer) 840 # Note: This test is iffy. Fit can fail if lone verts are inputted. 841 806 842 #------------------------------------------------------------- 807 843 if __name__ == "__main__": 808 844 suite = unittest.makeSuite(Test_Fit,'test') 809 #suite = unittest.makeSuite(Test_Fit,'test_smooth ing_and_interpolation')845 #suite = unittest.makeSuite(Test_Fit,'test_smooth_att_to_mesh_with_excess_verts') 810 846 #suite = unittest.makeSuite(Test_Fit,'test_smooth_attributes_to_mesh_one_point') 811 847 runner = unittest.TextTestRunner(verbosity=1) -
inundation/pyvolution/mesh.py
r2982 r3012 616 616 assert x < epsilon, msg 617 617 618 618 self.lone_vertices = [] 619 619 #Check that all vertices have been registered 620 620 for v_id, v in enumerate(self.vertexlist): 621 621 622 msg = 'Vertex %s does not belong to an element.'622 #msg = 'Vertex %s does not belong to an element.' 623 623 #assert v is not None, msg 624 624 if v is None: 625 print msg%v_id 625 #print msg%v_id 626 self.lone_vertices.append(v_id) 626 627 627 628 #Check integrity of neighbour structure … … 673 674 #See domain.set_boundary 674 675 676 def get_lone_vertices(self): 677 """Return a list of vertices that are not connected to any triangles. 678 679 Precondition 680 FIXME(DSG - DSG) Pull the code out of check integrity that builds this 681 structure. 682 check_integrity has to have been called. 683 """ 684 return self.lone_vertices 675 685 676 686 def get_centroid_coordinates(self): -
inundation/pyvolution/test_mesh.py
r2709 r3012 912 912 913 913 914 915 def test_lone_vertices(self): 916 a = [2.0, 1.0] 917 b = [6.0, 2.0] 918 c = [1.0, 3.0] 919 d = [2.0, 4.0] 920 921 points = [a, b, c, d] 922 vertices = [[0,1,2]] 923 924 mesh = Mesh(points, vertices) 925 mesh.check_integrity() 926 loners = mesh.get_lone_vertices() 927 self.failUnless(loners==[3], 928 'FAILED!') 929 930 931 a = [2.0, 1.0] 932 b = [6.0, 2.0] 933 c = [1.0, 3.0] 934 d = [2.0, 4.0] 935 936 points = [d, a, b, c] 937 vertices = [[3,1,2]] 938 939 mesh = Mesh(points, vertices) 940 mesh.check_integrity() 941 loners = mesh.get_lone_vertices() 942 self.failUnless(loners==[0], 943 'FAILED!') 944 914 945 #------------------------------------------------------------- 915 946 if __name__ == "__main__": 916 suite = unittest.makeSuite(Test_Mesh,'test_boundary_polygon')917 #suite = unittest.makeSuite(Test_Mesh,'test')947 #suite = unittest.makeSuite(Test_Mesh,'test_boundary_polygon') 948 suite = unittest.makeSuite(Test_Mesh,'test') 918 949 runner = unittest.TextTestRunner() 919 950 runner.run(suite)
Note: See TracChangeset
for help on using the changeset viewer.