Changeset 12601


Ignore:
Timestamp:
07/03/12 08:39:20 (13 years ago)
Author:
Mathieu Morlighem
Message:

Simplified InterpFromMeshToMesh2dx by adding options, and index is now always int

Location:
issm/trunk-jpl/src/modules
Files:
4 edited

Legend:

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

    r12518 r12601  
    44#include "./BamgConvertMesh.h"
    55
    6 void mexFunction( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]){
     6void mexFunction(int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]){
    77
    88        /*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;
    1613
    1714        /*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;
    2719
    2820        /*Boot module: */
     
    3729
    3830        /*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);
    4334
    4435        /*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");
    6040
    6141        /* Run core computations: */
    62         if (verbose) _printLine_("Call core");
    6342        BamgConvertMeshx(bamgmesh,bamggeom,index,x,y,nods,nels);
    6443
     
    7554}
    7655
    77 void BamgConvertMeshUsage(void)
    78 {
     56void BamgConvertMeshUsage(void){
    7957        _pprintString_("BAMGCONVERTMESH - convert [x y index] to a bamg geom and mesh geom");
    8058        _pprintLine_("");
  • issm/trunk-jpl/src/modules/InterpFromMeshToMesh2d/InterpFromMeshToMesh2d.cpp

    r12518 r12601  
    77WRAPPER(InterpFromMeshToMesh2d){
    88
    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;
    3322
    3423        /*Boot module: */
     
    4332        #endif
    4433        /*check on input arguments: */
    45         if((nrhs!=6) & (nrhs!=8)){
     34        if(nrhs<NRHS){
    4635                InterpFromMeshToMesh2dUsage();
    4736                _error2_("InterpFromMeshToMesh2dUsage usage error");
    4837        }
    4938
    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);
    5747
    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);
    8450
    8551        /*Write data: */
    86         WriteData(DATAINTERP,data_interp,x_interp_rows,data_cols);
     52        WriteData(DATAINTERP,data_interp,N_interp,N_data);
    8753
    8854        /*end module: */
     
    9056}
    9157
    92 void InterpFromMeshToMesh2dUsage(void)//{{{1
    93 
    94 {
     58void InterpFromMeshToMesh2dUsage(void){ /*{{{*/
    9559        _pprintLine_("INTERFROMMESHTOMESH2D - interpolation from a 2d triangular mesh onto a list of point");
    9660        _pprintLine_("");
    9761        _pprintLine_("   This function is a multi-threaded mex file that interpolates a field");
    98         _pprintLine_("   defined on a triangular mesh onto a list of point");
     62        _pprintLine_("   defined on a Delaunay triangulation onto a list of point");
    9963        _pprintLine_("");
    10064        _pprintLine_("   Usage:");
    10165        _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);");
    10367        _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)");
    11275        _pprintLine_("");
    11376        _pprintLine_("   Example:");
    11477        _pprintLine_("      load('temperature.mat');");
    11578        _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);");
    11780        _pprintLine_("");
    11881}
    119 //}}}
     82/*}}}*/
  • issm/trunk-jpl/src/modules/InterpFromMeshToMesh2d/InterpFromMeshToMesh2d.h

    r12118 r12601  
    1212#endif
    1313
    14 /*Very important definition in case we are compiling a python module!: needs to come before header files inclusion*/
     14/* local prototypes: */
     15void InterpFromMeshToMesh2dUsage(void);
     16
     17/*If python: this macro needs to come before header files inclusion*/
    1518#ifdef _HAVE_PYTHON_
    1619#define PY_ARRAY_UNIQUE_SYMBOL PythonIOSymbol
     
    2831#include "../../c/EnumDefinitions/EnumDefinitions.h"
    2932
     33#undef __FUNCT__
     34#define __FUNCT__  "InterpFromMeshToMesh2d"
     35
    3036#ifdef _HAVE_MATLAB_MODULES_
    3137/* serial input macros: */
     
    3642#define XINTERP prhs[4]
    3743#define YINTERP prhs[5]
    38 #define DEFAULT prhs[6]
    39 #define CONTOURNAME prhs[7]
    4044
    4145/* serial output macros: */
     
    5155#define XINTERP PyTuple_GetItem(args,4)
    5256#define YINTERP PyTuple_GetItem(args,5)
    53 #define DEFAULT PyTuple_GetItem(args,6)
    54 #define CONTOURNAME PyTuple_GetItem(args,7)
     57
    5558/* serial output macros: */
    5659#define DATAINTERP output,0
    5760#endif
    58 
    59 #undef __FUNCT__
    60 #define __FUNCT__  "InterpFromMeshToMesh2d"
    6161
    6262/* serial arg counts: */
     
    6464#define NLHS  1
    6565#undef NRHS
    66 #define NRHS  6 //can be 8 though
    67 
    68 /* local prototypes: */
    69 void InterpFromMeshToMesh2dUsage(void);
     66#define NRHS  6
    7067
    7168#endif
  • issm/trunk-jpl/src/modules/TriaSearch/TriaSearch.cpp

    r12518 r12601  
    99
    1010        /*input: */
    11         double* index=NULL;
     11        int*    index=NULL;
    1212        int     nel;
    1313        int     dummy;
     
    3737        FetchData(&y0,&numberofnodes,Y0HANDLE);
    3838
    39         /* Echo: {{{1*/
    40         //_printLine_("(x0,y0)=(" << x0 << "," << y0 << ")");
    41         /*}}}*/
    42 
    4339        /* Run core computations: */
    4440        TriaSearchx(&tria,index,nel,x,y,nods,x0,y0,numberofnodes);
     
    5450}
    5551
    56 void TriaSearchUsage(void)
    57 {
     52void TriaSearchUsage(void){
    5853        _pprintLine_("TriaSearch- find triangle holding a point (x0,y0) in a mesh");
    5954        _pprintLine_("");
Note: See TracChangeset for help on using the changeset viewer.