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

Last change on this file since 23189 was 23189, checked in by Mathieu Morlighem, 7 years ago

merged trunk-jpl and trunk for revision 23187

File size: 3.6 KB
Line 
1/*\file InterpFromMeshToMesh2d.c
2 *\brief: bamg module.
3 */
4#include "./InterpFromMeshToMesh2d.h"
5
6void InterpFromMeshToMesh2dUsage(void){/*{{{*/
7 _printf0_("INTERFROMMESHTOMESH2D - interpolation from a 2d triangular mesh onto a list of point\n");
8 _printf0_("\n");
9 _printf0_(" This function is a multi-threaded mex file that interpolates a field\n");
10 _printf0_(" defined on a Delaunay triangulation onto a list of point\n");
11 _printf0_("\n");
12 _printf0_(" Usage:\n");
13 _printf0_(" data_interp=InterpFromMeshToMesh2d(index,x,y,data,x_interp,y_interp);\n");
14 _printf0_(" or data_interp=InterpFromMeshToMesh2d(index,x,y,data,x_interp,y_interp,OPTIONS);\n");
15 _printf0_("\n");
16 _printf0_(" index : index of the mesh where data is defined (e.g. md.mesh.elements)\n");
17 _printf0_(" x,y : coordinates of the nodes where data is defined\n");
18 _printf0_(" data : matrix holding the data to be interpolated onto the mesh. (one column per field)\n");
19 _printf0_(" x_interp,y_interp : coordinates of the points onto which we interpolate.\n");
20 _printf0_(" data_interp : vector of mesh interpolated data.\n");
21 _printf0_(" Available options :\n");
22 _printf0_(" - 'default' : default value if point is outsite of triangulation (instead of linear interpolation)\n");
23 _printf0_("\n");
24 _printf0_(" Example:\n");
25 _printf0_(" load('temperature.mat');\n");
26 _printf0_(" md.initialization.temperature=InterpFromMeshToMesh2d(index,x,y,temperature,md.mesh.x,md.mesh.y);\n");
27 _printf0_(" md.initialization.temperature=InterpFromMeshToMesh2d(index,x,y,temperature,md.mesh.x,md.mesh.y,'default',253);\n");
28 _printf0_("\n");
29}/*}}}*/
30WRAPPER(InterpFromMeshToMesh2d_python){
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 xDelete<int>(index);
79 xDelete<double>(x_data);
80 xDelete<double>(y_data);
81 xDelete<double>(data);
82 xDelete<double>(x_interp);
83 xDelete<double>(y_interp);
84 xDelete<double>(data_interp);
85 delete options;
86 MODULEEND();
87}
Note: See TracBrowser for help on using the repository browser.