/*! \file grid_transformation.hpp \author Ha NGUYEN \since 14 May 2015 \date 18 June 2015 \brief Interface for all transformations. */ #ifndef __XIOS_GRID_TRANSFORMATION_HPP__ #define __XIOS_GRID_TRANSFORMATION_HPP__ #include #include #include "grid.hpp" #include "generic_algorithm_transformation.hpp" #include "transformation_enum.hpp" namespace xios { class CGrid; /*! \class CGridTransformation This class is an interface for all transformations to interact with the rest of XIOS. The class, firstly, tries to get all information relating to requested transformations by retrieving directly from grid. Then with all these information, all necessary transformations will be created by generic class \class CGenericAlgorithmTransformation. Because there are information exchange among clients to accomplish the transformations (e.g: some index need retrieving from other clients), this class uses class \class CTransformationMapping to fulfill this demand. For each transformation, a new temporary grid source is created. For a consequential transformations (e.g: inversing -> zoom -> inversing -> ...), the grid destination of current transformation will be grid source of the next transformation */ class CGridTransformation { public: /** Default constructor */ CGridTransformation(CGrid* destination, CGrid* source); ~CGridTransformation(); void computeAll(); const std::map >& getLocalIndexToSendFromGridSource() const; const std::map > > >& getLocalIndexToReceiveOnGridDest() const; CGrid* getGridSource() {return gridSource_; } CGrid* getGridDestination() { return gridDestination_; } private: void computeTransformation(); void initializeAlgorithms(); void initializeAxisAlgorithms(int axisPositionInGrid); void initializeDomainAlgorithms(int domPositionInGrid); void initializeMappingOfOriginalGridSource(); void selectAxisAlgo(int elementPositionInGrid, ETranformationType transType, int transformationOrder); void selectDomainAlgo(int elementPositionInGrid, ETranformationType transType, int transformationOrder); void selectAlgo(int elementPositionInGrid, ETranformationType transType, int transformationOrder, bool isDomainAlgo); void setUpGrid(int elementPositionInGrid, ETranformationType transType); void computeFinalTransformationMapping(); void computeTransformationFromOriginalGridSource(const std::map > >& globaIndexMapFromDestToSource); void updateFinalGridDestination(); private: //! Grid source on transformation CGrid* gridSource_; //! Grid destination on transformation CGrid* gridDestination_; //! The grid source of the first transformation (original grid source) CGrid* originalGridSource_; //! Grid source dimension size std::vector gridSourceDimensionSize_; //! Grid destination dimension size std::vector gridDestinationDimensionSize_; private: typedef std::list > > ListAlgoType; //! List of algorithm types and their order ListAlgoType listAlgos_; // true if domain algorithm and false if axis algorithm (can be replaced by tuple with listAlgos_ std::vector algoTypes_; // Mapping between position of an element in grid and its transformation (if any) std::list algoTransformation_; //! Mapping of (grid) global index representing tranformation. std::map > globaIndexMapFromDestToSource_; //! Local index of data to send from grid source std::map > localIndexToSendFromGridSource_; //! Local index of data to receive on grid destination std::map > > > localIndexToReceiveOnGridDest_; //! Position of axis and domain in grid std::map elementPosition2AxisPositionInGrid_, elementPosition2DomainPositionInGrid_; //! (Grid) Global index of grid source std::vector globalIndexOfCurrentGridSource_; std::vector globalIndexOfOriginalGridSource_; CArray weightOfGlobalIndexOfOriginalGridSource_; }; } #endif // __XIOS_GRID_TRANSFORMATION_HPP__