Changeset 986
- Timestamp:
- 10/24/19 18:27:01 (5 years ago)
- Location:
- codes/icosagcm/devel/Python
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
codes/icosagcm/devel/Python/dynamico/partition.h
r977 r986 11 11 idx_t options[]={0}, wgtflag=0, numflag=0, ncon=1; 12 12 real_t tpwgts[2*nparts], ubvec[]={1.05}; 13 13 int i; 14 14 /* int ParMETIS V3 PartKway ( 15 15 idx t *vtxdist, idx t *xadj, idx t *adjncy, idx t *vwgt, idx t *adjwgt, … … 22 22 printf("partition_graph : %d %d %d\n", mpi_rank, mpi_size, nparts); 23 23 printf("vtxdist : \n"); 24 for(i nt i=0; i<mpi_size+1; i++) printf("%d %d %d\n", mpi_rank, i, vtxdist[i]); */24 for(i=0; i<mpi_size+1; i++) printf("%d %d %d\n", mpi_rank, i, vtxdist[i]); */ 25 25 26 for(i nt i=0; i<2*nparts; i++) tpwgts[i] = 1./nparts;26 for(i=0; i<2*nparts; i++) tpwgts[i] = 1./nparts; 27 27 ParMETIS_V3_PartKway(vtxdist, xadj_loc, adjncy_loc, NULL, NULL, 28 28 &wgtflag, &numflag, &ncon, &nparts, … … 51 51 static inline void dynamico_morton_encode(int n, const int *x, const int *y, const int *z, uint64_t *m) 52 52 { 53 for(int i=0; i<n; i++) 53 int i; 54 for(i=0; i<n; i++) 54 55 m[i]=mortonEncode_magicbits(x[i],y[i],z[i]); 55 56 } -
codes/icosagcm/devel/Python/dynamico/partition.pyx
r977 r986 1 2 1 from ctypes import c_void_p, c_int, c_double, c_float, c_bool 3 2 from numpy cimport ndarray … … 6 5 7 6 ctypedef int idx_t 7 ctypedef unsigned long uint64_t 8 8 9 9 cdef extern from "partition.h": … … 11 11 idx_t vtxdist[], idx_t xadj_loc[], idx_t adjncy_loc[], 12 12 idx_t nparts, idx_t part[]) 13 void dynamico_morton_encode(int n, const int *x, const int *y, const int *z, long *m) 13 14 14 15 … … 51 52 dynamico_partition_graph(mpi_rank, mpi_size, &vtxdist[0], &xadj_loc[0], &adjncy_loc[0], nparts, &owner[0]) 52 53 return owner 54 55 #-------------------------------- Space-filling (Morton) ordering ------------------------# 56 57 def toint(x): return np.int32((x+1.)*65536) 58 59 def 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 -
codes/icosagcm/devel/Python/test/py/reorder.py
r779 r986 1 #------------ Read command-line arguments ----------# 2 from dynamico import getargs 3 getargs.add("--grid", type=int, default=2562, 4 help="number of primal cells in MPAS mesh") 5 args = getargs.parse() 6 grid = args.grid 7 8 #------------- Start --------------# 1 9 print 'Loading DYNAMICO modules ...' 2 from dynamico.meshes import morton_index, key_to_perm, reorder_indices, reorder_values, MPAS_Format, Unstructured_Mesh 10 from dynamico.meshes import key_to_perm, reorder_indices, reorder_values, MPAS_Format, Unstructured_Mesh 11 from dynamico.partition import morton_index 3 12 print '...Done' 4 13 import numpy as np … … 7 16 import time 8 17 9 #------------ Read command-line arguments ----------#10 11 import argparse12 parser = argparse.ArgumentParser()13 parser.add_argument("-n", type=int, default=2562,14 help="number of primal cells in MPAS mesh")15 args = parser.parse_args()16 grid = args.n17 18 18 19 #-------------- read MPAS mesh ----------------#
Note: See TracChangeset
for help on using the changeset viewer.