Changeset 12601
- Timestamp:
- 07/03/12 08:39:20 (13 years ago)
- Location:
- issm/trunk-jpl/src/modules
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/modules/BamgConvertMesh/BamgConvertMesh.cpp
r12518 r12601 4 4 #include "./BamgConvertMesh.h" 5 5 6 void mexFunction( 6 void mexFunction(int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]){ 7 7 8 8 /*input: */ 9 double* index=NULL; 10 int index_rows; 11 double* x=NULL; 12 int x_cols; 13 double* y=NULL; 14 int y_rows; 15 int y_cols; 9 int *index = NULL; 10 double *x = NULL; 11 double *y = NULL; 12 int nods,nels,test1,test2; 16 13 17 14 /*Output*/ 18 BamgMesh* bamgmesh=NULL; 19 BamgGeom* bamggeom=NULL; 20 mxArray* bamgmesh_mat=NULL; 21 mxArray* bamggeom_mat=NULL; 22 23 /*Intermediary*/ 24 int nods; 25 int nels; 26 int verbose=0; 15 BamgMesh *bamgmesh = NULL; 16 BamgGeom *bamggeom = NULL; 17 mxArray *bamgmesh_mat = NULL; 18 mxArray *bamggeom_mat = NULL; 27 19 28 20 /*Boot module: */ … … 37 29 38 30 /*Input datasets: */ 39 if (verbose) _printLine_("Fetching inputs"); 40 FetchData(&index,&nels,&index_rows,INDEXHANDLE); 41 FetchData(&x,&nods,&x_cols,XHANDLE); 42 FetchData(&y,&y_rows,&y_cols,YHANDLE); 31 FetchData(&index,&nels,&test1,INDEXHANDLE); 32 FetchData(&x,&nods,XHANDLE); 33 FetchData(&y,&test2,YHANDLE); 43 34 44 35 /*Check inputs*/ 45 if (nels<0){ 46 _error2_("Number of elements must be positive, check index number of lines"); 47 } 48 if (nods<0){ 49 _error2_("Number of nods must be positive, check x and y sizes"); 50 } 51 if (index_rows!=3){ 52 _error2_("index should have 3 columns"); 53 } 54 if (y_rows!=nods){ 55 _error2_("x and y do not have the same length"); 56 } 57 if (x_cols>1 || y_cols>1){ 58 _error2_("x and y should have only one column"); 59 } 36 if(nels<0) _error2_("Number of elements must be positive, check index number of lines"); 37 if(nods<0) _error2_("Number of nods must be positive, check x and y sizes"); 38 if(test1!=3) _error2_("index should have 3 columns"); 39 if(test2!=nods) _error2_("x and y do not have the same length"); 60 40 61 41 /* Run core computations: */ 62 if (verbose) _printLine_("Call core");63 42 BamgConvertMeshx(bamgmesh,bamggeom,index,x,y,nods,nels); 64 43 … … 75 54 } 76 55 77 void BamgConvertMeshUsage(void) 78 { 56 void BamgConvertMeshUsage(void){ 79 57 _pprintString_("BAMGCONVERTMESH - convert [x y index] to a bamg geom and mesh geom"); 80 58 _pprintLine_(""); -
issm/trunk-jpl/src/modules/InterpFromMeshToMesh2d/InterpFromMeshToMesh2d.cpp
r12518 r12601 7 7 WRAPPER(InterpFromMeshToMesh2d){ 8 8 9 /*input: */ 10 double* index=NULL; 11 int index_cols; 12 double* x_data=NULL; 13 int x_data_rows; 14 double* y_data=NULL; 15 int y_data_rows; 16 double* data=NULL; 17 int data_rows; 18 int data_cols; 19 double* x_interp=NULL; 20 int x_interp_rows; 21 double* y_interp=NULL; 22 int y_interp_rows; 23 char* contourname=NULL; 24 double* default_values=NULL; 25 int num_default_values=0; 26 DataSet *contours = NULL; 27 28 /*Intermediary*/ 29 int nels_data; 30 31 /* output: */ 32 double* data_interp=NULL; 9 /*Intermediaties*/ 10 int *index = NULL; 11 double *x_data = NULL; 12 double *y_data = NULL; 13 double *data = NULL; 14 int nods_data,nels_data; 15 int M_data,N_data; 16 double *x_interp = NULL; 17 double *y_interp = NULL; 18 int N_interp; 19 Options *options = NULL; 20 double *data_interp = NULL; 21 int test1,test2,test; 33 22 34 23 /*Boot module: */ … … 43 32 #endif 44 33 /*check on input arguments: */ 45 if( (nrhs!=6) & (nrhs!=8)){34 if(nrhs<NRHS){ 46 35 InterpFromMeshToMesh2dUsage(); 47 36 _error2_("InterpFromMeshToMesh2dUsage usage error"); 48 37 } 49 38 50 /*Input datasets: */ 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); 39 /*Fetch inputs: */ 40 FetchData(&index,&nels_data,&test,INDEX); if(test!=3) _error2_("index should have 3 columns"); 41 FetchData(&x_data,&nods_data,X); if(nods_data<3) _error2_("there should be at least three points"); 42 FetchData(&y_data,&test,Y); if(test!=nods_data) _error2_("vectors x and y should have the same length"); 43 FetchData(&data,&M_data,&N_data,DATA); if(M_data*N_data<1) _error2_("data is empty"); 44 FetchData(&x_interp,&N_interp,XINTERP); if(N_interp<1) _error2_("no interpolation requested"); 45 FetchData(&y_interp,&test,YINTERP); if(test!=N_interp) _error2_("vectors x_interp and y_interp should have the same length"); 46 FetchData(&options,NRHS,nrhs,prhs); 57 47 58 /*Figure out contours and default values: */ 59 if(nrhs==8){ 60 FetchData(&default_values,&num_default_values,DEFAULT); 61 FetchData(&contourname,CONTOURNAME); 62 contours=DomainOutlineRead(contourname); 63 } 64 else{ 65 num_default_values=0; 66 default_values=NULL; 67 contours=new DataSet(); 68 } 69 70 71 /*some checks*/ 72 if (x_data_rows!=y_data_rows){ 73 _error2_("vectors x and y should have the same length!"); 74 } 75 if (x_interp_rows!=y_interp_rows){ 76 _error2_("vectors x_interp and y_interp should have the same length!"); 77 } 78 if (index_cols!=3){ 79 _error2_("index should have 3 columns (input provided has " << index_cols << " columns)"); 80 } 81 82 /* Run core computations: */ 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); 48 /*Run core computations*/ 49 InterpFromMeshToMesh2dx(&data_interp,index,x_data,y_data,nods_data,nels_data,data,M_data,N_data,x_interp,y_interp,N_interp,options); 84 50 85 51 /*Write data: */ 86 WriteData(DATAINTERP,data_interp, x_interp_rows,data_cols);52 WriteData(DATAINTERP,data_interp,N_interp,N_data); 87 53 88 54 /*end module: */ … … 90 56 } 91 57 92 void InterpFromMeshToMesh2dUsage(void)//{{{1 93 94 { 58 void InterpFromMeshToMesh2dUsage(void){ /*{{{*/ 95 59 _pprintLine_("INTERFROMMESHTOMESH2D - interpolation from a 2d triangular mesh onto a list of point"); 96 60 _pprintLine_(""); 97 61 _pprintLine_(" This function is a multi-threaded mex file that interpolates a field"); 98 _pprintLine_(" defined on a triangular meshonto a list of point");62 _pprintLine_(" defined on a Delaunay triangulation onto a list of point"); 99 63 _pprintLine_(""); 100 64 _pprintLine_(" Usage:"); 101 65 _pprintLine_(" data_interp=InterpFromMeshToMesh2d(index,x,y,data,x_interp,y_interp);"); 102 _pprintLine_(" or data_interp=InterpFromMeshToMesh2d(index,x,y,data,x_interp,y_interp, default_value,contourname);");66 _pprintLine_(" or data_interp=InterpFromMeshToMesh2d(index,x,y,data,x_interp,y_interp,OPTIONS);"); 103 67 _pprintLine_(""); 104 _pprintLine_(" index: index of the mesh where data is defined"); 105 _pprintLine_(" x,y: coordinates of the nodes where data is defined"); 106 _pprintLine_(" data: matrix holding the data to be interpolated onto the mesh. (one column per field)"); 107 _pprintLine_(" x_interp,y_interp: coordinates of the points onto which we interpolate."); 108 _pprintLine_(" if default_value and contourname not specified: linear interpolation will happen on all x_interp,y_interp."); 109 _pprintLine_(" if (default_value,contourname) specified: linear interpolation will happen on all x_interp,y_interp inside the contour, default value will be adopted on the rest of the mesh."); 110 _pprintLine_(" note that default_value is either a scalar, or a vector of size length(x_interp)"); 111 _pprintLine_(" data_interp: vector of mesh interpolated data."); 68 _pprintLine_(" index : index of the mesh where data is defined"); 69 _pprintLine_(" x,y : coordinates of the nodes where data is defined"); 70 _pprintLine_(" data : matrix holding the data to be interpolated onto the mesh. (one column per field)"); 71 _pprintLine_(" x_interp,y_interp : coordinates of the points onto which we interpolate."); 72 _pprintLine_(" data_interp : vector of mesh interpolated data."); 73 _pprintLine_(" Available options :"); 74 _pprintLine_(" - 'default' : default value if point is outsite of triangulation (instead of linear interolation)"); 112 75 _pprintLine_(""); 113 76 _pprintLine_(" Example:"); 114 77 _pprintLine_(" load('temperature.mat');"); 115 78 _pprintLine_(" md.initialization.temperature=InterpFromMeshToMesh2d(index,x,y,temperature,md.mesh.x,md.mesh.y);"); 116 _pprintLine_(" md.initialization.temperature=InterpFromMeshToMesh2d(index,x,y,temperature,md.mesh.x,md.mesh.y, 253,'Contour.exp');");79 _pprintLine_(" md.initialization.temperature=InterpFromMeshToMesh2d(index,x,y,temperature,md.mesh.x,md.mesh.y,'default',253);"); 117 80 _pprintLine_(""); 118 81 } 119 / /}}}82 /*}}}*/ -
issm/trunk-jpl/src/modules/InterpFromMeshToMesh2d/InterpFromMeshToMesh2d.h
r12118 r12601 12 12 #endif 13 13 14 /*Very important definition in case we are compiling a python module!: needs to come before header files inclusion*/ 14 /* local prototypes: */ 15 void InterpFromMeshToMesh2dUsage(void); 16 17 /*If python: this macro needs to come before header files inclusion*/ 15 18 #ifdef _HAVE_PYTHON_ 16 19 #define PY_ARRAY_UNIQUE_SYMBOL PythonIOSymbol … … 28 31 #include "../../c/EnumDefinitions/EnumDefinitions.h" 29 32 33 #undef __FUNCT__ 34 #define __FUNCT__ "InterpFromMeshToMesh2d" 35 30 36 #ifdef _HAVE_MATLAB_MODULES_ 31 37 /* serial input macros: */ … … 36 42 #define XINTERP prhs[4] 37 43 #define YINTERP prhs[5] 38 #define DEFAULT prhs[6]39 #define CONTOURNAME prhs[7]40 44 41 45 /* serial output macros: */ … … 51 55 #define XINTERP PyTuple_GetItem(args,4) 52 56 #define YINTERP PyTuple_GetItem(args,5) 53 #define DEFAULT PyTuple_GetItem(args,6) 54 #define CONTOURNAME PyTuple_GetItem(args,7) 57 55 58 /* serial output macros: */ 56 59 #define DATAINTERP output,0 57 60 #endif 58 59 #undef __FUNCT__60 #define __FUNCT__ "InterpFromMeshToMesh2d"61 61 62 62 /* serial arg counts: */ … … 64 64 #define NLHS 1 65 65 #undef NRHS 66 #define NRHS 6 //can be 8 though 67 68 /* local prototypes: */ 69 void InterpFromMeshToMesh2dUsage(void); 66 #define NRHS 6 70 67 71 68 #endif -
issm/trunk-jpl/src/modules/TriaSearch/TriaSearch.cpp
r12518 r12601 9 9 10 10 /*input: */ 11 double*index=NULL;11 int* index=NULL; 12 12 int nel; 13 13 int dummy; … … 37 37 FetchData(&y0,&numberofnodes,Y0HANDLE); 38 38 39 /* Echo: {{{1*/40 //_printLine_("(x0,y0)=(" << x0 << "," << y0 << ")");41 /*}}}*/42 43 39 /* Run core computations: */ 44 40 TriaSearchx(&tria,index,nel,x,y,nods,x0,y0,numberofnodes); … … 54 50 } 55 51 56 void TriaSearchUsage(void) 57 { 52 void TriaSearchUsage(void){ 58 53 _pprintLine_("TriaSearch- find triangle holding a point (x0,y0) in a mesh"); 59 54 _pprintLine_("");
Note:
See TracChangeset
for help on using the changeset viewer.