Ignore:
Timestamp:
05/23/17 16:32:26 (7 years ago)
Author:
mhnguyen
Message:

Cleaning up some redundant codes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/dev_olga/src/node/axis.cpp

    r1143 r1144  
    5858 
    5959   ///--------------------------------------------------------------- 
    60  
    61    const std::set<StdString> & CAxis::getRelFiles(void) const 
    62    { 
    63       return (this->relFiles); 
    64    } 
    65  
    6660   bool CAxis::IsWritten(const StdString & filename) const 
    6761   { 
     
    10195 
    10296   //---------------------------------------------------------------- 
    103  
    104    const std::vector<int>& CAxis::getIndexesToWrite(void) const 
    105    { 
    106      return indexesToWrite; 
    107    } 
    10897 
    10998   /*! 
     
    207196   } 
    208197 
    209    void CAxis::fillInValues(const CArray<double,1>& values) 
    210    { 
    211      this->value = values; 
    212    } 
    213  
     198   /*! 
     199     Check common attributes of an axis. 
     200     This check should be done in the very beginning of work flow 
     201   */ 
    214202   void CAxis::checkAttributes(void) 
    215203   { 
     
    270258   } 
    271259 
     260   /*! 
     261      Check the validity of data and fill in values if any. 
     262   */ 
    272263   void CAxis::checkData() 
    273264   { 
     
    292283   } 
    293284 
     285   /*! 
     286     Check validity of zoom info and fill in values if any. 
     287   */ 
    294288   void CAxis::checkZoom(void) 
    295289   { 
     
    304298   } 
    305299 
     300   /*! 
     301     Check validity of mask info and fill in values if any. 
     302   */ 
    306303   void CAxis::checkMask() 
    307304   { 
     
    325322   } 
    326323 
    327   void CAxis::checkBounds() 
    328   { 
    329     if (!bounds.isEmpty()) 
    330     { 
    331       if (bounds.extent(0) != 2 || bounds.extent(1) != n) 
    332         ERROR("CAxis::checkAttributes(void)", 
    333               << "The bounds array of the axis [ id = '" << getId() << "' , context = '" << CObjectFactory::GetCurrentContextId() << "' ] must be of dimension 2 x axis size." << std::endl 
    334               << "Axis size is " << n.getValue() << "." << std::endl 
    335               << "Bounds size is "<< bounds.extent(0) << " x " << bounds.extent(1) << "."); 
    336       hasBounds_ = true; 
    337     } 
    338     else hasBounds_ = false; 
    339   } 
    340  
    341   void CAxis::checkEligibilityForCompressedOutput() 
    342   { 
    343     // We don't check if the mask is valid here, just if a mask has been defined at this point. 
    344     isCompressible_ = !mask.isEmpty(); 
    345   } 
    346  
    347   bool CAxis::dispatchEvent(CEventServer& event) 
     324   /*! 
     325     Check validity of bounds info and fill in values if any. 
     326   */ 
     327   void CAxis::checkBounds() 
     328   { 
     329     if (!bounds.isEmpty()) 
     330     { 
     331       if (bounds.extent(0) != 2 || bounds.extent(1) != n) 
     332         ERROR("CAxis::checkAttributes(void)", 
     333               << "The bounds array of the axis [ id = '" << getId() << "' , context = '" << CObjectFactory::GetCurrentContextId() << "' ] must be of dimension 2 x axis size." << std::endl 
     334               << "Axis size is " << n.getValue() << "." << std::endl 
     335               << "Bounds size is "<< bounds.extent(0) << " x " << bounds.extent(1) << "."); 
     336       hasBounds_ = true; 
     337     } 
     338     else hasBounds_ = false; 
     339   } 
     340 
     341   void CAxis::checkEligibilityForCompressedOutput() 
     342   { 
     343     // We don't check if the mask is valid here, just if a mask has been defined at this point. 
     344     isCompressible_ = !mask.isEmpty(); 
     345   } 
     346 
     347   bool CAxis::dispatchEvent(CEventServer& event) 
    348348   { 
    349349      if (SuperClass::dispatchEvent(event)) return true; 
     
    356356             return true; 
    357357             break; 
    358           //  case EVENT_ID_INDEX: 
    359           //   recvIndex(event); 
    360           //   return true; 
    361           //   break; 
    362358          case EVENT_ID_NON_DISTRIBUTED_ATTRIBUTES: 
    363359            recvNonDistributedAttributes(event); 
     
    376372   } 
    377373 
     374   /*! 
     375     Check attributes on client side (This name is still adequate???) 
     376   */ 
    378377   void CAxis::checkAttributesOnClient() 
    379378   { 
     
    385384   } 
    386385 
     386   /* 
     387     The (spatial) transformation sometimes can change attributes of an axis. Therefore, we should recheck them. 
     388   */ 
    387389   void CAxis::checkAttributesOnClientAfterTransformation(const std::vector<int>& globalDim, int orderPositionInGrid, 
    388390                                                          CServerDistributionDescription::ServerDistributionType distType) 
     
    413415   } 
    414416 
     417  /*! 
     418    Send attributes from one client to other clients 
     419    \param[in] globalDim global dimension of grid which contains this axis 
     420    \param[in] order 
     421  */ 
    415422  void CAxis::sendAttributes(const std::vector<int>& globalDim, int orderPositionInGrid, 
    416423                             CServerDistributionDescription::ServerDistributionType distType) 
     
    561568      indSrv_.swap(globalIndexAxisOnServer); 
    562569 
    563       // CClientServerMapping::GlobalIndexMap::const_iterator it = globalIndexAxisOnServer.begin(), 
    564       //                                                      ite = globalIndexAxisOnServer.end(); 
    565570      CClientServerMapping::GlobalIndexMap::const_iterator it = indSrv_.begin(), 
    566571                                                           ite = indSrv_.end(); 
    567       // std::vector<size_t>::const_iterator itbVec = (globalAxisZoom).begin(), 
    568       //                                     iteVec = (globalAxisZoom).end(); 
    569       // indSrv_.clear(); 
    570       // indWrittenSrv_.clear(); 
    571       // for (; it != ite; ++it) 
    572       // { 
    573       //   int rank = it->first; 
    574       //   const std::vector<size_t>& globalIndexTmp = it->second; 
    575       //   int nb = globalIndexTmp.size(); 
    576  
    577       //   for (int i = 0; i < nb; ++i) 
    578       //   { 
    579       //     if (std::binary_search(itbVec, iteVec, globalIndexTmp[i])) 
    580       //     { 
    581       //       indSrv_[rank].push_back(globalIndexTmp[i]); 
    582       //     } 
    583  
    584       //     if (writtenInd.count(globalIndexTmp[i])) 
    585       //     { 
    586       //       indWrittenSrv_[rank].push_back(globalIndexTmp[i]); 
    587       //     } 
    588       //   } 
    589       // } 
    590572 
    591573      connectedServerRank_.clear(); 
     
    594576      } 
    595577 
    596       // if (!indSrv_.empty()) 
    597       // { 
    598       //   std::map<int, vector<size_t> >::const_iterator itIndSrv  = indSrv_.begin(), 
    599       //                                                  iteIndSrv = indSrv_.end(); 
    600       //   connectedServerRank_.clear(); 
    601       //   for (; itIndSrv != iteIndSrv; ++itIndSrv) 
    602       //     connectedServerRank_.push_back(itIndSrv->first); 
    603       // } 
    604578      nbConnectedClients_ = CClientServerMapping::computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerRank_); 
    605579    } 
     
    750724    } 
    751725  } 
    752  
    753   // void CAxis::computeConnectedServer(const std::vector<int>& globalDim, int orderPositionInGrid, 
    754   //                                    CServerDistributionDescription::ServerDistributionType distType) 
    755   // { 
    756   //   CContext* context = CContext::getCurrent(); 
    757   //   CContextClient* client = (0 != context->clientPrimServer) ? context->clientPrimServer : context->client; 
    758   //   int nbServer = client->serverSize; 
    759   //   int range, clientSize = client->clientSize; 
    760   //   int rank = client->clientRank; 
    761  
    762   //   size_t ni = this->n.getValue(); 
    763   //   size_t ibegin = this->begin.getValue(); 
    764   //   size_t zoom_end = global_zoom_begin+global_zoom_n-1; 
    765   //   size_t nZoomCount = 0; 
    766   //   size_t nbIndex = index.numElements(); 
    767   //   for (size_t idx = 0; idx < nbIndex; ++idx) 
    768   //   { 
    769   //     size_t globalIndex = index(idx); 
    770   //     if (globalIndex >= global_zoom_begin && globalIndex <= zoom_end) ++nZoomCount; 
    771   //   } 
    772  
    773   //   CArray<size_t,1> globalIndexAxis(nbIndex); 
    774   //   std::vector<size_t> globalAxisZoom(nZoomCount); 
    775   //   nZoomCount = 0; 
    776   //   for (size_t idx = 0; idx < nbIndex; ++idx) 
    777   //   { 
    778   //     size_t globalIndex = index(idx); 
    779   //     globalIndexAxis(idx) = globalIndex; 
    780   //     if (globalIndex >= global_zoom_begin && globalIndex <= zoom_end) 
    781   //     { 
    782   //       globalAxisZoom[nZoomCount] = globalIndex; 
    783   //       ++nZoomCount; 
    784   //     } 
    785   //   } 
    786  
    787   //   std::set<int> writtenInd; 
    788   //   if (isCompressible_) 
    789   //   { 
    790   //     for (int idx = 0; idx < data_index.numElements(); ++idx) 
    791   //     { 
    792   //       int ind = CDistributionClient::getAxisIndex(data_index(idx), data_begin, ni); 
    793  
    794   //       if (ind >= 0 && ind < ni && mask(ind)) 
    795   //       { 
    796   //         ind += ibegin; 
    797   //         if (ind >= global_zoom_begin && ind <= zoom_end) 
    798   //           writtenInd.insert(ind); 
    799   //       } 
    800   //     } 
    801   //   } 
    802  
    803   //   CServerDistributionDescription serverDescriptionGlobal(globalDim, nbServer); 
    804   //   int distributedDimensionOnServer = serverDescriptionGlobal.getDimensionDistributed(); 
    805   //   CClientServerMapping::GlobalIndexMap globalIndexAxisOnServer; 
    806   //   if (distributedDimensionOnServer == orderPositionInGrid) // So we have distributed axis on client side and also on server side* 
    807   //   { 
    808   //     std::vector<int> nGlobAxis(1); 
    809   //     nGlobAxis[0] = n_glo.getValue(); 
    810  
    811   //     size_t globalSizeIndex = 1, indexBegin, indexEnd; 
    812   //     for (int i = 0; i < nGlobAxis.size(); ++i) globalSizeIndex *= nGlobAxis[i]; 
    813   //     indexBegin = 0; 
    814   //     if (globalSizeIndex <= clientSize) 
    815   //     { 
    816   //       indexBegin = rank%globalSizeIndex; 
    817   //       indexEnd = indexBegin; 
    818   //     } 
    819   //     else 
    820   //     { 
    821   //       for (int i = 0; i < clientSize; ++i) 
    822   //       { 
    823   //         range = globalSizeIndex / clientSize; 
    824   //         if (i < (globalSizeIndex%clientSize)) ++range; 
    825   //         if (i == client->clientRank) break; 
    826   //         indexBegin += range; 
    827   //       } 
    828   //       indexEnd = indexBegin + range - 1; 
    829   //     } 
    830  
    831   //     CServerDistributionDescription serverDescription(nGlobAxis, nbServer); 
    832   //     serverDescription.computeServerGlobalIndexInRange(std::make_pair<size_t,size_t>(indexBegin, indexEnd)); 
    833   //     CClientServerMapping* clientServerMap = new CClientServerMappingDistributed(serverDescription.getGlobalIndexRange(), client->intraComm); 
    834   //     clientServerMap->computeServerIndexMapping(globalIndexAxis); 
    835   //     globalIndexAxisOnServer = clientServerMap->getGlobalIndexOnServer(); 
    836   //     delete clientServerMap; 
    837   //   } 
    838   //   else 
    839   //   { 
    840   //     std::vector<size_t> globalIndexServer(n_glo.getValue()); 
    841   //     for (size_t idx = 0; idx < n_glo.getValue(); ++idx) 
    842   //     { 
    843   //       globalIndexServer[idx] = idx; 
    844   //     } 
    845  
    846   //     for (int idx = 0; idx < nbServer; ++idx) 
    847   //     { 
    848   //       globalIndexAxisOnServer[idx] = globalIndexServer; 
    849   //     } 
    850   //   } 
    851  
    852   //   CClientServerMapping::GlobalIndexMap::const_iterator it = globalIndexAxisOnServer.begin(), 
    853   //                                                        ite = globalIndexAxisOnServer.end(); 
    854   //   std::vector<size_t>::const_iterator itbVec = (globalAxisZoom).begin(), 
    855   //                                       iteVec = (globalAxisZoom).end(); 
    856   //   indSrv_.clear(); 
    857   //   indWrittenSrv_.clear(); 
    858   //   for (; it != ite; ++it) 
    859   //   { 
    860   //     int rank = it->first; 
    861   //     const std::vector<size_t>& globalIndexTmp = it->second; 
    862   //     int nb = globalIndexTmp.size(); 
    863  
    864   //     for (int i = 0; i < nb; ++i) 
    865   //     { 
    866   //       if (std::binary_search(itbVec, iteVec, globalIndexTmp[i])) 
    867   //       { 
    868   //         indSrv_[rank].push_back(globalIndexTmp[i]); 
    869   //       } 
    870  
    871   //       if (writtenInd.count(globalIndexTmp[i])) 
    872   //       { 
    873   //         indWrittenSrv_[rank].push_back(globalIndexTmp[i]); 
    874   //       } 
    875   //     } 
    876   //   } 
    877  
    878   //   connectedServerRank_.clear(); 
    879   //   for (it = globalIndexAxisOnServer.begin(); it != ite; ++it) { 
    880   //     connectedServerRank_.push_back(it->first); 
    881   //   } 
    882  
    883   //   if (!indSrv_.empty()) 
    884   //   { 
    885   //     std::map<int, vector<size_t> >::const_iterator itIndSrv  = indSrv_.begin(), 
    886   //                                                    iteIndSrv = indSrv_.end(); 
    887   //     connectedServerRank_.clear(); 
    888   //     for (; itIndSrv != iteIndSrv; ++itIndSrv) 
    889   //       connectedServerRank_.push_back(itIndSrv->first); 
    890   //   } 
    891   //   nbConnectedClients_ = CClientServerMapping::computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, connectedServerRank_); 
    892   // } 
    893726 
    894727  void CAxis::sendNonDistributedAttributes() 
Note: See TracChangeset for help on using the changeset viewer.