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

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

Various clean up

+) Remove some redundant codes

Test
+) On Curie
+) tests pass

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