source: XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/local_view.hpp @ 2230

Last change on this file since 2230 was 1954, checked in by ymipsl, 4 years ago

Xios coupling.

Add some comments.

YM

  • Property svn:executable set to *
File size: 2.2 KB
Line 
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
9namespace 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) ;
19    CLocalView(CLocalElement* parent, CElementView::type type, const CArray<bool,1>& maskView) ;
20
21    const CArray<int,1>& getIndex(void) { return index_ ;}
22    const CArray<size_t,1>& getGlobalIndex(void) { return globalIndex_ ;}
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      if(pos==0) globalIndexView.resize(pos) ;
37      else globalIndexView.resizeAndPreserve(pos) ;
38    }   
39
40    void getGlobalIndex(vector<size_t>& globalIndex, size_t sliceIndex, size_t* sliceSize, CLocalView** localView, int pos)
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_;} 
58    void sendRemoteElement(CRemoteConnector& connector, CContextClient* client, CEventClient& event, const CMessage& messageHeader) ;
59   
60    CArray<size_t,1>& globalIndex_ ;
61    CArray<int,1>& index_ ;
62    int& size_ ;        /** The number of index composing the view, ie the size of the corresponding data, ie the size of index_ */
63    int& localRank_ ;
64    int& localSize_ ;   /** The local size of the element, ie the size of globalIndex_ */
65  } ;
66
67}
68
69#endif
Note: See TracBrowser for help on using the repository browser.