source: XIOS/trunk/src/transformation/grid_transformation.hpp @ 841

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

Changing the way to create virtual grid during transformation.

+)Instead of establishing relation between source grid of current transformation and
the original source grid (source grid of the first transformation), each transformation
keeps its list of source grid and destination, which will be used in interpolation.
+) Clean some redundant codes

Test
+) All official tests pass
+) interpolation tests pass

File size: 5.0 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::vector<std::pair<int,double> > > > RecvIndexGridDestinationMap;
41
42public:
43  /** Default constructor */
44  CGridTransformation(CGrid* destination, CGrid* source);
45  ~CGridTransformation();
46
47  void computeAll(const std::vector<CArray<double,1>* >& dataAuxInput=std::vector<CArray<double,1>* >(), Time timeStamp = 0);
48
49  const std::list<SendingIndexGridSourceMap>& getLocalIndexToSendFromGridSource() const;
50  const std::list<RecvIndexGridDestinationMap>& getLocalIndexToReceiveOnGridDest() const;
51  const std::list<size_t>& getNbLocalIndexToReceiveOnGridDest() const;
52
53  CGrid* getGridSource() { return originalGridSource_; }
54  CGrid* getGridDestination() { return gridDestination_; }
55  ListAlgoType getAlgoList() const {return listAlgos_; }
56  int getNbAlgo() { return nbAlgos_; }
57  const std::vector<StdString>& getAuxInputs() const { return auxInputs_; }
58
59protected:
60  void computeTransformation();
61  void initializeAlgorithms();
62  void initializeAxisAlgorithms(int axisPositionInGrid);
63  void initializeDomainAlgorithms(int domPositionInGrid);
64  void initializeMappingOfOriginalGridSource();
65
66  void selectAxisAlgo(int elementPositionInGrid, ETranformationType transType, int transformationOrder);
67  void selectDomainAlgo(int elementPositionInGrid, ETranformationType transType, int transformationOrder);
68  void selectAlgo(int elementPositionInGrid, ETranformationType transType, int transformationOrder, bool isDomainAlgo);
69  void setUpGrid(int elementPositionInGrid, ETranformationType transType, int nbTransformation);
70//  void computeFinalTransformationMapping();
71//  void computeTransformationFromOriginalGridSource(const DestinationIndexMap& globaIndexMapFromDestToSource);
72  void computeTransformationMapping(const DestinationIndexMap& globalIndexWeightFromDestToSource);
73//  void updateFinalGridDestination();
74  bool isSpecialTransformation(ETranformationType transType);
75
76protected:
77  //! Grid source on transformation
78  CGrid* gridSource_;
79
80  //! Grid destination on transformation
81  CGrid* gridDestination_;
82
83  //! The grid source of the first transformation (original grid source)
84  CGrid* originalGridSource_;
85
86protected:
87  //! List of algorithm types and their order
88  ListAlgoType listAlgos_;
89
90  //! Number of algorithm
91  int nbAlgos_;
92
93  // true if domain algorithm and false if axis algorithm (can be replaced by tuple with listAlgos_
94  std::vector<bool> algoTypes_;
95
96  // Mapping between position of an element in grid and its transformation (if any)
97  std::vector<CGenericAlgorithmTransformation*> algoTransformation_;
98
99  //! Mapping of (grid) global index representing tranformation.
100  std::map<size_t, std::set<size_t> > globaIndexMapFromDestToSource_;
101
102  //! Local index of data to send from grid source
103  std::list<SendingIndexGridSourceMap> localIndexToSendFromGridSource_;
104
105  //! Local index of data to receive on grid destination
106  std::list<RecvIndexGridDestinationMap> localIndexToReceiveOnGridDest_;
107
108  //! Number of local index of data to receive on grid destination
109  std::list<size_t> nbLocalIndexOnGridDest_;
110
111  //! Position of axis and domain in grid
112  std::map<int, int> elementPosition2AxisPositionInGrid_, elementPosition2DomainPositionInGrid_;
113
114  //! (Grid) Global index of grid source
115  DestinationIndexMap currentGridIndexToOriginalGridIndex_;
116
117  std::vector<CGrid*> tempGrids_;
118  std::vector<StdString> auxInputs_;
119  bool dynamicalTransformation_;
120
121  std::set<Time> timeStamp_; //! Time stamps for auxillary inputs
122};
123
124}
125#endif // __XIOS_GRID_TRANSFORMATION_HPP__
Note: See TracBrowser for help on using the repository browser.