source: XIOS/trunk/src/transformation/generic_algorithm_transformation.hpp @ 867

Last change on this file since 867 was 867, checked in by mhnguyen, 6 years ago

Various clean up

+) Remove some redundant codes

Test
+) On Curie
+) tests pass

File size: 4.4 KB
Line 
1/*!
2   \file generic_algorithm_transformation.hpp
3   \author Ha NGUYEN
4   \since 14 May 2015
5   \date 29 June 2015
6
7   \brief Interface for all transformation algorithms.
8 */
9#ifndef __XIOS_GENERIC_ALGORITHM_TRANSFORMATION_HPP__
10#define __XIOS_GENERIC_ALGORITHM_TRANSFORMATION_HPP__
11
12#include <map>
13#include <set>
14#include "array_new.hpp"
15#include "client_client_dht_template.hpp"
16
17namespace xios {
18  class CGrid;
19  class CDomain;
20  class CAxis;
21
22  /*!
23  \class CGenericAlgorithmTransformation
24  This class defines the interface for all other inherted algorithms class
25  */
26class CGenericAlgorithmTransformation
27{
28protected:
29  typedef std::vector<std::pair<int, std::pair<size_t,double> > > DestinationGlobalIndex;
30public:
31  // Stupid global index map, it must be replaced by tuple
32  // Mapping between global index map of DESTINATION and its local index with pair of global index of SOURCE and weights
33  typedef boost::unordered_map<size_t, DestinationGlobalIndex> DestinationIndexMap;
34  //
35  typedef boost::unordered_map<int, boost::unordered_map<size_t, std::vector<std::pair<size_t,double> > > > SourceDestinationIndexMap;
36
37protected:
38  typedef boost::unordered_map<size_t,int> GlobalLocalMap;
39protected:
40  typedef boost::unordered_map<int, std::vector<int> > TransformationIndexMap;
41  typedef boost::unordered_map<int, std::vector<double> > TransformationWeightMap;
42  typedef boost::unordered_map<int, std::vector<int> > TransformationPositionMap;
43
44public:
45  CGenericAlgorithmTransformation();
46
47  virtual ~CGenericAlgorithmTransformation() {}
48
49  void computeGlobalSourceIndex(int elementPositionInGrid,
50                               CGrid* gridSrc,
51                               CGrid* gridDst,
52                               SourceDestinationIndexMap& globaIndexWeightFromSrcToDst);
53
54  std::vector<StdString> getIdAuxInputs();
55
56  /*!
57  Compute global index mapping from one element of destination grid to the corresponding element of source grid
58  */
59  void computeIndexSourceMapping(const std::vector<CArray<double,1>* >& dataAuxInputs = std::vector<CArray<double,1>* >());
60
61protected:
62  virtual void computeIndexSourceMapping_(const std::vector<CArray<double,1>* >&) = 0;
63
64  /*!
65  Compute proc which contains global index of an element
66    \param[in] globalElementIndex demanding global index of an element of source grid
67    \param[out] globalElementIndexOnProc Proc contains the demanding global index
68  */
69  virtual void computeExchangeGlobalIndex(const CArray<size_t,1>& globalElementIndex,
70                                          CClientClientDHTInt::Index2VectorInfoTypeMap& globalElementIndexOnProc) = 0;
71
72protected:
73  void computeGlobalGridIndexMapping(int elementPositionInGrid,
74                                     const std::vector<int>& srcRank,
75                                     boost::unordered_map<int, std::vector<std::pair<int,double> > >& src2DstMap,
76                                     CGrid* gridDst,
77                                     CGrid* gridSrc,
78                                     std::vector<boost::unordered_map<int,std::vector<size_t> > >& globalElementIndexOnProc,
79                                     SourceDestinationIndexMap& globaIndexWeightFromSrcToDst);
80
81  void computeExchangeDomainIndex(CDomain* domainDst,
82                                  CDomain* domainSrc,
83                                  CArray<size_t,1>& destGlobalIndexPositionInGrid,
84                                  boost::unordered_map<int,std::vector<size_t> >& globalDomainIndexOnProc);
85
86  void computeExchangeAxisIndex(CAxis* axisDst,
87                                CAxis* axisSrc,
88                                CArray<size_t,1>& destGlobalIndexPositionInGrid,
89                                boost::unordered_map<int,std::vector<size_t> >& globalAxisIndexOnProc);
90
91protected:
92  //! Map between global index of destination element and source element
93  std::vector<TransformationIndexMap> transformationMapping_;
94  //! Weight corresponding of source to destination
95  std::vector<TransformationWeightMap> transformationWeight_;
96  //! Map of global index of destination element and corresponding global index of other elements in the same grid
97  //! By default, one index of an element corresponds to all index of remaining element in the grid. So it's empty
98  std::vector<TransformationPositionMap> transformationPosition_;
99
100  //! Id of auxillary inputs which helps doing transformation dynamically
101  std::vector<StdString> idAuxInputs_;
102};
103
104}
105#endif // __XIOS_GENERIC_ALGORITHM_TRANSFORMATION_HPP__
Note: See TracBrowser for help on using the repository browser.