Changeset 818 for XIOS/trunk/src/distribution_client.cpp
- Timestamp:
- 01/26/16 18:19:14 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/src/distribution_client.cpp
r817 r818 19 19 , isDataDistributed_(true), axisNum_(0), domainNum_(0), nIndexDomain_(), nIndexAxis_() 20 20 , globalDataSendToServer_(), localDataIndexSendToServer_(), localDataIndex_(), localMaskIndex_() 21 , infoIndex_() 21 22 { 22 23 } … … 30 31 , isDataDistributed_(true), axisNum_(0), domainNum_(0), nIndexDomain_(), nIndexAxis_() 31 32 , globalDataSendToServer_(), localDataIndexSendToServer_(), localDataIndex_(), localMaskIndex_() 33 , infoIndex_() 32 34 { 33 35 readDistributionInfo(grid); … … 176 178 // Data_*_index of each dimension 177 179 dataIndex_.resize(this->dims_); 180 infoIndex_.resize(this->dims_); 178 181 179 182 // A trick to determine position of each domain in domainList … … 201 204 dataIndex_.at(indexMap_[idx]+1).resize(domList[domIndex]->data_j_index.numElements()); 202 205 dataIndex_.at(indexMap_[idx]+1) = domList[domIndex]->data_j_index; 206 infoIndex_.at(indexMap_[idx]+1).resize(domList[domIndex]->j_index.numElements()); 207 infoIndex_.at(indexMap_[idx]+1) = domList[domIndex]->j_index; 203 208 204 209 // On the i axis … … 213 218 dataIndex_.at(indexMap_[idx]).resize(domList[domIndex]->data_i_index.numElements()); 214 219 dataIndex_.at(indexMap_[idx]) = domList[domIndex]->data_i_index; 220 infoIndex_.at(indexMap_[idx]).resize(domList[domIndex]->i_index.numElements()); 221 infoIndex_.at(indexMap_[idx]) = domList[domIndex]->i_index; 215 222 216 223 dataNIndex_.at(idx) = domList[domIndex]->data_i_index.numElements(); … … 233 240 dataIndex_.at(indexMap_[idx]).resize(axisList[axisIndex]->data_index.numElements()); 234 241 dataIndex_.at(indexMap_[idx]) = axisList[axisIndex]->data_index; 242 infoIndex_.at(indexMap_[idx]).resize(axisList[axisIndex]->index.numElements()); 243 infoIndex_.at(indexMap_[idx]) = axisList[axisIndex]->index; 235 244 dataNIndex_.at(idx) = axisList[axisIndex]->data_index.numElements(); 236 245 dataDims_.at(idx) = 1; … … 326 335 size_t ssize = 1, idx = 0; 327 336 for (int i = 0; i < this->dims_; ++i) 328 337 ssize *= nLocal_[i]; 329 338 330 339 this->globalIndex_.resize(ssize); 331 std::vector<int> idxLoop(this-> dims_,0);332 int innnerLoopSize = nLocal_[0];340 std::vector<int> idxLoop(this->numElement_,0); 341 int innnerLoopSize = infoIndex_[0].numElements(); 333 342 while (idx < ssize) 334 343 { 335 for (int i = 0; i < this-> dims_; ++i)336 { 337 if (idxLoop[i] == nLocal_[i])344 for (int i = 0; i < this->numElement_; ++i) 345 { 346 if (idxLoop[i] == infoIndex_[indexMap_[i]].numElements()) 338 347 { 339 348 idxLoop[i] = 0; … … 344 353 for (int i = 0; i < innnerLoopSize; ++i) 345 354 { 346 size_t globalIndex = i dxLoop[0] + nBeginGlobal_[0];355 size_t globalIndex = infoIndex_[0](idxLoop[0]); 347 356 size_t mulDim = 1; 348 for (int k = 1; k < this->dims_; ++k) 349 { 350 mulDim *= nGlob_[k-1]; 351 globalIndex += (idxLoop[k] + nBeginGlobal_[k])*mulDim; 352 } 357 for (int idxElement = 0; idxElement < this->numElement_; ++idxElement) 358 { 359 if (axisDomainOrder_(idxElement)) 360 { 361 int jb = (0 == idxElement) ? 1 : 0; 362 for (int j = jb; j <= 1; ++j) 363 { 364 mulDim *= nGlob_[indexMap_[idxElement]+j-1]; 365 globalIndex += (infoIndex_[indexMap_[idxElement]+j](idxLoop[idxElement]))*mulDim; 366 } 367 } 368 else 369 { 370 if (0 != idxElement) 371 { 372 mulDim *= nGlob_[indexMap_[idxElement]-1]; 373 globalIndex += (infoIndex_[indexMap_[idxElement]](idxLoop[idxElement]))*mulDim; 374 } 375 } 376 } 377 353 378 this->globalIndex_(idx) = globalIndex; 354 379 ++idxLoop[0]; … … 356 381 } 357 382 } 383 358 384 } 359 385 … … 429 455 } 430 456 431 int maskIndex = currentIndex[0];432 for (int j = 0; j < this->dims_; ++j)433 434 457 // Inner most index 435 458 idxDomain = idxAxis = 0; … … 451 474 } 452 475 453 if (gridMask_(gridMaskIndex)) //(gridMask_(currentIndex[0], currentIndex[1], currentIndex[2]))476 if (gridMask_(gridMaskIndex)) 454 477 { 455 478 ++indexLocalDataOnClientCount; 456 479 bool isIndexOnServer = true; 457 for (int j = 0; j < this->dims_; ++j) 458 isIndexOnServer = isIndexOnServer && ((currentIndex[j]+nBeginGlobal_[j]) <= nZoomEnd_[j]) 459 && (nZoomBegin_[j] <= (currentIndex[j]+nBeginGlobal_[j])); 480 481 for (int idxElement = 0; idxElement < this->numElement_; ++idxElement) 482 { 483 int actualIdx = 0; 484 if (axisDomainOrder_(idxElement)) 485 { 486 actualIdx = currentIndex[indexMap_[idxElement]]+currentIndex[indexMap_[idxElement]+1]*nLocal_[indexMap_[idxElement]]; 487 isIndexOnServer = isIndexOnServer && ((infoIndex_[indexMap_[idxElement]](actualIdx)) <= nZoomEnd_[indexMap_[idxElement]]) 488 && (nZoomBegin_[indexMap_[idxElement]] <= (infoIndex_[indexMap_[idxElement]](actualIdx))) 489 && ((infoIndex_[indexMap_[idxElement]+1](actualIdx)) <= nZoomEnd_[indexMap_[idxElement]+1]) 490 && (nZoomBegin_[indexMap_[idxElement]+1] <= (infoIndex_[indexMap_[idxElement]+1](actualIdx))); 491 } 492 else 493 { 494 isIndexOnServer = isIndexOnServer && ((infoIndex_[indexMap_[idxElement]](currentIndex[indexMap_[idxElement]])) <= nZoomEnd_[indexMap_[idxElement]]) 495 && (nZoomBegin_[indexMap_[idxElement]] <= (infoIndex_[indexMap_[idxElement]](currentIndex[indexMap_[idxElement]]))); 496 } 497 } 460 498 if (isIndexOnServer) ++indexSend2ServerCount; 461 499 } … … 571 609 { 572 610 localDataIndex_[indexLocalDataOnClientCount] = countLocalData; 573 574 611 bool isIndexOnServer = true; 575 for (int j = 0; j < this->dims_; ++j) 576 isIndexOnServer = isIndexOnServer && 577 ((currentIndex[j]+nBeginGlobal_[j]) <= nZoomEnd_[j]) && 578 (nZoomBegin_[j] <= (currentIndex[j]+nBeginGlobal_[j])); 612 for (int idxElement = 0; idxElement < this->numElement_; ++idxElement) 613 { 614 int actualIdx = 0; 615 if (axisDomainOrder_(idxElement)) 616 { 617 actualIdx = currentIndex[indexMap_[idxElement]]+currentIndex[indexMap_[idxElement]+1]*nLocal_[indexMap_[idxElement]]; 618 isIndexOnServer = isIndexOnServer && ((infoIndex_[indexMap_[idxElement]](actualIdx)) <= nZoomEnd_[indexMap_[idxElement]]) 619 && (nZoomBegin_[indexMap_[idxElement]] <= (infoIndex_[indexMap_[idxElement]](actualIdx))) 620 && ((infoIndex_[indexMap_[idxElement]+1](actualIdx)) <= nZoomEnd_[indexMap_[idxElement]+1]) 621 && (nZoomBegin_[indexMap_[idxElement]+1] <= (infoIndex_[indexMap_[idxElement]+1](actualIdx))); 622 } 623 else 624 { 625 isIndexOnServer = isIndexOnServer && ((infoIndex_[indexMap_[idxElement]](currentIndex[indexMap_[idxElement]])) <= nZoomEnd_[indexMap_[idxElement]]) 626 && (nZoomBegin_[indexMap_[idxElement]] <= (infoIndex_[indexMap_[idxElement]](currentIndex[indexMap_[idxElement]]))); 627 } 628 } 629 579 630 if (isIndexOnServer) 580 631 { 581 size_t globalIndex = currentIndex[0] + nBeginGlobal_[0]; 632 int actualIdx = (axisDomainOrder_(0)) ? currentIndex[0]+currentIndex[1]*nLocal_[0] 633 : currentIndex[0]; 634 size_t globalIndex = infoIndex_[0](actualIdx); //idxLoop[0] + nBeginGlobal_[0]; 582 635 size_t mulDim = 1; 583 for (int k = 1; k < this->dims_; ++k)636 for (int idxElement = 0; idxElement < this->numElement_; ++idxElement) 584 637 { 585 mulDim *= nGlob_[k-1]; 586 globalIndex += (currentIndex[k] + nBeginGlobal_[k])*mulDim; 638 if (axisDomainOrder_(idxElement)) 639 { 640 actualIdx = currentIndex[indexMap_[idxElement]]+currentIndex[indexMap_[idxElement]+1]*nLocal_[indexMap_[idxElement]]; 641 int jb = (0 == idxElement) ? 1 : 0; 642 for (int j = jb; j <= 1; ++j) 643 { 644 mulDim *= nGlob_[indexMap_[idxElement]+j-1]; 645 globalIndex += (infoIndex_[indexMap_[idxElement]+j](actualIdx))*mulDim; 646 } 647 } 648 else 649 { 650 if (0 != idxElement) 651 { 652 mulDim *= nGlob_[indexMap_[idxElement]-1]; 653 globalIndex += (infoIndex_[indexMap_[idxElement]](currentIndex[indexMap_[idxElement]]))*mulDim; 654 } 655 } 587 656 } 588 657 globalDataSendToServer_[indexSend2ServerCount] = globalIndex;
Note: See TracChangeset
for help on using the changeset viewer.