Changeset 21110


Ignore:
Timestamp:
08/07/16 22:43:42 (9 years ago)
Author:
Mathieu Morlighem
Message:

CHG: interpolation type is now provided as a string rather than an Enum

Location:
issm/trunk-jpl/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/c/modules/InterpFromGridToMeshx/InterpFromGridToMeshx.cpp

    r16282 r21110  
    33 */
    44
    5 /*Include {{{*/
    65#ifdef HAVE_CONFIG_H
    76        #include <config.h>
     
    109#endif
    1110
     11#include <cstring>
    1212#include "./InterpFromGridToMeshx.h"
    1313#include "../../shared/shared.h"
    1414#include "../../shared/io/io.h"
    15 /*}}}*/
    1615
    1716/*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){
     17int 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){
    1918
    2019        /*output: */
     
    7574        gate.data          = data;
    7675        gate.default_value = default_value;
    77         gate.interp        = interpenum;
     76        gate.interp        = interptype;
    7877        gate.M             = M;
    7978        gate.N             = N;
     
    123122        double *data                  = gate->data;
    124123        double  default_value         = gate->default_value;
    125         int     interpenum            = gate->interp;
     124        const char* interptype        = gate->interp;
    126125        int     M                     = gate->M;
    127126        int     N                     = gate->N;
     
    159158                        Q22=data[(m+1)*N+n+1];
    160159
    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!*/
    174172                        }
    175173                        if(xIsNan<IssmPDouble>(data_value)) data_value=default_value;
  • issm/trunk-jpl/src/c/modules/InterpFromGridToMeshx/InterpFromGridToMeshx.h

    r15000 r21110  
    1818        double*             data;
    1919        double              default_value;
    20         int                 interp;
     20        const char*         interp;
    2121        int                 M;
    2222        int                 N;
     
    2727} InterpFromGridToMeshxThreadStruct;
    2828
    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);
     29int    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);
    3030void*  InterpFromGridToMeshxt(void* vInterpFromGridToMeshxThreadStruct);
    3131bool   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  
    3939        int     x_mesh_rows,y_mesh_rows;
    4040        double  default_value;
    41         int     interpolationenum;
     41        char*   interpolationtype = NULL;
    4242
    4343        /* output: */
     
    6363        /* Run core computations: */
    6464        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);
    6768        }
    6869        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");
    7071        }
    7172
Note: See TracChangeset for help on using the changeset viewer.