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