Ignore:
Timestamp:
06/09/16 11:33:19 (8 years ago)
Author:
mhnguyen
Message:

Various clean up

+) Remove some redundant codes

Test
+) On Curie
+) tests pass

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/transformation/grid_transformation.cpp

    • Property svn:executable set to *
    r862 r867  
    1515#include "context.hpp" 
    1616#include "context_client.hpp" 
    17 #include "transformation_mapping.hpp" 
    1817#include "axis_algorithm_transformation.hpp" 
    1918#include "distribution_client.hpp" 
    2019#include "mpi_tag.hpp" 
     20#include "grid.hpp" 
    2121#include <boost/unordered_map.hpp> 
    2222 
     
    2424CGridTransformation::CGridTransformation(CGrid* destination, CGrid* source) 
    2525: gridSource_(source), gridDestination_(destination), originalGridSource_(source), 
    26   algoTypes_(), nbAlgos_(0), currentGridIndexToOriginalGridIndex_(), tempGrids_(), 
     26  algoTypes_(), nbAlgos_(0), tempGrids_(), 
    2727  auxInputs_(), dynamicalTransformation_(false), timeStamp_() 
    2828 
     
    4545  } 
    4646 
    47   initializeMappingOfOriginalGridSource(); 
     47  initializeTransformations(); 
    4848} 
    4949 
     
    5454for each transformation, we need to make sure that the current "temporary source" maps its global index correctly to the original one. 
    5555*/ 
    56 void CGridTransformation::initializeMappingOfOriginalGridSource() 
     56void CGridTransformation::initializeTransformations() 
    5757{ 
    5858  CContext* context = CContext::getCurrent(); 
     
    9595    { 
    9696      axisPositionInGrid.push_back(i); 
    97 //      axisPositionInGrid.push_back(idx); 
    98 //      ++idx; 
    9997    } 
    10098    else 
    10199    { 
    102100      domPositionInGrid.push_back(i); 
    103 //      ++idx; 
    104 //      domPositionInGrid.push_back(idx); 
    105 //      ++idx; 
    106101    } 
    107102  } 
     
    123118    { 
    124119      initializeAxisAlgorithms(i); 
    125 //      initializeAxisAlgorithms(idx); 
    126 //      ++idx; 
    127120    } 
    128121    else 
    129122    { 
    130123      initializeDomainAlgorithms(i); 
    131 //      ++idx; 
    132 //      initializeDomainAlgorithms(idx); 
    133 //      ++idx; 
    134124    } 
    135125  } 
     
    357347  -) Chose the correct algorithm by transformation type and position of element 
    358348  -) Calculate the mapping of global index between the current grid source and grid destination 
    359   -) Calculate the mapping of global index between current grid DESTINATION and ORIGINAL grid SOURCE 
     349  -) Calculate the mapping of global index between current grid DESTINATION and grid SOURCE 
    360350  -) Make current grid destination become grid source in the next transformation 
    361351*/ 
    362 //void CGridTransformation::computeAll(const std::vector<CArray<double,1>* >& dataAuxInputs, Time timeStamp) 
    363 //{ 
    364 //  if (nbAlgos_ < 1) return; 
    365 //  if (!auxInputs_.empty() && !dynamicalTransformation_) { dynamicalTransformation_ = true; return; } 
    366 //  if (dynamicalTransformation_) 
    367 //  { 
    368 //    if (timeStamp_.insert(timeStamp).second) 
    369 //      DestinationIndexMap().swap(currentGridIndexToOriginalGridIndex_);  // Reset map 
    370 //    else 
    371 //      return; 
    372 //  } 
    373 // 
    374 //  CContext* context = CContext::getCurrent(); 
    375 //  CContextClient* client = context->client; 
    376 // 
    377 //  ListAlgoType::const_iterator itb = listAlgos_.begin(), 
    378 //                               ite = listAlgos_.end(), it; 
    379 // 
    380 //  CGenericAlgorithmTransformation* algo = 0; 
    381 //  int nbAgloTransformation = 0; // Only count for executed transformation. Generate domain is a special one, not executed in the list 
    382 //  for (it = itb; it != ite; ++it) 
    383 //  { 
    384 //    int elementPositionInGrid = it->first; 
    385 //    ETranformationType transType = (it->second).first; 
    386 //    int transformationOrder = (it->second).second; 
    387 //    DestinationIndexMap globaIndexWeightFromDestToSource; 
    388 // 
    389 //    // First of all, select an algorithm 
    390 //    if (!dynamicalTransformation_ || (algoTransformation_.size() < listAlgos_.size())) 
    391 //    { 
    392 //      selectAlgo(elementPositionInGrid, transType, transformationOrder, algoTypes_[std::distance(itb, it)]); 
    393 //      algo = algoTransformation_.back(); 
    394 //    } 
    395 //    else 
    396 //      algo = algoTransformation_[std::distance(itb, it)]; 
    397 // 
    398 //    if (0 != algo) // Only registered transformation can be executed 
    399 //    { 
    400 //      algo->computeIndexSourceMapping(dataAuxInputs); 
    401 // 
    402 //      // Recalculate the distribution of grid destination 
    403 //      CDistributionClient distributionClientDest(client->clientRank, gridDestination_); 
    404 //      const CDistributionClient::GlobalLocalDataMap& globalLocalIndexGridDestSendToServer = distributionClientDest.getGlobalLocalDataSendToServer(); 
    405 // 
    406 //      // ComputeTransformation of global index of each element 
    407 //      std::vector<int> gridDestinationDimensionSize = gridDestination_->getGlobalDimension(); 
    408 //      std::vector<int> gridSrcDimensionSize = gridSource_->getGlobalDimension(); 
    409 //      int elementPosition = it->first; 
    410 //      algo->computeGlobalSourceIndex(elementPosition, 
    411 //                                     gridDestinationDimensionSize, 
    412 //                                     gridSrcDimensionSize, 
    413 //                                     globalLocalIndexGridDestSendToServer, 
    414 //                                     globaIndexWeightFromDestToSource); 
    415 // 
    416 //      // Compute transformation of global indexes among grids 
    417 //      computeTransformationMapping(globaIndexWeightFromDestToSource); 
    418 // 
    419 //      // Update number of local index on each transformation 
    420 //      nbLocalIndexOnGridDest_.push_back(globalLocalIndexGridDestSendToServer.size()); 
    421 // 
    422 //      if (1 < nbAlgos_) 
    423 //      { 
    424 //        // Now grid destination becomes grid source in a new transformation 
    425 //        if (nbAgloTransformation != (nbAlgos_-1)) setUpGrid(elementPositionInGrid, transType, nbAgloTransformation); 
    426 //      } 
    427 //      ++nbAgloTransformation; 
    428 //    } 
    429 //  } 
    430 //} 
    431  
    432352void CGridTransformation::computeAll(const std::vector<CArray<double,1>* >& dataAuxInputs, Time timeStamp) 
    433353{ 
     
    436356  if (dynamicalTransformation_) 
    437357  { 
    438     if (timeStamp_.insert(timeStamp).second) 
    439     { 
    440       DestinationIndexMap().swap(currentGridIndexToOriginalGridIndex_);  // Reset map 
    441       std::list<size_t>().swap(nbLocalIndexOnGridDest_); 
     358    if (timeStamp_.insert(timeStamp).second)   //Reset map 
     359    { 
    442360      std::list<SendingIndexGridSourceMap>().swap(localIndexToSendFromGridSource_); 
    443361      std::list<RecvIndexGridDestinationMap>().swap(localIndexToReceiveOnGridDest_); 
    444     }       
     362      std::list<size_t>().swap(nbLocalIndexOnGridDest_); 
     363    } 
    445364    else 
    446365      return; 
     
    555474  } 
    556475 
    557  
    558  
    559476  // Sending global index of grid source to corresponding process as well as the corresponding mask 
    560477  std::vector<MPI_Request> requests; 
     
    720637} 
    721638 
    722 ///*! 
    723 //  Compute exchange index between grid source and grid destination 
    724 //  \param [in] globalIndexWeightFromDestToSource global index mapping between grid destination and grid source 
    725 //*/ 
    726 //void CGridTransformation::computeTransformationMapping(const DestinationIndexMap& globalIndexWeightFromDestToSource) 
    727 //{ 
    728 //  CContext* context = CContext::getCurrent(); 
    729 //  CContextClient* client = context->client; 
    730 // 
    731 //  CTransformationMapping transformationMap(gridDestination_, gridSource_); 
    732 // 
    733 //  transformationMap.computeTransformationMapping(globalIndexWeightFromDestToSource); 
    734 // 
    735 //  const CTransformationMapping::ReceivedIndexMap& globalIndexToReceive = transformationMap.getGlobalIndexReceivedOnGridDestMapping(); 
    736 //  CTransformationMapping::ReceivedIndexMap::const_iterator itbMapRecv, itMapRecv, iteMapRecv; 
    737 //  itbMapRecv = globalIndexToReceive.begin(); 
    738 //  iteMapRecv = globalIndexToReceive.end(); 
    739 //  localIndexToReceiveOnGridDest_.push_back(RecvIndexGridDestinationMap()); 
    740 //  RecvIndexGridDestinationMap& recvTmp = localIndexToReceiveOnGridDest_.back(); 
    741 //  for (itMapRecv = itbMapRecv; itMapRecv != iteMapRecv; ++itMapRecv) 
    742 //  { 
    743 //    int sourceRank = itMapRecv->first; 
    744 //    int numGlobalIndex = (itMapRecv->second).size(); 
    745 //    recvTmp[sourceRank].resize(numGlobalIndex); 
    746 //    for (int i = 0; i < numGlobalIndex; ++i) 
    747 //    { 
    748 //      recvTmp[sourceRank][i] = make_pair((itMapRecv->second)[i].localIndex,(itMapRecv->second)[i].weight); 
    749 //    } 
    750 //  } 
    751 // 
    752 //  // Find out local index on grid source (to send) 
    753 //  const CTransformationMapping::SentIndexMap& globalIndexToSend = transformationMap.getGlobalIndexSendToGridDestMapping(); 
    754 //  CTransformationMapping::SentIndexMap::const_iterator itbMap, itMap, iteMap; 
    755 //  itbMap = globalIndexToSend.begin(); 
    756 //  iteMap = globalIndexToSend.end(); 
    757 //  localIndexToSendFromGridSource_.push_back(SendingIndexGridSourceMap()); 
    758 //  SendingIndexGridSourceMap& tmpSend = localIndexToSendFromGridSource_.back(); 
    759 //  for (itMap = itbMap; itMap != iteMap; ++itMap) 
    760 //  { 
    761 //    int destRank = itMap->first; 
    762 //    int vecSize = itMap->second.size(); 
    763 //    tmpSend[destRank].resize(vecSize); 
    764 //    for (int idx = 0; idx < vecSize; ++idx) 
    765 //    { 
    766 //      tmpSend[destRank](idx) = itMap->second[idx].first; 
    767 //    } 
    768 //  } 
    769 //} 
    770  
    771639bool CGridTransformation::isSpecialTransformation(ETranformationType transType) 
    772640{ 
Note: See TracChangeset for help on using the changeset viewer.