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

Last change on this file since 2203 was 2203, checked in by ymipsl, 3 years ago

New functionnality : domain, axis and scalar can now be retrieve with new syntax id :
ex. for domain :

id="domainId" : old syntax, working as before
id="fieldId::domainId" : get the domain related to "domainId" associated to the field "fieldId", work if only 1 domain related to domainId is associated to the field.
id="fieldId::domainId[n]" : get the nth domain related to "domainId" associated to the field "fieldId"
id="fieldId::" : get the domain associated the the field "fieldId, work if grid associated to th field is composed with exactly 1 domain (and possibly other components axis or scalars)
id="fieldId::[n] : get the nth domain composing the grid associated to the field

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