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 | class CGridTransformConnector; |
---|
15 | |
---|
16 | class CLocalView : public CDistributedView, public std::enable_shared_from_this<CLocalView> |
---|
17 | { |
---|
18 | public: |
---|
19 | CLocalView(shared_ptr<CLocalElement> parent, CElementView::type type, const CArray<int,1>& indexView) ; |
---|
20 | CLocalView(shared_ptr<CLocalElement> parent, CElementView::type type, const CArray<bool,1>& maskView) ; |
---|
21 | |
---|
22 | const CArray<int,1>& getIndex(void) { return index_ ;} |
---|
23 | const CArray<size_t,1>& getGlobalIndex(void) { return globalIndex_ ;} |
---|
24 | |
---|
25 | void getGlobalIndexView(CArray<size_t,1>& globalIndexView) |
---|
26 | { |
---|
27 | globalIndexView.resize(size_) ; |
---|
28 | int pos=0 ; |
---|
29 | for(int i=0 ; i<size_ ; i++) |
---|
30 | { |
---|
31 | if (index_(i)>=0 && index_(i)<localSize_) |
---|
32 | { |
---|
33 | globalIndexView(i) = globalIndex_(index_(i)) ; |
---|
34 | pos++ ; |
---|
35 | } |
---|
36 | } |
---|
37 | if(pos==0) globalIndexView.resize(pos) ; |
---|
38 | else globalIndexView.resizeAndPreserve(pos) ; |
---|
39 | } |
---|
40 | |
---|
41 | void getGlobalIndex(vector<size_t>& globalIndex, size_t sliceIndex, size_t* sliceSize, shared_ptr<CLocalView>* localView, int pos) |
---|
42 | { |
---|
43 | if (pos==0) |
---|
44 | { |
---|
45 | for(int i=0;i<size_;i++) |
---|
46 | if (index_(i)>=0 && index_(i)<localSize_) globalIndex.push_back(sliceIndex + globalIndex_(index_(i))) ; |
---|
47 | } |
---|
48 | else |
---|
49 | { |
---|
50 | for(int i=0;i<size_;i++) |
---|
51 | if (index_(i)>=0 && index_(i)<localSize_) |
---|
52 | localView[pos-1]->getGlobalIndex(globalIndex, sliceIndex + globalIndex_(index_(i))*sliceSize[pos], sliceSize, localView, pos-1) ; |
---|
53 | } |
---|
54 | } |
---|
55 | |
---|
56 | void createWithoutRedundancyFullViewConnector( int globalSize, MPI_Comm comm_file, shared_ptr<CGridTransformConnector>& gridTransformConnector, CArray<size_t,1>& globalIndex ); |
---|
57 | |
---|
58 | int getLocalSize(void) {return localSize_ ;} |
---|
59 | int getSize(void) {return size_;} |
---|
60 | void sendRemoteElement(shared_ptr<CRemoteConnector> connector, CContextClient* client, CEventClient& event, const CMessage& messageHeader) ; |
---|
61 | |
---|
62 | CArray<size_t,1>& globalIndex_ ; |
---|
63 | CArray<int,1>& index_ ; |
---|
64 | int& size_ ; /** The number of index composing the view, ie the size of the corresponding data, ie the size of index_ */ |
---|
65 | int& localRank_ ; |
---|
66 | int& localSize_ ; /** The local size of the element, ie the size of globalIndex_ */ |
---|
67 | } ; |
---|
68 | |
---|
69 | } |
---|
70 | |
---|
71 | #endif |
---|