source: XIOS/dev/branch_openmp/src/transformation/grid_transformation.hpp @ 1538

Last change on this file since 1538 was 1328, checked in by yushan, 7 years ago

dev_omp

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