Changeset 23231
- Timestamp:
- 09/08/18 13:03:10 (7 years ago)
- Location:
- issm/trunk-jpl
- Files:
-
- 6 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/m/modules/Chaco.py
r23095 r23231 5 5 6 6 Usage: 7 [assgn]= Chaco(A,vwgts,ewgts,x,y,z,options,nparts,goal);7 assgn = Chaco(A,vwgts,ewgts,x,y,z,options,nparts,goal); 8 8 9 9 A: Input adjacency matrix -
issm/trunk-jpl/src/m/modules/Scotch.py
r23095 r23231 2 2 3 3 def Scotch(*varargin): 4 '''SCOTCH - Scotch partitioner4 '''SCOTCH - Scotch partitioner 5 5 6 6 Usage: -
issm/trunk-jpl/src/m/partition/partitioner.py
r23095 r23231 3 3 import MatlabFuncs as m 4 4 from adjacency import * 5 #from Chaco import *5 from Chaco import * 6 6 #from Scotch import * 7 #from MeshPartition import *7 from MeshPartition import * 8 8 from project3d import * 9 from mesh2d import * 9 10 10 11 def partitioner(md,*varargin): … … 60 61 61 62 if m.strcmpi(package,'chaco'): 62 raise RuntimeError('Chaco is not currently supported for this function')63 #raise RuntimeError('Chaco is not currently supported for this function') 63 64 64 65 # default method (from chaco.m) 65 #method=np.array([1,1,0,0,1,1,50,0,.001,7654321]).reshape(-1,1)66 #method[0]=3 # global method (3=inertial (geometric))67 #method[2]=0 # vertex weights (0=off, 1=on)66 method=np.array([1,1,0,0,1,1,50,0,.001,7654321]) 67 method[0]=3 # global method (3=inertial (geometric)) 68 method[2]=0 # vertex weights (0=off, 1=on) 68 69 69 70 #specify bisection 70 #method[5]=options.getfieldvalue('section')# ndims (1=bisection, 2=quadrisection, 3=octasection)71 method[5]=options.getfieldvalue('section')# ndims (1=bisection, 2=quadrisection, 3=octasection) 71 72 72 73 #are we using weights? 73 #if m.strcmpi(options.getfieldvalue('weighting'),'on'):74 #weights=np.floor(md.qmu.vertex_weight/min(md.qmu.vertex_weight))75 #method[2]=176 #else:77 #weights=[]74 if m.strcmpi(options.getfieldvalue('weighting'),'on'): 75 weights=np.floor(md.qmu.vertex_weight/min(md.qmu.vertex_weight)) 76 method[2]=1 77 else: 78 weights=[] 78 79 80 method = method.reshape(-1,1) # transpose to 1x10 instead of 10 81 79 82 # partition into nparts 80 #if isinstance(md.mesh,mesh2d): 81 #part=Chaco(md.qmu.adjacency,weights,[],md.mesh.x, md.mesh.y,np.zeros((md.mesh.numberofvertices,)),method,npart,[]).T+1 #index partitions from 1 up. like metis. 82 #else: 83 #part=Chaco(md.qmu.adjacency,weights,[],md.mesh.x, md.mesh.y,md.mesh.z,method,npart,[]).T+1 #index partitions from 1 up. like metis. 84 83 if isinstance(md.mesh,mesh2d): 84 part=np.array(Chaco(md.qmu.adjacency,weights,np.array([]),md.mesh.x, md.mesh.y,np.zeros((md.mesh.numberofvertices,)),method,npart,np.array([]))).T+1 #index partitions from 1 up. like metis. 85 else: 86 part=np.array(Chaco(md.qmu.adjacency,weights,np.array([]),md.mesh.x, md.mesh.y,md.mesh.z,method,npart,np.array([]))).T+1 #index partitions from 1 up. like metis. 85 87 86 88 elif m.strcmpi(package,'scotch'): -
issm/trunk-jpl/src/m/qmu/dakota_in_write.py
r23095 r23231 62 62 filei2=fullfile(pathstr,name+ext) 63 63 64 print 'Opening Dakota input file \''+filei2 + '\' '64 print 'Opening Dakota input file \''+filei2 + '\'.' 65 65 try: 66 66 with open(filei2,'w+') as fidi: -
issm/trunk-jpl/src/m/qmu/dakota_out_parse.py
r23095 r23231 241 241 dmax95 =prctile_issm(data,95,0) 242 242 243 # Note: the following line may cause the following warning 244 # (should not crash or invalidate results) when one of 245 # the inputs does not change with respect to the 246 # other/s causing an internal divide-by-zero error 247 248 #/usr/local/lib/python2.7/dist-packages/numpy/lib/function_base.py:3163: 249 # RuntimeWarning: invalid value encountered in true_divide 250 # c /= stddev[:,None] 251 252 # (and/or the same but with "c /= stddev[None, :]") 253 243 254 dcorrel=np.corrcoef(data.T) 244 255 -
issm/trunk-jpl/src/m/qmu/process_qmu_response_data.m
r23095 r23231 43 43 %ok, process the domains named in qmu_mass_flux_profiles, to build a list of segments (MatArray) 44 44 md.qmu.mass_flux_segments=cell(num_mass_flux,1); 45 md.qmu.mass_flux_segments46 45 for i=1:num_mass_flux, 47 46 md.qmu.mass_flux_segments{i}=MeshProfileIntersection(md.mesh.elements,md.mesh.x,md.mesh.y,[md.qmu.mass_flux_profile_directory '/' md.qmu.mass_flux_profiles{i}]); 48 47 end 49 md.qmu.mass_flux_segments50 48 end -
issm/trunk-jpl/src/wrappers/Chaco/Chaco.cpp
r22671 r23231 47 47 /*Fetch Data*/ 48 48 FetchChacoData(&nvtxs,&adjacency,&start,&ewgts,A_IN,EWGTS_IN); 49 FetchData(&vwgts,&nterms,VWGTS_IN); 50 FetchData(&x,&nterms,X_IN); 51 FetchData(&y,&nterms,Y_IN); 52 FetchData(&z,&nterms,Z_IN); 53 FetchData(&in_options,&nterms,OPTNS_IN); 49 FetchData(&vwgts,&nterms,VWGTS_IN); 50 FetchData(&x,&nterms,X_IN); 51 FetchData(&y,&nterms,Y_IN); 52 FetchData(&z,&nterms,Z_IN); 53 FetchData(&in_options,&nterms,OPTNS_IN); 54 54 for (i=0;i<(nterms<10?nterms:10);i++) options[i]=in_options[i]; //copy in_options into default options 55 FetchData(&npart,NPARTS_IN); 55 FetchData(&npart,NPARTS_IN); 56 56 //int * nparts=xNew<int>(1); nparts[0]=npart; //weird Chacox interface ain't it? 57 FetchData(&goal,&nterms,GOAL_IN); 57 FetchData(&goal,&nterms,GOAL_IN); 58 58 59 59 /*Allocate output: */ -
issm/trunk-jpl/src/wrappers/python/io/FetchPythonData.cpp
r22674 r23231 32 32 } 33 33 else if (PyInt_Check(py_float)) 34 34 dscalar=(double)PyInt_AsLong(py_float); 35 35 else if (PyBool_Check(py_float)) 36 36 dscalar=(double)PyLong_AsLong(py_float); … … 132 132 double* dmatrix=NULL; 133 133 double* matrix=NULL; 134 int M,N; 134 int M=0; 135 int N=0; 135 136 int ndim; 136 137 npy_intp* dims=NULL; … … 236 237 /*output: */ 237 238 int* matrix=NULL; 238 int M,N; 239 int M=0; 240 int N=0; 239 241 int ndim; 240 242 npy_intp* dims=NULL; … … 325 327 bool* bmatrix=NULL; 326 328 bool* matrix=NULL; 327 int M,N; 329 int M=0; 330 int N=0; 328 331 int ndim; 329 332 npy_intp* dims=NULL; … … 411 414 double* dvector=NULL; 412 415 double* vector=NULL; 413 int M ;416 int M=0; 414 417 int ndim; 415 418 npy_intp* dims=NULL; … … 499 502 /*output: */ 500 503 float* vector=NULL; 501 int M ;504 int M=0; 502 505 int ndim; 503 506 npy_intp* dims=NULL; … … 539 542 /*transform into int vector: */ 540 543 vector=xNew<float>(M); 541 for(i=0;i<M;i++)vector[i]=(float) lvector[i];544 for(i=0;i<M;i++)vector[i]=(float)dvector[i]; 542 545 } 543 546 … … 566 569 } 567 570 else 568 571 vector=NULL; 569 572 } 570 573 else{ … … 584 587 /*output: */ 585 588 int* vector=NULL; 586 int M ;589 int M=0; 587 590 int ndim; 588 591 npy_intp* dims=NULL; … … 624 627 /*transform into int vector: */ 625 628 vector=xNew<int>(M); 626 for(i=0;i<M;i++)vector[i]=(int) lvector[i];629 for(i=0;i<M;i++)vector[i]=(int)dvector[i]; 627 630 } 628 631 … … 672 675 bool* bvector=NULL; 673 676 bool* vector=NULL; 674 int M ;677 int M=0; 675 678 int ndim; 676 679 npy_intp* dims=NULL; … … 923 926 *pcontours=contours; 924 927 } 925 /*}}}*/ 926 void FetchChacoData(int* pnvtxs,int** padjacency,int** pstart,float** pewgts,PyObject* A_IN,PyObject* EWGTS_IN){ 927 _error_("Nathan... I need your help here"); 928 } 928 929 void FetchChacoData(int* pnvtxs,int** padjacency,int** pstart,float** pewgts,PyObject* A_IN, PyObject* EWGTS_IN){/*{{{*/ 930 931 double* a = ((double*)PyArray_DATA((PyArrayObject*)A_IN)); 932 int ndim = PyArray_NDIM((PyArrayObject*)A_IN); 933 int nzmax = PyArray_CountNonzero((PyArrayObject*)A_IN); 934 935 /*Fetch adjacency matrix:*/ 936 int nvtxs = PyArray_DIMS((PyArrayObject*)A_IN)[1]; 937 938 int* mwstart = xNewZeroInit<int>(nvtxs+1); 939 pyGetJc(a,nvtxs,mwstart); 940 941 int* mwadjacency = xNewZeroInit<int>(nzmax); 942 pyGetIr(a,nvtxs,nzmax,mwadjacency); 943 944 int* start = xNew<int>(nvtxs+1); 945 for(int i=0;i<nvtxs+1;i++) start[i]=(int)mwstart[i]; 946 int* adjacency = xNew<int>(nzmax); 947 for(int i=0; i<nzmax; i++) adjacency[i]=(int)mwadjacency[i]; 948 949 /*Get edges weights*/ 950 int nedges = start[nvtxs]; 951 float* ewgts = NULL; 952 int size = PyArray_SIZE((PyArrayObject*)EWGTS_IN); 953 //size may be 1 and still be empty; 954 //presumably size of edge_weights input will never be exactly 1 955 if(size != 1 && size != 0){ 956 ewgts = xNewZeroInit<float>(nedges); 957 for(int i = 0; i<nedges;i++){ 958 ewgts[i] = (float)a[i]; 959 } 960 } 961 962 /*Assign output pointers*/ 963 *pnvtxs = nvtxs; 964 *padjacency = adjacency; 965 *pstart = start; 966 *pewgts = ewgts; 967 } 968 /*}}}*/ 969 970 void pyGetJc(double* a, int nvtxs, int* Jc){ 971 /*{{{*/ 972 //get the number of non-zero elements in each row, adding to the prior number; 973 //always starts with 0 and has length: number_of_rows_in(a)+1 == nvtxs+1 974 // eg: 0, 1, 3, 6, 8, 13, ... 975 // for: 1 in the first row, 2 in the second, 3 in the third, etc. 976 int c = 0; 977 Jc[c++] = 0; 978 979 for(int i=0;i<nvtxs;i++){ 980 for(int j=0;j<nvtxs;j++){ 981 if ((int)a[i+(j*nvtxs)] != 0){ 982 Jc[c] += 1; 983 } 984 } 985 c++; 986 Jc[c] = Jc[c-1]; 987 } 988 return; 989 } 990 /*}}}*/ 991 992 void pyGetIr(double* a, int nvtxs, int nzmax, int* Ir){ 993 /*{{{*/ 994 //get the row-wise position of each non-zero element; 995 //has length: number_of_non_zero_elements_in(a) == nzmax 996 // eg: 10, 24, 25, 4, ... 997 // the 10th, 24th, and 25th elements in the first row, the 4th in the second row 998 // using pyGetJc to determine which indices correspond to which row 999 int r = 0; 1000 1001 for(int i=0;i<nvtxs;i++){ 1002 for(int j=0;j<nvtxs;j++){ 1003 if ((int)a[i+(j*nvtxs)] != 0){ 1004 Ir[r] = j; 1005 r++; 1006 } 1007 } 1008 } 1009 return; 1010 } 1011 /*}}}*/ 929 1012 930 1013 /*Python version dependent: */ -
issm/trunk-jpl/src/wrappers/python/io/pythonio.h
r22674 r23231 51 51 void FetchChacoData(int* pnvtxs,int** padjacency,int** pstart,float** pewgts,PyObject* A_IN,PyObject* EWGTS_IN); 52 52 53 void pyGetJc(double* a, int nvtxs, int* Jc); 54 void pyGetIr(double* a, int nvtxs, int nzmax, int* Ir); 55 53 56 int CheckNumPythonArguments(PyObject* inputs,int NRHS, void (*function)( void )); 54 57
Note:
See TracChangeset
for help on using the changeset viewer.