source: XIOS3/trunk/src/node/axis.hpp @ 2389

Last change on this file since 2389 was 2389, checked in by jderouillat, 2 years ago

Move renames of the attributes name in the element classes

  • 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.5 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      public: 
178        bool hasValue;       
179        bool hasBounds;
180        bool hasLabel;
181
182      private:
183         bool checkData(bool generateError);
184         bool checkMask(bool generateError);
185         bool checkBounds(bool generateError);
186         bool checkLabel(bool generateError);
187     
188      public:
189         void sendAxisToCouplerOut(CContextClient* client, const std::vector<int>& globalDim, int orderPositionInGrid, const string& fieldId, int posInGrid) ;
190      private:
191         std::set<CContextClient*> sendAxisToCouplerOut_done_ ;
192   
193      public:
194         void makeAliasForCoupling(const string& fieldId, int posInGrid) ;
195         string getCouplingAlias(const string& fieldId, int posInGrid) ;
196
197      private:
198
199/** Clients that have to send a axis. There can be multiple clients in case of secondary server, otherwise only one client. */
200         std::list<CContextClient*> clients;
201         std::set<CContextClient*> clientsSet;
202
203      private:
204         /** define if the axis is completed or not ie all attributes have been received before in case
205             of grid reading from file or coupling */ 
206         bool isCompleted_=true ; 
207      public:     
208         /*!
209           \brief Check if a axis is completed
210           Before make any axis processing, we must be sure that all axis informations have
211           been sent, for exemple when reading a grid in a file or when grid elements are sent by an
212           other context (coupling). So all direct reference of the axis (axis_ref) must be also completed
213           \return true if axis and axis reference are completed
214          */
215         bool isCompleted(void)
216         {
217           if (hasDirectAxisReference()) if (!getDirectAxisReference()->isCompleted()) return false;
218           else return isCompleted_ ;
219
220           MISSING_RETURN( "bool CAxis::isCompleted() " );
221           return true;
222         }
223         void setCompleted(void) { isCompleted_=true ; }
224         void unsetCompleted(void) { isCompleted_=false ; }
225     
226      private:
227         bool isChecked;
228         std::set<StdString> relFiles, relFilesCompressed;
229          std::map<int, std::unordered_map<int, vector<size_t> > > indSrv_; // Global index of each client sent to server
230         std::map<int, std::vector<int> > connectedServerRank_;
231
232       //////////////////////////////////////////////////////////////////////////////////////
233       //  this part is related to distribution, element definition, views and connectors  //
234       //////////////////////////////////////////////////////////////////////////////////////
235         
236        private:
237         shared_ptr<CLocalElement> localElement_ ;
238         void initializeLocalElement(void) ;
239        public: 
240         shared_ptr<CLocalElement> getLocalElement(void) { if (localElement_==nullptr) initializeLocalElement() ; return localElement_ ; }
241         shared_ptr<CLocalView> getLocalView(CElementView::type type) { return getLocalElement()->getView(type) ;}
242        private:
243         void addFullView(void) ;
244         void addWorkflowView(void) ;
245         void addModelView(void) ;
246
247        private:
248         shared_ptr<CLocalConnector> modelToWorkflowConnector_ ;
249         void computeModelToWorkflowConnector(void)  ;
250        public:
251         shared_ptr<CLocalConnector> getModelToWorkflowConnector(void) { if (modelToWorkflowConnector_==nullptr) computeModelToWorkflowConnector() ; return modelToWorkflowConnector_ ;}
252       
253       public:
254         void computeRemoteElement(CContextClient* client, EDistributionType) ;
255         void distributeToServer(CContextClient* client, std::map<int, CArray<size_t,1>>& globalIndexOut, std::map<int, CArray<size_t,1>>& globalIndexIn, 
256                                 shared_ptr<CScattererConnector>& scattererConnector, const string& axisId="") ;
257
258         static void recvAxisDistribution(CEventServer& event) ;
259         void receivedAxisDistribution(CEventServer& event, int phasis) ;
260         void setServerMask(CArray<bool,1>& serverMask, CContextClient* client ) ;
261         void sendDistributedAttributes(CContextClient* client, shared_ptr<CScattererConnector> scattererConnector, const string& axisId) ;
262         static void recvDistributedAttributes(CEventServer& event) ;
263         void recvDistributedAttributes(CEventServer& event, const string& type) ;
264       private:
265         map<CContextClient*, shared_ptr<CDistributedElement>> remoteElement_ ;
266       public: 
267         shared_ptr<CDistributedElement> getRemoteElement(CContextClient* client) {return remoteElement_[client] ;}
268       private:
269         map<CContextClient*, shared_ptr<CScattererConnector>> clientToServerConnector_ ;
270       public: 
271         shared_ptr<CScattererConnector> getClientToServerConnector(CContextClient* client) { return clientToServerConnector_[client] ;}
272       private:
273         shared_ptr<CGathererConnector>  gathererConnector_ ;
274       public:
275         shared_ptr<CGathererConnector> getGathererConnector(void) { return gathererConnector_ ;}
276       private:
277         shared_ptr<CGathererConnector> serverFromClientConnector_ ;
278         shared_ptr<CDistributedElement> elementFrom_ ;
279       public:
280        shared_ptr<CGathererConnector> getServerFromClientConnector(void) { return serverFromClientConnector_ ;}
281
282       private:
283         shared_ptr<CScattererConnector> serverToClientConnector_ = nullptr ;
284         shared_ptr<CDistributedElement> elementTo_ ;
285       public: 
286         shared_ptr<CScattererConnector> getServerToClientConnector(void) { return serverToClientConnector_ ;} 
287
288       private:
289          map<CContextClient*,shared_ptr<CGathererConnector>>  clientFromServerConnector_  ;
290       public: 
291        shared_ptr<CGathererConnector> getClientFromServerConnector(CContextClient* client) { return clientFromServerConnector_[client] ;} 
292
293         DECLARE_REF_FUNC(Axis,axis)
294   }; // class CAxis
295
296   ///--------------------------------------------------------------
297
298   // Declare/Define CAxisGroup and CAxisDefinition
299   DECLARE_GROUP(CAxis);
300} // namespace xios
301
302#endif // __XIOS_CAxis__
Note: See TracBrowser for help on using the repository browser.