Ignore:
Timestamp:
Nov 6, 2008, 12:28:22 PM (15 years ago)
Author:
rwilson
Message:

Initial NumPy? changes (again!).

File:
1 edited

Legend:

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

    r5842 r5899  
    1 
    2 from Numeric import concatenate, reshape, take, allclose
    3 from Numeric import array, zeros, Int, Float, sqrt, sum, arange
     1## Automatically adapted for numpy.oldnumeric Oct 28, 2008 by alter_code1.py
     2
     3
     4##from numpy.oldnumeric import concatenate, reshape, take, allclose
     5##from numpy.oldnumeric import array, zeros, Int, Float, sqrt, sum, arange
     6from numpy import concatenate, reshape, take, allclose
     7from numpy import array, zeros, int, float, sqrt, sum, arange
    48
    59from anuga.coordinate_transforms.geo_reference import Geo_reference
     
    9094        if verbose: print 'General_mesh: Building basic mesh structure in ANUGA domain'
    9195
    92         self.triangles = array(triangles, Int)
    93         self.nodes = array(nodes, Float)
     96##        self.triangles = array(triangles, Int)
     97##        self.nodes = array(nodes, Float)
     98        self.triangles = array(triangles, int)
     99        self.nodes = array(nodes, float)
    94100
    95101
     
    138144
    139145        msg = 'Vertex indices reference non-existing coordinate sets'
    140         assert max(self.triangles.flat) < self.nodes.shape[0], msg
     146        assert max(self.triangles.ravel()) < self.nodes.shape[0], msg
    141147
    142148
     
    146152                      max(self.nodes[:,0]), max(self.nodes[:,1]) ]
    147153
    148         self.xy_extent = array(xy_extent, Float)
     154##        self.xy_extent = array(xy_extent, Float)
     155        self.xy_extent = array(xy_extent, float)
    149156
    150157
    151158        # Allocate space for geometric quantities
    152         self.normals = zeros((N, 6), Float)
    153         self.areas = zeros(N, Float)
    154         self.edgelengths = zeros((N, 3), Float)
     159##        self.normals = zeros((N, 6), Float)
     160##        self.areas = zeros(N, Float)
     161##        self.edgelengths = zeros((N, 3), Float)
     162        self.normals = zeros((N, 6), float)
     163        self.areas = zeros(N, float)
     164        self.edgelengths = zeros((N, 3), float)
    155165
    156166        # Get x,y coordinates for all triangles and store
     
    311321            i = triangle_id
    312322            msg = 'triangle_id must be an integer'
     323            print 'type(triangle_id)=%s. triangle_id=%s' % (type(triangle_id), str(triangle_id))
    313324            assert int(i) == i, msg
    314325            assert 0 <= i < self.number_of_triangles
     
    349360
    350361        M = self.number_of_triangles
    351         vertex_coordinates = zeros((3*M, 2), Float)
     362##        vertex_coordinates = zeros((3*M, 2), Float)
     363        vertex_coordinates = zeros((3*M, 2), float)
    352364
    353365        for i in range(M):
     
    376388            indices = range(M)
    377389
    378         return take(self.triangles, indices)
     390        return take(self.triangles, indices, axis=0)
    379391   
    380392
     
    409421       
    410422        #T = reshape(array(range(K)).astype(Int), (M,3))
    411         T = reshape(arange(K).astype(Int), (M,3))  # Faster
     423##        T = reshape(arange(K).astype(Int), (M,3))  # Faster
     424        T = reshape(arange(K).astype(int), (M,3))  # Faster
    412425       
    413426        return T     
     
    442455           
    443456            # Get number of triangles for this node
    444             count = self.number_of_triangles_per_node[node]
     457            count = int(self.number_of_triangles_per_node[node])
    445458
    446459            for i in range(count):
     
    582595        Y = C[:,1:6:2].copy()
    583596
    584         xmin = min(X.flat)
    585         xmax = max(X.flat)
    586         ymin = min(Y.flat)
    587         ymax = max(Y.flat)
     597        xmin = min(X.ravel())
     598        xmax = max(X.ravel())
     599        ymin = min(Y.ravel())
     600        ymax = max(Y.ravel())
    588601        #print "C",C
    589602        return xmin, xmax, ymin, ymax
Note: See TracChangeset for help on using the changeset viewer.