Ignore:
Timestamp:
11/12/15 16:33:08 (8 years ago)
Author:
mhnguyen
Message:

Adding attribute reading of unstructured grid

+) Fix a minor bug relating to unstructured grid detection
+) Add attribute reading for unstructured domain

Test
+) On Curie
+) test_remap passes

File:
1 edited

Legend:

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

    r782 r783  
    228228   { 
    229229     if (this->isRedistributed_) return; 
     230 
     231     this->isRedistributed_ = true; 
     232     CContext* context = CContext::getCurrent(); 
     233     CContextClient* client = context->client; 
     234     int rankClient = client->clientRank; 
     235     int rankOnDomain = rankClient%nbLocalDomain; 
     236 
     237     if (ni_glo.isEmpty() || ni_glo <= 0 ) 
     238     { 
     239        ERROR("CDomain::redistribute(int nbLocalDomain)", 
     240           << "[ Id = " << this->getId() << " ] " 
     241           << "The global domain is badly defined," 
     242           << " check the \'ni_glo\'  value !") 
     243     } 
     244 
     245     if (nj_glo.isEmpty() || nj_glo <= 0 ) 
     246     { 
     247        ERROR("CDomain::redistribute(int nbLocalDomain)", 
     248           << "[ Id = " << this->getId() << " ] " 
     249           << "The global domain is badly defined," 
     250           << " check the \'nj_glo\'  value !") 
     251     } 
     252 
    230253     if ((type_attr::rectilinear == type)  || (type_attr::curvilinear == type)) 
    231254     { 
    232         this->isRedistributed_ = true; 
    233  
    234         CContext* context = CContext::getCurrent(); 
    235         CContextClient* client = context->client; 
    236         int rankClient = client->clientRank; 
    237         int rankOnDomain = rankClient%nbLocalDomain; 
    238  
    239         if (ni_glo.isEmpty() || ni_glo <= 0 ) 
    240         { 
    241            ERROR("CDomain::redistribute(int nbLocalDomain)", 
    242               << "[ Id = " << this->getId() << " ] " 
    243               << "The global domain is badly defined," 
    244               << " check the \'ni_glo\'  value !") 
    245         } 
    246  
    247         if (nj_glo.isEmpty() || nj_glo <= 0 ) 
    248         { 
    249            ERROR("CDomain::redistribute(int nbLocalDomain)", 
    250               << "[ Id = " << this->getId() << " ] " 
    251               << "The global domain is badly defined," 
    252               << " check the \'nj_glo\'  value !") 
    253         } 
    254  
    255255        int globalDomainSize = ni_glo * nj_glo; 
    256256        if (globalDomainSize <= nbLocalDomain) 
     
    329329        // Now fill other attributes 
    330330        if (type_attr::rectilinear == type) fillInRectilinearLonLat(); 
     331     } 
     332     else  // unstructured domain 
     333     { 
     334        int globalDomainSize = ni_glo * nj_glo; 
     335        if (globalDomainSize <= nbLocalDomain) 
     336        { 
     337          for (int idx = 0; idx < nbLocalDomain; ++idx) 
     338          { 
     339            if (rankOnDomain < globalDomainSize) 
     340            { 
     341              int iIdx = rankOnDomain % ni_glo; 
     342              int jIdx = rankOnDomain / ni_glo; 
     343              ibegin.setValue(iIdx); jbegin.setValue(jIdx); 
     344              ni.setValue(1); nj.setValue(1); 
     345            } 
     346            else 
     347            { 
     348              ibegin.setValue(0); jbegin.setValue(0); 
     349              ni.setValue(0); nj.setValue(0); 
     350            } 
     351          } 
     352        } 
     353        else 
     354        { 
     355          float njGlo = nj_glo.getValue(); 
     356          float niGlo = ni_glo.getValue(); 
     357          std::vector<int> ibeginVec(nbLocalDomain,0); 
     358          std::vector<int> niVec(nbLocalDomain); 
     359          for (int i = 1; i < nbLocalDomain; ++i) 
     360          { 
     361            int range = ni_glo / nbLocalDomain; 
     362            if (i < (ni_glo%nbLocalDomain)) ++range; 
     363            niVec[i-1] = range; 
     364            ibeginVec[i] = ibeginVec[i-1] + niVec[i-1]; 
     365          } 
     366          niVec[nbLocalDomain-1] = ni_glo - ibeginVec[nbLocalDomain-1]; 
     367 
     368          int iIdx = rankOnDomain % nbLocalDomain; 
     369          ibegin.setValue(ibeginVec[iIdx]); 
     370          jbegin.setValue(0); 
     371          ni.setValue(niVec[iIdx]); 
     372          nj.setValue(1); 
     373        } 
    331374     } 
    332375   } 
Note: See TracChangeset for help on using the changeset viewer.