Changeset 1984


Ignore:
Timestamp:
12/06/20 22:14:56 (3 years ago)
Author:
ymipsl
Message:

intermediate commit for new tranformation engine?
YM

Location:
XIOS/dev/dev_ym/XIOS_COUPLING/src
Files:
16 added
48 deleted
63 edited

Legend:

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

    r1361 r1984  
    5151    SuperClassAttribute::setAttributes(refer_ptr, apply);              \ 
    5252  }                                                                    \ 
    53   if (this->hasAttribute("name") && this->name.isEmpty())              \ 
    54     this->name.setValue(this->get##type##OutputName());                \ 
    5553}                                                                      \ 
    5654                                                                       \ 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/gatherer_connector.hpp

    r1930 r1984  
    2929       
    3030      template<typename T> 
    31       void transfer(int sizeT, map<int, CArray<T,1>>& dataIn, CArray<T,1>& dataOut) 
     31      void transfer(int repeat, int sizeT, map<int, CArray<T,1>>& dataIn, CArray<T,1>& dataOut) 
    3232      { 
    3333        // for future, make a specific transfer function for sizeT=1 to avoid multiplication (increasing performance) 
    34         dataOut.resize(dstSize_*sizeT) ;   
    35         T* output = dataOut.dataFirst() ; 
     34        size_t dstSlice = dstSize_*sizeT ; 
     35        dataOut.resize(repeat* dstSlice) ;   
     36         
    3637        for(auto& data : dataIn) 
    3738        { 
     39          T* output = dataOut.dataFirst() ; 
    3840          int rank=data.first ; 
    3941          auto input  = data.second.dataFirst() ; 
     
    4143          auto& mask=mask_[rank] ; 
    4244          int size=mask.size() ; 
    43  
    44           for(int i=0, j=0 ;i<size;i++) 
    45           { 
    46             if (mask[i])  
     45          size_t srcSlice = size * sizeT ; 
     46          for(int l=0; l<repeat; l++) 
     47          {    
     48            for(int i=0, j=0 ;i<size;i++) 
    4749            { 
    48               int cj = connector[j]*sizeT ; 
    49               int ci = i*sizeT ; 
    50               for (int k=0;k<sizeT;k++) output[cj+k] = input[ci+k] ; 
    51               j++ ; 
     50              if (mask[i])  
     51              { 
     52                int cj = connector[j]*sizeT ; 
     53                int ci = i*sizeT ; 
     54                for (int k=0;k<sizeT;k++) output[cj+k] = input[ci+k] ; 
     55                j++ ; 
     56              } 
    5257            } 
     58            input+=srcSlice ; 
     59            output+=dstSlice ; 
    5360          } 
    5461        } 
     62      } 
     63 
     64      template<typename T> 
     65      void transfer(int sizeT, map<int, CArray<T,1>>& dataIn, CArray<T,1>& dataOut) 
     66      { 
     67        transfer(1, 1, dataIn, dataOut) ; 
    5568      } 
    5669     
     
    101114      void transfer(map<int, CArray<T,1>>& dataIn, CArray<T,1>& dataOut, T missingValue) 
    102115      { 
    103         transfer(1, dataIn, dataout, missingValue) 
     116        transfer(1, 1, dataIn, dataout, missingValue) 
    104117      } 
    105118       
     
    107120      void transfer(int sizeT, map<int, CArray<T,1>>& dataIn, CArray<T,1>& dataOut, T missingValue) 
    108121      { 
    109         dataOut.resize(dstSize_*sizeT) ; 
     122         transfer(1, sizeT, dataIn, dataOut, missingValue) ; 
     123      } 
     124 
     125      template<typename T> 
     126      void transfer(int repeat , int sizeT, map<int, CArray<T,1>>& dataIn, CArray<T,1>& dataOut, T missingValue) 
     127      { 
     128        dataOut.resize(repeat*dstSize_*sizeT) ; 
    110129        dataOut=missingValue ; 
    111         transfer(sizeT, dataIn, dataOut) ; 
     130        transfer(1, sizeT, dataIn, dataOut) ; 
    112131      } 
    113132 
     
    121140          (*subEvent.buffer) >> data ; 
    122141        } 
    123         transfer(sizeT, dataIn, dataOut) ; 
     142        transfer(1, sizeT, dataIn, dataOut) ; 
    124143      } 
    125144       
     
    139158          (*subEvent.buffer) >> data ; 
    140159        } 
    141         transfer(sizeT, dataIn, dataOut, missingValue) ; 
     160        transfer(1, sizeT, dataIn, dataOut, missingValue) ; 
    142161      } 
    143162 
     
    151170          (*subEvent.buffer) >> data ; 
    152171        } 
    153         transfer(1, dataIn, dataOut, missingValue) ; 
     172        transfer(1, 1, dataIn, dataOut, missingValue) ; 
    154173      } 
    155174 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/grid_remote_connector.cpp

    r1938 r1984  
    8787    srcView_[nSrc-1]->getGlobalIndex(srcGlobalIndex, sliceIndex, srcSliceSize.data(), srcView_.data(), nSrc-1) ; 
    8888     
    89     CArray<size_t,1> srcGlobalIndexArray(srcGlobalIndex.data(), shape(srcGlobalIndex.size()),neverDeleteData) ; 
    90     dataRanks.computeIndexInfoMapping(srcGlobalIndexArray) ; 
     89    if (srcGlobalIndex.size()>0) 
     90    { 
     91      CArray<size_t,1> srcGlobalIndexArray(srcGlobalIndex.data(), shape(srcGlobalIndex.size()),neverDeleteData) ; 
     92      dataRanks.computeIndexInfoMapping(srcGlobalIndexArray) ; 
     93    } 
     94    else 
     95    { 
     96      CArray<size_t,1> srcGlobalIndexArray ; 
     97      dataRanks.computeIndexInfoMapping(srcGlobalIndexArray) ; 
     98    } 
    9199    const auto& returnInfo = dataRanks.getInfoIndexMap() ; 
    92100 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/scatterer_connector.hpp

    r1943 r1984  
    3838    void transfer(const CArray<T,n>& dataIn, map<int, CArray<T,1>>& dataOut) 
    3939    { 
    40       transfer(1, dataIn, dataOut) ; 
     40      transfer(1,1, dataIn, dataOut) ; 
    4141    } 
    4242 
     
    4444    void transfer(const CArray<T,n>& dataIn, map<int, CArray<T,1>>& dataOut, T missingValue) 
    4545    { 
    46       transfer(1, dataIn, dataOut, missingValue) ; 
     46      transfer(1, 1, dataIn, dataOut, missingValue) ; 
    4747    } 
    4848 
     
    5050    void transfer(int sizeT, const CArray<T,n>& dataIn, map<int, CArray<T,1>>& dataOut) 
    5151    { 
     52      transfer(1, sizeT, dataIn, dataOut) 
     53    } 
     54     
     55    template<typename T, int n> 
     56    void transfer(int repeat, int sizeT, const CArray<T,n>& dataIn, map<int, CArray<T,1>>& dataOut) 
     57    { 
    5258      // for future, make a specific transfer function for sizeT=1 to avoid multiplication (increasing performance) 
     59      size_t srcSlice = sizeT*srcSize_ ; 
    5360      for(auto& rankConnector : connector_) 
    5461      { 
     
    5865        int dstSize = mask.size() ; 
    5966        auto& data = dataOut[rank] ; 
    60         data.resize(dstSize * sizeT) ; 
     67        size_t dstSlice = dstSize*sizeT ; 
     68        data.resize(repeat*dstSlice) ; 
    6169        T* dstData = data.dataFirst() ; 
    6270        const T* srcData = dataIn.dataFirst() ; 
    63         for(int i=0, j=0; i<dstSize; i++) 
    64           if (mask[i])  
    65           { 
    66             for(int k=0;k<sizeT;k++) dstData[i*sizeT+k] = srcData[connector[j]*sizeT+k] ; 
    67             j++ ; 
    68           } 
    69       } 
    70     } 
    71  
    72     template<typename T, int n> 
    73     void transfer(int sizeT, const CArray<T,n>& dataIn, map<int, CArray<T,1>>& dataOut, T missingValue) 
     71        for(int l=0; l<repeat; l++) 
     72        { 
     73          for(int i=0, j=0; i<dstSize; i++) 
     74            if (mask[i])  
     75            { 
     76              for(int k=0;k<sizeT;k++) dstData[i*sizeT+k] = srcData[connector[j]*sizeT+k] ; 
     77              j++ ; 
     78            } 
     79          dstData+=dstSlice ; 
     80          srcData+=srcSlice ; 
     81        } 
     82      } 
     83    } 
     84 
     85    template<typename T, int n> 
     86    void transfer(int repeat, int sizeT, const CArray<T,n>& dataIn, map<int, CArray<T,1>>& dataOut, T missingValue) 
    7487    { 
    7588      // for future, make a specific transfer function for sizeT=1 to avoid multiplication (increasing performance) 
     89      size_t srcSlice = sizeT*srcSize_ ; 
    7690      for(auto& rankConnector : connector_) 
    7791      { 
     
    8195        int dstSize = mask.size() ; 
    8296        auto& data = dataOut[rank] ; 
    83         data.resize(dstSize * sizeT) ; 
     97        size_t dstSlice = dstSize*sizeT ; 
     98        data.resize(repeat * dstSlice) ; 
    8499        T* dstData = data.dataFirst() ; 
    85100        const T* srcData = dataIn.dataFirst() ; 
    86         for(int i=0, j=0; i<dstSize; i++) 
    87           if (mask[i])  
    88           { 
    89             for(int k=0;k<sizeT;k++) dstData[i*sizeT+k] = srcData[connector[j]*sizeT+k] ; 
    90             j++ ; 
    91           } 
    92           else  
    93           { 
    94             for(int k=0;k<sizeT;k++) dstData[i*sizeT+k] = missingValue ; 
    95             j++ ; 
    96           } 
     101        for(int l=0; l<repeat; l++) 
     102        { 
     103          for(int i=0, j=0; i<dstSize; i++) 
     104            if (mask[i])  
     105            { 
     106              for(int k=0;k<sizeT;k++) dstData[i*sizeT+k] = srcData[connector[j]*sizeT+k] ; 
     107              j++ ; 
     108            } 
     109            else  
     110            { 
     111              for(int k=0;k<sizeT;k++) dstData[i*sizeT+k] = missingValue ; 
     112              j++ ; 
     113            } 
     114          dstData+=dstSlice ; 
     115          srcData+=srcSlice ; 
     116        } 
    97117      } 
    98118    } 
     
    101121    void transfer(const CArray<T,n>& dataIn, CContextClient* client, CEventClient& event, const CMessage& messageHeader) 
    102122    { 
    103       transfer(1, dataIn, client, event, messageHeader) ; 
     123      transfer( 1, dataIn, client, event, messageHeader) ; 
    104124    } 
    105125 
     
    107127    void transfer(const CArray<T,n>& dataIn, T missingValue, CContextClient* client, CEventClient& event, const CMessage& messageHeader) 
    108128    { 
    109       transfer(1, dataIn, missingValue, client, event, messageHeader) ; 
     129      transfer( 1, dataIn, missingValue, client, event, messageHeader) ; 
    110130    } 
    111131 
     
    114134    { 
    115135      map<int, CArray<T,1>> dataOut ; 
    116       transfer(sizeT, dataIn, dataOut) ; 
     136      transfer(1, sizeT, dataIn, dataOut) ; 
    117137      sendToServer(dataOut, client, event, messageHeader) ; 
    118138    } 
     
    122142    { 
    123143      map<int, CArray<T,1>> dataOut ; 
    124       transfer(sizeT, dataIn, dataOut, missingValue) ; 
     144      transfer(1, sizeT, dataIn, dataOut, missingValue) ; 
    125145      sendToServer(dataOut, client, event, messageHeader) ; 
    126146    } 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/filter/client_to_server_store_filter.cpp

    r1935 r1984  
    2525    CMessage message ; 
    2626    message<<field_->getId() << data[0]->timestamp ; 
    27     field_->getGrid()->getClientToServerConnector(client_)->transfer(data[0]->data, client_, event, message) ; 
     27    field_->getSentGrid()->getClientToServerConnector(client_)->transfer(data[0]->data, client_, event, message) ; 
    2828    CTimer::get("Field : send data").suspend(); 
    2929  } 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/mpi_tools.cpp

    r1759 r1984  
    2626    return ret ; 
    2727  } 
     28 
    2829} 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/mpi_tools.hpp

    r1759 r1984  
    11#ifndef __XIOS_MPI_TOOLS_HPP__ 
     2#define __XIOS_MPI_TOOLS_HPP__ 
    23 
    34#include <string> 
     
    78 
    89  int MPI_Bcast_string(std::string& str, int root, MPI_Comm comm) ; 
     10 
     11  template<typename T>  
     12  MPI_Datatype MPI_GetType(void) ; 
     13 
     14  template<> 
     15  MPI_Datatype MPI_GetType<char>(void) { return MPI_CHAR ;} 
     16 
     17  template<> 
     18  MPI_Datatype MPI_GetType<short int>(void) { return MPI_SHORT ;} 
     19 
     20  template<> 
     21  MPI_Datatype MPI_GetType<int>(void) { return MPI_INT ;} 
     22 
     23  template<> 
     24  MPI_Datatype MPI_GetType<size_t>(void) { return MPI_SIZE_T ;} 
     25 
     26  template<> 
     27  MPI_Datatype MPI_GetType<float>(void) { return MPI_FLOAT ;} 
     28 
     29  template<> 
     30  MPI_Datatype MPI_GetType<double>(void) { return MPI_DOUBLE ;} 
     31 
     32  template<> 
     33  MPI_Datatype MPI_GetType<long double>(void) { return MPI_LONG_DOUBLE ;} 
     34 
     35 
    936}  
    1037#endif 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/axis.cpp

    r1975 r1984  
    555555   * Go through the hierarchy to find the axis from which the transformations must be inherited 
    556556   */ 
    557   void CAxis::solveInheritanceTransformation() 
     557  void CAxis::solveInheritanceTransformation_old() 
    558558  TRY 
    559559  { 
     
    572572      for (size_t i = 0; i < refAxis.size(); ++i) 
    573573        refAxis[i]->setTransformations(axis->getAllTransformations()); 
     574  } 
     575  CATCH_DUMP_ATTR 
     576 
     577  void CAxis::solveInheritanceTransformation() 
     578  TRY 
     579  { 
     580    if (solveInheritanceTransformation_done_) return; 
     581    else solveInheritanceTransformation_done_=true ; 
     582 
     583    CAxis* axis = this; 
     584    std::list<CAxis*> refAxis; 
     585    bool out=false ; 
     586    vector<StdString> excludedAttr; 
     587    excludedAttr.push_back("axis_ref"); 
     588     
     589    refAxis.push_front(axis) ; 
     590    while (axis->hasDirectAxisReference() && !out) 
     591    { 
     592      CAxis* lastAxis=axis ; 
     593      axis = axis->getDirectAxisReference(); 
     594      axis->solveRefInheritance() ; 
     595      if (!axis->SuperClass::isEqual(lastAxis,excludedAttr)) out=true ; 
     596      refAxis.push_front(axis) ; 
     597    } 
     598 
     599    CTransformationPaths::TPath path ; 
     600    auto& pathList = std::get<2>(path) ; 
     601    std::get<0>(path) = EElement::AXIS ; 
     602    std::get<1>(path) = refAxis.front()->getId() ; 
     603    for (auto& axis : refAxis) 
     604    { 
     605      CAxis::TransMapTypes transformations = axis->getAllTransformations(); 
     606      for(auto& transformation : transformations) pathList.push_back({transformation.second->getTransformationType(),  
     607                                                                      transformation.second->getId()}) ; 
     608    } 
     609    transformationPaths_.addPath(path) ; 
     610 
    574611  } 
    575612  CATCH_DUMP_ATTR 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/axis.hpp

    r1975 r1984  
    1616#include "transformation.hpp" 
    1717#include "transformation_enum.hpp" 
     18#include "transformation_path.hpp" 
    1819#include "element.hpp" 
    1920#include "local_connector.hpp" 
     
    2122#include "gatherer_connector.hpp" 
    2223#include "distribution_type.hpp" 
    23  
    24  
    25 namespace xios { 
     24#include "generic_algorithm_transformation.hpp" 
     25 
     26 
     27namespace xios 
     28{ 
    2629   /// ////////////////////// Déclarations ////////////////////// /// 
    2730 
     
    5760         typedef CAxisAttributes RelAttributes; 
    5861         typedef CAxisGroup      RelGroup; 
    59          typedef CTransformation<CAxis>::TransformationMapTypes TransMapTypes; 
    6062 
    6163      public: 
     
    7981         bool isDistributed(void) const; 
    8082         
    81         public: 
     83      public: 
    8284        /*! 
    8385            \brief return if the axis can be written or not in a compressed way. 
     
    8688         */  
    8789         bool isCompressible(void) { if (!isCompressibleComputed_) computeIsCompressible() ; return isCompressible_ ;}  
    88         private: 
     90      private: 
    8991         bool isCompressible_ ; /** specify if the domain can be written in a compressed way */  
    9092         bool isCompressibleComputed_=false ; /** Indicate if compressability has been computed*/ 
    9193         void computeIsCompressible() ; 
    9294         
    93         public: 
     95      public: 
    9496 
    9597         /// Mutateur /// 
     
    119121         size_t getGlobalWrittenSize(void) ; 
    120122 
    121          bool hasTransformation(); 
    122          void solveInheritanceTransformation(); 
    123          TransMapTypes getAllTransformations();          
    124          void duplicateTransformation(CAxis*); 
    125          CTransformation<CAxis>* addTransformation(ETranformationType transType, const StdString& id=""); 
     123      ////////////////////////// 
     124      ///// transformations //// 
     125      ////////////////////////// 
     126      public: 
     127        typedef CTransformation<CAxis>::TransformationMapTypes TransMapTypes; 
     128      private: 
     129        static bool initializeTransformationMap(std::map<StdString, ETranformationType>& m); 
     130        static std::map<StdString, ETranformationType> transformationMapList_; 
     131        static bool dummyTransformationMapList_; 
     132        TransMapTypes transformationMap_;          
     133 
     134      public: 
     135        CTransformation<CAxis>* addTransformation(ETranformationType transType, const StdString& id=""); 
     136        CTransformation<CAxis>* addTransformation(ETranformationType transType, CTransformation<CAxis>* transformation) ; 
     137        void setTransformations(const TransMapTypes&);          
     138        void duplicateTransformation(CAxis*); 
     139        TransMapTypes getAllTransformations(); 
     140        bool hasTransformation(); 
     141        void solveInheritanceTransformation_old(); // to remove later 
     142        void solveInheritanceTransformation(); 
     143      private: 
     144        bool solveInheritanceTransformation_done_= false ; 
     145      private: 
     146        CGenericAlgorithmTransformation* transformationAlgorithm_ = nullptr ; 
     147      public: 
     148        void setTransformationAlgorithm(CGenericAlgorithmTransformation* transformationAlgorithm) { transformationAlgorithm=transformationAlgorithm ;} 
     149        CGenericAlgorithmTransformation* getTransformationAlgorithm(void) { return transformationAlgorithm_ ;}    
     150      private: 
     151        CTransformationPaths transformationPaths_ ; 
     152      public: 
     153        CTransformationPaths getTransformationPaths(void) {return transformationPaths_;}  
     154        void setTransformationPaths(const CTransformationPaths& transformationPaths) { transformationPaths_=transformationPaths ;} 
     155 
     156      //////////////////////////// 
    126157         bool isEqual(CAxis* axis); 
    127158 
     
    131162        bool hasLabel; 
    132163 
    133        private: 
     164      private: 
    134165         void checkData(); 
    135166         void checkMask(); 
     
    145176         void makeAliasForCoupling(const string& fieldId, int posInGrid) ; 
    146177 
    147       private: 
    148          void setTransformations(const TransMapTypes&); 
    149178 
    150179      private: 
     
    177206         bool isChecked; 
    178207         std::set<StdString> relFiles, relFilesCompressed; 
    179          TransMapTypes transformationMap_;          
    180  
    181          std::map<int, std::unordered_map<int, vector<size_t> > > indSrv_; // Global index of each client sent to server 
     208          std::map<int, std::unordered_map<int, vector<size_t> > > indSrv_; // Global index of each client sent to server 
    182209         std::map<int, std::vector<int> > connectedServerRank_; 
    183  
    184        private: 
    185          static bool initializeTransformationMap(std::map<StdString, ETranformationType>& m); 
    186          static std::map<StdString, ETranformationType> transformationMapList_; 
    187          static bool dummyTransformationMapList_; 
    188  
    189210 
    190211       ////////////////////////////////////////////////////////////////////////////////////// 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/compute_connectivity_domain.cpp

    r944 r1984  
    2727  bool CComputeConnectivityDomain::registerTrans() 
    2828  { 
    29     registerTransformation(TRANS_COMPUTE_CONNECTIVITY_DOMAIN, CComputeConnectivityDomain::create); 
     29    registerTransformation(TRANS_COMPUTE_CONNECTIVITY_DOMAIN, {create, getTransformation}); 
    3030  } 
    3131 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/compute_connectivity_domain.hpp

    r934 r1984  
    4141      typedef CObjectTemplate<CComputeConnectivityDomain> SuperClass; 
    4242      typedef CComputeConnectivityDomainAttributes SuperClassAttribute; 
     43      typedef CComputeConnectivityDomain MyClass ; 
     44      typedef CTransformation<CDomain> SuperTransform ; 
    4345 
    4446    public : 
     
    5658      static StdString GetDefName(void); 
    5759      static ENodeType GetType(void); 
     60      const string& getId(void) { return this->SuperClass::getId();} 
     61      ETranformationType getTransformationType(void) { return TRANS_COMPUTE_CONNECTIVITY_DOMAIN ;} 
     62      static CTransformation<CDomain>* getTransformation(const StdString& id) { return SuperClass::get(id);} 
     63      virtual void inheritFrom(SuperTransform* srcTransform) { solveDescInheritance(true, this->SuperClass::get((MyClass*)srcTransform)) ;} 
    5864    private: 
    5965      static bool registerTrans(); 
    6066      static CTransformation<CDomain>* create(const StdString& id, xml::CXMLNode* node); 
    6167      static bool _dummyRegistered; 
    62   }; // class CComputeConnectivityDomain 
     68    public: 
     69   }; // class CComputeConnectivityDomain 
    6370 
    6471  DECLARE_GROUP(CComputeConnectivityDomain); 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/context.cpp

    r1974 r1984  
    13021302   CATCH_DUMP_ATTR 
    13031303 
    1304    void CContext::buildFilterGraphOfEnabledFields() 
    1305    TRY 
    1306    { 
    1307      int size = this->enabledFiles.size(); 
    1308      for (int i = 0; i < size; ++i) 
    1309      { 
    1310        this->enabledFiles[i]->buildFilterGraphOfEnabledFields(garbageCollector); 
    1311      } 
    1312  
    1313      size = this->enabledCouplerOut.size(); 
    1314      for (int i = 0; i < size; ++i) 
    1315      { 
    1316        this->enabledCouplerOut[i]->buildFilterGraphOfEnabledFields(garbageCollector); 
    1317      } 
    1318    } 
    1319    CATCH_DUMP_ATTR 
    13201304 
    13211305   void CContext::postProcessFilterGraph() 
     
    13801364  CATCH_DUMP_ATTR 
    13811365 
    1382   void CContext::solveAllRefOfFieldsWithReadAccess() 
    1383   TRY 
    1384   { 
    1385     for (size_t i = 0; i < fieldsWithReadAccess_.size(); ++i) 
    1386       fieldsWithReadAccess_[i]->solveAllReferenceEnabledField(false); 
    1387   } 
    1388   CATCH_DUMP_ATTR 
    1389  
    1390   void CContext::buildFilterGraphOfFieldsWithReadAccess() 
    1391   TRY 
    1392   { 
    1393     for (size_t i = 0; i < fieldsWithReadAccess_.size(); ++i) 
    1394       fieldsWithReadAccess_[i]->buildFilterGraph(garbageCollector, true); 
    1395   } 
    1396   CATCH_DUMP_ATTR 
    1397  
     1366   
    13981367   void CContext::solveAllInheritance(bool apply) 
    13991368   TRY 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/context.hpp

    r1974 r1984  
    139139         void prepareTimeseries(void); 
    140140         void solveOnlyRefOfEnabledFields(void);          
    141          void buildFilterGraphOfEnabledFields(); 
    142141         void postProcessFilterGraph(); 
    143142         void startPrefetchingOfEnabledReadModeFiles(); 
     
    145144         void doPostTimestepOperationsForEnabledReadModeFiles(); 
    146145         void findFieldsWithReadAccess(void); 
    147          void solveAllRefOfFieldsWithReadAccess(); 
    148          void buildFilterGraphOfFieldsWithReadAccess(); 
    149146         void triggerLateFields(void) ; 
    150147         void solveAllRefOfEnabledFieldsAndTransform(void); 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/domain.cpp

    r1974 r1984  
    11#include "domain.hpp" 
    2  
    32#include "attribute_template.hpp" 
    43#include "object_template.hpp" 
     
    2524#include "grid_scatterer_connector.hpp" 
    2625#include "grid_gatherer_connector.hpp" 
     26#include "transformation_path.hpp" 
    2727 
    2828 
     
    7777     CDomain* domain = CDomainGroup::get("domain_definition")->createChild(); 
    7878     return domain; 
    79    } 
    80    CATCH 
    81  
    82    std::map<StdString, ETranformationType> CDomain::transformationMapList_ = std::map<StdString, ETranformationType>(); 
    83    bool CDomain::_dummyTransformationMapList = CDomain::initializeTransformationMap(CDomain::transformationMapList_); 
    84  
    85    bool CDomain::initializeTransformationMap(std::map<StdString, ETranformationType>& m) 
    86    TRY 
    87    { 
    88      m["zoom_domain"] = TRANS_ZOOM_DOMAIN; 
    89      m["interpolate_domain"] = TRANS_INTERPOLATE_DOMAIN; 
    90      m["generate_rectilinear_domain"] = TRANS_GENERATE_RECTILINEAR_DOMAIN; 
    91      m["compute_connectivity_domain"] = TRANS_COMPUTE_CONNECTIVITY_DOMAIN; 
    92      m["expand_domain"] = TRANS_EXPAND_DOMAIN; 
    93      m["reorder_domain"] = TRANS_REORDER_DOMAIN; 
    94      m["extract_domain"] = TRANS_EXTRACT_DOMAIN; 
    9579   } 
    9680   CATCH 
     
    21792163  CATCH_DUMP_ATTR 
    21802164 
    2181   
     2165///////////////////////////////////////////////////////////////////////// 
     2166///////////////             TRANSFORMATIONS                    ////////// 
     2167///////////////////////////////////////////////////////////////////////// 
     2168 
     2169  std::map<StdString, ETranformationType> CDomain::transformationMapList_ = std::map<StdString, ETranformationType>(); 
     2170  bool CDomain::dummyTransformationMapList_ = CDomain::initializeTransformationMap(CDomain::transformationMapList_); 
     2171 
     2172  bool CDomain::initializeTransformationMap(std::map<StdString, ETranformationType>& m) 
     2173  TRY 
     2174  { 
     2175    m["zoom_domain"] = TRANS_ZOOM_DOMAIN; 
     2176    m["interpolate_domain"] = TRANS_INTERPOLATE_DOMAIN; 
     2177    m["generate_rectilinear_domain"] = TRANS_GENERATE_RECTILINEAR_DOMAIN; 
     2178    m["compute_connectivity_domain"] = TRANS_COMPUTE_CONNECTIVITY_DOMAIN; 
     2179    m["expand_domain"] = TRANS_EXPAND_DOMAIN; 
     2180    m["reorder_domain"] = TRANS_REORDER_DOMAIN; 
     2181    m["extract_domain"] = TRANS_EXTRACT_DOMAIN; 
     2182  } 
     2183  CATCH 
     2184 
     2185 
    21822186  CTransformation<CDomain>* CDomain::addTransformation(ETranformationType transType, const StdString& id) 
    21832187  TRY 
     
    21882192  CATCH_DUMP_ATTR 
    21892193 
     2194  CTransformation<CDomain>* CDomain::addTransformation(ETranformationType transType, CTransformation<CDomain>* transformation) 
     2195  TRY 
     2196  { 
     2197    transformationMap_.push_back(std::make_pair(transType, transformation)); 
     2198    return transformationMap_.back().second; 
     2199  } 
     2200  CATCH_DUMP_ATTR 
    21902201  /*! 
    21912202    Check whether a domain has transformation 
     
    22342245   * Go through the hierarchy to find the domain from which the transformations must be inherited 
    22352246   */ 
    2236   void CDomain::solveInheritanceTransformation() 
     2247  void CDomain::solveInheritanceTransformation_old() 
    22372248  TRY 
    22382249  { 
     
    22532264  } 
    22542265  CATCH_DUMP_ATTR 
     2266 
     2267 
     2268  void CDomain::solveInheritanceTransformation() 
     2269  TRY 
     2270  { 
     2271    if (solveInheritanceTransformation_done_) return; 
     2272    else solveInheritanceTransformation_done_=true ; 
     2273 
     2274    CDomain* domain = this; 
     2275    CDomain* Lastdomain ; 
     2276    std::list<CDomain*> refDomains; 
     2277    bool out=false ; 
     2278    vector<StdString> excludedAttr; 
     2279    excludedAttr.push_back("domain_ref"); 
     2280     
     2281    refDomains.push_front(domain) ; 
     2282    while (domain->hasDirectDomainReference() && !out) 
     2283    { 
     2284      CDomain* lastDomain=domain ; 
     2285      domain = domain->getDirectDomainReference(); 
     2286      domain->solveRefInheritance() ; 
     2287      if (!domain->SuperClass::isEqual(lastDomain,excludedAttr)) out=true ; 
     2288      refDomains.push_front(domain) ; 
     2289    } 
     2290 
     2291    CTransformationPaths::TPath path ; 
     2292    auto& pathList = std::get<2>(path) ; 
     2293    std::get<0>(path) = EElement::DOMAIN ; 
     2294    std::get<1>(path) = refDomains.front()->getId() ; 
     2295    for (auto& domain : refDomains) 
     2296    { 
     2297      CDomain::TransMapTypes transformations = domain->getAllTransformations(); 
     2298      for(auto& transformation : transformations) pathList.push_back({transformation.second->getTransformationType(),  
     2299                                                                      transformation.second->getId()}) ; 
     2300    } 
     2301    transformationPaths_.addPath(path) ; 
     2302 
     2303  } 
     2304  CATCH_DUMP_ATTR 
     2305   
     2306///////////////////////////////////////////////////////////////////////////////////////////// 
     2307/////////////////////////////////////////////////////////////////////////////////////////////  
    22552308 
    22562309  void CDomain::setContextClient(CContextClient* contextClient) 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/domain.hpp

    r1974 r1984  
    1616#include "transformation.hpp" 
    1717#include "transformation_enum.hpp" 
     18#include "transformation_path.hpp" 
    1819#include "server_distribution_description.hpp" 
    1920#include "mesh.hpp" 
     
    2324#include "gatherer_connector.hpp" 
    2425#include "distribution_type.hpp" 
    25  
    26  
    27 namespace xios { 
     26#include "generic_algorithm_transformation.hpp" 
     27 
     28 
     29namespace xios 
     30{ 
    2831 
    2932   /// ////////////////////// Déclarations ////////////////////// /// 
     
    6164         typedef CDomainAttributes RelAttributes; 
    6265         typedef CDomainGroup      RelGroup; 
    63          typedef CTransformation<CDomain>::TransformationMapTypes TransMapTypes; 
    64  
     66          
    6567         /// Constructeurs /// 
    6668         CDomain(void); 
     
    8284         bool checkAttributes_done_ = false ; 
    8385 
    84          bool hasTransformation(); 
    85          void solveInheritanceTransformation(); 
    86          TransMapTypes getAllTransformations(); 
     86          
     87      ////////////////////////// 
     88      ///// transformations //// 
     89      ////////////////////////// 
     90      public: 
     91        typedef CTransformation<CDomain>::TransformationMapTypes TransMapTypes; 
     92      private: 
     93        static bool initializeTransformationMap(std::map<StdString, ETranformationType>& m); 
     94        static std::map<StdString, ETranformationType> transformationMapList_; 
     95        static bool dummyTransformationMapList_; 
     96        TransMapTypes transformationMap_;          
     97 
     98      public: 
     99        CTransformation<CDomain>* addTransformation(ETranformationType transType, const StdString& id=""); 
     100        CTransformation<CDomain>* addTransformation(ETranformationType transType, CTransformation<CDomain>* transformation) ; 
     101        void setTransformations(const TransMapTypes&);          
     102        void duplicateTransformation(CDomain*); 
     103        TransMapTypes getAllTransformations(); 
     104        bool hasTransformation(); 
     105        void solveInheritanceTransformation_old(); // to remove later 
     106        void solveInheritanceTransformation(); 
     107      private: 
     108        bool solveInheritanceTransformation_done_= false ; 
     109      private: 
     110        CGenericAlgorithmTransformation* transformationAlgorithm_ = nullptr ; 
     111      public: 
     112        void setTransformationAlgorithm(CGenericAlgorithmTransformation* transformationAlgorithm) { transformationAlgorithm_=transformationAlgorithm ;} 
     113        CGenericAlgorithmTransformation* getTransformationAlgorithm(void) { return transformationAlgorithm_ ;}    
     114      private: 
     115        CTransformationPaths transformationPaths_ ; 
     116      public: 
     117        CTransformationPaths getTransformationPaths(void) {return transformationPaths_;}  
     118        void setTransformationPaths(const CTransformationPaths& transformationPaths) { transformationPaths_=transformationPaths ;} 
     119 
     120      //////////////////////////// 
     121 
    87122         void redistribute(int nbLocalDomain); 
    88          void duplicateTransformation(CDomain*); 
    89          CTransformation<CDomain>* addTransformation(ETranformationType transType, const StdString& id=""); 
    90123 
    91124      public: 
     
    195228         void checkArea(void); 
    196229         void checkLonLat(); 
    197  
    198          void setTransformations(const TransMapTypes&);          
    199          void computeNGlobDomain(); 
    200230          
    201231       public: 
     
    239269 
    240270         bool isRedistributed_; 
    241          TransMapTypes transformationMap_;          
    242271         bool isUnstructed_; 
    243272 
    244273        
    245        private: 
    246          static bool initializeTransformationMap(std::map<StdString, ETranformationType>& m); 
    247          static std::map<StdString, ETranformationType> transformationMapList_; 
    248          static bool _dummyTransformationMapList; 
    249  
    250274       ////////////////////////////////////////////////////////////////////////////////////// 
    251275       //  this part is related to distribution, element definition, views and connectors  // 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/duplicate_scalar_to_axis.cpp

    r1314 r1984  
    2828  bool CDuplicateScalarToAxis::registerTrans() 
    2929  { 
    30     return registerTransformation(TRANS_DUPLICATE_SCALAR_TO_AXIS, CDuplicateScalarToAxis::create); 
     30    return registerTransformation(TRANS_DUPLICATE_SCALAR_TO_AXIS, {create, getTransformation}); 
    3131  } 
    3232 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/duplicate_scalar_to_axis.hpp

    r1314 r1984  
    4141      typedef CObjectTemplate<CDuplicateScalarToAxis> SuperClass; 
    4242      typedef CDuplicateScalarToAxisAttributes SuperClassAttribute; 
     43      typedef CDuplicateScalarToAxis MyClass ; 
     44      typedef CTransformation<CAxis> SuperTransform ; 
    4345 
    4446    public : 
     
    5658      static StdString GetDefName(void); 
    5759      static ENodeType GetType(void); 
     60      const string& getId(void) { return this->SuperClass::getId();} 
     61      ETranformationType getTransformationType(void) { return TRANS_DUPLICATE_SCALAR_TO_AXIS ;} 
     62      static CTransformation<CAxis>* getTransformation(const StdString& id) { return SuperClass::get(id);} 
     63      virtual void inheritFrom(SuperTransform* srcTransform) { solveDescInheritance(true, this->SuperClass::get((MyClass*)srcTransform)) ;} 
    5864    private: 
    5965      static bool registerTrans(); 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/expand_domain.cpp

    r1158 r1984  
    2727  bool CExpandDomain::registerTrans() 
    2828  { 
    29     registerTransformation(TRANS_EXPAND_DOMAIN, CExpandDomain::create); 
     29    registerTransformation(TRANS_EXPAND_DOMAIN, {create, getTransformation}); 
    3030  } 
    3131 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/expand_domain.hpp

    r935 r1984  
    4141      typedef CObjectTemplate<CExpandDomain> SuperClass; 
    4242      typedef CExpandDomainAttributes SuperClassAttribute; 
     43      typedef CExpandDomain MyClass ; 
     44      typedef CTransformation<CDomain> SuperTransform ; 
    4345 
    4446    public : 
     
    5658      static StdString GetDefName(void); 
    5759      static ENodeType GetType(void); 
     60      const string& getId(void) { return this->SuperClass::getId();} 
     61      ETranformationType getTransformationType(void) { return TRANS_EXPAND_DOMAIN ;} 
     62      static CTransformation<CDomain>* getTransformation(const StdString& id) { return SuperClass::get(id);} 
     63      virtual void inheritFrom(SuperTransform* srcTransform) { solveDescInheritance(true, this->SuperClass::get((MyClass*)srcTransform)) ;} 
    5864    private: 
    5965      static bool registerTrans(); 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/extract_axis.cpp

    r1558 r1984  
    2626  bool CExtractAxis::registerTrans() 
    2727  { 
    28     return registerTransformation(TRANS_EXTRACT_AXIS, CExtractAxis::create); 
     28    return registerTransformation(TRANS_EXTRACT_AXIS, {create, getTransformation}); 
    2929  } 
    3030 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/extract_axis.hpp

    r1558 r1984  
    4141      typedef CObjectTemplate<CExtractAxis> SuperClass; 
    4242      typedef CExtractAxisAttributes SuperClassAttribute; 
     43      typedef CExtractAxis MyClass ; 
     44      typedef CTransformation<CAxis> SuperTransform ; 
    4345 
    4446    public : 
     
    5658      static StdString GetDefName(void); 
    5759      static ENodeType GetType(void); 
     60      const string& getId(void) { return this->SuperClass::getId();} 
     61      ETranformationType getTransformationType(void) { return TRANS_EXTRACT_AXIS ;} 
     62      static CTransformation<CAxis>* getTransformation(const StdString& id) { return SuperClass::get(id);} 
     63      virtual void inheritFrom(SuperTransform* srcTransform) { solveDescInheritance(true, this->SuperClass::get((MyClass*)srcTransform)) ;} 
    5864    private: 
    5965      static bool registerTrans(); 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/extract_axis_to_scalar.cpp

    r960 r1984  
    2828  bool CExtractAxisToScalar::registerTrans() 
    2929  { 
    30     return registerTransformation(TRANS_EXTRACT_AXIS_TO_SCALAR, CExtractAxisToScalar::create); 
     30    return registerTransformation(TRANS_EXTRACT_AXIS_TO_SCALAR, {create, getTransformation}); 
    3131  } 
    3232 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/extract_axis_to_scalar.hpp

    r960 r1984  
    4141      typedef CObjectTemplate<CExtractAxisToScalar> SuperClass; 
    4242      typedef CExtractAxisToScalarAttributes SuperClassAttribute; 
     43      typedef CExtractAxisToScalar MyClass ; 
     44      typedef CTransformation<CScalar> SuperTransform ; 
    4345 
    4446    public : 
     
    5658      static StdString GetDefName(void); 
    5759      static ENodeType GetType(void); 
     60      const string& getId(void) { return this->SuperClass::getId();} 
     61      ETranformationType getTransformationType(void) { return TRANS_EXTRACT_AXIS_TO_SCALAR ;} 
     62      static CTransformation<CScalar>* getTransformation(const StdString& id) { return SuperClass::get(id);} 
     63      virtual void inheritFrom(SuperTransform* srcTransform) { solveDescInheritance(true, this->SuperClass::get((MyClass*)srcTransform)) ;} 
    5864    private: 
    5965      static bool registerTrans(); 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/extract_domain.cpp

    r1549 r1984  
    2727  bool CExtractDomain::registerTrans() 
    2828  { 
    29     registerTransformation(TRANS_EXTRACT_DOMAIN, CExtractDomain::create); 
     29    registerTransformation(TRANS_EXTRACT_DOMAIN, {create, getTransformation}); 
    3030  } 
    3131 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/extract_domain.hpp

    r1549 r1984  
    4141      typedef CObjectTemplate<CExtractDomain> SuperClass; 
    4242      typedef CExtractDomainAttributes SuperClassAttribute; 
     43      typedef CExtractDomain MyClass ; 
     44      typedef CTransformation<CDomain> SuperTransform ; 
    4345 
    4446    public : 
     
    5658      static StdString GetDefName(void); 
    5759      static ENodeType GetType(void); 
    58     private: 
     60      const string& getId(void) { return this->SuperClass::getId();} 
     61      ETranformationType getTransformationType(void) { return TRANS_EXTRACT_DOMAIN ;} 
     62      static CTransformation<CDomain>* getTransformation(const StdString& id) { return SuperClass::get(id);} 
     63      virtual void inheritFrom(SuperTransform* srcTransform) { solveDescInheritance(true, this->SuperClass::get((MyClass*)srcTransform)) ;} 
     64     private: 
    5965      static bool registerTrans(); 
    6066      static CTransformation<CDomain>* create(const StdString& id, xml::CXMLNode* node); 
    61       static bool _dummyRegistered; 
     67     static bool _dummyRegistered; 
    6268  }; // class CExtractDomain 
    6369 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/extract_domain_to_axis.cpp

    r980 r1984  
    2828  bool CExtractDomainToAxis::registerTrans() 
    2929  { 
    30     return registerTransformation(TRANS_EXTRACT_DOMAIN_TO_AXIS, CExtractDomainToAxis::create); 
     30    return registerTransformation(TRANS_EXTRACT_DOMAIN_TO_AXIS, {create, getTransformation}); 
    3131  } 
    3232 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/extract_domain_to_axis.hpp

    r895 r1984  
    4141      typedef CObjectTemplate<CExtractDomainToAxis> SuperClass; 
    4242      typedef CExtractDomainToAxisAttributes SuperClassAttribute; 
    43  
     43      typedef CExtractDomainToAxis MyClass ; 
     44      typedef CTransformation<CAxis> SuperTransform ; 
     45  
    4446    public : 
    4547      /// Constructeurs /// 
     
    5658      static StdString GetDefName(void); 
    5759      static ENodeType GetType(void); 
     60      const string& getId(void) { return this->SuperClass::getId();} 
     61      ETranformationType getTransformationType(void) { return TRANS_EXTRACT_DOMAIN_TO_AXIS ;} 
     62      static CTransformation<CAxis>* getTransformation(const StdString& id) { return SuperClass::get(id);} 
     63      virtual void inheritFrom(SuperTransform* srcTransform) { solveDescInheritance(true, this->SuperClass::get((MyClass*)srcTransform)) ;} 
    5864    private: 
    5965      static bool registerTrans(); 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/field.cpp

    r1973 r1984  
    766766 
    767767      CGrid* gridSrc=getDirectFieldReference()->getGrid() ; 
     768      std::shared_ptr<COutputPin> lastFilter ; 
     769      if (filterExpr) lastFilter=filterExpr ; 
     770      else lastFilter = inputFilter ; 
     771      CGrid* newGrid ;     
     772       
    768773      for(auto grid : gridPath) 
    769774      { 
    770775        grid->solveElementsRefInheritance() ; 
     776        
     777        // new 
     778         
     779        std::pair<std::shared_ptr<CFilter>, std::shared_ptr<CFilter> > filters = grid->buildTransformationGraph(gc, gridSrc, detectMissingValues, defaultValue, newGrid) ; 
     780        lastFilter->connectOutput(filters.first, 0); 
     781        lastFilter = filters.second; 
     782        gridSrc = newGrid ; 
     783 
     784        // end new 
     785/* 
    771786        grid->completeGrid(gridSrc); // grid generation, to be checked 
    772787        grid->checkElementsAttributes() ; 
     
    775790          if (!CField::get(fieldId)->buildWorkflowGraph(gc)) return false ; 
    776791        gridSrc=grid ; 
    777       } 
    778        
     792*/ 
     793      } 
     794 
     795    /*   
    779796      std::shared_ptr<COutputPin> lastFilter ; 
    780797      if (filterExpr) lastFilter=filterExpr ; 
     
    793810        } 
    794811      } 
     812    */ 
     813      grid_=newGrid ; 
     814      grid_ref=grid_->getId() ; // for server  
    795815      instantDataFilter = lastFilter ; 
    796816       
     
    824844 
    825845        grid_->solveElementsRefInheritance() ; 
    826         grid_->completeGrid(); // grid generation, to be checked 
     846        CGrid* newGrid ; 
     847        std::pair<std::shared_ptr<CFilter>, std::shared_ptr<CFilter> > filters = grid_->buildTransformationGraph(gc, nullptr, detectMissingValues, defaultValue, newGrid) ; 
     848        grid_ = newGrid ; 
     849        grid_ref=grid_->getId() ; // for server  
     850//        grid_->completeGrid(); // grid generation, to be checked => later 
    827851        grid_->checkElementsAttributes() ; 
    828852        instantDataFilter=inputFilter ; 
     
    16031627    CContext::getCurrent()->sendContextToFileServer(client); 
    16041628    getRelFile()->sendFileToFileServer(client); 
    1605     grid_->sendGridToFileServer(client); 
     1629    sentGrid_ = grid_-> duplicateSentGrid() ; 
     1630    sentGrid_->sendGridToFileServer(client); 
     1631    name = getFieldOutputName() ; 
    16061632    this->sendAllAttributesToServer(client); 
    16071633    this->sendAddAllVariables(client); 
     
    16971723    if (grid_ref.isEmpty()) 
    16981724    { 
    1699       grid_ref=grid_->getId() ; 
     1725      grid_ref=sentGrid_->getId() ; 
    17001726      SuperClass::sendAllAttributesToServer(client) ; 
    17011727      domain_ref.reset() ; 
     
    17041730      grid_ref.reset(); 
    17051731    } 
    1706     else SuperClass::sendAllAttributesToServer(client) ; 
     1732    else  
     1733    { 
     1734      string tmp = grid_ref; 
     1735      grid_ref = sentGrid_->getId() ; 
     1736      SuperClass::sendAllAttributesToServer(client) ; 
     1737      grid_ref = tmp ; 
     1738    } 
    17071739  } 
    17081740  CATCH_DUMP_ATTR 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/field.hpp

    r1973 r1984  
    227227 
    228228        bool hasGridMask(void) const; 
    229         CGrid* getGrid(void) { return grid_; }  
    230  
     229         
    231230        void connectToFileServer(CGarbageCollector& gc) ; 
    232231        void connectToCouplerOut(CGarbageCollector& gc) ; 
     
    268267 
    269268         CGrid*  grid_=nullptr; 
     269         CGrid* getGrid(void) { return grid_; }  
     270       
     271      private: 
     272         CGrid* sentGrid_=nullptr ; 
     273      public: 
     274         CGrid* getSentGrid(void) { return sentGrid_; }     
     275 
     276      public: 
    270277//         CFile*  file; 
    271278          
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/generate_rectilinear_domain.cpp

    r838 r1984  
    2727  bool CGenerateRectilinearDomain::registerTrans() 
    2828  { 
    29     registerTransformation(TRANS_GENERATE_RECTILINEAR_DOMAIN, create); 
     29    registerTransformation(TRANS_GENERATE_RECTILINEAR_DOMAIN, {create, getTransformation}); 
    3030  } 
    3131 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/generate_rectilinear_domain.hpp

    r836 r1984  
    4141      typedef CObjectTemplate<CGenerateRectilinearDomain> SuperClass; 
    4242      typedef CGenerateRectilinearDomainAttributes SuperClassAttribute; 
     43      typedef CGenerateRectilinearDomain MyClass ; 
     44      typedef CTransformation<CDomain> SuperTransform ; 
    4345 
    4446    public : 
     
    5658      static StdString GetDefName(void); 
    5759      static ENodeType GetType(void); 
     60      const string& getId(void) { return this->SuperClass::getId();} 
     61      ETranformationType getTransformationType(void) { return TRANS_GENERATE_RECTILINEAR_DOMAIN ;} 
     62      static CTransformation<CDomain>* getTransformation(const StdString& id) { return SuperClass::get(id);} 
     63      virtual void inheritFrom(SuperTransform* srcTransform) { solveDescInheritance(true, this->SuperClass::get((MyClass*)srcTransform)) ;} 
    5864    private: 
    5965      static bool registerTrans(); 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/grid.cpp

    r1974 r1984  
    2424#include "grid_local_view.hpp" 
    2525#include "grid_mask_connector.hpp" 
    26  
    27  
    28 namespace xios { 
     26#include "transformation_path.hpp" 
     27#include "grid_transformation_factory_impl.hpp" 
     28#include "transform_filter.hpp" 
     29 
     30 
     31namespace xios 
     32{ 
    2933 
    3034   /// ////////////////////// Dfinitions ////////////////////// /// 
     
    236240     axis_domain_order.resize(order_.size()); 
    237241     for (int idx = 0; idx < order_.size(); ++idx) axis_domain_order(idx)=order_[idx]; 
    238      return vDomainGroup_->createChild(id); 
     242     CDomain* domain = vDomainGroup_->createChild(id); 
     243     computeElements(); 
     244     return domain ; 
    239245   } 
    240246   CATCH_DUMP_ATTR 
     
    246252     axis_domain_order.resize(order_.size()); 
    247253     for (int idx = 0; idx < order_.size(); ++idx) axis_domain_order(idx)=order_[idx]; 
    248      return vAxisGroup_->createChild(id); 
     254     CAxis* axis=vAxisGroup_->createChild(id); 
     255     computeElements();  
     256     return axis ; 
    249257   } 
    250258   CATCH_DUMP_ATTR 
     
    256264     axis_domain_order.resize(order_.size()); 
    257265     for (int idx = 0; idx < order_.size(); ++idx) axis_domain_order(idx)=order_[idx]; 
    258      return vScalarGroup_->createChild(id); 
     266     CScalar* scalar =  vScalarGroup_->createChild(id); 
     267     computeElements(); 
     268     return scalar; 
    259269   } 
    260270   CATCH_DUMP_ATTR 
     
    518528    int idxDomain = 0, idxAxis=0 , idxScalar=0 ;  
    519529  
     530    elements_.clear() ; 
    520531    for(auto type : order_) 
    521532    { 
     
    572583    setAxisList(); 
    573584    setScalarList(); 
     585    computeElements() ; 
    574586   } 
    575587   CATCH_DUMP_ATTR 
     
    960972 
    961973    
    962 //---------------------------------------------------------------- 
    963  
    964974 
    965975 
     
    18711881 
    18721882 
    1873  
    1874  
    1875  
    1876  
    1877  
    18781883  bool CGrid::hasTransform() 
    18791884  TRY 
     
    18921897  } 
    18931898  CATCH_DUMP_ATTR 
     1899 
     1900 
     1901 
     1902//********************************************************** 
     1903//**************   New transformation method  ************** 
     1904//********************************************************** 
     1905 
     1906  std::pair<std::shared_ptr<CFilter>, std::shared_ptr<CFilter> >  
     1907  CGrid::buildTransformationGraph(CGarbageCollector& gc, CGrid* gridSrc, double detectMissingValues, double defaultValue, CGrid*& newGrid) 
     1908  TRY 
     1909  { 
     1910    std::shared_ptr<CFilter> inputFilter = std::shared_ptr<CPassThroughFilter>(new CPassThroughFilter(gc)); 
     1911    std::shared_ptr<CFilter> outputFilter = inputFilter ; 
     1912     
     1913    newGrid = CGrid::create() ; // give it an id later ?? 
     1914    bool hadTransform=false ; 
     1915    bool hasTransform=false ; 
     1916    CGenericAlgorithmTransformation* algo ; 
     1917    int dimBefore=1 ; 
     1918    int dimAfter=1 ; 
     1919 
     1920    for(int i=0 ; i<elements_.size(); i++) 
     1921    { 
     1922      CTransformationPaths transformationPath ; 
     1923      auto dstElement = elements_[i] ; 
     1924 
     1925      if (dstElement.type==TYPE_DOMAIN)      transformationPath = dstElement.domain->getTransformationPaths() ; 
     1926      else if (dstElement.type==TYPE_AXIS)   transformationPath = dstElement.axis->getTransformationPaths() ; 
     1927      else if (dstElement.type==TYPE_SCALAR) transformationPath = dstElement.scalar->getTransformationPaths() ; 
     1928 
     1929      SElement srcElement  ; 
     1930      if (gridSrc==nullptr) srcElement = this->elements_[i] ; 
     1931      else srcElement = gridSrc->elements_[i] ; 
     1932 
     1933      if (gridSrc==nullptr) transformationPath.mergePaths() ; 
     1934      else 
     1935      {   
     1936        if (srcElement.type==TYPE_DOMAIN)      transformationPath.mergePaths(srcElement.domain->getTransformationPaths()) ; 
     1937        else if (srcElement.type==TYPE_AXIS)   transformationPath.mergePaths(srcElement.axis->getTransformationPaths()) ; 
     1938        else if (srcElement.type==TYPE_SCALAR) transformationPath.mergePaths(srcElement.scalar->getTransformationPaths()) ; 
     1939      } 
     1940 
     1941      hasTransform=transformationPath.hasTransform()  ; 
     1942       
     1943 
     1944      if (hasTransform && !hadTransform) 
     1945      { 
     1946        EElement dstElementType=transformationPath.getNextElementType() ; 
     1947        string dstElementId=transformationPath.getNextElementId() ; 
     1948        string srcElementId=transformationPath.getNextElementSrcId() ; 
     1949        auto transType = transformationPath.getNextTransformationType() ; 
     1950        auto transId = transformationPath.getNextTransformationId() ; 
     1951 
     1952        CGrid* tmpGridSrc=CGrid::create(); // source grid  
     1953        if (srcElement.type==TYPE_DOMAIN)      tmpGridSrc->addDomain(srcElement.domain->getId()) ; 
     1954        else if (srcElement.type==TYPE_AXIS)   tmpGridSrc->addAxis(srcElement.axis->getId()) ; 
     1955        else if (srcElement.type==TYPE_SCALAR) tmpGridSrc->addScalar(srcElement.scalar->getId()) ; 
     1956        tmpGridSrc->checkElementsAttributes() ; 
     1957        CGrid* tmpGridDst=CGrid::create(); // destination Grid 
     1958        map<int,int> posInGrid={{0,0}} ; 
     1959                
     1960        cout<<"--> New transform from "<<srcElementId<<" to "<<dstElementId<<endl ; 
     1961        if (dstElementType==EElement::DOMAIN) 
     1962        { 
     1963          CDomain* dstDomain ; 
     1964          if (CDomain::has(dstElementId)) dstDomain = CDomain::get(dstElementId) ; 
     1965          else 
     1966          { 
     1967            dstDomain = CDomain::create() ; 
     1968            dstDomain->createAlias(dstElementId) ; 
     1969            if (srcElementId=="" && srcElement.type==TYPE_DOMAIN)  dstDomain->duplicateAttributes(srcElement.domain) ; // make a copy 
     1970            else dstDomain->duplicateAttributes(CDomain::get(srcElementId)) ; // make a copy 
     1971            CTransformation<CDomain>* transformation = CTransformation<CDomain>::createTransformation(transType,"") ; 
     1972            auto srcTransform = CTransformation<CDomain>::getTransformation(transType, transId) ; 
     1973            transformation->inheritFrom(srcTransform) ; 
     1974            tmpGridDst->addDomain(dstDomain->getId()) ; 
     1975 
     1976            //reuse existing algorithm interface for, now 
     1977            algo = CGridTransformationFactory<CDomain>::createTransformation(transType, tmpGridDst, tmpGridSrc, 
     1978                                                                             transformation, 0,  
     1979                                                                             posInGrid,posInGrid,posInGrid, 
     1980                                                                             posInGrid,posInGrid,posInGrid ); 
     1981            dstDomain->setTransformationAlgorithm(algo) ; 
     1982            transformationPath.removeNextTransform() ; 
     1983            dstDomain->setTransformationPaths(transformationPath) ; 
     1984            newGrid->addDomain(dstDomain->getId()) ; 
     1985          } 
     1986          algo = dstDomain->getTransformationAlgorithm() ; 
     1987        } 
     1988        else if (dstElementType==EElement::AXIS) 
     1989        { 
     1990          CAxis* dstAxis ; 
     1991          if (CAxis::has(dstElementId)) dstAxis = CAxis::get(dstElementId) ; 
     1992          else 
     1993          { 
     1994            dstAxis = CAxis::create() ; 
     1995            dstAxis->createAlias(dstElementId) ; 
     1996            if (srcElementId=="" && srcElement.type==TYPE_AXIS)  dstAxis->duplicateAttributes(srcElement.axis) ; // make a copy 
     1997            else dstAxis->duplicateAttributes(CAxis::get(srcElementId)) ; // make a copy 
     1998            CTransformation<CAxis>* transformation = CTransformation<CAxis>::createTransformation(transType,"") ; 
     1999            auto srcTransform = CTransformation<CAxis>::getTransformation(transType, transId) ; 
     2000            transformation->inheritFrom(srcTransform) ; 
     2001            tmpGridDst->addAxis(dstAxis->getId()) ; 
     2002 
     2003            //reuse existing algorithm interface for, now 
     2004            algo = CGridTransformationFactory<CAxis>::createTransformation(transType, tmpGridDst, tmpGridSrc, 
     2005                                                                           transformation, 0,  
     2006                                                                           posInGrid,posInGrid,posInGrid, 
     2007                                                                           posInGrid,posInGrid,posInGrid ); 
     2008            dstAxis->setTransformationAlgorithm(algo) ; 
     2009            transformationPath.removeNextTransform() ; 
     2010            dstAxis->setTransformationPaths(transformationPath) ; 
     2011            newGrid->addAxis(dstAxis->getId()) ; 
     2012          } 
     2013          algo = dstAxis->getTransformationAlgorithm() ; 
     2014        } 
     2015        else if (dstElementType==EElement::SCALAR) 
     2016        { 
     2017          CScalar* dstScalar ; 
     2018          if (CScalar::has(dstElementId)) dstScalar = CScalar::get(dstElementId) ; 
     2019          else 
     2020          { 
     2021            dstScalar = CScalar::create() ; 
     2022            dstScalar->createAlias(dstElementId) ; 
     2023            if (srcElementId=="" && srcElement.type==TYPE_SCALAR)  dstScalar->duplicateAttributes(srcElement.scalar) ; // make a copy 
     2024            else dstScalar->duplicateAttributes(CScalar::get(srcElementId)) ; // make a copy 
     2025            CTransformation<CScalar>* transformation = CTransformation<CScalar>::createTransformation(transType,"") ; 
     2026            auto srcTransform = CTransformation<CScalar>::getTransformation(transType, transId) ; 
     2027            transformation->inheritFrom(srcTransform) ; 
     2028            tmpGridDst->addScalar(dstScalar->getId()) ; 
     2029 
     2030            //reuse existing algorithm interface for, now 
     2031            algo = CGridTransformationFactory<CScalar>::createTransformation(transType, tmpGridDst, tmpGridSrc, 
     2032                                                                             transformation, 0,  
     2033                                                                             posInGrid,posInGrid,posInGrid, 
     2034                                                                             posInGrid,posInGrid,posInGrid ); 
     2035            dstScalar->setTransformationAlgorithm(algo) ; 
     2036            transformationPath.removeNextTransform() ; 
     2037            dstScalar->setTransformationPaths(transformationPath) ; 
     2038            newGrid->addScalar(dstScalar->getId()) ; 
     2039          } 
     2040          algo = dstScalar->getTransformationAlgorithm() ;           
     2041        } 
     2042        // here create a new spatial filter with algo 
     2043         
     2044        hadTransform=true ; 
     2045        hasTransform=false ;  
     2046      } 
     2047      else 
     2048      { 
     2049        string srcElementId=transformationPath.getNextElementSrcId() ; 
     2050        if (srcElement.type==TYPE_DOMAIN)       
     2051        { 
     2052          CDomain* domain ; 
     2053          if (!CDomain::has(srcElementId))  
     2054          { 
     2055            domain=srcElement.domain ; 
     2056            domain->createAlias(srcElementId) ; 
     2057          } 
     2058          else domain = CDomain::get(srcElementId) ; 
     2059          domain->checkAttributes() ; 
     2060          
     2061          if (hadTransform) dimBefore*=domain->getLocalView(CElementView::WORKFLOW)->getLocalSize() ; 
     2062          else dimAfter*=domain->getLocalView(CElementView::WORKFLOW)->getLocalSize() ; 
     2063          newGrid->addDomain(srcElementId) ; 
     2064        } 
     2065        else if (srcElement.type==TYPE_AXIS) 
     2066        {    
     2067          CAxis* axis ; 
     2068          if (!CAxis::has(srcElementId))  
     2069          { 
     2070            axis=srcElement.axis ; 
     2071            axis->createAlias(srcElementId) ; 
     2072          } 
     2073          else axis = CAxis::get(srcElementId) ; 
     2074          axis->checkAttributes() ; 
     2075          
     2076          if (hadTransform) dimBefore*=axis->getLocalView(CElementView::WORKFLOW)->getLocalSize() ; 
     2077          else dimAfter*=axis->getLocalView(CElementView::WORKFLOW)->getLocalSize() ; 
     2078          newGrid->addAxis(srcElementId) ; 
     2079        } 
     2080        else if (srcElement.type==TYPE_SCALAR) 
     2081        { 
     2082          CScalar* scalar ; 
     2083          if (!CScalar::has(srcElementId))  
     2084          { 
     2085            scalar=srcElement.scalar ; 
     2086            scalar->createAlias(srcElementId) ; 
     2087          } 
     2088          else scalar = CScalar::get(srcElementId) ; 
     2089          scalar->checkAttributes() ; 
     2090          
     2091          if (hadTransform) dimBefore*=scalar->getLocalView(CElementView::WORKFLOW)->getLocalSize() ; 
     2092          else dimAfter*=scalar->getLocalView(CElementView::WORKFLOW)->getLocalSize() ; 
     2093          newGrid->addScalar(srcElementId) ; 
     2094        } 
     2095      } 
     2096    }   
     2097     
     2098    if (hadTransform) 
     2099    { 
     2100      shared_ptr<CTransformFilter> transformFilter = shared_ptr<CTransformFilter>(new CTransformFilter(gc, algo, dimBefore, dimAfter, detectMissingValues, defaultValue)) ; 
     2101      outputFilter->connectOutput(transformFilter,0) ; 
     2102      outputFilter = transformFilter ; 
     2103 
     2104      gridSrc=newGrid ; 
     2105      pair<shared_ptr<CFilter>, shared_ptr<CFilter> > filters = gridSrc->buildTransformationGraph(gc, gridSrc, detectMissingValues, defaultValue, newGrid) ; 
     2106      outputFilter->connectOutput(filters.first,0) ; 
     2107      outputFilter=filters.second ; 
     2108    } 
     2109      
     2110    return {inputFilter,outputFilter} ; 
     2111  } 
     2112  CATCH_DUMP_ATTR 
     2113 
     2114 
     2115//**************************************************************** 
     2116//**************************************************************** 
     2117 
     2118//---------------------------------------------------------------- 
     2119 
     2120  CGrid* CGrid::duplicateSentGrid(void) 
     2121  { 
     2122    CGrid* newGrid ; 
     2123    string sentGridId="sent__"+getId() ; 
     2124    if (has(sentGridId)) newGrid = get(sentGridId) ; 
     2125    else 
     2126    { 
     2127      newGrid = CGrid::create(sentGridId) ; 
     2128      for(auto element : elements_) 
     2129      { 
     2130        if (element.type==TYPE_DOMAIN)       
     2131        { 
     2132          CDomain* domain = CDomain::create(); 
     2133          domain->duplicateAttributes(element.domain) ; 
     2134          domain->name = element.domain->getId() ; 
     2135          newGrid->addDomain(domain->getId()) ; 
     2136        } 
     2137        else if (element.type==TYPE_AXIS)       
     2138        { 
     2139          CAxis* axis = CAxis::create(); 
     2140          axis->duplicateAttributes(element.axis) ; 
     2141          axis->name = element.axis->getId() ; 
     2142          newGrid->addAxis(axis->getId()) ; 
     2143        } 
     2144        else if (element.type==TYPE_SCALAR)       
     2145        { 
     2146          CScalar* scalar = CScalar::create(); 
     2147          scalar->duplicateAttributes(element.scalar) ; 
     2148          scalar->name = element.scalar->getId() ; 
     2149          newGrid->addScalar(scalar->getId()) ; 
     2150        } 
     2151      } 
     2152      newGrid->checkElementsAttributes() ; 
     2153    } 
     2154    return newGrid ; 
     2155  } 
     2156 
    18942157 
    18952158  void CGrid::setContextClient(CContextClient* contextClient) 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/grid.hpp

    r1974 r1984  
    2020#include "grid_scatterer_connector.hpp" 
    2121#include "grid_gatherer_connector.hpp" 
     22#include "transformation_path.hpp" 
     23#include "filter.hpp" 
    2224 
    2325 
     
    210212         bool doGridHaveDataDistributed(CContextClient* client = 0); 
    211213 
     214         /////////////////////////////////////////// 
     215         ////////    TRANSFORMATIONS           ///// 
     216         /////////////////////////////////////////// 
     217      public: 
    212218         CGridTransformation* getTransformations(); 
    213219 
     
    221227          
    222228         std::vector<std::string> getAuxInputTransformGrid(void) ;  
    223  
     229         std::map<CGrid*, std::pair<bool,StdString> >& getTransGridSource(); 
     230         bool hasTransform(); 
     231         void addTransGridSource(CGrid* gridSrc); 
    224232         void completeGrid(CGrid* transformGridSrc = 0); 
    225233         bool isTransformed(); 
     
    227235         bool isGenerated(); 
    228236         void setGenerated(); 
    229          void addTransGridSource(CGrid* gridSrc); 
    230          std::map<CGrid*, std::pair<bool,StdString> >& getTransGridSource(); 
    231          bool hasTransform(); 
    232          size_t getGlobalWrittenSize(void) ; 
     237         void setTransformationAlgorithms(); 
     238         pair<shared_ptr<CFilter>, shared_ptr<CFilter> > buildTransformationGraph(CGarbageCollector& gc, CGrid* gridSrc, double detectMissingValues, 
     239                                                                                  double defaultValue, CGrid*& newGrid) ; 
     240      private: 
     241         bool isTransformed_, isGenerated_; 
     242         CGridTransformation* transformations_; 
     243         bool hasTransform_; 
     244        
     245        /////////////////////////////////////////// 
     246      public: 
     247 
     248        size_t getGlobalWrittenSize(void) ; 
    233249          
    234250         bool isCompleted(void) ; 
     
    265281        CScalarGroup* getVirtualScalarGroup() const; 
    266282 
    267         void setTransformationAlgorithms(); 
    268283        int computeGridGlobalDimension(std::vector<int>& globalDim, 
    269284                                       const std::vector<CDomain*> domains, 
     
    310325        std::set<std::string> relFilesCompressed; 
    311326 
    312         bool isTransformed_, isGenerated_; 
    313327         
    314328        std::vector<int> axisPositionInGrid_; 
     
    317331        std::vector<int>& getAxisPositionInGrid(void) { if (!computeAxisPositionInGrid_done_) computeAxisPositionInGrid() ; return axisPositionInGrid_ ;} 
    318332 
    319         CGridTransformation* transformations_; 
    320333        bool hasDomainAxisBaseRef_;         
    321334        std::map<CGrid*, std::pair<bool,StdString> > gridSrc_; 
    322         bool hasTransform_; 
    323335 
    324336     ////////////////////////////////////////////////////////////////////////////////////// 
    325337     //  this part is related to distribution, element definition, views and connectors  // 
    326338     ////////////////////////////////////////////////////////////////////////////////////// 
     339      public: 
     340       CGrid* duplicateSentGrid(void) ; 
    327341      private: 
    328342       static void recvMask(CEventServer& event) ; 
     
    336350 
    337351      private: 
    338         CGridLocalConnector* modelToWorkflowConnector_ ; 
     352        CGridLocalConnector* modelToWorkflowConnector_ = nullptr ; 
    339353      public: 
    340354        void computeModelToWorkflowConnector(void) ; 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/interpolate_axis.cpp

    r937 r1984  
    2727  bool CInterpolateAxis::registerTrans() 
    2828  { 
    29     return registerTransformation(TRANS_INTERPOLATE_AXIS, CInterpolateAxis::create); 
     29    return registerTransformation(TRANS_INTERPOLATE_AXIS, {create, getTransformation}); 
    3030  } 
    3131 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/interpolate_axis.hpp

    r836 r1984  
    4141      typedef CObjectTemplate<CInterpolateAxis> SuperClass; 
    4242      typedef CInterpolateAxisAttributes SuperClassAttribute; 
     43      typedef CInterpolateAxis MyClass ; 
     44      typedef CTransformation<CAxis> SuperTransform ; 
    4345 
    4446    public : 
     
    5860      static StdString GetDefName(void); 
    5961      static ENodeType GetType(void); 
     62      const string& getId(void) { return this->SuperClass::getId();} 
     63      ETranformationType getTransformationType(void) { return TRANS_INTERPOLATE_AXIS ;} 
     64      static CTransformation<CAxis>* getTransformation(const StdString& id) { return SuperClass::get(id);} 
     65      virtual void inheritFrom(SuperTransform* srcTransform) { solveDescInheritance(true, this->SuperClass::get((MyClass*)srcTransform)) ;} 
    6066    private: 
    6167      static bool registerTrans(); 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/interpolate_domain.cpp

    r1615 r1984  
    2727  bool CInterpolateDomain::registerTrans() 
    2828  { 
    29     registerTransformation(TRANS_INTERPOLATE_DOMAIN, create); 
     29    registerTransformation(TRANS_INTERPOLATE_DOMAIN, {create, getTransformation}); 
    3030  } 
    3131 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/interpolate_domain.hpp

    r1021 r1984  
    4141      typedef CObjectTemplate<CInterpolateDomain> SuperClass; 
    4242      typedef CInterpolateDomainAttributes SuperClassAttribute; 
     43      typedef CInterpolateDomain MyClass ; 
     44      typedef CTransformation<CDomain> SuperTransform ; 
    4345 
    4446    public : 
     
    5658      static StdString GetDefName(void); 
    5759      static ENodeType GetType(void); 
     60      const string& getId(void) { return this->SuperClass::getId();} 
     61      ETranformationType getTransformationType(void) { return TRANS_INTERPOLATE_DOMAIN ;} 
     62      static CTransformation<CDomain>* getTransformation(const StdString& id) { return SuperClass::get(id);} 
     63      virtual void inheritFrom(SuperTransform* srcTransform) { solveDescInheritance(true, this->SuperClass::get((MyClass*)srcTransform)) ;} 
    5864    private: 
    5965      static bool registerTrans(); 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/inverse_axis.cpp

    r836 r1984  
    2626  bool CInverseAxis::registerTrans() 
    2727  { 
    28     return registerTransformation(TRANS_INVERSE_AXIS, CInverseAxis::create); 
     28    return registerTransformation(TRANS_INVERSE_AXIS, {create, getTransformation}); 
    2929  } 
    3030 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/inverse_axis.hpp

    r836 r1984  
    3939      typedef CObjectTemplate<CInverseAxis> SuperClass; 
    4040      typedef CInverseAxisAttributes SuperClassAttribute; 
     41      typedef CInverseAxis MyClass ; 
     42      typedef CTransformation<CAxis> SuperTransform ; 
    4143 
    4244    public : 
     
    5456      static StdString GetDefName(void); 
    5557      static ENodeType GetType(void); 
    56  
     58      const string& getId(void) { return this->SuperClass::getId();} 
     59      ETranformationType getTransformationType(void) { return TRANS_INVERSE_AXIS ;} 
     60      static CTransformation<CAxis>* getTransformation(const StdString& id) { return SuperClass::get(id);} 
     61      virtual void inheritFrom(SuperTransform* srcTransform) { solveDescInheritance(true, this->SuperClass::get((MyClass*)srcTransform)) ;} 
    5762    private: 
    5863      static bool registerTrans(); 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/reduce_axis_to_axis.cpp

    r1314 r1984  
    2727  bool CReduceAxisToAxis::registerTrans() 
    2828  { 
    29     return registerTransformation(TRANS_REDUCE_AXIS_TO_AXIS, CReduceAxisToAxis::create); 
     29    return registerTransformation(TRANS_REDUCE_AXIS_TO_AXIS, {create, getTransformation}); 
    3030  } 
    3131 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/reduce_axis_to_axis.hpp

    r1301 r1984  
    4040      typedef CObjectTemplate<CReduceAxisToAxis> SuperClass; 
    4141      typedef CReduceAxisToAxisAttributes SuperClassAttribute; 
     42      typedef CReduceAxisToAxis MyClass ; 
     43      typedef CTransformation<CAxis> SuperTransform ; 
    4244 
    4345    public : 
     
    5557      static StdString GetDefName(void); 
    5658      static ENodeType GetType(void); 
     59      const string& getId(void) { return this->SuperClass::getId();} 
     60      ETranformationType getTransformationType(void) { return TRANS_REDUCE_AXIS_TO_AXIS ;} 
     61      static CTransformation<CAxis>* getTransformation(const StdString& id) { return SuperClass::get(id);} 
     62      virtual void inheritFrom(SuperTransform* srcTransform) { solveDescInheritance(true, this->SuperClass::get((MyClass*)srcTransform)) ;} 
    5763    private: 
    5864      static bool registerTrans(); 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/reduce_axis_to_scalar.cpp

    r980 r1984  
    2626  bool CReduceAxisToScalar::registerTrans() 
    2727  { 
    28     return registerTransformation(TRANS_REDUCE_AXIS_TO_SCALAR, CReduceAxisToScalar::create); 
     28    return registerTransformation(TRANS_REDUCE_AXIS_TO_SCALAR, {create, getTransformation}); 
    2929  } 
    3030 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/reduce_axis_to_scalar.hpp

    r888 r1984  
    4040      typedef CObjectTemplate<CReduceAxisToScalar> SuperClass; 
    4141      typedef CReduceAxisToScalarAttributes SuperClassAttribute; 
     42      typedef CReduceAxisToScalar MyClass ; 
     43      typedef CTransformation<CScalar> SuperTransform ; 
    4244 
    4345    public : 
     
    5557      static StdString GetDefName(void); 
    5658      static ENodeType GetType(void); 
     59      const string& getId(void) { return this->SuperClass::getId();} 
     60      ETranformationType getTransformationType(void) { return TRANS_REDUCE_AXIS_TO_SCALAR ;} 
     61      static CTransformation<CScalar>* getTransformation(const StdString& id) { return SuperClass::get(id);} 
     62      virtual void inheritFrom(SuperTransform* srcTransform) { solveDescInheritance(true, this->SuperClass::get((MyClass*)srcTransform)) ;} 
    5763    private: 
    5864      static bool registerTrans(); 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/reduce_domain_to_axis.cpp

    r1299 r1984  
    2828  bool CReduceDomainToAxis::registerTrans() 
    2929  { 
    30     return registerTransformation(TRANS_REDUCE_DOMAIN_TO_AXIS, CReduceDomainToAxis::create); 
     30    return registerTransformation(TRANS_REDUCE_DOMAIN_TO_AXIS, {create, getTransformation}); 
    3131  } 
    3232 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/reduce_domain_to_axis.hpp

    r895 r1984  
    4141      typedef CObjectTemplate<CReduceDomainToAxis> SuperClass; 
    4242      typedef CReduceDomainToAxisAttributes SuperClassAttribute; 
     43      typedef CReduceDomainToAxis MyClass ; 
     44     typedef CTransformation<CAxis> SuperTransform ; 
    4345 
    4446    public : 
     
    5658      static StdString GetDefName(void); 
    5759      static ENodeType GetType(void); 
    58     private: 
     60      const string& getId(void) { return this->SuperClass::getId();} 
     61      ETranformationType getTransformationType(void) { return TRANS_REDUCE_DOMAIN_TO_AXIS ;} 
     62      static CTransformation<CAxis>* getTransformation(const StdString& id) { return SuperClass::get(id);} 
     63      virtual void inheritFrom(SuperTransform* srcTransform) { solveDescInheritance(true, this->SuperClass::get((MyClass*)srcTransform)) ;} 
     64     private: 
    5965      static bool registerTrans(); 
    6066      static CTransformation<CAxis>* create(const StdString& id, xml::CXMLNode* node); 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/reduce_domain_to_scalar.cpp

    r1313 r1984  
    2626  bool CReduceDomainToScalar::registerTrans() 
    2727  { 
    28     return registerTransformation(TRANS_REDUCE_DOMAIN_TO_SCALAR, CReduceDomainToScalar::create); 
     28    return registerTransformation(TRANS_REDUCE_DOMAIN_TO_SCALAR, {create, getTransformation}); 
    2929  } 
    3030 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/reduce_domain_to_scalar.hpp

    r976 r1984  
    4141      typedef CObjectTemplate<CReduceDomainToScalar> SuperClass; 
    4242      typedef CReduceDomainToScalarAttributes SuperClassAttribute; 
     43      typedef CReduceDomainToScalar MyClass ; 
     44      typedef CTransformation<CScalar> SuperTransform ; 
    4345 
    4446    public : 
     
    5658      static StdString GetDefName(void); 
    5759      static ENodeType GetType(void); 
     60      const string& getId(void) { return this->SuperClass::getId();} 
     61      ETranformationType getTransformationType(void) { return TRANS_REDUCE_DOMAIN_TO_SCALAR ;} 
     62      static CTransformation<CScalar>* getTransformation(const StdString& id) { return SuperClass::get(id);} 
     63      virtual void inheritFrom(SuperTransform* srcTransform) { solveDescInheritance(true, this->SuperClass::get((MyClass*)srcTransform)) ;} 
    5864    private: 
    5965      static bool registerTrans(); 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/reduce_scalar_to_scalar.cpp

    r1314 r1984  
    2626  bool CReduceScalarToScalar::registerTrans() 
    2727  { 
    28     return registerTransformation(TRANS_REDUCE_SCALAR_TO_SCALAR, CReduceScalarToScalar::create); 
     28    return registerTransformation(TRANS_REDUCE_SCALAR_TO_SCALAR, {create, getTransformation}); 
    2929  } 
    3030 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/reduce_scalar_to_scalar.hpp

    r1314 r1984  
    4040      typedef CObjectTemplate<CReduceScalarToScalar> SuperClass; 
    4141      typedef CReduceScalarToScalarAttributes SuperClassAttribute; 
     42      typedef CReduceScalarToScalar MyClass ; 
     43      typedef CTransformation<CScalar> SuperTransform ; 
    4244 
    4345    public : 
     
    5557      static StdString GetDefName(void); 
    5658      static ENodeType GetType(void); 
     59      const string& getId(void) { return this->SuperClass::getId();} 
     60      ETranformationType getTransformationType(void) { return TRANS_REDUCE_SCALAR_TO_SCALAR ;} 
     61      static CTransformation<CScalar>* getTransformation(const StdString& id) { return SuperClass::get(id);} 
     62      virtual void inheritFrom(SuperTransform* srcTransform) { solveDescInheritance(true, this->SuperClass::get((MyClass*)srcTransform)) ;} 
    5763    private: 
    5864      static bool registerTrans(); 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/reorder_domain.cpp

    r1457 r1984  
    2727  bool CReorderDomain::registerTrans() 
    2828  { 
    29     registerTransformation(TRANS_REORDER_DOMAIN, CReorderDomain::create); 
     29    registerTransformation(TRANS_REORDER_DOMAIN, {create, getTransformation}); 
    3030  } 
    3131 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/reorder_domain.hpp

    r1457 r1984  
    4141      typedef CObjectTemplate<CReorderDomain> SuperClass; 
    4242      typedef CReorderDomainAttributes SuperClassAttribute; 
     43      typedef CReorderDomain MyClass ; 
     44      typedef CTransformation<CDomain> SuperTransform ; 
    4345 
    4446    public : 
     
    5658      static StdString GetDefName(void); 
    5759      static ENodeType GetType(void); 
    58     private: 
     60      const string& getId(void) { return this->SuperClass::getId();} 
     61      ETranformationType getTransformationType(void) { return TRANS_REORDER_DOMAIN ;} 
     62      static CTransformation<CDomain>* getTransformation(const StdString& id) { return SuperClass::get(id);} 
     63      virtual void inheritFrom(SuperTransform* srcTransform) { solveDescInheritance(true, this->SuperClass::get((MyClass*)srcTransform)) ;} 
     64     private: 
    5965      static bool registerTrans(); 
    6066      static CTransformation<CDomain>* create(const StdString& id, xml::CXMLNode* node); 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/scalar.cpp

    r1975 r1984  
    135135   * Go through the hierarchy to find the scalar from which the transformations must be inherited 
    136136   */ 
    137   void CScalar::solveInheritanceTransformation() 
     137  void CScalar::solveInheritanceTransformation_old() 
    138138  { 
    139139    if (hasTransformation() || !hasDirectScalarReference()) 
     
    153153  } 
    154154  
     155  void CScalar::solveInheritanceTransformation() 
     156  TRY 
     157  { 
     158    if (solveInheritanceTransformation_done_) return; 
     159    else solveInheritanceTransformation_done_=true ; 
     160 
     161    CScalar* scalar = this; 
     162    CScalar* Lastscalar ; 
     163    std::list<CScalar*> refScalars; 
     164    bool out=false ; 
     165    vector<StdString> excludedAttr; 
     166    excludedAttr.push_back("scalar_ref"); 
     167     
     168    refScalars.push_front(scalar) ; 
     169    while (scalar->hasDirectScalarReference() && !out) 
     170    { 
     171      CScalar* lastScalar=scalar ; 
     172      scalar = scalar->getDirectScalarReference(); 
     173      scalar->solveRefInheritance() ; 
     174      if (!scalar->SuperClass::isEqual(lastScalar,excludedAttr)) out=true ; 
     175      refScalars.push_front(scalar) ; 
     176    } 
     177 
     178    CTransformationPaths::TPath path ; 
     179    auto& pathList = std::get<2>(path) ; 
     180    std::get<0>(path) = EElement::SCALAR ; 
     181    std::get<1>(path) = refScalars.front()->getId() ; 
     182    for (auto& scalar : refScalars) 
     183    { 
     184      CScalar::TransMapTypes transformations = scalar->getAllTransformations(); 
     185      for(auto& transformation : transformations) pathList.push_back({transformation.second->getTransformationType(),  
     186                                                                      transformation.second->getId()}) ; 
     187    } 
     188    transformationPaths_.addPath(path) ; 
     189 
     190  } 
     191  CATCH_DUMP_ATTR 
     192 
    155193  /* obsolete, to remove after reimplementing coupling */ 
    156194  void CScalar::sendScalarToCouplerOut(CContextClient* client, const string& fieldId, int posInGrid) 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/scalar.hpp

    r1975 r1984  
    1313#include "transformation.hpp" 
    1414#include "transformation_enum.hpp" 
    15  
     15#include "transformation_path.hpp" 
    1616#include "element.hpp" 
    1717#include "local_connector.hpp" 
     
    1919#include "gatherer_connector.hpp" 
    2020#include "distribution_type.hpp" 
     21#include "generic_algorithm_transformation.hpp" 
    2122 
    2223 
    2324namespace xios 
    2425{ 
    25       /// ////////////////////// Déclarations ////////////////////// /// 
    26  
    27       class CScalarGroup; 
    28       class CScalarAttributes; 
    29       class CScalar; 
    30       ///-------------------------------------------------------------- 
    31  
    32       // Declare/Define CVarAttribute 
    33       BEGIN_DECLARE_ATTRIBUTE_MAP(CScalar) 
     26  /// ////////////////////// Déclarations ////////////////////// /// 
     27 
     28  class CScalarGroup; 
     29  class CScalarAttributes; 
     30  class CScalar; 
     31  ///-------------------------------------------------------------- 
     32 
     33  // Declare/Define CVarAttribute 
     34  BEGIN_DECLARE_ATTRIBUTE_MAP(CScalar) 
    3435#include "scalar_attribute.conf" 
    35       END_DECLARE_ATTRIBUTE_MAP(CScalar) 
    36  
    37       ///-------------------------------------------------------------- 
    38  
    39       class CScalar 
    40          : public CObjectTemplate<CScalar> 
    41          , public CScalarAttributes 
     36  END_DECLARE_ATTRIBUTE_MAP(CScalar) 
     37 
     38  ///-------------------------------------------------------------- 
     39 
     40  class CScalar: public CObjectTemplate<CScalar> 
     41               , public CScalarAttributes 
     42  { 
     43      friend class CScalarGroup; 
     44 
     45      /// typedef /// 
     46      typedef CObjectTemplate<CScalar>   SuperClass; 
     47      typedef CScalarAttributes SuperClassAttribute; 
     48 
     49    public: 
     50      enum EEventId 
    4251      { 
    43            friend class CScalarGroup; 
    44  
    45             /// typedef /// 
    46             typedef CObjectTemplate<CScalar>   SuperClass; 
    47             typedef CScalarAttributes SuperClassAttribute; 
    48  
    49          public: 
    50            enum EEventId 
    51            { 
    52              EVENT_ID_SCALAR_DISTRIBUTION, 
    53              EVENT_ID_SEND_DISTRIBUTED_ATTRIBUTE, 
    54            } ; 
    55            static bool dispatchEvent(CEventServer& event);       
     52        EVENT_ID_SCALAR_DISTRIBUTION, 
     53        EVENT_ID_SEND_DISTRIBUTED_ATTRIBUTE, 
     54      } ; 
     55      static bool dispatchEvent(CEventServer& event);       
    5656            
    5757 
    58          public : 
    59  
    60             typedef CScalarAttributes RelAttributes; 
    61             typedef CScalarGroup      RelGroup; 
    62             typedef CTransformation<CScalar>::TransformationMapTypes TransMapTypes; 
    63  
    64             /// Constructeurs /// 
    65             CScalar(void); 
    66             explicit CScalar(const StdString & id); 
    67             CScalar(const CScalar & var);       // Not implemented yet. 
    68             CScalar(const CScalar * const var); // Not implemented yet. 
    69  
    70             /// Destructeur /// 
    71             virtual ~CScalar(void); 
    72  
    73          public : 
    74             /// Accesseurs statiques /// 
    75             static StdString GetName(void); 
    76             static StdString GetDefName(void); 
    77             static ENodeType GetType(void); 
    78  
    79          public: 
    80             static CScalar* createScalar(); 
    81  
    82          public: 
    83             void checkAttributes(void); 
    84             bool checkAttributes_done_ = false ; 
     58    public : 
     59 
     60      typedef CScalarAttributes RelAttributes; 
     61      typedef CScalarGroup      RelGroup; 
     62 
     63      /// Constructeurs /// 
     64      CScalar(void); 
     65      explicit CScalar(const StdString & id); 
     66      CScalar(const CScalar & var);       // Not implemented yet. 
     67      CScalar(const CScalar * const var); // Not implemented yet. 
     68 
     69      /// Destructeur /// 
     70      virtual ~CScalar(void); 
     71 
     72    public : 
     73      /// Accesseurs statiques /// 
     74      static StdString GetName(void); 
     75      static StdString GetDefName(void); 
     76      static ENodeType GetType(void); 
     77 
     78    public: 
     79      static CScalar* createScalar(); 
     80 
     81    public: 
     82      void checkAttributes(void); 
     83      bool checkAttributes_done_ = false ; 
    8584             
    86             void addRelFile(const StdString& filename); 
    87             bool IsWritten(const StdString& filename) const; 
    88              virtual void parse(xml::CXMLNode & node); 
     85      void addRelFile(const StdString& filename); 
     86      bool IsWritten(const StdString& filename) const; 
     87      virtual void parse(xml::CXMLNode & node); 
    8988         
    90          public: 
    91             void sendScalarToCouplerOut(CContextClient* client, const string& fieldId, int posInGrid) ; 
    92          private: 
    93             std::set<CContextClient*> sendScalarToCouplerOut_done_ ; 
     89    public: 
     90      void sendScalarToCouplerOut(CContextClient* client, const string& fieldId, int posInGrid) ; 
     91    private: 
     92      std::set<CContextClient*> sendScalarToCouplerOut_done_ ; 
    9493          
    95          public: 
    96             void makeAliasForCoupling(const string& fieldId, int posInGrid) ; 
    97  
    98          public: 
    99            bool hasTransformation(); 
    100            void solveInheritanceTransformation(); 
    101            TransMapTypes getAllTransformations(); 
    102            void duplicateTransformation(CScalar*); 
    103            CTransformation<CScalar>* addTransformation(ETranformationType transType, const StdString& id=""); 
    104            bool isEqual(CScalar* scalar); 
    105         private:   
     94    public: 
     95      void makeAliasForCoupling(const string& fieldId, int posInGrid) ; 
     96 
     97      //////////////////////////////// 
     98      ////    TRANSFORMATIONS     //// 
     99      ////////////////////////////////  
     100    public: 
     101      typedef CTransformation<CScalar>::TransformationMapTypes TransMapTypes; 
     102    private: 
     103      static bool initializeTransformationMap(std::map<StdString, ETranformationType>& m); 
     104      static std::map<StdString, ETranformationType> transformationMapList_; 
     105      static bool dummyTransformationMapList_;      TransMapTypes transformationMap_; 
     106      void setTransformations(const TransMapTypes&); 
     107 
     108    public: 
     109      bool hasTransformation(); 
     110      TransMapTypes getAllTransformations(); 
     111      void duplicateTransformation(CScalar*); 
     112      CTransformation<CScalar>* addTransformation(ETranformationType transType, const StdString& id=""); 
     113     
     114       void solveInheritanceTransformation_old(); 
     115       void solveInheritanceTransformation(); 
     116      private: 
     117        bool solveInheritanceTransformation_done_= false ; 
     118      private: 
     119        CGenericAlgorithmTransformation* transformationAlgorithm_ = nullptr ; 
     120      public: 
     121        void setTransformationAlgorithm(CGenericAlgorithmTransformation* transformationAlgorithm) { transformationAlgorithm_=transformationAlgorithm ;} 
     122        CGenericAlgorithmTransformation* getTransformationAlgorithm(void) { return transformationAlgorithm_ ;}    
     123      private: 
     124        CTransformationPaths transformationPaths_ ; 
     125      public: 
     126        CTransformationPaths getTransformationPaths(void) {return transformationPaths_;}  
     127        void setTransformationPaths(const CTransformationPaths& transformationPaths) { transformationPaths_=transformationPaths ;} 
     128      //////////////////////////////// 
     129      //////////////////////////////// 
     130 
     131      bool isEqual(CScalar* scalar); 
     132    private:   
    106133          /** Clients that have to send a scalar. There can be multiple clients in case of secondary server, otherwise only one client. */ 
    107          std::list<CContextClient*> clients; 
    108          std::set<CContextClient*> clientsSet; 
    109         public: 
    110           void setContextClient(CContextClient* contextClient) ; 
     134      std::list<CContextClient*> clients; 
     135      std::set<CContextClient*> clientsSet; 
     136    public: 
     137      void setContextClient(CContextClient* contextClient) ; 
    111138         
    112          private: 
    113            std::set<StdString> relFiles; 
    114            TransMapTypes transformationMap_; 
    115  
    116             void setTransformations(const TransMapTypes&); 
    117  
    118        private: 
    119            static bool initializeTransformationMap(std::map<StdString, ETranformationType>& m); 
    120            static std::map<StdString, ETranformationType> transformationMapList_; 
    121            static bool dummyTransformationMapList_; 
    122  
    123            /** define if the scalar is completed or not ie all attributes have been received before in case  
    124                of grid reading from file or coupling */  
    125       private: 
    126          /** define if the scalar is completed or not ie all attributes have been received before in case  
    127              of grid reading from file or coupling */  
    128          bool isCompleted_=true ;   
    129       public:      
    130          /*! 
    131            \brief Check if a scalar is completed 
    132            Before make any scalar processing, we must be sure that all scalar informations have 
    133            been sent, for exemple when reading a grid in a file or when grid elements are sent by an 
    134            other context (coupling). So all direct reference of the scalar (scalar_ref) must be also completed 
    135            \return true if scalar and scalar reference are completed 
    136           */ 
    137          bool isCompleted(void) 
    138          { 
    139            if (hasDirectScalarReference()) if (!getDirectScalarReference()->isCompleted()) return false; 
    140            else return isCompleted_ ; 
    141          } 
    142          void setCompleted(void) { isCompleted_=true ; } 
    143          void unsetCompleted(void) { isCompleted_=false ; } 
    144  
    145  
    146  
    147        ////////////////////////////////////////////////////////////////////////////////////// 
    148        //  this part is related to distribution, element definition, views and connectors  // 
    149        ////////////////////////////////////////////////////////////////////////////////////// 
    150        private: 
    151          CLocalElement* localElement_ = nullptr ; 
    152          void initializeLocalElement(void) ; 
     139    private: 
     140      std::set<StdString> relFiles; 
     141 
     142    private: 
     143      /** define if the scalar is completed or not ie all attributes have been received before in case  
     144           of grid reading from file or coupling */  
     145      bool isCompleted_=true ;   
     146    public:      
     147      /*! 
     148        \brief Check if a scalar is completed 
     149        Before make any scalar processing, we must be sure that all scalar informations have 
     150        been sent, for exemple when reading a grid in a file or when grid elements are sent by an 
     151        other context (coupling). So all direct reference of the scalar (scalar_ref) must be also completed 
     152        \return true if scalar and scalar reference are completed 
     153      */ 
     154      bool isCompleted(void) 
     155      { 
     156        if (hasDirectScalarReference()) if (!getDirectScalarReference()->isCompleted()) return false; 
     157        else return isCompleted_ ; 
     158      } 
     159      void setCompleted(void) { isCompleted_=true ; } 
     160      void unsetCompleted(void) { isCompleted_=false ; } 
     161 
     162 
     163 
     164    ////////////////////////////////////////////////////////////////////////////////////// 
     165    //  this part is related to distribution, element definition, views and connectors  // 
     166    ////////////////////////////////////////////////////////////////////////////////////// 
     167    private: 
     168      CLocalElement* localElement_ = nullptr ; 
     169      void initializeLocalElement(void) ; 
    153170        
    154        public:   
    155          CLocalElement* getLocalElement(void) { if (localElement_==nullptr) initializeLocalElement() ; return localElement_ ; } 
    156          CLocalView* getLocalView(CElementView::type type) { return getLocalElement()->getView(type) ;} 
     171    public:   
     172      CLocalElement* getLocalElement(void) { if (localElement_==nullptr) initializeLocalElement() ; return localElement_ ; } 
     173      CLocalView* getLocalView(CElementView::type type) { return getLocalElement()->getView(type) ;} 
    157174        
    158        private:   
    159          void addFullView(void) ; 
    160          void addWorkflowView(void) ; 
    161          void addModelView(void) ; 
     175    private:   
     176      void addFullView(void) ; 
     177      void addWorkflowView(void) ; 
     178      void addModelView(void) ; 
    162179         
    163        private: 
    164          CLocalConnector* modelToWorkflowConnector_ ; 
    165          void computeModelToWorkflowConnector(void)  ; 
    166        public: 
    167          CLocalConnector* getModelToWorkflowConnector(void) { if (modelToWorkflowConnector_==nullptr) computeModelToWorkflowConnector() ; return modelToWorkflowConnector_ ;} 
    168  
    169        public: 
    170          void computeRemoteElement(CContextClient* client, EDistributionType) ; 
    171          void distributeToServer(CContextClient* client, std::map<int, CArray<size_t,1>>& globalIndex, CScattererConnector* &scattererConnector, 
     180    private: 
     181      CLocalConnector* modelToWorkflowConnector_ ; 
     182      void computeModelToWorkflowConnector(void)  ; 
     183    public: 
     184      CLocalConnector* getModelToWorkflowConnector(void) { if (modelToWorkflowConnector_==nullptr) computeModelToWorkflowConnector() ; return modelToWorkflowConnector_ ;} 
     185 
     186    public: 
     187      void computeRemoteElement(CContextClient* client, EDistributionType) ; 
     188      void distributeToServer(CContextClient* client, std::map<int, CArray<size_t,1>>& globalIndex, CScattererConnector* &scattererConnector, 
    172189                                 const string& scalarId="") ; 
    173190 
    174          static void recvScalarDistribution(CEventServer& event) ; 
    175          void receivedScalarDistribution(CEventServer& event, int phasis) ; 
    176          void setServerMask(CArray<bool,1>& serverMask, CContextClient* client) ; 
    177          void sendDistributedAttributes(CContextClient* client, CScattererConnector& scattererConnector, const string& scalarId) ; 
    178          static void recvDistributedAttributes(CEventServer& event) ; 
    179          void recvDistributedAttributes(CEventServer& event, const string& type) ; 
    180  
    181        private: 
    182          map<CContextClient*, CDistributedElement*> remoteElement_ ; 
    183        public:  
    184          CDistributedElement* getRemoteElement(CContextClient* client) {return remoteElement_[client] ;} 
    185        private: 
    186          map<CContextClient*, CScattererConnector*> clientToServerConnector_ ; 
    187        public:  
    188          CScattererConnector* getClientToServerConnector(CContextClient* client) { return clientToServerConnector_[client] ;} 
    189  
    190        private: 
    191          CGathererConnector*  gathererConnector_ ; 
    192        public: 
    193          CGathererConnector* getGathererConnector(void) { return gathererConnector_ ;} 
    194        private: 
    195          CGathererConnector* serverFromClientConnector_ ; 
    196          CDistributedElement* elementFrom_ ; 
    197        public: 
    198         CGathererConnector* getServerFromClientConnector(void) { return serverFromClientConnector_ ;} 
    199  
    200        private: 
    201          CScattererConnector*  serverToClientConnector_ = nullptr ; 
    202        public:  
    203          CScattererConnector* getServerToClientConnector(void) { return serverToClientConnector_ ;}  
    204  
    205        private: 
    206           map<CContextClient*,CGathererConnector*>  clientFromServerConnector_  ; 
    207        public:  
    208          CGathererConnector* getClientFromServerConnector(CContextClient* client) { return clientFromServerConnector_[client] ;}  
    209  
    210       private: 
    211             DECLARE_REF_FUNC(Scalar,scalar) 
    212  
    213       }; // class CVar 
    214       ///-------------------------------------------------------------- 
    215  
    216       // Declare/Define CScalarGroup and CScalarDefinition 
    217       DECLARE_GROUP(CScalar); 
     191      static void recvScalarDistribution(CEventServer& event) ; 
     192      void receivedScalarDistribution(CEventServer& event, int phasis) ; 
     193      void setServerMask(CArray<bool,1>& serverMask, CContextClient* client) ; 
     194      void sendDistributedAttributes(CContextClient* client, CScattererConnector& scattererConnector, const string& scalarId) ; 
     195      static void recvDistributedAttributes(CEventServer& event) ; 
     196      void recvDistributedAttributes(CEventServer& event, const string& type) ; 
     197 
     198    private: 
     199      map<CContextClient*, CDistributedElement*> remoteElement_ ; 
     200    public:  
     201      CDistributedElement* getRemoteElement(CContextClient* client) {return remoteElement_[client] ;} 
     202    private: 
     203      map<CContextClient*, CScattererConnector*> clientToServerConnector_ ; 
     204    public:  
     205      CScattererConnector* getClientToServerConnector(CContextClient* client) { return clientToServerConnector_[client] ;} 
     206 
     207    private: 
     208      CGathererConnector*  gathererConnector_ ; 
     209    public: 
     210      CGathererConnector* getGathererConnector(void) { return gathererConnector_ ;} 
     211    private: 
     212      CGathererConnector* serverFromClientConnector_ ; 
     213      CDistributedElement* elementFrom_ ; 
     214    public: 
     215      CGathererConnector* getServerFromClientConnector(void) { return serverFromClientConnector_ ;} 
     216 
     217    private: 
     218      CScattererConnector*  serverToClientConnector_ = nullptr ; 
     219    public:  
     220      CScattererConnector* getServerToClientConnector(void) { return serverToClientConnector_ ;}  
     221 
     222    private: 
     223      map<CContextClient*,CGathererConnector*>  clientFromServerConnector_  ; 
     224    public:  
     225      CGathererConnector* getClientFromServerConnector(CContextClient* client) { return clientFromServerConnector_[client] ;}  
     226 
     227    private: 
     228      DECLARE_REF_FUNC(Scalar,scalar) 
     229 
     230  }; // class CVar 
     231  ///-------------------------------------------------------------- 
     232 
     233  // Declare/Define CScalarGroup and CScalarDefinition 
     234  DECLARE_GROUP(CScalar); 
    218235} // namespace xios 
    219236 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/temporal_splitting.cpp

    r1275 r1984  
    2929  bool CTemporalSplitting::registerTrans() 
    3030  { 
    31     return registerTransformation(TRANS_TEMPORAL_SPLITTING, CTemporalSplitting::create); 
     31    return registerTransformation(TRANS_TEMPORAL_SPLITTING, {create, getTransformation}); 
    3232  } 
    3333 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/temporal_splitting.hpp

    r1275 r1984  
    4040      typedef CObjectTemplate<CTemporalSplitting> SuperClass; 
    4141      typedef CTemporalSplittingAttributes SuperClassAttribute; 
     42      typedef CTemporalSplitting MyClass ; 
     43      typedef CTransformation<CAxis> SuperTransform ; 
    4244 
    4345    public : 
     
    5557      static StdString GetDefName(void); 
    5658      static ENodeType GetType(void); 
     59      const string& getId(void) { return this->SuperClass::getId();} 
     60      ETranformationType getTransformationType(void) { return TRANS_TEMPORAL_SPLITTING ;} 
     61      static CTransformation<CAxis>* getTransformation(const StdString& id) { return SuperClass::get(id);} 
     62      virtual void inheritFrom(SuperTransform* srcTransform) { solveDescInheritance(true, this->SuperClass::get((MyClass*)srcTransform)) ;} 
    5763    private: 
    5864      static bool registerTrans(); 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/zoom_axis.cpp

    r1201 r1984  
    2626  bool CZoomAxis::registerTrans() 
    2727  { 
    28     return registerTransformation(TRANS_ZOOM_AXIS, CZoomAxis::create); 
     28    return registerTransformation(TRANS_ZOOM_AXIS, {create, getTransformation}); 
    2929  } 
    3030 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/zoom_axis.hpp

    r836 r1984  
    4141      typedef CObjectTemplate<CZoomAxis> SuperClass; 
    4242      typedef CZoomAxisAttributes SuperClassAttribute; 
     43      typedef CZoomAxis MyClass ; 
     44      typedef CTransformation<CAxis> SuperTransform ; 
    4345 
    4446    public : 
     
    5658      static StdString GetDefName(void); 
    5759      static ENodeType GetType(void); 
     60      const string& getId(void) { return this->SuperClass::getId();} 
     61      ETranformationType getTransformationType(void) { return TRANS_ZOOM_AXIS ;} 
     62      static CTransformation<CAxis>* getTransformation(const StdString& id) { return SuperClass::get(id);} 
     63      virtual void inheritFrom(SuperTransform* srcTransform) { solveDescInheritance(true, this->SuperClass::get((MyClass*)srcTransform)) ;} 
    5864    private: 
    5965      static bool registerTrans(); 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/zoom_domain.cpp

    r836 r1984  
    2727  bool CZoomDomain::registerTrans() 
    2828  { 
    29     registerTransformation(TRANS_ZOOM_DOMAIN, CZoomDomain::create); 
     29    registerTransformation(TRANS_ZOOM_DOMAIN, {create, getTransformation}); 
    3030  } 
    3131 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/node/zoom_domain.hpp

    r836 r1984  
    4141      typedef CObjectTemplate<CZoomDomain> SuperClass; 
    4242      typedef CZoomDomainAttributes SuperClassAttribute; 
     43      typedef CZoomDomain MyClass ; 
     44      typedef CTransformation<CDomain> SuperTransform ; 
    4345 
    4446    public : 
     
    5658      static StdString GetDefName(void); 
    5759      static ENodeType GetType(void); 
     60      const string& getId(void) { return this->SuperClass::getId();} 
     61      ETranformationType getTransformationType(void) { return TRANS_ZOOM_DOMAIN ;} 
     62      virtual void inheritFrom(SuperTransform* srcTransform) { solveDescInheritance(true, this->SuperClass::get((MyClass*)srcTransform)) ;} 
     63      static CTransformation<CDomain>* getTransformation(const StdString& id) { return SuperClass::get(id);} 
    5864    private: 
    5965      static bool registerTrans(); 
    6066      static CTransformation<CDomain>* create(const StdString& id, xml::CXMLNode* node); 
     67      
    6168      static bool _dummyRegistered; 
    6269  }; // class CZoomDomain 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/object_template.hpp

    r1875 r1984  
    5252         /// Traitements /// 
    5353         virtual void solveDescInheritance(bool apply, const CAttributeMap * const parent = 0); 
    54  
     54  
    5555         /// Traitement statique /// 
    5656         static void ClearAllAttributes(void); 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/generic_algorithm_transformation.cpp

    r1784 r1984  
    1414#include "timer.hpp" 
    1515#include "mpi.hpp" 
    16  
    17 namespace xios { 
     16#include "transform_connector.hpp" 
     17#include "weight_transform_connector.hpp" 
     18 
     19namespace xios  
     20{ 
    1821 
    1922CGenericAlgorithmTransformation::CGenericAlgorithmTransformation() 
     
    11351138CATCH 
    11361139 
    1137 } 
     1140 
     1141/////////////////////////////////////////////////////////////// 
     1142////////// new algorithm for new method               ///////// 
     1143/////////////////////////////////////////////////////////////// 
     1144 
     1145 
     1146 
     1147void CGenericAlgorithmTransformation::computeAlgorithm(CLocalView* srcView, CLocalView* dstView) 
     1148{ 
     1149  auto& srcMap = transformationMapping_[0] ; 
     1150  set<size_t> srcIndex ; 
     1151  for(auto& it : srcMap) 
     1152    for(size_t index : it.second) srcIndex.insert(index) ; 
     1153 
     1154  CArray<size_t,1> srcArrayIndex(srcIndex.size()) ; 
     1155  int i=0 ; 
     1156  for(size_t index : srcIndex) { srcArrayIndex(i) = index ; i++ ;} 
     1157  CLocalElement recvElement(CContext::getCurrent()->getIntraCommRank(), srcView->getGlobalSize(), srcArrayIndex) ; 
     1158  recvElement.addFullView() ; 
     1159 
     1160  transformConnector_ = new CTransformConnector(srcView, recvElement.getView(CElementView::FULL), CContext::getCurrent()->getIntraComm())  ; 
     1161  transformConnector_->computeConnector() ; 
     1162  weightTransformConnector_ = new  CWeightTransformConnector( recvElement.getView(CElementView::FULL), dstView, transformationMapping_[0], transformationWeight_[0]) ;  
     1163} 
     1164  
     1165 
     1166void CGenericAlgorithmTransformation::apply(int dimBefore, int dimAfter, const CArray<double,1>& dataIn, CArray<double,1>& dataOut) 
     1167{ 
     1168  CArray<double,1> dataOutTmp ; 
     1169  transformConnector_->transfer(dimBefore, dimAfter, dataIn, dataOutTmp) ; 
     1170  weightTransformConnector_ -> transfer(dimBefore, dimAfter, dataOutTmp, dataOut) ; 
     1171} 
     1172 
     1173 
     1174 
     1175 
     1176 
     1177 
     1178} 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/transformation/generic_algorithm_transformation.hpp

    r1637 r1984  
    1414#include "array_new.hpp" 
    1515#include "client_client_dht_template.hpp" 
     16#include "local_view.hpp" 
     17#include "transform_connector.hpp" 
     18#include "weight_transform_connector.hpp" 
    1619 
    17 namespace xios { 
     20namespace xios 
     21{ 
    1822  class CGrid; 
    1923  class CDomain; 
     
    169173  bool eliminateRedondantSrc_ ; // flag to indicate if the transformation must select only one global source point for all proc. 
    170174                               // In this case it will choose preferentially the current process  
     175 
     176   
     177// new methods for new algorithm 
     178 
     179  public :  
     180   
     181    void computeAlgorithm(CLocalView* srcView, CLocalView* dstView) ; 
     182    void apply(int dimBefore, int dimAfter, const CArray<double,1>& dataIn, CArray<double,1>& dataOut); 
     183     
     184    CTransformConnector* transformConnector_ ; 
     185    CWeightTransformConnector* weightTransformConnector_ ; 
     186 
    171187}; 
    172188 
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/xios_spl.hpp

    r1875 r1984  
    88#include <unordered_map> 
    99#include <memory> 
    10  
    1110// standard C 
    1211#include <cstring> 
    1312#include <cstdlib> 
     13 
    1414#include <cmath> 
     15// bug in cmath header => macro collision marco with DOMAIN 
     16#ifdef DOMAIN 
     17#undef DOMAIN 
     18#endif 
     19 
    1520#include <ctime> 
    1621 
     
    2429#include <queue> 
    2530#include <valarray> 
     31#include <tuple> 
     32 
    2633// Flux. 
    2734#include <iostream> 
     
    3239#include <boost/cast.hpp> 
    3340#include <boost/current_function.hpp> 
     41 
    3442/// Map /// 
    3543#define xios_map std::map 
     
    6169#include "log.hpp" 
    6270using namespace std; 
    63 using namespace boost ; 
    64  
     71//using namespace boost ; 
    6572 
    6673#endif //__XIOS_SPL__ 
Note: See TracChangeset for help on using the changeset viewer.