Changeset 2304
- Timestamp:
- 09/24/09 09:16:11 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/c/InterpFromMeshToGridx/InterpFromMeshToGridx.cpp
r2301 r2304 18 18 /*Intermediary*/ 19 19 int i,j,n; 20 int i1,i2,j1,j2; 20 21 int interpolation_type; 21 22 bool debug; 23 int xflip,yflip; 22 24 double area; 23 25 double area_1,area_2,area_3; … … 57 59 debug=(bool)((double)ncols*nlines*nels >= pow((double)10,(double)10)); 58 60 59 /*Initialize coordintes and griddata*/ 61 /*figure out if x or y are flipped*/ 62 if (xposting<0) xflip=1; 63 else xflip=0; 64 if (yposting<0) yflip=1; 65 else yflip=0; 66 67 /*Compute coordinates lists*/ 60 68 // EAST = ACTUAL WEST !!!!!!!!!!!!!!! 61 69 cornersouth=cornernorth-nlines*yposting; … … 65 73 for(i=0;i<=nlines;i++) y_m[i] = cornersouth + yposting*i; 66 74 for(i=0;i<=ncols; i++) x_m[i] = cornereast + xposting*i; 75 76 /*Initialize coordintes and griddata*/ 67 77 for(i=0;i<nlines;i++){ 68 78 for(j=0;j<ncols; j++){ … … 72 82 73 83 /*Get extreme coordinates of the grid*/ 74 if (xposting>0){ 75 x_grid_min=cornereast; 76 x_grid_max=cornerwest; 84 if (xflip){ 85 x_grid_min=x_grid[ncols-1]; x_grid_max=x_grid[0]; 77 86 } 78 87 else{ 79 x_grid_min=cornerwest; 80 x_grid_max=cornereast; 88 x_grid_min=x_grid[0]; x_grid_max=x_grid[ncols-1]; 81 89 } 82 if (yposting>0){ 83 y_grid_min=cornersouth; 84 y_grid_max=cornernorth; 90 if (yflip){ 91 y_grid_min=y_grid[nlines-1]; y_grid_max=y_grid[0]; 85 92 } 86 93 else{ 87 y_grid_min=cornernorth; 88 y_grid_max=cornersouth; 94 y_grid_min=y_grid[0]; y_grid_max=y_grid[nlines-1]; 89 95 } 90 96 … … 109 115 if ( (x_tria_min>x_grid_max) || (x_tria_max<x_grid_min) || (y_tria_min>y_grid_max) || (y_tria_max<y_grid_min) ) continue; 110 116 117 /*Get indices i and j that form a square around the currant triangle*/ 118 if (yflip){ 119 i1=floor((y_tria_max-y_grid_max)/yposting)-1; 120 i2= ceil((y_tria_min-y_grid_max)/yposting); 121 } 122 else{ 123 i1=floor((y_tria_min-y_grid_min)/yposting)-1; 124 i2= ceil((y_tria_max-y_grid_min)/yposting); 125 } 126 if (xflip){ 127 j1=floor((x_tria_max-x_grid_max)/xposting)-1; 128 j2= ceil((x_tria_min-x_grid_max)/xposting); 129 } 130 else{ 131 j1=floor((x_tria_min-x_grid_min)/xposting)-1; 132 j2= ceil((x_tria_max-x_grid_min)/xposting); 133 } 134 111 135 /*get area of the current element (Jacobian = 2 * area)*/ 112 136 //area =x2 * y3 - y2*x3 + x1 * y2 - y1 * x2 + x3 * y1 - y3 * x1; … … 115 139 + x_mesh[(int)index_mesh[3*n+2]-1]*y_mesh[(int)index_mesh[3*n+0]-1]-y_mesh[(int)index_mesh[3*n+2]-1]*x_mesh[(int)index_mesh[3*n+0]-1]; 116 140 117 118 141 /*Go through x_grid and y_grid and interpolate if necessary*/ 119 for (i= 0;i<nlines;i++){142 for (i=i1;i<=i2;i++){ 120 143 121 144 //exit if y not between y_tria_min and y_tria_max 122 145 if((y_grid[i]>y_tria_max) || (y_grid[i]<y_tria_min)) continue; 123 146 124 for(j= 0;j<ncols; j++){147 for(j=j1;j<=j2; j++){ 125 148 126 149 //exit if x not between x_tria_min and x_tria_max
Note:
See TracChangeset
for help on using the changeset viewer.