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 | |
---|
19 | #include "mesh.hpp" |
---|
20 | |
---|
21 | namespace 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 | |
---|
45 | enum EEventId |
---|
46 | { |
---|
47 | EVENT_ID_SERVER_ATTRIBUT, EVENT_ID_INDEX, EVENT_ID_LON, EVENT_ID_LAT, EVENT_ID_AREA |
---|
48 | } ; |
---|
49 | |
---|
50 | /// typedef /// |
---|
51 | typedef CObjectTemplate<CDomain> SuperClass; |
---|
52 | typedef CDomainAttributes SuperClassAttribute; |
---|
53 | |
---|
54 | public: |
---|
55 | |
---|
56 | typedef CDomainAttributes RelAttributes; |
---|
57 | typedef CDomainGroup RelGroup; |
---|
58 | typedef CTransformation<CDomain>::TransformationMapTypes TransMapTypes; |
---|
59 | |
---|
60 | /// Constructeurs /// |
---|
61 | CDomain(void); |
---|
62 | explicit CDomain(const StdString & id); |
---|
63 | CDomain(const CDomain & domain); // Not implemented yet. |
---|
64 | CDomain(const CDomain * const domain); // Not implemented yet. |
---|
65 | |
---|
66 | static CDomain* createDomain(); |
---|
67 | |
---|
68 | CMesh* mesh; |
---|
69 | void assignMesh(const StdString, const int); |
---|
70 | |
---|
71 | virtual void parse(xml::CXMLNode & node); |
---|
72 | |
---|
73 | /// Vérifications /// |
---|
74 | void checkAttributes(void); |
---|
75 | |
---|
76 | void checkAttributesOnClient(); |
---|
77 | void checkAttributesOnClientAfterTransformation(); |
---|
78 | |
---|
79 | void checkEligibilityForCompressedOutput(void); |
---|
80 | |
---|
81 | void sendCheckedAttributes(); |
---|
82 | |
---|
83 | bool hasTransformation(); |
---|
84 | void solveInheritanceTransformation(); |
---|
85 | TransMapTypes getAllTransformations(); |
---|
86 | void redistribute(int nbLocalDomain); |
---|
87 | void duplicateTransformation(CDomain*); |
---|
88 | CTransformation<CDomain>* addTransformation(ETranformationType transType, const StdString& id=""); |
---|
89 | |
---|
90 | public: |
---|
91 | const std::set<StdString> & getRelFiles(void) const; |
---|
92 | bool IsWritten(const StdString & filename) const; |
---|
93 | bool isWrittenCompressed(const StdString& filename) const; |
---|
94 | |
---|
95 | const std::vector<int>& getIndexesToWrite(void) const; |
---|
96 | int getNumberWrittenIndexes() const; |
---|
97 | int getTotalNumberWrittenIndexes() const; |
---|
98 | int getOffsetWrittenIndexes() const; |
---|
99 | |
---|
100 | std::map<int, StdSize> getAttributesBufferSize(); |
---|
101 | |
---|
102 | bool isEmpty(void) const; |
---|
103 | bool isDistributed(void) const; |
---|
104 | bool isCompressible(void) const; |
---|
105 | bool distributionAttributesHaveValue() const; |
---|
106 | |
---|
107 | int ni_srv,ibegin_srv,iend_srv ; |
---|
108 | int zoom_ni_srv,zoom_ibegin_srv,zoom_iend_srv ; |
---|
109 | |
---|
110 | int nj_srv,jbegin_srv,jend_srv ; |
---|
111 | int zoom_nj_srv,zoom_jbegin_srv,zoom_jend_srv ; |
---|
112 | |
---|
113 | CArray<double, 1> lonvalue_srv, latvalue_srv ; |
---|
114 | CArray<double, 2> bounds_lon_srv, bounds_lat_srv ; |
---|
115 | CArray<double, 1> lonvalue_client, latvalue_client; |
---|
116 | CArray<double, 2> bounds_lon_client, bounds_lat_client; |
---|
117 | CArray<double, 1> area_srv; |
---|
118 | |
---|
119 | vector<int> connectedServer ; // list of connected server |
---|
120 | vector<int> nbSenders ; // for each communication with a server, number of communicating client |
---|
121 | vector<int> nbDataSrv ; // size of data to send to each server |
---|
122 | vector< vector<int> > i_indSrv ; // for each server, i global index to send |
---|
123 | vector< vector<int> > j_indSrv ; // for each server, j global index to send |
---|
124 | |
---|
125 | std::vector<int> getNbGlob(); |
---|
126 | bool isEqual(CDomain* domain); |
---|
127 | public: |
---|
128 | /// Mutateur /// |
---|
129 | void addRelFile(const StdString & filename); |
---|
130 | void addRelFileCompressed(const StdString& filename); |
---|
131 | void completeLonLatClient(void); |
---|
132 | void sendServerAttribut(void) ; |
---|
133 | void sendLonLatArea(void); |
---|
134 | void computeConnectedServer(void) ; |
---|
135 | void computeLocalMask(void) ; |
---|
136 | |
---|
137 | void AllgatherRectilinearLonLat(CArray<double,1>& lon, CArray<double,1>& lat, |
---|
138 | CArray<double,1>& lon_g, CArray<double,1>& lat_g); |
---|
139 | |
---|
140 | void fillInRectilinearBoundLonLat(CArray<double,1>& lon, CArray<double,1>& lat, |
---|
141 | CArray<double,2>& boundsLon, CArray<double,2>& boundsLat); |
---|
142 | |
---|
143 | void fillInLonLat(); |
---|
144 | |
---|
145 | static bool dispatchEvent(CEventServer& event); |
---|
146 | static void recvServerAttribut(CEventServer& event); |
---|
147 | static void recvIndex(CEventServer& event); |
---|
148 | static void recvLon(CEventServer& event); |
---|
149 | static void recvLat(CEventServer& event); |
---|
150 | static void recvArea(CEventServer& event); |
---|
151 | void recvServerAttribut(CBufferIn& buffer); |
---|
152 | void recvIndex(int rank, CBufferIn& buffer); |
---|
153 | void recvLon(int rank, CBufferIn& buffer); |
---|
154 | void recvLat(int rank, CBufferIn& buffer); |
---|
155 | void recvArea(int rank, CBufferIn& buffer); |
---|
156 | |
---|
157 | /// Destructeur /// |
---|
158 | virtual ~CDomain(void); |
---|
159 | |
---|
160 | /// Accesseurs statiques /// |
---|
161 | static StdString GetName(void); |
---|
162 | static StdString GetDefName(void); |
---|
163 | |
---|
164 | static ENodeType GetType(void); |
---|
165 | const std::map<int, vector<size_t> >& getIndexServer() const; |
---|
166 | CArray<bool, 1> localMask; |
---|
167 | bool isCurvilinear ; |
---|
168 | bool hasBounds ; |
---|
169 | bool hasArea; |
---|
170 | bool hasLonLat; |
---|
171 | bool hasPole ; |
---|
172 | |
---|
173 | private: |
---|
174 | void checkDomain(void); |
---|
175 | void checkLocalIDomain(void); |
---|
176 | void checkLocalJDomain(void); |
---|
177 | |
---|
178 | void checkMask(void); |
---|
179 | void checkDomainData(void); |
---|
180 | void checkCompression(void); |
---|
181 | |
---|
182 | void checkBounds(void); |
---|
183 | void checkArea(void); |
---|
184 | void checkLonLat(); |
---|
185 | void checkZoom(void); |
---|
186 | |
---|
187 | void setTransformations(const TransMapTypes&); |
---|
188 | void computeNGlobDomain(); |
---|
189 | |
---|
190 | void sendIndex(); |
---|
191 | void sendArea(); |
---|
192 | void sendLonLat(); |
---|
193 | |
---|
194 | void fillInRectilinearLonLat(); |
---|
195 | void fillInCurvilinearLonLat(); |
---|
196 | void fillInUnstructuredLonLat(); |
---|
197 | private: |
---|
198 | bool isChecked; |
---|
199 | std::set<StdString> relFiles, relFilesCompressed; |
---|
200 | bool isClientChecked; // Verify whether all attributes of domain on the client side are good |
---|
201 | bool isClientAfterTransformationChecked; |
---|
202 | std::map<int, CArray<int,1> > indiSrv, indjSrv; |
---|
203 | std::map<int,int> nbConnectedClients_; // Mapping of number of communicating client to a server |
---|
204 | std::map<int, vector<size_t> > indSrv_; // Global index of each client sent to server |
---|
205 | std::map<int, vector<int> > indWrittenSrv_; // Global written index of each client sent to server |
---|
206 | std::vector<int> indexesToWrite; |
---|
207 | int numberWrittenIndexes_, totalNumberWrittenIndexes_, offsetWrittenIndexes_; |
---|
208 | std::vector<int> connectedServerRank_; |
---|
209 | bool isDistributed_; |
---|
210 | //! True if and only if the data defined on the domain can be outputted in a compressed way |
---|
211 | bool isCompressible_; |
---|
212 | bool isRedistributed_; |
---|
213 | TransMapTypes transformationMap_; |
---|
214 | bool isUnstructed_; |
---|
215 | |
---|
216 | private: |
---|
217 | static bool initializeTransformationMap(std::map<StdString, ETranformationType>& m); |
---|
218 | static std::map<StdString, ETranformationType> transformationMapList_; |
---|
219 | static bool _dummyTransformationMapList; |
---|
220 | |
---|
221 | DECLARE_REF_FUNC(Domain,domain) |
---|
222 | |
---|
223 | }; // class CDomain |
---|
224 | |
---|
225 | ///-------------------------------------------------------------- |
---|
226 | |
---|
227 | // Declare/Define CDomainGroup and CDomainDefinition |
---|
228 | DECLARE_GROUP(CDomain); |
---|
229 | |
---|
230 | ///-------------------------------------------------------------- |
---|
231 | |
---|
232 | } // namespace xios |
---|
233 | |
---|
234 | #endif //__XIOS_CDomain__ |
---|