source: XIOS3/dev/XIOS_ATTACHED/src/node/axis.hpp @ 2482

Last change on this file since 2482 was 2482, checked in by ymipsl, 15 months ago

First guess in supression of attached mode replaced by online reader and write filters

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