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

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

Big cleaning on XIOS coupling branch
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: 9.9 KB
Line 
1#ifndef __XIOS_CAxis__
2#define __XIOS_CAxis__
3
4/// XIOS headers ///
5#include "xios_spl.hpp"
6#include "group_factory.hpp"
7#include "virtual_node.hpp"
8
9#include "declare_group.hpp"
10#include "declare_ref_func.hpp"
11#include "declare_virtual_node.hpp"
12#include "attribute_array.hpp"
13#include "attribute_enum.hpp"
14#include "attribute_enum_impl.hpp"
15#include "server_distribution_description.hpp"
16#include "transformation.hpp"
17#include "transformation_enum.hpp"
18#include "element.hpp"
19#include "local_connector.hpp"
20#include "scatterer_connector.hpp"
21#include "gatherer_connector.hpp"
22#include "distribution_type.hpp"
23
24
25namespace xios {
26   /// ////////////////////// Déclarations ////////////////////// ///
27
28   class CAxisGroup;
29   class CAxisAttributes;
30   class CAxis;
31
32   ///--------------------------------------------------------------
33
34   // Declare/Define CAxisAttribute
35   BEGIN_DECLARE_ATTRIBUTE_MAP(CAxis)
36#  include "axis_attribute.conf"
37   END_DECLARE_ATTRIBUTE_MAP(CAxis)
38
39   ///--------------------------------------------------------------
40
41   class CAxis
42      : public CObjectTemplate<CAxis>
43      , public CAxisAttributes
44   {
45               /// typedef ///
46         typedef CObjectTemplate<CAxis>   SuperClass;
47         typedef CAxisAttributes SuperClassAttribute;
48         
49      public:
50         enum EEventId
51         {
52           EVENT_ID_AXIS_DISTRIBUTION,
53           EVENT_ID_SEND_DISTRIBUTED_ATTRIBUTE
54         } ;
55
56      public:
57         typedef CAxisAttributes RelAttributes;
58         typedef CAxisGroup      RelGroup;
59         typedef CTransformation<CAxis>::TransformationMapTypes TransMapTypes;
60
61      public:
62         /// Constructeurs ///
63         CAxis(void);
64         explicit CAxis(const StdString & id);
65         CAxis(const CAxis & axis);       // Not implemented yet.
66         CAxis(const CAxis * const axis); // Not implemented yet.
67
68         static CAxis* createAxis();
69
70         /// Accesseurs ///
71         const std::set<StdString> & getRelFiles(void) const;
72 
73         std::map<int, StdSize> getAttributesBufferSize(CContextClient* client, const std::vector<int>& globalDim, int orderPositionInGrid,
74                                                        CServerDistributionDescription::ServerDistributionType disType = CServerDistributionDescription::BAND_DISTRIBUTION);
75
76         /// Test ///
77         bool IsWritten(const StdString & filename) const;
78         bool isWrittenCompressed(const StdString& filename) const;
79         bool isDistributed(void) const;
80       
81        public:
82        /*!
83            \brief return if the axis can be written or not in a compressed way.
84            ie if there are some masked or indexed point on the domain. Valid only on server side.
85            \return true if domain can be writtedn in a compressed way
86         */ 
87         bool isCompressible(void) { if (!isCompressibleComputed_) computeIsCompressible() ; return isCompressible_ ;} 
88        private:
89         bool isCompressible_ ; /** specify if the domain can be written in a compressed way */ 
90         bool isCompressibleComputed_=false ; /** Indicate if compressability has been computed*/
91         void computeIsCompressible() ;
92       
93        public:
94
95         /// Mutateur ///
96         void addRelFile(const StdString & filename);
97         void addRelFileCompressed(const StdString& filename);
98
99         
100
101         /// Destructeur ///
102         virtual ~CAxis(void);
103
104         virtual void parse(xml::CXMLNode & node);
105
106         void setContextClient(CContextClient* contextClient);
107
108         /// Accesseurs statiques ///
109         static StdString GetName(void);
110         static StdString GetDefName(void);
111         static ENodeType GetType(void);
112
113         static bool dispatchEvent(CEventServer& event);         
114       
115         /// Vérifications ///
116         void checkAttributes(void);
117         bool checkAttributes_done_ = false ;
118
119         size_t getGlobalWrittenSize(void) ;
120
121         bool hasTransformation();
122         void solveInheritanceTransformation();
123         TransMapTypes getAllTransformations();         
124         void duplicateTransformation(CAxis*);
125         CTransformation<CAxis>* addTransformation(ETranformationType transType, const StdString& id="");
126         bool isEqual(CAxis* axis);
127
128      public: 
129        bool hasValue;       
130        bool hasBounds;
131        bool hasLabel;
132
133       private:
134         void checkData();
135         void checkMask();
136         void checkBounds();
137         void checkLabel();
138     
139      public:
140         void sendAxisToCouplerOut(CContextClient* client, const std::vector<int>& globalDim, int orderPositionInGrid, const string& fieldId, int posInGrid) ;
141      private:
142         std::set<CContextClient*> sendAxisToCouplerOut_done_ ;
143   
144      public:
145         void makeAliasForCoupling(const string& fieldId, int posInGrid) ;
146
147      private:
148         void setTransformations(const TransMapTypes&);
149
150      private:
151
152/** Clients that have to send a axis. There can be multiple clients in case of secondary server, otherwise only one client. */
153         std::list<CContextClient*> clients;
154         std::set<CContextClient*> clientsSet;
155
156      private:
157         /** define if the axis is completed or not ie all attributes have been received before in case
158             of grid reading from file or coupling */ 
159         bool isCompleted_=true ; 
160      public:     
161         /*!
162           \brief Check if a axis is completed
163           Before make any axis processing, we must be sure that all axis informations have
164           been sent, for exemple when reading a grid in a file or when grid elements are sent by an
165           other context (coupling). So all direct reference of the axis (axis_ref) must be also completed
166           \return true if axis and axis reference are completed
167          */
168         bool isCompleted(void)
169         {
170           if (hasDirectAxisReference()) if (!getDirectAxisReference()->isCompleted()) return false;
171           else return isCompleted_ ;
172         }
173         void setCompleted(void) { isCompleted_=true ; }
174         void unsetCompleted(void) { isCompleted_=false ; }
175     
176      private:
177         bool isChecked;
178         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
182         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
189
190       //////////////////////////////////////////////////////////////////////////////////////
191       //  this part is related to distribution, element definition, views and connectors  //
192       //////////////////////////////////////////////////////////////////////////////////////
193         
194        private:
195         CLocalElement* localElement_ = nullptr ;
196         void initializeLocalElement(void) ;
197        public: 
198         CLocalElement* getLocalElement(void) { if (localElement_==nullptr) initializeLocalElement() ; return localElement_ ; }
199         CLocalView* getLocalView(CElementView::type type) { return getLocalElement()->getView(type) ;}
200        private:
201         void addFullView(void) ;
202         void addWorkflowView(void) ;
203         void addModelView(void) ;
204
205        private:
206         CLocalConnector* modelToWorkflowConnector_ ;
207         void computeModelToWorkflowConnector(void)  ;
208        public:
209         CLocalConnector* getModelToWorkflowConnector(void) { if (modelToWorkflowConnector_==nullptr) computeModelToWorkflowConnector() ; return modelToWorkflowConnector_ ;}
210       
211       public:
212         void computeRemoteElement(CContextClient* client, EDistributionType) ;
213         void distributeToServer(CContextClient* client, std::map<int, CArray<size_t,1>>& globalIndex, CScattererConnector* &scattererConnector,
214                                 const string& axisId="") ;
215
216         static void recvAxisDistribution(CEventServer& event) ;
217         void receivedAxisDistribution(CEventServer& event, int phasis) ;
218         void setServerMask(CArray<bool,1>& serverMask, CContextClient* client ) ;
219         void sendDistributedAttributes(CContextClient* client, CScattererConnector& scattererConnector, const string& axisId) ;
220         static void recvDistributedAttributes(CEventServer& event) ;
221         void recvDistributedAttributes(CEventServer& event, const string& type) ;
222       private:
223         map<CContextClient*, CDistributedElement*> remoteElement_ ;
224       public: 
225         CDistributedElement* getRemoteElement(CContextClient* client) {return remoteElement_[client] ;}
226       private:
227         map<CContextClient*, CScattererConnector*> clientToServerConnector_ ;
228       public: 
229         CScattererConnector* getClientToServerConnector(CContextClient* client) { return clientToServerConnector_[client] ;}
230       private:
231         CGathererConnector*  gathererConnector_ ;
232       public:
233         CGathererConnector* getGathererConnector(void) { return gathererConnector_ ;}
234       private:
235         CGathererConnector* serverFromClientConnector_ ;
236         CDistributedElement* elementFrom_ ;
237       public:
238        CGathererConnector* getServerFromClientConnector(void) { return serverFromClientConnector_ ;}
239
240       private:
241         CScattererConnector*  serverToClientConnector_ = nullptr ;
242       public: 
243         CScattererConnector* getServerToClientConnector(void) { return serverToClientConnector_ ;} 
244
245       private:
246          map<CContextClient*,CGathererConnector*>  clientFromServerConnector_  ;
247       public: 
248         CGathererConnector* getClientFromServerConnector(CContextClient* client) { return clientFromServerConnector_[client] ;} 
249
250         DECLARE_REF_FUNC(Axis,axis)
251   }; // class CAxis
252
253   ///--------------------------------------------------------------
254
255   // Declare/Define CAxisGroup and CAxisDefinition
256   DECLARE_GROUP(CAxis);
257} // namespace xios
258
259#endif // __XIOS_CAxis__
Note: See TracBrowser for help on using the repository browser.