Changeset 818


Ignore:
Timestamp:
01/26/16 18:19:14 (6 years ago)
Author:
mhnguyen
Message:

Fixing mixed index of unstructured grid

+) Update correct global index with i_index,j_index

Test
+) On Curie
+) test_client, test_complete, test_remap, test_unstruct pass

Location:
XIOS/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/inputs/REMAP/iodef.xml

    r786 r818  
    1010     <field id="dst_field" operation="instant" field_ref="src_field" domain_ref="dst_domain"/> 
    1111     <field id="tmp_field" operation="instant" domain_ref="src_domain_regular_tmp"/> 
    12      <field id="tmp_field_1" operation="instant" grid_ref="src_grid_curvilinear" /> 
    13      <field id="tmp_field_2" operation="instant" domain_ref="domain_src_unstructured" /> 
     12<!--     <field id="tmp_field_1" operation="instant" grid_ref="src_grid_curvilinear" />--> 
     13<!--     <field id="tmp_field_2" operation="instant" domain_ref="domain_src_unstructured" />--> 
    1414     <field id="dst_field_regular" operation="instant" field_ref="tmp_field" domain_ref="dst_domain_regular" read_access="true"/> 
    15      <field id="dst_field_regular_pole" operation="instant" field_ref="src_field" domain_ref="dst_domain_regular_pole"/> 
     15<!--     <field id="dst_field_regular_pole" operation="instant" field_ref="src_field" domain_ref="dst_domain_regular_pole"/>--> 
    1616   </field_definition> 
    1717 
     
    1919   <file_definition type="one_file" par_access="collective" output_freq="1ts" output_level="10" enabled=".TRUE."> 
    2020     <file id="output" name="output"> 
    21 <!--        <field field_ref="src_field" name="field" />--> 
     21        <field field_ref="src_field" name="field" /> 
    2222     </file> 
    2323     <file id="output_dst" name="output_dst" type="one_file"> 
    24 <!--        <field field_ref="dst_field" name="field" />--> 
     24        <field field_ref="dst_field" name="field" /> 
    2525     </file> 
    2626     <file id="out_dst_regular_pole" name="out_dst_regular_pole" type="one_file"> 
    27         <field field_ref="dst_field_regular_pole" name="field" /> 
     27<!--        <field field_ref="dst_field_regular_pole" name="field" />--> 
    2828     </file> 
    2929     <file id="output_dst_regular" name="output_dst_regular" type="one_file"> 
    30 <!--        <field field_ref="dst_field_regular" name="field" />--> 
     30        <field field_ref="dst_field_regular" name="field" /> 
    3131     </file> 
    3232     <file id="output_dst_curvilinear" name="output_dst_curvilinear" type="one_file"> 
     
    3434     </file> 
    3535     <file id="output_dst_unstructured" name="output_dst_unstructured" type="one_file"> 
    36         <field field_ref="tmp_field_2" operation="instant"/> 
     36<!--        <field field_ref="tmp_field_2" operation="instant"/>--> 
    3737     </file> 
    3838 
     
    4545 
    4646     <file id="output_src_curvilinear" name="output_src_curvilinear" mode="read" type="one_file"> 
    47         <field id="src_field_curvilinear" name="field_A" grid_ref="src_grid_curvilinear" operation="instant"/> 
     47<!--        <field id="src_field_curvilinear" name="field_A" grid_ref="src_grid_curvilinear" operation="instant"/>--> 
    4848     </file> 
    4949     <file id="output_unstructured" name="output_unstructured" mode="read" type="one_file"> 
    50         <field id="field_src_unstructred" name="field" domain_ref="domain_src_unstructured" operation="instant"/> 
     50<!--        <field id="field_src_unstructred" name="field" domain_ref="domain_src_unstructured" operation="instant"/>--> 
    5151     </file> 
    5252   </file_definition> 
     
    6262   <domain_definition> 
    6363     <domain id="src_domain" /> 
    64      <domain id="dst_domain" domain_src="src_domain"> 
     64     <domain id="dst_domain"> 
    6565       <interpolate_domain/> 
    6666     </domain> 
    67      <domain id="dst_domain_regular_pole" domain_src="src_domain" ni_glo="180" nj_glo="90" type="rectilinear"> 
     67     <domain id="dst_domain_regular_pole" ni_glo="180" nj_glo="90" type="rectilinear"> 
    6868       <generate_rectilinear_domain id="domain_regular_pole"/> 
    6969       <interpolate_domain/> 
    7070     </domain> 
    71      <domain id="dst_domain_regular" domain_src="src_domain_regular_tmp" ni_glo="90" nj_glo="45" type="rectilinear"> 
     71     <domain id="dst_domain_regular" ni_glo="90" nj_glo="45" type="rectilinear"> 
    7272       <generate_rectilinear_domain /> 
    7373       <interpolate_domain/> 
  • XIOS/trunk/inputs/Unstruct/iodef.xml

    r718 r818  
    99   </field_definition> 
    1010 
    11    <file_definition type="multiple_file" par_access="collective" output_freq="6h" output_level="10" enabled=".TRUE."> 
     11   <file_definition type="one_file" par_access="collective" output_freq="6h" output_level="10" enabled=".TRUE."> 
    1212     <file id="output" name="output"> 
    1313        <field field_ref="field_A_srf" name="field_A_srf" /> 
  • XIOS/trunk/src/distribution_client.cpp

    r817 r818  
    1919   , isDataDistributed_(true), axisNum_(0), domainNum_(0), nIndexDomain_(), nIndexAxis_() 
    2020   , globalDataSendToServer_(), localDataIndexSendToServer_(), localDataIndex_(), localMaskIndex_() 
     21   , infoIndex_() 
    2122{ 
    2223} 
     
    3031   , isDataDistributed_(true), axisNum_(0), domainNum_(0), nIndexDomain_(), nIndexAxis_() 
    3132   , globalDataSendToServer_(), localDataIndexSendToServer_(), localDataIndex_(), localMaskIndex_() 
     33   , infoIndex_() 
    3234{ 
    3335  readDistributionInfo(grid); 
     
    176178  // Data_*_index of each dimension 
    177179  dataIndex_.resize(this->dims_); 
     180  infoIndex_.resize(this->dims_); 
    178181 
    179182  // A trick to determine position of each domain in domainList 
     
    201204      dataIndex_.at(indexMap_[idx]+1).resize(domList[domIndex]->data_j_index.numElements()); 
    202205      dataIndex_.at(indexMap_[idx]+1) = domList[domIndex]->data_j_index; 
     206      infoIndex_.at(indexMap_[idx]+1).resize(domList[domIndex]->j_index.numElements()); 
     207      infoIndex_.at(indexMap_[idx]+1) = domList[domIndex]->j_index; 
    203208 
    204209      // On the i axis 
     
    213218      dataIndex_.at(indexMap_[idx]).resize(domList[domIndex]->data_i_index.numElements()); 
    214219      dataIndex_.at(indexMap_[idx]) = domList[domIndex]->data_i_index; 
     220      infoIndex_.at(indexMap_[idx]).resize(domList[domIndex]->i_index.numElements()); 
     221      infoIndex_.at(indexMap_[idx]) = domList[domIndex]->i_index; 
    215222 
    216223      dataNIndex_.at(idx) = domList[domIndex]->data_i_index.numElements(); 
     
    233240      dataIndex_.at(indexMap_[idx]).resize(axisList[axisIndex]->data_index.numElements()); 
    234241      dataIndex_.at(indexMap_[idx]) = axisList[axisIndex]->data_index; 
     242      infoIndex_.at(indexMap_[idx]).resize(axisList[axisIndex]->index.numElements()); 
     243      infoIndex_.at(indexMap_[idx]) = axisList[axisIndex]->index; 
    235244      dataNIndex_.at(idx) = axisList[axisIndex]->data_index.numElements(); 
    236245      dataDims_.at(idx) = 1; 
     
    326335  size_t ssize = 1, idx = 0; 
    327336  for (int i = 0; i < this->dims_; ++i) 
    328     ssize *= nLocal_[i]; 
     337  ssize *= nLocal_[i]; 
    329338 
    330339  this->globalIndex_.resize(ssize); 
    331   std::vector<int> idxLoop(this->dims_,0); 
    332   int innnerLoopSize = nLocal_[0]; 
     340  std::vector<int> idxLoop(this->numElement_,0); 
     341  int innnerLoopSize = infoIndex_[0].numElements(); 
    333342  while (idx < ssize) 
    334343  { 
    335     for (int i = 0; i < this->dims_; ++i) 
    336     { 
    337       if (idxLoop[i] == nLocal_[i]) 
     344    for (int i = 0; i < this->numElement_; ++i) 
     345    { 
     346      if (idxLoop[i] == infoIndex_[indexMap_[i]].numElements()) 
    338347      { 
    339348        idxLoop[i] = 0; 
     
    344353    for (int i = 0; i < innnerLoopSize; ++i) 
    345354    { 
    346       size_t globalIndex = idxLoop[0] + nBeginGlobal_[0]; 
     355      size_t globalIndex = infoIndex_[0](idxLoop[0]); 
    347356      size_t mulDim = 1; 
    348       for (int k = 1; k < this->dims_; ++k) 
    349       { 
    350         mulDim *= nGlob_[k-1]; 
    351         globalIndex += (idxLoop[k] + nBeginGlobal_[k])*mulDim; 
    352       } 
     357      for (int idxElement = 0; idxElement < this->numElement_; ++idxElement) 
     358      { 
     359        if (axisDomainOrder_(idxElement)) 
     360        { 
     361          int jb = (0 == idxElement) ? 1 : 0; 
     362          for (int j = jb; j <= 1; ++j) 
     363          { 
     364            mulDim *= nGlob_[indexMap_[idxElement]+j-1]; 
     365            globalIndex += (infoIndex_[indexMap_[idxElement]+j](idxLoop[idxElement]))*mulDim; 
     366          } 
     367        } 
     368        else 
     369        { 
     370          if (0 != idxElement) 
     371          { 
     372            mulDim *= nGlob_[indexMap_[idxElement]-1]; 
     373            globalIndex += (infoIndex_[indexMap_[idxElement]](idxLoop[idxElement]))*mulDim; 
     374          } 
     375        } 
     376      } 
     377 
    353378      this->globalIndex_(idx) = globalIndex; 
    354379      ++idxLoop[0]; 
     
    356381    } 
    357382  } 
     383 
    358384} 
    359385 
     
    429455    } 
    430456 
    431     int maskIndex = currentIndex[0]; 
    432     for (int j = 0; j < this->dims_; ++j) 
    433  
    434457    // Inner most index 
    435458    idxDomain = idxAxis = 0; 
     
    451474      } 
    452475 
    453       if (gridMask_(gridMaskIndex)) //(gridMask_(currentIndex[0], currentIndex[1], currentIndex[2])) 
     476      if (gridMask_(gridMaskIndex)) 
    454477      { 
    455478        ++indexLocalDataOnClientCount; 
    456479        bool isIndexOnServer = true; 
    457         for (int j = 0; j < this->dims_; ++j) 
    458           isIndexOnServer = isIndexOnServer && ((currentIndex[j]+nBeginGlobal_[j]) <= nZoomEnd_[j]) 
    459                                             && (nZoomBegin_[j] <= (currentIndex[j]+nBeginGlobal_[j])); 
     480 
     481        for (int idxElement = 0; idxElement < this->numElement_; ++idxElement) 
     482        { 
     483          int actualIdx = 0; 
     484          if (axisDomainOrder_(idxElement)) 
     485          { 
     486            actualIdx = currentIndex[indexMap_[idxElement]]+currentIndex[indexMap_[idxElement]+1]*nLocal_[indexMap_[idxElement]]; 
     487            isIndexOnServer = isIndexOnServer && ((infoIndex_[indexMap_[idxElement]](actualIdx)) <= nZoomEnd_[indexMap_[idxElement]]) 
     488                                              && (nZoomBegin_[indexMap_[idxElement]] <= (infoIndex_[indexMap_[idxElement]](actualIdx))) 
     489                                              && ((infoIndex_[indexMap_[idxElement]+1](actualIdx)) <= nZoomEnd_[indexMap_[idxElement]+1]) 
     490                                              && (nZoomBegin_[indexMap_[idxElement]+1] <= (infoIndex_[indexMap_[idxElement]+1](actualIdx))); 
     491          } 
     492          else 
     493          { 
     494            isIndexOnServer = isIndexOnServer && ((infoIndex_[indexMap_[idxElement]](currentIndex[indexMap_[idxElement]])) <= nZoomEnd_[indexMap_[idxElement]]) 
     495                                              && (nZoomBegin_[indexMap_[idxElement]] <= (infoIndex_[indexMap_[idxElement]](currentIndex[indexMap_[idxElement]]))); 
     496          } 
     497        } 
    460498        if (isIndexOnServer) ++indexSend2ServerCount; 
    461499      } 
     
    571609      { 
    572610        localDataIndex_[indexLocalDataOnClientCount] = countLocalData; 
    573  
    574611        bool isIndexOnServer = true; 
    575         for (int j = 0; j < this->dims_; ++j) 
    576           isIndexOnServer = isIndexOnServer && 
    577                             ((currentIndex[j]+nBeginGlobal_[j]) <= nZoomEnd_[j]) && 
    578                             (nZoomBegin_[j] <= (currentIndex[j]+nBeginGlobal_[j])); 
     612        for (int idxElement = 0; idxElement < this->numElement_; ++idxElement) 
     613        { 
     614          int actualIdx = 0; 
     615          if (axisDomainOrder_(idxElement)) 
     616          { 
     617            actualIdx = currentIndex[indexMap_[idxElement]]+currentIndex[indexMap_[idxElement]+1]*nLocal_[indexMap_[idxElement]]; 
     618            isIndexOnServer = isIndexOnServer && ((infoIndex_[indexMap_[idxElement]](actualIdx)) <= nZoomEnd_[indexMap_[idxElement]]) 
     619                                              && (nZoomBegin_[indexMap_[idxElement]] <= (infoIndex_[indexMap_[idxElement]](actualIdx))) 
     620                                              && ((infoIndex_[indexMap_[idxElement]+1](actualIdx)) <= nZoomEnd_[indexMap_[idxElement]+1]) 
     621                                              && (nZoomBegin_[indexMap_[idxElement]+1] <= (infoIndex_[indexMap_[idxElement]+1](actualIdx))); 
     622          } 
     623          else 
     624          { 
     625            isIndexOnServer = isIndexOnServer && ((infoIndex_[indexMap_[idxElement]](currentIndex[indexMap_[idxElement]])) <= nZoomEnd_[indexMap_[idxElement]]) 
     626                                              && (nZoomBegin_[indexMap_[idxElement]] <= (infoIndex_[indexMap_[idxElement]](currentIndex[indexMap_[idxElement]]))); 
     627          } 
     628        } 
     629 
    579630        if (isIndexOnServer) 
    580631        { 
    581           size_t globalIndex = currentIndex[0] + nBeginGlobal_[0]; 
     632          int actualIdx = (axisDomainOrder_(0)) ? currentIndex[0]+currentIndex[1]*nLocal_[0] 
     633                                                : currentIndex[0]; 
     634          size_t globalIndex = infoIndex_[0](actualIdx); //idxLoop[0] + nBeginGlobal_[0]; 
    582635          size_t mulDim = 1; 
    583           for (int k = 1; k < this->dims_; ++k) 
     636          for (int idxElement = 0; idxElement < this->numElement_; ++idxElement) 
    584637          { 
    585             mulDim *= nGlob_[k-1]; 
    586             globalIndex += (currentIndex[k] + nBeginGlobal_[k])*mulDim; 
     638            if (axisDomainOrder_(idxElement)) 
     639            { 
     640              actualIdx = currentIndex[indexMap_[idxElement]]+currentIndex[indexMap_[idxElement]+1]*nLocal_[indexMap_[idxElement]]; 
     641              int jb = (0 == idxElement) ? 1 : 0; 
     642              for (int j = jb; j <= 1; ++j) 
     643              { 
     644                mulDim *= nGlob_[indexMap_[idxElement]+j-1]; 
     645                globalIndex += (infoIndex_[indexMap_[idxElement]+j](actualIdx))*mulDim; 
     646              } 
     647            } 
     648            else 
     649            { 
     650              if (0 != idxElement) 
     651              { 
     652                mulDim *= nGlob_[indexMap_[idxElement]-1]; 
     653                globalIndex += (infoIndex_[indexMap_[idxElement]](currentIndex[indexMap_[idxElement]]))*mulDim; 
     654              } 
     655            } 
    587656          } 
    588657          globalDataSendToServer_[indexSend2ServerCount] = globalIndex; 
  • XIOS/trunk/src/distribution_client.hpp

    r676 r818  
    9797    std::vector<int> dataBegin_; //!< Data begin (data_ibegin, data_jbegin, etc) 
    9898    std::vector<CArray<int,1> > dataIndex_; //!< Data index 
     99    std::vector<CArray<int,1> > infoIndex_; //!< i_index, j_index 
    99100 
    100101    std::vector<CArray<bool,1> > domainMasks_; //!< Domain mask 
Note: See TracChangeset for help on using the changeset viewer.