1 | /*! |
---|
2 | \file grid_transformation.hpp |
---|
3 | \author Ha NGUYEN |
---|
4 | \since 14 May 2015 |
---|
5 | \date 09 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 | |
---|
18 | namespace xios { |
---|
19 | |
---|
20 | class CGrid; |
---|
21 | |
---|
22 | /*! |
---|
23 | \class CGridTransformation |
---|
24 | This class is an interface for all transformations to interact with the rest of XIOS. |
---|
25 | The class, firstly, tries to get all information relating to requested transformations by retrieving directly from grid. |
---|
26 | Then with all these information, all necessary transformations will be be created by generic class \class CGenericAlgorithmTransformation. |
---|
27 | Because there are information exchange among clients to accomplish the transformations (e.g: some index need retrieving from other clients), |
---|
28 | this class uses class \class CTransformationMapping to fulfill this demand. |
---|
29 | For each transformation, a new temporary grid source is created. |
---|
30 | For a consequential transformations (e.g: inversing -> zoom -> inversing -> ...), |
---|
31 | the grid destination of current transformation will be grid source of the next transformation |
---|
32 | */ |
---|
33 | class CGridTransformation |
---|
34 | { |
---|
35 | public: |
---|
36 | /** Default constructor */ |
---|
37 | CGridTransformation(CGrid* destination, CGrid* source); |
---|
38 | ~CGridTransformation(); |
---|
39 | |
---|
40 | void computeAll(); |
---|
41 | |
---|
42 | |
---|
43 | std::map<int, CArray<int,1>* > getLocalIndexToSendFromGridSource(); |
---|
44 | std::map<int, std::vector<CArray<int,1>* > > getLocalIndexToReceiveOnGridDest(); |
---|
45 | |
---|
46 | private: |
---|
47 | void computeTransformation(); |
---|
48 | void initializeAlgorithms(); |
---|
49 | void initializeAxisAlgorithms(); |
---|
50 | void initializeDomainAlgorithms(); |
---|
51 | void initializeMappingOfOriginalGridSource(); |
---|
52 | |
---|
53 | void selectAxisAlgo(int elementPositionInGrid, ETranformationType transType, int transformationOrder); |
---|
54 | void selectDomainAlgo(int elementPositionInGrid, ETranformationType transType, int transformationOrder); |
---|
55 | void selectAlgo(int elementPositionInGrid, ETranformationType transType, int transformationOrder); |
---|
56 | void setUpGrid(int elementPositionInGrid, ETranformationType transType); |
---|
57 | void computeFinalTransformationMapping(); |
---|
58 | void computeTransformationFromOriginalGridSource(const std::map<size_t, std::set<size_t> >& globaIndexMapFromDestToSource); |
---|
59 | void updateFinalGridDestination(); |
---|
60 | |
---|
61 | private: |
---|
62 | //! Grid source on transformation |
---|
63 | CGrid* gridSource_; |
---|
64 | |
---|
65 | //! Grid destination on transformation |
---|
66 | CGrid* gridDestination_; |
---|
67 | |
---|
68 | //! The grid source of the first transformation (original grid source) |
---|
69 | CGrid* originalGridSource_; |
---|
70 | |
---|
71 | //! Grid source dimension size |
---|
72 | std::vector<int> gridSourceDimensionSize_; |
---|
73 | |
---|
74 | //! Grid destination dimension size |
---|
75 | std::vector<int> gridDestinationDimensionSize_; |
---|
76 | |
---|
77 | private: |
---|
78 | typedef std::list<std::pair<int,std::pair<ETranformationType,int> > > ListAlgoType; |
---|
79 | //! List of algorithm types and their order |
---|
80 | ListAlgoType listAlgos_; |
---|
81 | |
---|
82 | // Mapping between position of an element in grid and its transformation (if any) |
---|
83 | std::list<CGenericAlgorithmTransformation*> algoTransformation_; |
---|
84 | |
---|
85 | //! Mapping of (grid) global index representing tranformation. |
---|
86 | std::map<size_t, std::set<size_t> > globaIndexMapFromDestToSource_; |
---|
87 | |
---|
88 | //! Local index of data to send from grid source |
---|
89 | std::map<int, CArray<int,1>* > localIndexToSendFromGridSource_; |
---|
90 | |
---|
91 | //! Local index of data to receive on grid destination |
---|
92 | std::map<int, std::vector<CArray<int,1>* > > localIndexToReceiveOnGridDest_; |
---|
93 | |
---|
94 | //! Position of axis and domain in grid |
---|
95 | std::map<int, int> elementPosition2AxisPositionInGrid_, elementPosition2DomainPositionInGrid_; |
---|
96 | |
---|
97 | //! (Grid) Global index of grid source |
---|
98 | CArray<size_t,1>* globalIndexOfCurrentGridSource_; |
---|
99 | CArray<size_t,1>* globalIndexOfOriginalGridSource_; |
---|
100 | }; |
---|
101 | |
---|
102 | } |
---|
103 | #endif // __XIOS_GRID_TRANSFORMATION_HPP__ |
---|