Changeset 21110
- Timestamp:
- 08/07/16 22:43:42 (9 years ago)
- Location:
- issm/trunk-jpl/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/modules/InterpFromGridToMeshx/InterpFromGridToMeshx.cpp
r16282 r21110 3 3 */ 4 4 5 /*Include {{{*/6 5 #ifdef HAVE_CONFIG_H 7 6 #include <config.h> … … 10 9 #endif 11 10 11 #include <cstring> 12 12 #include "./InterpFromGridToMeshx.h" 13 13 #include "../../shared/shared.h" 14 14 #include "../../shared/io/io.h" 15 /*}}}*/16 15 17 16 /*InterpFromGridToMeshx{{{*/ 18 int InterpFromGridToMeshx(IssmSeqVec<IssmPDouble>** pdata_mesh,double* x_in, int x_rows, double* y_in, int y_rows, double* data, int M, int N, double* x_mesh, double* y_mesh, int nods,double default_value, int interpenum){17 int InterpFromGridToMeshx(IssmSeqVec<IssmPDouble>** pdata_mesh,double* x_in, int x_rows, double* y_in, int y_rows, double* data, int M, int N, double* x_mesh, double* y_mesh, int nods,double default_value,const char* interptype){ 19 18 20 19 /*output: */ … … 75 74 gate.data = data; 76 75 gate.default_value = default_value; 77 gate.interp = interp enum;76 gate.interp = interptype; 78 77 gate.M = M; 79 78 gate.N = N; … … 123 122 double *data = gate->data; 124 123 double default_value = gate->default_value; 125 int interpenum= gate->interp;124 const char* interptype = gate->interp; 126 125 int M = gate->M; 127 126 int N = gate->N; … … 159 158 Q22=data[(m+1)*N+n+1]; 160 159 161 switch(interpenum){ 162 case TriangleInterpEnum: 163 data_value=triangleinterp(x1,x2,y1,y2,Q11,Q12,Q21,Q22,x_grid,y_grid); 164 break; 165 case BilinearInterpEnum: 166 data_value=bilinearinterp(x1,x2,y1,y2,Q11,Q12,Q21,Q22,x_grid,y_grid); 167 break; 168 case NearestInterpEnum: 169 data_value=nearestinterp(x1,x2,y1,y2, Q11,Q12,Q21,Q22,x_grid,y_grid); 170 break; 171 default: 172 _printf_("Interpolation " << EnumToStringx(interpenum) << " not supported yet\n"); 173 return NULL; /*WARNING: no error because it would blow up the multithreading!*/ 160 if(strcmp(interptype,"triangle")==0){ 161 data_value=triangleinterp(x1,x2,y1,y2,Q11,Q12,Q21,Q22,x_grid,y_grid); 162 } 163 else if(strcmp(interptype,"bilinear")==0){ 164 data_value=bilinearinterp(x1,x2,y1,y2,Q11,Q12,Q21,Q22,x_grid,y_grid); 165 } 166 else if(strcmp(interptype,"nearest")==0){ 167 data_value=nearestinterp(x1,x2,y1,y2, Q11,Q12,Q21,Q22,x_grid,y_grid); 168 } 169 else{ 170 _printf_("Interpolation " << interptype << " not supported yet (supported intepolations are: triangle, bilinear and nearest)\n"); 171 return NULL; /*WARNING: no error because it would blow up the multithreading!*/ 174 172 } 175 173 if(xIsNan<IssmPDouble>(data_value)) data_value=default_value; -
issm/trunk-jpl/src/c/modules/InterpFromGridToMeshx/InterpFromGridToMeshx.h
r15000 r21110 18 18 double* data; 19 19 double default_value; 20 intinterp;20 const char* interp; 21 21 int M; 22 22 int N; … … 27 27 } InterpFromGridToMeshxThreadStruct; 28 28 29 int InterpFromGridToMeshx(IssmSeqVec<IssmPDouble>** pdata_mesh,double* x, int x_rows, double* y, int y_rows, double* data, int M, int N, double* x_mesh, double* y_mesh, int nods, double default_value, int interpenum=BilinearInterpEnum);29 int InterpFromGridToMeshx(IssmSeqVec<IssmPDouble>** pdata_mesh,double* x, int x_rows, double* y, int y_rows, double* data, int M, int N, double* x_mesh, double* y_mesh, int nods, double default_value, const char* interptype); 30 30 void* InterpFromGridToMeshxt(void* vInterpFromGridToMeshxThreadStruct); 31 31 bool findindices(int* pn,int* pm,double* x,int x_rows, double* y,int y_rows, double xgrid,double ygrid); -
issm/trunk-jpl/src/wrappers/InterpFromGridToMesh/InterpFromGridToMesh.cpp
r20877 r21110 39 39 int x_mesh_rows,y_mesh_rows; 40 40 double default_value; 41 int interpolationenum;41 char* interpolationtype = NULL; 42 42 43 43 /* output: */ … … 63 63 /* Run core computations: */ 64 64 if(nrhs==7){ 65 FetchData(&interpolationenum,INTERPENUM); 66 InterpFromGridToMeshx(&data_mesh, x, x_rows, y, y_rows, data, data_rows,data_cols, x_mesh, y_mesh, x_mesh_rows,default_value,interpolationenum); 65 FetchData(&interpolationtype,INTERPENUM); 66 InterpFromGridToMeshx(&data_mesh, x, x_rows, y, y_rows, data, data_rows,data_cols, x_mesh, y_mesh, x_mesh_rows,default_value,interpolationtype); 67 xDelete<char>(interpolationtype); 67 68 } 68 69 else{ 69 InterpFromGridToMeshx(&data_mesh, x, x_rows, y, y_rows, data, data_rows,data_cols, x_mesh, y_mesh, x_mesh_rows,default_value );70 InterpFromGridToMeshx(&data_mesh, x, x_rows, y, y_rows, data, data_rows,data_cols, x_mesh, y_mesh, x_mesh_rows,default_value,"bilinear"); 70 71 } 71 72
Note:
See TracChangeset
for help on using the changeset viewer.