Ignore:
Timestamp:
05/31/23 12:20:29 (13 months ago)
Author:
ymipsl
Message:

Supress limitation of number of vertex max in remaper.
YM

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS2/trunk/extern/remap/src/elt.hpp

    r1614 r2506  
    33#include <list> 
    44#include "triple.hpp" 
     5#include <vector> 
    56 
    6 #define NMAX 10 /**< maximum number of vertices for polygons */ 
     7#define NMAX 0 /**< maximum number of vertices for polygons */ 
    78 
    89#define NOT_FOUND -1 
     
    5859        { 
    5960                int k = 0; 
     61                vertex.resize(max_num_vert) ; 
    6062                vertex[k++] = xyz(bounds_lon[0], bounds_lat[0]); 
    6163                for (int i = 1; i < max_num_vert; i++) 
     
    7274                } 
    7375                n = k; 
    74                 x = barycentre(vertex, n); 
     76    vertex.resize(n) ; 
     77    vertex.shrink_to_fit(); 
     78          allocate() ; 
     79 
     80                x = barycentre(vertex.data(), n); 
    7581        } 
    76  
     82  void allocate(void) 
     83  { 
     84    vertex.resize(n) ; 
     85    neighbour.resize(n) ; 
     86    d.resize(n) ; 
     87    edge.resize(n) ; 
     88    gradNeigh.resize(n) ; 
     89    neighId.resize(n) ; 
     90  } 
    7791        Elt& operator=(const Elt& rhs) 
    7892        { 
     
    87101                is   = rhs.is; 
    88102 
    89                 for(int i = 0; i < NMAX; i++) 
    90                 { 
    91                         neighbour[i] = rhs.neighbour[i]; 
    92                         d[i]         = rhs.d[i]; 
    93                         edge[i]      = rhs.edge[i]; 
    94                         vertex[i]    = rhs.vertex[i]; 
    95                         gradNeigh[i] = rhs.gradNeigh[i]; 
    96                 } 
     103                neighbour = rhs.neighbour; 
     104                d         = rhs.d; 
     105                edge      = rhs.edge; 
     106                vertex    = rhs.vertex; 
     107                gradNeigh = rhs.gradNeigh; 
    97108                return *this; 
    98109        } 
     
    109120  void insert_vertex(int i, const Coord& v) 
    110121  { 
     122    vertex.resize(n+1) ; 
     123    edge.resize(n+1) ; 
     124    d.resize(n+1) ; 
     125    neighbour.resize(n+1) ; 
     126    gradNeigh.resize(n+1) ; 
     127    neighId.resize(n+1) ; 
     128 
    111129    for(int j=n; j > i ; j--) 
    112130    { 
     
    120138  } 
    121139   
    122         int neighbour[NMAX]; 
    123         double d[NMAX]; /**< distance of centre of small circle to origin, zero if great circle */ 
     140        std::vector<int> neighbour; 
     141        std::vector<double> d; /**< distance of centre of small circle to origin, zero if great circle */ 
    124142        double val;     /**< value (sample if src element, interpolated if dest element) */ 
    125         Coord vertex[NMAX]; 
    126         Coord edge[NMAX]; /**< edge normals: if great circle tangential to sphere, if small circle parallel to pole */ 
     143        std::vector<Coord> vertex; 
     144        std::vector<Coord> edge; /**< edge normals: if great circle tangential to sphere, if small circle parallel to pole */ 
    127145        Coord grad;    /**< gradient of the reconstructed linear function over this element */ 
    128         Coord gradNeigh[NMAX]; /**< for weight computation: gradients for val=1 at individual neighbours */ 
    129         struct GloId neighId[NMAX]; /**< weight computation needs to know global IDs for all sources with "link" */ 
     146        std::vector<Coord> gradNeigh; /**< for weight computation: gradients for val=1 at individual neighbours */ 
     147        std::vector<struct GloId> neighId; /**< weight computation needs to know global IDs for all sources with "link" */ 
    130148        std::list<Polyg*> is; /**< intersections */ 
    131149}; 
Note: See TracChangeset for help on using the changeset viewer.