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

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

Cleaning up some redundant codes

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