[1918] | 1 | #ifndef __LOCAL_VIEW_HPP__ |
---|
| 2 | #define __LOCAL_VIEW_HPP__ |
---|
| 3 | |
---|
| 4 | #include "xios_spl.hpp" |
---|
| 5 | #include "array_new.hpp" |
---|
| 6 | #include "distributed_view.hpp" |
---|
| 7 | #include "context_client.hpp" |
---|
| 8 | |
---|
| 9 | namespace xios |
---|
| 10 | { |
---|
| 11 | |
---|
| 12 | class CLocalElement ; |
---|
| 13 | class CRemoteConnector ; |
---|
| 14 | |
---|
| 15 | class CLocalView : public CDistributedView |
---|
| 16 | { |
---|
| 17 | public: |
---|
| 18 | CLocalView(CLocalElement* parent, CElementView::type type, const CArray<int,1>& indexView) ; |
---|
[1930] | 19 | CLocalView(CLocalElement* parent, CElementView::type type, const CArray<bool,1>& maskView) ; |
---|
| 20 | |
---|
[1918] | 21 | const CArray<int,1>& getIndex(void) { return index_ ;} |
---|
| 22 | const CArray<size_t,1>& getGlobalIndex(void) { return globalIndex_ ;} |
---|
[1930] | 23 | |
---|
| 24 | void getGlobalIndexView(CArray<size_t,1>& globalIndexView) |
---|
| 25 | { |
---|
| 26 | globalIndexView.resize(size_) ; |
---|
| 27 | int pos=0 ; |
---|
| 28 | for(int i=0 ; i<size_ ; i++) |
---|
| 29 | { |
---|
| 30 | if (index_(i)>=0 && index_(i)<localSize_) |
---|
| 31 | { |
---|
| 32 | globalIndexView(i) = globalIndex_(index_(i)) ; |
---|
| 33 | pos++ ; |
---|
| 34 | } |
---|
| 35 | } |
---|
| 36 | globalIndexView.resizeAndPreserve(pos) ; |
---|
| 37 | } |
---|
[1918] | 38 | |
---|
| 39 | void getGlobalIndex(vector<size_t>& globalIndex, size_t sliceIndex, size_t* sliceSize, CLocalView** localView, int pos) |
---|
| 40 | { |
---|
| 41 | if (pos==0) |
---|
| 42 | { |
---|
| 43 | for(int i=0;i<size_;i++) |
---|
| 44 | if (index_(i)>=0 && index_(i)<localSize_) globalIndex.push_back(sliceIndex + globalIndex_(index_(i))) ; |
---|
| 45 | } |
---|
| 46 | else |
---|
| 47 | { |
---|
| 48 | for(int i=0;i<size_;i++) |
---|
| 49 | if (index_(i)>=0 && index_(i)<localSize_) |
---|
| 50 | localView[pos-1]->getGlobalIndex(globalIndex, sliceIndex + globalIndex_(index_(i))*sliceSize[pos], sliceSize, localView, pos-1) ; |
---|
| 51 | } |
---|
| 52 | } |
---|
| 53 | |
---|
| 54 | |
---|
| 55 | int getLocalSize(void) {return localSize_ ;} |
---|
| 56 | int getSize(void) {return size_;} |
---|
| 57 | void sendRemoteElement(CRemoteConnector& connector, CContextClient* client, CEventClient& event, const CMessage& messageHeader) ; |
---|
| 58 | |
---|
| 59 | CArray<size_t,1>& globalIndex_ ; |
---|
| 60 | CArray<int,1>& index_ ; |
---|
| 61 | int& size_ ; |
---|
| 62 | int& localRank_ ; |
---|
| 63 | int& localSize_ ; |
---|
| 64 | } ; |
---|
| 65 | |
---|
| 66 | } |
---|
| 67 | |
---|
| 68 | #endif |
---|