source: issm/trunk/src/wrappers/InterpFromMeshToMesh2d/InterpFromMeshToMesh2d.cpp@ 13975

Last change on this file since 13975 was 13236, checked in by Mathieu Morlighem, 13 years ago

CHG: preparing files for python inclusion

File size: 3.4 KB
Line 
1/*\file InterpFromMeshToMesh2d.c
2 *\brief: bamg module.
3 */
4#include "./InterpFromMeshToMesh2d.h"
5
6void InterpFromMeshToMesh2dUsage(void){/*{{{*/
7 _pprintLine_("INTERFROMMESHTOMESH2D - interpolation from a 2d triangular mesh onto a list of point");
8 _pprintLine_("");
9 _pprintLine_(" This function is a multi-threaded mex file that interpolates a field");
10 _pprintLine_(" defined on a Delaunay triangulation onto a list of point");
11 _pprintLine_("");
12 _pprintLine_(" Usage:");
13 _pprintLine_(" data_interp=InterpFromMeshToMesh2d(index,x,y,data,x_interp,y_interp);");
14 _pprintLine_(" or data_interp=InterpFromMeshToMesh2d(index,x,y,data,x_interp,y_interp,OPTIONS);");
15 _pprintLine_("");
16 _pprintLine_(" index : index of the mesh where data is defined");
17 _pprintLine_(" x,y : coordinates of the nodes where data is defined");
18 _pprintLine_(" data : matrix holding the data to be interpolated onto the mesh. (one column per field)");
19 _pprintLine_(" x_interp,y_interp : coordinates of the points onto which we interpolate.");
20 _pprintLine_(" data_interp : vector of mesh interpolated data.");
21 _pprintLine_(" Available options :");
22 _pprintLine_(" - 'default' : default value if point is outsite of triangulation (instead of linear interolation)");
23 _pprintLine_("");
24 _pprintLine_(" Example:");
25 _pprintLine_(" load('temperature.mat');");
26 _pprintLine_(" md.initialization.temperature=InterpFromMeshToMesh2d(index,x,y,temperature,md.mesh.x,md.mesh.y);");
27 _pprintLine_(" md.initialization.temperature=InterpFromMeshToMesh2d(index,x,y,temperature,md.mesh.x,md.mesh.y,'default',253);");
28 _pprintLine_("");
29}/*}}}*/
30WRAPPER(InterpFromMeshToMesh2d){
31
32 /*Intermediaties*/
33 int *index = NULL;
34 double *x_data = NULL;
35 double *y_data = NULL;
36 double *data = NULL;
37 int nods_data,nels_data;
38 int M_data,N_data;
39 double *x_interp = NULL;
40 double *y_interp = NULL;
41 int N_interp;
42 Options *options = NULL;
43 double *data_interp = NULL;
44 int test1,test2,test;
45
46 /*Boot module: */
47 MODULEBOOT();
48
49 /*checks on output arguments on the matlab side: */
50 #ifdef _HAVE_MATLAB_MODULES_
51 if(nlhs!=NLHS){
52 InterpFromMeshToMesh2dUsage();
53 _error_("InterpFromMeshToMesh2dUsage usage error");
54 }
55 #endif
56 /*check on input arguments: */
57 if(nrhs<NRHS){
58 InterpFromMeshToMesh2dUsage();
59 _error_("InterpFromMeshToMesh2dUsage usage error");
60 }
61
62 /*Fetch inputs: */
63 FetchData(&index,&nels_data,&test,INDEX); if(test!=3) _error_("index should have 3 columns");
64 FetchData(&x_data,&nods_data,X); if(nods_data<3) _error_("there should be at least three points");
65 FetchData(&y_data,&test,Y); if(test!=nods_data) _error_("vectors x and y should have the same length");
66 FetchData(&data,&M_data,&N_data,DATA); if(M_data*N_data<1) _error_("data is empty");
67 FetchData(&x_interp,&N_interp,XINTERP); if(N_interp<1) _error_("no interpolation requested");
68 FetchData(&y_interp,&test,YINTERP); if(test!=N_interp) _error_("vectors x_interp and y_interp should have the same length");
69 FetchData(&options,NRHS,nrhs,ARGUMENTS);
70
71 /*Run core computations*/
72 InterpFromMeshToMesh2dx(&data_interp,index,x_data,y_data,nods_data,nels_data,data,M_data,N_data,x_interp,y_interp,N_interp,options);
73
74 /*Write data: */
75 WriteData(DATAINTERP,data_interp,N_interp,N_data);
76
77 /*end module: */
78 MODULEEND();
79}
Note: See TracBrowser for help on using the repository browser.