source: XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/element.hpp @ 1918

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

Big update on on going work related to data distribution and transfer between clients and servers.

  • move all related file into distribution directorie
  • implement the concept of data "View"
  • implement the concept of "connector" which make the data transfer between 2 differents "Views"

YM

  • Property svn:executable set to *
File size: 2.5 KB
Line 
1#ifndef __ELEMENT_HPP__
2#define __ELEMENT_HPP__
3
4#include "xios_spl.hpp"
5#include "array_new.hpp"
6#include "element_view.hpp"
7#include "exception.hpp"
8#include "context_client.hpp"
9#include "context_server.hpp"
10
11namespace xios
12{
13  class CDistributedView ;
14  class CLocalView;
15  class CLocalConnector ;
16
17  class CDistributedElement
18  {
19
20  protected:
21    std::map<int, CArray<size_t,1>> globalIndex_ ;
22    std::map<int, int> localSize_ ;
23    size_t globalSize_ ;
24    std::vector<CDistributedView*> views_= std::vector<CDistributedView*>(CElementView::numViewType_) ;
25    CDistributedElement(void) {} ;
26   
27  public:
28    CDistributedElement(int globalSize, const map<int, CArray<size_t,1>>& globalIndex) ;
29    CDistributedElement(CEventServer& event) ;
30    void addFullView(void) ;
31    void sendToServer(CContextClient* client, CEventClient& event, const CMessage& messageHeader) ;
32    void recvFromClient(CEventServer& event) ;
33    size_t getGlobalSize(void) { return globalSize_;}
34
35    CDistributedView* getView(CElementView::type type) 
36    { 
37      if (views_[(size_t)type]==nullptr) { ERROR("CDistributedElement::getView(CElementView::type type)",<<"View is not initialized");} 
38      else return views_[(size_t)type] ; 
39    }
40
41    void addView(CElementView::type type, std::map<int, CArray<int,1>>& indexView) ;
42    void sendToServer(CEventClient& event, const CMessage& messageHeader) ;
43
44    friend class CDistributedView ;
45  } ;
46
47
48  class CLocalElement : public CDistributedElement
49  {
50    // keep local connector inside   
51      std::map<pair<CElementView::type,CElementView::type>, CLocalConnector*> connectors_  ;
52 
53    public: 
54      CLocalElement(int localRank, size_t globalSize, CArray<size_t,1>& globalIndex) ;
55      CLocalElement(int localRank, CEventServer& event) ;
56      void recvFromClient(int localRank, CEventServer& event) ;
57     
58      void addView(CElementView::type type, CArray<int,1>& indexView) ;
59      void addFullView(void) ;
60      CLocalView* getView(CElementView::type type) 
61      { 
62        if (views_[(size_t)type]==nullptr) { ERROR("CLocalElement::getView(CElementView::type type)",<<"View is not initialized");} 
63        else return (CLocalView*) views_[(size_t)type] ; 
64      }
65     
66      CLocalConnector* getConnector(CElementView::type srcType, CElementView::type dstType) ;
67
68    private :
69      int localRank_;
70      CArray<size_t,1>& globalIndex_ ;
71      int& localSize_ ;
72   
73    friend class CLocalView ;
74  } ;
75
76}
77
78#endif
79
Note: See TracBrowser for help on using the repository browser.