Changeset 2501


Ignore:
Timestamp:
Mar 8, 2006, 6:30:00 PM (18 years ago)
Author:
ole
Message:

Renamed class Mesh (in pyvolution) to Neighbour_mesh because of possible
name clashes with class Mesh (pmesh). This was observed on some systems.

Location:
inundation/pyvolution
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • inundation/pyvolution/domain.py

    r2494 r2501  
    88"""
    99
    10 from mesh import Mesh
     10from mesh import Neighbour_mesh
    1111from generic_boundary_conditions import *
    1212import types
    1313
    14 class Domain(Mesh):
     14class Domain(Neighbour_mesh):
    1515
    1616    def __init__(self, coordinates, vertices, boundary = None,
     
    1919                 use_inscribed_circle=False):
    2020
    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)
    2323
    2424        from Numeric import zeros, Float, Int
     
    331331    #MISC
    332332    def check_integrity(self):
    333         Mesh.check_integrity(self)
     333        Neighbour_mesh.check_integrity(self)
    334334
    335335        for quantity in self.conserved_quantities:
  • inundation/pyvolution/least_squares.py

    r2447 r2501  
    2323#from general_mesh import General_mesh
    2424from Numeric import zeros, array, Float, Int, dot, transpose, concatenate, ArrayType
    25 from pyvolution.mesh import Mesh
     25from pyvolution.mesh import Neighbour_mesh
    2626
    2727from Numeric import zeros, take, array, Float, Int, dot, transpose, concatenate, ArrayType
     
    357357        else:
    358358            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)
    361361       
    362362        self.mesh.check_integrity()
  • inundation/pyvolution/mesh.py

    r1800 r2501  
    77from general_mesh import General_mesh
    88
    9 class Mesh(General_mesh):
    10     """Collection of triangular elements (purely geometric)
     9class Neighbour_mesh(General_mesh):
     10    """Collection of triangular elements (purely geometric) with neighbour structure
    1111
    1212    A triangular element is defined in terms of three vertex ids,
     
    2121
    2222    To instantiate:
    23        Mesh(coordinates, triangles)
     23       Neighbour_mesh(coordinates, triangles)
    2424
    2525    where
     
    4141        points = [a, b, c, e]
    4242        triangles = [ [1,0,2], [1,2,3] ]   #bac, bce
    43         mesh = Mesh(points, triangles)
     43        mesh = Neighbour_mesh(points, triangles)
    4444
    4545        #creates two triangles: bac and bce
    4646
    4747
    48     Mesh takes the optional third argument boundary which is a
     48    Neighbour_mesh takes the optional third argument boundary which is a
    4949    dictionary mapping from (element_id, edge_id) to boundary tag.
    5050    The default value is None which will assign the default_boundary_tag
     
    159159
    160160    def __repr__(self):
    161         return 'Mesh: %d triangles, %d elements, %d boundary segments'\
     161        return 'Neighbour_mesh: %d triangles, %d elements, %d boundary segments'\
    162162               %(self.coordinates.shape[0], len(self), len(self.boundary))
    163163
     
    490490        that area corresponds to edgelengths, that vertices
    491491        are arranged in a counter-clockwise order, etc etc
    492         Neighbour structure will be checked by class Mesh
     492        Neighbour structure will be checked by class Neighbour_mesh
    493493        """
    494494
  • inundation/pyvolution/quantity.py

    r2491 r2501  
    2020    def __init__(self, domain, vertex_values=None):
    2121
    22         from mesh import Mesh
     22        from mesh import Neighbour_mesh
    2323        from Numeric import array, zeros, Float
    2424
    2525        msg = 'First argument in Quantity.__init__ '
    26         msg += 'must be of class Mesh (or a subclass thereof)'
    27         assert isinstance(domain, Mesh), msg
     26        msg += 'must be of class Neighbour_mesh (or a subclass thereof)'
     27        assert isinstance(domain, Neighbour_mesh), msg
    2828
    2929        if vertex_values is None:
     
    196196        geospatial_data:
    197197          Arbitrary geo spatial dataset in the form of the class
    198           Geospatial_data. Mesh points are populated using least squares
     198          Geospatial_data. Neighbour_mesh points are populated using least squares
    199199          fitting           
    200200
  • inundation/pyvolution/test_all.py

    r2253 r2501  
    8181
    8282    #Attempt to compile all extensions
    83     execfile('..' + sep + 'utilities' + sep + 'compile.py')
     83    #execfile('..' + sep + 'utilities' + sep + 'compile.py')
    8484
    8585    #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')   
    8989   
    9090    #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')   
    9494   
    9595    #os.system('python compile.py')
  • inundation/pyvolution/test_least_squares.py

    r2281 r2501  
    817817
    818818    def test_fit_and_interpolation(self):
    819         from mesh import Mesh
     819        from mesh import Neighbour_mesh
    820820
    821821        a = [0.0, 0.0]
     
    910910        using another set of points.
    911911        """
    912         from mesh import Mesh
     912        from mesh import Neighbour_mesh
    913913
    914914
     
    10011001        """
    10021002       
    1003         from mesh import Mesh
     1003        from mesh import Neighbour_mesh
    10041004
    10051005
     
    12861286        coordinate system as defined by origin.
    12871287        """
    1288         from mesh import Mesh
     1288        from mesh import Neighbour_mesh
    12891289
    12901290        #Setup mesh used to represent fitted function
     
    14151415        from coordinate_transforms.geo_reference import Geo_reference
    14161416
    1417         #Mesh
     1417        #Neighbour_mesh
    14181418        vertex_coordinates = [[0.76, 0.76],
    14191419                              [0.76, 5.76],
  • inundation/pyvolution/test_mesh.py

    r1911 r2501  
    1616    return sqrt( sum( (array(x)-array(y))**2 ))
    1717
    18 class Test_Mesh(unittest.TestCase):
     18class Test_Neighbour_mesh(unittest.TestCase):
    1919    def setUp(self):
    2020        pass
     
    2828
    2929        try:
    30             mesh = Mesh(points, vertices)
     30            mesh = Neighbour_mesh(points, vertices)
    3131        except:
    3232            pass
     
    4444        points = [a, b, c]
    4545        vertices = [[0,1,2]]
    46         mesh = Mesh(points, vertices)
     46        mesh = Neighbour_mesh(points, vertices)
    4747
    4848        #Centroid
     
    140140        points = [a, b, c, centroid]
    141141        vertices = [[0,3,2], [2,3,1], [1,3,0]]
    142         new_mesh = Mesh(points, vertices)
     142        new_mesh = Neighbour_mesh(points, vertices)
    143143
    144144        assert new_mesh.areas[0] == new_mesh.areas[1]
     
    158158        vertices = [[0,1,2]]
    159159
    160         mesh = Mesh(points, vertices)
     160        mesh = Neighbour_mesh(points, vertices)
    161161        centroid = mesh.centroid_coordinates[0]
    162162
     
    203203        points = [a, b, c, centroid]
    204204        vertices = [[0,3,2], [2,3,1], [1,3,0]]
    205         new_mesh = Mesh(points, vertices)
     205        new_mesh = Neighbour_mesh(points, vertices)
    206206
    207207        assert new_mesh.areas[0] == new_mesh.areas[1]
     
    224224        vertices = [[0,1,2]]
    225225
    226         mesh = Mesh(points, vertices,use_inscribed_circle=False)
     226        mesh = Neighbour_mesh(points, vertices,use_inscribed_circle=False)
    227227        assert allclose(mesh.radii[0],sqrt(3.0)/3),'Steve''s doesn''t work'
    228228
    229         mesh = Mesh(points, vertices,use_inscribed_circle=True)
     229        mesh = Neighbour_mesh(points, vertices,use_inscribed_circle=True)
    230230        assert allclose(mesh.radii[0],sqrt(3.0)/3),'inscribed circle doesn''t work'
    231231
     
    239239        vertices = [[0,1,2]]
    240240
    241         mesh = Mesh(points, vertices,use_inscribed_circle=False)
     241        mesh = Neighbour_mesh(points, vertices,use_inscribed_circle=False)
    242242        assert allclose(mesh.radii[0],5.0/6),'Steve''s doesn''t work'
    243243
    244         mesh = Mesh(points, vertices,use_inscribed_circle=True)
     244        mesh = Neighbour_mesh(points, vertices,use_inscribed_circle=True)
    245245        assert allclose(mesh.radii[0],1.0),'inscribed circle doesn''t work'
    246246
     
    253253        points = [a, b, c, e]
    254254        vertices = [ [1,0,2], [1,2,3] ]   #bac, bce
    255         mesh = Mesh(points, vertices)
     255        mesh = Neighbour_mesh(points, vertices)
    256256
    257257        assert mesh.areas[0] == 2.0
     
    277277        #bac, bce, ecf, dbe, daf, dae
    278278        vertices = [ [1,0,2], [1,2,4], [4,2,5], [3,1,4]]
    279         mesh = Mesh(points, vertices)
     279        mesh = Neighbour_mesh(points, vertices)
    280280
    281281        #Test that points are arranged in a counter clock wise order
     
    309309        #bac, bce, ecf, dbe
    310310        vertices = [ [1,0,2], [1,2,4], [4,2,5], [3,1,4] ]
    311         mesh = Mesh(points, vertices)
     311        mesh = Neighbour_mesh(points, vertices)
    312312
    313313        mesh.check_integrity()
     
    377377                      [5, 2, 3]]
    378378        try:
    379             mesh = Mesh(points, triangles)
     379            mesh = Neighbour_mesh(points, triangles)
    380380        except:
    381381            pass
     
    388388
    389389        points, vertices, boundary = rectangular(M, N)
    390         mesh = Mesh(points, vertices, boundary)
     390        mesh = Neighbour_mesh(points, vertices, boundary)
    391391
    392392        #Test that points are arranged in a counter clock wise order
     
    396396        N=2
    397397        points, vertices, boundary = rectangular(M, N)
    398         mesh = Mesh(points, vertices, boundary)
     398        mesh = Neighbour_mesh(points, vertices, boundary)
    399399
    400400        #Test that points are arranged in a counter clock wise order
     
    410410
    411411        points, vertices, boundary = rectangular(4, 4)
    412         mesh = Mesh(points, vertices, boundary)
     412        mesh = Neighbour_mesh(points, vertices, boundary)
    413413
    414414
     
    439439
    440440        points, vertices, boundary = rectangular(M, N, len1, len2)
    441         mesh = Mesh(points, vertices, boundary)
     441        mesh = Neighbour_mesh(points, vertices, boundary)
    442442
    443443        assert len(mesh) == 2*M*N
     
    460460
    461461        points, vertices, boundary = rectangular(2*N, N, len1=10, len2=10)
    462         mesh = Mesh(points, vertices, boundary)
     462        mesh = Neighbour_mesh(points, vertices, boundary)
    463463
    464464
     
    476476        #bac, bce, ecf, dbe
    477477        vertices = [ [1,0,2], [1,2,4], [4,2,5], [3,1,4] ]
    478         mesh = Mesh(points, vertices)
     478        mesh = Neighbour_mesh(points, vertices)
    479479        mesh.check_integrity()
    480480
     
    527527
    528528
    529         mesh = Mesh(points, vertices, boundary)
     529        mesh = Neighbour_mesh(points, vertices, boundary)
    530530        mesh.check_integrity()
    531531
     
    559559
    560560
    561         mesh = Mesh(points, vertices, boundary)
     561        mesh = Neighbour_mesh(points, vertices, boundary)
    562562        mesh.check_integrity()
    563563
     
    592592
    593593
    594         mesh = Mesh(points, vertices) #, boundary)
     594        mesh = Neighbour_mesh(points, vertices) #, boundary)
    595595        mesh.check_integrity()
    596596
     
    629629        #Too few points
    630630        try:
    631             mesh = Mesh([points[0]], vertices)
     631            mesh = Neighbour_mesh([points[0]], vertices)
    632632        except AssertionError:
    633633            pass
     
    637637        #Too few points - 1 element
    638638        try:
    639             mesh = Mesh([points[0]], [vertices[0]])
     639            mesh = Neighbour_mesh([points[0]], [vertices[0]])
    640640        except AssertionError:
    641641            pass
     
    645645        #Wrong dimension of vertices
    646646        try:
    647             mesh = Mesh(points, vertices[0])
     647            mesh = Neighbour_mesh(points, vertices[0])
    648648        except AssertionError:
    649649            pass
     
    653653        #Unsubscriptable coordinates object raises exception
    654654        try:
    655             mesh = Mesh(points[0], [vertices[0]])
     655            mesh = Neighbour_mesh(points[0], [vertices[0]])
    656656        except AssertionError:
    657657            pass
     
    664664        #Not specifying all boundary tags
    665665        #try:
    666         #    mesh = Mesh(points, vertices, {(3,0): 'x'})
     666        #    mesh = Neighbour_mesh(points, vertices, {(3,0): 'x'})
    667667        #except AssertionError:
    668668        #    pass
     
    672672        #Specifying wrong non existing segment
    673673        try:
    674             mesh = Mesh(points, vertices, {(5,0): 'x'})
     674            mesh = Neighbour_mesh(points, vertices, {(5,0): 'x'})
    675675        except AssertionError:
    676676            pass
     
    705705    def test_boundary_polygon(self):
    706706        from mesh_factory import rectangular
    707         from mesh import Mesh
     707        from mesh import Neighbour_mesh
    708708        from Numeric import zeros, Float
    709709
    710710        #Create basic mesh
    711711        points, vertices, boundary = rectangular(2, 2)
    712         mesh = Mesh(points, vertices, boundary)
     712        mesh = Neighbour_mesh(points, vertices, boundary)
    713713
    714714
     
    725725
    726726    def test_boundary_polygon_II(self):
    727         from mesh import Mesh
     727        from mesh import Neighbour_mesh
    728728        from Numeric import zeros, Float
    729729       
     
    747747                     [4,3,6], [6,7,4], [6,5,8], [6,8,7]]
    748748
    749         mesh = Mesh(points, vertices)
     749        mesh = Neighbour_mesh(points, vertices)
    750750
    751751        mesh.check_integrity()
     
    765765        """
    766766
    767         from mesh import Mesh
     767        from mesh import Neighbour_mesh
    768768        from Numeric import zeros, Float
    769769
     
    788788
    789789
    790         mesh = Mesh(points, vertices)
     790        mesh = Neighbour_mesh(points, vertices)
    791791        mesh.check_integrity()
    792792
     
    806806        """
    807807
    808         from mesh import Mesh
     808        from mesh import Neighbour_mesh
    809809        from Numeric import zeros, Float
    810810        from mesh_factory import rectangular       
     
    816816
    817817        #####
    818         mesh = Mesh(points, vertices)
     818        mesh = Neighbour_mesh(points, vertices)
    819819        mesh.check_integrity()
    820820
     
    829829
    830830        #####
    831         mesh = Mesh(points, vertices, boundary)
     831        mesh = Neighbour_mesh(points, vertices, boundary)
    832832        mesh.check_integrity()
    833833
     
    847847#-------------------------------------------------------------
    848848if __name__ == "__main__":
    849     suite = unittest.makeSuite(Test_Mesh,'test')
     849    suite = unittest.makeSuite(Test_Neighbour_mesh,'test')
    850850    runner = unittest.TextTestRunner()
    851851    runner.run(suite)
Note: See TracChangeset for help on using the changeset viewer.