Ignore:
Timestamp:
11/15/17 12:14:34 (6 years ago)
Author:
yushan
Message:

dev_omp

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/branch_openmp/extern/remap/src/polyg.cpp

    r1289 r1328  
    77 
    88#include "polyg.hpp" 
    9 #include <stdio.h> 
    109 
    1110namespace sphereRemap { 
     
    4645Coord barycentre(const Coord *x, int n) 
    4746{ 
    48  
    4947        if (n == 0) return ORIGIN; 
    5048        Coord bc = ORIGIN; 
    5149        for (int i = 0; i < n; i++) 
    52         { 
    5350                bc = bc + x[i]; 
    54         }        
    5551        /* both distances can be equal down to roundoff when norm(bc) < mashineepsilon  
    5652           which can occur when weighted with tiny area */ 
    57    
    58          
    59   //assert(squaredist(bc, proj(bc)) <= squaredist(bc, proj(bc * (-1.0))));       
     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)); 
    6056 
    6157        return proj(bc); 
     
    165161{ 
    166162        if (N < 3) 
    167                 return 0; /* polygons with less than three vertices have zero area */ 
     163          return 0; /* polygons with less than three vertices have zero area */ 
    168164        Coord t[3]; 
    169165        t[0] = barycentre(x, N); 
     
    177173                t[1] = x[i]; 
    178174                t[2] = x[ii]; 
    179     double sc=scalarprod(crossprod(t[1] - t[0], t[2] - t[0]), t[0]) ; 
     175                double sc=scalarprod(crossprod(t[1] - t[0], t[2] - t[0]), t[0]) ; 
    180176                assert(sc >= -1e-10); // Error: tri a l'env (wrong orientation) 
    181177                double area_gc = triarea(t[0], t[1], t[2]); 
    182                 //if(area_gc<=0) printf("area_gc = %e\n", area_gc); 
    183178                double area_sc_gc_moon = 0; 
    184179                if (d[i]) /* handle small circle case */ 
     
    188183                        char sgl = (mext > 0) ? -1 : 1; 
    189184                        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); 
    191185                        gg_exact = gg_exact + sc_gc_moon_normalintegral(t[1], t[2], pole); 
    192186                } 
    193187                area += area_gc + area_sc_gc_moon; /* for "spherical circle segment" sum triangular part (at) and "small moon" and => account for small circle */ 
    194188                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])); 
    196189        } 
    197190        gg = barycentre(g, N); 
Note: See TracChangeset for help on using the changeset viewer.