source: XIOS/trunk/src/client_server_mapping.hpp @ 827

Last change on this file since 827 was 598, checked in by rlacroix, 9 years ago

Add the infrastructure to request fields from the server.

This will be used to read input files so add a new file attribute mode to define whether data is written or read from a file.

Currently the data is not actually read and random data is transfered for those fields in read mode.

File size: 2.5 KB
Line 
1/*!
2   \file client_server_mapping.hpp
3   \author Ha NGUYEN
4   \since 04 Feb 2015
5   \date 09 Mars 2015
6
7   \brief Mapping between index client and server.
8 */
9#ifndef __XIOS_CLIENT_SERVER_MAPPING_HPP__
10#define __XIOS_CLIENT_SERVER_MAPPING_HPP__
11
12#include "xios_spl.hpp"
13#include "array_new.hpp"
14#include "mpi.hpp"
15
16namespace xios {
17
18/*!
19  \class CClientServerMapping
20  This class computes index of data which are sent to server as well as index of data
21on server side.
22*/
23class CClientServerMapping
24{
25  public:
26    /** Default constructor */
27    CClientServerMapping();
28
29    /** Default destructor */
30    virtual ~CClientServerMapping();
31
32    // Only need global index on client to calculate mapping (supposed client has info of distribution)
33    virtual void computeServerIndexMapping(const CArray<size_t,1>& globalIndexOnClient) = 0;
34
35//    // In case of computing local index on client sent to server
36//    virtual void computeServerIndexMapping(const CArray<size_t,1>& globalIndexOnClient,
37//                                           const CArray<int,1>& localIndexOnClient) = 0;
38
39    // Simple case, global index on client and index on servers
40    virtual void computeServerIndexMapping(const CArray<size_t,1>& globalIndexOnClient,
41                                           const std::vector<CArray<size_t,1>* >& globalIndexOnServer);
42
43    static std::map<int,int> computeConnectedClients(int nbServer, int nbClient,
44                                                     MPI_Comm& clientIntraComm,
45                                                     const std::vector<int>& connectedServerRank);
46
47    const std::map<int, std::vector<size_t> >& getGlobalIndexOnServer() const;
48    const std::map<int, std::vector<int> >& getLocalIndexSendToServer() const;
49
50  protected:
51    void defaultComputeServerIndexMapping(const CArray<size_t,1>& globalIndexOnClient,
52                                          const std::vector<CArray<size_t,1>* >& globalIndexOnServer,
53                                          const CArray<int,1>* localIndexOnClient = 0);
54
55  protected:
56    //! Global index of data on SERVER, which are calculated by client(s)
57    std::map<int, std::vector<size_t> > indexGlobalOnServer_;
58
59    //! Index of the local data which will be sent to the corresponding server(s)
60    std::map<int, std::vector<int> >  localIndexSend2Server_;
61
62    //!< Number of clients connected to a server
63    std::map<int, int> connectedClients_;
64};
65
66} // namespace xios
67#endif // __XIOS_CLIENT_SERVER_MAPPING_HPP__
Note: See TracBrowser for help on using the repository browser.