[623] | 1 | /*! |
---|
| 2 | \file transformation_mapping.hpp |
---|
| 3 | \author Ha NGUYEN |
---|
| 4 | \since 14 May 2015 |
---|
| 5 | \date 09 June 2015 |
---|
| 6 | |
---|
| 7 | \brief Take charge of communication among clients to exchange transformed data. |
---|
| 8 | */ |
---|
[620] | 9 | #ifndef __XIOS_TRANSFORMATION_MAPPING_HPP__ |
---|
| 10 | #define __XIOS_TRANSFORMATION_MAPPING_HPP__ |
---|
| 11 | |
---|
| 12 | #include <map> |
---|
| 13 | #include <set> |
---|
| 14 | #include "grid.hpp" |
---|
[630] | 15 | #include "axis.hpp" |
---|
[620] | 16 | #include "array_new.hpp" |
---|
| 17 | #include "client_server_mapping_distributed.hpp" |
---|
| 18 | |
---|
| 19 | namespace xios { |
---|
| 20 | |
---|
| 21 | /*! |
---|
| 22 | \class CTransformationMapping |
---|
| 23 | This class is in charge of transfer the global index form grid from grid source to grid destination in a rather generic way. |
---|
| 24 | In order to make a transformation, the grid destination will make a request to grid source about the global indexes which it needs. |
---|
| 25 | The same discovering algorithm as the case of client-server is applied to find the corresponding client which contains the demanding global index. |
---|
| 26 | */ |
---|
| 27 | class CTransformationMapping |
---|
| 28 | { |
---|
| 29 | public: |
---|
[829] | 30 | typedef boost::unordered_map<size_t, std::vector<std::pair<int, std::pair<size_t,double> > > > DestinationIndexMap; |
---|
[842] | 31 | struct ReceivedIndex { |
---|
| 32 | ReceivedIndex(int l, size_t g, double w) : localIndex(l),globalIndex(g), weight(w) {} |
---|
| 33 | ReceivedIndex() : localIndex(0), globalIndex(0), weight(0.0) {} |
---|
| 34 | int localIndex; |
---|
| 35 | size_t globalIndex; |
---|
| 36 | double weight; |
---|
| 37 | }; |
---|
| 38 | |
---|
| 39 | typedef boost::unordered_map<int,std::vector<ReceivedIndex> > ReceivedIndexMap; |
---|
[829] | 40 | typedef boost::unordered_map<int,std::vector<std::pair<int, size_t> > > SentIndexMap; |
---|
| 41 | |
---|
| 42 | public: |
---|
[620] | 43 | /** Default constructor */ |
---|
| 44 | CTransformationMapping(CGrid* destination, CGrid* source); |
---|
[630] | 45 | CTransformationMapping(CAxis* destination, CAxis* source); |
---|
| 46 | |
---|
[620] | 47 | ~CTransformationMapping(); |
---|
| 48 | |
---|
[829] | 49 | void computeTransformationMapping(const DestinationIndexMap& globaIndexMapFromDestToSource); |
---|
| 50 | const ReceivedIndexMap& getGlobalIndexReceivedOnGridDestMapping() const; |
---|
| 51 | const SentIndexMap& getGlobalIndexSendToGridDestMapping() const; |
---|
[620] | 52 | |
---|
| 53 | protected: |
---|
| 54 | CGrid* gridSource_; // Grid source |
---|
| 55 | CGrid* gridDestination_; // Grid destination demande the necessary global index from grid source |
---|
| 56 | |
---|
| 57 | //! Global index mapping of grid source and grid destination between two clients |
---|
[829] | 58 | CClientClientDHTPairIntInt* gridIndexClientClientMapping_; |
---|
[620] | 59 | |
---|
| 60 | //! Mapping of client rank of grid source and global index received in grid destination |
---|
[829] | 61 | ReceivedIndexMap globalIndexReceivedOnGridDestMapping_; |
---|
[620] | 62 | |
---|
| 63 | //! Mapping of client rank of grid destination and global index to send from grid source |
---|
[829] | 64 | SentIndexMap globalIndexSendToGridDestMapping_; |
---|
[620] | 65 | }; |
---|
| 66 | |
---|
| 67 | } |
---|
| 68 | #endif // __XIOS_TRANSFORMATION_MAPPING_HPP__ |
---|