source: XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/grid_gatherer_connector.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: 1.5 KB
Line 
1#ifndef __GRID_GATHERER_CONNECTOR_HPP__
2#define __GRID_GATHERER_CONNECTOR_HPP__
3
4#include "xios_spl.hpp"
5#include "array_new.hpp"
6#include "distributed_view.hpp"
7#include "mpi.hpp"
8#include "local_view.hpp"
9#include "distributed_view.hpp"
10#include "context_client.hpp"
11#include "gatherer_connector.hpp"
12
13
14namespace xios
15{
16 
17  class CGridGathererConnector
18  {
19    private:
20   
21      vector<CGathererConnector*> elementsConnector_ ;
22      int dstSize_ ;
23
24    public:
25      CGridGathererConnector(vector<CGathererConnector*> elementsConnector) : elementsConnector_(elementsConnector)
26      {
27        dstSize_ = 1 ;
28        for(auto& connector : elementsConnector_) dstSize_=dstSize_*connector->getDstSize() ;
29      }
30
31      template<typename T> 
32      void transfer(const map<int, CArray<T,1>>& input, CArray<T,1>& output)
33      {
34        int n = elementsConnector_.size()-1 ;
35        CGathererConnector** connector = elementsConnector_.data() + n ;
36        output.resize(dstSize_) ;
37        for(auto& rankDataIn : input) 
38        {
39          elementsConnector_[n]->transfer(rankDataIn.first, connector, n, rankDataIn.second.dataFirst(), output.dataFirst()) ;
40        }
41      } 
42
43      template<typename T>
44      void transfer(CEventServer& event, CArray<T,1>& dataOut)
45      {
46        map<int, CArray<T,1>> dataIn ;
47        for (auto& subEvent : event.subEvents) 
48        {
49          auto& data = dataIn[subEvent.rank]; 
50          (*subEvent.buffer) >> data ;
51        }
52        transfer(dataIn, dataOut) ;
53      }
54 
55  };
56}
57
58#endif
Note: See TracBrowser for help on using the repository browser.