source: XIOS/dev/XIOS_DEV_CMIP6/src/node/domain.hpp @ 1236

Last change on this file since 1236 was 1236, checked in by mhnguyen, 7 years ago

Making some changes to allow pools with different number of server

+) Associate context client to each grid distribution (This should be changed in the future)
+) Correct some buffer size estimation
+) Clean some redundant code and add comments

  • 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
File size: 8.5 KB
Line 
1#ifndef __XIOS_CDomain__
2#define __XIOS_CDomain__
3
4/// XIOS headers ///
5#include "xios_spl.hpp"
6#include "group_factory.hpp"
7
8#include "declare_group.hpp"
9#include "declare_ref_func.hpp"
10#include "event_client.hpp"
11#include "event_server.hpp"
12#include "buffer_in.hpp"
13#include "array_new.hpp"
14#include "attribute_array.hpp"
15#include "attribute_enum.hpp"
16#include "transformation.hpp"
17#include "transformation_enum.hpp"
18#include "server_distribution_description.hpp"
19#include "mesh.hpp"
20
21namespace xios {
22
23   /// ////////////////////// Déclarations ////////////////////// ///
24
25   class CDomainGroup;
26   class CDomainAttributes;
27   class CDomain;
28   class CFile;
29
30   ///--------------------------------------------------------------
31
32   // Declare/Define CDomainAttribute
33   BEGIN_DECLARE_ATTRIBUTE_MAP(CDomain)
34#  include "domain_attribute.conf"
35#  include "domain_attribute_private.conf"
36   END_DECLARE_ATTRIBUTE_MAP(CDomain)
37
38   ///--------------------------------------------------------------
39
40   class CDomain
41      : public CObjectTemplate<CDomain>
42      , public CDomainAttributes
43   {
44     /// typedef ///
45     typedef CObjectTemplate<CDomain>   SuperClass;
46     typedef CDomainAttributes SuperClassAttribute;
47     public:
48         enum EEventId
49         {
50           EVENT_ID_INDEX, EVENT_ID_LON, EVENT_ID_LAT, 
51           EVENT_ID_AREA, EVENT_ID_MASK,
52           EVENT_ID_DATA_INDEX, EVENT_ID_SERVER_ATTRIBUT
53         } ;
54
55      public:
56
57         typedef CDomainAttributes RelAttributes;
58         typedef CDomainGroup      RelGroup;
59         typedef CTransformation<CDomain>::TransformationMapTypes TransMapTypes;
60
61         /// Constructeurs ///
62         CDomain(void);
63         explicit CDomain(const StdString & id);
64         CDomain(const CDomain & domain);       // Not implemented yet.
65         CDomain(const CDomain * const domain); // Not implemented yet.
66
67         static CDomain* createDomain();
68         
69         CMesh* mesh;
70         void assignMesh(const StdString, const int);
71       
72         virtual void parse(xml::CXMLNode & node);
73
74         /// Vérifications ///
75         void checkAttributes(void);
76         void checkAttributesOnClient();
77         void checkAttributesOnClientAfterTransformation();
78         void checkEligibilityForCompressedOutput(void);
79
80         void sendCheckedAttributes();
81
82         bool hasTransformation();
83         void solveInheritanceTransformation();
84         TransMapTypes getAllTransformations();
85         void redistribute(int nbLocalDomain);
86         void duplicateTransformation(CDomain*);
87         CTransformation<CDomain>* addTransformation(ETranformationType transType, const StdString& id="");
88
89      public:
90         const std::set<StdString> & getRelFiles(void) const;
91         bool IsWritten(const StdString & filename) const;
92         bool isWrittenCompressed(const StdString& filename) const;
93         
94         int getNumberWrittenIndexes() const;
95         int getTotalNumberWrittenIndexes() const;
96         int getOffsetWrittenIndexes() const;
97
98         std::map<int, StdSize> getAttributesBufferSize(CContextClient* client);
99
100         bool isEmpty(void) const;
101         bool isDistributed(void) const;
102         bool isCompressible(void) const; 
103 
104         std::vector<int> getNbGlob();
105         bool isEqual(CDomain* domain);
106
107         static bool dispatchEvent(CEventServer& event);
108
109      public:
110         /// Mutateur ///
111         void addRelFile(const StdString & filename);
112         void addRelFileCompressed(const StdString& filename);           
113         
114         void computeWrittenIndex();
115
116         void AllgatherRectilinearLonLat(CArray<double,1>& lon, CArray<double,1>& lat,
117                                         CArray<double,1>& lon_g, CArray<double,1>& lat_g);
118
119         void fillInRectilinearBoundLonLat(CArray<double,1>& lon, CArray<double,1>& lat,
120                                           CArray<double,2>& boundsLon, CArray<double,2>& boundsLat);
121         
122         void fillInLonLat();
123         bool distributionAttributesHaveValue() const;
124
125         size_t getGlobalWrittenSize() ;
126         /// Destructeur ///
127         virtual ~CDomain(void);
128
129         /// Accesseurs statiques ///
130         static StdString GetName(void);
131         static StdString GetDefName(void);
132
133         static ENodeType GetType(void);       
134
135      public:
136         CArray<double, 1> lonvalue, latvalue;
137         CArray<double, 2> bounds_lonvalue, bounds_latvalue;
138         CArray<double, 1> areavalue;
139
140         CArray<size_t,1> localIndexToWriteOnServer;
141         CArray<int, 1> compressedIndexToWriteOnServer;
142
143         CArray<bool, 1> localMask;
144         bool isCurvilinear ;
145         bool hasBounds ;
146         bool hasArea;
147         bool hasLonLat;
148         bool hasPole ;
149
150      private:
151         void checkDomain(void);
152         void checkLocalIDomain(void);
153         void checkLocalJDomain(void);
154
155         void checkMask(void);
156         void checkDomainData(void);
157         void checkCompression(void);
158
159         void checkBounds(void);
160         void checkArea(void);
161         void checkLonLat();
162         void checkZoom(void);
163         void computeLocalMask(void) ;
164
165         void setTransformations(const TransMapTypes&);         
166         void computeNGlobDomain();
167         void sendAttributes();
168         void sendIndex();
169         void sendDistributionAttributes();
170         void sendMask();
171         void sendArea();
172         void sendLonLat();         
173         void sendDataIndex();
174         void convertLonLatValue();
175         void fillInRectilinearLonLat();
176         void fillInCurvilinearLonLat();
177         void fillInUnstructuredLonLat();
178         
179         static void recvDistributionAttributes(CEventServer& event);
180         static void recvIndex(CEventServer& event);
181         static void recvIndexZoom(CEventServer& event);
182         static void recvMask(CEventServer& event);         
183         static void recvLon(CEventServer& event);
184         static void recvLat(CEventServer& event);
185         static void recvArea(CEventServer& event);
186         static void recvDataIndex(CEventServer& event);
187         void recvDistributionAttributes(CBufferIn& buffer);                 
188         void recvIndex(std::map<int, CBufferIn*>& rankBuffers);         
189         void recvMask(std::map<int, CBufferIn*>& rankBuffers);
190         void recvLon(std::map<int, CBufferIn*>& rankBuffers);
191         void recvLat(std::map<int, CBufferIn*>& rankBuffers);
192         void recvArea(std::map<int, CBufferIn*>& rankBuffers);         
193         void recvDataIndex(std::map<int, CBufferIn*>& rankBuffers);
194
195         void completeLonLatClient(void); 
196         void computeConnectedClients();   
197
198       private:         
199         bool doZoomByIndex_;
200         bool isChecked, computedWrittenIndex_;
201         std::set<StdString> relFiles, relFilesCompressed;
202         bool isClientChecked; // Verify whether all attributes of domain on the client side are good
203         bool isClientAfterTransformationChecked;
204         std::map<int, CArray<int,1> > indGlob_;
205         std::map<CContextClient*, map<int,int> > nbSenders; // Mapping of number of communicating client to a server
206
207         std::map<CContextClient*, boost::unordered_map<int, vector<size_t> > > indSrv_; // Global index of each client sent to server         
208         // std::map<CContextClient*, std::map<int, vector<int> > > indWrittenSrv_; // Global written index of each client sent to server
209         std::vector<int> indexesToWrite;
210         std::vector<int> recvClientRanks_;
211         int numberWrittenIndexes_, totalNumberWrittenIndexes_, offsetWrittenIndexes_;         
212         std::map<CContextClient*, std::map<int,size_t> > connectedDataSize_;
213         std::map<CContextClient*, std::vector<int> > connectedServerRank_;
214
215         //! True if and only if the data defined on the domain can be outputted in a compressed way
216         bool isCompressible_;
217         bool isRedistributed_;
218         TransMapTypes transformationMap_;         
219         bool isUnstructed_;
220         boost::unordered_map<size_t,size_t> globalLocalIndexMap_;
221       
222       private:
223         static bool initializeTransformationMap(std::map<StdString, ETranformationType>& m);
224         static std::map<StdString, ETranformationType> transformationMapList_;
225         static bool _dummyTransformationMapList;
226
227         DECLARE_REF_FUNC(Domain,domain)
228
229   }; // class CDomain
230
231   ///--------------------------------------------------------------
232
233   // Declare/Define CDomainGroup and CDomainDefinition
234   DECLARE_GROUP(CDomain);
235
236   ///--------------------------------------------------------------
237
238} // namespace xios
239
240#endif //__XIOS_CDomain__
Note: See TracBrowser for help on using the repository browser.