source: XIOS/dev/dev_olga/src/transformation/grid_transformation_selector.hpp @ 1204

Last change on this file since 1204 was 978, checked in by mhnguyen, 7 years ago

Correcting various bugs relating to transformation

+) Fix the order of transformation selection
+) Correct domain transformation selection
+) Reorganize test_remap

Test
+) On Curie
+) All tests pass

File size: 3.6 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
54protected:
55  void updateElementPosition();
56  void initializeAlgorithms();
57  void initializeDomainAlgorithms(int domPositionInGrid);
58  void initializeAxisAlgorithms(int axisPositionInGrid);
59  void initializeScalarAlgorithms(int scalarPositionInGrid);
60  void initializeTransformations(TransformationType type);
61  void selectAlgo(int elementPositionInGrid, ETranformationType transType, int transformationOrder, int algo);
62  bool isSpecialTransformation(ETranformationType transType);
63  void registerTransformations();
64
65protected:
66  virtual void selectScalarAlgo(int elementPositionInGrid, ETranformationType transType, int transformationOrder) = 0;
67  virtual void selectAxisAlgo(int elementPositionInGrid, ETranformationType transType, int transformationOrder) = 0;
68  virtual void selectDomainAlgo(int elementPositionInGrid, ETranformationType transType, int transformationOrder) = 0;
69
70protected:
71  //! Grid source on transformation
72  CGrid* gridSource_;
73
74  //! Grid destination on transformation
75  CGrid* gridDestination_;
76
77  //! Grid source and grid destination it's the same
78  bool isSameGrid_;
79
80protected:
81  //! List of algorithm types and their order
82  ListAlgoType listAlgos_;
83
84  //! Number of normal algorithm
85  int nbNormalAlgos_;
86
87  //! Number of special algorithms (such as generate_rectilinear_grid)
88  int nbSpecialAlgos_;
89
90  // true if domain algorithm and false if axis algorithm (can be replaced by tuple with listAlgos_
91  std::vector<AlgoType> algoTypes_;
92
93  // Mapping between position of an element in grid and its transformation (if any)
94  std::vector<CGenericAlgorithmTransformation*> algoTransformation_;
95
96  //! Position of scalar, axis and domain in grid
97  std::map<int, int> elementPositionInGridSrc2AxisPosition_, elementPositionInGridSrc2DomainPosition_, elementPositionInGridSrc2ScalarPosition_;
98  std::map<int, int> elementPositionInGridDst2AxisPosition_, elementPositionInGridDst2DomainPosition_, elementPositionInGridDst2ScalarPosition_;
99
100  std::vector<StdString> auxInputs_;
101  std::set<Time> timeStamp_; //! Time stamps for auxillary inputs
102};
103
104}
105#endif // __XIOS_GRID_TRANSFORMATION_SELECTOR_HPP__
Note: See TracBrowser for help on using the repository browser.