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

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

Making some improvements of transformation algorithm

+) Correct the way to enlisting transformations in an element (domain, axis)
+) Optimize generic transformation to make sure temporary grid to be created on demand
+) Update some mpi tag to prevent conflict
+) Correct some minor stuffs
+) Update documents

Test
+) On Curie
+) all test pass

File size: 4.2 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
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.
26Then with all these information, all necessary transformations will be created by generic class \class CGenericAlgorithmTransformation.
27Because there are information exchange among clients to accomplish the transformations (e.g: some index need retrieving from other clients),
28this class uses class \class CTransformationMapping to fulfill this demand.
29For each transformation, a new temporary grid source is created.
30For a consequential transformations (e.g: inversing -> zoom -> inversing -> ...),
31the grid destination of current transformation will be grid source of the next transformation
32*/
33class CGridTransformation
34{
35public:
36  typedef std::list<std::pair<int,std::pair<ETranformationType,int> > > ListAlgoType;
37
38public:
39  /** Default constructor */
40  CGridTransformation(CGrid* destination, CGrid* source);
41  ~CGridTransformation();
42
43  void computeAll();
44
45  const std::map<int, CArray<int,1> >& getLocalIndexToSendFromGridSource() const;
46  const std::map<int, std::vector<std::vector<std::pair<int,double> > > >& getLocalIndexToReceiveOnGridDest() const;
47  CGrid* getGridSource() { return originalGridSource_; }
48  CGrid* getGridDestination() { return gridDestination_; }
49  ListAlgoType getAlgoList() const {return listAlgos_; }
50
51protected:
52  void computeTransformation();
53  void initializeAlgorithms();
54  void initializeAxisAlgorithms(int axisPositionInGrid);
55  void initializeDomainAlgorithms(int domPositionInGrid);
56  void initializeMappingOfOriginalGridSource();
57
58  void selectAxisAlgo(int elementPositionInGrid, ETranformationType transType, int transformationOrder);
59  void selectDomainAlgo(int elementPositionInGrid, ETranformationType transType, int transformationOrder);
60  void selectAlgo(int elementPositionInGrid, ETranformationType transType, int transformationOrder, bool isDomainAlgo);
61  void setUpGrid(int elementPositionInGrid, ETranformationType transType);
62  void computeFinalTransformationMapping();
63  void computeTransformationFromOriginalGridSource(const std::map<size_t, std::vector<std::pair<size_t,double> > >& globaIndexMapFromDestToSource);
64  void updateFinalGridDestination();
65  bool isSpecialTransformation(ETranformationType transType);
66
67protected:
68  //! Grid source on transformation
69  CGrid* gridSource_;
70
71  //! Grid destination on transformation
72  CGrid* gridDestination_;
73
74  //! The grid source of the first transformation (original grid source)
75  CGrid* originalGridSource_;
76
77protected:
78  //! List of algorithm types and their order
79  ListAlgoType listAlgos_;
80
81  //! Number of algorithm
82  int nbAlgos_;
83
84  typedef std::map<size_t, std::vector<std::pair<size_t,double> > > GlobalIndexMap;
85
86  // true if domain algorithm and false if axis algorithm (can be replaced by tuple with listAlgos_
87  std::vector<bool> algoTypes_;
88
89  // Mapping between position of an element in grid and its transformation (if any)
90  std::list<CGenericAlgorithmTransformation*> algoTransformation_;
91
92  //! Mapping of (grid) global index representing tranformation.
93  std::map<size_t, std::set<size_t> > globaIndexMapFromDestToSource_;
94
95  //! Local index of data to send from grid source
96  std::map<int, CArray<int,1> > localIndexToSendFromGridSource_;
97
98  //! Local index of data to receive on grid destination
99  std::map<int,std::vector<std::vector<std::pair<int,double> > > > localIndexToReceiveOnGridDest_;
100
101  //! Position of axis and domain in grid
102  std::map<int, int> elementPosition2AxisPositionInGrid_, elementPosition2DomainPositionInGrid_;
103
104  //! (Grid) Global index of grid source
105  GlobalIndexMap currentGridIndexToOriginalGridIndex_;
106};
107
108}
109#endif // __XIOS_GRID_TRANSFORMATION_HPP__
Note: See TracBrowser for help on using the repository browser.