Changeset 623 for XIOS/trunk/src/filter/grid_transformation.cpp
- Timestamp:
- 06/22/15 13:36:31 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/src/filter/grid_transformation.cpp
r622 r623 1 /*! 2 \file grid_transformation.cpp 3 \author Ha NGUYEN 4 \since 14 May 2015 5 \date 09 June 2015 6 7 \brief Interface for all transformations. 8 */ 1 9 #include "grid_transformation.hpp" 2 #include "axis_ inverse.hpp"3 #include "axis_ zoom.hpp"10 #include "axis_algorithm_inverse.hpp" 11 #include "axis_algorithm_zoom.hpp" 4 12 #include "context.hpp" 5 13 #include "context_client.hpp" … … 35 43 { 36 44 CAxis* axis = CAxis::createAxis(); 37 axis SrcTmp[idx]->duplicateAttributes(axis);45 axis->setAttributes(axisSrcTmp[idx]); 38 46 axisSrc.push_back(axis); 39 47 } … … 42 50 { 43 51 CDomain* domain = CDomain::createDomain(); 44 domain SrcTmp[idx]->duplicateAttributes(domain);52 domain->setAttributes(domainSrcTmp[idx]); 45 53 domainSrc.push_back(domain); 46 54 } … … 168 176 case TRANS_ZOOM_AXIS: 169 177 zoomAxis = dynamic_cast<CZoomAxis*> (it->second); 170 algo = new CAxis Zoom(axisListDestP[axisIndex], axisListSrcP[axisIndex], zoomAxis);178 algo = new CAxisAlgorithmZoom(axisListDestP[axisIndex], axisListSrcP[axisIndex], zoomAxis); 171 179 break; 172 180 case TRANS_INVERSE_AXIS: 173 algo = new CAxis Inverse(axisListDestP[axisIndex], axisListSrcP[axisIndex]);181 algo = new CAxisAlgorithmInverse(axisListDestP[axisIndex], axisListSrcP[axisIndex]); 174 182 break; 175 183 default: … … 196 204 case TRANS_INVERSE_AXIS: 197 205 axisIndex = elementPosition2AxisPositionInGrid_[elementPositionInGrid]; 198 axisList DestP[axisIndex]->duplicateAttributes(axisListSrcP[axisIndex]);206 axisListSrcP[axisIndex]->duplicateAttributes(axisListDestP[axisIndex]); 199 207 break; 200 208 default: … … 226 234 const CArray<size_t,1>& globalIndexGridDestSendToServer = distributionClientDest.getGlobalDataIndexSendToServer(); 227 235 236 std::cout << "global index grid dest send to server " << globalIndexGridDestSendToServer << std::endl; 228 237 // ComputeTransformation of global index of each element 229 238 std::vector<int> gridDestinationDimensionSize = gridDestination_->getGlobalDimension(); … … 241 250 } 242 251 243 std::cout << "global index destination 0 " << *globalIndexOfCurrentGridSource_ << std::endl; 244 std::cout << "global index destination 1 " << *globalIndexOfOriginalGridSource_ << std::endl; 252 std::cout << "global index destination 0 final " << *globalIndexOfCurrentGridSource_ << std::endl; 253 std::cout << "global index destination 1 final " << *globalIndexOfOriginalGridSource_ << std::endl; 254 updateFinalGridDestination(); 245 255 computeFinalTransformationMapping(); 246 256 } … … 248 258 249 259 /*! 250 Compute index mapping representing transformation between two grids 251 Each domain and each axis can contain some information of transformation, these information are then converted into 252 form of global index mapping reprensenting transformation between two grids. 260 After applying the algorithms, there are some informations on grid destination needing change, for now, there are: 261 +) mask 253 262 */ 254 void CGridTransformation::computeTransformation() 255 { 256 // const CArray<size_t,1>& globalIndexGridDestSendToServer = gridDestination_->getDistributionClient()->getGlobalDataIndexSendToServer(); 257 // std::list<std::pair<int,CGenericAlgorithmTransformation*> >::const_iterator itbMap, itMap, iteMap; 258 // itbMap = algoTransformation_.begin(); 259 // iteMap = algoTransformation_.end(); 260 // 261 // std::vector<CGenericAlgorithmTransformation*>::const_iterator itbVec, itVec, iteVec; 262 // 263 // for (itMap = itbMap; itMap != iteMap; ++itMap) 264 // { 265 // int elementPosition = itMap->first; 266 // itbVec = (itMap->second).begin(); 267 // iteVec = (itMap->second).end(); 268 // for (itVec = itbVec; itVec != iteVec; ++itVec) 269 // { 270 // (*itVec)->computeGlobalSourceIndex(elementPosition, 271 // gridDestinationDimensionSize_, 272 // globalIndexGridDestSendToServer, 273 // globaIndexMapFromDestToSource_); 274 // } 275 // } 263 void CGridTransformation::updateFinalGridDestination() 264 { 265 CContext* context = CContext::getCurrent(); 266 CContextClient* client=context->client; 267 268 //First of all, retrieve info of local mask of grid destination 269 CDistributionClient distributionClientDest(client->clientRank, gridDestination_); 270 const CArray<int, 1>& localMaskIndexOnClientDest = distributionClientDest.getLocalMaskIndexOnClient(); 271 std::cout << "local mask " << localMaskIndexOnClientDest << std::endl; 272 273 const CArray<size_t,1>& globalIndexOnClientDest = distributionClientDest.getGlobalDataIndexSendToServer(); 274 std::cout << "global index " << globalIndexOnClientDest << std::endl; 275 CArray<size_t, 1>::const_iterator itbArr, itArr, iteArr; 276 itbArr = globalIndexOnClientDest.begin(); 277 iteArr = globalIndexOnClientDest.end(); 278 279 // Then find out which index became invalid (become masked after being applied the algorithms, or demande some masked points from grid source) 280 int num = globalIndexOfOriginalGridSource_->numElements(); 281 const size_t sfmax = NumTraits<unsigned long>::sfmax(); 282 int maskIndexNum = 0; 283 for (int idx = 0; idx < num; ++idx) 284 { 285 if (sfmax == (*globalIndexOfOriginalGridSource_)(idx)) 286 { 287 size_t maskedGlobalIndex = (*globalIndexOfCurrentGridSource_)(idx); 288 itArr = std::find(itbArr, iteArr, maskedGlobalIndex); 289 if (iteArr != itArr) ++maskIndexNum; 290 } 291 } 292 293 CArray<int,1>* maskIndexToModify = new CArray<int,1>(maskIndexNum); 294 maskIndexNum = 0; 295 for (int idx = 0; idx < num; ++idx) 296 { 297 if (sfmax == (*globalIndexOfOriginalGridSource_)(idx)) 298 { 299 size_t maskedGlobalIndex = (*globalIndexOfCurrentGridSource_)(idx); 300 itArr = std::find(itbArr, iteArr, maskedGlobalIndex); 301 if (iteArr != itArr) 302 { 303 int localIdx = std::distance(itbArr, itArr); 304 (*maskIndexToModify)(maskIndexNum) = (localMaskIndexOnClientDest)(localIdx); 305 ++maskIndexNum; 306 } 307 } 308 } 309 310 std::cout << "index to modify " << *maskIndexToModify << std::endl; 311 gridDestination_->modifyMask(*maskIndexToModify); 312 313 delete maskIndexToModify; 276 314 } 277 315 … … 302 340 for (itSend = itbSend; itSend != iteSend; ++itSend) sendBuffSize += (itSend->second).size(); 303 341 342 std::cout << "global index destination 0 before" << *globalIndexOfCurrentGridSource_ << std::endl; 343 std::cout << "global index destination 1 before" << *globalIndexOfOriginalGridSource_ << std::endl; 344 345 typedef unsigned long Scalar; 304 346 unsigned long* sendBuff, *currentSendBuff; 305 347 if (0 != sendBuffSize) sendBuff = new unsigned long [sendBuffSize]; 348 for (StdSize idx = 0; idx < sendBuffSize; ++idx) sendBuff[idx] = NumTraits<Scalar>::sfmax(); 349 306 350 int currentBuffPosition = 0; 307 351 for (itSend = itbSend; itSend != iteSend; ++itSend) … … 332 376 unsigned long* recvBuff, *currentRecvBuff; 333 377 if (0 != recvBuffSize) recvBuff = new unsigned long [recvBuffSize]; 378 for (StdSize idx = 0; idx < recvBuffSize; ++idx) recvBuff[idx] = NumTraits<Scalar>::sfmax(); 379 334 380 int currentRecvBuffPosition = 0; 335 381 for (itRecv = itbRecv; itRecv != iteRecv; ++itRecv) … … 353 399 } 354 400 355 globalIndexOfCurrentGridSource_->resize(nbCurrentGridSource); 356 globalIndexOfOriginalGridSource_->resize(nbCurrentGridSource); 401 if (globalIndexOfCurrentGridSource_->numElements() != nbCurrentGridSource) 402 { 403 if ((0 != nbCurrentGridSource) && (0 != globalIndexOfCurrentGridSource_)) 404 { 405 delete globalIndexOfCurrentGridSource_; 406 globalIndexOfCurrentGridSource_ = new CArray<size_t,1>(nbCurrentGridSource); 407 } 408 } 409 410 if (globalIndexOfOriginalGridSource_->numElements() != nbCurrentGridSource) 411 { 412 if ((0 != nbCurrentGridSource) && (0 != globalIndexOfOriginalGridSource_)) 413 { 414 delete globalIndexOfOriginalGridSource_; 415 globalIndexOfOriginalGridSource_ = new CArray<size_t,1>(nbCurrentGridSource); 416 } 417 } 418 357 419 int k = 0; 358 420 currentRecvBuff = recvBuff; … … 372 434 } 373 435 436 std::cout << "global index destination 0 after " << *globalIndexOfCurrentGridSource_ << std::endl; 437 std::cout << "global index destination 1 after " << *globalIndexOfOriginalGridSource_ << std::endl; 374 438 if (0 != sendBuffSize) delete [] sendBuff; 375 439 if (0 != recvBuffSize) delete [] recvBuff; … … 391 455 392 456 int nb = globalIndexOfCurrentGridSource_->numElements(); 457 const size_t sfmax = NumTraits<unsigned long>::sfmax(); 393 458 for (int idx = 0; idx < nb; ++idx) 394 459 { 395 globaIndexMapFromDestToSource[(*globalIndexOfCurrentGridSource_)(idx)].insert((*globalIndexOfOriginalGridSource_)(idx)); 460 if (sfmax != (*globalIndexOfOriginalGridSource_)(idx)) 461 globaIndexMapFromDestToSource[(*globalIndexOfCurrentGridSource_)(idx)].insert((*globalIndexOfOriginalGridSource_)(idx)); 396 462 } 397 463 … … 403 469 404 470 CDistributionClient distributionClientDest(client->clientRank, gridDestination_); 405 CDistributionClient distributionClientSrc(client->clientRank, gridSource_); 406 407 CArray<int, 1> localIndexOnClientDest = distributionClientDest.getLocalDataIndexOnClient(); //gridDestination_->getDistributionClient()->getLocalDataIndexOnClient(); 408 CArray<size_t,1> globalIndexOnClientDest = distributionClientDest.getGlobalDataIndexSendToServer(); //gridDestination_->getDistributionClient()->getGlobalDataIndexSendToServer(); 471 CDistributionClient distributionClientSrc(client->clientRank, originalGridSource_); 472 473 // const CArray<int, 1>& localIndexOnClientDest = distributionClientDest.getLocalDataIndexOnClient(); //gridDestination_->getDistributionClient()->getLocalDataIndexOnClient(); 474 const CArray<int, 1>& localIndexOnClientDest = distributionClientDest.getLocalDataIndexSendToServer(); 475 const CArray<size_t,1>& globalIndexOnClientDest = distributionClientDest.getGlobalDataIndexSendToServer(); //gridDestination_->getDistributionClient()->getGlobalDataIndexSendToServer(); 409 476 410 477 std::cout << "dest: local index " << localIndexOnClientDest << std::endl; 411 478 std::cout << "dest: global index " << globalIndexOnClientDest << std::endl; 412 CArray<int, 1>localIndexOnClientSrc = distributionClientSrc.getLocalDataIndexOnClient(); //gridSource_->getDistributionClient()->getLocalDataIndexOnClient();413 CArray<size_t,1>globalIndexOnClientSrc = distributionClientSrc.getGlobalDataIndexSendToServer(); //gridSource_->getDistributionClient()->getGlobalDataIndexSendToServer();479 const CArray<int, 1>& localIndexOnClientSrc = distributionClientSrc.getLocalDataIndexOnClient(); //gridSource_->getDistributionClient()->getLocalDataIndexOnClient(); 480 const CArray<size_t,1>& globalIndexOnClientSrc = distributionClientSrc.getGlobalDataIndexSendToServer(); //gridSource_->getDistributionClient()->getGlobalDataIndexSendToServer(); 414 481 std::cout << "src: local index " << localIndexOnClientSrc << std::endl; 415 482 std::cout << "src: global index " << globalIndexOnClientSrc << std::endl; 416 483 std::vector<size_t>::const_iterator itbVec, itVec, iteVec; 417 CArray<size_t, 1>:: iterator itbArr, itArr, iteArr;484 CArray<size_t, 1>::const_iterator itbArr, itArr, iteArr; 418 485 419 486 std::map<int,std::vector<std::vector<size_t> > >::const_iterator itbMapRecv, itMapRecv, iteMapRecv; … … 439 506 { 440 507 int localIdx = std::distance(itbArr, itArr); 441 //(*localIndexToReceiveOnGridDest_[sourceRank][i])(idx) = localIndexOnClientDest(localIdx); // Local index of un-extracted data (only domain)442 (*localIndexToReceiveOnGridDest_[sourceRank][i])(idx) = (localIdx); // Local index of extracted data508 (*localIndexToReceiveOnGridDest_[sourceRank][i])(idx) = localIndexOnClientDest(localIdx); // Local index of un-extracted data (only domain) 509 // (*localIndexToReceiveOnGridDest_[sourceRank][i])(idx) = (localIdx); // Local index of extracted data 443 510 } 444 511 } 445 512 } 513 // std::cout << "local index to receive from source Rank = " << sourceRank << (*localIndexToReceiveOnGridDest_[sourceRank][i]) << std::endl; 446 514 } 447 515 … … 468 536 } 469 537 } 538 std::cout << "local index to send to dest Rank = " << destRank << (*localIndexToSendFromGridSource_[destRank]) << std::endl; 470 539 } 471 540 }
Note: See TracChangeset
for help on using the changeset viewer.