source: XIOS3/trunk/src/distribution/local_view.hpp @ 2385

Last change on this file since 2385 was 2385, checked in by jderouillat, 2 years ago

Move in a new method of CLocalView the management of a without redundancy full view connector (used in hash computation of elements)

  • Property svn:executable set to *
File size: 2.5 KB
RevLine 
[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
9namespace xios
10{
11
12  class CLocalElement ;
13  class CRemoteConnector ;
[2385]14  class CGridTransformConnector;
[1918]15
[2385]16  class CLocalView : public CDistributedView, public std::enable_shared_from_this<CLocalView>
[1918]17  {
18    public:
[2267]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) ;
[1930]21
[1918]22    const CArray<int,1>& getIndex(void) { return index_ ;}
23    const CArray<size_t,1>& getGlobalIndex(void) { return globalIndex_ ;}
[1930]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      }
[1936]37      if(pos==0) globalIndexView.resize(pos) ;
38      else globalIndexView.resizeAndPreserve(pos) ;
[1930]39    }   
[1918]40
[2267]41    void getGlobalIndex(vector<size_t>& globalIndex, size_t sliceIndex, size_t* sliceSize, shared_ptr<CLocalView>* localView, int pos)
[1918]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
[2385]56    void createWithoutRedundancyFullViewConnector( int globalSize, MPI_Comm comm_file, shared_ptr<CGridTransformConnector>& gridTransformConnector, CArray<size_t,1>& globalIndex );
[1918]57
58    int getLocalSize(void) {return localSize_ ;}
59    int getSize(void) {return size_;} 
[2267]60    void sendRemoteElement(shared_ptr<CRemoteConnector> connector, CContextClient* client, CEventClient& event, const CMessage& messageHeader) ;
[1918]61   
62    CArray<size_t,1>& globalIndex_ ;
63    CArray<int,1>& index_ ;
[1954]64    int& size_ ;        /** The number of index composing the view, ie the size of the corresponding data, ie the size of index_ */
[1918]65    int& localRank_ ;
[1954]66    int& localSize_ ;   /** The local size of the element, ie the size of globalIndex_ */
[1918]67  } ;
68
69}
70
[2385]71#endif
Note: See TracBrowser for help on using the repository browser.