[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: |
---|
[2267] | 18 | CLocalView(shared_ptr<CLocalElement> parent, CElementView::type type, const CArray<int,1>& indexView) ; |
---|
| 19 | CLocalView(shared_ptr<CLocalElement> parent, CElementView::type type, const CArray<bool,1>& maskView) ; |
---|
[1930] | 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 | } |
---|
[1936] | 36 | if(pos==0) globalIndexView.resize(pos) ; |
---|
| 37 | else globalIndexView.resizeAndPreserve(pos) ; |
---|
[1930] | 38 | } |
---|
[1918] | 39 | |
---|
[2267] | 40 | void getGlobalIndex(vector<size_t>& globalIndex, size_t sliceIndex, size_t* sliceSize, shared_ptr<CLocalView>* localView, int pos) |
---|
[1918] | 41 | { |
---|
| 42 | if (pos==0) |
---|
| 43 | { |
---|
| 44 | for(int i=0;i<size_;i++) |
---|
| 45 | if (index_(i)>=0 && index_(i)<localSize_) globalIndex.push_back(sliceIndex + globalIndex_(index_(i))) ; |
---|
| 46 | } |
---|
| 47 | else |
---|
| 48 | { |
---|
| 49 | for(int i=0;i<size_;i++) |
---|
| 50 | if (index_(i)>=0 && index_(i)<localSize_) |
---|
| 51 | localView[pos-1]->getGlobalIndex(globalIndex, sliceIndex + globalIndex_(index_(i))*sliceSize[pos], sliceSize, localView, pos-1) ; |
---|
| 52 | } |
---|
| 53 | } |
---|
| 54 | |
---|
| 55 | |
---|
| 56 | int getLocalSize(void) {return localSize_ ;} |
---|
| 57 | int getSize(void) {return size_;} |
---|
[2267] | 58 | void sendRemoteElement(shared_ptr<CRemoteConnector> connector, CContextClient* client, CEventClient& event, const CMessage& messageHeader) ; |
---|
[1918] | 59 | |
---|
| 60 | CArray<size_t,1>& globalIndex_ ; |
---|
| 61 | CArray<int,1>& index_ ; |
---|
[1954] | 62 | int& size_ ; /** The number of index composing the view, ie the size of the corresponding data, ie the size of index_ */ |
---|
[1918] | 63 | int& localRank_ ; |
---|
[1954] | 64 | int& localSize_ ; /** The local size of the element, ie the size of globalIndex_ */ |
---|
[1918] | 65 | } ; |
---|
| 66 | |
---|
| 67 | } |
---|
| 68 | |
---|
| 69 | #endif |
---|