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

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

Tracking memory leak :
Tranformations and algorithms are now managed with shared_ptr.

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