[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: |
---|
| 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); |
---|
[933] | 59 | void registerTransformations(); |
---|
[887] | 60 | |
---|
| 61 | protected: |
---|
| 62 | virtual void selectScalarAlgo(int elementPositionInGrid, ETranformationType transType, int transformationOrder) = 0; |
---|
| 63 | virtual void selectAxisAlgo(int elementPositionInGrid, ETranformationType transType, int transformationOrder) = 0; |
---|
| 64 | virtual void selectDomainAlgo(int elementPositionInGrid, ETranformationType transType, int transformationOrder) = 0; |
---|
| 65 | |
---|
| 66 | protected: |
---|
| 67 | //! Grid source on transformation |
---|
| 68 | CGrid* gridSource_; |
---|
| 69 | |
---|
| 70 | //! Grid destination on transformation |
---|
| 71 | CGrid* gridDestination_; |
---|
| 72 | |
---|
[897] | 73 | //! Grid source and grid destination it's the same |
---|
| 74 | bool isSameGrid_; |
---|
| 75 | |
---|
[887] | 76 | protected: |
---|
| 77 | //! List of algorithm types and their order |
---|
| 78 | ListAlgoType listAlgos_; |
---|
| 79 | |
---|
| 80 | //! Number of normal algorithm |
---|
| 81 | int nbNormalAlgos_; |
---|
| 82 | |
---|
| 83 | //! Number of special algorithms (such as generate_rectilinear_grid) |
---|
| 84 | int nbSpecialAlgos_; |
---|
| 85 | |
---|
| 86 | // true if domain algorithm and false if axis algorithm (can be replaced by tuple with listAlgos_ |
---|
| 87 | std::vector<AlgoType> algoTypes_; |
---|
| 88 | |
---|
| 89 | // Mapping between position of an element in grid and its transformation (if any) |
---|
| 90 | std::vector<CGenericAlgorithmTransformation*> algoTransformation_; |
---|
| 91 | |
---|
[888] | 92 | //! Position of scalar, axis and domain in grid |
---|
[887] | 93 | std::map<int, int> elementPositionInGridSrc2AxisPosition_, elementPositionInGridSrc2DomainPosition_, elementPositionInGridSrc2ScalarPosition_; |
---|
| 94 | std::map<int, int> elementPositionInGridDst2AxisPosition_, elementPositionInGridDst2DomainPosition_, elementPositionInGridDst2ScalarPosition_; |
---|
| 95 | |
---|
| 96 | std::vector<StdString> auxInputs_; |
---|
| 97 | std::set<Time> timeStamp_; //! Time stamps for auxillary inputs |
---|
| 98 | }; |
---|
| 99 | |
---|
| 100 | } |
---|
| 101 | #endif // __XIOS_GRID_TRANSFORMATION_SELECTOR_HPP__ |
---|