source: XIOS/dev/dev_olga/src/transformation/grid_transformation.hpp @ 1620

Last change on this file since 1620 was 1589, checked in by oabramkina, 23 months ago

Backporting r1578 and r1586 to dev, cleaning the code before merging it to XIOS 2.5.

File size: 3.7 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
52  CGrid* getGridSource() { return originalGridSource_; }
53  CGrid* getGridDestination() { return gridDestination_; }
54
55protected:
56  void computeTransformation();
57
58  virtual void selectScalarAlgo(int elementPositionInGrid, ETranformationType transType, int transformationOrder);
59  virtual void selectAxisAlgo(int elementPositionInGrid, ETranformationType transType, int transformationOrder);
60  virtual void selectDomainAlgo(int elementPositionInGrid, ETranformationType transType, int transformationOrder);
61
62  void setUpGridSource(int elementPositionInGrid);
63  void setUpGridDestination(int elementPositionInGrid, ETranformationType);
64  void computeTransformationMapping(const SourceDestinationIndexMap& globalIndexWeightFromSrcToDest);
65  std::map<int,std::pair<int,int> > getElementPosition(CGrid* grid);
66
67protected:
68  //! The grid source of the first transformation (original grid source)
69  CGrid* tmpGridDestination_;
70  CGrid* originalGridSource_;
71  std::vector<CGrid*> tempGridSrcs_, tempGridDests_;
72
73protected:
74  //! Mapping of (grid) global index representing transformation.
75  std::map<size_t, std::set<size_t> > globaIndexMapFromDestToSource_;
76
77  //! Local index of data to send from grid source
78  std::list<SendingIndexGridSourceMap> localIndexToSendFromGridSource_;
79
80  //! Local index of data to receive on grid destination
81  std::list<RecvIndexGridDestinationMap> localIndexToReceiveOnGridDest_;
82
83  //! Number of local index of data to receive on grid destination
84  std::list<size_t> nbLocalIndexOnGridDest_;
85
86  bool dynamicalTransformation_;
87  std::set<Time> timeStamp_; //! Time stamps for auxillary inputs
88};
89
90}
91#endif // __XIOS_GRID_TRANSFORMATION_HPP__
Note: See TracBrowser for help on using the repository browser.