Changeset 1158


Ignore:
Timestamp:
Mar 29, 2005, 4:19:37 PM (19 years ago)
Author:
duncan
Message:

throw exception if edges are duplicated.

Location:
inundation/ga/storm_surge/pyvolution
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • inundation/ga/storm_surge/pyvolution/least_squares.py

    r1154 r1158  
    305305        self.mesh = Mesh(vertex_coordinates, triangles,
    306306                         origin = mesh_origin)
     307        #FIXME, remove if mesh checks it.
     308        self.mesh.check_integrity()
    307309        self.data_origin = data_origin
    308310
  • inundation/ga/storm_surge/pyvolution/mesh.py

    r1011 r1158  
    133133        #self.build_boundary_structure()       
    134134
     135        #FIXME check integrity?
    135136       
    136137    def __repr__(self):
     
    161162            a = self.triangles[i, 0]
    162163            b = self.triangles[i, 1]
    163             c = self.triangles[i, 2]           
     164            c = self.triangles[i, 2]
     165            if neighbourdict.has_key((a,b)):
     166                    msg = "Edge 2 of triangle %d is duplicating edge %d of triangle %d.\n" %(i,neighbourdict[a,b][1],neighbourdict[a,b][0])
     167                    raise msg
     168            if neighbourdict.has_key((b,c)):
     169                    msg = "Edge 0 of triangle %d is duplicating edge %d of triangle %d.\n" %(i,neighbourdict[b,c][1],neighbourdict[b,c][0])
     170                    raise msg
     171            if neighbourdict.has_key((c,a)):
     172                    msg = "Edge 1 of triangle %d is duplicating edge %d of triangle %d.\n" %(i,neighbourdict[c,a][1],neighbourdict[c,a][0])
     173                    raise msg
     174                   
    164175            neighbourdict[a,b] = (i, 2) #(id, edge)
    165176            neighbourdict[b,c] = (i, 0) #(id, edge)
     
    472483            msg = 'Some points do not belong to an element.\n'
    473484            msg += 'Make sure all points appear as element vertices!'
    474             if v is None:
    475                 print 'WARNING (mesh.py): %s' %msg
    476                 break
    477 
    478 
    479                
     485            assert v is not None, msg
     486           
    480487        #Check integrity of neighbour structure
    481488        for i in range(N):
     
    498505                if neighbour_id >= 0:
    499506                    edge = self.neighbour_edges[i, k]
    500                     assert self.neighbours[neighbour_id, edge] == i
     507                    msg = 'Triangle %d has neighbour %d but it does not point back. \n' %(i,neighbour_id)
     508                    msg += 'Only points to (%s)' %(self.neighbours[neighbour_id,:])
     509                    assert self.neighbours[neighbour_id, edge] == i ,msg
    501510
    502511
  • inundation/ga/storm_surge/pyvolution/test_advection.py

    r1150 r1158  
    2626        points = [a, b, c, d, e, f]
    2727        #bac, bce, ecf, dbe, daf, dae
    28         vertices = [ [1,0,2], [1,2,4], [4,2,5], [3,1,4], [3,0,5], [3,0,4]]
     28        vertices = [ [1,0,2], [1,2,4], [4,2,5], [3,1,4]]
    2929
    3030        domain = Domain(points, vertices)
  • inundation/ga/storm_surge/pyvolution/test_domain.py

    r1018 r1158  
    5151        points = [a, b, c, d, e, f]
    5252        #bac, bce, ecf, dbe, daf, dae
    53         vertices = [ [1,0,2], [1,2,4], [4,2,5], [3,1,4], [3,0,5], [3,0,4]]
     53        vertices = [ [1,0,2], [1,2,4], [4,2,5], [3,1,4]]
    5454
    5555        conserved_quantities = ['stage', 'xmomentum', 'ymomentum']
     
    7878        points = [a, b, c, d, e, f]
    7979        #bac, bce, ecf, dbe, daf, dae
    80         vertices = [ [1,0,2], [1,2,4], [4,2,5], [3,1,4], [3,0,5], [3,0,4]]
     80        vertices = [ [1,0,2], [1,2,4], [4,2,5], [3,1,4]]
    8181
    8282        domain = Domain(points, vertices, boundary=None,
     
    8686
    8787        domain.set_quantity('stage', [[1,2,3], [5,5,5],
    88                                       [0,0,9], [-6, 3, 3],
    89                                       [0,0,0], [0,0,0]])
     88                                      [0,0,9], [-6, 3, 3]])
    9089
    9190        domain.set_quantity('xmomentum', [[1,2,3], [5,5,5],
    92                                           [0,0,9], [-6, 3, 3],
    93                                           [0,0,0], [0,0,0]])
     91                                          [0,0,9], [-6, 3, 3]])
    9492
    9593        domain.check_integrity()
  • inundation/ga/storm_surge/pyvolution/test_least_squares.py

    r1097 r1158  
    201201                      [3, 2, 1],
    202202                      [0, 2, 4],
    203                       [0, 2, 4],
    204203                      [4, 2, 5],
    205204                      [5, 2, 3]]
     
    534533
    535534        vertices = [a, b, c, d]
    536         triangles = [ [1,0,2], [2,3,0] ]   #bac, cdb
     535        triangles = [ [1,0,2], [2,3,1] ]   #bac, cdb
    537536
    538537        #Points within triangle 1
  • inundation/ga/storm_surge/pyvolution/test_mesh.py

    r1018 r1158  
    241241        points = [a, b, c, d, e, f]
    242242        #bac, bce, ecf, dbe, daf, dae
    243         vertices = [ [1,0,2], [1,2,4], [4,2,5], [3,1,4], [3,0,5], [3,0,4]]
     243        vertices = [ [1,0,2], [1,2,4], [4,2,5], [3,1,4]]
    244244        mesh = Mesh(points, vertices)
    245245
     
    251251        assert mesh.areas[2] == 2.0
    252252        assert mesh.areas[3] == 2.0
    253         assert mesh.areas[4] == 8.0
    254         assert mesh.areas[5] == 4.0
    255253
    256254        assert mesh.edgelengths[1,0] == 2.0
     
    262260        assert allclose(mesh.centroid_coordinates[2], [8.0/3, 2.0/3])
    263261        assert allclose(mesh.centroid_coordinates[3], [2.0/3, 8.0/3])
    264 
    265262
    266263    def test_mesh_and_neighbours(self):
     
    329326
    330327
     328    def test_build_neighbour_structure_duplicates(self):
     329        p0 = [-66.0, 14.0]
     330        p1 = [14.0, -66.0]
     331        p2 = [14.0, 14.0]
     332        p3 = [60.0, 20.0]
     333        p4 = [10.0, 60.0]
     334        p5 = [60.0, 60.0]
     335
     336        points = [p0, p1, p2, p3, p4, p5]
     337        triangles = [ [0, 1, 2],
     338                      [3, 2, 1],
     339                      [0, 2, 4],
     340                      [0, 2, 4],
     341                      [4, 2, 5],
     342                      [5, 2, 3]]
     343        try:
     344            mesh = Mesh(points, triangles)
     345        except:
     346            pass
     347        else:
     348            raise "triangle edge duplicates not caught"
     349               
    331350    def test_rectangular_mesh_basic(self):
    332351        M=1
  • inundation/ga/storm_surge/pyvolution/test_shallow_water.py

    r1027 r1158  
    197197        points = [a, b, c, d, e, f]
    198198        #bac, bce, ecf, dbe, daf, dae
    199         vertices = [ [1,0,2], [1,2,4], [4,2,5], [3,1,4], [3,0,5], [3,0,4]]
     199        vertices = [ [1,0,2], [1,2,4], [4,2,5], [3,1,4]]
    200200
    201201        domain = Domain(points, vertices)
Note: See TracChangeset for help on using the changeset viewer.