[1918] | 1 | #include "gatherer_connector.hpp" |
---|
| 2 | |
---|
| 3 | namespace xios |
---|
| 4 | { |
---|
| 5 | void CGathererConnector::computeConnector(void) |
---|
| 6 | { |
---|
| 7 | dstSize_=dstView_->getSize() ; |
---|
| 8 | auto& srcGlobalIndex = srcView_->getGlobalIndex() ; |
---|
| 9 | auto& srcIndex = srcView_->getIndex() ; |
---|
| 10 | for(auto& rankIndex : srcIndex) srcSize_[rankIndex.first] = rankIndex.second.numElements(); |
---|
| 11 | auto& dstGlobalIndex = dstView_->getGlobalIndex() ; |
---|
| 12 | auto& dstIndex = dstView_->getIndex() ; |
---|
| 13 | dstSize_=dstIndex.numElements() ; |
---|
| 14 | |
---|
| 15 | unordered_map<size_t,int> mapGlobalLocalIndex ; |
---|
| 16 | int globalIndexSize=dstGlobalIndex.size() ; |
---|
[1930] | 17 | //for(auto& ind : dstIndex) mapGlobalLocalIndex[dstGlobalIndex(ind)] = ind ; |
---|
| 18 | for(int i=0; i<dstSize_ ; i++) if (dstIndex(i)>=0 && dstIndex(i)<globalIndexSize) mapGlobalLocalIndex[dstGlobalIndex(dstIndex(i))] = i ; |
---|
| 19 | |
---|
[1918] | 20 | for(auto& rankIndex : srcIndex) |
---|
| 21 | { |
---|
| 22 | int rank=rankIndex.first ; |
---|
| 23 | auto& index=rankIndex.second ; |
---|
| 24 | int indexSize = index.numElements() ; |
---|
| 25 | auto& globalIndex = srcGlobalIndex[rank] ; |
---|
| 26 | int globalIndexSize=globalIndex.numElements() ; |
---|
| 27 | auto& connector = connector_[rank] ; |
---|
| 28 | auto& mask = mask_[rank] ; |
---|
| 29 | for(int ind=0; ind<indexSize ; ind++) |
---|
| 30 | { |
---|
[1930] | 31 | if (index(ind)>=0 && index(ind)<globalIndexSize) |
---|
[1918] | 32 | { |
---|
[1930] | 33 | auto it=mapGlobalLocalIndex.find(globalIndex(index(ind))) ; |
---|
[1918] | 34 | if (it != mapGlobalLocalIndex.end()) |
---|
| 35 | { |
---|
| 36 | connector.push_back(it->second) ; |
---|
| 37 | mask.push_back(true) ; |
---|
| 38 | } |
---|
| 39 | else mask.push_back(false) ; |
---|
| 40 | } |
---|
| 41 | else mask.push_back(false) ; |
---|
| 42 | } |
---|
| 43 | } |
---|
| 44 | } |
---|
| 45 | |
---|
| 46 | |
---|
| 47 | } |
---|