Changeset 1220 for XIOS/dev/branch_openmp/extern/remap/src/polyg.cpp
- Timestamp:
- 07/20/17 09:18:34 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/branch_openmp/extern/remap/src/polyg.cpp
r1205 r1220 7 7 8 8 #include "polyg.hpp" 9 #include <stdio.h> 9 10 10 11 namespace sphereRemap { … … 45 46 Coord barycentre(const Coord *x, int n) 46 47 { 48 47 49 if (n == 0) return ORIGIN; 48 50 Coord bc = ORIGIN; 49 51 for (int i = 0; i < n; i++) 52 { 50 53 bc = bc + x[i]; 54 } 51 55 /* both distances can be equal down to roundoff when norm(bc) < mashineepsilon 52 56 which can occur when weighted with tiny area */ 53 54 assert(squaredist(bc, proj(bc)) <= squaredist(bc, proj(bc * (-1.0))));55 //if (squaredist(bc, proj(bc)) > squaredist(bc, proj(bc * (-1.0)))) return proj(bc * (-1.0)); 57 58 59 //assert(squaredist(bc, proj(bc)) <= squaredist(bc, proj(bc * (-1.0)))); 56 60 57 61 return proj(bc); … … 173 177 t[1] = x[i]; 174 178 t[2] = x[ii]; 175 179 double sc=scalarprod(crossprod(t[1] - t[0], t[2] - t[0]), t[0]) ; 176 180 assert(sc >= -1e-10); // Error: tri a l'env (wrong orientation) 177 181 double area_gc = triarea(t[0], t[1], t[2]); 182 if(area_gc<=0) printf("area_gc = %e\n", area_gc); 178 183 double area_sc_gc_moon = 0; 179 184 if (d[i]) /* handle small circle case */ … … 183 188 char sgl = (mext > 0) ? -1 : 1; 184 189 area_sc_gc_moon = sgl * alun(arcdist(t[1], t[2]), fabs(scalarprod(t[1], pole))); 190 //if(area_sc_gc_moon<=0) printf("area_sc_gc_moon = %e\n", area_sc_gc_moon); 185 191 gg_exact = gg_exact + sc_gc_moon_normalintegral(t[1], t[2], pole); 186 192 } 187 193 area += area_gc + area_sc_gc_moon; /* for "spherical circle segment" sum triangular part (at) and "small moon" and => account for small circle */ 188 194 g[i] = barycentre(t, 3) * (area_gc + area_sc_gc_moon); 195 //printf("g[%d] = (%e,%e,%e) * (%e+%e) = (%e,%e,%e) norm = %e\n", i, barycentre(t, 3).x, barycentre(t, 3).y, barycentre(t, 3).z, area_gc, area_sc_gc_moon, g[i].x, g[i].y, g[i].z, norm(g[i])); 189 196 } 190 197 gg = barycentre(g, N);
Note: See TracChangeset
for help on using the changeset viewer.