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

Last change on this file since 887 was 887, checked in by mhnguyen, 5 years ago

Adding a new type of element into grid: Scalar

+) Add a new node Scalar for xml
+) Make some change on writing scalar value
+) Reorganize some codes
+) Remove some redundant codes

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
40public:
41  /** Default constructor */
42  CGridTransformation(CGrid* destination, CGrid* source);
43  ~CGridTransformation();
44
45  void computeAll(const std::vector<CArray<double,1>* >& dataAuxInput=std::vector<CArray<double,1>* >(), Time timeStamp = 0);
46
47  const std::list<SendingIndexGridSourceMap>& getLocalIndexToSendFromGridSource() const;
48  const std::list<RecvIndexGridDestinationMap>& getLocalIndexToReceiveOnGridDest() const;
49  const std::list<size_t>& getNbLocalIndexToReceiveOnGridDest() const;
50  const std::list<std::vector<bool> >& getLocalMaskIndexOnGridDest() 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, ETranformationType transType, int nbTransformation);
63  void setUpGridDestination(int elementPositionInGrid, ETranformationType transType, int nbTransformation);
64  void computeTransformationMapping(const SourceDestinationIndexMap& globalIndexWeightFromSrcToDest);
65
66protected:
67  //! The grid source of the first transformation (original grid source)
68  CGrid* tmpGridDestination_;
69  CGrid* originalGridSource_;
70  std::vector<CGrid*> tempGridSrcs_, tempGridDests_;
71
72protected:
73  //! Mapping of (grid) global index representing tranformation.
74  std::map<size_t, std::set<size_t> > globaIndexMapFromDestToSource_;
75
76  //! Local index of data to send from grid source
77  std::list<SendingIndexGridSourceMap> localIndexToSendFromGridSource_;
78
79  //! Local index of data to receive on grid destination
80  std::list<RecvIndexGridDestinationMap> localIndexToReceiveOnGridDest_;
81
82  //! Number of local index of data to receive on grid destination
83  std::list<size_t> nbLocalIndexOnGridDest_;
84  std::list<std::vector<bool> > localMaskOnGridDest_;
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.