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 | namespace xios { |
---|
20 | |
---|
21 | /// ////////////////////// Déclarations ////////////////////// /// |
---|
22 | |
---|
23 | class CDomainGroup; |
---|
24 | class CDomainAttributes; |
---|
25 | class CDomain; |
---|
26 | |
---|
27 | ///-------------------------------------------------------------- |
---|
28 | |
---|
29 | // Declare/Define CDomainAttribute |
---|
30 | BEGIN_DECLARE_ATTRIBUTE_MAP(CDomain) |
---|
31 | # include "domain_attribute.conf" |
---|
32 | END_DECLARE_ATTRIBUTE_MAP(CDomain) |
---|
33 | |
---|
34 | ///-------------------------------------------------------------- |
---|
35 | |
---|
36 | class CDomain |
---|
37 | : public CObjectTemplate<CDomain> |
---|
38 | , public CDomainAttributes |
---|
39 | { |
---|
40 | enum EEventId |
---|
41 | { |
---|
42 | EVENT_ID_SERVER_ATTRIBUT, EVENT_ID_INDEX, EVENT_ID_LON, EVENT_ID_LAT, EVENT_ID_AREA |
---|
43 | } ; |
---|
44 | |
---|
45 | /// typedef /// |
---|
46 | typedef CObjectTemplate<CDomain> SuperClass; |
---|
47 | typedef CDomainAttributes SuperClassAttribute; |
---|
48 | |
---|
49 | public : |
---|
50 | |
---|
51 | typedef CDomainAttributes RelAttributes; |
---|
52 | typedef CDomainGroup RelGroup; |
---|
53 | typedef CTransformation<CDomain>::TransformationMapTypes TransMapTypes; |
---|
54 | |
---|
55 | /// Constructeurs /// |
---|
56 | CDomain(void); |
---|
57 | explicit CDomain(const StdString & id); |
---|
58 | CDomain(const CDomain & domain); // Not implemented yet. |
---|
59 | CDomain(const CDomain * const domain); // Not implemented yet. |
---|
60 | |
---|
61 | static CDomain* createDomain(); |
---|
62 | void duplicateAttributes(CDomain* domain); |
---|
63 | |
---|
64 | virtual void parse(xml::CXMLNode & node); |
---|
65 | |
---|
66 | /// Vérifications /// |
---|
67 | void checkAttributes(void); |
---|
68 | |
---|
69 | void checkAttributesOnClient(); |
---|
70 | void checkAttributesOnClientAfterTransformation(); |
---|
71 | |
---|
72 | void sendCheckedAttributes(); |
---|
73 | |
---|
74 | bool hasTransformation(); |
---|
75 | void solveInheritanceTransformation(); |
---|
76 | TransMapTypes getAllTransformations(); |
---|
77 | |
---|
78 | private : |
---|
79 | void checkDomain(void); |
---|
80 | void checkLocalIDomain(void); |
---|
81 | void checkLocalJDomain(void); |
---|
82 | |
---|
83 | void checkMask(void); |
---|
84 | void checkDomainData(void); |
---|
85 | void checkCompression(void); |
---|
86 | |
---|
87 | void checkBounds(void); |
---|
88 | void checkArea(void); |
---|
89 | void checkLonLat(); |
---|
90 | |
---|
91 | public : |
---|
92 | |
---|
93 | /// Autres /// |
---|
94 | |
---|
95 | const std::set<StdString> & getRelFiles(void) const; |
---|
96 | |
---|
97 | |
---|
98 | /// Test /// |
---|
99 | bool IsWritten(const StdString & filename) const; |
---|
100 | // bool hasZoom(void) const; |
---|
101 | bool isEmpty(void) const; |
---|
102 | bool isDistributed(void) const; |
---|
103 | |
---|
104 | |
---|
105 | // int ni_client,ibegin_client,iend_client ; |
---|
106 | // int zoom_ni_client,zoom_ibegin_client,zoom_iend_client ; |
---|
107 | // |
---|
108 | // int nj_client,jbegin_client,jend_client ; |
---|
109 | // int zoom_nj_client,zoom_jbegin_client,zoom_jend_client ; |
---|
110 | |
---|
111 | int ni_srv,ibegin_srv,iend_srv ; |
---|
112 | int zoom_ni_srv,zoom_ibegin_srv,zoom_iend_srv ; |
---|
113 | |
---|
114 | int nj_srv,jbegin_srv,jend_srv ; |
---|
115 | int zoom_nj_srv,zoom_jbegin_srv,zoom_jend_srv ; |
---|
116 | |
---|
117 | CArray<double, 1> lonvalue_srv, latvalue_srv ; |
---|
118 | CArray<double, 2> bounds_lon_srv, bounds_lat_srv ; |
---|
119 | CArray<double, 1> lonvalue_client, latvalue_client; |
---|
120 | CArray<double, 2> bounds_lon_client, bounds_lat_client; |
---|
121 | CArray<double, 1> area_srv; |
---|
122 | |
---|
123 | |
---|
124 | vector<int> connectedServer ; // list of connected server |
---|
125 | vector<int> nbSenders ; // for each communication with a server, number of communicating client |
---|
126 | vector<int> nbDataSrv ; // size of data to send to each server |
---|
127 | vector< vector<int> > i_indSrv ; // for each server, i global index to send |
---|
128 | vector< vector<int> > j_indSrv ; // for each server, j global index to send |
---|
129 | |
---|
130 | |
---|
131 | // CArray<int,2> mapConnectedServer ; // (ni,nj) => mapped to connected server number, -1 if no server is target |
---|
132 | |
---|
133 | int global_zoom_ibegin, global_zoom_ni; |
---|
134 | int global_zoom_jbegin, global_zoom_nj; |
---|
135 | |
---|
136 | public : |
---|
137 | /// Mutateur /// |
---|
138 | void addRelFile(const StdString & filename); |
---|
139 | void completeLonLatClient(void); |
---|
140 | void sendServerAttribut(void) ; |
---|
141 | void sendLonLatArea(void); |
---|
142 | void computeConnectedServer(void) ; |
---|
143 | |
---|
144 | static bool dispatchEvent(CEventServer& event); |
---|
145 | static void recvServerAttribut(CEventServer& event); |
---|
146 | static void recvIndex(CEventServer& event); |
---|
147 | static void recvLon(CEventServer& event); |
---|
148 | static void recvLat(CEventServer& event); |
---|
149 | static void recvArea(CEventServer& event); |
---|
150 | void recvServerAttribut(CBufferIn& buffer); |
---|
151 | void recvIndex(int rank, CBufferIn& buffer); |
---|
152 | void recvLon(int rank, CBufferIn& buffer); |
---|
153 | void recvLat(int rank, CBufferIn& buffer); |
---|
154 | void recvArea(int rank, CBufferIn& buffer); |
---|
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<int, 2> local_mask; |
---|
166 | bool isCurvilinear ; |
---|
167 | bool hasBounds ; |
---|
168 | bool hasArea; |
---|
169 | bool hasLonLat; |
---|
170 | private: |
---|
171 | void checkTransformations(); |
---|
172 | void setTransformations(const TransMapTypes&); |
---|
173 | void computeNGlobDomain(); |
---|
174 | |
---|
175 | void sendIndex(); |
---|
176 | void sendArea(); |
---|
177 | void sendLonLat(); |
---|
178 | |
---|
179 | private : |
---|
180 | bool isChecked; |
---|
181 | std::set<StdString> relFiles; |
---|
182 | bool isClientChecked; // Verify whether all attributes of domain on the client side are good |
---|
183 | bool isClientAfterTransformationChecked; |
---|
184 | std::map<int, CArray<int,1> > indiSrv, indjSrv; |
---|
185 | std::map<int,int> nbConnectedClients_; // Mapping of number of communicating client to a server |
---|
186 | std::map<int, vector<size_t> > indSrv_; // Global index of each client sent to server |
---|
187 | std::vector<int> connectedServerRank_; |
---|
188 | bool isDistributed_; |
---|
189 | TransMapTypes transformationMap_; |
---|
190 | std::vector<int> nGlobDomain_; |
---|
191 | bool isUnstructed_; |
---|
192 | |
---|
193 | |
---|
194 | |
---|
195 | DECLARE_REF_FUNC(Domain,domain) |
---|
196 | |
---|
197 | }; // class CDomain |
---|
198 | |
---|
199 | ///-------------------------------------------------------------- |
---|
200 | |
---|
201 | // Declare/Define CDomainGroup and CDomainDefinition |
---|
202 | DECLARE_GROUP(CDomain); |
---|
203 | |
---|
204 | ///-------------------------------------------------------------- |
---|
205 | |
---|
206 | } // namespace xios |
---|
207 | |
---|
208 | #endif // __XIOS_CDomain__ |
---|