[623] | 1 | /*! |
---|
| 2 | \file grid_transformation.hpp |
---|
| 3 | \author Ha NGUYEN |
---|
| 4 | \since 14 May 2015 |
---|
[624] | 5 | \date 18 June 2015 |
---|
[623] | 6 | |
---|
| 7 | \brief Interface for all transformations. |
---|
| 8 | */ |
---|
[620] | 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" |
---|
[622] | 16 | #include "transformation_enum.hpp" |
---|
[620] | 17 | |
---|
| 18 | namespace xios { |
---|
| 19 | |
---|
| 20 | class CGrid; |
---|
| 21 | |
---|
[623] | 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. |
---|
[630] | 26 | Then with all these information, all necessary transformations will be created by generic class \class CGenericAlgorithmTransformation. |
---|
[623] | 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 | */ |
---|
[620] | 33 | class CGridTransformation |
---|
| 34 | { |
---|
| 35 | public: |
---|
| 36 | /** Default constructor */ |
---|
| 37 | CGridTransformation(CGrid* destination, CGrid* source); |
---|
| 38 | ~CGridTransformation(); |
---|
| 39 | |
---|
[622] | 40 | void computeAll(); |
---|
| 41 | |
---|
[653] | 42 | const std::map<int, CArray<int,1> >& getLocalIndexToSendFromGridSource() const; |
---|
[630] | 43 | const std::map<int, std::vector<std::vector<std::pair<int,double> > > >& getLocalIndexToReceiveOnGridDest() const; |
---|
[632] | 44 | CGrid* getGridSource() {return gridSource_; } |
---|
| 45 | CGrid* getGridDestination() { return gridDestination_; } |
---|
[622] | 46 | |
---|
[620] | 47 | private: |
---|
| 48 | void computeTransformation(); |
---|
| 49 | void initializeAlgorithms(); |
---|
[631] | 50 | void initializeAxisAlgorithms(int axisPositionInGrid); |
---|
| 51 | void initializeDomainAlgorithms(int domPositionInGrid); |
---|
[622] | 52 | void initializeMappingOfOriginalGridSource(); |
---|
[620] | 53 | |
---|
[622] | 54 | void selectAxisAlgo(int elementPositionInGrid, ETranformationType transType, int transformationOrder); |
---|
| 55 | void selectDomainAlgo(int elementPositionInGrid, ETranformationType transType, int transformationOrder); |
---|
[631] | 56 | void selectAlgo(int elementPositionInGrid, ETranformationType transType, int transformationOrder, bool isDomainAlgo); |
---|
[622] | 57 | void setUpGrid(int elementPositionInGrid, ETranformationType transType); |
---|
| 58 | void computeFinalTransformationMapping(); |
---|
[630] | 59 | void computeTransformationFromOriginalGridSource(const std::map<size_t, std::vector<std::pair<size_t,double> > >& globaIndexMapFromDestToSource); |
---|
[623] | 60 | void updateFinalGridDestination(); |
---|
[622] | 61 | |
---|
[620] | 62 | private: |
---|
[623] | 63 | //! Grid source on transformation |
---|
[620] | 64 | CGrid* gridSource_; |
---|
[623] | 65 | |
---|
| 66 | //! Grid destination on transformation |
---|
[620] | 67 | CGrid* gridDestination_; |
---|
[623] | 68 | |
---|
| 69 | //! The grid source of the first transformation (original grid source) |
---|
[622] | 70 | CGrid* originalGridSource_; |
---|
[620] | 71 | |
---|
[623] | 72 | //! Grid source dimension size |
---|
[620] | 73 | std::vector<int> gridSourceDimensionSize_; |
---|
[623] | 74 | |
---|
| 75 | //! Grid destination dimension size |
---|
[620] | 76 | std::vector<int> gridDestinationDimensionSize_; |
---|
| 77 | |
---|
[622] | 78 | private: |
---|
| 79 | typedef std::list<std::pair<int,std::pair<ETranformationType,int> > > ListAlgoType; |
---|
[623] | 80 | //! List of algorithm types and their order |
---|
| 81 | ListAlgoType listAlgos_; |
---|
[631] | 82 | // true if domain algorithm and false if axis algorithm (can be replaced by tuple with listAlgos_ |
---|
| 83 | std::vector<bool> algoTypes_; |
---|
[622] | 84 | |
---|
[620] | 85 | // Mapping between position of an element in grid and its transformation (if any) |
---|
[622] | 86 | std::list<CGenericAlgorithmTransformation*> algoTransformation_; |
---|
[623] | 87 | |
---|
| 88 | //! Mapping of (grid) global index representing tranformation. |
---|
[620] | 89 | std::map<size_t, std::set<size_t> > globaIndexMapFromDestToSource_; |
---|
| 90 | |
---|
[623] | 91 | //! Local index of data to send from grid source |
---|
[653] | 92 | std::map<int, CArray<int,1> > localIndexToSendFromGridSource_; |
---|
[623] | 93 | |
---|
| 94 | //! Local index of data to receive on grid destination |
---|
[630] | 95 | std::map<int,std::vector<std::vector<std::pair<int,double> > > > localIndexToReceiveOnGridDest_; |
---|
[622] | 96 | |
---|
[623] | 97 | //! Position of axis and domain in grid |
---|
[622] | 98 | std::map<int, int> elementPosition2AxisPositionInGrid_, elementPosition2DomainPositionInGrid_; |
---|
| 99 | |
---|
[623] | 100 | //! (Grid) Global index of grid source |
---|
[653] | 101 | CArray<size_t,1> globalIndexOfCurrentGridSource_; |
---|
| 102 | CArray<size_t,1> globalIndexOfOriginalGridSource_; |
---|
| 103 | CArray<double,1> weightOfGlobalIndexOfOriginalGridSource_; |
---|
[620] | 104 | }; |
---|
| 105 | |
---|
| 106 | } |
---|
| 107 | #endif // __XIOS_GRID_TRANSFORMATION_HPP__ |
---|