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