1 | #ifndef __XMLIO_CGrid__ |
---|
2 | #define __XMLIO_CGrid__ |
---|
3 | |
---|
4 | /// xios headers /// |
---|
5 | #include "xmlioserver_spl.hpp" |
---|
6 | #include "group_factory.hpp" |
---|
7 | |
---|
8 | #include "declare_group.hpp" |
---|
9 | #include "domain.hpp" |
---|
10 | #include "axis.hpp" |
---|
11 | #include "array_new.hpp" |
---|
12 | #include "attribute_array.hpp" |
---|
13 | |
---|
14 | namespace xios { |
---|
15 | |
---|
16 | /// ////////////////////// Déclarations ////////////////////// /// |
---|
17 | |
---|
18 | class CGridGroup; |
---|
19 | class CGridAttributes; |
---|
20 | class CDomainGroup; |
---|
21 | class CAxisGroup; |
---|
22 | class CGrid; |
---|
23 | |
---|
24 | ///-------------------------------------------------------------- |
---|
25 | |
---|
26 | // Declare/Define CGridAttribute |
---|
27 | BEGIN_DECLARE_ATTRIBUTE_MAP(CGrid) |
---|
28 | # include "grid_attribute.conf" |
---|
29 | END_DECLARE_ATTRIBUTE_MAP(CGrid) |
---|
30 | |
---|
31 | ///-------------------------------------------------------------- |
---|
32 | |
---|
33 | class CGrid |
---|
34 | : public CObjectTemplate<CGrid> |
---|
35 | , public CGridAttributes |
---|
36 | { |
---|
37 | /// typedef /// |
---|
38 | typedef CObjectTemplate<CGrid> SuperClass; |
---|
39 | typedef CGridAttributes SuperClassAttribute; |
---|
40 | |
---|
41 | public : |
---|
42 | |
---|
43 | typedef CGridAttributes RelAttributes; |
---|
44 | typedef CGridGroup RelGroup; |
---|
45 | |
---|
46 | enum EEventId |
---|
47 | { |
---|
48 | EVENT_ID_INDEX, EVENT_ID_ADD_DOMAIN, EVENT_ID_ADD_AXIS |
---|
49 | } ; |
---|
50 | |
---|
51 | /// Constructeurs /// |
---|
52 | CGrid(void); |
---|
53 | explicit CGrid(const StdString & id); |
---|
54 | CGrid(const CGrid & grid); // Not implemented yet. |
---|
55 | CGrid(const CGrid * const grid); // Not implemented yet. |
---|
56 | |
---|
57 | /// Traitements /// |
---|
58 | // void solveReference(void); |
---|
59 | |
---|
60 | void solveDomainAxisRef(bool areAttributesChecked); |
---|
61 | |
---|
62 | void checkMaskIndex(bool doCalculateIndex); |
---|
63 | |
---|
64 | // virtual void toBinary (StdOStream & os) const; |
---|
65 | // virtual void fromBinary(StdIStream & is); |
---|
66 | |
---|
67 | /// Tests /// |
---|
68 | bool hasAxis(void) const; |
---|
69 | |
---|
70 | public : |
---|
71 | |
---|
72 | /// Accesseurs /// |
---|
73 | const std::deque< CArray<int, 1>* > & getStoreIndex(void) const; |
---|
74 | const std::deque< CArray<int, 1>* > & getOutIIndex(void) const; |
---|
75 | const std::deque< CArray<int, 1>* > & getOutJIndex(void) const; |
---|
76 | const std::deque< CArray<int, 1>* > & getOutLIndex(void) const; |
---|
77 | |
---|
78 | const CAxis* getRelAxis (void) const; |
---|
79 | const CDomain* getRelDomain(void) const; |
---|
80 | |
---|
81 | StdSize getDimension(void) const; |
---|
82 | |
---|
83 | // StdSize getLocalSize(void) const; |
---|
84 | // StdSize getGlobalSize(void) const; |
---|
85 | StdSize getDataSize(void) const; |
---|
86 | // std::vector<StdSize> getLocalShape(void) const; |
---|
87 | // std::vector<StdSize> getGlobalShape(void) const; |
---|
88 | |
---|
89 | /// Entrées-sorties de champs /// |
---|
90 | template <int n> |
---|
91 | void inputField(const CArray<double,n>& field, CArray<double,1>& stored) const; |
---|
92 | |
---|
93 | void inputFieldServer(const std::deque< CArray<double, 1>* > storedClient, |
---|
94 | CArray<double, 1>& storedServer) const; |
---|
95 | |
---|
96 | void outputField(int rank, const CArray<double,1>& stored, CArray<double,3>& field) ; |
---|
97 | void outputField(int rank, const CArray<double,1>& stored, CArray<double,2>& field) ; |
---|
98 | void outputField(int rank, const CArray<double,1>& stored, CArray<double,1>& field) ; |
---|
99 | |
---|
100 | virtual void parse(xml::CXMLNode & node); |
---|
101 | |
---|
102 | /// Destructeur /// |
---|
103 | virtual ~CGrid(void); |
---|
104 | |
---|
105 | public : |
---|
106 | |
---|
107 | /// Accesseurs statiques /// |
---|
108 | static StdString GetName(void); |
---|
109 | static StdString GetDefName(void); |
---|
110 | |
---|
111 | static ENodeType GetType(void); |
---|
112 | |
---|
113 | /// Instanciateurs Statiques /// |
---|
114 | static CGrid* createGrid(CDomain* domain); |
---|
115 | static CGrid* createGrid(CDomain* domain, CAxis* axis); |
---|
116 | static CGrid* createGrid(std::vector<CDomain*> domains, std::vector<CAxis*> axis); |
---|
117 | |
---|
118 | public : |
---|
119 | |
---|
120 | /// Entrées-sorties de champs (interne) /// |
---|
121 | void storeField_arr(const double * const data, CArray<double,1>& stored) const; |
---|
122 | |
---|
123 | /// Traitements protégés /// |
---|
124 | void computeIndexServer(void); |
---|
125 | void computeIndex(void); |
---|
126 | // void solveDomainRef(void); //TODO temporarily comment |
---|
127 | // void solveAxisRef(void); // TODO: temporarily comment |
---|
128 | |
---|
129 | void solveDomainRef(bool checkAtt); |
---|
130 | void solveAxisRef(bool checkAtt); |
---|
131 | void solveDomainAxisRefInheritance(bool apply = true); |
---|
132 | |
---|
133 | void sendAddDomain(const std::string& id=""); |
---|
134 | void sendAddAxis(const std::string& id=""); |
---|
135 | void sendAllDomains(); |
---|
136 | void sendAllAxis(); |
---|
137 | |
---|
138 | static void recvAddDomain(CEventServer& event) ; |
---|
139 | void recvAddDomain(CBufferIn& buffer) ; |
---|
140 | static void recvAddAxis(CEventServer& event) ; |
---|
141 | void recvAddAxis(CBufferIn& buffer) ; |
---|
142 | |
---|
143 | static bool dispatchEvent(CEventServer& event) ; |
---|
144 | void outputFieldToServer(CArray<double,1>& fieldIn, int rank, CArray<double,1>& fieldOut) ; |
---|
145 | static void recvIndex(CEventServer& event) ; |
---|
146 | void recvIndex(int rank, CBufferIn& buffer) ; |
---|
147 | void sendIndex(void) ; |
---|
148 | |
---|
149 | void computeDomConServer(); |
---|
150 | std::map<int, int> getDomConServerSide(); |
---|
151 | std::map<int, StdSize> getConnectedServerDataSize(); |
---|
152 | std::vector<StdString> getDomainList(); |
---|
153 | std::vector<StdString> getAxisList(); |
---|
154 | std::vector<CDomain*> getDomains(); |
---|
155 | std::vector<CAxis*> getAxis(); |
---|
156 | |
---|
157 | public: |
---|
158 | |
---|
159 | /// Propriétés privées /// |
---|
160 | bool withAxis ; |
---|
161 | bool isChecked; |
---|
162 | bool isDomainAxisChecked; |
---|
163 | |
---|
164 | CAxis* axis ; |
---|
165 | CDomain* domain ; |
---|
166 | |
---|
167 | std::deque< CArray<int, 1>* > storeIndex ; |
---|
168 | std::deque< CArray<int, 1>* > out_i_index ; |
---|
169 | std::deque< CArray<int, 1>* > out_j_index ; |
---|
170 | std::deque< CArray<int, 1>* > out_l_index ; |
---|
171 | |
---|
172 | CArray<int, 1> storeIndex_client ; |
---|
173 | CArray<int, 1> out_i_client ; |
---|
174 | CArray<int, 1> out_j_client ; |
---|
175 | CArray<int, 1> out_l_client ; |
---|
176 | |
---|
177 | map<int, CArray<int, 1>* > storeIndex_toSrv ; |
---|
178 | map<int,int> nbSenders ; |
---|
179 | // std::deque<ARRAY(int, 1)> out_i_toSrv ; |
---|
180 | // std::deque<ARRAY(int, 1)> out_j_toSrv ; |
---|
181 | // std::deque<ARRAY(int, 1)> out_l_toSrv ; |
---|
182 | |
---|
183 | map<int, CArray<int, 1>* > out_i_fromClient ; |
---|
184 | map<int, CArray<int, 1>* > out_j_fromClient ; |
---|
185 | map<int, CArray<int, 1>* > out_l_fromClient ; |
---|
186 | void checkMask(void) ; |
---|
187 | |
---|
188 | std::map<int, int> domConnectedServerSide_; |
---|
189 | bool isDomConServerComputed_; |
---|
190 | |
---|
191 | private: |
---|
192 | void setVirtualDomainGroup(CDomainGroup* newVDomainGroup); |
---|
193 | void setVirtualDomainGroup(); |
---|
194 | void setVirtualAxisGroup(CAxisGroup* newVAxisGroup); |
---|
195 | void setVirtualAxisGroup(); |
---|
196 | // void setAxisList(); |
---|
197 | void setAxisList(const std::vector<CAxis*> axis = std::vector<CAxis*>()); |
---|
198 | // void setDomainList(); |
---|
199 | void setDomainList(const std::vector<CDomain*> domains = std::vector<CDomain*>()); |
---|
200 | |
---|
201 | CDomain* addDomain(const std::string& id); |
---|
202 | CAxis* addAxis(const std::string& id); |
---|
203 | |
---|
204 | CAxisGroup* getVirtualAxisGroup() const; |
---|
205 | CDomainGroup* getVirtualDomainGroup() const; |
---|
206 | private: |
---|
207 | CDomainGroup* vDomainGroup_; |
---|
208 | CAxisGroup* vAxisGroup_; |
---|
209 | std::vector<std::string> axisList_, domList_; |
---|
210 | bool isAxisListSet, isDomListSet; |
---|
211 | |
---|
212 | // List order of axis in a grid, if there is a domain, it will take value -1 |
---|
213 | std::vector<int> axisOrder_; |
---|
214 | }; // class CGrid |
---|
215 | |
---|
216 | ///-------------------------------------------------------------- |
---|
217 | |
---|
218 | template <int n> |
---|
219 | void CGrid::inputField(const CArray<double,n>& field, CArray<double,1>& stored) const |
---|
220 | { |
---|
221 | if (this->getDataSize() != field.numElements()) |
---|
222 | ERROR("void CGrid::inputField(const CArray<double,n>& field, CArray<double,1>& stored) const", |
---|
223 | << "[ Awaiting size of the data = " << this->getDataSize() << ", " |
---|
224 | << "Received data size = " << field.numElements() << " ] " |
---|
225 | << "The array of data has not the good size !") |
---|
226 | this->storeField_arr(field.dataFirst(), stored) ; |
---|
227 | } |
---|
228 | |
---|
229 | ///-------------------------------------------------------------- |
---|
230 | |
---|
231 | // Declare/Define CGridGroup and CGridDefinition |
---|
232 | DECLARE_GROUP(CGrid); |
---|
233 | |
---|
234 | ///-------------------------------------------------------------- |
---|
235 | |
---|
236 | } // namespace xios |
---|
237 | |
---|
238 | #endif // __XMLIO_CGrid__ |
---|