source: XIOS/dev/dev_olga/src/node/domain.hpp @ 1158

Last change on this file since 1158 was 1158, checked in by oabramkina, 7 years ago

Two server levels: merging with trunk r1137.
There are bugs.

  • 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: 9.0 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           EVENT_ID_INDEX_ZOOM
54         } ;
55
56
57
58      public:
59
60         typedef CDomainAttributes RelAttributes;
61         typedef CDomainGroup      RelGroup;
62         typedef CTransformation<CDomain>::TransformationMapTypes TransMapTypes;
63
64         /// Constructeurs ///
65         CDomain(void);
66         explicit CDomain(const StdString & id);
67         CDomain(const CDomain & domain);       // Not implemented yet.
68         CDomain(const CDomain * const domain); // Not implemented yet.
69
70         static CDomain* createDomain();
71         
72         CMesh* mesh;
73         void assignMesh(const StdString, const int);
74       
75         virtual void parse(xml::CXMLNode & node);
76
77         /// Vérifications ///
78         void checkAttributes(void);
79         void checkAttributesOnClient();
80         void checkAttributesOnClientAfterTransformation();
81         void checkEligibilityForCompressedOutput(void);
82
83         void sendCheckedAttributes();
84
85         bool hasTransformation();
86         void solveInheritanceTransformation();
87         TransMapTypes getAllTransformations();
88         void redistribute(int nbLocalDomain);
89         void duplicateTransformation(CDomain*);
90         CTransformation<CDomain>* addTransformation(ETranformationType transType, const StdString& id="");
91
92      public:
93         const std::set<StdString> & getRelFiles(void) const;
94         bool IsWritten(const StdString & filename) const;
95         bool isWrittenCompressed(const StdString& filename) const;
96         
97         int getNumberWrittenIndexes() const;
98         int getTotalNumberWrittenIndexes() const;
99         int getOffsetWrittenIndexes() const;
100
101         std::map<int, StdSize> getAttributesBufferSize();
102         CArray<size_t,1> localIndexToWriteOnServer;
103         CArray<int, 1> compressedIndexToWriteOnServer;
104
105         bool isEmpty(void) const;
106         bool isDistributed(void) const;
107         bool isCompressible(void) const; 
108 
109         CArray<double, 1> lonvalue, latvalue;
110         CArray<double, 2> bounds_lonvalue, bounds_latvalue;
111         CArray<double, 1> areavalue;
112
113         vector<int> connectedServer ; // list of connected server
114         vector<int> nbSenders ; // for each communication with a server, number of communicating client
115         vector<int> nbDataSrv ; // size of data to send to each server
116         vector< vector<int> > i_indSrv ; // for each server, i global index to send
117         vector< vector<int> > j_indSrv ; // for each server, j global index to send
118         std::vector<int> getNbGlob();
119         bool isEqual(CDomain* domain);
120      public:
121         /// Mutateur ///
122         void addRelFile(const StdString & filename);
123         void addRelFileCompressed(const StdString& filename);
124         void completeLonLatClient(void);         
125         void computeConnectedClients();
126         void computeWrittenIndex();
127
128         void AllgatherRectilinearLonLat(CArray<double,1>& lon, CArray<double,1>& lat,
129                                         CArray<double,1>& lon_g, CArray<double,1>& lat_g);
130
131         void fillInRectilinearBoundLonLat(CArray<double,1>& lon, CArray<double,1>& lat,
132                                           CArray<double,2>& boundsLon, CArray<double,2>& boundsLat);
133         
134         void fillInLonLat();
135         bool distributionAttributesHaveValue() const;
136
137         static bool dispatchEvent(CEventServer& event);
138         static void recvDistributionAttributes(CEventServer& event);
139         static void recvIndex(CEventServer& event);
140         static void recvIndexZoom(CEventServer& event);
141         static void recvMask(CEventServer& event);
142         static void recvZoom(CEventServer& event);
143         static void recvLon(CEventServer& event);
144         static void recvLat(CEventServer& event);
145         static void recvArea(CEventServer& event);
146         static void recvDataIndex(CEventServer& event);
147         void recvDistributionAttributes(CBufferIn& buffer);                 
148         void recvIndex(std::map<int, CBufferIn*>& rankBuffers);
149         void recvIndexZoom(std::map<int, CBufferIn*>& rankBuffers);
150         void recvMask(std::map<int, CBufferIn*>& rankBuffers);
151         void recvLon(std::map<int, CBufferIn*>& rankBuffers);
152         void recvLat(std::map<int, CBufferIn*>& rankBuffers);
153         void recvArea(std::map<int, CBufferIn*>& rankBuffers);         
154         void recvDataIndex(std::map<int, CBufferIn*>& rankBuffers);
155
156         /// Destructeur ///
157         virtual ~CDomain(void);
158
159         /// Accesseurs statiques ///
160         static StdString GetName(void);
161         static StdString GetDefName(void);
162
163         static ENodeType GetType(void);
164         const std::map<int, vector<size_t> >& getIndexServer() const;
165         CArray<bool, 1> localMask;
166         bool isCurvilinear ;
167         bool hasBounds ;
168         bool hasArea;
169         bool hasLonLat;
170         bool hasPole ;
171
172      private:
173         void checkDomain(void);
174         void checkLocalIDomain(void);
175         void checkLocalJDomain(void);
176
177         void checkMask(void);
178         void checkDomainData(void);
179         void checkCompression(void);
180
181         void checkBounds(void);
182         void checkArea(void);
183         void checkLonLat();
184         void checkZoom(void);
185         void computeLocalMask(void) ;
186
187         void setTransformations(const TransMapTypes&);         
188         void computeNGlobDomain();
189         void sendAttributes();
190         void sendIndex();
191         void sendDistributionAttributes();
192         void sendMask();
193         void sendArea();
194         void sendLonLat();
195         void sendIndexZoom();
196         void sendDataIndex();
197         void convertLonLatValue();
198         void fillInRectilinearLonLat();
199         void fillInCurvilinearLonLat();
200         void fillInUnstructuredLonLat();
201       private:         
202         bool doZoomByIndex_;
203         bool isChecked, computedWrittenIndex_;
204         std::set<StdString> relFiles, relFilesCompressed;
205         bool isClientChecked; // Verify whether all attributes of domain on the client side are good
206         bool isClientAfterTransformationChecked;
207         std::map<int, CArray<int,1> > indiSrv, indjSrv, indGlob_, indGlobZoom_;
208         std::map<int,int> nbConnectedClients_, nbConnectedClientsZoom_; // Mapping of number of communicating client to a server
209
210         boost::unordered_map<int, vector<size_t> > indSrv_; // Global index of each client sent to server
211         boost::unordered_map<int, vector<size_t> > indZoomSrv_; // Global index of each client sent to server
212         std::map<int, vector<int> > indWrittenSrv_; // Global written index of each client sent to server
213         std::vector<int> indexesToWrite;
214         std::vector<int> recvClientRanks_, recvClientZoomRanks_;
215         int numberWrittenIndexes_, totalNumberWrittenIndexes_, offsetWrittenIndexes_;
216         std::vector<int> connectedServerRank_, connectedServerZoomRank_;         
217         //! True if and only if the data defined on the domain can be outputted in a compressed way
218         bool isCompressible_;
219         bool isRedistributed_;
220         TransMapTypes transformationMap_;         
221         bool isUnstructed_;
222         boost::unordered_map<size_t,size_t> globalLocalIndexMap_, globalLocalIndexZoomMap_;
223       
224       private:
225         static bool initializeTransformationMap(std::map<StdString, ETranformationType>& m);
226         static std::map<StdString, ETranformationType> transformationMapList_;
227         static bool _dummyTransformationMapList;
228
229         DECLARE_REF_FUNC(Domain,domain)
230
231   }; // class CDomain
232
233   ///--------------------------------------------------------------
234
235   // Declare/Define CDomainGroup and CDomainDefinition
236   DECLARE_GROUP(CDomain);
237
238   ///--------------------------------------------------------------
239
240} // namespace xios
241
242#endif //__XIOS_CDomain__
Note: See TracBrowser for help on using the repository browser.