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
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 ;
[2291]126         bool checkGeometricAttributes(bool generateError) ; 
127         void setGeometricAttributes(const CAxis& axisSrc) ;
128         void resetGeometricAttributes(void) ;
[619]129
[1215]130         size_t getGlobalWrittenSize(void) ;
[676]131
[1984]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 ;
[2206]154      public:
155        bool activateFieldWorkflow(CGarbageCollector& gc) ;
[1984]156      private:
[2206]157        bool activateFieldWorkflow_done_=false ;
158      private:
[2270]159        shared_ptr<CGenericAlgorithmTransformation> transformationAlgorithm_ = nullptr ;
[1984]160      public:
[2270]161        void setTransformationAlgorithm(shared_ptr<CGenericAlgorithmTransformation> transformationAlgorithm) { transformationAlgorithm_=transformationAlgorithm ;}
162        shared_ptr<CGenericAlgorithmTransformation> getTransformationAlgorithm(void) { return transformationAlgorithm_ ;}   
[1984]163      private:
164        CTransformationPaths transformationPaths_ ;
165      public:
166        CTransformationPaths getTransformationPaths(void) {return transformationPaths_;} 
167        void setTransformationPaths(const CTransformationPaths& transformationPaths) { transformationPaths_=transformationPaths ;}
168
169      ////////////////////////////
[1158]170         bool isEqual(CAxis* axis);
[619]171
[1235]172      public: 
173        bool hasValue;       
[1558]174        bool hasBounds;
175        bool hasLabel;
176
[1984]177      private:
[2291]178         bool checkData(bool generateError);
179         bool checkMask(bool generateError);
180         bool checkBounds(bool generateError);
181         bool checkLabel(bool generateError);
[1870]182     
[1875]183      public:
184         void sendAxisToCouplerOut(CContextClient* client, const std::vector<int>& globalDim, int orderPositionInGrid, const string& fieldId, int posInGrid) ;
[1870]185      private:
[1875]186         std::set<CContextClient*> sendAxisToCouplerOut_done_ ;
187   
188      public:
189         void makeAliasForCoupling(const string& fieldId, int posInGrid) ;
[2022]190         string getCouplingAlias(const string& fieldId, int posInGrid) ;
[1875]191
[567]192      private:
[1345]193
[1875]194/** Clients that have to send a axis. There can be multiple clients in case of secondary server, otherwise only one client. */
[1353]195         std::list<CContextClient*> clients;
196         std::set<CContextClient*> clientsSet;
[1345]197
[1875]198      private:
[1869]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 ; 
[1875]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_ ;
[2282]214
215           MISSING_RETURN( "bool CAxis::isCompleted() " );
216           return true;
[1875]217         }
218         void setCompleted(void) { isCompleted_=true ; }
219         void unsetCompleted(void) { isCompleted_=false ; }
220     
221      private:
[219]222         bool isChecked;
[676]223         std::set<StdString> relFiles, relFilesCompressed;
[1984]224          std::map<int, std::unordered_map<int, vector<size_t> > > indSrv_; // Global index of each client sent to server
[1337]225         std::map<int, std::vector<int> > connectedServerRank_;
[1099]226
[1930]227       //////////////////////////////////////////////////////////////////////////////////////
228       //  this part is related to distribution, element definition, views and connectors  //
229       //////////////////////////////////////////////////////////////////////////////////////
[1918]230         
231        private:
[2267]232         shared_ptr<CLocalElement> localElement_ ;
[1918]233         void initializeLocalElement(void) ;
234        public: 
[2267]235         shared_ptr<CLocalElement> getLocalElement(void) { if (localElement_==nullptr) initializeLocalElement() ; return localElement_ ; }
236         shared_ptr<CLocalView> getLocalView(CElementView::type type) { return getLocalElement()->getView(type) ;}
[1918]237        private:
238         void addFullView(void) ;
239         void addWorkflowView(void) ;
240         void addModelView(void) ;
241
242        private:
[2267]243         shared_ptr<CLocalConnector> modelToWorkflowConnector_ ;
[1918]244         void computeModelToWorkflowConnector(void)  ;
245        public:
[2267]246         shared_ptr<CLocalConnector> getModelToWorkflowConnector(void) { if (modelToWorkflowConnector_==nullptr) computeModelToWorkflowConnector() ; return modelToWorkflowConnector_ ;}
[1930]247       
248       public:
249         void computeRemoteElement(CContextClient* client, EDistributionType) ;
[2267]250         void distributeToServer(CContextClient* client, std::map<int, CArray<size_t,1>>& globalIndex, shared_ptr<CScattererConnector>& scattererConnector,
[1956]251                                 const string& axisId="") ;
[1918]252
[1930]253         static void recvAxisDistribution(CEventServer& event) ;
254         void receivedAxisDistribution(CEventServer& event, int phasis) ;
[1943]255         void setServerMask(CArray<bool,1>& serverMask, CContextClient* client ) ;
[2267]256         void sendDistributedAttributes(CContextClient* client, shared_ptr<CScattererConnector> scattererConnector, const string& axisId) ;
[1930]257         static void recvDistributedAttributes(CEventServer& event) ;
258         void recvDistributedAttributes(CEventServer& event, const string& type) ;
259       private:
[2267]260         map<CContextClient*, shared_ptr<CDistributedElement>> remoteElement_ ;
[1930]261       public: 
[2267]262         shared_ptr<CDistributedElement> getRemoteElement(CContextClient* client) {return remoteElement_[client] ;}
[1930]263       private:
[2267]264         map<CContextClient*, shared_ptr<CScattererConnector>> clientToServerConnector_ ;
[1930]265       public: 
[2267]266         shared_ptr<CScattererConnector> getClientToServerConnector(CContextClient* client) { return clientToServerConnector_[client] ;}
[1930]267       private:
[2267]268         shared_ptr<CGathererConnector>  gathererConnector_ ;
[1943]269       public:
[2267]270         shared_ptr<CGathererConnector> getGathererConnector(void) { return gathererConnector_ ;}
[1943]271       private:
[2267]272         shared_ptr<CGathererConnector> serverFromClientConnector_ ;
273         shared_ptr<CDistributedElement> elementFrom_ ;
[1930]274       public:
[2267]275        shared_ptr<CGathererConnector> getServerFromClientConnector(void) { return serverFromClientConnector_ ;}
[1930]276
[1934]277       private:
[2267]278         shared_ptr<CScattererConnector> serverToClientConnector_ = nullptr ;
[1934]279       public: 
[2267]280         shared_ptr<CScattererConnector> getServerToClientConnector(void) { return serverToClientConnector_ ;} 
[1930]281
[1934]282       private:
[2267]283          map<CContextClient*,shared_ptr<CGathererConnector>>  clientFromServerConnector_  ;
[1934]284       public: 
[2267]285        shared_ptr<CGathererConnector> getClientFromServerConnector(CContextClient* client) { return clientFromServerConnector_[client] ;} 
[1930]286
[540]287         DECLARE_REF_FUNC(Axis,axis)
[219]288   }; // class CAxis
289
290   ///--------------------------------------------------------------
291
292   // Declare/Define CAxisGroup and CAxisDefinition
293   DECLARE_GROUP(CAxis);
[335]294} // namespace xios
[219]295
[591]296#endif // __XIOS_CAxis__
Note: See TracBrowser for help on using the repository browser.