Changeset 630 for XIOS/trunk/src/transformation/transformation_mapping.cpp
- Timestamp:
- 07/07/15 10:46:25 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/src/transformation/transformation_mapping.cpp
r624 r630 38 38 } 39 39 40 CTransformationMapping::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 40 61 CTransformationMapping::~CTransformationMapping() 41 62 { … … 46 67 Suppose that we have transformations between two grids, which are represented in form of mapping between global indexes of these two grids, 47 68 this 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 source69 The grid destination is the grid whose global indexes demande global indexes from the other grid 49 70 Grid destination and grid source are also distributed among clients but in different manners. 50 \param [in] globaIndex MapFromDestToSource mapping representing the transformations71 \param [in] globaIndexWeightFromDestToSource mapping representing the transformations 51 72 */ 52 void CTransformationMapping::computeTransformationMapping(const std::map<size_t, std:: set<size_t> >& globaIndexMapFromDestToSource)73 void CTransformationMapping::computeTransformationMapping(const std::map<size_t, std::vector<std::pair<size_t,double> > >& globaIndexWeightFromDestToSource) 53 74 { 54 75 CContext* context = CContext::getCurrent(); 55 76 CContextClient* client=context->client; 56 77 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; 60 85 for (itMap = itbMap; itMap != iteMap; ++itMap) 61 86 { 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 } 63 93 } 64 94 65 95 // 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(); 71 99 int idx = 0; 72 100 for (itMap = itbMap; itMap != iteMap; ++itMap) 73 101 { 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; 82 104 } 83 105 … … 165 187 \return global index mapping to receive on grid destination 166 188 */ 167 const std::map<int,std::vector<std::vector<s ize_t> > >& CTransformationMapping::getGlobalIndexReceivedOnGridDestMapping() const189 const std::map<int,std::vector<std::vector<std::pair<size_t,double> > > >& CTransformationMapping::getGlobalIndexReceivedOnGridDestMapping() const 168 190 { 169 191 return globalIndexReceivedOnGridDestMapping_;
Note: See TracChangeset
for help on using the changeset viewer.