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

Last change on this file since 624 was 624, checked in by mhnguyen, 9 years ago

Final tests of zoom and inverse on axis

+) Modify test_client and test_complete to work with new grid definition
+) Correct some bugs causing memory leak
+) Clean abundant code
+) Add more comments to new files

Test
+) On Curie
+) test_client and test_complete pass with correct results

File size: 3.8 KB
Line 
1/*!
2   \file grid_transformation.hpp
3   \author Ha NGUYEN
4   \since 14 May 2015
5   \date 18 June 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 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  /** Default constructor */
37  CGridTransformation(CGrid* destination, CGrid* source);
38  ~CGridTransformation();
39
40  void computeAll();
41
42  const std::map<int, CArray<int,1>* >& getLocalIndexToSendFromGridSource() const;
43  const std::map<int, std::vector<CArray<int,1>* > >& getLocalIndexToReceiveOnGridDest() const;
44
45private:
46  void computeTransformation();
47  void initializeAlgorithms();
48  void initializeAxisAlgorithms();
49  void initializeDomainAlgorithms();
50  void initializeMappingOfOriginalGridSource();
51
52  void selectAxisAlgo(int elementPositionInGrid, ETranformationType transType, int transformationOrder);
53  void selectDomainAlgo(int elementPositionInGrid, ETranformationType transType, int transformationOrder);
54  void selectAlgo(int elementPositionInGrid, ETranformationType transType, int transformationOrder);
55  void setUpGrid(int elementPositionInGrid, ETranformationType transType);
56  void computeFinalTransformationMapping();
57  void computeTransformationFromOriginalGridSource(const std::map<size_t, std::set<size_t> >& globaIndexMapFromDestToSource);
58  void updateFinalGridDestination();
59
60private:
61  //! Grid source on transformation
62  CGrid* gridSource_;
63
64  //! Grid destination on transformation
65  CGrid* gridDestination_;
66
67  //! The grid source of the first transformation (original grid source)
68  CGrid* originalGridSource_;
69
70  //! Grid source dimension size
71  std::vector<int> gridSourceDimensionSize_;
72
73  //! Grid destination dimension size
74  std::vector<int> gridDestinationDimensionSize_;
75
76private:
77  typedef std::list<std::pair<int,std::pair<ETranformationType,int> > > ListAlgoType;
78  //! List of algorithm types and their order
79  ListAlgoType listAlgos_;
80
81  // Mapping between position of an element in grid and its transformation (if any)
82  std::list<CGenericAlgorithmTransformation*> algoTransformation_;
83
84  //! Mapping of (grid) global index representing tranformation.
85  std::map<size_t, std::set<size_t> > globaIndexMapFromDestToSource_;
86
87  //! Local index of data to send from grid source
88  std::map<int, CArray<int,1>* > localIndexToSendFromGridSource_;
89
90  //! Local index of data to receive on grid destination
91  std::map<int, std::vector<CArray<int,1>* > > localIndexToReceiveOnGridDest_;
92
93  //! Position of axis and domain in grid
94  std::map<int, int> elementPosition2AxisPositionInGrid_, elementPosition2DomainPositionInGrid_;
95
96  //! (Grid) Global index of grid source
97  CArray<size_t,1>* globalIndexOfCurrentGridSource_;
98  CArray<size_t,1>* globalIndexOfOriginalGridSource_;
99};
100
101}
102#endif // __XIOS_GRID_TRANSFORMATION_HPP__
Note: See TracBrowser for help on using the repository browser.