source: XIOS/trunk/src/transformation/grid_transformation.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: 5.1 KB
Line 
1/*!
2   \file grid_transformation.hpp
3   \author Ha NGUYEN
4   \since 14 May 2015
5   \date 26 Aug 2015
6
7   \brief Interface for all transformations.
8 */
9#ifndef __XIOS_GRID_TRANSFORMATION_HPP__
10#define __XIOS_GRID_TRANSFORMATION_HPP__
11
12#include <map>
13#include <vector>
14#include "grid.hpp"
15#include "generic_algorithm_transformation.hpp"
16#include "transformation_enum.hpp"
17#include "duration.hpp"
18
19namespace xios {
20
21class CGrid;
22
23/*!
24  \class CGridTransformation
25  This class is an interface for all transformations to interact with the rest of XIOS.
26The class, firstly, tries to get all information relating to requested transformations by retrieving directly from grid.
27Then with all these information, all necessary transformations will be created by generic class \class CGenericAlgorithmTransformation.
28Because there are information exchange among clients to accomplish the transformations (e.g: some index need retrieving from other clients),
29this class uses class \class CTransformationMapping to fulfill this demand.
30For each transformation, a new temporary grid source is created.
31For a consequential transformations (e.g: inversing -> zoom -> inversing -> ...),
32the grid destination of current transformation will be grid source of the next transformation
33*/
34class CGridTransformation
35{
36public:
37  typedef std::list<std::pair<int,std::pair<ETranformationType,int> > > ListAlgoType;
38  typedef boost::unordered_map<size_t, std::vector<std::pair<int, std::pair<size_t,double> > > > DestinationIndexMap;
39  typedef std::map<int, CArray<int,1> > SendingIndexGridSourceMap;
40  typedef std::map<int,std::vector<std::pair<int,double> > > RecvIndexGridDestinationMap;
41//  typedef std::map<int,std::vector<std::vector<std::pair<int,double> > > > RecvIndexGridDestinationMap;
42
43public:
44  /** Default constructor */
45  CGridTransformation(CGrid* destination, CGrid* source);
46  ~CGridTransformation();
47
48  void computeAll(const std::vector<CArray<double,1>* >& dataAuxInput=std::vector<CArray<double,1>* >(), Time timeStamp = 0);
49
50  const std::list<SendingIndexGridSourceMap>& getLocalIndexToSendFromGridSource() const;
51  const std::list<RecvIndexGridDestinationMap>& getLocalIndexToReceiveOnGridDest() const;
52  const std::list<size_t>& getNbLocalIndexToReceiveOnGridDest() const;
53
54  CGrid* getGridSource() { return originalGridSource_; }
55  CGrid* getGridDestination() { return gridDestination_; }
56  ListAlgoType getAlgoList() const {return listAlgos_; }
57  int getNbAlgo() { return nbAlgos_; }
58  const std::vector<StdString>& getAuxInputs() const { return auxInputs_; }
59
60protected:
61  void computeTransformation();
62  void initializeAlgorithms();
63  void initializeAxisAlgorithms(int axisPositionInGrid);
64  void initializeDomainAlgorithms(int domPositionInGrid);
65  void initializeMappingOfOriginalGridSource();
66
67  void selectAxisAlgo(int elementPositionInGrid, ETranformationType transType, int transformationOrder);
68  void selectDomainAlgo(int elementPositionInGrid, ETranformationType transType, int transformationOrder);
69  void selectAlgo(int elementPositionInGrid, ETranformationType transType, int transformationOrder, bool isDomainAlgo);
70  void setUpGrid(int elementPositionInGrid, ETranformationType transType, int nbTransformation);
71//  void computeFinalTransformationMapping();
72//  void computeTransformationFromOriginalGridSource(const DestinationIndexMap& globaIndexMapFromDestToSource);
73  void computeTransformationMapping(const DestinationIndexMap& globalIndexWeightFromDestToSource);
74//  void updateFinalGridDestination();
75  bool isSpecialTransformation(ETranformationType transType);
76
77protected:
78  //! Grid source on transformation
79  CGrid* gridSource_;
80
81  //! Grid destination on transformation
82  CGrid* gridDestination_;
83
84  //! The grid source of the first transformation (original grid source)
85  CGrid* originalGridSource_;
86
87protected:
88  //! List of algorithm types and their order
89  ListAlgoType listAlgos_;
90
91  //! Number of algorithm
92  int nbAlgos_;
93
94  // true if domain algorithm and false if axis algorithm (can be replaced by tuple with listAlgos_
95  std::vector<bool> algoTypes_;
96
97  // Mapping between position of an element in grid and its transformation (if any)
98  std::vector<CGenericAlgorithmTransformation*> algoTransformation_;
99
100  //! Mapping of (grid) global index representing tranformation.
101  std::map<size_t, std::set<size_t> > globaIndexMapFromDestToSource_;
102
103  //! Local index of data to send from grid source
104  std::list<SendingIndexGridSourceMap> localIndexToSendFromGridSource_;
105
106  //! Local index of data to receive on grid destination
107  std::list<RecvIndexGridDestinationMap> localIndexToReceiveOnGridDest_;
108
109  //! Number of local index of data to receive on grid destination
110  std::list<size_t> nbLocalIndexOnGridDest_;
111
112  //! Position of axis and domain in grid
113  std::map<int, int> elementPosition2AxisPositionInGrid_, elementPosition2DomainPositionInGrid_;
114
115  //! (Grid) Global index of grid source
116  DestinationIndexMap currentGridIndexToOriginalGridIndex_;
117
118  std::vector<CGrid*> tempGrids_;
119  std::vector<StdString> auxInputs_;
120  bool dynamicalTransformation_;
121
122  std::set<Time> timeStamp_; //! Time stamps for auxillary inputs
123};
124
125}
126#endif // __XIOS_GRID_TRANSFORMATION_HPP__
Note: See TracBrowser for help on using the repository browser.