- Timestamp:
- 09/29/15 14:01:53 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/src/transformation/domain_algorithm_interpolate.cpp
r689 r709 76 76 { 77 77 nVertexSrc = constNVertex; 78 domainSrc_->fillInRectilinearBoundLonLat(boundsLonSrc, boundsLatSrc); 78 79 } 79 80 … … 114 115 } 115 116 117 118 116 119 // Ok, now use mapper to calculate 117 120 int nSrcLocal = domainSrc_->i_index.numElements(); 118 121 int nDstLocal = domainDest_->i_index.numElements(); 122 long int * globalSrc = new long int [nSrcLocal]; 123 long int * globalDst = new long int [nDstLocal]; 124 125 long int globalIndex; 126 int i_ind, j_ind; 127 for (int idx = 0; idx < nSrcLocal; ++idx) 128 { 129 i_ind=domainSrc_->i_index(idx) ; 130 j_ind=domainSrc_->j_index(idx) ; 131 132 globalIndex = i_ind + j_ind * domainSrc_->ni_glo; 133 globalSrc[idx] = globalIndex; 134 } 135 136 for (int idx = 0; idx < nDstLocal; ++idx) 137 { 138 i_ind=domainDest_->i_index(idx) ; 139 j_ind=domainDest_->j_index(idx) ; 140 141 globalIndex = i_ind + j_ind * domainDest_->ni_glo; 142 globalDst[idx] = globalIndex; 143 } 144 145 146 // Calculate weight index 119 147 Mapper mapper(client->intraComm); 120 148 mapper.setVerbosity(PROGRESS) ; 121 mapper.setSourceMesh(boundsLonSrc.dataFirst(), boundsLatSrc.dataFirst(), nVertexSrc, nSrcLocal, &srcPole[0] );122 mapper.setTargetMesh(boundsLonDest.dataFirst(), boundsLatDest.dataFirst(), nVertexDest, nDstLocal, &dstPole[0] );149 mapper.setSourceMesh(boundsLonSrc.dataFirst(), boundsLatSrc.dataFirst(), nVertexSrc, nSrcLocal, &srcPole[0], globalSrc); 150 mapper.setTargetMesh(boundsLonDest.dataFirst(), boundsLatDest.dataFirst(), nVertexDest, nDstLocal, &dstPole[0], globalDst); 123 151 std::vector<double> timings = mapper.computeWeights(orderInterp); 124 152 153 std::map<int,std::vector<std::pair<int,double> > > interpMapValue; 125 154 for (int idx = 0; idx < mapper.nWeights; ++idx) 126 155 { 127 transformationMapping_[mapper.targetWeightId[idx]].push_back(mapper.sourceWeightId[idx]); 128 transformationWeight_[mapper.targetWeightId[idx]].push_back(mapper.remapMatrix[idx]); 129 } 156 interpMapValue[mapper.targetWeightId[idx]].push_back(make_pair(mapper.sourceWeightId[idx],mapper.remapMatrix[idx])); 157 } 158 exchangeRemapInfo(interpMapValue); 159 160 delete [] globalSrc; 161 delete [] globalDst; 130 162 } 131 163 … … 141 173 } 142 174 175 void CDomainAlgorithmInterpolate::readRemapInfo() 176 { 177 CContext* context = CContext::getCurrent(); 178 CContextClient* client=context->client; 179 int clientRank = client->clientRank; 180 181 std::string filename = interpDomain_->file.getValue(); 182 std::map<int,std::vector<std::pair<int,double> > > interpMapValue; 183 readInterpolationInfo(filename, interpMapValue); 184 185 exchangeRemapInfo(interpMapValue); 186 } 187 188 143 189 /*! 144 190 Read remap information from file then distribute it among clients 145 191 */ 146 void CDomainAlgorithmInterpolate:: readRemapInfo()192 void CDomainAlgorithmInterpolate::exchangeRemapInfo(const std::map<int,std::vector<std::pair<int,double> > >& interpMapValue) 147 193 { 148 194 CContext* context = CContext::getCurrent(); 149 195 CContextClient* client=context->client; 150 196 int clientRank = client->clientRank; 151 152 std::string filename = interpDomain_->file.getValue();153 std::map<int,std::vector<std::pair<int,double> > > interpMapValue;154 readInterpolationInfo(filename, interpMapValue);155 197 156 198 boost::unordered_map<size_t,int> globalIndexOfDomainDest; … … 189 231 int* sendBuff = new int[nbClient]; 190 232 int* recvBuff = new int[nbClient]; 191 for (int i = 0; i < nbClient; ++i) sendBuff[i] = 0; 233 for (int i = 0; i < nbClient; ++i) 234 { 235 sendBuff[i] = 0; 236 recvBuff[i] = 0; 237 } 192 238 int sendBuffSize = 0; 193 239 std::map<int, std::vector<size_t> >::const_iterator itbMap = globalIndexInterpSendToClient.begin(), itMap, … … 195 241 for (itMap = itbMap; itMap != iteMap; ++itMap) 196 242 { 243 const std::vector<size_t>& tmp = itMap->second; 197 244 int sizeIndex = 0, mapSize = (itMap->second).size(); 198 245 for (int idx = 0; idx < mapSize; ++idx) 199 246 { 200 sizeIndex += interpMapValue [(itMap->second)[idx]].size();247 sizeIndex += interpMapValue.at((itMap->second)[idx]).size(); 201 248 } 202 249 sendBuff[itMap->first] = sizeIndex; 203 250 sendBuffSize += sizeIndex; 204 251 } 252 205 253 206 254 MPI_Allreduce(sendBuff, recvBuff, nbClient, MPI_INT, MPI_SUM, client->intraComm); … … 211 259 212 260 std::vector<MPI_Request> sendRequest; 213 // Now send index and weight 214 int sendOffSet = 0 ;261 262 int sendOffSet = 0, l = 0; 215 263 for (itMap = itbMap; itMap != iteMap; ++itMap) 216 264 { 265 const std::vector<size_t>& indexToSend = itMap->second; 266 int mapSize = indexToSend.size(); 217 267 int k = 0; 218 int mapSize = (itMap->second).size();219 220 268 for (int idx = 0; idx < mapSize; ++idx) 221 269 { 222 std::vector<std::pair<int,double> >& interpMap = interpMapValue[(itMap->second)[idx]];270 const std::vector<std::pair<int,double> >& interpMap = interpMapValue.at(indexToSend[idx]); 223 271 for (int i = 0; i < interpMap.size(); ++i) 224 272 { 225 sendIndexDestBuff[ k] = (itMap->second)[idx];226 sendIndexSrcBuff[ k] = interpMap[i].first;227 sendWeightBuff[ k] = interpMap[i].second;273 sendIndexDestBuff[l] = indexToSend[idx]; 274 sendIndexSrcBuff[l] = interpMap[i].first; 275 sendWeightBuff[l] = interpMap[i].second; 228 276 ++k; 277 ++l; 229 278 } 230 279 } … … 303 352 304 353 std::vector<MPI_Status> requestStatus(sendRequest.size()); 305 MPI_Wait (&sendRequest[0], &requestStatus[0]);354 MPI_Waitall(sendRequest.size(), &sendRequest[0], MPI_STATUS_IGNORE); 306 355 307 356 delete [] sendIndexDestBuff; … … 322 371 */ 323 372 void CDomainAlgorithmInterpolate::readInterpolationInfo(std::string& filename, 324 373 std::map<int,std::vector<std::pair<int,double> > >& interpMapValue) 325 374 { 326 375 int ncid ;
Note: See TracChangeset
for help on using the changeset viewer.