Changeset 7400


Ignore:
Timestamp:
Aug 21, 2009, 2:02:46 PM (15 years ago)
Author:
steve
Message:

Commit a working copy of numpy version of build_commun

Location:
anuga_core/source/anuga_parallel
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga_parallel/build_commun.py

    r3926 r7400  
    1313#  Author: Linda Stals, June 2005
    1414#  Modified: Linda Stals, Nov 2005 (optimise python code)
    15 #
    16 #
    17 #########################################################
    18 
    19 from Numeric import array, Int, Float, zeros
     15#            Steve Roberts, Aug 2009 (update to numpy)
     16#
     17#
     18#########################################################
     19
     20#from Numeric import array, Int, Float, zeros
     21
     22import numpy as num
     23
    2024import logging, logging.config
    2125logger = logging.getLogger('parallel')
     
    3034
    3135import pypar
     36
    3237
    3338from build_local import build_local_mesh
     
    6570             tagmap[bkey] = counter
    6671             counter = counter+1
     72
    6773    pypar.send(tagmap, p)
    6874
    6975    # send the quantities key information
    70    
     76
    7177    pypar.send(submesh["full_quan"].keys(), p)
    7278   
    7379    # send the number of triangles per processor
    7480
    75     pypar.send(triangles_per_proc, p, use_buffer=True)
     81    pypar.send(triangles_per_proc, p)
    7682
    7783    # compress full_commun
     
    8288        for i in range(len(submesh["full_commun"][p][c])):
    8389            flat_full_commun.append([c,submesh["full_commun"][p][c][i]])
     90
     91    print 'flat_full_commun', flat_full_commun
    8492
    8593    # send the array sizes so memory can be allocated
     
    95103    setup_array[7] = len(flat_full_commun)
    96104
    97     pypar.send(setup_array, p)
     105    pypar.send(num.array(setup_array, num.int), p)
    98106   
    99107    # send the nodes
    100    
    101     pypar.send(submesh["full_nodes"][p], p, use_buffer=True)
    102     pypar.send(submesh["ghost_nodes"][p], p, use_buffer=True)
     108
     109    pypar.send(num.array(submesh["full_nodes"][p], num.float), p)
     110    pypar.send(num.array(submesh["ghost_nodes"][p], num.float),p)
    103111
    104112    # send the triangles
    105113
    106     pypar.send(array(submesh["full_triangles"][p], Int), p, use_buffer=True)
    107     pypar.send(submesh["ghost_triangles"][p], p, use_buffer=True)
     114    pypar.send(num.array(submesh["full_triangles"][p],  num.int), p)
     115    pypar.send(num.array(submesh["ghost_triangles"][p], num.int), p)
    108116
    109117    # send the boundary
     
    112120    for b in submesh["full_boundary"][p]:
    113121        bc.append([b[0], b[1], tagmap[submesh["full_boundary"][p][b]]])
    114     pypar.send(bc, p, use_buffer=True)
     122
     123
     124    pypar.send(num.array(bc, num.int), p)
     125
    115126    bc = []
    116127    for b in submesh["ghost_boundary"][p]:
    117128        bc.append([b[0], b[1], tagmap[submesh["ghost_boundary"][p][b]]])
    118     pypar.send(bc, p, use_buffer=True)
     129
     130    pypar.send(num.array(bc, num.int), p)
    119131
    120132    # send the communication pattern
    121133
    122     pypar.send(submesh["ghost_commun"][p], p, use_buffer=True)
    123     pypar.send(flat_full_commun, p, use_buffer=True)
     134    pypar.send(submesh["ghost_commun"][p], p)
     135
     136    pypar.send(num.array(flat_full_commun, num.int), p)
    124137
    125138    # send the quantities
    126139   
    127140    for k in submesh["full_quan"]:
    128         pypar.send(submesh["full_quan"][k][p], p, use_buffer=True)
     141        pypar.send(num.array(submesh["full_quan"][k][p], num.float), p)
    129142       
    130143    for k in submesh["ghost_quan"]:
    131         pypar.send(submesh["ghost_quan"][k][p], p, use_buffer=True)
     144        pypar.send(num.array(submesh["ghost_quan"][k][p], num.float),p)
    132145       
    133146
     
    150163
    151164def rec_submesh_flat(p):
    152 
     165   
    153166    numproc = pypar.size()
    154167    myid = pypar.rank()
     
    161174   
    162175    tagmap = pypar.receive(p)
     176
    163177    itagmap = {}
    164178    for t in tagmap:
     
    166180
    167181    # receive the quantities key information
    168    
     182
    169183    qkeys = pypar.receive(p)
    170184
    171185    # receive the number of triangles per processor
    172186
    173     triangles_per_proc = []
    174     for i in range(numproc):
    175         triangles_per_proc.append([0])
    176 
    177     triangles_per_proc = pypar.receive(p, triangles_per_proc)
     187    triangles_per_proc = pypar.receive(p)
    178188
    179189    # recieve information about the array sizes
    180190
    181     setup_array = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
    182     setup_array = pypar.receive(p, setup_array)
    183 
     191    setup_array = pypar.receive(p)
     192
     193    no_full_nodes = setup_array[0]
     194    no_ghost_nodes = setup_array[1]
     195    no_full_triangles = setup_array[2]
     196    no_ghost_triangles = setup_array[3]
     197    no_full_boundary = setup_array[4]
     198    no_ghost_boundary = setup_array[5]
     199    no_ghost_commun = setup_array[6]
     200    no_full_commun = setup_array[7]
     201    no_quantities = len(qkeys)
     202   
    184203    # receive the full nodes
    185204
    186     no_full_nodes = setup_array[0]
    187     full_nodes = zeros((no_full_nodes, 3), Float)
    188     submesh_cell["full_nodes"] = pypar.receive(p, full_nodes)
    189    
     205    submesh_cell["full_nodes"] = pypar.receive(p)
     206
    190207    # receive the ghost nodes
    191208
    192     no_ghost_nodes = setup_array[1]
    193     ghost_nodes = zeros((no_ghost_nodes, 3), Float)
    194     submesh_cell["ghost_nodes"] = pypar.receive(p, ghost_nodes)
    195 
     209    submesh_cell["ghost_nodes"] = pypar.receive(p)
    196210   
    197211    # receive the full triangles
    198212
    199     no_full_triangles = setup_array[2]
    200     full_triangles = zeros((no_full_triangles, 3), Int)
    201     submesh_cell["full_triangles"] = pypar.receive(p, full_triangles)
     213    submesh_cell["full_triangles"] = pypar.receive(p)
    202214   
    203215    # receive the ghost triangles
    204216
    205     no_ghost_triangles = setup_array[3]
    206     ghost_triangles = zeros((no_ghost_triangles, 4), Int)
    207     submesh_cell["ghost_triangles"] = pypar.receive(p, ghost_triangles)
    208    
     217    submesh_cell["ghost_triangles"] = pypar.receive(p)
     218
    209219    # receive the full boundary
    210220
    211     no_full_boundary = setup_array[4]
    212     bc = []
    213     for i in range(no_full_boundary):
    214         bc.append([0.0, 0.0, 0.0])
    215     bnd_c = pypar.receive(p, bc)
     221    bnd_c = pypar.receive(p)
    216222
    217223    submesh_cell["full_boundary"] = {}
     
    221227    # receive the ghost boundary
    222228
    223     no_ghost_boundary = setup_array[5]
    224     bc = []
    225     for i in range(no_ghost_boundary):
    226         bc.append([0.0, 0.0, 0.0])
    227     bnd_c = pypar.receive(p, bc)
     229    bnd_c = pypar.receive(p)
    228230
    229231    submesh_cell["ghost_boundary"] = {}
     
    233235    # receive the ghost communication pattern
    234236
    235     no_ghost_commun = setup_array[6]
    236     ghost_commun = zeros((no_ghost_commun, 2), Int)
    237     submesh_cell["ghost_commun"] = pypar.receive(p, ghost_commun)
     237    submesh_cell["ghost_commun"] = pypar.receive(p)
    238238   
    239239    # receive the full communication pattern
    240240
    241     no_full_commun = setup_array[7]
    242     full_commun = []
    243     for i in range(no_full_commun):
    244         full_commun.append([0.0, 0.0])
    245 
    246     full_commun = pypar.receive(p, full_commun)
     241    full_commun = pypar.receive(p)
    247242
    248243    submesh_cell["full_commun"] = {}
     
    254249    # receive the quantities
    255250
    256     no_quantities = len(qkeys)
    257     new_quan = zeros((no_full_triangles, 3), Float)
    258251    submesh_cell["full_quan"]={}
    259252   
    260253    for i in range(no_quantities):
    261         tmp = pypar.receive(p, new_quan)
    262         submesh_cell["full_quan"][qkeys[i]]=zeros((no_full_triangles,3), Float)
     254        tmp = pypar.receive(p)
     255        submesh_cell["full_quan"][qkeys[i]]=num.zeros((no_full_triangles,3), num.float)
    263256        submesh_cell["full_quan"][qkeys[i]][:] = tmp[:]
    264257
    265     new_quan = zeros((no_ghost_triangles, 3), Float)
    266258    submesh_cell["ghost_quan"]={}
    267259    for i in range(no_quantities):
    268         tmp = pypar.receive(p, new_quan)
    269         submesh_cell["ghost_quan"][qkeys[i]]= zeros((no_ghost_triangles,3), Float)
     260        tmp = pypar.receive(p)
     261        submesh_cell["ghost_quan"][qkeys[i]]= num.zeros((no_ghost_triangles,3), num.float)
    270262        submesh_cell["ghost_quan"][qkeys[i]][:] = tmp[:]
    271263   
     
    293285
    294286def rec_submesh(p):
    295 
     287   
    296288    numproc = pypar.size()
    297289    myid = pypar.rank()
  • anuga_core/source/anuga_parallel/build_local.py

    r3579 r7400  
    1414#  Authors: Linda Stals and Matthew Hardy, June 2005
    1515#  Modified: Linda Stals, Nov 2005 (optimise python code)
    16 #
    17 #
    18 #########################################################
    19 
    20 from Numeric import  zeros, Float, Int, concatenate, \
    21      take, arrayrange, put, sort, compress, equal
    22 
    23 
     16#            Steve Roberts, Aug 2009 (updating to numpy)
     17#
     18#
     19#########################################################
     20
     21#from Numeric import  zeros, Float, Int, concatenate, \
     22#     take, arrayrange, put, sort, compress, equal
     23
     24
     25import numpy as num
     26 
    2427#########################################################
    2528# Convert the format of the data to that used by ANUGA
     
    4649    # Extract the nodes (using the local ID)
    4750   
    48     GAnodes = take(nodes, (1, 2), 1)
     51    GAnodes = num.take(nodes, (1, 2), 1)
    4952
    5053    # Build a global ID to local ID mapping
     
    5457        if nodes[i][0] > NGlobal:
    5558            NGlobal = nodes[i][0]
    56     index = zeros(int(NGlobal)+1, Int)
    57     put(index, take(nodes, (0,), 1).astype(Int), \
    58         arrayrange(Nnodes))
     59    index = num.zeros(int(NGlobal)+1, num.int)
     60    num.put(index, num.take(nodes, (0,), 1).astype(num.int), \
     61        num.arange(Nnodes))
    5962       
    6063    # Change the global IDs in the triangles to the local IDs
    6164
    62     GAtriangles = zeros((Ntriangles, 3), Int)
    63     GAtriangles[:,0] = take(index, triangles[:,0])
    64     GAtriangles[:,1] = take(index, triangles[:,1])
    65     GAtriangles[:,2] = take(index, triangles[:,2])
     65    GAtriangles = num.zeros((Ntriangles, 3), num.int)
     66    GAtriangles[:,0] = num.take(index, triangles[:,0])
     67    GAtriangles[:,1] = num.take(index, triangles[:,1])
     68    GAtriangles[:,2] = num.take(index, triangles[:,2])
    6669
    6770    # Change the triangle numbering in the boundaries
     
    109112    # information by the global numbering)
    110113   
    111     ghostc = sort(ghostc, 0)
     114    ghostc = num.sort(ghostc, 0)
    112115   
    113116    for c in range(nproc):
    114117        s = ghostc[:,0]
    115         d = compress(equal(ghostc[:,1],c), s)
     118        d = num.compress(num.equal(ghostc[:,1],c), s)
    116119        if len(d) > 0:
    117120            ghost_recv[c] = [0, 0]
    118121            ghost_recv[c][1] = d
    119             ghost_recv[c][0] = take(index, d)
     122            ghost_recv[c][0] = num.take(index, d)
    120123           
    121124    # Build a temporary copy of the full_send dictionary
     
    136139
    137140    for neigh in tmp_send:
    138         neigh_commun = sort(tmp_send[neigh], 0)
     141        neigh_commun = num.sort(tmp_send[neigh], 0)
    139142        full_send[neigh] = [0, 0]
    140143        full_send[neigh][0] = neigh_commun[:,1]
     
    167170    # Combine the full nodes and ghost nodes
    168171
    169     nodes = concatenate((submesh["full_nodes"], \
     172    nodes = num.concatenate((submesh["full_nodes"], \
    170173                         submesh["ghost_nodes"]))
    171174   
    172175    # Combine the full triangles and ghost triangles
    173176
    174     gtri =  take(submesh["ghost_triangles"],(1, 2, 3),1)
    175     triangles = concatenate((submesh["full_triangles"], gtri))
     177    gtri =  num.take(submesh["ghost_triangles"],(1, 2, 3),1)
     178    triangles = num.concatenate((submesh["full_triangles"], gtri))
    176179
    177180    # Combine the full boundaries and ghost boundaries
     
    189192        if id > NGlobal:
    190193            NGlobal = id
    191     index = zeros(int(NGlobal)+1, Int)
    192     index[lower_t:upper_t]=arrayrange(upper_t-lower_t)
     194    index = num.zeros(int(NGlobal)+1, num.int)
     195    index[lower_t:upper_t]=num.arange(upper_t-lower_t)
    193196    for i in range(len(submesh["ghost_triangles"])):
    194197        index[submesh["ghost_triangles"][i][0]] = i+upper_t-lower_t
     
    205208        Nf = len(submesh["full_quan"][k])
    206209        Ng = len(submesh["ghost_quan"][k])
    207         quantities[k] = zeros((Nf+Ng, 3), Float)
     210        quantities[k] = num.zeros((Nf+Ng, 3), num.float)
    208211        quantities[k][0:Nf] = submesh["full_quan"][k]
    209212        quantities[k][Nf:Nf+Ng] = submesh["ghost_quan"][k]
     
    223226    return GAnodes, GAtriangles, GAboundary, quantities, ghost_rec, \
    224227           full_send
     228
  • anuga_core/source/anuga_parallel/build_submesh.py

    r7389 r7400  
    11#########################################################
    22#
    3 # Subdivide the GA domain. This module is primarily
     3# Subdivide the domain. This module is primarily
    44# responsible for building the ghost layer and
    55# communication pattern
     
    88#  Author: Linda Stals, June 2005
    99#  Modified: Linda Stals, Nov 2005 (optimise python code)
     10#            Steve Roberts, Aug 2009 (convert to numpy)
    1011#
    1112#
     
    1415import sys
    1516
    16 from Numeric import zeros, Float, Int, concatenate, \
    17      reshape, arrayrange, take, nonzero
     17#from Numeric import zeros, Float, Int, concatenate, \
     18#     reshape, arrayrange, take, nonzero
     19
     20import numpy as num
    1821
    1922from anuga.abstract_2d_finite_volumes.neighbour_mesh import Mesh
     
    5558    boundary_list = []
    5659    submesh = {}
    57     node_range = reshape(arrayrange(nnodes),(nnodes,1))
    58     tsubnodes = concatenate((node_range, nodes), 1)
     60    node_range = num.reshape(num.arange(nnodes),(nnodes,1))
     61
     62    #print node_range
     63    tsubnodes = num.concatenate((node_range, nodes), 1)
     64
    5965
    6066    # Loop over processors
     
    7884        # Find nodes in processor p
    7985
    80         nodemap = zeros(nnodes, 'i')
     86        nodemap = num.zeros(nnodes, 'i')
    8187        for t in subtriangles:
    8288            nodemap[t[0]]=1
     
    8490            nodemap[t[2]]=1
    8591
    86         node_list.append(take(tsubnodes,nonzero(nodemap)))
     92       
     93        node_list.append(tsubnodes.take(num.flatnonzero(nodemap),axis=0))
    8794
    8895        # Move to the next processor
     
    134141    # Find the first layer of boundary triangles
    135142
    136     trianglemap = zeros(ntriangles, 'i')
     143    trianglemap = num.zeros(ntriangles, 'i')
    137144    for t in range(tlower, tupper):
    138145       
    139146        n = mesh.neighbours[t, 0]
     147
    140148        if n >= 0:
    141149            if n < tlower or n >= tupper:
     
    169177    # Build the triangle list and make note of the vertices
    170178
    171     nodemap = zeros(ncoord, 'i')
     179    nodemap = num.zeros(ncoord, 'i')
    172180    fullnodes = submesh["full_nodes"][p]
    173181
     
    180188            nodemap[t[2]] = 1
    181189
    182     trilist = reshape(arrayrange(ntriangles),(ntriangles,1))
    183     tsubtriangles = concatenate((trilist, mesh.triangles), 1)
    184     subtriangles = take(tsubtriangles, nonzero(trianglemap))
    185 
     190    trilist = num.reshape(num.arange(ntriangles),(ntriangles,1))
     191    tsubtriangles = num.concatenate((trilist, mesh.triangles), 1)
     192    subtriangles = tsubtriangles.take(num.flatnonzero(trianglemap),axis=0)
     193
     194   
    186195    # Keep a record of the triangle vertices, if they are not already there
    187196
     
    190199        nodemap[int(n[0])] = 0
    191200
    192     nodelist = reshape(arrayrange(ncoord),(ncoord,1))
    193     tsubnodes = concatenate((nodelist, mesh.get_nodes()), 1)
    194     subnodes = take(tsubnodes, nonzero(nodemap))
     201    nodelist = num.reshape(num.arange(ncoord),(ncoord,1))
     202    tsubnodes = num.concatenate((nodelist, mesh.get_nodes()), 1)
     203    subnodes = tsubnodes.take(num.flatnonzero(nodemap),axis=0)
    195204
    196205    # Clean up before exiting
     
    234243#########################################################
    235244def is_in_processor(ghost_list, tlower, tupper, n):
    236     return (n in ghost_list) or (tlower <= n and tupper > n)
     245
     246    return num.equal(ghost_list,n).any() or (tlower <= n and tupper > n)
     247
    237248
    238249def ghost_bnd_layer(ghosttri, tlower, tupper, mesh, p):
     
    240251    ghost_list = []
    241252    subboundary = {}
    242        
     253
     254
    243255    for t in ghosttri:
    244256        ghost_list.append(t[0])
    245257   
    246258    for t in ghosttri:
     259
    247260        n = mesh.neighbours[t[0], 0]
    248261        if not is_in_processor(ghost_list, tlower, tupper, n):
     
    279292    # Loop over the ghost triangles
    280293
    281     ghost_commun = zeros((len(subtri), 2), Int)
     294    ghost_commun = num.zeros((len(subtri), 2), num.int)
    282295
    283296    for i in range(len(subtri)):
     
    410423        ghost_nodes.append(subnodes)
    411424
     425
    412426        # Find the boundary layer formed by the ghost triangles
    413427       
     
    492506        for k in quantities:
    493507            submesh["full_quan"][k].append(quantities[k][lower:upper])
    494             submesh["ghost_quan"][k].append(zeros( (M,3) , Float))
     508            submesh["ghost_quan"][k].append(num.zeros( (M,3) , num.float))
    495509            for j in range(M):
    496510                submesh["ghost_quan"][k][p][j] = \
  • anuga_core/source/anuga_parallel/parallel_advection.py

    r5763 r7400  
    2323
    2424from anuga.advection import *
    25 from Numeric import zeros, Float, Int, ones, allclose, array
     25
     26
     27#from Numeric import zeros, Float, Int, ones, allclose, array
     28import numpy as num
     29
    2630import pypar
    2731
     
    7882        # For some reason it looks like pypar only reduces numeric arrays
    7983        # hence we need to create some dummy arrays for communication
    80         ltimestep = ones( 1, Float )
     84        ltimestep = num.ones( 1, num.float )
    8185        ltimestep[0] = self.flux_timestep
    82         gtimestep = zeros( 1, Float) # Buffer for results
    83        
    84         pypar.raw_reduce(ltimestep, gtimestep, pypar.MIN, 0)
     86        gtimestep = num.zeros( 1, num.float ) # Buffer for results
     87
     88        #ltimestep = self.flux_timeste
     89
     90        #print self.processor, ltimestep, gtimestep
     91       
     92        pypar.reduce(ltimestep, pypar.MIN, 0, buffer=gtimestep)
     93
     94        #print self.processor, ltimestep, gtimestep
     95       
    8596        pypar.broadcast(gtimestep,0)
     97
     98        #print self.processor, ltimestep, gtimestep
    8699
    87100        self.flux_timestep = gtimestep[0]
     
    102115        # the separate processors
    103116
    104         from Numeric import take,put
     117        #from Numeric import take,put
     118        import numpy as num
    105119        import time
    106120        t0 = time.time()
     
    122136                        #for i in range(N):
    123137                        #    Xout[i,0] = stage_cv[Idf[i]]
    124                         Xout[:,0] = take(stage_cv, Idf)
     138                        Xout[:,0] = num.take(stage_cv, Idf)
    125139
    126140                        pypar.send(Xout,send_proc)
     
    139153                    N = len(Idg)
    140154
    141                     put(stage_cv, Idg, X[:,0])
     155                    num.put(stage_cv, Idg, X[:,0])
    142156                    #for i in range(N):
    143157                    #    stage_cv[Idg[i]] = X[i,0]
     
    162176            #    stage_cv[Idg[i]] = stage_cv[Idf[i]]
    163177
    164             put(stage_cv, Idg, take(stage_cv, Idf))
     178            num.put(stage_cv, Idg, num.take(stage_cv, Idf))
    165179
    166180
  • anuga_core/source/anuga_parallel/parallel_api.py

    r6721 r7400  
    44"""
    55
    6 from Numeric import zeros
     6
    77
    88# The abstract Python-MPI interface
     
    168168
    169169
     170
     171
    170172    # Build the mesh that should be assigned to each processor,
    171173    # this includes ghost nodes and the communication pattern
  • anuga_core/source/anuga_parallel/parallel_meshes.py

    r6721 r7400  
    1515
    1616import sys
    17 from Numeric import array, zeros, Float, Int, ones, sum
    18 
     17#from Numeric import array, zeros, Float, Int, ones, sum
     18
     19import numpy as num
    1920import pypar
    2021
     
    8687    E = EIndex(n,m)
    8788
    88     points = zeros( (Np,2), Float)
     89    points = num.zeros( (Np,2), num.float)
    8990
    9091    for i in range(m+1):
     
    9899
    99100
    100     elements = zeros( (Nt,3), Int)
     101    elements = num.zeros( (Nt,3), num.int)
    101102    boundary = {}
    102103    Idgl = []
     
    170171        print Idgr
    171172       
    172         Idfl = array(Idfl,Int)
    173         Idgr = array(Idgr,Int)
     173        Idfl = num.array(Idfl,num.int)
     174        Idgr = num.array(Idgr,num.int)
    174175
    175176        print Idfl
     
    184185        Idfl.extend(Idfr)
    185186        Idgr.extend(Idgl)
    186         Idfl = array(Idfl,Int)
    187         Idgr = array(Idgr,Int)
     187        Idfl = num.array(Idfl,num.int)
     188        Idgr = num.array(Idgr,num.int)
    188189        full_send_dict[(processor-1)%numproc]  = [Idfl, Idfl]
    189190        ghost_recv_dict[(processor-1)%numproc] = [Idgr, Idgr]
    190191    else:
    191         Idfl = array(Idfl,Int)
    192         Idgl = array(Idgl,Int)
    193 
    194         Idfr = array(Idfr,Int)
    195         Idgr = array(Idgr,Int)
     192        Idfl = num.array(Idfl,num.int)
     193        Idgl = num.array(Idgl,num.int)
     194
     195        Idfr = num.array(Idfr,num.int)
     196        Idgr = num.array(Idgr,num.int)
    196197
    197198        full_send_dict[(processor-1)%numproc]  = [Idfl, Idfl]
     
    252253    E = EIndex(n,m)
    253254
    254     points = zeros( (Np,2), Float)
     255    points = num.zeros( (Np,2), num.float)
    255256
    256257    for i in range(m+1):
     
    264265
    265266
    266     elements = zeros( (Nt,3), Int)
     267    elements = num.zeros( (Nt,3), num.int)
    267268    boundary = {}
    268269    ghosts = {}
     
    389390    E = EIndex(n,m)
    390391
    391     points = zeros( (Np,2), Float)
     392    points = num.zeros( (Np,2), num.float)
    392393
    393394    for i in range(m+1):
     
    401402
    402403
    403     elements = zeros( (Nt,3), Int)
     404    elements = num.zeros( (Nt,3), num.int)
    404405    boundary = {}
    405406    ghosts = {}
  • anuga_core/source/anuga_parallel/parallel_shallow_water.py

    r5763 r7400  
    2323
    2424from anuga.shallow_water.shallow_water_domain import *
    25 from Numeric import zeros, Float, Int, ones, allclose, array
     25
     26
     27import numpy as num
    2628
    2729import pypar
     
    5759#        for key in full_send_dict:
    5860#            buffer_shape = full_send_dict[key][0].shape[0]
    59 #            full_send_dict[key].append(zeros( (buffer_shape,self.nsys) ,Float))
     61#            full_send_dict[key].append(num.zeros( (buffer_shape,self.nsys) ,num.loat))
    6062#
    6163#
    6264#        for key in ghost_recv_dict:
    6365#            buffer_shape = ghost_recv_dict[key][0].shape[0]
    64 #            ghost_recv_dict[key].append(zeros( (buffer_shape,self.nsys) ,Float))
     66#            ghost_recv_dict[key].append(num.zeros( (buffer_shape,self.nsys) ,num.float))
    6567#
    6668#        self.full_send_dict  = full_send_dict
     
    6870
    6971        # Buffers for synchronisation of timesteps
    70         self.local_timestep = zeros(1, Float)
    71         self.global_timestep = zeros(1, Float)
    72 
    73         self.local_timesteps = zeros(self.numproc, Float)
     72        self.local_timestep = num.zeros(1, num.float)
     73        self.global_timestep = num.zeros(1, num.float)
     74
     75        self.local_timesteps = num.zeros(self.numproc, num.loat)
    7476
    7577
  • anuga_core/source/anuga_parallel/pmesh_divide.py

    r6721 r7400  
    1212#  Modified: Linda Stals, Nov 2005
    1313#            Jack Kelly, Nov 2005
     14#            Steve Roberts, Aug 2009 (updating to numpy)
    1415#
    1516#
     
    2021from math import floor
    2122
    22 from Numeric import zeros, Float, Int, reshape, argsort, ArrayType
    23 
     23import numpy as num
     24#import zeros, float, Int, reshape, argsort, ArrayType
    2425
    2526#########################################################
     
    4950    # Temporary storage area
    5051
    51     index = zeros(N, Int)
     52    index = num.zeros(N, num.int)
    5253    q_reord = {}
    5354
     
    6263
    6364    for k in quantities:
    64         q_reord[k] = zeros((N, 3), Float)
     65        q_reord[k] = num.zeros((N, 3), num.float)
    6566        for i in range(N):
    6667            q_reord[k][index[i]]=quantities[k].vertex_values[i]
     
    8889
    8990try:
    90    
    9191    from pymetis.metis import partMeshNodal
    9292except ImportError:
     
    9696    print "***************************************************"
    9797    raise ImportError
     98
    9899def pmesh_divide_metis(domain, n_procs):
    99100   
     
    121122        n_vert = domain.get_number_of_nodes()
    122123        t_list = domain.triangles.copy()
    123         t_list = reshape(t_list, (-1,))
     124        t_list = num.reshape(t_list, (-1,))
    124125   
    125126        # The 1 here is for triangular mesh elements.
     
    133134        # Sometimes (usu. on x86_64), partMeshNodal returnes an array of zero
    134135        # dimensional arrays. Correct this.
    135         if type(epart[0]) == ArrayType:
    136             epart_new = zeros(len(epart), Int)
     136        if type(epart[0]) == num.ndarray:
     137            epart_new = num.zeros(len(epart), num.int)
    137138            for i in range(len(epart)):
    138139                epart_new[i] = epart[i][0]
     
    184185        quantities = {}
    185186        for k in domain.quantities:
    186             quantities[k] = zeros((n_tri, 3), Float)
     187            quantities[k] = num.zeros((n_tri, 3), num.float)
    187188            for i in range(n_tri):
    188189                quantities[k][i] = domain.quantities[k].vertex_values[i]
     
    195196    # this helps with the communication
    196197
    197     ttriangles = zeros((len(triangles), 3), Int)
     198    ttriangles = num.zeros((len(triangles), 3), num.int)
    198199    for i in range(len(triangles)):
    199200        ttriangles[i] = triangles[i]
  • anuga_core/source/anuga_parallel/run_advection.py

    r5763 r7400  
    44#========================================================================
    55from anuga.config import g, epsilon
    6 from Numeric import allclose, array, zeros, ones, Float
     6
     7#from Numeric import allclose, array, zeros, ones, Float
     8
    79from anuga.advection import Domain, Transmissive_boundary, Dirichlet_boundary
    8 from Numeric import array
     10
     11#from Numeric import array
     12import numpy as num
    913
    1014
    11 from mesh_factory import rectangular
     15from anuga.interface import rectangular_cross
    1216
    1317#points, vertices, boundary = rectangular(60, 60)
    14 points, vertices, boundary = rectangular(10, 10)
     18points, vertices, boundary = rectangular_cross(10, 10)
    1519
    1620#Create advection domain with direction (1,-1)
     
    2630#Boundaries
    2731T = Transmissive_boundary(domain)
    28 D = Dirichlet_boundary(array([1.0]))
     32D = Dirichlet_boundary(num.array([1.0]))
    2933
    3034#turn on the visualisation
    3135rect = [0.0, 0.0, 1.0, 1.0]
    3236#domain.initialise_visualiser(rect=rect)
    33 domain.visualise = True
     37domain.visualise = False
    3438
    3539
  • anuga_core/source/anuga_parallel/run_parallel_advection.py

    r6721 r7400  
    4848numprocs = pypar.size()
    4949myid = pypar.rank()
    50 processor_name = pypar.Get_processor_name()
     50processor_name = pypar.get_processor_name()
    5151
    5252N = 5
    5353M = 2
     54
     55N = 10
     56M = 5
    5457
    5558#######################
     
    121124# Let processor 0 output some timing information
    122125
    123 visualise = True
     126visualise = False
    124127if visualise:
    125128    from anuga.visualiser import RealtimeVisualiser
     
    137140    t0 = time.time()
    138141
    139 for t in domain.evolve(yieldstep = 0.1, finaltime = 3.0):
     142for t in domain.evolve(yieldstep = 0.1, finaltime = 30.0):
    140143    if myid == 0:
    141144        domain.write_time()
  • anuga_core/source/anuga_parallel/test_parallel_sw_runup.py

    r6721 r7400  
    1515#------------------------------------------------------------------------------
    1616
    17 from Numeric import allclose
     17import numpy as num
    1818
    1919from anuga.pmesh.mesh_interface import create_mesh_from_regions
    20 from anuga.abstract_2d_finite_volumes.mesh_factory import rectangular_cross
     20
    2121from anuga.utilities.numerical_tools import ensure_numeric
    2222from anuga.utilities.polygon import is_inside_polygon
    2323
    24 from anuga.shallow_water import Domain
    25 from anuga.shallow_water import Reflective_boundary
    26 from anuga.shallow_water import Dirichlet_boundary
    27 from anuga.shallow_water import Time_boundary
    28 from anuga.shallow_water import Transmissive_boundary
     24from anuga.interface import Domain
     25from anuga.interface import Reflective_boundary
     26from anuga.interface import Dirichlet_boundary
     27from anuga.interface import Time_boundary
     28from anuga.interface import Transmissive_boundary
     29
     30from anuga.interface import rectangular_cross
    2931
    3032from parallel_api import distribute, myid, numprocs
     
    161163    if tri_ids[i] > -1:
    162164        #print 'myid = %g, allclose(gauge_values[%g], G%g) = %g' % (myid, i,i, allclose(gauge_values[i], G[i]))
    163         success = success and allclose(gauge_values[i], G[i])
     165        success = success and num.allclose(gauge_values[i], G[i])
    164166
    165167
Note: See TracChangeset for help on using the changeset viewer.