[887] | 1 | /*! |
---|
| 2 | \file grid_transformation.hpp |
---|
| 3 | \author Ha NGUYEN |
---|
| 4 | \since 23 June 2016 |
---|
| 5 | \date 23 June 2016 |
---|
| 6 | |
---|
| 7 | \brief Helper class to select different transformations. |
---|
| 8 | */ |
---|
| 9 | #ifndef __XIOS_GRID_TRANSFORMATION_SELECTOR_HPP__ |
---|
| 10 | #define __XIOS_GRID_TRANSFORMATION_SELECTOR_HPP__ |
---|
| 11 | |
---|
| 12 | #include <map> |
---|
| 13 | #include <vector> |
---|
| 14 | #include "generic_algorithm_transformation.hpp" |
---|
| 15 | #include "transformation_enum.hpp" |
---|
| 16 | #include "duration.hpp" |
---|
| 17 | |
---|
| 18 | namespace xios { |
---|
| 19 | |
---|
| 20 | class CGrid; |
---|
| 21 | |
---|
| 22 | /*! |
---|
| 23 | \class CGridTransformationSelector |
---|
[933] | 24 | This class is a helper class to chose a algorithm (transformation) from the algorithm list of |
---|
[887] | 25 | specific grid. |
---|
| 26 | */ |
---|
| 27 | class CGridTransformationSelector |
---|
| 28 | { |
---|
| 29 | public: |
---|
[978] | 30 | // Stupid C++98, should be replaced with tuple. |
---|
| 31 | // List of algorithm to process. Order of element in this list |
---|
| 32 | // <Position of element in grid, <transformationType, <transformation order, alogrithm type> > > |
---|
| 33 | typedef std::list<std::pair<int,std::pair<ETranformationType,std::pair<int,int> > > > ListAlgoType; |
---|
[887] | 34 | protected: |
---|
| 35 | enum AlgoType { |
---|
| 36 | scalarType = 0, axisType = 1, domainType = 2 |
---|
| 37 | }; |
---|
| 38 | |
---|
[889] | 39 | protected: |
---|
| 40 | enum TransformationType { |
---|
| 41 | special = 0, normal = 1 |
---|
| 42 | }; |
---|
| 43 | |
---|
[887] | 44 | public: |
---|
| 45 | /** Default constructor */ |
---|
[889] | 46 | CGridTransformationSelector(CGrid* destination, CGrid* source, TransformationType type = normal); |
---|
[887] | 47 | virtual ~CGridTransformationSelector(); |
---|
| 48 | |
---|
| 49 | ListAlgoType getAlgoList() const { return listAlgos_; } |
---|
| 50 | int getNbAlgo() { return nbNormalAlgos_; } |
---|
| 51 | const std::vector<StdString>& getAuxInputs() const { return auxInputs_; } |
---|
[888] | 52 | const std::vector<CGenericAlgorithmTransformation*>& getAlgos() const { return algoTransformation_; } |
---|
[1275] | 53 | const std::map<int, int> getElementPositionInGridSrc2AxisPosition() const { return elementPositionInGridSrc2AxisPosition_ ;} |
---|
| 54 | const std::map<int, int> getElementPositionInGridSrc2DomainPosition() const { return elementPositionInGridSrc2DomainPosition_ ;} |
---|
| 55 | const std::map<int, int> getElementPositionInGridSrc2ScalarPosition() const { return elementPositionInGridSrc2ScalarPosition_ ;} |
---|
| 56 | const std::map<int, int> getElementPositionInGridDst2AxisPosition() const { return elementPositionInGridDst2AxisPosition_ ;} |
---|
| 57 | const std::map<int, int> getElementPositionInGridDst2DomainPosition() const { return elementPositionInGridDst2DomainPosition_ ;} |
---|
| 58 | const std::map<int, int> getElementPositionInGridDst2ScalarPosition() const { return elementPositionInGridDst2ScalarPosition_ ;} |
---|
[887] | 59 | |
---|
[1275] | 60 | |
---|
[887] | 61 | protected: |
---|
[978] | 62 | void updateElementPosition(); |
---|
[887] | 63 | void initializeAlgorithms(); |
---|
| 64 | void initializeDomainAlgorithms(int domPositionInGrid); |
---|
| 65 | void initializeAxisAlgorithms(int axisPositionInGrid); |
---|
| 66 | void initializeScalarAlgorithms(int scalarPositionInGrid); |
---|
[889] | 67 | void initializeTransformations(TransformationType type); |
---|
[978] | 68 | void selectAlgo(int elementPositionInGrid, ETranformationType transType, int transformationOrder, int algo); |
---|
[887] | 69 | bool isSpecialTransformation(ETranformationType transType); |
---|
[933] | 70 | void registerTransformations(); |
---|
[887] | 71 | |
---|
| 72 | protected: |
---|
| 73 | virtual void selectScalarAlgo(int elementPositionInGrid, ETranformationType transType, int transformationOrder) = 0; |
---|
| 74 | virtual void selectAxisAlgo(int elementPositionInGrid, ETranformationType transType, int transformationOrder) = 0; |
---|
| 75 | virtual void selectDomainAlgo(int elementPositionInGrid, ETranformationType transType, int transformationOrder) = 0; |
---|
| 76 | |
---|
| 77 | protected: |
---|
| 78 | //! Grid source on transformation |
---|
| 79 | CGrid* gridSource_; |
---|
| 80 | |
---|
| 81 | //! Grid destination on transformation |
---|
| 82 | CGrid* gridDestination_; |
---|
| 83 | |
---|
[897] | 84 | //! Grid source and grid destination it's the same |
---|
| 85 | bool isSameGrid_; |
---|
| 86 | |
---|
[887] | 87 | protected: |
---|
| 88 | //! List of algorithm types and their order |
---|
| 89 | ListAlgoType listAlgos_; |
---|
| 90 | |
---|
| 91 | //! Number of normal algorithm |
---|
| 92 | int nbNormalAlgos_; |
---|
| 93 | |
---|
| 94 | //! Number of special algorithms (such as generate_rectilinear_grid) |
---|
| 95 | int nbSpecialAlgos_; |
---|
| 96 | |
---|
| 97 | // true if domain algorithm and false if axis algorithm (can be replaced by tuple with listAlgos_ |
---|
| 98 | std::vector<AlgoType> algoTypes_; |
---|
| 99 | |
---|
| 100 | // Mapping between position of an element in grid and its transformation (if any) |
---|
| 101 | std::vector<CGenericAlgorithmTransformation*> algoTransformation_; |
---|
| 102 | |
---|
[888] | 103 | //! Position of scalar, axis and domain in grid |
---|
[887] | 104 | std::map<int, int> elementPositionInGridSrc2AxisPosition_, elementPositionInGridSrc2DomainPosition_, elementPositionInGridSrc2ScalarPosition_; |
---|
| 105 | std::map<int, int> elementPositionInGridDst2AxisPosition_, elementPositionInGridDst2DomainPosition_, elementPositionInGridDst2ScalarPosition_; |
---|
| 106 | |
---|
| 107 | std::vector<StdString> auxInputs_; |
---|
| 108 | std::set<Time> timeStamp_; //! Time stamps for auxillary inputs |
---|
| 109 | }; |
---|
| 110 | |
---|
| 111 | } |
---|
| 112 | #endif // __XIOS_GRID_TRANSFORMATION_SELECTOR_HPP__ |
---|