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