Changeset 601


Ignore:
Timestamp:
Nov 19, 2004, 12:42:44 PM (20 years ago)
Author:
ole
Message:

Allowed for internal boundaries (again:-)

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

Legend:

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

    r518 r601  
    242242                a, b = self.neighbours.shape
    243243                assert vol_id < a and edge_id < b, msg
    244                
    245                 msg = 'Segment (%d, %d) is not a boundary' %(vol_id, edge_id)
    246                 assert self.neighbours[vol_id, edge_id] < 0, msg
    247 
    248             #Check that all boundary segments are assigned a value
     244
     245                #FIXME: This assert violates internal boundaries (delete it)
     246                #msg = 'Segment (%d, %d) is not a boundary' %(vol_id, edge_id)
     247                #assert self.neighbours[vol_id, edge_id] < 0, msg
     248
     249            #Check that all boundary segments are assigned a tag
    249250            for vol_id in range(self.number_of_elements):
    250251                for edge_id in range(0, 3):
     
    259260                            #FIXME: Print only as per verbosity
    260261                            #print msg
     262
     263                            #FIXME: Make this situation an error in the future
     264                            #and make another function which will
     265                            #enable default boundary-tags where
     266                            #tags a not specified
    261267                            boundary[ (vol_id, edge_id) ] =\
    262268                                      default_boundary_tag
     
    429435        #NOTE: This assert doesn't hold true if there are internal boundaries
    430436        #FIXME: Look into this further.
    431         #for id, edge in self.boundary:
    432         #    assert self.neighbours[id,edge] < 0
    433 
    434 
     437        #FIXME: In mark 3 this seems to be OK, which I think is good.
     438        for id, edge in self.boundary:
     439            assert self.neighbours[id,edge] < 0
     440
     441
     442       
     443           
    435444    def get_centroid_coordinates(self):
    436445        """Return all centroid coordinates.
  • inundation/ga/storm_surge/pyvolution/test_mesh.py

    r598 r601  
    496496
    497497
    498     def test_boundary_inputs_using_defaults(self):
     498    def test_boundary_inputs_using_one_default(self):
    499499        a = [0.0, 0.0]
    500500        b = [0.0, 2.0]
     
    529529            assert mesh.neighbours[vol_id, edge_id] == b
    530530
     531    def test_boundary_inputs_using_all_defaults(self):
     532        a = [0.0, 0.0]
     533        b = [0.0, 2.0]
     534        c = [2.0,0.0]
     535        d = [0.0, 4.0]
     536        e = [2.0, 2.0]
     537        f = [4.0,0.0]
     538
     539        points = [a, b, c, d, e, f]
     540
     541        #bac, bce, ecf, dbe
     542        vertices = [ [1,0,2], [1,2,4], [4,2,5], [3,1,4] ]
     543
     544        boundary = { (0, 0): 'First',
     545                     (0, 2): 'Second',
     546                     (2, 0): 'Third',
     547                     (2, 1): 'Fourth',
     548                     #(3, 1): 'Fifth',  #Skip this
     549                     (3, 2): 'Sixth'}                                         
     550                     
     551       
     552        mesh = Mesh(points, vertices) #, boundary)       
     553        mesh.check_integrity()
     554
     555        from config import default_boundary_tag
     556        assert mesh.boundary[ (0, 0) ] == default_boundary_tag
     557        assert mesh.boundary[ (0, 2) ] == default_boundary_tag
     558        assert mesh.boundary[ (2, 0) ] == default_boundary_tag
     559        assert mesh.boundary[ (2, 1) ] == default_boundary_tag               
     560        assert mesh.boundary[ (3, 1) ] == default_boundary_tag
     561        assert mesh.boundary[ (3, 2) ] == default_boundary_tag               
     562
     563
     564        #Check enumeration
     565        for k, (vol_id, edge_id) in enumerate(mesh.boundary_segments):       
     566            b = -k-1
     567            assert mesh.neighbours[vol_id, edge_id] == b
     568
    531569
    532570
     
    579617            raise 'Should have raised an exception'
    580618
     619        #FIXME: This has been commented out pending a decision
     620        #whether to allow partial boundary tags or not
     621        #
    581622        #Not specifying all boundary tags
    582         try:
    583             mesh = Mesh(points, vertices, {(3,0): 'x'})       
    584         except AssertionError:
    585             pass
    586         else:
    587             raise 'Should have raised an exception'
     623        #try:
     624        #    mesh = Mesh(points, vertices, {(3,0): 'x'})       
     625        #except AssertionError:
     626        #    pass
     627        #else:
     628        #    raise 'Should have raised an exception'
    588629
    589630        #Specifying wrong non existing segment
     
    612653        boundary[(2,0)] = 'internal'
    613654        boundary[(1,0)] = 'internal'
    614        
     655
    615656        #Create shallow water domain
    616657        domain = Domain(points, vertices, boundary)
Note: See TracChangeset for help on using the changeset viewer.