Ignore:
Timestamp:
01/12/21 23:05:02 (3 years ago)
Author:
ymipsl
Message:
  • bug fix when createing mask on server side when overlapping grid
  • implement axis interpolation on pressure coordinate
  • big cleaning in transformation

YM

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/generic_algorithm_transformation.hpp

    r2007 r2011  
    3434class CGenericAlgorithmTransformation 
    3535{ 
    36 public: 
    37   enum AlgoTransType { 
    38     ELEMENT_GENERATION = 0, 
    39     ELEMENT_MODIFICATION_WITHOUT_DATA = 1, 
    40     ELEMENT_MODIFICATION_WITH_DATA = 2, 
    41     ELEMENT_NO_MODIFICATION_WITH_DATA = 3, 
    42     ELEMENT_NO_MODIFICATION_WITHOUT_DATA = 4 
    43   } ; 
    44  
    45 public: 
    46   // Mapping between global index map of DESTINATION and its local index with pair of global index of SOURCE and weights 
    47   typedef std::unordered_map<int, std::unordered_map<size_t, std::vector<std::pair<size_t,double> > > > SourceDestinationIndexMap; 
    48  
    49 protected: 
    50   typedef std::unordered_map<size_t,int> GlobalLocalMap; 
    51 protected: 
    52   typedef std::unordered_map<int, std::vector<int> > TransformationIndexMap; 
    53   typedef std::unordered_map<int, std::vector<double> > TransformationWeightMap; 
    54   typedef std::unordered_map<int, std::vector<int> > TransformationPositionMap; 
    55  
    56 public: 
    57   //CGenericAlgorithmTransformation(); 
    58   CGenericAlgorithmTransformation(bool isSource); 
    59  
    60   virtual ~CGenericAlgorithmTransformation() {} 
    61  
    62   bool isDistributedTransformation(int elementPositionInGrid, CGrid* gridSrc, CGrid* gridDst) ; 
    63  
    64   void computeGlobalSourceIndex(int elementPositionInGrid, 
    65                                CGrid* gridSrc, 
    66                                CGrid* gridDst, 
    67                                SourceDestinationIndexMap& globaIndexWeightFromSrcToDst); 
    68  
    69     /*! 
    70     Apply a operation on local data. 
    71     \param [in] localIndex vector contains local index of local data output and the corresponding weight 
    72     \param [in] dataInput Pointer to the first element of data input array (in form of buffer) 
    73     \param [in/out] dataOut Array contains local data 
    74     \param [in/out] flagInitial vector of boolean to mark the local index already initialized. True means there is a need for initalization 
    75     \param [in] ignoreMissingValue don't count missing value in operation if this flag is true 
    76     \param [in] firstPass indicate if it is the first time the apply funtion is called for a same transformation, in order to make a clean initialization  
    77   */ 
    78   virtual void apply(const std::vector<std::pair<int,double> >& localIndex, 
    79                      const double* dataInput, 
    80                      CArray<double,1>& dataOut, 
    81                      std::vector<bool>& flagInitial,                      
    82                      bool ignoreMissingValue, bool firstPass); 
    83  
    84   /*! 
    85    * Update whole dataOut (on necessary). 
    86    * (Example:  Impose a weight, whose value is only known after being applied an operation, on dataOut) 
    87    * \param [in/out] dataOut dataOut 
    88    */ 
    89   virtual void updateData(CArray<double,1>& dataOut); 
    90  
    91   std::vector<StdString> getIdAuxInputs(); 
    92   AlgoTransType type(); 
    93   /*! 
    94   Compute global index mapping from one element of destination grid to the corresponding element of source grid 
    95   */ 
    96   void computeIndexSourceMapping(const std::vector<CArray<double,1>* >& dataAuxInputs = std::vector<CArray<double,1>* >()); 
    97   void computeTransformationMappingNonDistributed(int elementPositionInGrid, CGrid* gridSrc, CGrid* gridDst, 
    98                                                   vector<int>& localSrc, vector<int>& localDst, vector<double>& weight, int& nbLocalIndexOnGridDest); 
    99   void nonDistributedrecursiveFunct(int currentPos, bool masked, int elementPositionInGrid,  vector< CArray<bool,1>* >& maskSrc, vector< CArray<bool,1>* >& maskDst, 
    100                                     int& srcInd, int& srcIndCompressed, vector<int>& nIndexSrc, 
    101                                     int& t, vector<vector<vector<pair<int,double> > > >& dstIndWeight, int currentInd, 
    102                                     vector<int>& localSrc, vector<int>& localDst, vector<double>& weight) ; 
    103  
    104 protected: 
    105   virtual void computeIndexSourceMapping_(const std::vector<CArray<double,1>* >&) {}; 
    106  
    107   /*! 
    108   Compute proc which contains global index of an element 
    109     \param[in] globalElementIndex demanding global index of an element of source grid 
    110     \param[in] elementType type of source element, 2: domain, 1: axis and 0: scalar 
    111     \param[out] globalElementIndexOnProc Proc contains the demanding global index 
    112   */ 
    113   virtual void computeExchangeGlobalIndex(const CArray<size_t,1>& globalElementIndex, 
    114                                           int elementType, 
    115                                           CClientClientDHTInt::Index2VectorInfoTypeMap& globalElementIndexOnProc){}; 
    116  
    117 protected: 
    118   void computeGlobalGridIndexMapping(int elementPositionInGrid, 
    119                                      const std::vector<int>& srcRank, 
    120                                      std::unordered_map<int, std::vector<std::pair<int,double> > >& src2DstMap, 
    121                                      CGrid* gridDst, 
    122                                      CGrid* gridSrc, 
    123                                      std::vector<std::unordered_map<int,std::vector<size_t> > >& globalElementIndexOnProc, 
    124                                      SourceDestinationIndexMap& globaIndexWeightFromSrcToDst); 
    125  
    126   void computeExchangeDomainIndex(CDomain* domainDst, 
    127                                   CDomain* domainSrc, 
    128                                   CArray<size_t,1>& destGlobalIndexPositionInGrid, 
    129                                   std::unordered_map<int,std::vector<size_t> >& globalDomainIndexOnProc); 
    130  
    131   void computeExchangeAxisIndex(CAxis* axisDst, 
    132                                 CAxis* axisSrc, 
    133                                 CArray<size_t,1>& destGlobalIndexPositionInGrid, 
    134                                 std::unordered_map<int,std::vector<size_t> >& globalAxisIndexOnProc); 
    135  
    136   void computeExchangeScalarIndex(CScalar* scalarDst, 
    137                                   CScalar* scalarSrc, 
    138                                   CArray<size_t,1>& destGlobalIndexPositionInGrid, 
    139                                   std::unordered_map<int,std::vector<size_t> >& globalScalarIndexOnProc); 
    140  
    141   void computePositionElements(CGrid* dst, CGrid* src); 
    142  
    143 protected: 
    144   //! indicate if the transformation is performed on a distributed element 
    145   bool isDistributed_ ; 
    146   //! indicate if the method  isDistributedTransformation has been called before 
    147   bool isDistributedComputed_ ; 
    148    
    149   //! Map between global index of destination element and source element 
    150   std::vector<TransformationIndexMap> transformationMapping_; 
    151   //! Weight corresponding of source to destination 
    152   std::vector<TransformationWeightMap> transformationWeight_; 
    153   //! Map of global index of destination element and corresponding global index of other elements in the same grid 
    154   //! By default, one index of an element corresponds to all index of remaining element in the grid. So it's empty 
    155   std::vector<TransformationPositionMap> transformationPosition_; 
    156  
    157   //! Id of auxillary inputs which helps doing transformation dynamically 
    158   std::vector<StdString> idAuxInputs_; 
    159   AlgoTransType type_; 
    160  
    161   std::set<StdSize> indexElementSrc_; 
    162  
    163   std::vector<std::unordered_map<int,std::vector<size_t> > > globalElementIndexOnProc_; 
    164  
    165   std::vector<int> procContainSrcElementIdx_;  // List of processes containing source index of transformed elements 
    166 //  std::set<int> procOfNonTransformedElements_; // Processes contain the source index of non-transformed elements 
    167   std::set<int> commonProc_; 
    168   std::vector< set<int> > procElementList_ ; // List of processes containing source index of elements 
    169  
    170   CClientClientDHTInt::Index2VectorInfoTypeMap globalIndexOfTransformedElementOnProc_; 
    171    
    172   bool computedProcSrcNonTransformedElement_; // Flag to indicate whether we computed proc containing non transformed elements 
    173  
    174   std::map<int, int> elementPositionInGridSrc2AxisPosition_, elementPositionInGridSrc2DomainPosition_, elementPositionInGridSrc2ScalarPosition_; 
    175   std::map<int, int> elementPositionInGridDst2AxisPosition_, elementPositionInGridDst2DomainPosition_, elementPositionInGridDst2ScalarPosition_; 
    176  
    177   bool eliminateRedondantSrc_ ; // flag to indicate if the transformation must select only one global source point for all proc. 
    178                                // In this case it will choose preferentially the current process  
    179   bool isSource_ ; //flag to indicate that the algorithm is a source algorithm, that mean the grid is modified or generated but  
    180                    // no fluxes are tranformed 
    181    
    182 // new methods for new algorithm 
    183  
    18436  public :  
    185    
     37    CGenericAlgorithmTransformation(bool isSource) ; 
    18638    virtual CGridAlgorithm* createGridAlgorithm(CGrid* gridSrc, CGrid* newGrid, int pos) ; 
    18739    virtual CTransformFilter* createTransformFilter(CGarbageCollector& gc, CGridAlgorithm* algo, bool detectMissingValues, double defaultValue) ; 
    188     virtual void apply(int dimBefore, int dimAfter, const CArray<double,1>& dataIn, CArray<double,1>& dataOut); // transform into pure virtual function later 
     40    virtual void apply(int dimBefore, int dimAfter, const CArray<double,1>& dataIn, CArray<double,1>& dataOut) { abort() ;} //=0 
     41    virtual void apply(int dimBefore, int dimAfter, const CArray<double,1>& dataIn, const vector<CArray<double,1>>& auxData, CArray<double,1>& dataOut) { abort() ;} //=0 
     42     
     43    virtual vector<string> getAuxFieldId(void) ; 
    18944  protected : 
     45    typedef std::unordered_map<int, std::vector<int> > TransformationIndexMap; 
     46    typedef std::unordered_map<int, std::vector<double> > TransformationWeightMap; 
     47  
     48    CLocalElement* recvElement_=nullptr ; 
     49    bool isSource_ ; 
    19050 
    191     CLocalElement* recvElement_=nullptr ; 
    19251  public: 
    19352    CLocalElement* getRecvElement(void) { return recvElement_ ;} 
Note: See TracChangeset for help on using the changeset viewer.