Ignore:
Timestamp:
07/07/15 10:46:25 (9 years ago)
Author:
mhnguyen
Message:

Implementing interpolation (polynomial) and correct some bugs

+) Implement interpolation (polynomial)
+) Correct some minor bugs relating to memory allocation
+) Clear some redundant codes

Test
+) On Curie
+) test_client and test_complete pass

File:
1 edited

Legend:

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

    r624 r630  
    3838} 
    3939 
     40CTransformationMapping::CTransformationMapping(CAxis* destination, CAxis* source) 
     41  : gridSource_(0), gridDestination_(0) 
     42{ 
     43  CContext* context = CContext::getCurrent(); 
     44  CContextClient* client=context->client; 
     45  int clientRank = client->clientRank; 
     46 
     47  int niSrc     = source->ni.getValue(); 
     48  int ibeginSrc = source->ibegin.getValue(); 
     49 
     50  boost::unordered_map<size_t,int> globalIndexOfAxisSource; 
     51  for (int idx = 0; idx < niSrc; ++idx) 
     52  { 
     53    globalIndexOfAxisSource[idx+ibeginSrc] = clientRank; 
     54  } 
     55 
     56  gridIndexClientClientMapping_ = new CClientServerMappingDistributed(globalIndexOfAxisSource, 
     57                                                                      client->intraComm, 
     58                                                                      true); 
     59} 
     60 
    4061CTransformationMapping::~CTransformationMapping() 
    4162{ 
     
    4667  Suppose that we have transformations between two grids, which are represented in form of mapping between global indexes of these two grids, 
    4768this function tries to find out which clients a client needs to send and receive these global indexes to accomplish the transformations. 
    48   The grid destination is the grid whose global indexes demande global indexes from the grid source 
     69  The grid destination is the grid whose global indexes demande global indexes from the other grid 
    4970  Grid destination and grid source are also distributed among clients but in different manners. 
    50   \param [in] globaIndexMapFromDestToSource mapping representing the transformations 
     71  \param [in] globaIndexWeightFromDestToSource mapping representing the transformations 
    5172*/ 
    52 void CTransformationMapping::computeTransformationMapping(const std::map<size_t, std::set<size_t> >& globaIndexMapFromDestToSource) 
     73void CTransformationMapping::computeTransformationMapping(const std::map<size_t, std::vector<std::pair<size_t,double> > >& globaIndexWeightFromDestToSource) 
    5374{ 
    5475  CContext* context = CContext::getCurrent(); 
    5576  CContextClient* client=context->client; 
    5677 
    57   int numMappingPoints = 0; 
    58   std::map<size_t, std::set<size_t> >::const_iterator itbMap = globaIndexMapFromDestToSource.begin(), itMap, 
    59                                                       iteMap = globaIndexMapFromDestToSource.end(); 
     78  std::map<size_t, std::vector<std::pair<size_t,double> > >::const_iterator itbMap = globaIndexWeightFromDestToSource.begin(), itMap, 
     79                                                                            iteMap = globaIndexWeightFromDestToSource.end(); 
     80 
     81  // Not only one index on grid destination can demande two indexes from grid source 
     82  // but an index on grid source has to be sent to two indexes of grid destination 
     83  std::map<size_t, std::vector<std::pair<size_t,double> > > globalIndexMapFromSrcToDest; 
     84  std::vector<std::pair<size_t,double> >::const_iterator itbVecPair, itVecPair, iteVecPair; 
    6085  for (itMap = itbMap; itMap != iteMap; ++itMap) 
    6186  { 
    62     numMappingPoints += (itMap->second).size(); 
     87    itbVecPair = (itMap->second).begin(); 
     88    iteVecPair = (itMap->second).end(); 
     89    for (itVecPair = itbVecPair; itVecPair != iteVecPair; ++itVecPair) 
     90    { 
     91      globalIndexMapFromSrcToDest[itVecPair->first].push_back(std::make_pair(itMap->first, itVecPair->second)); 
     92    } 
    6393  } 
    6494 
    6595  // All global indexes of a client on grid destination 
    66   CArray<size_t,1> globalIndexMap(numMappingPoints); 
    67   // Not only one index on grid destination can demande two indexes from grid source 
    68   // but an index on grid destination have to be sent to two indexes of grid destination 
    69   std::map<size_t, std::vector<size_t> > globalIndexMapFromSrcToDest; 
    70   std::set<size_t>::const_iterator itbSet, itSet, iteSet; 
     96  CArray<size_t,1> globalIndexMap(globalIndexMapFromSrcToDest.size()); 
     97  itbMap = globalIndexMapFromSrcToDest.begin(); 
     98  iteMap = globalIndexMapFromSrcToDest.end(); 
    7199  int idx = 0; 
    72100  for (itMap = itbMap; itMap != iteMap; ++itMap) 
    73101  { 
    74     itbSet = (itMap->second).begin(); 
    75     iteSet = (itMap->second).end(); 
    76     for (itSet = itbSet; itSet != iteSet; ++itSet) 
    77     { 
    78       globalIndexMap(idx) = *itSet; 
    79       globalIndexMapFromSrcToDest[*itSet].push_back(itMap->first); 
    80       ++idx; 
    81     } 
     102    globalIndexMap(idx) = itMap->first; 
     103    ++idx; 
    82104  } 
    83105 
     
    165187  \return global index mapping to receive on grid destination 
    166188*/ 
    167 const std::map<int,std::vector<std::vector<size_t> > >& CTransformationMapping::getGlobalIndexReceivedOnGridDestMapping() const 
     189const std::map<int,std::vector<std::vector<std::pair<size_t,double> > > >& CTransformationMapping::getGlobalIndexReceivedOnGridDestMapping() const 
    168190{ 
    169191  return globalIndexReceivedOnGridDestMapping_; 
Note: See TracChangeset for help on using the changeset viewer.