Changeset 1622 for XIOS/trunk/src/node/grid.hpp
- Timestamp:
- 12/11/18 13:22:07 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/src/node/grid.hpp
r1564 r1622 372 372 template <int n> 373 373 void CGrid::inputField(const CArray<double,n>& field, CArray<double,1>& stored) const 374 TRY 374 375 { 375 376 //#ifdef __XIOS_DEBUG … … 383 384 this->storeField_arr(field.dataFirst(), stored); 384 385 } 386 CATCH 385 387 386 388 template <int n> 387 389 void CGrid::outputField(const CArray<double,1>& stored, CArray<double,n>& field) const 390 TRY 388 391 { 389 392 //#ifdef __XIOS_DEBUG … … 397 400 this->restoreField_arr(stored, field.dataFirst()); 398 401 } 402 CATCH 399 403 400 404 /*! … … 406 410 template <int N> 407 411 void CGrid::uncompressField(const CArray<double,N>& data, CArray<double,1>& outData) const 412 TRY 408 413 { 409 414 uncompressField_arr(data.dataFirst(), outData); 410 415 } 416 CATCH 411 417 412 418 template<int N> … … 416 422 const CArray<int,1>& axisDomainOrder, 417 423 bool createMask) 424 TRY 418 425 { 419 426 if (!gridMask.isEmpty() || createMask) … … 515 522 } 516 523 } 524 CATCH_DUMP_ATTR 517 525 518 526 template<int N> … … 520 528 const std::vector<int>& eachDimSize, 521 529 bool newValue) 530 TRY 522 531 { 523 532 if (N != eachDimSize.size()) … … 534 543 gridMask = newValue; 535 544 } 545 CATCH_DUMP_ATTR 536 546 537 547 … … 543 553 template<int N> 544 554 void CGrid::modifyGridMask(CArray<bool,N>& gridMask, const CArray<int,1>& indexToModify, bool valueToModify) 555 TRY 545 556 { 546 557 int num = indexToModify.numElements(); … … 550 561 } 551 562 } 563 CATCH_DUMP_ATTR 564 552 565 ///-------------------------------------------------------------- 553 566 554 555 /*! 556 A grid can have multiple dimension, so can its mask in the form of multi-dimension array. 557 It's not a good idea to store all multi-dimension arrays corresponding to each mask. 558 One of the ways is to convert this array into 1-dimension one and every process is taken place on it. 559 \param [in] multi-dimension array grid mask 560 */ 561 template<int N> 562 void CGrid::getLocalMask(const CArray<bool,N>& gridMask, CArray<bool,1>& localMask) 563 { 564 if (gridMask.isEmpty()) return ; 565 int dim = gridMask.dimensions(); 566 std::vector<int> dimensionSizes(dim); 567 for (int i = 0; i < dim; ++i) dimensionSizes[i] = gridMask.extent(i); 568 569 std::vector<int> idxLoop(dim,0); 570 int ssize = gridMask.numElements(), idx = 0; 571 localMask.resize(ssize); 572 while (idx < ssize) 567 /*! 568 A grid can have multiple dimension, so can its mask in the form of multi-dimension array. 569 It's not a good idea to store all multi-dimension arrays corresponding to each mask. 570 One of the ways is to convert this array into 1-dimension one and every process is taken place on it. 571 \param [in] multi-dimension array grid mask 572 */ 573 template<int N> 574 void CGrid::getLocalMask(const CArray<bool,N>& gridMask, CArray<bool,1>& localMask) 575 TRY 573 576 { 574 for (int i = 0; i < dim-1; ++i) 577 if (gridMask.isEmpty()) return ; 578 int dim = gridMask.dimensions(); 579 std::vector<int> dimensionSizes(dim); 580 for (int i = 0; i < dim; ++i) dimensionSizes[i] = gridMask.extent(i); 581 582 std::vector<int> idxLoop(dim,0); 583 int ssize = gridMask.numElements(), idx = 0; 584 localMask.resize(ssize); 585 while (idx < ssize) 575 586 { 576 if (idxLoop[i] == dimensionSizes[i])587 for (int i = 0; i < dim-1; ++i) 577 588 { 578 idxLoop[i] = 0; 579 ++idxLoop[i+1]; 589 if (idxLoop[i] == dimensionSizes[i]) 590 { 591 idxLoop[i] = 0; 592 ++idxLoop[i+1]; 593 } 580 594 } 595 596 int maskIndex = idxLoop[0]; 597 int mulDim = 1; 598 for (int k = 1; k < dim; ++k) 599 { 600 mulDim *= dimensionSizes[k-1]; 601 maskIndex += idxLoop[k]*mulDim; 602 } 603 localMask(maskIndex) = *(gridMask.dataFirst()+maskIndex); 604 605 ++idxLoop[0]; 606 ++idx; 581 607 } 582 583 int maskIndex = idxLoop[0];584 int mulDim = 1;585 for (int k = 1; k < dim; ++k)586 {587 mulDim *= dimensionSizes[k-1];588 maskIndex += idxLoop[k]*mulDim;589 }590 localMask(maskIndex) = *(gridMask.dataFirst()+maskIndex);591 592 ++idxLoop[0];593 ++idx;594 608 } 595 } 609 CATCH_DUMP_ATTR 596 610 597 611 // Declare/Define CGridGroup and CGridDefinition
Note: See TracChangeset
for help on using the changeset viewer.