Changeset 3945


Ignore:
Timestamp:
Nov 8, 2006, 5:35:23 PM (17 years ago)
Author:
ole
Message:

One large step towards major cleanup. This has mainly to do with
the way vertex coordinates are handled internally.

Location:
anuga_core/source/anuga
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/abstract_2d_finite_volumes/general_mesh.py

    r3928 r3945  
    66
    77class General_mesh:
    8     """Collection of triangular elements (purely geometric)
     8    """Collection of 2D triangular elements
    99
    1010    A triangular element is defined in terms of three vertex ids,
    11     ordered counter clock-wise,
    12     each corresponding to a given coordinate set.
    13     Vertices from different elements can point to the same
    14     coordinate set.
    15 
    16     Coordinate sets are implemented as an N x 2 Numeric array containing
     11    ordered counter clock-wise, each corresponding to a given node
     12    which is represented as a coordinate set (x,y).
     13    Vertices from different triangles can point to the same node.
     14    The nodes are implemented as an Nx2 Numeric array containing the
    1715    x and y coordinates.
    1816
    1917
    2018    To instantiate:
    21        Mesh(coordinates, triangles)
     19       Mesh(nodes, triangles)
    2220
    2321    where
    2422
    25       coordinates is either a list of 2-tuples or an Mx2 Numeric array of
     23      nodes is either a list of 2-tuples or an Nx2 Numeric array of
    2624      floats representing all x, y coordinates in the mesh.
    2725
    28       triangles is either a list of 3-tuples or an Nx3 Numeric array of
     26      triangles is either a list of 3-tuples or an Mx3 Numeric array of
    2927      integers representing indices of all vertices in the mesh.
    30       Each vertex is identified by its index i in [0, M-1].
     28      Each vertex is identified by its index i in [0, N-1].
    3129
    3230
    3331    Example:
     32
    3433        a = [0.0, 0.0]
    3534        b = [0.0, 2.0]
     
    3736        e = [2.0, 2.0]
    3837
    39         points = [a, b, c, e]
    40         triangles = [ [1,0,2], [1,2,3] ]   #bac, bce
    41         mesh = Mesh(points, triangles)
    42 
    43         #creates two triangles: bac and bce
     38        nodes = [a, b, c, e]
     39        triangles = [ [1,0,2], [1,2,3] ]   # bac, bce
     40
     41        # Create mesh with two triangles: bac and bce   
     42        mesh = Mesh(nodes, triangles)
     43
     44
    4445
    4546    Other:
    4647
    47       In addition mesh computes an Nx6 array called vertex_coordinates.
     48      In addition mesh computes an Mx6 array called vertex_coordinates.
    4849      This structure is derived from coordinates and contains for each
    4950      triangle the three x,y coordinates at the vertices.
    5051
    51 
    52         This is a cut down version of mesh from mesh.py
     52      See neighbourmesh.py for a specialisation of the general mesh class
     53      which includes information about neighbours and the mesh boundary.
     54
     55      The mesh object is purely geometrical and contains no information
     56      about quantities defined on the mesh.
     57
    5358    """
    5459
    5560    #FIXME: It would be a good idea to use geospatial data as an alternative
    5661    #input
    57     def __init__(self, coordinates, triangles,
     62    def __init__(self, nodes, triangles,
     63                 geo_reference=None,                 
    5864                 number_of_full_nodes=None,
    5965                 number_of_full_triangles=None,                 
    60                  geo_reference=None,
    6166                 verbose=False):
    62         """
    63         Build triangles from x,y coordinates (sequence of 2-tuples or
    64         Mx2 Numeric array of floats) and triangles (sequence of 3-tuples
    65         or Nx3 Numeric array of non-negative integers).
    66 
    67         origin is a 3-tuple consisting of UTM zone, easting and northing.
    68         If specified coordinates are assumed to be relative to this origin.
     67        """Build triangular 2d mesh from nodes and triangle information
     68
     69        Input:
     70       
     71          nodes: x,y coordinates represented as a sequence of 2-tuples or
     72                 a Nx2 Numeric array of floats.
     73                 
     74          triangles: sequence of 3-tuples or Mx3 Numeric array of
     75                     non-negative integers representing indices into
     76                     the nodes array.
     77       
     78          georeference (optional): If specified coordinates are
     79          assumed to be relative to this origin.
    6980
    7081
     
    7485        In this case it is usefull to specify the number of real (called full)
    7586        nodes and triangles. If omitted they will default to all.
     87         
    7688        """
    7789
    7890        if verbose: print 'General_mesh: Building basic mesh structure'
    7991
    80         self.triangles = array(triangles,Int)
    81         self.coordinates = array(coordinates,Float)
     92        self.triangles = array(triangles, Int)
     93        self.nodes = array(nodes, Float)
     94
    8295
    8396        # Register number of elements and nodes
    8497        self.number_of_triangles = N = self.triangles.shape[0]
    85         self.number_of_nodes = self.coordinates.shape[0]       
     98        self.number_of_nodes = self.nodes.shape[0]       
    8699
    87100       
    88101
    89102        if number_of_full_nodes is None:
    90             self.number_of_full_nodes=self.number_of_nodes
     103            self.number_of_full_nodes = self.number_of_nodes
    91104        else:
    92105            assert int(number_of_full_nodes)
    93             self.number_of_full_nodes=number_of_full_nodes           
     106            self.number_of_full_nodes = number_of_full_nodes           
    94107
    95108
    96109        if number_of_full_triangles is None:
    97             self.number_of_full_triangles=self.number_of_triangles           
     110            self.number_of_full_triangles = self.number_of_triangles           
    98111        else:
    99112            assert int(number_of_full_triangles)           
    100             self.number_of_full_triangles=number_of_full_triangles
     113            self.number_of_full_triangles = number_of_full_triangles
    101114       
    102115       
     
    114127
    115128        # Input checks
    116         msg = 'Triangles must an Nx3 Numeric array or a sequence of 3-tuples. '
     129        msg = 'Triangles must an Mx3 Numeric array or a sequence of 3-tuples. '
    117130        msg += 'The supplied array has the shape: %s'\
    118131               %str(self.triangles.shape)
    119132        assert len(self.triangles.shape) == 2, msg
    120133
    121         msg = 'Coordinates must an Mx2 Numeric array or a sequence of 2-tuples'
     134        msg = 'Nodes must an Nx2 Numeric array or a sequence of 2-tuples'
    122135        msg += 'The supplied array has the shape: %s'\
    123                %str(self.coordinates.shape)
    124         assert len(self.coordinates.shape) == 2, msg
     136               %str(self.nodes.shape)
     137        assert len(self.nodes.shape) == 2, msg
    125138
    126139        msg = 'Vertex indices reference non-existing coordinate sets'
    127         assert max(max(self.triangles)) <= self.coordinates.shape[0], msg
     140        assert max(max(self.triangles)) <= self.nodes.shape[0], msg
    128141
    129142
    130143        # FIXME: Maybe move to statistics?
    131144        # Or use with get_extent
    132         xy_extent = [ min(self.coordinates[:,0]), min(self.coordinates[:,1]) ,
    133                       max(self.coordinates[:,0]), max(self.coordinates[:,1]) ]
     145        xy_extent = [ min(self.nodes[:,0]), min(self.nodes[:,1]) ,
     146                      max(self.nodes[:,0]), max(self.nodes[:,1]) ]
    134147
    135148        self.xy_extent = array(xy_extent, Float)
     
    152165            if verbose and i % ((N+10)/10) == 0: print '(%d/%d)' %(i, N)
    153166           
    154 
    155             x0 = V[i, 0]; y0 = V[i, 1]
    156             x1 = V[i, 2]; y1 = V[i, 3]
    157             x2 = V[i, 4]; y2 = V[i, 5]
     167            x0, y0 = V[3*i, :]
     168            x1, y1 = V[3*i+1, :]
     169            x2, y2 = V[3*i+2, :]           
    158170
    159171            # Area
     
    210222    def __repr__(self):
    211223        return 'Mesh: %d vertices, %d triangles'\
    212                %(self.coordinates.shape[0], len(self))
     224               %(self.nodes.shape[0], len(self))
    213225
    214226    def get_normals(self):
     
    227239
    228240
    229 
    230     def get_vertex_coordinates(self, unique=False, obj=False, absolute=False):
    231         """Return all vertex coordinates.
    232         Return all vertex coordinates for all triangles as an Nx6 array
    233         (ordered as x0, y0, x1, y1, x2, y2 for each triangle)
    234 
    235         if obj is True, the x/y pairs are returned in a 3*N x 2 array.
    236         FIXME, we might make that the default.
    237         FIXME Maybe use keyword: continuous = False for this condition?
    238         FIXME - Maybe use something referring to unique vertices?
     241    def get_nodes(self, absolute=False):
     242        """Return all node coordinates ordered in an Nx2 array.
     243        This is the same format they were provided in the constructor
     244        i.e. without any duplication.
    239245
    240246        Boolean keyword argument absolute determines whether coordinates
    241247        are to be made absolute by taking georeference into account
    242248        Default is False as many parts of ANUGA expects relative coordinates.
    243         (To see which, switch to default absolute=True and run tests).
     249        (To see which, switch to default absolute=True and run tests).       
    244250        """
    245251
    246252        N = self.number_of_full_nodes
    247 
    248         if unique is True:
    249             V = self.coordinates[:N,:]
    250             if absolute is True:
    251                 if not self.geo_reference.is_absolute():
    252                     V = self.geo_reference.get_absolute(V)
    253 
    254             return V
    255 
     253        V = self.nodes[:N,:]
     254        if absolute is True:
     255            if not self.geo_reference.is_absolute():
     256                V = self.geo_reference.get_absolute(V)
    256257               
    257 
     258        return V
     259       
     260       
     261
     262    def get_vertex_coordinates(self, unique=False, absolute=False):
     263        """Return all vertex coordinates.
     264        Return all vertex coordinates for all triangles as a 3*N x 2 array
     265        where the jth vertex of the ith triangle is located in row 3*i+j.
     266
     267        Boolean keyword unique will cause the points to be returned as
     268        they were provided in the constructor i.e. without any duplication
     269        in an N x 2 array.
     270
     271        """
     272
     273        if unique is True:       
     274            return self.get_nodes(absolute)
     275
     276           
    258277        V = self.vertex_coordinates
    259278        if absolute is True:
    260279            if not self.geo_reference.is_absolute():
     280                V = self.geo_reference.get_absolute(V)
    261281           
    262                 V0 = self.geo_reference.get_absolute(V[:N,0:2])
    263                 V1 = self.geo_reference.get_absolute(V[:N,2:4])
    264                 V2 = self.geo_reference.get_absolute(V[:N,4:6])
    265 
    266                 # This does double the memory need
    267                 V = concatenate( (V0, V1, V2), axis=1 )
    268 
    269                
    270         if obj is True:
    271             N = V.shape[0]
    272             return reshape(V, (3*N, 2))
    273         else:   
    274             return V
     282        return V
     283
    275284
    276285
     
    281290
    282291        V = self.get_vertex_coordinates(absolute=absolute)
    283         return V[i, 2*j:2*j+2]
    284    
    285         ##return self.vertex_coordinates[i, 2*j:2*j+2]
     292        return V[3*i+j, :]
    286293
    287294
    288295    def compute_vertex_coordinates(self):
    289         """Return vertex coordinates for all triangles as an Nx6 array
    290         (ordered as x0, y0, x1, y1, x2, y2 for each triangle)
    291         """
    292 
    293         #FIXME (Ole): Perhaps they should be ordered as in obj files??
    294         #See quantity.get_vertex_values
    295         #FIXME (Ole) - oh yes they should
     296        """Return all vertex coordinates for all triangles as a 3*N x 2 array
     297        where the jth vertex of the ith triangle is located in row 3*i+j.
     298
     299        This function is used to precompute this important structure. Use
     300        get_vertex coordinates to retrieve the points.
     301        """
    296302
    297303        N = self.number_of_triangles
    298         vertex_coordinates = zeros((N, 6), Float)
     304        vertex_coordinates = zeros((3*N, 2), Float)
    299305
    300306        for i in range(N):
    301307            for j in range(3):
    302308                k = self.triangles[i,j]  #Index of vertex 0
    303                 v_k = self.coordinates[k]
    304                 vertex_coordinates[i, 2*j+0] = v_k[0]
    305                 vertex_coordinates[i, 2*j+1] = v_k[1]
     309                v_k = self.nodes[k]
     310
     311                vertex_coordinates[3*i+j,:] = v_k
     312
    306313
    307314        return vertex_coordinates
     315
    308316
    309317    def get_vertices(self, indices=None):
     
    358366
    359367        Preconditions:
    360           self.coordinates and self.triangles are defined
     368          self.nodes and self.triangles are defined
    361369
    362370        Postcondition:
     
    364372        """
    365373
    366         vertexlist = [None]*len(self.coordinates)
     374        vertexlist = [None]*len(self.nodes)
    367375        for i in range(self.number_of_triangles):
    368376
  • anuga_core/source/anuga/abstract_2d_finite_volumes/generic_boundary_conditions.py

    r3931 r3945  
    220220        for i, (vol_id, edge_id) in enumerate(boundary_keys):
    221221
    222             x0 = V[vol_id, 0]; y0 = V[vol_id, 1]
    223             x1 = V[vol_id, 2]; y1 = V[vol_id, 3]
    224             x2 = V[vol_id, 4]; y2 = V[vol_id, 5]
    225 
     222            base_index = 3*vol_id
     223            x0, y0 = V[base_index, :]
     224            x1, y1 = V[base_index+1, :]
     225            x2, y2 = V[base_index+2, :]
     226           
    226227            #Compute midpoints
    227228            if edge_id == 0: m = array([(x1 + x2)/2, (y1 + y2)/2])
  • anuga_core/source/anuga/abstract_2d_finite_volumes/neighbour_mesh.py

    r3928 r3945  
    113113            if verbose and i % ((N+10)/10) == 0: print '(%d/%d)' %(i, N)
    114114
    115             x0 = V[i, 0]; y0 = V[i, 1]
    116             x1 = V[i, 2]; y1 = V[i, 3]
    117             x2 = V[i, 4]; y2 = V[i, 5]
     115            x0, y0 = V[3*i, :]
     116            x1, y1 = V[3*i+1, :]
     117            x2, y2 = V[3*i+2, :]                       
     118
     119            #x0 = V[i, 0]; y0 = V[i, 1]
     120            #x1 = V[i, 2]; y1 = V[i, 3]
     121            #x2 = V[i, 4]; y2 = V[i, 5]
    118122
    119123            #Compute centroid
     
    596600        #Check each triangle
    597601        for i in range(N):
     602
     603            x0, y0 = V[3*i, :]
     604            x1, y1 = V[3*i+1, :]
     605            x2, y2 = V[3*i+2, :]
    598606           
    599             x0 = V[i, 0]; y0 = V[i, 1]
    600             x1 = V[i, 2]; y1 = V[i, 3]
    601             x2 = V[i, 4]; y2 = V[i, 5]
    602 
    603607            #Check that area hasn't been compromised
    604608            area = self.areas[i]
  • anuga_core/source/anuga/abstract_2d_finite_volumes/quantity.py

    r3928 r3945  
    1616
    1717from Numeric import array, zeros, Float, less, concatenate, NewAxis, argmax, allclose
    18 from anuga.utilities.numerical_tools import ensure_numeric
     18from anuga.utilities.numerical_tools import ensure_numeric, is_scalar
    1919
    2020class Quantity:
     
    558558            is_subset = True
    559559
     560
     561        # FIXME (Ole): Now we can compute the arrays once and for all
     562        # for both centroids and vertices and the use set_values_from_array
     563
    560564        if location == 'centroids':
    561             P = take(self.domain.centroid_coordinates, indices)
     565            V = take(self.domain.centroid_coordinates, indices)
    562566            if is_subset:
    563                 self.set_values(f(P[:,0], P[:,1]),
     567                self.set_values(f(V[:,0], V[:,1]),
    564568                                location = location,
    565569                                indices = indices)
    566570            else:
    567                 self.set_values(f(P[:,0], P[:,1]), location = location)
     571                self.set_values(f(V[:,0], V[:,1]), location = location)
    568572        elif location == 'vertices':
    569             P = self.domain.vertex_coordinates
     573            V = self.domain.get_vertex_coordinates()
     574
     575            x = V[:,0]; y = V[:,1];                     
     576            values = f(x, y)
     577
     578            if is_scalar(values):
     579                # Function returned a constant value
     580                self.set_values_from_constant(values,
     581                                              location, indices, verbose)
     582                return
     583               
     584           
    570585            if is_subset:
    571586                #Brute force
    572                 for e in indices:
    573                     for i in range(3):
    574                         self.vertex_values[e,i] = f(P[e,2*i], P[e,2*i+1])
     587                for i in indices:
     588                    for j in range(3):
     589                        self.vertex_values[i,j] = values[3*i+j]
    575590            else:
    576                 for i in range(3):
    577                     self.vertex_values[:,i] = f(P[:,2*i], P[:,2*i+1])
     591                for j in range(3):
     592                    self.vertex_values[:,j] = values[j::3]
    578593        else:
    579594            raise 'Not implemented: %s' %location
     
    625640            raise ms
    626641
    627         coordinates = self.domain.coordinates
    628         triangles = self.domain.triangles
     642        coordinates = self.domain.get_nodes()
     643        triangles = self.domain.triangles      #FIXME
    629644
    630645
     
    910925        elif location == 'unique vertices':
    911926            if (indices ==  None):
    912                 indices=range(self.domain.coordinates.shape[0])
     927                indices=range(self.domain.number_of_nodes)
    913928            vert_values = []
    914929            #Go through list of unique vertices
     
    958973
    959974        if indices == None:
    960             assert A.shape[0] == self.domain.coordinates.shape[0]
     975            assert A.shape[0] == self.domain.get_nodes().shape[0]
    961976            vertex_list = range(A.shape[0])
    962977        else:
     
    10851100
    10861101            if xy is True:
    1087                 X = self.domain.coordinates[:,0].astype(precision)
    1088                 Y = self.domain.coordinates[:,1].astype(precision)
     1102                X = self.domain.get_nodes()[:,0].astype(precision)
     1103                Y = self.domain.get_nodes()[:,1].astype(precision)
    10891104
    10901105                return X, Y, A, V
     
    13891404    from Numeric import zeros, Float
    13901405
    1391     N = len(quantity.domain)
     1406    N = quantity.domain.number_of_nodes
    13921407
    13931408    beta_w = quantity.domain.beta_w
  • anuga_core/source/anuga/abstract_2d_finite_volumes/test_general_mesh.py

    r3928 r3945  
    2929
    3030
    31         assert allclose(domain.get_vertex_coordinates(unique=True), domain.coordinates)
     31        assert allclose(domain.get_vertex_coordinates(unique=True),
     32                        domain.nodes)
    3233
    3334        #assert allclose(domain.get_vertex_coordinates(), ...TODO
     
    5152        assert domain.get_vertices([0,4]) == [domain.triangles[0],
    5253                                              domain.triangles[4]]
     54       
    5355    def test_areas(self):
    5456        from mesh_factory import rectangular
  • anuga_core/source/anuga/abstract_2d_finite_volumes/test_neighbour_mesh.py

    r3688 r3945  
    7676
    7777        #Vertex coordinates
     78        #V = mesh.get_vertex_coordinates()
     79        #assert allclose(V[0], [0.0, 0.0, 4.0, 0.0, 0.0, 3.0])
     80       
     81
    7882        V = mesh.get_vertex_coordinates()
    79         assert allclose(V[0], [0.0, 0.0, 4.0, 0.0, 0.0, 3.0])
    80 
    81         V = mesh.get_vertex_coordinates(obj=True)
    8283        assert allclose(V, [ [0.0, 0.0],
    8384                             [4.0, 0.0],
     
    104105
    105106        V = mesh.get_vertex_coordinates()
    106 
    107         x0 = V[0,0]
    108         y0 = V[0,1]
    109         x1 = V[0,2]
    110         y1 = V[0,3]
    111         x2 = V[0,4]
    112         y2 = V[0,5]
     107        x0 = V[0, 0]; y0 = V[0, 1]
     108        x1 = V[1, 0]; y1 = V[1, 1]
     109        x2 = V[2, 0]; y2 = V[2, 1]
     110        #x0 = V[0,0]
     111        #y0 = V[0,1]
     112        #x1 = V[0,2]
     113        #y1 = V[0,3]
     114        #x2 = V[0,4]
     115        #y2 = V[0,5]
    113116
    114117        m0 = [(x1 + x2)/2, (y1 + y2)/2]
     
    172175
    173176        V = mesh.get_vertex_coordinates()
    174 
    175         x0 = V[0,0]
    176         y0 = V[0,1]
    177         x1 = V[0,2]
    178         y1 = V[0,3]
    179         x2 = V[0,4]
    180         y2 = V[0,5]
     177        x0 = V[0, 0]; y0 = V[0, 1]
     178        x1 = V[1, 0]; y1 = V[1, 1]
     179        x2 = V[2, 0]; y2 = V[2, 1]       
     180
     181        #x0 = V[0,0]
     182        #y0 = V[0,1]
     183        #x1 = V[0,2]
     184        #y1 = V[0,3]
     185        #x2 = V[0,4]
     186        #y2 = V[0,5]
    181187
    182188        m0 = [(x1 + x2)/2, (y1 + y2)/2]
  • anuga_core/source/anuga/abstract_2d_finite_volumes/test_quantity.py

    r3704 r3945  
    395395
    396396
    397         answer = linear_function(quantity.domain.get_vertex_coordinates(obj = True))
     397        answer = linear_function(quantity.domain.get_vertex_coordinates())
    398398        #print quantity.vertex_values, answer
    399399        assert allclose(quantity.vertex_values.flat, answer)
     
    401401
    402402        #Now try by setting the same values directly
    403         vertex_attributes = fit_to_mesh(quantity.domain.coordinates,
    404                                         quantity.domain.triangles,
     403        vertex_attributes = fit_to_mesh(quantity.domain.get_nodes(),
     404                                        quantity.domain.triangles, #FIXME
    405405                                        data_points,
    406406                                        z,
     
    514514        quantity.set_values(filename = ptsfile,
    515515                            attribute_name = att, alpha = 0)
    516         answer = linear_function(quantity.domain.get_vertex_coordinates(obj = True))
     516        answer = linear_function(quantity.domain.get_vertex_coordinates())
    517517
    518518        #print quantity.vertex_values.flat
     
    592592        quantity.set_values(filename = ptsfile,
    593593                            attribute_name = att, alpha = 0)
    594         answer = linear_function(quantity.domain.get_vertex_coordinates(obj = True) - [x0, y0])
     594        answer = linear_function(quantity.domain.get_vertex_coordinates() - [x0, y0])
    595595
    596596        assert allclose(quantity.vertex_values.flat, answer)
     
    666666        quantity.set_values(filename = ptsfile,
    667667                            attribute_name = att, alpha = 0)
    668         answer = linear_function(quantity.domain.get_vertex_coordinates(obj = True) + [x0, y0])
     668        answer = linear_function(quantity.domain.get_vertex_coordinates() + [x0, y0])
    669669
    670670
  • anuga_core/source/anuga/fit_interpolate/fit.py

    r3633 r3945  
    9393                 max_vertices_per_cell)
    9494       
    95         m = self.mesh.coordinates.shape[0] #Nbr of basis functions (vertices)
     95        m = self.mesh.number_of_nodes # Nbr of basis functions (vertices)
    9696       
    9797        self.AtA = None
     
    152152        #"element stiffness matrices:
    153153
    154         m = self.mesh.coordinates.shape[0] #Nbr of basis functions (1/vertex)
     154        m = self.mesh.number_of_nodes # Nbr of basis functions (1/vertex)
    155155
    156156        self.D = Sparse(m,m)
     
    233233        if self.AtA == None:
    234234            # AtA and Atz need ot be initialised.
    235             m = self.mesh.coordinates.shape[0] #Nbr of vertices
     235            m = self.mesh.number_of_nodes
    236236            if len(z.shape) > 1:
    237237                att_num = z.shape[1]
     
    316316
    317317        #Check sanity
    318         m = self.mesh.coordinates.shape[0] #Nbr of basis functions (1/vertex)
     318        m = self.mesh.number_of_nodes # Nbr of basis functions (1/vertex)
    319319        n = self.point_count
    320320        if n<m and self.alpha == 0.0:
  • anuga_core/source/anuga/fit_interpolate/interpolate.py

    r3941 r3945  
    257257            print '\n WARNING: No points within the mesh! \n'
    258258           
    259         m = self.mesh.coordinates.shape[0] #Nbr of basis functions (1/vertex)
    260         n = point_coordinates.shape[0]     #Nbr of data points
     259        m = self.mesh.number_of_nodes  # Nbr of basis functions (1/vertex)
     260        n = point_coordinates.shape[0] # Nbr of data points
    261261
    262262        if verbose: print 'Number of datapoints: %d' %n
  • anuga_core/source/anuga/utilities/numerical_tools.py

    r3850 r3945  
    6161    if x < 0: return -1
    6262    if x == 0: return 0   
    63    
     63
     64
     65def is_scalar(x):
     66    """True if x is a scalar (constant numeric value)
     67    """
     68
     69    from types import IntType, FloatType
     70    if type(x) in [IntType, FloatType]:
     71        return True
     72    else:
     73        return False
    6474
    6575def angle(v1, v2=None):
  • anuga_core/source/anuga/utilities/quad.py

    r3566 r3945  
    139139        if len(args) == 2:
    140140            point_id = int(args[1])
    141             x = self.__class__.mesh.coordinates[point_id][0]
    142             y = self.__class__.mesh.coordinates[point_id][1]
     141            x, y = self.__class__.mesh.get_nodes()[point_id]
    143142
    144143            #print point_id, x, y
     
    394393    #Make root cell
    395394    #print mesh.coordinates
    396    
    397     xmin = min(mesh.coordinates[:,0])
    398     xmax = max(mesh.coordinates[:,0])
    399     ymin = min(mesh.coordinates[:,1])
    400     ymax = max(mesh.coordinates[:,1])
     395
     396    nodes = mesh.get_nodes()
     397    xmin = min(nodes[:,0])
     398    xmax = max(nodes[:,0])
     399    ymin = min(nodes[:,1])
     400    ymax = max(nodes[:,1])
    401401
    402402   
     
    425425   
    426426    #Insert indices of all vertices
    427     root.insert( range(len(mesh.coordinates)) )
     427    root.insert( range(mesh.number_of_nodes) )
    428428
    429429    #Build quad tree and return
  • anuga_core/source/anuga/utilities/test_quad.py

    r3566 r3945  
    120120
    121121        Q = build_quadtree(self.mesh)
     122        #Q.show()
     123        #print Q.count()
    122124        assert Q.count() == 8
    123125
    124         #Q.show()
     126
    125127
    126128        result = Q.search(3, 105)
Note: See TracChangeset for help on using the changeset viewer.