source: XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/grid_remote_connector.hpp @ 2267

Last change on this file since 2267 was 2267, checked in by ymipsl, 3 years ago

tracking memory leak
Elements, views, and connectors are now managed with shared pointer.
YM

  • Property svn:executable set to *
File size: 3.9 KB
Line 
1#ifndef __GRID_REMOTE_CONNECTOR_HPP__
2#define __GRID_REMOTE_CONNECTOR_HPP__
3
4#include "xios_spl.hpp"
5#include "array_new.hpp"
6#include "mpi.hpp"
7#include "local_view.hpp"
8#include "distributed_view.hpp"
9#include "context_client.hpp"
10
11
12namespace xios
13{
14 
15  class CGridRemoteConnector
16  {
17
18    public:
19
20      CGridRemoteConnector(vector<shared_ptr<CLocalView>>& srcView, vector<shared_ptr<CDistributedView>>& dstView, MPI_Comm localComm, int remoteSize) ;
21      CGridRemoteConnector(vector<shared_ptr<CLocalView>>& srcView, vector<shared_ptr<CLocalView>>& dstView, MPI_Comm localComm, int remoteSize) ;
22      void computeViewDistribution(void) ;
23      void computeConnector(void) ;
24      void computeConnectorMethods(void) ;
25      void computeGenericMethod(vector<shared_ptr<CLocalView>>& srcView, vector<shared_ptr<CDistributedView>>& dstView, vector<int>& indElements) ;
26      void computeSrcDstNonDistributed(int i, map<int,bool>& ranks) ;
27      void computeDstNonDistributed(int i, map<int,bool>& ranks) ;
28      void computeSrcNonDistributed(int i) ;
29      void computeRedondantRanks(void) ;
30      std::map<int, CArray<size_t,1>>& getDistributedGlobalIndex(int pos) { return elements_[pos] ;} 
31      const vector<bool>& getIsSrcViewDistributed(void) { return isSrcViewDistributed_ ;}
32      const vector<bool>& getIsDstViewDistributed(void) { return isDstViewDistributed_ ;}
33      const set<int>& getRankToRemove(void) {return rankToRemove_;} 
34   
35    protected:
36 
37    /**
38     * Source views composing the source grid. The vector store an internal copy of pointer elements composing the grid.
39     * It is feed at construction time
40     */
41      vector<shared_ptr<CLocalView>> srcView_ ;
42
43    /**
44     * Destination views composing the source grid. The vector store an internal copy of pointer elements composing the grid
45     * It is feed at construction time
46     */
47      vector<shared_ptr<CDistributedView>> dstView_ ;
48
49    /** 
50     * The list of global indices to send to each rank of the remote view (servers). The vector store the information for each element, and the map
51     * specify a list of global indices to send to each rank of the remote view.
52     * size of element_[] -> number of elements composing the grids (source/destination)
53     * element[i][rank] == CArray<size_t,1> -> list of global indices  to send to the remote process of rank \b rank for the view \b i
54     * The is computed when calling computeConnector internal methods
55     * map can be returned trough the public accessor : getDistributedGlobalIndex(int)
56     */
57      vector<map<int, CArray<size_t,1>>> elements_ ;
58   
59      /**
60      /* internal copy of the local communicator (client workflow). Feed at construction time.
61       */
62      MPI_Comm localComm_ ;
63
64      /**
65      /* size of the remote communicator (== nb of servers). Feed at consctruction time
66       */
67      int remoteSize_ ;
68
69      /**
70      /* for each view composing the source grid, the vector store the information about the distribution of the element, i.e.
71       * if each ranks of the local view has exactly the same global indices than each other. This is computed when calling 
72       * \b computeViewDistribution method. 
73       */
74      vector<bool> isSrcViewDistributed_ ;
75
76     /**
77      /* for each view composing the destination grid, the vector store the information about the distribution of the element, i.e.
78       * if each ranks of the remote view has exactly the same global indices than each other. This is computed when calling 
79       * \b computeViewDistribution method.
80       */
81      vector<bool> isDstViewDistributed_ ;
82
83      /**
84      /* Redondant ranks of the \b elements_ are stored there by calling computeRedondantRanks(), to be removed latter or to be retrieve from elsewhere.
85       */
86      set<int> rankToRemove_ ;
87     
88   
89  } ;
90
91}
92
93#endif
Note: See TracBrowser for help on using the repository browser.