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

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

Add missing return statements detected using -fsanitize=return. Return errors at runtime if reached.

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