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

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

Tracking memory leak : release memory statically alocated

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.9 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"
[2274]25#include "grid_transformation_factory_impl.hpp"
[219]26
[1930]27
[1984]28namespace xios
29{
[219]30   /// ////////////////////// Déclarations ////////////////////// ///
31
32   class CAxisGroup;
33   class CAxisAttributes;
34   class CAxis;
[2206]35   class CField;
[219]36
37   ///--------------------------------------------------------------
38
39   // Declare/Define CAxisAttribute
40   BEGIN_DECLARE_ATTRIBUTE_MAP(CAxis)
[231]41#  include "axis_attribute.conf"
[219]42   END_DECLARE_ATTRIBUTE_MAP(CAxis)
43
44   ///--------------------------------------------------------------
45
46   class CAxis
47      : public CObjectTemplate<CAxis>
48      , public CAxisAttributes
49   {
[987]50               /// typedef ///
51         typedef CObjectTemplate<CAxis>   SuperClass;
52         typedef CAxisAttributes SuperClassAttribute;
53         
[1235]54      public:
[567]55         enum EEventId
56         {
[1930]57           EVENT_ID_AXIS_DISTRIBUTION,
58           EVENT_ID_SEND_DISTRIBUTED_ATTRIBUTE
[567]59         } ;
60
[1235]61      public:
[219]62         typedef CAxisAttributes RelAttributes;
63         typedef CAxisGroup      RelGroup;
64
[621]65      public:
[219]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.
[2274]71         static void releaseStaticAllocation(void) ; // release static allocation on heap
[219]72
[622]73         static CAxis* createAxis();
[2206]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) ;
[1158]77
78         /// Accesseurs ///
79         const std::set<StdString> & getRelFiles(void) const;
[1975]80 
[1371]81         std::map<int, StdSize> getAttributesBufferSize(CContextClient* client, const std::vector<int>& globalDim, int orderPositionInGrid,
82                                                        CServerDistributionDescription::ServerDistributionType disType = CServerDistributionDescription::BAND_DISTRIBUTION);
[731]83
[219]84         /// Test ///
85         bool IsWritten(const StdString & filename) const;
[676]86         bool isWrittenCompressed(const StdString& filename) const;
[594]87         bool isDistributed(void) const;
[1956]88       
[1984]89      public:
[1956]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_ ;} 
[1984]96      private:
[1956]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       
[1984]101      public:
[219]102
103         /// Mutateur ///
104         void addRelFile(const StdString & filename);
[676]105         void addRelFileCompressed(const StdString& filename);
[219]106
[1869]107         
[219]108
109         /// Destructeur ///
110         virtual ~CAxis(void);
111
[619]112         virtual void parse(xml::CXMLNode & node);
113
[1345]114         void setContextClient(CContextClient* contextClient);
115
[219]116         /// Accesseurs statiques ///
117         static StdString GetName(void);
118         static StdString GetDefName(void);
119         static ENodeType GetType(void);
120
[1235]121         static bool dispatchEvent(CEventServer& event);         
[1869]122       
123         /// Vérifications ///
124         void checkAttributes(void);
125         bool checkAttributes_done_ = false ;
[619]126
[1215]127         size_t getGlobalWrittenSize(void) ;
[676]128
[1984]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 ;
[2206]151      public:
152        bool activateFieldWorkflow(CGarbageCollector& gc) ;
[1984]153      private:
[2206]154        bool activateFieldWorkflow_done_=false ;
155      private:
[2270]156        shared_ptr<CGenericAlgorithmTransformation> transformationAlgorithm_ = nullptr ;
[1984]157      public:
[2270]158        void setTransformationAlgorithm(shared_ptr<CGenericAlgorithmTransformation> transformationAlgorithm) { transformationAlgorithm_=transformationAlgorithm ;}
159        shared_ptr<CGenericAlgorithmTransformation> getTransformationAlgorithm(void) { return transformationAlgorithm_ ;}   
[1984]160      private:
161        CTransformationPaths transformationPaths_ ;
162      public:
163        CTransformationPaths getTransformationPaths(void) {return transformationPaths_;} 
164        void setTransformationPaths(const CTransformationPaths& transformationPaths) { transformationPaths_=transformationPaths ;}
165
166      ////////////////////////////
[1158]167         bool isEqual(CAxis* axis);
[619]168
[1235]169      public: 
170        bool hasValue;       
[1558]171        bool hasBounds;
172        bool hasLabel;
173
[1984]174      private:
[551]175         void checkData();
176         void checkMask();
[1158]177         void checkBounds();
178         void checkLabel();
[1870]179     
[1875]180      public:
181         void sendAxisToCouplerOut(CContextClient* client, const std::vector<int>& globalDim, int orderPositionInGrid, const string& fieldId, int posInGrid) ;
[1870]182      private:
[1875]183         std::set<CContextClient*> sendAxisToCouplerOut_done_ ;
184   
185      public:
186         void makeAliasForCoupling(const string& fieldId, int posInGrid) ;
[2022]187         string getCouplingAlias(const string& fieldId, int posInGrid) ;
[1875]188
[567]189      private:
[1345]190
[1875]191/** Clients that have to send a axis. There can be multiple clients in case of secondary server, otherwise only one client. */
[1353]192         std::list<CContextClient*> clients;
193         std::set<CContextClient*> clientsSet;
[1345]194
[1875]195      private:
[1869]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 ; 
[1875]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         void setCompleted(void) { isCompleted_=true ; }
213         void unsetCompleted(void) { isCompleted_=false ; }
214     
215      private:
[219]216         bool isChecked;
[676]217         std::set<StdString> relFiles, relFilesCompressed;
[1984]218          std::map<int, std::unordered_map<int, vector<size_t> > > indSrv_; // Global index of each client sent to server
[1337]219         std::map<int, std::vector<int> > connectedServerRank_;
[1099]220
[1930]221       //////////////////////////////////////////////////////////////////////////////////////
222       //  this part is related to distribution, element definition, views and connectors  //
223       //////////////////////////////////////////////////////////////////////////////////////
[1918]224         
225        private:
[2267]226         shared_ptr<CLocalElement> localElement_ ;
[1918]227         void initializeLocalElement(void) ;
228        public: 
[2267]229         shared_ptr<CLocalElement> getLocalElement(void) { if (localElement_==nullptr) initializeLocalElement() ; return localElement_ ; }
230         shared_ptr<CLocalView> getLocalView(CElementView::type type) { return getLocalElement()->getView(type) ;}
[1918]231        private:
232         void addFullView(void) ;
233         void addWorkflowView(void) ;
234         void addModelView(void) ;
235
236        private:
[2267]237         shared_ptr<CLocalConnector> modelToWorkflowConnector_ ;
[1918]238         void computeModelToWorkflowConnector(void)  ;
239        public:
[2267]240         shared_ptr<CLocalConnector> getModelToWorkflowConnector(void) { if (modelToWorkflowConnector_==nullptr) computeModelToWorkflowConnector() ; return modelToWorkflowConnector_ ;}
[1930]241       
242       public:
243         void computeRemoteElement(CContextClient* client, EDistributionType) ;
[2267]244         void distributeToServer(CContextClient* client, std::map<int, CArray<size_t,1>>& globalIndex, shared_ptr<CScattererConnector>& scattererConnector,
[1956]245                                 const string& axisId="") ;
[1918]246
[1930]247         static void recvAxisDistribution(CEventServer& event) ;
248         void receivedAxisDistribution(CEventServer& event, int phasis) ;
[1943]249         void setServerMask(CArray<bool,1>& serverMask, CContextClient* client ) ;
[2267]250         void sendDistributedAttributes(CContextClient* client, shared_ptr<CScattererConnector> scattererConnector, const string& axisId) ;
[1930]251         static void recvDistributedAttributes(CEventServer& event) ;
252         void recvDistributedAttributes(CEventServer& event, const string& type) ;
253       private:
[2267]254         map<CContextClient*, shared_ptr<CDistributedElement>> remoteElement_ ;
[1930]255       public: 
[2267]256         shared_ptr<CDistributedElement> getRemoteElement(CContextClient* client) {return remoteElement_[client] ;}
[1930]257       private:
[2267]258         map<CContextClient*, shared_ptr<CScattererConnector>> clientToServerConnector_ ;
[1930]259       public: 
[2267]260         shared_ptr<CScattererConnector> getClientToServerConnector(CContextClient* client) { return clientToServerConnector_[client] ;}
[1930]261       private:
[2267]262         shared_ptr<CGathererConnector>  gathererConnector_ ;
[1943]263       public:
[2267]264         shared_ptr<CGathererConnector> getGathererConnector(void) { return gathererConnector_ ;}
[1943]265       private:
[2267]266         shared_ptr<CGathererConnector> serverFromClientConnector_ ;
267         shared_ptr<CDistributedElement> elementFrom_ ;
[1930]268       public:
[2267]269        shared_ptr<CGathererConnector> getServerFromClientConnector(void) { return serverFromClientConnector_ ;}
[1930]270
[1934]271       private:
[2267]272         shared_ptr<CScattererConnector> serverToClientConnector_ = nullptr ;
[1934]273       public: 
[2267]274         shared_ptr<CScattererConnector> getServerToClientConnector(void) { return serverToClientConnector_ ;} 
[1930]275
[1934]276       private:
[2267]277          map<CContextClient*,shared_ptr<CGathererConnector>>  clientFromServerConnector_  ;
[1934]278       public: 
[2267]279        shared_ptr<CGathererConnector> getClientFromServerConnector(CContextClient* client) { return clientFromServerConnector_[client] ;} 
[1930]280
[540]281         DECLARE_REF_FUNC(Axis,axis)
[219]282   }; // class CAxis
283
284   ///--------------------------------------------------------------
285
286   // Declare/Define CAxisGroup and CAxisDefinition
287   DECLARE_GROUP(CAxis);
[335]288} // namespace xios
[219]289
[591]290#endif // __XIOS_CAxis__
Note: See TracBrowser for help on using the repository browser.