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

intermediate commit for new tranformation engine?
YM

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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 
Note: See TracChangeset for help on using the changeset viewer.