Changeset 8699
- Timestamp:
- Feb 15, 2013, 10:28:56 AM (12 years ago)
- Location:
- trunk/anuga_core
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_core/source/anuga/__init__.py
r8690 r8699 117 117 from anuga.file_conversion.ferret2sww import ferret2sww 118 118 from anuga.file_conversion.dem2dem import dem2dem 119 from anuga.file_conversion.sww2 png import sww2png119 from anuga.file_conversion.sww2array import sww2array 120 120 121 121 -
trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/neighbour_mesh.py
r8592 r8699 740 740 V = self.get_vertex_coordinates() 741 741 742 # Check each triangle 743 for i in xrange(N): 744 745 x0, y0 = V[3*i, :] 746 x1, y1 = V[3*i+1, :] 747 x2, y2 = V[3*i+2, :] 748 749 # Check that area hasn't been compromised 750 area = self.areas[i] 751 ref = -((x1*y0-x0*y1)+(x2*y1-x1*y2)+(x0*y2-x2*y0))/2 752 msg = 'Triangle %i (%f,%f), (%f,%f), (%f, %f)' % (i, x0,y0,x1,y1,x2,y2) 753 msg += 'Wrong area: %f %f'\ 754 %(area, ref) 755 assert abs((area - ref)/area) < epsilon, msg 756 757 msg = 'Triangle %i (%f,%f), (%f,%f), (%f, %f)' % (i, x0,y0,x1,y1,x2,y2) 758 msg += ' is degenerate: area == %f' % self.areas[i] 759 assert area > 0.0, msg 760 761 # Check that points are arranged in counter clock-wise order 762 v0 = [x1-x0, y1-y0] 763 v1 = [x2-x1, y2-y1] 764 v2 = [x0-x2, y0-y2] 765 a0 = anglediff(v1, v0) 766 a1 = anglediff(v2, v1) 767 a2 = anglediff(v0, v2) 768 769 msg = '''Vertices (%s,%s), (%s,%s), (%s,%s) are not arranged 770 in counter clockwise order''' %(x0, y0, x1, y1, x2, y2) 771 assert a0 < pi and a1 < pi and a2 < pi, msg 772 773 # Check that normals are orthogonal to edge vectors 774 # Note that normal[k] lies opposite vertex k 775 776 normal0 = self.normals[i, 0:2] 777 normal1 = self.normals[i, 2:4] 778 normal2 = self.normals[i, 4:6] 779 780 for u, v in [ (v0, normal2), (v1, normal0), (v2, normal1) ]: 781 782 # Normalise 783 l_u = num.sqrt(u[0]*u[0] + u[1]*u[1]) 784 l_v = num.sqrt(v[0]*v[0] + v[1]*v[1]) 785 786 msg = 'Normal vector in triangle %d does not have unit length' %i 787 assert num.allclose(l_v, 1), msg 788 789 x = (u[0]*v[0] + u[1]*v[1])/l_u # Inner product 790 791 msg = 'Normal vector (%f,%f) is not perpendicular to' %tuple(v) 792 msg += ' edge (%f,%f) in triangle %d.' %(tuple(u) + (i,)) 793 msg += ' Inner product is %e.' %x 794 assert x < epsilon, msg 742 # # Check each triangle 743 # for i in xrange(0): 744 # 745 # x0, y0 = V[3*i, :] 746 # x1, y1 = V[3*i+1, :] 747 # x2, y2 = V[3*i+2, :] 748 # 749 # # Check that area hasn't been compromised 750 # area = self.areas[i] 751 # ref = -((x1*y0-x0*y1)+(x2*y1-x1*y2)+(x0*y2-x2*y0))/2 752 # msg = 'Triangle %i (%f,%f), (%f,%f), (%f, %f)' % (i, x0,y0,x1,y1,x2,y2) 753 # msg += 'Wrong area: %f %f'\ 754 # %(area, ref) 755 # assert abs((area - ref)/area) < epsilon, msg 756 # 757 # msg = 'Triangle %i (%f,%f), (%f,%f), (%f, %f)' % (i, x0,y0,x1,y1,x2,y2) 758 # msg += ' is degenerate: area == %f' % self.areas[i] 759 # assert area > 0.0, msg 760 # 761 # # Check that points are arranged in counter clock-wise order 762 # v0 = [x1-x0, y1-y0] 763 # v1 = [x2-x1, y2-y1] 764 # v2 = [x0-x2, y0-y2] 765 # a0 = anglediff(v1, v0) 766 # a1 = anglediff(v2, v1) 767 # a2 = anglediff(v0, v2) 768 # 769 # msg = '''Vertices (%s,%s), (%s,%s), (%s,%s) are not arranged 770 # in counter clockwise order''' %(x0, y0, x1, y1, x2, y2) 771 # assert a0 < pi and a1 < pi and a2 < pi, msg 772 # 773 # # Check that normals are orthogonal to edge vectors 774 # # Note that normal[k] lies opposite vertex k 775 # 776 # normal0 = self.normals[i, 0:2] 777 # normal1 = self.normals[i, 2:4] 778 # normal2 = self.normals[i, 4:6] 779 # 780 # for u, v in [ (v0, normal2), (v1, normal0), (v2, normal1) ]: 781 # 782 # # Normalise 783 # l_u = num.sqrt(u[0]*u[0] + u[1]*u[1]) 784 # l_v = num.sqrt(v[0]*v[0] + v[1]*v[1]) 785 # 786 # msg = 'Normal vector in triangle %d does not have unit length' %i 787 # assert num.allclose(l_v, 1), msg 788 # 789 # x = (u[0]*v[0] + u[1]*v[1])/l_u # Inner product 790 # 791 # msg = 'Normal vector (%f,%f) is not perpendicular to' %tuple(v) 792 # msg += ' edge (%f,%f) in triangle %d.' %(tuple(u) + (i,)) 793 # msg += ' Inner product is %e.' %x 794 # assert x < epsilon, msg 795 796 797 # let's try numpy constructs 798 799 x0 = V[0::3, 0] 800 y0 = V[0::3, 1] 801 x1 = V[1::3, 0] 802 y1 = V[1::3, 1] 803 x2 = V[2::3, 0] 804 y2 = V[2::3, 1] 805 806 #print 'check areas' 807 area = self.areas 808 809 ref = -((x1*y0-x0*y1)+(x2*y1-x1*y2)+(x0*y2-x2*y0))/2 810 811 812 813 assert num.sum(num.abs((area - ref)/area)) < epsilon, 'Error in areas' 814 815 assert num.all(area > 0.0), 'A negative area' 816 817 818 tx0 = x2 - x1 819 ty0 = y2 - y1 820 tx1 = x0 - x2 821 ty1 = y0 - y2 822 tx2 = x1 - x0 823 ty2 = y1 - y0 824 825 nx0 = self.normals[:,0] 826 ny0 = self.normals[:,1] 827 nx1 = self.normals[:,2] 828 ny1 = self.normals[:,3] 829 nx2 = self.normals[:,4] 830 ny2 = self.normals[:,5] 831 832 #print nx0.shape 833 #print tx0.shape 834 #print ny0.shape 835 #print ty0.shape 836 837 838 #print 'check edge |_ to normals' 839 assert num.all(tx0*nx0 + ty0*ny0 < epsilon), 'Normal not perpendicular to edge' 840 assert num.all(tx1*nx1 + ty1*ny1 < epsilon), 'Normal not perpendicular to edge' 841 assert num.all(tx2*nx2 + ty2*ny2 < epsilon), 'Normal not perpendicular to edge' 842 843 844 #print 'check normals are unit length' 845 assert num.all(num.abs(nx0**2 + ny0**2 - 1) < epsilon), 'Normal are not normalised' 846 assert num.all(num.abs(nx1**2 + ny1**2 - 1) < epsilon), 'Normal are not normalised' 847 assert num.all(num.abs(nx2**2 + ny2**2 - 1) < epsilon), 'Normal are not normalised' 848 849 850 851 852 #print 'check neighbours' 853 854 # 0 neighbours 855 neighs = self.neighbours 856 nids = neighs[:,0] 857 eids = self.neighbour_edges[:,0] 858 859 ids = num.arange(len(nids)) 860 nnid = num.where(nids>-1, 3*nids+eids, 0) 861 862 #assert num.all(num.where(nids>-1, neighs[nnid]-ids, 0)==0) 863 864 865 795 866 796 867 -
trunk/anuga_core/source/anuga/fit_interpolate/fit.py
r8697 r8699 580 580 581 581 # This is very slow! 582 #mesh.check_integrity()582 mesh.check_integrity() 583 583 584 584 interp = Fit(mesh=mesh, -
trunk/anuga_core/source/anuga/pmesh/mesh_interface.py
r8505 r8699 358 358 verbose=verbose) 359 359 m.export_mesh_file(filename) 360 361 return m 360 362 -
trunk/anuga_core/validation_tests/Tests/Case_studies/Okushiri/create_okushiri.py
r8695 r8699 170 170 use_cache=False, 171 171 verbose=True) 172 173 172 174 173 175 if elevation_in_mesh is True:
Note: See TracChangeset
for help on using the changeset viewer.