Ignore:
Timestamp:
07/28/15 13:37:07 (9 years ago)
Author:
mhnguyen
Message:

Making changes in domain to make sure unstructed grid work with new method of index distribution

+) Change the way define i_index and j_index of a domain
+) Remove some redundant attributes of domain
+) Adjust the way to calculate index distribution on server side

Test
+) Make some minor change to test_unstruct_complete to work with new XIOS
+) On Curie
+) All test pass and correct

File:
1 edited

Legend:

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

    • Property svn:executable set to *
    r635 r657  
    1717#include "client_server_mapping_distributed.hpp" 
    1818#include "zoom_domain.hpp" 
     19#include "interpolate_from_file_domain.hpp" 
    1920 
    2021namespace xios { 
     
    2526      : CObjectTemplate<CDomain>(), CDomainAttributes() 
    2627      , isChecked(false), relFiles(), isClientChecked(false), nbConnectedClients_(), indSrv_(), connectedServerRank_() 
    27       , hasBounds(false), hasArea(false), isDistributed_(false) 
    28       , global_zoom_ibegin(0), global_zoom_ni(0), global_zoom_jbegin(0), global_zoom_nj(0) 
     28      , hasBounds(false), hasArea(false), isDistributed_(false), nGlobDomain_(), isUnstructed_(false) 
     29      , global_zoom_ni(0), global_zoom_ibegin(0), global_zoom_nj(0), global_zoom_jbegin(0), maskInter_() 
     30      , isClientAfterTransformationChecked(false) 
    2931   { /* Ne rien faire de plus */ } 
    3032 
     
    3234      : CObjectTemplate<CDomain>(id), CDomainAttributes() 
    3335      , isChecked(false), relFiles(), isClientChecked(false), nbConnectedClients_(), indSrv_(), connectedServerRank_() 
    34       , hasBounds(false), hasArea(false), isDistributed_(false) 
    35       , global_zoom_ibegin(0), global_zoom_ni(0), global_zoom_jbegin(0), global_zoom_nj(0) 
     36      , hasBounds(false), hasArea(false), isDistributed_(false), nGlobDomain_(), isUnstructed_(false) 
     37      , global_zoom_ni(0), global_zoom_ibegin(0), global_zoom_nj(0), global_zoom_jbegin(0), maskInter_() 
     38      , isClientAfterTransformationChecked(false) 
    3639   { /* Ne rien faire de plus */ } 
    3740 
     
    5962 
    6063   //---------------------------------------------------------------- 
    61  
    62    bool CDomain::hasZoom(void) const 
    63    { 
    64       return ((this->zoom_ni.getValue() != this->ni_glo.getValue()) && 
    65               (this->zoom_nj.getValue() != this->nj_glo.getValue())); 
    66    } 
    67  
    68    //---------------------------------------------------------------- 
    69  
    7064   bool CDomain::isEmpty(void) const 
    7165   { 
     
    7569 
    7670   //---------------------------------------------------------------- 
    77  
    7871   bool CDomain::IsWritten(const StdString & filename) const 
    7972   { 
     
    8275 
    8376   //---------------------------------------------------------------- 
    84  
    8577   bool CDomain::isDistributed(void) const 
    8678   { 
     
    8981 
    9082   //---------------------------------------------------------------- 
    91  
    9283   void CDomain::addRelFile(const StdString & filename) 
    9384   { 
     
    113104               << " check the \'ni_glo\'  value !") 
    114105         } 
    115          nj_glo=ni_glo ; 
    116          ni_glo=1 ; 
    117          if (!ni.isEmpty()) nj=ni ; 
    118          if (!ibegin.isEmpty()) jbegin=ibegin ; 
    119          if (!iend.isEmpty()) jend=iend ; 
    120          if (!i_index.isEmpty()) 
    121          { 
    122           j_index.resize(1,nj) ; 
    123           for(int i=0;i<ni;i++) j_index(0,i)=i_index(i,0) ; 
    124           i_index.resize(1,nj) ; 
    125           for(int j=0;j<nj;j++) i_index(0,j)=0 ; 
    126          } 
    127  
    128          if (!mask.isEmpty()) 
    129          { 
    130           CArray<int,2> mask_tmp(nj,1) ; 
    131           mask_tmp = mask ; 
    132           mask.resize(1,nj) ; 
    133           for(int j=0;j<nj;j++) mask(0,j)=mask_tmp(j,0) ; 
    134          } 
     106         isUnstructed_ = true; 
     107         nj_glo = 1; 
     108         nj = 1; 
     109         jbegin = 0; 
     110         if (ni.isEmpty()) ni = i_index.numElements(); 
     111         j_index.resize(ni); 
     112         for(int i=0;i<ni;++i) j_index(i)=0; 
     113 
     114//         nj_glo=ni_glo ; 
     115//         ni_glo=1 ; 
     116//         if (!ni.isEmpty()) nj=ni ; 
     117//         if (!ibegin.isEmpty()) jbegin=ibegin ; 
     118//         if (!iend.isEmpty()) jend=iend ; 
     119//         if (!i_index.isEmpty()) 
     120//         { 
     121//          j_index.resize(1,nj) ; 
     122//          for(int i=0;i<ni;i++) j_index(0,i)=i_index(i,0) ; 
     123//          i_index.resize(1,nj) ; 
     124//          for(int j=0;j<nj;j++) i_index(0,j)=0 ; 
     125//         } 
     126// 
     127//         if (!mask.isEmpty()) 
     128//         { 
     129//          CArray<int,2> mask_tmp(nj,1); 
     130//          mask_tmp = mask ; 
     131//          mask.resize(1,nj) ; 
     132//          for(int j=0;j<nj;j++) mask(0,j)=mask_tmp(j,0) ; 
     133//         } 
    135134 
    136135         if (!area.isEmpty()) 
    137136           area.transposeSelf(1, 0); 
    138137 
    139          ni=1 ; 
    140          ibegin=0 ; 
    141          iend=0 ; 
     138//         ni=1 ; 
     139//         ibegin=0 ; 
     140//         iend=0 ; 
    142141 
    143142      } 
     
    151150      } 
    152151 
    153       isDistributed_ = !ibegin.isEmpty() || !iend.isEmpty() || !ni.isEmpty() || !jbegin.isEmpty() || !jend.isEmpty() || !nj.isEmpty(); 
     152      isDistributed_ = !ibegin.isEmpty() || !ni.isEmpty() || !jbegin.isEmpty() || !nj.isEmpty(); 
    154153 
    155154      checkLocalIDomain(); 
    156155      checkLocalJDomain(); 
    157156 
    158       ibegin_client = ibegin; iend_client = iend; ni_client = ni; 
    159       jbegin_client = jbegin; jend_client = jend; nj_client = nj; 
     157      ibegin_client = ibegin; ni_client = ni; iend_client = ibegin + ni - 1; 
     158      jbegin_client = jbegin; nj_client = nj; jend_client = jbegin + nj - 1; 
    160159 
    161160      if (i_index.isEmpty()) 
    162161      { 
    163         i_index.resize(ni,nj); 
    164         for (int j = 0; j < nj; j++) 
    165           for (int i = 0; i < ni; i++) i_index(i,j) = i; 
     162        i_index.resize(ni*nj); 
     163        for (int j = 0; j < nj; ++j) 
     164          for (int i = 0; i < ni; ++i) i_index(i+j*ni) = i+ibegin; 
    166165      } 
    167166 
    168167      if (j_index.isEmpty()) 
    169168      { 
    170         j_index.resize(ni,nj); 
    171         for (int j = 0; j < nj; j++) 
    172           for (int i = 0; i < ni; i++) j_index(i,j) = j; 
    173       } 
     169        j_index.resize(ni*nj); 
     170        for (int j = 0; j < nj; ++j) 
     171          for (int i = 0; i < ni; ++i) j_index(i+j*ni) = j+jbegin; 
     172      } 
     173      computeNGlobDomain(); 
    174174   } 
    175175 
     
    178178   void CDomain::checkLocalIDomain(void) 
    179179   { 
    180       if (!ni.isEmpty() && !ibegin.isEmpty() && iend.isEmpty()) 
    181         iend.setValue(ibegin.getValue() + ni.getValue() - 1); 
    182       else if (!ni.isEmpty() && !iend.isEmpty() && ibegin.isEmpty()) 
    183         ibegin.setValue(iend.getValue() - ni.getValue()  + 1); 
    184       else if (!ibegin.isEmpty() && !iend.isEmpty() && ni.isEmpty()) 
    185         ni.setValue(iend.getValue() - ibegin.getValue() + 1); 
    186       else if (!ibegin.isEmpty() && !iend.isEmpty() && !ni.isEmpty()) 
    187       { 
    188         if (iend.getValue() != ibegin.getValue() + ni.getValue() - 1) 
    189           ERROR("CDomain::checkLocalIDomain(void)", 
    190                 << "[ Id = " << this->getId() << " ] " 
    191                 << "The local domain is wrongly defined," 
    192                 << " iend is different from (ibegin + ni - 1)"); 
    193       } 
    194       else if (ibegin.isEmpty() && iend.isEmpty() && ni.isEmpty()) 
     180      if (ibegin.isEmpty() && ni.isEmpty()) 
    195181      { 
    196182        ibegin = 0; 
    197         iend = ni_glo - 1; 
    198183        ni = ni_glo; 
    199184      } 
    200       else 
     185      else if (!i_index.isEmpty()) 
     186      { 
     187        ibegin = i_index(0); 
     188      } 
     189 
     190      if (ni.getValue() < 0 || ibegin.getValue() < 0 || 
     191         (ibegin.getValue() + ni.getValue()) > ni_glo.getValue()) 
    201192      { 
    202193        ERROR("CDomain::checkLocalIDomain(void)", 
    203194              << "[ Id = " << this->getId() << " ] " 
    204195              << "The local domain is wrongly defined," 
    205               << " defining just one attribute among 'ibegin', 'iend' or 'ni' is invalid"); 
    206       } 
    207  
    208       if (ni.getValue() < 0 || ibegin.getValue() > iend.getValue() || 
    209           ibegin.getValue() < 0 || iend.getValue() > (ni_glo.getValue() - 1)) 
    210       { 
    211         ERROR("CDomain::checkLocalIDomain(void)", 
    212               << "[ Id = " << this->getId() << " ] " 
    213               << "The local domain is wrongly defined," 
    214               << " check the attributes 'ni_glo', 'ni', 'ibegin' and 'iend'"); 
    215       } 
    216    } 
    217  
    218    //---------------------------------------------------------------- 
    219  
     196              << " check the attributes 'ni_glo', 'ni' and 'ibegin'"); 
     197      } 
     198   } 
     199 
     200   //---------------------------------------------------------------- 
    220201   void CDomain::checkLocalJDomain(void) 
    221202   { 
    222       if (!nj.isEmpty() && !jbegin.isEmpty() && jend.isEmpty()) 
    223         jend.setValue(jbegin.getValue() + nj.getValue() - 1); 
    224       else if (!nj.isEmpty() && !jend.isEmpty() && jbegin.isEmpty()) 
    225         jbegin.setValue(jend.getValue() - nj.getValue() + 1); 
    226       else if (!jbegin.isEmpty() && !jend.isEmpty() && nj.isEmpty()) 
    227         nj.setValue(jend.getValue() - jbegin.getValue() + 1); 
    228       else if (!jbegin.isEmpty() && !jend.isEmpty() && !nj.isEmpty()) 
    229       { 
    230         if (jend.getValue() != jbegin.getValue() + nj.getValue() - 1) 
    231           ERROR("CDomain::checkLocalJDomain(void)", 
    232                 << "[ Id = " << this->getId() << " ] " 
    233                 << "The local domain is wrongly defined," 
    234                 << " jend is different from (jbegin + nj - 1)"); 
    235       } 
    236       else if (jbegin.isEmpty() && jend.isEmpty() && nj.isEmpty()) 
    237       { 
    238         jbegin = 0; 
    239         jend = nj_glo - 1; 
    240         nj = nj_glo; 
    241       } 
    242       else 
     203     if (jbegin.isEmpty() && nj.isEmpty()) 
     204     { 
     205       jbegin = 0; 
     206       nj = nj_glo; 
     207     } 
     208     else if (!j_index.isEmpty()) 
     209     { 
     210       jbegin = j_index(0); 
     211     } 
     212 
     213      if (nj.getValue() < 0 || jbegin.getValue() < 0 || 
     214         (jbegin.getValue() + nj.getValue()) > nj_glo.getValue()) 
    243215      { 
    244216        ERROR("CDomain::checkLocalJDomain(void)", 
    245217              << "[ Id = " << this->getId() << " ] " 
    246218              << "The local domain is wrongly defined," 
    247               << " defining just one attribute among 'jbegin', 'jend' or 'nj' is invalid"); 
    248       } 
    249  
    250       if (nj.getValue() < 0 || jbegin.getValue() > jend.getValue() || 
    251           jbegin.getValue() < 0 || jend.getValue() > (nj_glo.getValue() - 1)) 
    252       { 
    253         ERROR("CDomain::checkLocalJDomain(void)", 
    254               << "[ Id = " << this->getId() << " ] " 
    255               << "The local domain is wrongly defined," 
    256               << " check the attributes 'nj_glo', 'nj', 'jbegin' and 'jend'"); 
    257       } 
    258    } 
    259  
    260    //---------------------------------------------------------------- 
    261  
     219              << " check the attributes 'nj_glo', 'nj' and 'jbegin'"); 
     220      } 
     221   } 
     222 
     223   //---------------------------------------------------------------- 
    262224   void CDomain::checkMask(void) 
    263225   { 
     
    266228      int ibegin_mask = 0, 
    267229          jbegin_mask = 0, 
    268           iend_mask = iend.getValue() - ibegin.getValue(), 
    269           jend_mask = jend.getValue() - jbegin.getValue(); 
    270  
    271       if (!zoom_ibegin.isEmpty()) 
    272       { 
    273          int zoom_iend = zoom_ibegin.getValue() + zoom_ni.getValue() - 1; 
    274          int zoom_jend = zoom_jbegin.getValue() + zoom_nj.getValue() - 1; 
    275  
    276          ibegin_mask = max (ibegin.getValue(), zoom_ibegin.getValue()); 
    277          jbegin_mask = max (jbegin.getValue(), zoom_jbegin.getValue()); 
    278          iend_mask   = min (iend.getValue(), zoom_iend); 
    279          jend_mask   = min (jend.getValue(), zoom_jend); 
    280  
    281          ibegin_mask -= ibegin.getValue(); 
    282          jbegin_mask -= jbegin.getValue(); 
    283          iend_mask   -= ibegin.getValue(); 
    284          jend_mask   -= jbegin.getValue(); 
    285       } 
    286  
     230          iend_mask = ibegin.getValue() + ni.getValue() - 1, 
     231          jend_mask = jbegin.getValue() + nj.getValue() - 1; 
     232 
     233      if (!mask_1D.isEmpty() && !mask_2D.isEmpty()) 
     234        ERROR("CDomain::checkMask(void)", 
     235             <<"Only one mask is used but both mask_1D and mask_2D are defined! "<<endl 
     236             <<"Define only one mask: mask_1D or mask_2D "); 
     237 
     238      if (!mask_1D.isEmpty() && mask_2D.isEmpty()) 
     239      { 
     240        if (mask_1D.numElements() != i_index.numElements()) 
     241          ERROR("CDomain::checkMask(void)", 
     242                <<"the mask_1D has not the same size than the local domain"<<endl 
     243                <<"Local size is "<<i_index.numElements()<<endl 
     244                <<"Mask size is "<<mask_1D.numElements()); 
     245      } 
     246 
     247      if (mask_1D.isEmpty() && !mask_2D.isEmpty()) 
     248      { 
     249         if ((mask_2D.extent(0) != ni) || 
     250             (mask_2D.extent(1) != nj)) 
     251            ERROR("CDomain::checkMask(void)", 
     252                  <<"the mask has not the same size than the local domain"<<endl 
     253                  <<"Local size is "<<ni<<"x"<<nj<<endl 
     254                  <<"Mask size is "<<mask.extent(0)<<"x"<<mask.extent(1)); 
     255      } 
     256 
     257      if (!mask_1D.isEmpty()) 
     258      { 
     259        maskInter_.resize(mask_1D.numElements()); 
     260        maskInter_ = mask_1D; 
     261      } 
     262      else if (!mask_2D.isEmpty()) 
     263      { 
     264        maskInter_.resize(mask_2D.extent(0) * mask_2D.extent(0)); 
     265        for (int j = 0; j < nj; ++j) 
     266          for (int i = 0; i < ni; ++i) maskInter_(i+j*ni) = mask_2D(i,j); 
     267      } 
     268      else 
     269      { 
     270        maskInter_.resize(i_index.numElements()); 
     271        for (int i = 0; i < i_index.numElements(); ++i) maskInter_(i) = true; 
     272      } 
     273 
     274      if (!mask.isEmpty()) 
     275      { 
     276        maskInter_.resize(mask.extent(0) * mask.extent(1)); 
     277        for (int j = 0; j < nj; ++j) 
     278          for (int i = 0; i < ni; ++i) maskInter_(i+j*ni) = mask(i,j); 
     279      } 
     280      else 
     281      { 
     282        maskInter_.resize(ni*nj); 
     283        for (int i = 0; i < maskInter_.numElements(); ++i) maskInter_(i) = true; 
     284      } 
    287285 
    288286      if (!mask.isEmpty()) 
     
    294292                   <<"Local size is "<<ni<<"x"<<nj<<endl 
    295293                  <<"Mask size is "<<mask.extent(0)<<"x"<<mask.extent(1)); 
    296          for (int i = 0; i < ni; i++) 
    297          { 
    298             for (int j = 0; j < nj; j++) 
    299             { 
    300                if (i < ibegin_mask && i > iend_mask && 
    301                    j < jbegin_mask && j > jend_mask ) 
    302                      mask(i,j) = false; 
    303             } 
    304          } 
     294//         for (int i = 0; i < ni; i++) 
     295//         { 
     296//            for (int j = 0; j < nj; j++) 
     297//            { 
     298//               if (i < ibegin_mask && i > iend_mask && 
     299//                   j < jbegin_mask && j > jend_mask ) 
     300//                     mask(i,j) = false; 
     301//            } 
     302//         } 
    305303      } 
    306304      else // (!mask.hasValue()) 
     
    520518   void CDomain::checkZoom(void) 
    521519   { 
    522       // Résolution et vérification des données globales de zoom. 
    523       if (!this->zoom_ni.isEmpty() || !this->zoom_nj.isEmpty() || 
    524           !this->zoom_ibegin.isEmpty() || !this->zoom_jbegin.isEmpty()) 
    525       { 
    526          if (this->zoom_ni.isEmpty()     || this->zoom_nj.isEmpty() || 
    527              this->zoom_ibegin.isEmpty() || this->zoom_jbegin.isEmpty()) 
    528          { 
    529             ERROR("CDomain::checkZoom(void)", 
    530                   <<"if one of zoom attributes is defined then all zoom attributes must be defined") ; 
    531          } 
    532          else 
    533          { 
    534             int zoom_iend = zoom_ibegin + zoom_ni - 1; 
    535             int zoom_jend = zoom_jbegin + zoom_nj - 1; 
    536  
    537             if (zoom_ibegin < 0  || zoom_jbegin < 0 || zoom_iend > (ni_glo-1) || zoom_jend > (nj_glo-1)) 
    538                ERROR("CDomain::checkZoom(void)", 
    539                      << "Zoom is wrongly defined," 
    540                      << " Check the values : zoom_ni, zoom_nj, zoom_ibegin, zoom_jbegin") ; 
    541          } 
    542       } 
    543       else 
    544       { 
    545          zoom_ni = ni_glo; 
    546          zoom_nj = nj_glo; 
    547          zoom_ibegin = 0; 
    548          zoom_jbegin = 0; 
    549       } 
    550  
    551520      // compute client zoom indices 
    552521      // compute client zoom indices 
     
    594563   } 
    595564 
     565//   void CDomain::checkAttributesOnClientBeforeTransformation() 
     566//   { 
     567//      if (this->isClientBeforeTransformationChecked) return; 
     568//      CContext* context=CContext::getCurrent(); 
     569// 
     570//      this->checkDomain(); 
     571//      this->checkBounds(); 
     572//      this->checkArea(); 
     573// 
     574//      if (context->hasClient) 
     575//      { 
     576//        this->checkDomainData(); 
     577//        this->checkCompression(); 
     578//      } 
     579// 
     580//      this->isClientBeforeTransformationChecked = true; 
     581//   } 
     582 
     583   void CDomain::checkAttributesOnClientAfterTransformation() 
     584   { 
     585     CContext* context=CContext::getCurrent() ; 
     586 
     587     this->checkZoom(); 
     588     if (this->isClientAfterTransformationChecked) return; 
     589     if (context->hasClient) 
     590     { 
     591       this->checkMask(); 
     592       this->computeConnectedServer(); 
     593       this->completeLonLatClient(); 
     594     } 
     595 
     596     this->isClientAfterTransformationChecked = true; 
     597   } 
     598 
    596599   //---------------------------------------------------------------- 
    597600   // Divide function checkAttributes into 2 seperate ones 
     
    625628   { 
    626629     if (!this->isClientChecked) checkAttributesOnClient(); 
     630     if (!this->isClientAfterTransformationChecked) checkAttributesOnClientAfterTransformation(); 
    627631     CContext* context=CContext::getCurrent() ; 
    628632 
     
    631635     if (context->hasClient) 
    632636     { 
    633        this->computeConnectedServer(); 
    634        this->completeLonLatClient(); 
     637//       this->computeConnectedServer(); 
     638//       this->completeLonLatClient(); 
    635639 
    636640       sendServerAttribut() ; 
     
    676680  void CDomain::sendServerAttribut(void) 
    677681  { 
    678     std::vector<int> nGlobDomain(2); 
    679     nGlobDomain[0] = ni_glo.getValue(); 
    680     nGlobDomain[1] = nj_glo.getValue(); 
    681     CServerDistributionDescription serverDescription(nGlobDomain); 
     682    CServerDistributionDescription serverDescription(nGlobDomain_); 
    682683 
    683684    CContext* context = CContext::getCurrent(); 
     
    685686    int nbServer = client->serverSize; 
    686687 
    687     serverDescription.computeServerDistribution(nbServer); 
     688    if (isUnstructed_) serverDescription.computeServerDistribution(nbServer,0); 
     689    else serverDescription.computeServerDistribution(nbServer,1); 
     690 
    688691    std::vector<std::vector<int> > serverIndexBegin = serverDescription.getServerIndexBegin(); 
    689692    std::vector<std::vector<int> > serverDimensionSizes = serverDescription.getServerDimensionSizes(); 
     
    718721  } 
    719722 
     723  void CDomain::computeNGlobDomain() 
     724  { 
     725    nGlobDomain_.resize(2); 
     726    nGlobDomain_[0] = ni_glo.getValue(); 
     727    nGlobDomain_[1] = nj_glo.getValue(); 
     728  } 
     729 
    720730  void CDomain::computeConnectedServer(void) 
    721731  { 
    722     ibegin_client=ibegin ; iend_client=iend ; ni_client=ni ; 
    723     jbegin_client=jbegin ; jend_client=jend ; nj_client=nj ; 
     732    ibegin_client=ibegin; ni_client=ni; iend_client=ibegin_client + ni_client - 1; 
     733    jbegin_client=jbegin; nj_client=nj; jend_client=jbegin_client + nj_client - 1; 
    724734 
    725735    CContext* context=CContext::getCurrent() ; 
     
    728738    bool doComputeGlobalIndexServer = true; 
    729739 
    730     int i,j,i_ind,j_ind ; 
     740    int i,j,i_ind,j_ind, nbIndex; 
    731741    int zoom_iend=global_zoom_ibegin+global_zoom_ni-1 ; 
    732742    int zoom_jend=global_zoom_jbegin+global_zoom_nj-1 ; 
     
    734744    // Precompute number of index 
    735745    int globalIndexCountZoom = 0; 
    736     for(j=0;j<nj;j++) 
    737       for(i=0;i<ni;i++) 
    738       { 
    739         i_ind=ibegin+i_index(i,j) ; 
    740         j_ind=jbegin+j_index(i,j) ; 
    741  
    742         if (i_ind >= global_zoom_ibegin && i_ind <= zoom_iend && j_ind >= global_zoom_jbegin && j_ind <= zoom_jend) 
    743         { 
    744           ++globalIndexCountZoom; 
    745         } 
    746       } 
     746    nbIndex = i_index.numElements(); 
     747    for (i = 0; i < nbIndex; ++i) 
     748    { 
     749      i_ind=i_index(i); 
     750      j_ind=j_index(i); 
     751 
     752      if (i_ind >= global_zoom_ibegin && i_ind <= zoom_iend && j_ind >= global_zoom_jbegin && j_ind <= zoom_jend) 
     753      { 
     754        ++globalIndexCountZoom; 
     755      } 
     756    } 
    747757 
    748758    // Fill in index 
    749759    CArray<size_t,1> globalIndexDomainZoom(globalIndexCountZoom); 
    750     CArray<size_t,1> globalIndexDomain(ni*nj); 
     760    CArray<size_t,1> localIndexDomainZoom(globalIndexCountZoom); 
     761    CArray<size_t,1> globalIndexDomain(nbIndex); 
    751762    size_t globalIndex; 
    752763    int globalIndexCount = 0; 
    753764    globalIndexCountZoom = 0; 
    754765 
    755     for(j=0;j<nj;j++) 
    756       for(i=0;i<ni;i++) 
    757       { 
    758         i_ind=ibegin+i_index(i,j) ; 
    759         j_ind=jbegin+j_index(i,j) ; 
    760  
    761         globalIndex = i_ind + j_ind * ni_glo; 
    762         globalIndexDomain(globalIndexCount) = globalIndex; 
    763         ++globalIndexCount; 
    764         if (i_ind >= global_zoom_ibegin && i_ind <= zoom_iend && j_ind >= global_zoom_jbegin && j_ind <= zoom_jend) 
    765         { 
    766           globalIndexDomainZoom(globalIndexCountZoom) = globalIndex; 
    767           ++globalIndexCountZoom; 
    768         } 
    769       } 
    770  
    771      std::vector<int> nGlobDomain(2); 
    772      nGlobDomain[0] = ni_glo.getValue(); 
    773      nGlobDomain[1] = nj_glo.getValue(); 
     766    for (i = 0; i < nbIndex; ++i) 
     767    { 
     768      i_ind=i_index(i); 
     769      j_ind=j_index(i); 
     770      globalIndex = i_ind + j_ind * ni_glo; 
     771      globalIndexDomain(globalIndexCount) = globalIndex; 
     772      ++globalIndexCount; 
     773      if (i_ind >= global_zoom_ibegin && i_ind <= zoom_iend && j_ind >= global_zoom_jbegin && j_ind <= zoom_jend) 
     774      { 
     775        globalIndexDomainZoom(globalIndexCountZoom) = globalIndex; 
     776        localIndexDomainZoom(globalIndexCountZoom) = i; 
     777        ++globalIndexCountZoom; 
     778      } 
     779    } 
     780 
    774781     size_t globalSizeIndex = 1, indexBegin, indexEnd; 
    775782     int range, clientSize = client->clientSize; 
    776      for (int i = 0; i < nGlobDomain.size(); ++i) globalSizeIndex *= nGlobDomain[i]; 
     783     for (int i = 0; i < nGlobDomain_.size(); ++i) globalSizeIndex *= nGlobDomain_[i]; 
    777784     indexBegin = 0; 
    778785     for (int i = 0; i < clientSize; ++i) 
     
    785792     indexEnd = indexBegin + range - 1; 
    786793 
    787     CServerDistributionDescription serverDescription(nGlobDomain); 
    788     serverDescription.computeServerGlobalIndexInRange(nbServer, std::make_pair<size_t,size_t>(indexBegin, indexEnd)); 
     794    CServerDistributionDescription serverDescription(nGlobDomain_); 
     795    if (isUnstructed_) serverDescription.computeServerGlobalIndexInRange(nbServer, std::make_pair<size_t,size_t>(indexBegin, indexEnd), 0); 
     796    else serverDescription.computeServerGlobalIndexInRange(nbServer, std::make_pair<size_t,size_t>(indexBegin, indexEnd), 1); 
     797 
    789798    CClientServerMapping* clientServerMap = new CClientServerMappingDistributed(serverDescription.getGlobalIndexRange(), 
    790799                                                                                client->intraComm); 
     
    805814        if (iteVec != std::find(itbVec, iteVec, globalIndexDomainZoom(i))) 
    806815        { 
    807           indSrv_[rank].push_back(globalIndexDomainZoom(i)); 
     816          indSrv_[rank].push_back(localIndexDomainZoom(i)); 
    808817        } 
    809818      } 
     
    824833 
    825834    delete clientServerMap; 
     835  } 
     836 
     837  const std::map<int, vector<size_t> >& CDomain::getIndexServer() const 
     838  { 
     839    return indSrv_; 
    826840  } 
    827841 
     
    871885      CArray<double,1>& lon = list_lon.back(); 
    872886      CArray<double,1>& lat = list_lat.back(); 
    873  
     887      const std::vector<size_t>& temp = it->second; 
    874888      for (n = 0; n < nbData; ++n) 
    875889      { 
    876890        idx = static_cast<int>(it->second[n]); 
    877         i = idx % ni_glo; 
    878         j = idx / ni_glo; 
    879         ind = (i - zoom_ibegin_client) + (j - zoom_jbegin_client) * zoom_ni_client; 
     891        i = i_index(idx); 
     892        j = j_index(idx); 
     893        ind = n; 
     894//        ind = (i - zoom_ibegin_client) + (j - zoom_jbegin_client) * zoom_ni_client; 
    880895 
    881896        lon(n) = lonvalue(ind); 
     
    894909        } 
    895910 
    896         indi(n) = ibegin + i_index(i - ibegin, j - jbegin); 
    897         indj(n) = jbegin + j_index(i - ibegin, j - jbegin); 
     911        indi(n) = i; 
     912        indj(n) = j; 
    898913 
    899914        if (hasArea) 
     
    11921207      StdString zoomDomainDefRoot("zoom_domain_definition"); 
    11931208      StdString zoom("zoom_domain"); 
     1209      StdString interpFromFileDomainDefRoot("interpolate_from_file_domain_definition"); 
     1210      StdString interpFromFile("interpolate_from_file_domain"); 
    11941211      do 
    11951212      { 
     
    11991216          transformationMap_.push_back(std::make_pair(TRANS_ZOOM_DOMAIN,tmp)); 
    12001217        } 
     1218        else if (node.getElementName() == interpFromFile) 
     1219        { 
     1220          CInterpolateFromFileDomain* tmp = (CInterpolateFromFileDomainGroup::get(interpFromFileDomainDefRoot))->createChild(); 
     1221          tmp->parse(node); 
     1222          transformationMap_.push_back(std::make_pair(TRANS_INTERPOLATE_DOMAIN_FROM_FILE,tmp)); 
     1223        } 
    12011224      } while (node.goToNextElement()) ; 
    12021225      node.goToParentElement(); 
Note: See TracChangeset for help on using the changeset viewer.