source: XIOS/dev/dev_ym/XIOS_COUPLING/src/node/axis.hpp @ 1984

Last change on this file since 1984 was 1984, checked in by ymipsl, 4 years ago

intermediate commit for new tranformation engine?
YM

  • Property copyright set to
    Software name : XIOS (Xml I/O Server)
    http://forge.ipsl.jussieu.fr/ioserver
    Creation date : January 2009
    Licence : CeCCIL version2
    see license file in root directory : Licence_CeCILL_V2-en.txt
    or http://www.cecill.info/licences/Licence_CeCILL_V2-en.html
    Holder : CEA/LSCE (Laboratoire des Sciences du CLimat et de l'Environnement)
    CNRS/IPSL (Institut Pierre Simon Laplace)
    Project Manager : Yann Meurdesoif
    yann.meurdesoif@cea.fr
  • Property svn:executable set to *
File size: 11.1 KB
RevLine 
[591]1#ifndef __XIOS_CAxis__
2#define __XIOS_CAxis__
[219]3
[591]4/// XIOS headers ///
5#include "xios_spl.hpp"
[219]6#include "group_factory.hpp"
[619]7#include "virtual_node.hpp"
[219]8
9#include "declare_group.hpp"
[540]10#include "declare_ref_func.hpp"
[619]11#include "declare_virtual_node.hpp"
[369]12#include "attribute_array.hpp"
[399]13#include "attribute_enum.hpp"
14#include "attribute_enum_impl.hpp"
[567]15#include "server_distribution_description.hpp"
[619]16#include "transformation.hpp"
17#include "transformation_enum.hpp"
[1984]18#include "transformation_path.hpp"
[1918]19#include "element.hpp"
20#include "local_connector.hpp"
[1930]21#include "scatterer_connector.hpp"
22#include "gatherer_connector.hpp"
23#include "distribution_type.hpp"
[1984]24#include "generic_algorithm_transformation.hpp"
[219]25
[1930]26
[1984]27namespace xios
28{
[219]29   /// ////////////////////// Déclarations ////////////////////// ///
30
31   class CAxisGroup;
32   class CAxisAttributes;
33   class CAxis;
34
35   ///--------------------------------------------------------------
36
37   // Declare/Define CAxisAttribute
38   BEGIN_DECLARE_ATTRIBUTE_MAP(CAxis)
[231]39#  include "axis_attribute.conf"
[219]40   END_DECLARE_ATTRIBUTE_MAP(CAxis)
41
42   ///--------------------------------------------------------------
43
44   class CAxis
45      : public CObjectTemplate<CAxis>
46      , public CAxisAttributes
47   {
[987]48               /// typedef ///
49         typedef CObjectTemplate<CAxis>   SuperClass;
50         typedef CAxisAttributes SuperClassAttribute;
51         
[1235]52      public:
[567]53         enum EEventId
54         {
[1930]55           EVENT_ID_AXIS_DISTRIBUTION,
56           EVENT_ID_SEND_DISTRIBUTED_ATTRIBUTE
[567]57         } ;
58
[1235]59      public:
[219]60         typedef CAxisAttributes RelAttributes;
61         typedef CAxisGroup      RelGroup;
62
[621]63      public:
[219]64         /// Constructeurs ///
65         CAxis(void);
66         explicit CAxis(const StdString & id);
67         CAxis(const CAxis & axis);       // Not implemented yet.
68         CAxis(const CAxis * const axis); // Not implemented yet.
69
[622]70         static CAxis* createAxis();
[1158]71
72         /// Accesseurs ///
73         const std::set<StdString> & getRelFiles(void) const;
[1975]74 
[1371]75         std::map<int, StdSize> getAttributesBufferSize(CContextClient* client, const std::vector<int>& globalDim, int orderPositionInGrid,
76                                                        CServerDistributionDescription::ServerDistributionType disType = CServerDistributionDescription::BAND_DISTRIBUTION);
[731]77
[219]78         /// Test ///
79         bool IsWritten(const StdString & filename) const;
[676]80         bool isWrittenCompressed(const StdString& filename) const;
[594]81         bool isDistributed(void) const;
[1956]82       
[1984]83      public:
[1956]84        /*!
85            \brief return if the axis can be written or not in a compressed way.
86            ie if there are some masked or indexed point on the domain. Valid only on server side.
87            \return true if domain can be writtedn in a compressed way
88         */ 
89         bool isCompressible(void) { if (!isCompressibleComputed_) computeIsCompressible() ; return isCompressible_ ;} 
[1984]90      private:
[1956]91         bool isCompressible_ ; /** specify if the domain can be written in a compressed way */ 
92         bool isCompressibleComputed_=false ; /** Indicate if compressability has been computed*/
93         void computeIsCompressible() ;
94       
[1984]95      public:
[219]96
97         /// Mutateur ///
98         void addRelFile(const StdString & filename);
[676]99         void addRelFileCompressed(const StdString& filename);
[219]100
[1869]101         
[219]102
103         /// Destructeur ///
104         virtual ~CAxis(void);
105
[619]106         virtual void parse(xml::CXMLNode & node);
107
[1345]108         void setContextClient(CContextClient* contextClient);
109
[219]110         /// Accesseurs statiques ///
111         static StdString GetName(void);
112         static StdString GetDefName(void);
113         static ENodeType GetType(void);
114
[1235]115         static bool dispatchEvent(CEventServer& event);         
[1869]116       
117         /// Vérifications ///
118         void checkAttributes(void);
119         bool checkAttributes_done_ = false ;
[619]120
[1215]121         size_t getGlobalWrittenSize(void) ;
[676]122
[1984]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      ////////////////////////////
[1158]157         bool isEqual(CAxis* axis);
[619]158
[1235]159      public: 
160        bool hasValue;       
[1558]161        bool hasBounds;
162        bool hasLabel;
163
[1984]164      private:
[551]165         void checkData();
166         void checkMask();
[1158]167         void checkBounds();
168         void checkLabel();
[1870]169     
[1875]170      public:
171         void sendAxisToCouplerOut(CContextClient* client, const std::vector<int>& globalDim, int orderPositionInGrid, const string& fieldId, int posInGrid) ;
[1870]172      private:
[1875]173         std::set<CContextClient*> sendAxisToCouplerOut_done_ ;
174   
175      public:
176         void makeAliasForCoupling(const string& fieldId, int posInGrid) ;
177
[676]178
[567]179      private:
[1345]180
[1875]181/** Clients that have to send a axis. There can be multiple clients in case of secondary server, otherwise only one client. */
[1353]182         std::list<CContextClient*> clients;
183         std::set<CContextClient*> clientsSet;
[1345]184
[1875]185      private:
[1869]186         /** define if the axis is completed or not ie all attributes have been received before in case
187             of grid reading from file or coupling */ 
188         bool isCompleted_=true ; 
[1875]189      public:     
190         /*!
191           \brief Check if a axis is completed
192           Before make any axis processing, we must be sure that all axis informations have
193           been sent, for exemple when reading a grid in a file or when grid elements are sent by an
194           other context (coupling). So all direct reference of the axis (axis_ref) must be also completed
195           \return true if axis and axis reference are completed
196          */
197         bool isCompleted(void)
198         {
199           if (hasDirectAxisReference()) if (!getDirectAxisReference()->isCompleted()) return false;
200           else return isCompleted_ ;
201         }
202         void setCompleted(void) { isCompleted_=true ; }
203         void unsetCompleted(void) { isCompleted_=false ; }
204     
205      private:
[219]206         bool isChecked;
[676]207         std::set<StdString> relFiles, relFilesCompressed;
[1984]208          std::map<int, std::unordered_map<int, vector<size_t> > > indSrv_; // Global index of each client sent to server
[1337]209         std::map<int, std::vector<int> > connectedServerRank_;
[1099]210
[1930]211       //////////////////////////////////////////////////////////////////////////////////////
212       //  this part is related to distribution, element definition, views and connectors  //
213       //////////////////////////////////////////////////////////////////////////////////////
[1918]214         
215        private:
216         CLocalElement* localElement_ = nullptr ;
217         void initializeLocalElement(void) ;
218        public: 
219         CLocalElement* getLocalElement(void) { if (localElement_==nullptr) initializeLocalElement() ; return localElement_ ; }
220         CLocalView* getLocalView(CElementView::type type) { return getLocalElement()->getView(type) ;}
221        private:
222         void addFullView(void) ;
223         void addWorkflowView(void) ;
224         void addModelView(void) ;
225
226        private:
227         CLocalConnector* modelToWorkflowConnector_ ;
228         void computeModelToWorkflowConnector(void)  ;
229        public:
230         CLocalConnector* getModelToWorkflowConnector(void) { if (modelToWorkflowConnector_==nullptr) computeModelToWorkflowConnector() ; return modelToWorkflowConnector_ ;}
[1930]231       
232       public:
233         void computeRemoteElement(CContextClient* client, EDistributionType) ;
[1956]234         void distributeToServer(CContextClient* client, std::map<int, CArray<size_t,1>>& globalIndex, CScattererConnector* &scattererConnector,
235                                 const string& axisId="") ;
[1918]236
[1930]237         static void recvAxisDistribution(CEventServer& event) ;
238         void receivedAxisDistribution(CEventServer& event, int phasis) ;
[1943]239         void setServerMask(CArray<bool,1>& serverMask, CContextClient* client ) ;
[1930]240         void sendDistributedAttributes(CContextClient* client, CScattererConnector& scattererConnector, const string& axisId) ;
241         static void recvDistributedAttributes(CEventServer& event) ;
242         void recvDistributedAttributes(CEventServer& event, const string& type) ;
243       private:
244         map<CContextClient*, CDistributedElement*> remoteElement_ ;
245       public: 
246         CDistributedElement* getRemoteElement(CContextClient* client) {return remoteElement_[client] ;}
247       private:
248         map<CContextClient*, CScattererConnector*> clientToServerConnector_ ;
249       public: 
250         CScattererConnector* getClientToServerConnector(CContextClient* client) { return clientToServerConnector_[client] ;}
251       private:
252         CGathererConnector*  gathererConnector_ ;
[1943]253       public:
254         CGathererConnector* getGathererConnector(void) { return gathererConnector_ ;}
255       private:
[1930]256         CGathererConnector* serverFromClientConnector_ ;
257         CDistributedElement* elementFrom_ ;
258       public:
259        CGathererConnector* getServerFromClientConnector(void) { return serverFromClientConnector_ ;}
260
[1934]261       private:
262         CScattererConnector*  serverToClientConnector_ = nullptr ;
263       public: 
264         CScattererConnector* getServerToClientConnector(void) { return serverToClientConnector_ ;} 
[1930]265
[1934]266       private:
267          map<CContextClient*,CGathererConnector*>  clientFromServerConnector_  ;
268       public: 
269         CGathererConnector* getClientFromServerConnector(CContextClient* client) { return clientFromServerConnector_[client] ;} 
[1930]270
[540]271         DECLARE_REF_FUNC(Axis,axis)
[219]272   }; // class CAxis
273
274   ///--------------------------------------------------------------
275
276   // Declare/Define CAxisGroup and CAxisDefinition
277   DECLARE_GROUP(CAxis);
[335]278} // namespace xios
[219]279
[591]280#endif // __XIOS_CAxis__
Note: See TracBrowser for help on using the repository browser.