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

Last change on this file since 1537 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.8 KB
Line 
1/*!
2   \file grid_transformation.hpp
3   \author Ha NGUYEN
4   \since 14 May 2015
5   \date 26 Aug 2015
6
7   \brief Interface for all transformations.
8 */
9#ifndef __XIOS_GRID_TRANSFORMATION_HPP__
10#define __XIOS_GRID_TRANSFORMATION_HPP__
11
12#include <map>
13#include <vector>
14#include "generic_algorithm_transformation.hpp"
15#include "transformation_enum.hpp"
16#include "duration.hpp"
17#include "grid_transformation_selector.hpp"
18
19namespace xios {
20
21class CGrid;
22
23/*!
24  \class CGridTransformation
25  This class is an interface for all transformations to interact with the rest of XIOS.
26The class, firstly, tries to get all information relating to requested transformations by retrieving directly from grid.
27Secondly, with all these information, all necessary transformations will be created by generic class \class CGenericAlgorithmTransformation.
28Then this class accomplishes the transformations by exchanging information among clients (e.g: some index need retrieving index from other clients),
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*/
33class CGridTransformation : public CGridTransformationSelector
34{
35public:
36  typedef std::map<int, CArray<int,1> > SendingIndexGridSourceMap;
37  typedef std::map<int,std::vector<std::pair<int,double> > > RecvIndexGridDestinationMap;
38  typedef CGenericAlgorithmTransformation::SourceDestinationIndexMap SourceDestinationIndexMap;
39  typedef CGenericAlgorithmTransformation::AlgoTransType AlgoTransType;
40
41public:
42  /** Default constructor */
43  CGridTransformation(CGrid* destination, CGrid* source);
44  ~CGridTransformation();
45
46  void computeAll(const std::vector<CArray<double,1>* >& dataAuxInput=std::vector<CArray<double,1>* >(), Time timeStamp = 0);
47
48  const std::list<SendingIndexGridSourceMap>& getLocalIndexToSendFromGridSource() const;
49  const std::list<RecvIndexGridDestinationMap>& getLocalIndexToReceiveOnGridDest() const;
50  const std::list<size_t>& getNbLocalIndexToReceiveOnGridDest() const;
51  const std::list<std::vector<bool> >& getLocalMaskIndexOnGridDest() const;
52
53  CGrid* getGridSource() { return originalGridSource_; }
54  CGrid* getGridDestination() { return gridDestination_; }
55
56protected:
57  void computeTransformation();
58
59  virtual void selectScalarAlgo(int elementPositionInGrid, ETranformationType transType, int transformationOrder);
60  virtual void selectAxisAlgo(int elementPositionInGrid, ETranformationType transType, int transformationOrder);
61  virtual void selectDomainAlgo(int elementPositionInGrid, ETranformationType transType, int transformationOrder);
62
63  void setUpGridSource(int elementPositionInGrid);
64  void setUpGridDestination(int elementPositionInGrid, ETranformationType);
65  void computeTransformationMapping(const SourceDestinationIndexMap& globalIndexWeightFromSrcToDest);
66  std::map<int,std::pair<int,int> > getElementPosition(CGrid* grid);
67
68protected:
69  //! The grid source of the first transformation (original grid source)
70  CGrid* tmpGridDestination_;
71  CGrid* originalGridSource_;
72  std::vector<CGrid*> tempGridSrcs_, tempGridDests_;
73
74protected:
75  //! Mapping of (grid) global index representing transformation.
76  std::map<size_t, std::set<size_t> > globaIndexMapFromDestToSource_;
77
78  //! Local index of data to send from grid source
79  std::list<SendingIndexGridSourceMap> localIndexToSendFromGridSource_;
80
81  //! Local index of data to receive on grid destination
82  std::list<RecvIndexGridDestinationMap> localIndexToReceiveOnGridDest_;
83
84  //! Number of local index of data to receive on grid destination
85  std::list<size_t> nbLocalIndexOnGridDest_;
86  std::list<std::vector<bool> > localMaskOnGridDest_;
87
88  bool dynamicalTransformation_;
89  std::set<Time> timeStamp_; //! Time stamps for auxillary inputs
90};
91
92}
93#endif // __XIOS_GRID_TRANSFORMATION_HPP__
Note: See TracBrowser for help on using the repository browser.