[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 |
---|
| 24 | This class is a helper class to chose a algorithm (transformation) from the alogrithm list of |
---|
| 25 | specific grid. |
---|
| 26 | */ |
---|
| 27 | class CGridTransformationSelector |
---|
| 28 | { |
---|
| 29 | public: |
---|
| 30 | typedef std::list<std::pair<int,std::pair<ETranformationType,int> > > ListAlgoType; |
---|
| 31 | protected: |
---|
| 32 | enum AlgoType { |
---|
| 33 | scalarType = 0, axisType = 1, domainType = 2 |
---|
| 34 | }; |
---|
| 35 | |
---|
[889] | 36 | protected: |
---|
| 37 | enum TransformationType { |
---|
| 38 | special = 0, normal = 1 |
---|
| 39 | }; |
---|
| 40 | |
---|
[887] | 41 | public: |
---|
| 42 | /** Default constructor */ |
---|
[889] | 43 | CGridTransformationSelector(CGrid* destination, CGrid* source, TransformationType type = normal); |
---|
[887] | 44 | virtual ~CGridTransformationSelector(); |
---|
| 45 | |
---|
| 46 | ListAlgoType getAlgoList() const { return listAlgos_; } |
---|
| 47 | int getNbAlgo() { return nbNormalAlgos_; } |
---|
| 48 | const std::vector<StdString>& getAuxInputs() const { return auxInputs_; } |
---|
[888] | 49 | const std::vector<CGenericAlgorithmTransformation*>& getAlgos() const { return algoTransformation_; } |
---|
[887] | 50 | |
---|
| 51 | protected: |
---|
| 52 | void initializeAlgorithms(); |
---|
| 53 | void initializeDomainAlgorithms(int domPositionInGrid); |
---|
| 54 | void initializeAxisAlgorithms(int axisPositionInGrid); |
---|
| 55 | void initializeScalarAlgorithms(int scalarPositionInGrid); |
---|
[889] | 56 | void initializeTransformations(TransformationType type); |
---|
[887] | 57 | void selectAlgo(int elementPositionInGrid, ETranformationType transType, int transformationOrder, AlgoType algo); |
---|
| 58 | bool isSpecialTransformation(ETranformationType transType); |
---|
| 59 | |
---|
| 60 | protected: |
---|
| 61 | virtual void selectScalarAlgo(int elementPositionInGrid, ETranformationType transType, int transformationOrder) = 0; |
---|
| 62 | virtual void selectAxisAlgo(int elementPositionInGrid, ETranformationType transType, int transformationOrder) = 0; |
---|
| 63 | virtual void selectDomainAlgo(int elementPositionInGrid, ETranformationType transType, int transformationOrder) = 0; |
---|
| 64 | |
---|
| 65 | protected: |
---|
| 66 | //! Grid source on transformation |
---|
| 67 | CGrid* gridSource_; |
---|
| 68 | |
---|
| 69 | //! Grid destination on transformation |
---|
| 70 | CGrid* gridDestination_; |
---|
| 71 | |
---|
[897] | 72 | //! Grid source and grid destination it's the same |
---|
| 73 | bool isSameGrid_; |
---|
| 74 | |
---|
[887] | 75 | protected: |
---|
| 76 | //! List of algorithm types and their order |
---|
| 77 | ListAlgoType listAlgos_; |
---|
| 78 | |
---|
| 79 | //! Number of normal algorithm |
---|
| 80 | int nbNormalAlgos_; |
---|
| 81 | |
---|
| 82 | //! Number of special algorithms (such as generate_rectilinear_grid) |
---|
| 83 | int nbSpecialAlgos_; |
---|
| 84 | |
---|
| 85 | // true if domain algorithm and false if axis algorithm (can be replaced by tuple with listAlgos_ |
---|
| 86 | std::vector<AlgoType> algoTypes_; |
---|
| 87 | |
---|
| 88 | // Mapping between position of an element in grid and its transformation (if any) |
---|
| 89 | std::vector<CGenericAlgorithmTransformation*> algoTransformation_; |
---|
| 90 | |
---|
[888] | 91 | //! Position of scalar, axis and domain in grid |
---|
[887] | 92 | std::map<int, int> elementPositionInGridSrc2AxisPosition_, elementPositionInGridSrc2DomainPosition_, elementPositionInGridSrc2ScalarPosition_; |
---|
| 93 | std::map<int, int> elementPositionInGridDst2AxisPosition_, elementPositionInGridDst2DomainPosition_, elementPositionInGridDst2ScalarPosition_; |
---|
| 94 | |
---|
| 95 | std::vector<StdString> auxInputs_; |
---|
| 96 | std::set<Time> timeStamp_; //! Time stamps for auxillary inputs |
---|
| 97 | }; |
---|
| 98 | |
---|
| 99 | } |
---|
| 100 | #endif // __XIOS_GRID_TRANSFORMATION_SELECTOR_HPP__ |
---|