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

Last change on this file since 2291 was 2291, checked in by ymipsl, 2 years ago

Improve reduction transformation

  • make the difference between reduction over geometry or reduction between process.
  • geometrical reduction :

domain -> axis
axis -> scalar
domain -> scalar

  • reduction across processes for redondant geometrical cell :

axis -> axis
scalar -> scalar

Reduction can be local (only for the geometrical cell owned by current process) or global, using the "local" attribute (bool) over the reduction.

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.2 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         bool checkGeometricAttributes(bool generateError) ; 
127         void setGeometricAttributes(const CAxis& axisSrc) ;
128         void resetGeometricAttributes(void) ;
129
130         size_t getGlobalWrittenSize(void) ;
131
132      //////////////////////////
133      ///// transformations ////
134      //////////////////////////
135      public:
136        typedef CTransformation<CAxis>::TransformationMapTypes TransMapTypes;
137      private:
138        static bool initializeTransformationMap(std::map<StdString, ETranformationType>& m);
139        static std::map<StdString, ETranformationType> transformationMapList_;
140        static bool dummyTransformationMapList_;
141        TransMapTypes transformationMap_;         
142
143      public:
144        CTransformation<CAxis>* addTransformation(ETranformationType transType, const StdString& id="");
145        CTransformation<CAxis>* addTransformation(ETranformationType transType, CTransformation<CAxis>* transformation) ;
146        void setTransformations(const TransMapTypes&);         
147        void duplicateTransformation(CAxis*);
148        TransMapTypes getAllTransformations();
149        bool hasTransformation();
150        void solveInheritanceTransformation_old(); // to remove later
151        void solveInheritanceTransformation();
152      private:
153        bool solveInheritanceTransformation_done_= false ;
154      public:
155        bool activateFieldWorkflow(CGarbageCollector& gc) ;
156      private:
157        bool activateFieldWorkflow_done_=false ;
158      private:
159        shared_ptr<CGenericAlgorithmTransformation> transformationAlgorithm_ = nullptr ;
160      public:
161        void setTransformationAlgorithm(shared_ptr<CGenericAlgorithmTransformation> transformationAlgorithm) { transformationAlgorithm_=transformationAlgorithm ;}
162        shared_ptr<CGenericAlgorithmTransformation> getTransformationAlgorithm(void) { return transformationAlgorithm_ ;}   
163      private:
164        CTransformationPaths transformationPaths_ ;
165      public:
166        CTransformationPaths getTransformationPaths(void) {return transformationPaths_;} 
167        void setTransformationPaths(const CTransformationPaths& transformationPaths) { transformationPaths_=transformationPaths ;}
168
169      ////////////////////////////
170         bool isEqual(CAxis* axis);
171
172      public: 
173        bool hasValue;       
174        bool hasBounds;
175        bool hasLabel;
176
177      private:
178         bool checkData(bool generateError);
179         bool checkMask(bool generateError);
180         bool checkBounds(bool generateError);
181         bool checkLabel(bool generateError);
182     
183      public:
184         void sendAxisToCouplerOut(CContextClient* client, const std::vector<int>& globalDim, int orderPositionInGrid, const string& fieldId, int posInGrid) ;
185      private:
186         std::set<CContextClient*> sendAxisToCouplerOut_done_ ;
187   
188      public:
189         void makeAliasForCoupling(const string& fieldId, int posInGrid) ;
190         string getCouplingAlias(const string& fieldId, int posInGrid) ;
191
192      private:
193
194/** Clients that have to send a axis. There can be multiple clients in case of secondary server, otherwise only one client. */
195         std::list<CContextClient*> clients;
196         std::set<CContextClient*> clientsSet;
197
198      private:
199         /** define if the axis is completed or not ie all attributes have been received before in case
200             of grid reading from file or coupling */ 
201         bool isCompleted_=true ; 
202      public:     
203         /*!
204           \brief Check if a axis is completed
205           Before make any axis processing, we must be sure that all axis informations have
206           been sent, for exemple when reading a grid in a file or when grid elements are sent by an
207           other context (coupling). So all direct reference of the axis (axis_ref) must be also completed
208           \return true if axis and axis reference are completed
209          */
210         bool isCompleted(void)
211         {
212           if (hasDirectAxisReference()) if (!getDirectAxisReference()->isCompleted()) return false;
213           else return isCompleted_ ;
214
215           MISSING_RETURN( "bool CAxis::isCompleted() " );
216           return true;
217         }
218         void setCompleted(void) { isCompleted_=true ; }
219         void unsetCompleted(void) { isCompleted_=false ; }
220     
221      private:
222         bool isChecked;
223         std::set<StdString> relFiles, relFilesCompressed;
224          std::map<int, std::unordered_map<int, vector<size_t> > > indSrv_; // Global index of each client sent to server
225         std::map<int, std::vector<int> > connectedServerRank_;
226
227       //////////////////////////////////////////////////////////////////////////////////////
228       //  this part is related to distribution, element definition, views and connectors  //
229       //////////////////////////////////////////////////////////////////////////////////////
230         
231        private:
232         shared_ptr<CLocalElement> localElement_ ;
233         void initializeLocalElement(void) ;
234        public: 
235         shared_ptr<CLocalElement> getLocalElement(void) { if (localElement_==nullptr) initializeLocalElement() ; return localElement_ ; }
236         shared_ptr<CLocalView> getLocalView(CElementView::type type) { return getLocalElement()->getView(type) ;}
237        private:
238         void addFullView(void) ;
239         void addWorkflowView(void) ;
240         void addModelView(void) ;
241
242        private:
243         shared_ptr<CLocalConnector> modelToWorkflowConnector_ ;
244         void computeModelToWorkflowConnector(void)  ;
245        public:
246         shared_ptr<CLocalConnector> getModelToWorkflowConnector(void) { if (modelToWorkflowConnector_==nullptr) computeModelToWorkflowConnector() ; return modelToWorkflowConnector_ ;}
247       
248       public:
249         void computeRemoteElement(CContextClient* client, EDistributionType) ;
250         void distributeToServer(CContextClient* client, std::map<int, CArray<size_t,1>>& globalIndex, shared_ptr<CScattererConnector>& scattererConnector,
251                                 const string& axisId="") ;
252
253         static void recvAxisDistribution(CEventServer& event) ;
254         void receivedAxisDistribution(CEventServer& event, int phasis) ;
255         void setServerMask(CArray<bool,1>& serverMask, CContextClient* client ) ;
256         void sendDistributedAttributes(CContextClient* client, shared_ptr<CScattererConnector> scattererConnector, const string& axisId) ;
257         static void recvDistributedAttributes(CEventServer& event) ;
258         void recvDistributedAttributes(CEventServer& event, const string& type) ;
259       private:
260         map<CContextClient*, shared_ptr<CDistributedElement>> remoteElement_ ;
261       public: 
262         shared_ptr<CDistributedElement> getRemoteElement(CContextClient* client) {return remoteElement_[client] ;}
263       private:
264         map<CContextClient*, shared_ptr<CScattererConnector>> clientToServerConnector_ ;
265       public: 
266         shared_ptr<CScattererConnector> getClientToServerConnector(CContextClient* client) { return clientToServerConnector_[client] ;}
267       private:
268         shared_ptr<CGathererConnector>  gathererConnector_ ;
269       public:
270         shared_ptr<CGathererConnector> getGathererConnector(void) { return gathererConnector_ ;}
271       private:
272         shared_ptr<CGathererConnector> serverFromClientConnector_ ;
273         shared_ptr<CDistributedElement> elementFrom_ ;
274       public:
275        shared_ptr<CGathererConnector> getServerFromClientConnector(void) { return serverFromClientConnector_ ;}
276
277       private:
278         shared_ptr<CScattererConnector> serverToClientConnector_ = nullptr ;
279       public: 
280         shared_ptr<CScattererConnector> getServerToClientConnector(void) { return serverToClientConnector_ ;} 
281
282       private:
283          map<CContextClient*,shared_ptr<CGathererConnector>>  clientFromServerConnector_  ;
284       public: 
285        shared_ptr<CGathererConnector> getClientFromServerConnector(CContextClient* client) { return clientFromServerConnector_[client] ;} 
286
287         DECLARE_REF_FUNC(Axis,axis)
288   }; // class CAxis
289
290   ///--------------------------------------------------------------
291
292   // Declare/Define CAxisGroup and CAxisDefinition
293   DECLARE_GROUP(CAxis);
294} // namespace xios
295
296#endif // __XIOS_CAxis__
Note: See TracBrowser for help on using the repository browser.