source: XIOS/trunk/src/transformation/grid_transformation_selector.hpp @ 933

Last change on this file since 933 was 933, checked in by mhnguyen, 8 years ago

Improving transformation selection. Instead of modifying directly grid_transformation
we only need to register a new transformation with the framework

+) Update all transformations with this new method

Test
+) On Curie
+) Basic tests pass

File size: 3.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  typedef std::list<std::pair<int,std::pair<ETranformationType,int> > > ListAlgoType;
31protected:
32  enum AlgoType {
33    scalarType = 0, axisType = 1, domainType = 2
34  };
35
36protected:
37  enum TransformationType {
38    special = 0, normal = 1
39  };
40
41public:
42  /** Default constructor */
43  CGridTransformationSelector(CGrid* destination, CGrid* source, TransformationType type = normal);
44  virtual ~CGridTransformationSelector();
45
46  ListAlgoType getAlgoList() const { return listAlgos_; }
47  int getNbAlgo() { return nbNormalAlgos_; }
48  const std::vector<StdString>& getAuxInputs() const { return auxInputs_; }
49  const std::vector<CGenericAlgorithmTransformation*>& getAlgos() const { return algoTransformation_; }
50
51protected:
52  void initializeAlgorithms();
53  void initializeDomainAlgorithms(int domPositionInGrid);
54  void initializeAxisAlgorithms(int axisPositionInGrid);
55  void initializeScalarAlgorithms(int scalarPositionInGrid);
56  void initializeTransformations(TransformationType type);
57  void selectAlgo(int elementPositionInGrid, ETranformationType transType, int transformationOrder, AlgoType algo);
58  bool isSpecialTransformation(ETranformationType transType);
59  void registerTransformations();
60
61protected:
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
66protected:
67  //! Grid source on transformation
68  CGrid* gridSource_;
69
70  //! Grid destination on transformation
71  CGrid* gridDestination_;
72
73  //! Grid source and grid destination it's the same
74  bool isSameGrid_;
75
76protected:
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
92  //! Position of scalar, axis and domain in grid
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__
Note: See TracBrowser for help on using the repository browser.