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

Last change on this file since 843 was 843, checked in by mhnguyen, 5 years ago

Several improvements

+) Replace some time-consuming operations by simpler ones

Test
+) On Curie
+) All tests pass

File size: 4.8 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
16namespace xios {
17  /*!
18  \class CGenericAlgorithmTransformation
19  This class defines the interface for all other inherted algorithms class
20  */
21class CGenericAlgorithmTransformation
22{
23protected:
24  typedef std::vector<std::pair<int, std::pair<size_t,double> > > DestinationGlobalIndex;
25public:
26  // Stupid global index map, it must be replaced by tuple
27  // Mapping between global index map of DESTINATION and its local index with pair of global index of SOURCE and weights
28  typedef boost::unordered_map<size_t, DestinationGlobalIndex> DestinationIndexMap;
29
30protected:
31  typedef boost::unordered_map<size_t,int> GlobalLocalMap;
32
33public:
34  CGenericAlgorithmTransformation();
35
36  virtual ~CGenericAlgorithmTransformation() {}
37
38  void computeGlobalSourceIndex(int elementPositionInGrid,
39                                const std::vector<int>& gridDestGlobalDim,
40                                const std::vector<int>& gridSrcGlobalDim,
41                                const GlobalLocalMap& globalLocalIndexGridDestSendToServer,
42                                DestinationIndexMap& globaIndexWeightFromDestToSource);
43
44  std::vector<StdString> getIdAuxInputs();
45
46  /*!
47  Compute global index mapping from one element of destination grid to the corresponding element of source grid
48  */
49  void computeIndexSourceMapping(const std::vector<CArray<double,1>* >& dataAuxInputs = std::vector<CArray<double,1>* >());
50
51protected:
52  /*!
53  Compute an array of global index from a global index on an element
54    \param[in] destGlobalIndex global index on an element of destination grid
55    \param[in] srcGlobalIndex global index(es) on an element of source grid (which are needed by one index on element destination)
56    \param[in] elementPositionInGrid position of the element in the grid (for example: a grid with one domain and one axis, position of domain is 1, position of axis is 2)
57    \param[in] gridDestGlobalDim dimension size of destination grid (it should share the same size for all dimension, maybe except the element on which transformation is performed)
58    \param[in] globalLocalIndexDestSendToServerMap pair of global index and local index of destination grid which are to be sent to server(s), this array is already acsending sorted
59    \param[in/out] globalLocalIndexDestMap array of global index (for 2d grid, this array maybe a line, for 3d, this array may represent a plan). It should be preallocated
60    \param[in/out] globalIndexSrcGrid array of global index of source grid (for 2d grid, this array is a line, for 3d, this array represents a plan). It should be preallocated
61  */
62  virtual void computeGlobalGridIndexFromGlobalIndexElement(int destGlobalIndex,
63                                                        const std::vector<int>& srcGlobalIndex,
64                                                        const std::vector<int>& destGlobalIndexPositionInGrid,
65                                                        int elementPositionInGrid,
66                                                        const std::vector<int>& gridDestGlobalDim,
67                                                        const std::vector<int>& gridSrcGlobalDim,
68                                                        const GlobalLocalMap& globalLocalIndexDestSendToServerMap,
69                                                        std::vector<std::pair<size_t,int> >& globalLocalIndexDestMap,
70                                                        std::vector<std::vector<size_t> >& globalIndexSrcGrid) = 0;
71
72  virtual void computeIndexSourceMapping_(const std::vector<CArray<double,1>* >&) = 0;
73
74protected:
75  typedef boost::unordered_map<int, std::vector<int> > TransformationIndexMap;
76  typedef boost::unordered_map<int, std::vector<double> > TransformationWeightMap;
77  typedef boost::unordered_map<int, std::vector<int> > TransformationPositionMap;
78
79  //! Map between global index of destination element and source element
80  std::vector<TransformationIndexMap> transformationMapping_;
81  //! Weight corresponding of source to destination
82  std::vector<TransformationWeightMap> transformationWeight_;
83  //! Map of global index of destination element and corresponding global index of other elements in the same grid
84  //! By default, one index of an element corresponds to all index of remaining element in the grid. So it's empty
85  std::vector<TransformationPositionMap> transformationPosition_;
86
87  //! Id of auxillary inputs which help doing transformation dynamically
88  std::vector<StdString> idAuxInputs_;
89};
90
91}
92#endif // __XIOS_GENERIC_ALGORITHM_TRANSFORMATION_HPP__
Note: See TracBrowser for help on using the repository browser.