source: XIOS/dev/XIOS_DEV_CMIP6/src/transformation/grid_transformation_selector.hpp

Last change on this file was 1275, checked in by ymipsl, 3 years ago

implement diurnal cycle transformation taken as a grid tranformation : scalar -> axis

YM

File size: 4.4 KB
Line 
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
18namespace xios {
19
20class CGrid;
21
22/*!
23  \class CGridTransformationSelector
24  This class is a helper class to chose a algorithm (transformation) from the algorithm list of
25specific grid.
26*/
27class CGridTransformationSelector
28{
29public:
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;
34protected:
35  enum AlgoType {
36    scalarType = 0, axisType = 1, domainType = 2
37  };
38
39protected:
40  enum TransformationType {
41    special = 0, normal = 1
42  };
43
44public:
45  /** Default constructor */
46  CGridTransformationSelector(CGrid* destination, CGrid* source, TransformationType type = normal);
47  virtual ~CGridTransformationSelector();
48
49  ListAlgoType getAlgoList() const { return listAlgos_; }
50  int getNbAlgo() { return nbNormalAlgos_; }
51  const std::vector<StdString>& getAuxInputs() const { return auxInputs_; }
52  const std::vector<CGenericAlgorithmTransformation*>& getAlgos() const { return algoTransformation_; }
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_ ;}
59
60
61protected:
62  void updateElementPosition();
63  void initializeAlgorithms();
64  void initializeDomainAlgorithms(int domPositionInGrid);
65  void initializeAxisAlgorithms(int axisPositionInGrid);
66  void initializeScalarAlgorithms(int scalarPositionInGrid);
67  void initializeTransformations(TransformationType type);
68  void selectAlgo(int elementPositionInGrid, ETranformationType transType, int transformationOrder, int algo);
69  bool isSpecialTransformation(ETranformationType transType);
70  void registerTransformations();
71
72protected:
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
77protected:
78  //! Grid source on transformation
79  CGrid* gridSource_;
80
81  //! Grid destination on transformation
82  CGrid* gridDestination_;
83
84  //! Grid source and grid destination it's the same
85  bool isSameGrid_;
86
87protected:
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
103  //! Position of scalar, axis and domain in grid
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__
Note: See TracBrowser for help on using the repository browser.