Changeset 12118
- Timestamp:
- 04/24/12 21:43:39 (13 years ago)
- Location:
- issm/trunk-jpl/src/modules
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/modules/InterpFromMeshToMesh2d/InterpFromMeshToMesh2d.cpp
r12060 r12118 4 4 #include "./InterpFromMeshToMesh2d.h" 5 5 6 void mexFunction( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]){7 6 8 int i; 7 WRAPPER(InterpFromMeshToMesh2d){ 9 8 10 9 /*input: */ 11 10 double* index=NULL; 12 11 int index_cols; 13 14 12 double* x_data=NULL; 15 13 int x_data_rows; 16 17 14 double* y_data=NULL; 18 15 int y_data_rows; 19 20 16 double* data=NULL; 21 17 int data_rows; 22 18 int data_cols; 23 24 19 double* x_interp=NULL; 20 int x_interp_rows; 25 21 double* y_interp=NULL; 26 27 int x_interp_rows;28 22 int y_interp_rows; 29 23 char* contourname=NULL; 30 24 double* default_values=NULL; 31 25 int num_default_values=0; 32 33 //contours 34 mxArray* matlabstructure=NULL; 35 Contour** contours=NULL; 36 int numcontours; 37 Contour* contouri=NULL; 26 DataSet *contours = NULL; 38 27 39 28 /*Intermediary*/ 40 int nods_data;41 29 int nels_data; 42 int nods_interp;43 int verbose=0;44 30 45 31 /* output: */ … … 49 35 MODULEBOOT(); 50 36 51 /*checks on arguments on the matlab side: */ 37 /*checks on output arguments on the matlab side: */ 38 #ifdef _HAVE_MATLAB_MODULES_ 52 39 if(nlhs!=NLHS){ 53 40 InterpFromMeshToMesh2dUsage(); 54 41 _error_("InterpFromMeshToMesh2dUsage usage error"); 55 42 } 43 #endif 44 /*check on input arguments: */ 56 45 if((nrhs!=6) & (nrhs!=8)){ 57 46 InterpFromMeshToMesh2dUsage(); … … 60 49 61 50 /*Input datasets: */ 62 if (verbose) printf("Fetching inputs\n"); 63 FetchData(&index,&nels_data,&index_cols,INDEXHANDLE); 64 FetchData(&x_data,&x_data_rows,NULL,XHANDLE); 65 FetchData(&y_data,&y_data_rows,NULL,YHANDLE); 66 FetchData(&data,&data_rows,&data_cols,DATAHANDLE); 67 FetchData(&x_interp,&x_interp_rows,NULL,XINTERPHANDLE); 68 FetchData(&y_interp,&y_interp_rows,NULL,YINTERPHANDLE); 51 FetchData(&index,&nels_data,&index_cols,INDEX); 52 FetchData(&x_data,&x_data_rows,NULL,X); 53 FetchData(&y_data,&y_data_rows,NULL,Y); 54 FetchData(&data,&data_rows,&data_cols,DATA); 55 FetchData(&x_interp,&x_interp_rows,XINTERP); 56 FetchData(&y_interp,&y_interp_rows,YINTERP); 69 57 58 /*Figure out contours and default values: */ 70 59 if(nrhs==8){ 71 72 /*Call expread on filename to build a contour array in the matlab workspace: */ 73 mexCallMATLAB( 1, &matlabstructure, 1, (mxArray**)&FILENAME, "expread"); 74 75 /*default values: */ 76 FetchData(&default_values,&num_default_values,DEFAULTHANDLE); 77 78 /*contours: */ 79 numcontours=mxGetNumberOfElements(matlabstructure); 80 contours=(Contour**)xmalloc(numcontours*sizeof(Contour*)); 81 for(i=0;i<numcontours;i++){ 82 //allocate 83 contouri=(Contour*)xmalloc(sizeof(Contour)); 84 //retrieve dimension of this contour. 85 contouri->nods=(int)mxGetScalar(mxGetField(matlabstructure,i,"nods")); 86 //set pointers. 87 contouri->x=mxGetPr(mxGetField(matlabstructure,i,"x")); 88 contouri->y=mxGetPr(mxGetField(matlabstructure,i,"y")); 89 *(contours+i)=contouri; 90 } 91 92 /* Debugging of contours :{{{1*/ 93 /*for(i=0;i<numcontours;i++){ 94 printf("\nContour echo: contour number %i / %i\n",i+1,numcontours); 95 contouri=*(contours+i); 96 printf(" Number of vertices %i\n",contouri->nods); 97 for (j=0;j<contouri->nods;j++){ 98 printf(" %lf %lf\n",*(contouri->x+j),*(contouri->y+j)); 99 } 100 }*/ 101 /*}}}*/ 60 FetchData(&default_values,&num_default_values,DEFAULT); 61 FetchData(&contourname,CONTOURNAME); 62 contours=DomainOutlineRead(contourname); 102 63 } 103 64 else{ 104 65 num_default_values=0; 105 66 default_values=NULL; 106 numcontours=0; 107 contours=NULL; 67 contours=new DataSet(); 108 68 } 109 69 70 110 71 /*some checks*/ 111 if (verbose) printf("Checking inputs\n");112 72 if (x_data_rows!=y_data_rows){ 113 73 _error_("vectors x and y should have the same length!"); … … 120 80 } 121 81 122 /*get number of elements and number of nodes in the data*/123 nods_data=x_data_rows;124 nods_interp=x_interp_rows;125 126 82 /* Run core computations: */ 127 if (verbose) printf("Call core\n"); 128 InterpFromMeshToMesh2dx(&data_interp,index,x_data,y_data,nods_data,nels_data,data,data_rows,data_cols,x_interp,y_interp,nods_interp,default_values,num_default_values,contours,numcontours); 83 InterpFromMeshToMesh2dx(&data_interp,index,x_data,y_data,x_data_rows,nels_data,data,data_rows,data_cols,x_interp,y_interp,x_interp_rows,default_values,num_default_values,contours); 129 84 130 85 /*Write data: */ 131 WriteData(DATAINTERP,data_interp, nods_interp,data_cols);86 WriteData(DATAINTERP,data_interp,x_interp_rows,data_cols); 132 87 133 88 /*end module: */ … … 135 90 } 136 91 137 void InterpFromMeshToMesh2dUsage(void) 92 void InterpFromMeshToMesh2dUsage(void)//{{{1 93 138 94 { 139 95 _printf_(true,"INTERFROMMESHTOMESH2D - interpolation from a 2d triangular mesh onto a list of point\n"); … … 161 117 _printf_(true,"\n"); 162 118 } 119 //}}} -
issm/trunk-jpl/src/modules/InterpFromMeshToMesh2d/InterpFromMeshToMesh2d.h
r12013 r12118 6 6 #define _INTERPFROMMESHTOMESH2d_H 7 7 8 /* local prototypes: */ 9 void InterpFromMeshToMesh2dUsage(void); 8 #ifdef HAVE_CONFIG_H 9 #include <config.h> 10 #else 11 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!" 12 #endif 10 13 14 /*Very important definition in case we are compiling a python module!: needs to come before header files inclusion*/ 15 #ifdef _HAVE_PYTHON_ 16 #define PY_ARRAY_UNIQUE_SYMBOL PythonIOSymbol 17 #endif 18 19 /*Header files: */ 11 20 #include "../../c/include/globals.h" 21 #include "../../c/toolkits/toolkits.h" 22 #include "../../c/include/include.h" 12 23 #include "../../c/modules/modules.h" 13 24 #include "../../c/Container/Container.h" 14 25 #include "../../c/shared/shared.h" 15 26 #include "../../c/issm-binding.h" 27 #include "../../c/io/io.h" 28 #include "../../c/EnumDefinitions/EnumDefinitions.h" 29 30 #ifdef _HAVE_MATLAB_MODULES_ 31 /* serial input macros: */ 32 #define INDEX prhs[0] 33 #define X prhs[1] 34 #define Y prhs[2] 35 #define DATA prhs[3] 36 #define XINTERP prhs[4] 37 #define YINTERP prhs[5] 38 #define DEFAULT prhs[6] 39 #define CONTOURNAME prhs[7] 40 41 /* serial output macros: */ 42 #define DATAINTERP (mxArray**)&plhs[0] 43 #endif 44 45 #ifdef _HAVE_PYTHON_MODULES_ 46 /* serial input macros: */ 47 #define INDEX PyTuple_GetItem(args,0) 48 #define X PyTuple_GetItem(args,1) 49 #define Y PyTuple_GetItem(args,2) 50 #define DATA PyTuple_GetItem(args,3) 51 #define XINTERP PyTuple_GetItem(args,4) 52 #define YINTERP PyTuple_GetItem(args,5) 53 #define DEFAULT PyTuple_GetItem(args,6) 54 #define CONTOURNAME PyTuple_GetItem(args,7) 55 /* serial output macros: */ 56 #define DATAINTERP output,0 57 #endif 16 58 17 59 #undef __FUNCT__ 18 60 #define __FUNCT__ "InterpFromMeshToMesh2d" 19 61 20 21 /* serial input macros: */22 #define INDEXHANDLE prhs[0]23 #define XHANDLE prhs[1]24 #define YHANDLE prhs[2]25 #define DATAHANDLE prhs[3]26 #define XINTERPHANDLE prhs[4]27 #define YINTERPHANDLE prhs[5]28 #define DEFAULTHANDLE prhs[6]29 #define FILENAME prhs[7]30 31 /* serial output macros: */32 #define DATAINTERP (mxArray**)&plhs[0]33 34 62 /* serial arg counts: */ 35 63 #undef NLHS 36 64 #define NLHS 1 65 #undef NRHS 66 #define NRHS 6 //can be 8 though 67 68 /* local prototypes: */ 69 void InterpFromMeshToMesh2dUsage(void); 37 70 38 71 #endif -
issm/trunk-jpl/src/modules/python/Makefile.am
r12112 r12118 3 3 #Bin programs {{{1 4 4 if MODULES 5 bin_PROGRAMS = TriMesh \ 6 NodeConnectivity \ 7 ElementConnectivity 5 bin_PROGRAMS = ElementConnectivity\ 6 InterpFromMeshToMesh2d \ 7 NodeConnectivity\ 8 TriMesh 8 9 endif 9 10 #}}} … … 31 32 ../ElementConnectivity/ElementConnectivity.h 32 33 34 InterpFromMeshToMesh2d_SOURCES = ../InterpFromMeshToMesh2d/InterpFromMeshToMesh2d.cpp\ 35 ../InterpFromMeshToMesh2d/InterpFromMeshToMesh2d.h 36 33 37 NodeConnectivity_SOURCES = ../NodeConnectivity/NodeConnectivity.cpp\ 34 38 ../NodeConnectivity/NodeConnectivity.h
Note:
See TracChangeset
for help on using the changeset viewer.