source: XIOS/trunk/src/transformation/transformation_mapping.hpp @ 842

Last change on this file since 842 was 842, checked in by mhnguyen, 8 years ago

Small improvements on transformation mapping

+) Remove complex structure of transformation mapping by a simpler one

Test
+) On Curie
+) All tests pass

File size: 2.5 KB
Line 
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 */
9#ifndef __XIOS_TRANSFORMATION_MAPPING_HPP__
10#define __XIOS_TRANSFORMATION_MAPPING_HPP__
11
12#include <map>
13#include <set>
14#include "grid.hpp"
15#include "axis.hpp"
16#include "array_new.hpp"
17#include "client_server_mapping_distributed.hpp"
18
19namespace 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.
24In order to make a transformation, the grid destination will make a request to grid source about the global indexes which it needs.
25The same discovering algorithm as the case of client-server is applied to find the corresponding client which contains the demanding global index.
26*/
27class CTransformationMapping
28{
29public:
30  typedef boost::unordered_map<size_t, std::vector<std::pair<int, std::pair<size_t,double> > > > DestinationIndexMap;
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;
40  typedef boost::unordered_map<int,std::vector<std::pair<int, size_t> > > SentIndexMap;
41
42public:
43  /** Default constructor */
44  CTransformationMapping(CGrid* destination, CGrid* source);
45  CTransformationMapping(CAxis* destination, CAxis* source);
46
47  ~CTransformationMapping();
48
49  void computeTransformationMapping(const DestinationIndexMap& globaIndexMapFromDestToSource);
50  const ReceivedIndexMap& getGlobalIndexReceivedOnGridDestMapping() const;
51  const SentIndexMap& getGlobalIndexSendToGridDestMapping() const;
52
53protected:
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
58  CClientClientDHTPairIntInt* gridIndexClientClientMapping_;
59
60  //! Mapping of client rank of grid source and global index received in grid destination
61  ReceivedIndexMap globalIndexReceivedOnGridDestMapping_;
62
63  //! Mapping of client rank of grid destination and global index to send from grid source
64  SentIndexMap globalIndexSendToGridDestMapping_;
65};
66
67}
68#endif // __XIOS_TRANSFORMATION_MAPPING_HPP__
Note: See TracBrowser for help on using the repository browser.