Changeset 1274


Ignore:
Timestamp:
09/25/17 10:55:12 (3 years ago)
Author:
ymipsl
Message:

Improvement for spatial transformations : when axis or domain overlapping in source grid, transformation eliminate redondant global point, and choose if possible, point owned by current process.

YM

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/XIOS_DEV_CMIP6/src/transformation/generic_algorithm_transformation.cpp

    r1260 r1274  
    353353  \param [in] srcRank rank of client from which we demand global index of element source 
    354354  \param [in] src2DstMap mapping of global index of element source and global index of element destination 
    355   \param[in] gridSrc Grid source 
    356   \param[in] gridDst Grid destination 
    357   \param[in] globalElementIndexOnProc Global index of element source on different client rank 
    358   \param[out] globaIndexWeightFromSrcToDst Mapping of global index of grid source and grid destination 
     355  \param [in] gridSrc Grid source 
     356  \param [in] gridDst Grid destination 
     357  \param [in] globalElementIndexOnProc Global index of element source on different client rank 
     358  \param [out] globaIndexWeightFromSrcToDst Mapping of global index of grid source and grid destination 
    359359*/ 
    360360void CGenericAlgorithmTransformation::computeGlobalGridIndexMapping(int elementPositionInGrid, 
     
    366366                                                                   SourceDestinationIndexMap& globaIndexWeightFromSrcToDst) 
    367367{ 
     368  SourceDestinationIndexMap globaIndexWeightFromSrcToDst_tmp ; 
     369   
     370  CContext* context = CContext::getCurrent(); 
     371  CContextClient* client=context->client; 
     372  int clientRank = client->clientRank; 
     373   
    368374  std::vector<CDomain*> domainListSrcP = gridSrc->getDomains(); 
    369375  std::vector<CAxis*> axisListSrcP = gridSrc->getAxis(); 
     
    406412  size_t globalDstSize = 1; 
    407413  domainIndex = axisIndex = scalarIndex = 0; 
     414  set<size_t>  globalSrcStoreIndex ; 
     415   
    408416  for (int idx = 0; idx < nbElement; ++idx) 
    409417  { 
     
    429437  } 
    430438 
     439  std::map< std::pair<size_t,size_t>, int > rankMap ; 
     440  std::map< std::pair<size_t,size_t>, int >:: iterator rankMapIt ; 
     441   
    431442  for (int i = 0; i < srcRank.size(); ++i) 
    432443  { 
     
    488499        for (int k = 0; k < globalElementDstIndexSize; ++k) 
    489500        { 
    490           globaIndexWeightFromSrcToDst[rankSrc][globalSrcIndex].push_back(make_pair(globalDstVecIndex[k],src2DstMap[currentIndexSrc[elementPositionInGrid]][k].second )); 
     501           
     502          globaIndexWeightFromSrcToDst_tmp[rankSrc][globalSrcIndex].push_back(make_pair(globalDstVecIndex[k],src2DstMap[currentIndexSrc[elementPositionInGrid]][k].second )); 
     503          rankMapIt=rankMap.find(make_pair(globalSrcIndex,globalDstVecIndex[k])) ; 
     504          if (rankMapIt==rankMap.end()) rankMap[make_pair(globalSrcIndex,globalDstVecIndex[k])] = rankSrc ; 
     505          else if (rankSrc==clientRank) rankMapIt->second = rankSrc ; 
    491506        } 
    492507        ++idxLoop[0]; 
     
    495510    } 
    496511  } 
     512 
     513  // eliminate redondant global src point owned by differrent processes. 
     514  // Avoid as possible to tranfer data from an other process if the src point is also owned by current process  
     515 
     516   int rankSrc ; 
     517   size_t globalSrcIndex ; 
     518   size_t globalDstIndex ; 
     519   double weight ; 
     520  
     521   SourceDestinationIndexMap::iterator rankIt,rankIte ; 
     522   boost::unordered_map<size_t, std::vector<std::pair<size_t,double> > >::iterator globalSrcIndexIt, globalSrcIndexIte ; 
     523   std::vector<std::pair<size_t,double> >::iterator vectIt,vectIte ; 
     524    
     525   rankIt=globaIndexWeightFromSrcToDst_tmp.begin() ; rankIte=globaIndexWeightFromSrcToDst_tmp.end() ; 
     526   for(;rankIt!=rankIte;++rankIt) 
     527   { 
     528     rankSrc = rankIt->first ; 
     529     globalSrcIndexIt = rankIt->second.begin() ; globalSrcIndexIte = rankIte->second.end() ; 
     530     for(;globalSrcIndexIt!=globalSrcIndexIte;++globalSrcIndexIt) 
     531     { 
     532       globalSrcIndex = globalSrcIndexIt->first ; 
     533       vectIt = globalSrcIndexIt->second.begin() ; vectIte = globalSrcIndexIt->second.end() ; 
     534       for(vectIt; vectIt!=vectIte; vectIt++) 
     535       { 
     536         globalDstIndex = vectIt->first ; 
     537         weight = vectIt->second ; 
     538         if (rankMap[make_pair(globalSrcIndex,globalDstIndex)] == rankSrc)   
     539           globaIndexWeightFromSrcToDst[rankSrc][globalSrcIndex].push_back(make_pair(globalDstIndex,weight)) ; 
     540       } 
     541     } 
     542   } 
     543 
     544 
    497545} 
    498546 
Note: See TracChangeset for help on using the changeset viewer.