Changeset 14673
- Timestamp:
- 04/19/13 15:54:05 (12 years ago)
- Location:
- issm/trunk-jpl/src
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/modules/TriMeshx/TriMeshx.cpp
r14656 r14673 22 22 /*}}}*/ 23 23 24 void TriMeshx( IssmDenseMat<int>** pindex,IssmSeqVec<IssmPDouble>** px,IssmSeqVec<IssmPDouble>** py,IssmDenseMat<int>** psegments,IssmSeqVec<int>** psegmentmarkerlist,DataSet* domain,DataSet* rifts,double area){24 void TriMeshx(int** pindex,IssmPDouble** px,IssmPDouble** py,int** psegments,int** psegmentmarkerlist,int* pnels,int* pnods, int* pnsegs,DataSet* domain,DataSet* rifts,double area){ 25 25 26 26 #if !defined(_HAVE_TRIANGLE_) … … 31 31 32 32 /*output: */ 33 int *index = NULL; 34 IssmDenseMat<int> *index_matrix = NULL; 35 double *x = NULL; 36 double *y = NULL; 37 int *segments = NULL; 38 IssmDenseMat<int> *segments_matrix = NULL; 39 int *segmentmarkerlist = NULL; 33 int *index = NULL; 34 double *x = NULL; 35 double *y = NULL; 36 int *segments = NULL; 37 int *segmentmarkerlist = NULL; 40 38 41 39 /*intermediary: */ … … 197 195 198 196 /*Output : */ 199 index_matrix=new IssmDenseMat<int>(index,out.numberoftriangles,3,1); 200 *pindex=index_matrix; 201 202 segments_matrix=new IssmDenseMat<int>(segments,out.numberofsegments,3,1); 203 *psegments=segments_matrix; 204 205 *px=new IssmSeqVec<IssmPDouble>(x,out.numberofpoints); 206 *py=new IssmSeqVec<IssmPDouble>(y,out.numberofpoints); 207 *psegmentmarkerlist=new IssmSeqVec<int>(segmentmarkerlist,out.numberofsegments); 197 *pindex=index; 198 *px=x; 199 *py=y; 200 *psegments=segments; 201 *psegmentmarkerlist=segmentmarkerlist; 202 *pnels=out.numberoftriangles; 203 *pnods=out.numberofpoints; 204 *pnsegs=out.numberofsegments; 208 205 #endif 209 206 } -
issm/trunk-jpl/src/c/modules/TriMeshx/TriMeshx.h
r14656 r14673 11 11 12 12 /* local prototypes: */ 13 void TriMeshx(IssmDenseMat<int>** pindex,IssmSeqVec<IssmPDouble>** px,IssmSeqVec<IssmPDouble>** py,IssmDenseMat<int>** psegments,IssmSeqVec<int>** psegmentmarkerlist,DataSet* domain,DataSet* rifts,double area); 14 13 void TriMeshx(int** pindex,IssmPDouble** px,IssmPDouble** py,int** psegments,int** psegmentmarkerlist,int* pnels,int* pnods, int* pnseg,DataSet* domain,DataSet* rifts,double area); 15 14 #endif /* _TRIMESHX_H */ -
issm/trunk-jpl/src/wrappers/TriMesh/TriMesh.cpp
r14656 r14673 17 17 18 18 /*intermediary: */ 19 double area;19 double area; 20 20 DataSet *domain = NULL; 21 21 DataSet *rifts = NULL; 22 22 23 23 /* output: */ 24 IssmDenseMat<int> *index = NULL; 25 IssmSeqVec<double> *x = NULL; 26 IssmSeqVec<double> *y = NULL; 27 IssmDenseMat<int> *segments = NULL; 28 IssmSeqVec<int> *segmentmarkerlist = NULL; 24 int *index = NULL; 25 double *x = NULL; 26 double *y = NULL; 27 int *segments = NULL; 28 int *segmentmarkerlist = NULL; 29 int nels,nods,nsegs; 29 30 30 31 /*Boot module: */ … … 40 41 41 42 /*call x core: */ 42 TriMeshx(&index,&x,&y,&segments,&segmentmarkerlist, domain,rifts,area);43 TriMeshx(&index,&x,&y,&segments,&segmentmarkerlist,&nels,&nods,&nsegs,domain,rifts,area); 43 44 44 45 /*write outputs: */ 45 WriteData(INDEX,index );46 WriteData(X,x );47 WriteData(Y,y );48 WriteData(SEGMENTS,segments );49 WriteData(SEGMENTMARKERLIST,segmentmarkerlist );46 WriteData(INDEX,index,nels,3); 47 WriteData(X,x,nods); 48 WriteData(Y,y,nods); 49 WriteData(SEGMENTS,segments,nsegs,3); 50 WriteData(SEGMENTMARKERLIST,segmentmarkerlist,nsegs); 50 51 51 52 /*free ressources: */ -
issm/trunk-jpl/src/wrappers/matlab/io/WriteMatlabData.cpp
r14656 r14673 74 74 vector_matlab=(double*)mxMalloc(M*sizeof(double)); 75 75 for(int i=0;i<M;i++) vector_matlab[i]=vector[i]; 76 dataref = mxCreateDoubleMatrix(0,0,mxREAL); 77 mxSetM(dataref,(mwSize)M); 78 mxSetN(dataref,(mwSize)1); 79 mxSetPr(dataref,vector_matlab); 80 } 81 else{ 82 dataref = mxCreateDoubleMatrix(0,0,mxREAL); 83 } 84 85 *pdataref=dataref; 86 } 87 /*}}}*/ 88 /*FUNCTION WriteData(mxArray** pdataref,int* vector, int M){{{*/ 89 void WriteData(mxArray** pdataref,int* vector, int M){ 90 91 mxArray* dataref = NULL; 92 double* vector_matlab = NULL; 93 94 if(vector){ 95 96 /*create the matlab vector with Matlab's memory manager */ 97 vector_matlab=(double*)mxMalloc(M*sizeof(double)); 98 for(int i=0;i<M;i++) vector_matlab[i]=double(vector[i]); 76 99 dataref = mxCreateDoubleMatrix(0,0,mxREAL); 77 100 mxSetM(dataref,(mwSize)M); … … 290 313 } 291 314 /*}}}*/ 292 /*FUNCTION WriteData(mxArray** pdataref,IssmDenseMat<int>* matrix){{{*/293 void WriteData(mxArray** pdataref,IssmDenseMat<int>* matrix){294 295 int i,j;296 int rows,cols;297 mxArray *dataref = NULL;298 int *matrix_ptr = NULL;299 double *tmatrix_ptr = NULL;300 301 if(matrix){302 303 matrix_ptr=matrix->ToSerial();304 matrix->GetSize(&rows,&cols);305 306 /*Now transpose the matrix and allocate with Matlab's memory manager: */307 tmatrix_ptr=(double*)mxMalloc(rows*cols*sizeof(double));308 for(i=0;i<rows;i++){309 for(j=0;j<cols;j++){310 tmatrix_ptr[j*rows+i]=(double)matrix_ptr[i*cols+j];311 }312 }313 314 /*create matlab matrix: */315 dataref=mxCreateDoubleMatrix(0,0,mxREAL);316 mxSetM(dataref,rows);317 mxSetN(dataref,cols);318 mxSetPr(dataref,tmatrix_ptr);319 320 /*Free ressources:*/321 xDelete<int>(matrix_ptr);322 }323 else{324 dataref = mxCreateDoubleMatrix(0,0,mxREAL);325 }326 327 *pdataref=dataref;328 }329 /*}}}*/330 /*FUNCTION WriteData(mxArray** pdataref,IssmSeqVec<int>* vector){{{*/331 void WriteData(mxArray** pdataref,IssmSeqVec<int>* vector){332 333 mxArray* dataref=NULL;334 int* vector_ptr=NULL;335 double* vector_matlab=NULL;336 int rows;337 338 if(vector){339 /*call toolkit routine: */340 vector_ptr=vector->ToMPISerial();341 vector->GetSize(&rows);342 343 /*now create the matlab vector with Matlab's memory manager */344 vector_matlab=(double*)mxMalloc(rows*sizeof(double));345 for(int i=0;i<rows;i++) vector_matlab[i]=(double)vector_ptr[i];346 347 dataref = mxCreateDoubleMatrix(0,0,mxREAL);348 mxSetM(dataref,rows);349 mxSetN(dataref,1);350 mxSetPr(dataref,vector_matlab);351 }352 else{353 dataref = mxCreateDoubleMatrix(0,0,mxREAL);354 }355 356 /*Clean-up and return*/357 xDelete<int>(vector_ptr);358 *pdataref=dataref;359 }360 /*}}}*/361 315 /*FUNCTION WriteData(mxArray** pdataref,RiftStruct* riftstruct){{{*/ 362 316 void WriteData(mxArray** pdataref,RiftStruct* riftstruct){ -
issm/trunk-jpl/src/wrappers/matlab/io/matlabio.h
r14656 r14673 18 18 #include "../../c/toolkits/toolkits.h" 19 19 20 void WriteData(mxArray** pdataref,IssmDenseMat<int>* matrix);21 20 void WriteData(mxArray** pdataref,IssmDenseMat<double>* matrix); 22 21 void WriteData(mxArray** pdataref,double* matrix, int M,int N); 23 22 void WriteData(mxArray** pdataref,int* matrix, int M,int N); 24 void WriteData(mxArray** pdataref,IssmSeqVec<int>* vector);25 23 void WriteData(mxArray** pdataref,IssmSeqVec<double>* vector); 26 24 void WriteData(mxArray** pdataref,double* vector, int M); 25 void WriteData(mxArray** pdataref,int* vector, int M); 27 26 void WriteData(mxArray** pdataref,int integer); 28 27 void WriteData(mxArray** pdataref,bool boolean); -
issm/trunk-jpl/src/wrappers/python/io/WritePythonData.cpp
r14656 r14673 74 74 75 75 PyTuple_SetItem(tuple, index, array); 76 }/*}}}*/ 77 /*FUNCTION WriteData(PyObject* py_tuple,int index, double* vector, int M){{{*/ 78 void WriteData(PyObject* py_tuple, int index, double* vector, int M){ 79 80 double *buffer = NULL; 81 npy_intp dim = 10; 82 PyObject *array = NULL; 83 84 /*Copy vector*/ 85 buffer=xNew<double>(M); 86 for(int i=0;i<M;i++)buffer[i]=vector[i]; 87 88 dim=(npy_intp)M; 89 array=PyArray_SimpleNewFromData(1,&dim,NPY_DOUBLE,buffer); 90 91 PyTuple_SetItem(py_tuple, index, array); 92 93 }/*}}}*/ 94 /*FUNCTION WriteData(PyObject* py_tuple,int index, int* vector, int M){{{*/ 95 void WriteData(PyObject* py_tuple, int index, int* vector, int M){ 96 97 long* lvector=NULL; 98 npy_intp dim=10; 99 PyObject* array=NULL; 100 101 /*transform into long matrix: */ 102 lvector=xNew<long>(M); 103 for(int i=0;i<M;i++)lvector[i]=(long)vector[i]; 104 105 dim=(npy_intp)M; 106 array=PyArray_SimpleNewFromData(1,&dim,NPY_INT64,lvector); 107 108 PyTuple_SetItem(py_tuple, index, array); 109 76 110 }/*}}}*/ 77 111 /*FUNCTION WriteData(PyObject* py_tuple,int index){{{*/ … … 164 198 } 165 199 /*}}}*/ 166 /*FUNCTION WriteData(PyObject* py_tuple,int index,IssmDenseMat<int>* matrix){{{*/167 void WriteData(PyObject* py_tuple,int index,IssmDenseMat<int>* matrix){168 169 int M,N;170 int* ibuffer=NULL;171 npy_intp dims[2]={0,0};172 PyObject* array=NULL;173 174 matrix->GetSize(&M,&N);175 ibuffer=matrix->ToSerial();176 177 /*convert to long*/178 long* lbuffer=xNew<long>(M*N);179 for(int i=0;i<M*N;i++) lbuffer[i]=(long)ibuffer[i];180 xDelete<int>(ibuffer);181 182 dims[0]=(npy_intp)M;183 dims[1]=(npy_intp)N;184 array=PyArray_SimpleNewFromData(2,dims,NPY_INT64,lbuffer);185 186 PyTuple_SetItem(py_tuple, index, array);187 188 }/*}}}*/189 /*FUNCTION WriteData(PyObject* py_tuple,int index,IssmSeqVec<int>* vector){{{*/190 void WriteData(PyObject* py_tuple,int index,IssmSeqVec<int>* vector){191 192 int M;193 int* ibuffer=NULL;194 npy_intp dim=10;195 PyObject* array=NULL;196 197 vector->GetSize(&M);198 ibuffer=vector->ToMPISerial();199 200 /*convert to long*/201 long* lbuffer=xNew<long>(M);202 for(int i=0;i<M;i++) lbuffer[i]=(long)ibuffer[i];203 xDelete<int>(ibuffer);204 205 dim=(npy_intp)M;206 array=PyArray_SimpleNewFromData(1,&dim,NPY_INT64,lbuffer);207 208 PyTuple_SetItem(py_tuple, index, array);209 }210 /*}}}*/211 /*FUNCTION WriteData(PyObject* py_tuple,int index,IssmDenseMat<bool>* matrix){{{*/212 void WriteData(PyObject* py_tuple,int index,IssmDenseMat<bool>* matrix){213 214 int M,N;215 bool* buffer=NULL;216 npy_intp dims[2]={0,0};217 PyObject* array=NULL;218 219 matrix->GetSize(&M,&N);220 buffer=matrix->ToSerial();221 222 dims[0]=(npy_intp)M;223 dims[1]=(npy_intp)N;224 array=PyArray_SimpleNewFromData(2,dims,NPY_BOOL,buffer);225 226 PyTuple_SetItem(py_tuple, index, array);227 228 }/*}}}*/229 /*FUNCTION WriteData(PyObject* py_tuple,int index,IssmSeqVec<bool>* vector){{{*/230 void WriteData(PyObject* py_tuple,int index,IssmSeqVec<bool>* vector){231 232 int M;233 bool* buffer=NULL;234 npy_intp dim=10;235 PyObject* array=NULL;236 237 vector->GetSize(&M);238 buffer=vector->ToMPISerial();239 240 dim=(npy_intp)M;241 array=PyArray_SimpleNewFromData(1,&dim,NPY_BOOL,buffer);242 243 PyTuple_SetItem(py_tuple, index, array);244 }245 /*}}}*/246 200 /*FUNCTION WriteData(PyObject* py_tuple,int index,RiftStruct* riftstruct){{{*/ 247 201 void WriteData(PyObject* py_tuple,int index,RiftStruct* riftstruct){ -
issm/trunk-jpl/src/wrappers/python/io/pythonio.h
r14656 r14673 21 21 void WriteData(PyObject* py_tuple,int index, bool* matrix, int M,int N); 22 22 void WriteData(PyObject* py_tuple,int index, int integer); 23 void WriteData(PyObject* py_tuple,int index, double* vector, int M); 24 void WriteData(PyObject* py_tuple,int index, int* vector, int M); 23 25 void WriteData(PyObject* py_tuple,int index, char* string); 24 26 void WriteData(PyObject* py_tuple,int index); 25 27 void WriteData(PyObject* py_tuple,int index, IssmDenseMat<double>* matrix); 26 28 void WriteData(PyObject* py_tuple,int index, IssmSeqVec<double>* vector); 27 void WriteData(PyObject* py_tuple,int index, IssmDenseMat<int>* matrix);28 void WriteData(PyObject* py_tuple,int index, IssmSeqVec<int>* vector);29 void WriteData(PyObject* py_tuple,int index, IssmDenseMat<bool>* matrix);30 void WriteData(PyObject* py_tuple,int index, IssmSeqVec<bool>* vector);31 29 void WriteData(PyObject* py_tuple,int index, BamgGeom* bamggeom); 32 30 void WriteData(PyObject* py_tuple,int index, BamgMesh* bamgmesh);
Note:
See TracChangeset
for help on using the changeset viewer.