Ignore:
Timestamp:
09/19/13 17:05:07 (11 years ago)
Author:
ymipsl
Message:

Add unstructured grid management.

YM

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/node/domain.cpp

    r435 r449  
    2222      : CObjectTemplate<CDomain>(), CDomainAttributes() 
    2323      , isChecked(false),  relFiles() 
    24       , ibegin_sub(), iend_sub(), jbegin_sub(), jend_sub() 
    25       , ibegin_zoom_sub(), jbegin_zoom_sub(), ni_zoom_sub(), nj_zoom_sub() 
    26       , lonvalue_sub(), latvalue_sub() 
    2724   { /* Ne rien faire de plus */ } 
    2825 
     
    3027      : CObjectTemplate<CDomain>(id), CDomainAttributes() 
    3128      , isChecked(false), relFiles() 
    32       , ibegin_sub(), iend_sub(), jbegin_sub(), jend_sub() 
    33       , ibegin_zoom_sub(), jbegin_zoom_sub(),ni_zoom_sub(), nj_zoom_sub() 
    34       , lonvalue_sub(), latvalue_sub() 
    35    { /* Ne rien faire de plus */ } 
     29         { /* Ne rien faire de plus */ } 
    3630 
    3731   CDomain::~CDomain(void) 
    3832   {  
    39      vector<CArray<double,1>* >::iterator it; 
    40      for(it=lonvalue_sub.begin();it<lonvalue_sub.end();it++) delete *it; 
    41      for(it=latvalue_sub.begin();it<latvalue_sub.end();it++) delete *it; 
    4233   } 
    4334 
     
    4637   const std::set<StdString> & CDomain::getRelFiles(void) const 
    4738   { 
    48       return (this->relFiles); 
     39      return (this->relFiles);  
    4940   } 
    5041 
     
    7970   } 
    8071 
    81    //---------------------------------------------------------------- 
    82 /* 
    83    void CDomain::fromBinary(StdIStream & is) 
    84    { 
    85       SuperClass::fromBinary(is); 
    86        
    87       if ( !this->ibegin.isEmpty()   && 
    88            !this->jbegin.isEmpty()   && 
    89            !this->iend.isEmpty()     && 
    90            !this->jend.isEmpty()     && 
    91            !this->latvalue.isEmpty() && 
    92            !this->lonvalue.isEmpty()) 
    93       { 
    94        
    95          this->ibegin_sub.push_back(this->ibegin.getValue()); 
    96          this->jbegin_sub.push_back(this->jbegin.getValue()); 
    97          this->iend_sub.push_back(this->iend.getValue()); 
    98          this->jend_sub.push_back(this->jend.getValue());  
    99           
    100          this->ibegin_zoom_sub.push_back(this->zoom_ibegin_loc.getValue()); 
    101          this->jbegin_zoom_sub.push_back(this->zoom_jbegin_loc.getValue()); 
    102          this->ni_zoom_sub.push_back(this->zoom_ni_loc.getValue()); 
    103          this->nj_zoom_sub.push_back(this->zoom_nj_loc.getValue()); 
    104        
    105          this->latvalue_sub.push_back(this->latvalue.getValue()); 
    106          this->lonvalue_sub.push_back(this->lonvalue.getValue()); 
    107       } 
    108        
    109 #define CLEAR_ATT(name_)\ 
    110       SuperClassAttribute::operator[](#name_)->reset() 
    111  
    112          CLEAR_ATT(mask); 
    113          CLEAR_ATT(data_n_index); 
    114          CLEAR_ATT(data_i_index); 
    115          CLEAR_ATT(data_j_index); 
    116           
    117          CLEAR_ATT(data_ni); 
    118          CLEAR_ATT(data_nj); 
    119          CLEAR_ATT(data_ibegin); 
    120          CLEAR_ATT(data_jbegin); 
    121           
    122          CLEAR_ATT(ni); 
    123          CLEAR_ATT(nj); 
    124           
    125 #undef CLEAR_ATT 
    126  
    127       if ( !this->ibegin.isEmpty()   && 
    128            !this->jbegin.isEmpty()   && 
    129            !this->iend.isEmpty()     && 
    130            !this->jend.isEmpty()     && 
    131            !this->latvalue.isEmpty() && 
    132            !this->lonvalue.isEmpty()) 
    133       { 
    134  
    135          this->ibegin.setValue(*std::min_element(this->ibegin_sub.begin(),this->ibegin_sub.end())); 
    136          this->jbegin.setValue(*std::min_element(this->jbegin_sub.begin(),this->jbegin_sub.end())); 
    137          this->iend.setValue(*std::max_element(this->iend_sub.begin(),this->iend_sub.end())); 
    138          this->jend.setValue(*std::max_element(this->jend_sub.begin(),this->jend_sub.end())); 
    139       } 
    140    } 
    141 */ 
    14272   //---------------------------------------------------------------- 
    14373 
     
    15080   void CDomain::checkGlobalDomain(void) 
    15181   { 
    152       if ((ni_glo.isEmpty() || ni_glo.getValue() <= 0 ) || 
     82      if (!type.isEmpty() && type==type_attr::unstructured) 
     83      { 
     84         if (ni_glo.isEmpty() || ni_glo <= 0 ) 
     85         { 
     86            ERROR("CDomain::checkAttributes(void)", 
     87               << "[ Id = " << this->getId() << " ] " 
     88               << "The global domain is badly defined," 
     89               << " check the \'ni_glo\'  value !")  
     90         } 
     91         nj_glo=ni_glo ; 
     92         ni_glo=1 ; 
     93         if (!ni.isEmpty()) nj=ni ; 
     94         if (!ibegin.isEmpty()) jbegin=ibegin ; 
     95         if (!iend.isEmpty()) jend=iend ; 
     96         ni=1 ; 
     97         ibegin=1 ; 
     98         iend=1 ; 
     99      } 
     100      else if ((ni_glo.isEmpty() || ni_glo.getValue() <= 0 ) || 
    153101          (nj_glo.isEmpty() || nj_glo.getValue() <= 0 )) 
    154102      { 
     
    173121         ni.setValue(iend.getValue() - ibegin.getValue() + 1) ; 
    174122 
    175       else if (!ibegin.isEmpty() && !iend.isEmpty() && 
    176                !ni.isEmpty() && (iend.getValue() != ibegin.getValue() + ni.getValue() - 1)) 
    177       { 
    178          ERROR("CDomain::checkAttributes(void)", 
    179                << "The domain si wrong defined," 
    180                << " iend is different of (ibegin + ni - 1) !") ; 
     123      else if (!ibegin.isEmpty() && !iend.isEmpty() && !ni.isEmpty() ) 
     124      { 
     125         if (iend.getValue() != ibegin.getValue() + ni.getValue() - 1) 
     126           ERROR("CDomain::checkAttributes(void)", 
     127                 << "The domain si wrong defined," 
     128                 << " iend is different of (ibegin + ni - 1) !") ; 
    181129      } 
    182130      else 
     
    190138      if (ni.getValue() < 0 || ibegin.getValue() > iend.getValue() || 
    191139          ibegin.getValue() < 1 || iend.getValue() > ni_glo.getValue()) 
     140          { 
     141                  cout<<ni_glo<<"  "<<ni<<"  "<<ibegin<<"  "<<iend<<endl; 
     142 
    192143         ERROR("CDomain::checkAttributes(void)", 
    193144               << "[ Id = " << this->getId() << " ] " 
    194145               << "Local domain is wrong defined," 
    195146               << " Check the value : ni, ni_glo, ibegin, iend") ; 
    196  
     147        } 
    197148   } 
    198149 
     
    210161         nj.setValue(jend.getValue() - jbegin.getValue() + 1) ; 
    211162 
    212       else if (!jbegin.isEmpty() && !jend.isEmpty() && !nj.isEmpty() && 
    213                (jend.getValue() != jbegin.getValue() + nj.getValue() - 1)) 
    214       { 
    215          ERROR("CDomain::checkAttributes(void)", 
    216                << "The domain is wrong defined," 
    217                << " iend is different of (jbegin + nj - 1) !") ; 
     163      else if (!jbegin.isEmpty() && !jend.isEmpty() && !nj.isEmpty() ) 
     164      { 
     165          if  (jend.getValue() != jbegin.getValue() + nj.getValue() - 1) 
     166             ERROR("CDomain::checkAttributes(void)", 
     167                 << "The domain is wrong defined," 
     168                 << " iend is different of (jbegin + nj - 1) !") ; 
    218169      } 
    219170      else 
     
    229180               << "Domain is wrong defined," 
    230181               << " Check the values : nj, nj_glo, jbegin, jend") ; 
     182                
     183     ibegin_client=ibegin ; iend_client=iend ; ni_client=ni ; 
     184     jbegin_client=jbegin ; jend_client=jend ; nj_client=nj ; 
    231185   } 
    232186 
     
    416370      CArray<double,1> lonvalue_temp(ni*nj) ; 
    417371      CArray<double,1> latvalue_temp(ni*nj) ; 
    418        
    419       if ( lonvalue.numElements() == ni*nj && latvalue.numElements() == ni*nj ) isCurvilinear=true ; 
    420       else if ( lonvalue.numElements() == ni && latvalue.numElements() == nj ) isCurvilinear=false ; 
    421       else ERROR("void CDomain::completeLonLatClient(void)",<<"the grid is nor curvilinear, nor cartesian, because the size of longitude and latitude array is not coherent with the domain size"<<endl 
    422                                                             <<"lonvalue size = " << lonvalue.numElements() << "different of ni or ni*nj"<<endl 
    423                                                             <<"latvalue size = " << latvalue.numElements() << "different of nj or ni*nj" ) ; 
    424       if (isCurvilinear) 
     372      CArray<double,2> bounds_lon_temp(nvertex,ni*nj) ; 
     373      CArray<double,2> bounds_lat_temp(nvertex,ni*nj) ; 
     374       
     375      if (type.isEmpty()) 
     376      { 
     377        if ( lonvalue.numElements() == ni*nj && latvalue.numElements() == ni*nj )  
     378        { 
     379          type.setValue(type_attr::curvilinear) ; 
     380          isCurvilinear=true ; 
     381        } 
     382        else if ( lonvalue.numElements() == ni && latvalue.numElements() == nj )  
     383        { 
     384          type.setValue(type_attr::regular) ; 
     385          isCurvilinear=false ; 
     386        } 
     387        else ERROR("void CDomain::completeLonLatClient(void)",<<"the grid is nor curvilinear, nor cartesian, because the size of longitude and latitude array is not coherent with the domain size"<<endl 
     388                                                              <<"lonvalue size = " << lonvalue.numElements() << "different of ni or ni*nj"<<endl 
     389                                                              <<"latvalue size = " << latvalue.numElements() << "different of nj or ni*nj" ) ; 
     390      } 
     391      if (type==type_attr::curvilinear || type==type_attr::unstructured) 
    425392      { 
    426393        lonvalue_temp=lonvalue ; 
    427394        latvalue_temp=latvalue ; 
     395        if (hasBounds) bounds_lon_temp=bounds_lon ; 
     396        if (hasBounds) bounds_lat_temp=bounds_lat ; 
    428397      } 
    429398      else 
     
    435404            lonvalue_temp(k)=lonvalue(i) ; 
    436405            latvalue_temp(k)=latvalue(j) ; 
     406            if (hasBounds) 
     407            { 
     408              for(int n=0;n<nvertex;n++)  
     409              { 
     410                bounds_lon_temp(n,k)=bounds_lon(n,i) ; 
     411                bounds_lat_temp(n,k)=bounds_lat(n,j) ; 
     412              } 
     413            } 
    437414          } 
    438415      } 
    439416          
    440          
    441       const int zoom_ibegin_client  = zoom_ibegin_loc.getValue(), 
    442                 zoom_jbegin_client  = zoom_jbegin_loc.getValue(), 
    443                 zoom_ni_client      = zoom_ni_loc.getValue(), 
    444                 zoom_nj_client      = zoom_nj_loc.getValue(); 
    445                  
    446417      StdSize dm = zoom_ni_client * zoom_nj_client; 
    447418 
     
    453424        for (int j = 0; j < zoom_nj_client; j++) 
    454425        { 
    455           lonvalue(i + j * zoom_ni_client) = lonvalue_temp( (i + zoom_ibegin_client -1) + (j + zoom_jbegin_client -1)*ni.getValue() );  
    456           latvalue(i + j * zoom_ni_client) = latvalue_temp( (i + zoom_ibegin_client -1)+(j + zoom_jbegin_client -1)*ni.getValue() ); 
     426//          lonvalue(i + j * zoom_ni_client) = lonvalue_temp( (i + zoom_ibegin_client -1) + (j + zoom_jbegin_client -1)*ni );  
     427//          latvalue(i + j * zoom_ni_client) = latvalue_temp( (i + zoom_ibegin_client -1)+(j + zoom_jbegin_client -1)*ni ); 
     428          lonvalue(i + j * zoom_ni_client) = lonvalue_temp( (i + zoom_ibegin_client-ibegin) + (j + zoom_jbegin_client -jbegin)*ni );  
     429          latvalue(i + j * zoom_ni_client) = latvalue_temp( (i + zoom_ibegin_client - ibegin)+(j + zoom_jbegin_client - jbegin)*ni ); 
     430          if (hasBounds) 
     431          { 
     432            for(int n=0;n<nvertex;n++)  
     433            { 
     434//              bounds_lon(n,i + j * zoom_ni_client) = bounds_lon_temp( n, (i + zoom_ibegin_client -1) + (j + zoom_jbegin_client -1)*ni );  
     435//              bounds_lat(n,i + j * zoom_ni_client) = bounds_lat_temp( n, (i + zoom_ibegin_client -1)+(j + zoom_jbegin_client -1)*ni ); 
     436              bounds_lon(n,i + j * zoom_ni_client) = bounds_lon_temp( n, (i + zoom_ibegin_client - ibegin) + (j + zoom_jbegin_client -jbegin)*ni );  
     437              bounds_lat(n,i + j * zoom_ni_client) = bounds_lat_temp( n, (i + zoom_ibegin_client - ibegin)+(j + zoom_jbegin_client -jbegin)*ni ); 
     438            } 
     439          } 
    457440        } 
    458441      } 
    459    } 
     442    } 
    460443  
    461    //---------------------------------------------------------------- 
    462        
    463    void CDomain::completeLonLatServer(void) 
    464    { 
    465       CArray<double,1> lonvalue_temp ; 
    466       CArray<double,1> latvalue_temp ; 
    467        
    468       const int ibegin_serv     = ibegin.getValue(), 
    469                 jbegin_serv     = jbegin.getValue(), 
    470                 zoom_ni_serv    = zoom_ni_loc.getValue(), 
    471                 zoom_nj_serv    = zoom_nj_loc.getValue(), 
    472                 ibegin_zoom_srv = zoom_ibegin_loc.getValue(), 
    473                 jbegin_zoom_srv = zoom_jbegin_loc.getValue(); 
    474                        
    475                         
    476       if (this->data_dim.getValue() == 2) 
    477       { 
    478          StdSize dm = zoom_ni_serv * zoom_nj_serv;       
    479           
    480          lonvalue_temp.resize(dm); 
    481          latvalue_temp.resize(dm); 
    482           
    483          for (StdSize k = 0; k < lonvalue_sub.size(); k++) 
    484          { 
    485             CArray<double,1> lonvalue_loc(*(lonvalue_sub[k])) ; 
    486             CArray<double,1> latvalue_loc (*(latvalue_sub[k])); 
    487              
    488             const int zoom_ibegin_cl = ibegin_zoom_sub[k], zoom_ni_cl = ni_zoom_sub[k], 
    489                       zoom_jbegin_cl = jbegin_zoom_sub[k], zoom_nj_cl = nj_zoom_sub[k], 
    490                       ibegin_cl = ibegin_sub[k] , 
    491                       jbegin_cl = jbegin_sub[k] , 
    492                       ni_cl = iend_sub[k] - ibegin_sub[k] + 1; 
    493                        
    494             for (int i = 0; i < zoom_ni_cl; i++) 
    495             { 
    496                for (int j = 0; j < zoom_nj_cl; j++) 
    497                { 
    498                   int ii = i + (ibegin_cl-1) - (ibegin_serv - 1) + (zoom_ibegin_cl - 1) - (ibegin_zoom_srv - 1); 
    499                   int jj = j + (jbegin_cl-1) - (jbegin_serv - 1) + (zoom_jbegin_cl - 1) - (jbegin_zoom_srv - 1); 
    500                   lonvalue_temp(ii + jj * zoom_ni_serv) = lonvalue_loc(i + j * zoom_ni_cl); 
    501                   latvalue_temp(ii + jj * zoom_ni_serv) = latvalue_loc(i + j * zoom_ni_cl); 
    502                } 
    503             } 
    504          } 
    505           
    506          lonvalue.reference(lonvalue_temp.copy()) ; 
    507          latvalue.reference(latvalue_temp.copy()) ; 
    508       } 
    509       else 
    510       { 
    511          lonvalue_temp.resize(zoom_ni_serv); 
    512          latvalue_temp.resize(zoom_nj_serv); 
    513           
    514          for (StdSize k = 0; k < lonvalue_sub.size(); k++) 
    515          { 
    516             CArray<double,1> lonvalue_loc(*(lonvalue_sub[k])); 
    517             CArray<double,1> latvalue_loc(*(latvalue_sub[k])); 
    518              
    519             const int zoom_ibegin_cl = ibegin_zoom_sub[k], zoom_ni_cl = ni_zoom_sub[k], 
    520                       zoom_jbegin_cl = jbegin_zoom_sub[k], zoom_nj_cl = nj_zoom_sub[k]; 
    521                        
    522             for (int i = 0; i < zoom_ni_cl; i++) 
    523               lonvalue_temp(i /*- (ibegin_serv - 1)*/ + (zoom_ibegin_cl - 1) - (ibegin_zoom_srv - 1)) = lonvalue_loc(i); 
    524                 
    525             for (int j = 0; j < zoom_nj_cl; j++) 
    526               latvalue_temp(j /*- (jbegin_serv - 1)*/ + (zoom_jbegin_cl - 1) - (jbegin_zoom_srv - 1)) = latvalue_loc(j); 
    527          }        
    528          lonvalue.reference(lonvalue_temp.copy()) ; 
    529          latvalue.reference(latvalue_temp.copy()) ; 
    530       } 
    531    } 
    532444 
    533445   //---------------------------------------------------------------- 
     
    547459         else 
    548460         { 
    549             int zoom_iend = zoom_ibegin.getValue() + zoom_ni.getValue() - 1; 
    550             int zoom_jend = zoom_jbegin.getValue() + zoom_nj.getValue() - 1; 
     461            int zoom_iend = zoom_ibegin + zoom_ni - 1; 
     462            int zoom_jend = zoom_jbegin + zoom_nj - 1; 
    551463                 
    552             if (zoom_ibegin.getValue() < 1  || zoom_jbegin.getValue() < 1 || 
    553                 zoom_iend > ni_glo.getValue() || zoom_jend > nj_glo.getValue()) 
     464            if (zoom_ibegin < 1  || zoom_jbegin < 1 || zoom_iend > ni_glo || zoom_jend > nj_glo) 
    554465               ERROR("CDomain::checkZoom(void)", 
    555466                     << "Zoom is wrong defined," 
     
    559470      else 
    560471      { 
    561          this->zoom_ni.setValue(this->ni_glo.getValue());  
    562          this->zoom_nj.setValue(this->nj_glo.getValue()); 
    563          this->zoom_ibegin.setValue(1); 
    564          this->zoom_jbegin.setValue(1); 
    565       } 
    566       // Résolution des données locales de zoom. 
    567       { 
    568          int zoom_iend = zoom_ibegin.getValue() + zoom_ni.getValue() - 1; 
    569          int zoom_jend = zoom_jbegin.getValue() + zoom_nj.getValue() - 1; 
     472         zoom_ni = ni_glo;  
     473         zoom_nj = nj_glo; 
     474         zoom_ibegin = 1; 
     475         zoom_jbegin = 1; 
     476      } 
     477       
     478      // compute client zoom indices 
     479 
     480      int zoom_iend=zoom_ibegin+zoom_ni-1 ; 
     481      zoom_ibegin_client = ibegin_client > zoom_ibegin ? ibegin_client : zoom_ibegin ; 
     482      zoom_iend_client = iend_client < zoom_iend ? iend_client : zoom_iend ; 
     483      zoom_ni_client=zoom_iend_client-zoom_ibegin_client+1 ; 
     484      if (zoom_ni_client<0) zoom_ni_client=0 ; 
     485 
     486     
     487      int zoom_jend=zoom_jbegin+zoom_nj-1 ; 
     488      zoom_jbegin_client = jbegin_client > zoom_jbegin ? jbegin_client : zoom_jbegin ; 
     489      zoom_jend_client = jend_client < zoom_jend ? jend_client : zoom_jend ; 
     490      zoom_nj_client=zoom_jend_client-zoom_jbegin_client+1 ; 
     491      if (zoom_nj_client<0) zoom_nj_client=0 ; 
     492       
     493      cout << zoom_ibegin<<"  "<<zoom_ni <<"  "<< zoom_jbegin<<"  "<<zoom_nj<<endl ; 
     494      cout << zoom_ibegin_client<<"  "<<zoom_ni_client <<"  "<< zoom_jbegin_client<<"  "<<zoom_nj_client<<endl ; 
     495      cout << ibegin_client<<"  "<<iend_client <<"  "<< jbegin_client<<"  "<<jend_client<<endl ; 
     496/*     
     497      { 
     498         int zoom_iend = zoom_ibegin + zoom_ni - 1; 
     499         int zoom_jend = zoom_jbegin + zoom_nj - 1; 
    570500          
    571          if ((zoom_ibegin.getValue() > iend.getValue()) ||  
    572              (zoom_iend < ibegin.getValue())) 
    573          { 
    574             zoom_ni_loc.setValue(0); 
    575             zoom_ibegin_loc.setValue(zoom_ibegin.getValue()); 
     501         if ( zoom_ibegin > iend || zoom_iend < ibegin ) 
     502         { 
     503            zoom_ni_loc = 0 ; 
     504            zoom_ibegin_loc = zoom_ibegin ; 
    576505         } 
    577506         else 
    578507         { 
    579             int zoom_ibegin_loc_ = (zoom_ibegin.getValue() > ibegin.getValue())  
    580                                  ? zoom_ibegin.getValue() 
    581                                  : ibegin.getValue(); 
    582             int zoom_iend_loc_  = (zoom_iend < iend.getValue())  
    583                                  ? zoom_iend 
    584                                  : iend.getValue(); 
     508            int zoom_ibegin_loc_ = (zoom_ibegin > ibegin) ? zoom_ibegin : ibegin ; 
     509            int zoom_iend_loc_  = (zoom_iend < iend) ? zoom_iend : iend ; 
    585510            int zoom_ni_loc_ = zoom_iend_loc_ - zoom_ibegin_loc_ + 1; 
    586511             
    587             zoom_ni_loc.setValue(zoom_ni_loc_); 
    588             zoom_ibegin_loc.setValue(zoom_ibegin_loc_-ibegin.getValue()+1); 
     512            zoom_ni_loc = zoom_ni_loc_; 
     513            zoom_ibegin_loc = zoom_ibegin_loc_-ibegin.getValue()+1; 
    589514         } 
    590515          
    591          if ((zoom_jbegin.getValue() > jend.getValue()) ||  
    592              (zoom_jend < jbegin.getValue())) 
    593          { 
    594             zoom_nj_loc.setValue(0); 
    595             zoom_jbegin_loc.setValue(zoom_jbegin.getValue()); 
     516         if ( zoom_jbegin > jend || zoom_jend < jbegin ) 
     517         { 
     518            zoom_nj_loc = 0 ; 
     519            zoom_jbegin_loc = zoom_jbegin ; 
    596520         } 
    597521         else 
    598522         { 
    599             int zoom_jbegin_loc_ = (zoom_jbegin.getValue() > jbegin.getValue())  
    600                                  ? zoom_jbegin.getValue() 
    601                                  : jbegin.getValue(); 
    602             int zoom_jend_loc_  = (zoom_jend < jend.getValue())  
    603                                  ? zoom_jend 
    604                                  : jend.getValue(); 
     523            int zoom_jbegin_loc_ = ( zoom_jbegin > jbegin ) ? zoom_jbegin : jbegin ; 
     524            int zoom_jend_loc_  = (zoom_jend < jend) ? zoom_jend : jend ; 
    605525            int zoom_nj_loc_ = zoom_jend_loc_ - zoom_jbegin_loc_ + 1; 
    606526             
    607             zoom_nj_loc.setValue(zoom_nj_loc_); 
    608             zoom_jbegin_loc.setValue(zoom_jbegin_loc_-jbegin.getValue()+1); 
    609          } 
    610       } 
    611    } 
    612  
     527            zoom_nj_loc = zoom_nj_loc_; 
     528            zoom_jbegin_loc = zoom_jbegin_loc_-jbegin.getValue()+1; 
     529         } 
     530      } 
     531*/ 
     532   } 
     533    
     534   void CDomain::checkBounds(void) 
     535   { 
     536     if (!nvertex.isEmpty() && !bounds_lon.isEmpty() && !bounds_lat.isEmpty()) 
     537     { 
     538       hasBounds=true ; 
     539        
     540     } 
     541     else  
     542     { 
     543       hasBounds=false; 
     544       nvertex=0 ; 
     545     } 
     546   } 
     547             
    613548   //---------------------------------------------------------------- 
    614549 
     
    623558       
    624559      this->checkZoom(); 
     560      this->checkBounds(); 
    625561       
    626562      if (context->hasClient) 
     
    629565         this->checkDomainData(); 
    630566         this->checkCompression(); 
    631           
    632          this->ibegin_sub.push_back(this->ibegin.getValue()); 
    633          this->jbegin_sub.push_back(this->jbegin.getValue()); 
    634          this->iend_sub.push_back(this->iend.getValue()); 
    635          this->jend_sub.push_back(this->jend.getValue());  
    636  
    637          this->ibegin_zoom_sub.push_back(this->zoom_ibegin_loc.getValue()); 
    638          this->jbegin_zoom_sub.push_back(this->zoom_jbegin_loc.getValue()); 
    639          this->ni_zoom_sub.push_back(this->zoom_ni_loc.getValue()); 
    640          this->nj_zoom_sub.push_back(this->zoom_nj_loc.getValue()); 
    641        
    642          this->latvalue_sub.push_back(new CArray<double,1>(latvalue.copy())); 
    643          this->lonvalue_sub.push_back(new CArray<double,1>(lonvalue.copy()));   
    644  
    645  
    646 //         if (!this->isEmpty()) 
    647 //         { 
    648             this->completeLonLatClient(); 
    649 //         } 
    650          this->completeMask(); 
    651  
     567         this->completeLonLatClient(); 
    652568      } 
    653569      else 
     
    722638    CContextClient* client=context->client ; 
    723639    int nbServer=client->serverSize ; 
    724      
     640 
     641/*     
    725642    // compute client zoom indices 
    726643    int zoom_iend=zoom_ibegin.getValue()+zoom_ni.getValue()-1 ; 
     
    735652    zoom_nj_client=zoom_jend_client-zoom_jbegin_client+1 ; 
    736653    if (zoom_nj_client<0) zoom_nj_client=0 ; 
    737   
     654*/  
    738655    // find how much client are connected to a server 
     656    int zoom_iend=zoom_ibegin+zoom_ni-1 ; 
     657    int zoom_jend=zoom_jbegin+zoom_nj-1 ; 
     658     
    739659    jend_srv=0 ; 
    740660    for(int ns=0;ns<nbServer;ns++) 
     
    747667      ib = ibegin_client>ibegin_srv ? ibegin_client : ibegin_srv ; 
    748668      ie=  iend_client< iend_srv? iend_client : iend_srv ; 
    749       in=ie-ib+1 ; 
     669      in=ie-ib+1 ;  
    750670      if (in<0) in=0 ; 
    751671       
     
    837757   
    838758    list<shared_ptr<CMessage> > list_msg ;     
    839     list<CArray<double,1>* > list_indi,list_indj,list_lon,list_lat ; 
     759    list< CArray<int,1>* > list_indi,list_indj ; 
     760    list< CArray<double,1>* >list_lon,list_lat ; 
     761    list< CArray<double,2>* >list_boundslon,list_boundslat ; 
    840762 
    841763    for(int ns=0;ns<connectedServer.size();ns++) 
     
    844766      jb=jb_srv[ns] ; je=je_srv[ns] ; jn=jn_srv[ns] ; 
    845767       
    846       CArray<double,1> indi(in*jn) ; 
    847       CArray<double,1> indj(in*jn) ; 
     768      CArray<int,1> indi(in*jn) ; 
     769      CArray<int,1> indj(in*jn) ; 
    848770      CArray<double,1> lon(in*jn) ; 
    849771      CArray<double,1> lat(in*jn) ; 
     772      CArray<double,2> boundslon(nvertex,in*jn) ; 
     773      CArray<double,2> boundslat(nvertex,in*jn) ; 
    850774 
    851775           
     
    859783          lon(ind_loc)=lonvalue(ind_client) ; 
    860784          lat(ind_loc)=latvalue(ind_client) ; 
     785          if (hasBounds) 
     786          { 
     787            for(int n=0;n<nvertex;n++) 
     788            { 
     789              boundslon(n,ind_loc)=bounds_lon(n,ind_client); 
     790              boundslat(n,ind_loc)=bounds_lat(n,ind_client); 
     791            } 
     792          } 
    861793          indi(ind_loc)=i ; 
    862794          indj(ind_loc)=j ; 
    863795        } 
    864796       
    865       list_indi.push_back(new CArray<double,1>(indi.copy())) ; 
    866       list_indj.push_back(new CArray<double,1>(indj.copy())) ; 
     797      list_indi.push_back(new CArray<int,1>(indi.copy())) ; 
     798      list_indj.push_back(new CArray<int,1>(indj.copy())) ; 
    867799      list_lon.push_back(new CArray<double,1>(lon.copy())) ; 
    868800      list_lat.push_back(new CArray<double,1>(lat.copy())) ; 
     801      if (hasBounds) list_boundslon.push_back(new CArray<double,2>(boundslon.copy())) ; 
     802      if (hasBounds) list_boundslat.push_back(new CArray<double,2>(boundslat.copy())) ; 
    869803 
    870804      list_msg.push_back(shared_ptr<CMessage>(new CMessage)) ; 
    871805 
    872       *list_msg.back()<<this->getId()<<isCurvilinear ; 
     806      *list_msg.back()<<this->getId()<<(int)type ; // enum ne fonctionne pour les message => ToFix 
     807      *list_msg.back()<<isCurvilinear ; 
    873808      *list_msg.back()<<*list_indi.back()<<*list_indj.back()<<*list_lon.back()<<*list_lat.back() ; 
     809      if (hasBounds) *list_msg.back()<<*list_boundslon.back()<<*list_boundslat.back(); 
    874810      event.push(connectedServer[ns],nbSenders[ns],*list_msg.back()) ; 
    875811    } 
     
    877813    client->sendEvent(event) ; 
    878814     
    879     list<CArray<double,1>* >::iterator it; 
    880     for(it=list_indi.begin();it!=list_indi.end();it++) delete *it; 
    881     for(it=list_indj.begin();it!=list_indj.end();it++) delete *it; 
    882     for(it=list_lon.begin();it!=list_lon.end();it++)   delete *it; 
    883     for(it=list_lat.begin();it!=list_lat.end();it++)   delete *it; 
     815     
     816    for(list<CArray<int,1>* >::iterator it=list_indi.begin();it!=list_indi.end();it++) delete *it; 
     817    for(list<CArray<int,1>* >::iterator it=list_indj.begin();it!=list_indj.end();it++) delete *it; 
     818    for(list<CArray<double,1>* >::iterator it=list_lon.begin();it!=list_lon.end();it++)   delete *it; 
     819    for(list<CArray<double,1>* >::iterator it=list_lat.begin();it!=list_lat.end();it++)   delete *it; 
     820    if (hasBounds) for(list<CArray<double,2>* >::iterator it=list_boundslon.begin();it!=list_boundslon.end();it++)   delete *it; 
     821    if (hasBounds) for(list<CArray<double,2>* >::iterator it=list_boundslat.begin();it!=list_boundslat.end();it++)   delete *it; 
    884822     
    885823  } 
     
    940878    lonvalue_srv.resize(zoom_ni_srv*zoom_nj_srv) ; 
    941879    latvalue_srv.resize(zoom_ni_srv*zoom_nj_srv) ; 
     880    if (hasBounds) bounds_lon_srv.resize(nvertex,zoom_ni_srv*zoom_nj_srv) ; 
     881    if (hasBounds) bounds_lat_srv.resize(nvertex,zoom_ni_srv*zoom_nj_srv) ; 
    942882  } 
    943883     
     
    956896  void CDomain::recvLonLat(CBufferIn& buffer) 
    957897  { 
    958     CArray<double,1> indi ; 
    959     CArray<double,1> indj ; 
     898    CArray<int,1> indi ; 
     899    CArray<int,1> indj ; 
    960900    CArray<double,1> lon ; 
    961901    CArray<double,1> lat ; 
    962       
    963     buffer>>isCurvilinear>>indi>>indj>>lon>>lat ; 
     902    CArray<double,2> boundslon ; 
     903    CArray<double,2> boundslat ; 
     904 
     905    int type_int ; 
     906    buffer>>type_int>>isCurvilinear>>indi>>indj>>lon>>lat ; 
     907    if (hasBounds) buffer>>boundslon>>boundslat ; 
     908    type.setValue((type_attr::t_enum)type_int) ; // probleme des type enum avec les buffers : ToFix 
    964909 
    965910    int i,j,ind_srv ; 
     
    971916      lonvalue_srv(ind_srv)=lon(ind) ; 
    972917      latvalue_srv(ind_srv)=lat(ind) ; 
     918      if (hasBounds)  
     919      { 
     920        for(int n=0;n<nvertex;n++)  
     921        { 
     922          bounds_lon_srv(n,ind_srv)=boundslon(n,ind) ; 
     923          bounds_lat_srv(n,ind_srv)=boundslat(n,ind) ; 
     924        } 
     925      } 
    973926    } 
    974927  } 
    975928   //---------------------------------------------------------------- 
    976929    
    977    void CDomain::completeMask(void) 
    978    { 
    979       this->local_mask.resize(zoom_ni_loc,zoom_nj_loc); 
    980    } 
    981  
    982    //---------------------------------------------------------------- 
    983  
    984    CArray<int,2> CDomain::getLocalMask(void) const 
    985    { 
    986       return (this->local_mask); 
    987    } 
    988     
    989    //---------------------------------------------------------------- 
    990     
    991    const std::vector<int> & CDomain::getIBeginSub(void) const 
    992    { 
    993       return (this->ibegin_sub); 
    994    } 
    995     
    996    //---------------------------------------------------------------- 
    997     
    998    const std::vector<int> & CDomain::getIBeginZoomSub(void) const 
    999    { 
    1000       return (this->ibegin_zoom_sub); 
    1001    } 
    1002  
    1003    const std::vector<int> & CDomain::getNiZoomSub(void) const 
    1004    { 
    1005       return (this->ni_zoom_sub); 
    1006    } 
    1007                 
    1008    //---------------------------------------------------------------- 
    1009                       
    1010    const std::vector<int> & CDomain::getIEndSub(void) const 
    1011    { 
    1012       return (this->iend_sub); 
    1013    } 
    1014     
    1015    //---------------------------------------------------------------- 
    1016     
    1017    const std::vector<int> & CDomain::getJBeginSub(void) const 
    1018    { 
    1019       return (this->jbegin_sub); 
    1020    } 
    1021     
    1022    //---------------------------------------------------------------- 
    1023        
    1024    const std::vector<int> & CDomain::getJBeginZoomSub(void) const 
    1025    { 
    1026       return (this->jbegin_zoom_sub); 
    1027    } 
    1028  
    1029    const std::vector<int> & CDomain::getNjZoomSub(void) const 
    1030    { 
    1031       return (this->nj_zoom_sub); 
    1032    } 
    1033                    
    1034     
    1035    //---------------------------------------------------------------- 
    1036     
    1037    const std::vector<int> & CDomain::getJEndSub(void) const 
    1038    { 
    1039       return (this->jend_sub); 
    1040    } 
    1041     
    1042    //---------------------------------------------------------------- 
    1043     
    1044    const std::vector<CArray<double, 1>* > & CDomain::getLonValueSub(void) const 
    1045    { 
    1046       return (this->lonvalue_sub); 
    1047    } 
    1048     
    1049    //---------------------------------------------------------------- 
    1050     
    1051    const std::vector<CArray<double,1>*> & CDomain::getLatValueSub(void) const 
    1052    { 
    1053       return (this->latvalue_sub); 
    1054    }    
     930    
    1055931    
    1056932   ///--------------------------------------------------------------- 
Note: See TracChangeset for help on using the changeset viewer.