Changeset 1564
 Timestamp:
 07/20/18 14:02:55 (2 years ago)
 Location:
 XIOS/trunk/src
 Files:

 2 edited
Legend:
 Unmodified
 Added
 Removed

XIOS/trunk/src/distribution_client.cpp
r1562 r1564 68 68 break; 69 69 case 1: 70 readGridMaskInfo(grid>mask_1d);70 if (!grid>mask_1d.isEmpty()) readGridMaskInfo(grid>mask_1d); 71 71 break; 72 72 case 2: 73 readGridMaskInfo(grid>mask_2d);73 if (!grid>mask_2d.isEmpty()) readGridMaskInfo(grid>mask_2d); 74 74 break; 75 75 case 3: 76 readGridMaskInfo(grid>mask_3d);76 if (!grid>mask_3d.isEmpty()) readGridMaskInfo(grid>mask_3d); 77 77 break; 78 78 case 4: 79 readGridMaskInfo(grid>mask_4d);79 if (!grid>mask_4d.isEmpty()) readGridMaskInfo(grid>mask_4d); 80 80 break; 81 81 case 5: 82 readGridMaskInfo(grid>mask_5d);82 if (!grid>mask_5d.isEmpty()) readGridMaskInfo(grid>mask_5d); 83 83 break; 84 84 case 6: 85 readGridMaskInfo(grid>mask_6d);85 if (!grid>mask_6d.isEmpty()) readGridMaskInfo(grid>mask_6d); 86 86 break; 87 87 case 7: 88 readGridMaskInfo(grid>mask_7d);88 if (!grid>mask_7d.isEmpty()) readGridMaskInfo(grid>mask_7d); 89 89 break; 90 90 default: … … 411 411 size_t idx = 0, indexLocalDataOnClientCount = 0; 412 412 size_t ssize = 1; 413 413 414 for (int i = 0; i < numElement_; ++i) ssize *= eachElementSize[i]; 414 415 while (idx < ssize) … … 436 437 int gridMaskIndex = 0; 437 438 currentIndex[0] = elementLocalIndex_[0](i); 438 for (int k = 0; k < this>numElement_; ++k) 439 { 440 gridMaskIndex += (currentIndex[k])*elementNLocal_[k]; 441 } 442 443 if (gridMask_(gridMaskIndex)) 444 { 445 ++indexLocalDataOnClientCount; 446 } 439 440 // If defined, iterate on grid mask 441 if (!gridMask_.isEmpty()) 442 { 443 for (int k = 0; k < this>numElement_; ++k) 444 { 445 gridMaskIndex += (currentIndex[k])*elementNLocal_[k]; 446 } 447 if (gridMask_(gridMaskIndex)) ++indexLocalDataOnClientCount; 448 } 449 // If grid mask is not defined, iterate on elements' mask 450 else 451 { 452 bool maskTmp = true; 453 int idxDomain = 0, idxAxis = 0; 454 for (int elem = 0; elem < numElement_; ++elem) 455 { 456 if (2 == axisDomainOrder_(elem)) 457 { 458 maskTmp = maskTmp && domainMasks_[idxDomain](currentIndex[elem]); 459 ++idxDomain; 460 } 461 else if (1 == axisDomainOrder_(elem)) 462 { 463 maskTmp = maskTmp && axisMasks_[idxAxis](currentIndex[elem]); 464 ++idxAxis; 465 } 466 } 467 if (maskTmp) ++indexLocalDataOnClientCount; 468 } 469 447 470 } 448 471 idxLoop[0] += innerLoopSize; … … 518 541 } 519 542 520 if (gridMask_(gridMaskIndex)) 543 bool maskTmp = true; 544 // If defined, apply grid mask 545 if (!gridMask_.isEmpty()) 546 { 547 maskTmp = gridMask_(gridMaskIndex); 548 } 549 // If grid mask is not defined, apply elements' mask 550 else 551 { 552 int idxDomain = 0, idxAxis = 0; 553 for (int elem = 0; elem < numElement_; ++elem) 554 { 555 if (2 == axisDomainOrder_(elem)) 556 { 557 maskTmp = maskTmp && domainMasks_[idxDomain](currentIndex[elem]); 558 ++idxDomain; 559 } 560 else if (1 == axisDomainOrder_(elem)) 561 { 562 maskTmp = maskTmp && axisMasks_[idxAxis](currentIndex[elem]); 563 ++idxAxis; 564 } 565 } 566 } 567 568 if (maskTmp) 521 569 { 522 570 size_t globalIndex = 0; 
XIOS/trunk/src/node/grid.hpp
r1542 r1564 19 19 namespace xios { 20 20 21 /// ////////////////////// D ï¿œï¿œclarations ////////////////////// ///21 /// ////////////////////// Declarations ////////////////////// /// 22 22 23 23 class CGridGroup; … … 91 91 StdSize getDataSize(void) const; 92 92 93 /// Entr ï¿œï¿œessorties de champs93 /// Entreessorties de champs 94 94 template <int n> 95 95 void inputField(const CArray<double,n>& field, CArray<double,1>& stored) const; … … 417 417 bool createMask) 418 418 { 419 int idx = 0; 420 int numElement = axisDomainOrder.numElements(); 421 int dim = domainMasks.size() * 2 + axisMasks.size(); 422 std::vector<CDomain*> domainP = this>getDomains(); 423 std::vector<CAxis*> axisP = this>getAxis(); 424 425 std::vector<int> idxLoop(dim,0), indexMap(numElement), eachDimSize(dim); 426 std::vector<int> currentIndex(dim); 427 int idxDomain = 0, idxAxis = 0; 428 for (int i = 0; i < numElement; ++i) 429 { 430 indexMap[i] = idx; 431 if (2 == axisDomainOrder(i)) { 432 eachDimSize[indexMap[i]] = domainP[idxDomain]>ni; 433 eachDimSize[indexMap[i]+1] = domainP[idxDomain]>nj; 434 idx += 2; ++idxDomain; 419 if (!gridMask.isEmpty()  createMask) 420 { 421 int idx = 0; 422 int numElement = axisDomainOrder.numElements(); 423 int dim = domainMasks.size() * 2 + axisMasks.size(); 424 std::vector<CDomain*> domainP = this>getDomains(); 425 std::vector<CAxis*> axisP = this>getAxis(); 426 427 std::vector<int> idxLoop(dim,0), indexMap(numElement), eachDimSize(dim); 428 std::vector<int> currentIndex(dim); 429 int idxDomain = 0, idxAxis = 0; 430 for (int i = 0; i < numElement; ++i) 431 { 432 indexMap[i] = idx; 433 if (2 == axisDomainOrder(i)) { 434 eachDimSize[indexMap[i]] = domainP[idxDomain]>ni; 435 eachDimSize[indexMap[i]+1] = domainP[idxDomain]>nj; 436 idx += 2; ++idxDomain; 437 } 438 else if (1 == axisDomainOrder(i)) { 439 // eachDimSize[indexMap[i]] = axisMasks[idxAxis]>numElements(); 440 eachDimSize[indexMap[i]] = axisP[idxAxis]>n; 441 ++idx; ++idxAxis; 442 } 443 else {}; 435 444 } 436 else if (1 == axisDomainOrder(i)) { 437 // eachDimSize[indexMap[i]] = axisMasks[idxAxis]>numElements(); 438 eachDimSize[indexMap[i]] = axisP[idxAxis]>n; 439 ++idx; ++idxAxis; 440 } 441 else {}; 442 } 443 444 if (!gridMask.isEmpty() && !createMask) 445 { 446 for (int i = 0; i < dim; ++i) 445 446 // if (!gridMask.isEmpty() && !createMask) 447 if (!createMask) 447 448 { 448 if (gridMask.extent(i) != eachDimSize[i]) 449 ERROR("CGrid::checkMask(void)", 450 << "The mask has one dimension whose size is different from the one of the local grid." << std::endl 451 << "Local size of dimension " << i << " is " << eachDimSize[i] << "." << std::endl 452 << "Mask size for dimension " << i << " is " << gridMask.extent(i) << "." << std::endl 453 << "Grid = " << this>getId()) 454 } 455 } 456 else { 457 CArrayBoolTraits<CArray<bool,N> >::resizeArray(gridMask,eachDimSize); 458 gridMask = true; 459 } 460 461 int ssize = gridMask.numElements(); 462 idx = 0; 463 while (idx < ssize) 464 { 465 for (int i = 0; i < dim1; ++i) 466 { 467 if (idxLoop[i] == eachDimSize[i]) 449 for (int i = 0; i < dim; ++i) 468 450 { 469 idxLoop[i] = 0; 470 ++idxLoop[i+1]; 451 if (gridMask.extent(i) != eachDimSize[i]) 452 ERROR("CGrid::checkMask(void)", 453 << "The mask has one dimension whose size is different from the one of the local grid." << std::endl 454 << "Local size of dimension " << i << " is " << eachDimSize[i] << "." << std::endl 455 << "Mask size for dimension " << i << " is " << gridMask.extent(i) << "." << std::endl 456 << "Grid = " << this>getId()) 471 457 } 472 458 } 473 474 // Find out outer index 475 idxDomain = idxAxis = 0; 476 bool maskValue = true; 477 for (int i = 0; i < numElement; ++i) 459 else { 460 CArrayBoolTraits<CArray<bool,N> >::resizeArray(gridMask,eachDimSize); 461 gridMask = true; 462 } 463 464 int ssize = gridMask.numElements(); 465 idx = 0; 466 while (idx < ssize) 478 467 { 479 if (2 == axisDomainOrder(i))468 for (int i = 0; i < dim1; ++i) 480 469 { 481 int idxTmp = idxLoop[indexMap[i]] + idxLoop[indexMap[i]+1] * eachDimSize[indexMap[i]]; 482 if (idxTmp < (*domainMasks[idxDomain]).numElements()) 483 maskValue = maskValue && (*domainMasks[idxDomain])(idxTmp); 484 else 485 maskValue = false; 486 ++idxDomain; 470 if (idxLoop[i] == eachDimSize[i]) 471 { 472 idxLoop[i] = 0; 473 ++idxLoop[i+1]; 474 } 487 475 } 488 else if (1 == axisDomainOrder(i)) 476 477 // Find out outer index 478 idxDomain = idxAxis = 0; 479 bool maskValue = true; 480 for (int i = 0; i < numElement; ++i) 489 481 { 490 int idxTmp = idxLoop[indexMap[i]]; 491 if (idxTmp < (*axisMasks[idxAxis]).numElements()) 492 maskValue = maskValue && (*axisMasks[idxAxis])(idxTmp); 493 else 494 maskValue = false; 495 496 ++idxAxis; 482 if (2 == axisDomainOrder(i)) 483 { 484 int idxTmp = idxLoop[indexMap[i]] + idxLoop[indexMap[i]+1] * eachDimSize[indexMap[i]]; 485 if (idxTmp < (*domainMasks[idxDomain]).numElements()) 486 maskValue = maskValue && (*domainMasks[idxDomain])(idxTmp); 487 else 488 maskValue = false; 489 ++idxDomain; 490 } 491 else if (1 == axisDomainOrder(i)) 492 { 493 int idxTmp = idxLoop[indexMap[i]]; 494 if (idxTmp < (*axisMasks[idxAxis]).numElements()) 495 maskValue = maskValue && (*axisMasks[idxAxis])(idxTmp); 496 else 497 maskValue = false; 498 499 ++idxAxis; 500 } 497 501 } 502 503 int maskIndex = idxLoop[0]; 504 int mulDim = 1; 505 for (int k = 1; k < dim; ++k) 506 { 507 mulDim *= eachDimSize[k1]; 508 maskIndex += idxLoop[k]*mulDim; 509 } 510 *(gridMask.dataFirst()+maskIndex) &= maskValue; 511 512 ++idxLoop[0]; 513 ++idx; 498 514 } 499 500 int maskIndex = idxLoop[0]; 501 int mulDim = 1; 502 for (int k = 1; k < dim; ++k) 503 { 504 mulDim *= eachDimSize[k1]; 505 maskIndex += idxLoop[k]*mulDim; 506 } 507 *(gridMask.dataFirst()+maskIndex) &= maskValue; 508 509 ++idxLoop[0]; 510 ++idx; 511 } 512 515 } 513 516 } 514 517
Note: See TracChangeset
for help on using the changeset viewer.