Ignore:
Timestamp:
10/24/19 18:27:01 (5 years ago)
Author:
dubos
Message:

devel/Python : update reorder.py and fix C syntax of partition.h

File:
1 edited

Legend:

Unmodified
Added
Removed
  • codes/icosagcm/devel/Python/dynamico/partition.pyx

    r977 r986  
    1  
    21from ctypes import c_void_p, c_int, c_double, c_float, c_bool 
    32from numpy cimport ndarray 
     
    65 
    76ctypedef int idx_t 
     7ctypedef unsigned long uint64_t 
    88 
    99cdef extern from "partition.h": 
     
    1111                     idx_t vtxdist[], idx_t xadj_loc[], idx_t adjncy_loc[], 
    1212                     idx_t nparts, idx_t part[]) 
     13    void dynamico_morton_encode(int n, const int *x, const int *y, const int *z, long *m) 
    1314 
    1415 
     
    5152    dynamico_partition_graph(mpi_rank, mpi_size, &vtxdist[0], &xadj_loc[0], &adjncy_loc[0], nparts, &owner[0]) 
    5253    return owner 
     54 
     55#-------------------------------- Space-filling (Morton) ordering ------------------------# 
     56 
     57def toint(x): return np.int32((x+1.)*65536) 
     58 
     59def morton_index(x,y,z): 
     60    cdef int nn 
     61    cdef int[::1] xx,yy,zz 
     62    cdef long[::1] idx_ 
     63    nn, xx, yy, zz = x.size, toint(x), toint(y), toint(z) 
     64    idx=np.zeros(nn, dtype=np.int64) 
     65    idx_=idx 
     66    dynamico_morton_encode(nn, &xx[0],&yy[0],&zz[0], &idx_[0]) 
     67    return idx 
Note: See TracChangeset for help on using the changeset viewer.