source: XIOS/trunk/src/transformation/grid_transformation.hpp @ 827

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

Implementing dynamic interpolation on axis

+) Change grid transformation to make it more flexible
+) Make some small improvements

Test
+) On Curie
+) All test pass

File size: 4.5 KB
RevLine 
[623]1/*!
2   \file grid_transformation.hpp
3   \author Ha NGUYEN
4   \since 14 May 2015
[687]5   \date 26 Aug 2015
[623]6
7   \brief Interface for all transformations.
8 */
[620]9#ifndef __XIOS_GRID_TRANSFORMATION_HPP__
10#define __XIOS_GRID_TRANSFORMATION_HPP__
11
12#include <map>
13#include <vector>
14#include "grid.hpp"
15#include "generic_algorithm_transformation.hpp"
[622]16#include "transformation_enum.hpp"
[620]17
18namespace xios {
19
20class CGrid;
21
[623]22/*!
23  \class CGridTransformation
24  This class is an interface for all transformations to interact with the rest of XIOS.
25The class, firstly, tries to get all information relating to requested transformations by retrieving directly from grid.
[630]26Then with all these information, all necessary transformations will be created by generic class \class CGenericAlgorithmTransformation.
[623]27Because there are information exchange among clients to accomplish the transformations (e.g: some index need retrieving from other clients),
28this class uses class \class CTransformationMapping to fulfill this demand.
29For each transformation, a new temporary grid source is created.
30For a consequential transformations (e.g: inversing -> zoom -> inversing -> ...),
31the grid destination of current transformation will be grid source of the next transformation
32*/
[620]33class CGridTransformation
34{
35public:
[687]36  typedef std::list<std::pair<int,std::pair<ETranformationType,int> > > ListAlgoType;
37
38public:
[620]39  /** Default constructor */
40  CGridTransformation(CGrid* destination, CGrid* source);
41  ~CGridTransformation();
42
[827]43  void computeAll(const std::vector<CArray<double,1>* >& dataAuxInput=std::vector<CArray<double,1>* >());
[622]44
[653]45  const std::map<int, CArray<int,1> >& getLocalIndexToSendFromGridSource() const;
[630]46  const std::map<int, std::vector<std::vector<std::pair<int,double> > > >& getLocalIndexToReceiveOnGridDest() const;
[790]47  CGrid* getGridSource() { return originalGridSource_; }
[632]48  CGrid* getGridDestination() { return gridDestination_; }
[687]49  ListAlgoType getAlgoList() const {return listAlgos_; }
[824]50  int getNbAlgo() { return nbAlgos_; }
[827]51  const std::vector<StdString>& getAuxInputs() const { return auxInputs_; }
[622]52
[687]53protected:
[620]54  void computeTransformation();
55  void initializeAlgorithms();
[631]56  void initializeAxisAlgorithms(int axisPositionInGrid);
57  void initializeDomainAlgorithms(int domPositionInGrid);
[622]58  void initializeMappingOfOriginalGridSource();
[620]59
[622]60  void selectAxisAlgo(int elementPositionInGrid, ETranformationType transType, int transformationOrder);
61  void selectDomainAlgo(int elementPositionInGrid, ETranformationType transType, int transformationOrder);
[631]62  void selectAlgo(int elementPositionInGrid, ETranformationType transType, int transformationOrder, bool isDomainAlgo);
[827]63  void setUpGrid(int elementPositionInGrid, ETranformationType transType, int nbTransformation);
[622]64  void computeFinalTransformationMapping();
[630]65  void computeTransformationFromOriginalGridSource(const std::map<size_t, std::vector<std::pair<size_t,double> > >& globaIndexMapFromDestToSource);
[623]66  void updateFinalGridDestination();
[821]67  bool isSpecialTransformation(ETranformationType transType);
[622]68
[687]69protected:
[623]70  //! Grid source on transformation
[620]71  CGrid* gridSource_;
[623]72
73  //! Grid destination on transformation
[620]74  CGrid* gridDestination_;
[623]75
76  //! The grid source of the first transformation (original grid source)
[622]77  CGrid* originalGridSource_;
[620]78
[687]79protected:
[623]80  //! List of algorithm types and their order
81  ListAlgoType listAlgos_;
[821]82
83  //! Number of algorithm
84  int nbAlgos_;
85
86  typedef std::map<size_t, std::vector<std::pair<size_t,double> > > GlobalIndexMap;
87
[631]88  // true if domain algorithm and false if axis algorithm (can be replaced by tuple with listAlgos_
89  std::vector<bool> algoTypes_;
[622]90
[620]91  // Mapping between position of an element in grid and its transformation (if any)
[827]92  std::vector<CGenericAlgorithmTransformation*> algoTransformation_;
[623]93
94  //! Mapping of (grid) global index representing tranformation.
[620]95  std::map<size_t, std::set<size_t> > globaIndexMapFromDestToSource_;
96
[623]97  //! Local index of data to send from grid source
[653]98  std::map<int, CArray<int,1> > localIndexToSendFromGridSource_;
[623]99
100  //! Local index of data to receive on grid destination
[630]101  std::map<int,std::vector<std::vector<std::pair<int,double> > > > localIndexToReceiveOnGridDest_;
[622]102
[623]103  //! Position of axis and domain in grid
[622]104  std::map<int, int> elementPosition2AxisPositionInGrid_, elementPosition2DomainPositionInGrid_;
105
[623]106  //! (Grid) Global index of grid source
[821]107  GlobalIndexMap currentGridIndexToOriginalGridIndex_;
[827]108
109  std::vector<CGrid*> tempGrids_;
110  std::vector<StdString> auxInputs_;
111  bool dynamicalTransformation_;
[620]112};
113
114}
115#endif // __XIOS_GRID_TRANSFORMATION_HPP__
Note: See TracBrowser for help on using the repository browser.