1 | |
---|
2 | #include "grid.hpp" |
---|
3 | |
---|
4 | #include "attribute_template_impl.hpp" |
---|
5 | #include "object_template_impl.hpp" |
---|
6 | #include "group_template_impl.hpp" |
---|
7 | |
---|
8 | namespace xmlioserver { |
---|
9 | namespace tree { |
---|
10 | |
---|
11 | /// ////////////////////// Définitions ////////////////////// /// |
---|
12 | |
---|
13 | CGrid::CGrid(void) |
---|
14 | : CObjectTemplate<CGrid>(), CGridAttributes() |
---|
15 | , withAxis(false), isChecked(false), axis(), domain() |
---|
16 | , storeIndex(1), out_i_index(1), out_j_index(1), out_l_index(1) |
---|
17 | { /* Ne rien faire de plus */ } |
---|
18 | |
---|
19 | CGrid::CGrid(const StdString & id) |
---|
20 | : CObjectTemplate<CGrid>(id), CGridAttributes() |
---|
21 | , withAxis(false), isChecked(false), axis(), domain() |
---|
22 | , storeIndex(1), out_i_index(1), out_j_index(1), out_l_index(1) |
---|
23 | { /* Ne rien faire de plus */ } |
---|
24 | |
---|
25 | CGrid::~CGrid(void) |
---|
26 | { |
---|
27 | this->axis.reset() ; |
---|
28 | this->domain.reset() ; |
---|
29 | |
---|
30 | for (StdSize i = 0; i < this->storeIndex.size(); i++) |
---|
31 | { |
---|
32 | this->storeIndex[i].reset(); |
---|
33 | this->out_i_index[i].reset(); |
---|
34 | this->out_j_index[i].reset(); |
---|
35 | this->out_l_index[i].reset(); |
---|
36 | } |
---|
37 | } |
---|
38 | |
---|
39 | ///--------------------------------------------------------------- |
---|
40 | |
---|
41 | StdString CGrid::GetName(void) { return (StdString("grid")); } |
---|
42 | StdString CGrid::GetDefName(void) { return (CGrid::GetName()); } |
---|
43 | ENodeType CGrid::GetType(void) { return (eGrid); } |
---|
44 | |
---|
45 | //---------------------------------------------------------------- |
---|
46 | |
---|
47 | const std::deque<ARRAY(int, 1)> & CGrid::getStoreIndex(void) const |
---|
48 | { |
---|
49 | return (this->storeIndex ); |
---|
50 | } |
---|
51 | |
---|
52 | //--------------------------------------------------------------- |
---|
53 | |
---|
54 | const std::deque<ARRAY(int, 1)> & CGrid::getOutIIndex(void) const |
---|
55 | { |
---|
56 | return (this->out_i_index ); |
---|
57 | } |
---|
58 | |
---|
59 | //--------------------------------------------------------------- |
---|
60 | |
---|
61 | const std::deque<ARRAY(int, 1)> & CGrid::getOutJIndex(void) const |
---|
62 | { |
---|
63 | return (this->out_j_index ); |
---|
64 | } |
---|
65 | |
---|
66 | //--------------------------------------------------------------- |
---|
67 | |
---|
68 | const std::deque<ARRAY(int, 1)> & CGrid::getOutLIndex(void) const |
---|
69 | { |
---|
70 | return (this->out_l_index ); |
---|
71 | } |
---|
72 | |
---|
73 | //--------------------------------------------------------------- |
---|
74 | |
---|
75 | const boost::shared_ptr<CAxis> CGrid::getRelAxis (void) const |
---|
76 | { |
---|
77 | return (this->axis ); |
---|
78 | } |
---|
79 | |
---|
80 | //--------------------------------------------------------------- |
---|
81 | |
---|
82 | const boost::shared_ptr<CDomain> CGrid::getRelDomain(void) const |
---|
83 | { |
---|
84 | return (this->domain ); |
---|
85 | } |
---|
86 | |
---|
87 | //--------------------------------------------------------------- |
---|
88 | |
---|
89 | bool CGrid::hasAxis(void) const |
---|
90 | { |
---|
91 | return (this->withAxis); |
---|
92 | } |
---|
93 | |
---|
94 | //--------------------------------------------------------------- |
---|
95 | |
---|
96 | StdSize CGrid::getDimension(void) const |
---|
97 | { |
---|
98 | return ((this->withAxis)?3:2); |
---|
99 | } |
---|
100 | |
---|
101 | //--------------------------------------------------------------- |
---|
102 | |
---|
103 | std::vector<StdSize> CGrid::getLocalShape(void) const |
---|
104 | { |
---|
105 | std::vector<StdSize> retvalue; |
---|
106 | retvalue.push_back(domain->zoom_ni_loc.getValue()); |
---|
107 | retvalue.push_back(domain->zoom_nj_loc.getValue()); |
---|
108 | if (this->withAxis) |
---|
109 | retvalue.push_back(this->axis->size.getValue()); |
---|
110 | return (retvalue); |
---|
111 | } |
---|
112 | //--------------------------------------------------------------- |
---|
113 | |
---|
114 | StdSize CGrid::getLocalSize(void) const |
---|
115 | { |
---|
116 | StdSize retvalue = 1; |
---|
117 | std::vector<StdSize> shape_ = this->getLocalShape(); |
---|
118 | for (StdSize s = 0; s < shape_.size(); s++) |
---|
119 | retvalue *= shape_[s]; |
---|
120 | return (retvalue); |
---|
121 | } |
---|
122 | |
---|
123 | //--------------------------------------------------------------- |
---|
124 | |
---|
125 | std::vector<StdSize> CGrid::getGlobalShape(void) const |
---|
126 | { |
---|
127 | std::vector<StdSize> retvalue; |
---|
128 | retvalue.push_back(domain->ni.getValue()); |
---|
129 | retvalue.push_back(domain->nj.getValue()); |
---|
130 | if (this->withAxis) |
---|
131 | retvalue.push_back(this->axis->size.getValue()); |
---|
132 | return (retvalue); |
---|
133 | } |
---|
134 | //--------------------------------------------------------------- |
---|
135 | |
---|
136 | StdSize CGrid::getGlobalSize(void) const |
---|
137 | { |
---|
138 | StdSize retvalue = 1; |
---|
139 | std::vector<StdSize> shape_ = this->getGlobalShape(); |
---|
140 | for (StdSize s = 0; s < shape_.size(); s++) |
---|
141 | retvalue *= shape_[s]; |
---|
142 | return (retvalue); |
---|
143 | } |
---|
144 | |
---|
145 | //--------------------------------------------------------------- |
---|
146 | |
---|
147 | void CGrid::solveReference(void) |
---|
148 | { |
---|
149 | if (this->isChecked) return; |
---|
150 | this->solveDomainRef() ; |
---|
151 | this->solveAxisRef() ; |
---|
152 | if (this->storeIndex.size() == 1) |
---|
153 | { |
---|
154 | |
---|
155 | this->computeIndex() ; |
---|
156 | ARRAY_CREATE(storeIndex_ , int, 1, [0]); |
---|
157 | ARRAY_CREATE(out_l_index_, int, 1, [0]); |
---|
158 | ARRAY_CREATE(out_i_index_, int, 1, [0]); |
---|
159 | ARRAY_CREATE(out_j_index_, int, 1, [0]); |
---|
160 | |
---|
161 | this->storeIndex .push_front(storeIndex_); |
---|
162 | this->out_i_index.push_front(out_i_index_); |
---|
163 | this->out_j_index.push_front(out_j_index_); |
---|
164 | this->out_l_index.push_front(out_l_index_); |
---|
165 | } |
---|
166 | this->computeIndexServer(); |
---|
167 | this->isChecked = true; |
---|
168 | } |
---|
169 | |
---|
170 | //--------------------------------------------------------------- |
---|
171 | |
---|
172 | void CGrid::solveDomainRef(void) |
---|
173 | { |
---|
174 | if (!domain_ref.isEmpty()) |
---|
175 | { |
---|
176 | if (CObjectFactory::HasObject<CDomain>(domain_ref.getValue())) |
---|
177 | { |
---|
178 | this->domain = CObjectFactory::GetObject<CDomain>(domain_ref.getValue()) ; |
---|
179 | domain->checkAttributes() ; |
---|
180 | } |
---|
181 | else ERROR("CGrid::solveDomainRef(void)", |
---|
182 | << "Référence au domaine incorrecte") ; |
---|
183 | } |
---|
184 | else ERROR("CGrid::solveDomainRef(void)", |
---|
185 | << "Domaine non défini") ; |
---|
186 | } |
---|
187 | |
---|
188 | //--------------------------------------------------------------- |
---|
189 | |
---|
190 | void CGrid::solveAxisRef(void) |
---|
191 | { |
---|
192 | if (!axis_ref.isEmpty()) |
---|
193 | { |
---|
194 | this->withAxis = true ; |
---|
195 | if (CObjectFactory::GetObject<CAxis>(axis_ref.getValue())) |
---|
196 | { |
---|
197 | this->axis = CObjectFactory::GetObject<CAxis>(axis_ref.getValue()) ; |
---|
198 | axis->checkAttributes() ; |
---|
199 | } |
---|
200 | else ERROR("CGrid::solveAxisRef(void)", |
---|
201 | << "Référence a l'axe incorrecte") ; |
---|
202 | } |
---|
203 | else withAxis = false ; |
---|
204 | } |
---|
205 | |
---|
206 | //--------------------------------------------------------------- |
---|
207 | |
---|
208 | void CGrid::computeIndex(void) |
---|
209 | { |
---|
210 | |
---|
211 | const int ni = domain->ni.getValue() , |
---|
212 | nj = domain->nj.getValue() , |
---|
213 | size = (this->hasAxis()) ? axis->size.getValue() : 1 ; |
---|
214 | |
---|
215 | /*std::cout << ni << " : " |
---|
216 | << nj << " : " |
---|
217 | << size << std::endl;*/ |
---|
218 | |
---|
219 | const int data_dim = domain->data_dim.getValue() , |
---|
220 | data_n_index = domain->data_n_index.getValue() , |
---|
221 | data_ibegin = domain->data_ibegin.getValue() , |
---|
222 | data_jbegin = (data_dim == 2) |
---|
223 | ? domain->data_jbegin.getValue() : -1; |
---|
224 | |
---|
225 | ARRAY(int, 1) data_i_index = domain->data_i_index.getValue() , |
---|
226 | data_j_index = domain->data_j_index.getValue() ; |
---|
227 | |
---|
228 | /*std::cout << data_n_index << " : " |
---|
229 | << data_i_index << " : " |
---|
230 | << data_j_index << std::endl; */ |
---|
231 | |
---|
232 | ARRAY(bool, 2) mask = domain->mask.getValue() ; |
---|
233 | ARRAY(int, 2) local_mask = this->domain->getLocalMask(); |
---|
234 | |
---|
235 | int indexCount = 0; |
---|
236 | |
---|
237 | for(int l = 0; l < size ; l++) |
---|
238 | { |
---|
239 | for(int n = 0, i = 0, j = 0; n < data_n_index; n++) |
---|
240 | { |
---|
241 | int temp_i = (*data_i_index)[n] + data_ibegin, |
---|
242 | temp_j = (data_dim == 1) ? -1 |
---|
243 | : (*data_j_index)[n] + data_jbegin; |
---|
244 | i = (data_dim == 1) ? (temp_i - 1) % ni |
---|
245 | : (temp_i - 1) ; |
---|
246 | j = (data_dim == 1) ? (temp_i - 1) / ni |
---|
247 | : (temp_j - 1) ; |
---|
248 | |
---|
249 | if ((i >= 0 && i < ni) && |
---|
250 | (j >= 0 && j < nj) && (*mask)[i][j]) |
---|
251 | indexCount++ ; |
---|
252 | } |
---|
253 | } |
---|
254 | |
---|
255 | //std::cout << indexCount << std::endl; |
---|
256 | ARRAY_ASSIGN(this->storeIndex[0] , int, 1, [indexCount]); |
---|
257 | ARRAY_ASSIGN(this->out_l_index[0], int, 1, [indexCount]); |
---|
258 | ARRAY_ASSIGN(this->out_i_index[0], int, 1, [indexCount]); |
---|
259 | ARRAY_ASSIGN(this->out_j_index[0], int, 1, [indexCount]); |
---|
260 | |
---|
261 | // for(int count = 0, indexCount = 0, l = 0; l < size; l++) |
---|
262 | // for(int n = 0, i = 0, j = 0; n < data_n_index; n++, count++) |
---|
263 | |
---|
264 | //for(int n = 0, i = 0, j = 0, count = 0, indexCount = 0; n < data_n_index; n++) |
---|
265 | //for(int l = 0; l < size; l++, count++) |
---|
266 | |
---|
267 | for(int count = 0, indexCount = 0, l = 0; l < size; l++) |
---|
268 | { |
---|
269 | for(int n = 0, i = 0, j = 0; n < data_n_index; n++, count++) |
---|
270 | { |
---|
271 | int temp_i = (*data_i_index)[n] + data_ibegin, |
---|
272 | temp_j = (data_dim == 1) ? -1 |
---|
273 | : (*data_j_index)[n] + data_jbegin; |
---|
274 | i = (data_dim == 1) ? (temp_i - 1) % ni |
---|
275 | : (temp_i - 1) ; |
---|
276 | j = (data_dim == 1) ? (temp_i - 1) / ni |
---|
277 | : (temp_j - 1) ; |
---|
278 | |
---|
279 | if ((i >= 0 && i < ni) && |
---|
280 | (j >= 0 && j < nj) && (*mask)[i][j]) |
---|
281 | { |
---|
282 | (*this->storeIndex[0]) [indexCount] = count ; |
---|
283 | (*this->out_l_index[0])[indexCount] = l ; |
---|
284 | (*this->out_i_index[0])[indexCount] = i ; |
---|
285 | (*this->out_j_index[0])[indexCount] = j ; |
---|
286 | indexCount++ ; |
---|
287 | } |
---|
288 | } |
---|
289 | } |
---|
290 | |
---|
291 | |
---|
292 | // if (this->storeIndex[0]->size() != 0) |
---|
293 | // for (StdSize u = 0; u < this->storeIndex[0]->size(); u++) |
---|
294 | // (*local_mask)[(*out_i_index[0])[u]][(*out_j_index[0])[u]] = 1; |
---|
295 | |
---|
296 | // std::cout << "indexCount" << indexCount << std::endl; |
---|
297 | // std::cout << this->getId() << " : " << (*this->storeIndex[0]).num_elements() << std::endl; |
---|
298 | // StdOFStream ofs2(("log_client_"+this->getId()).c_str()); |
---|
299 | // for (StdSize h = 0; h < storeIndex[0]->size(); h++) |
---|
300 | // { |
---|
301 | // ofs2 << "(" << (*storeIndex[0])[h] << ";" |
---|
302 | // << (*out_i_index[0])[h] << "," |
---|
303 | // << (*out_j_index[0])[h] << "," |
---|
304 | // << (*out_l_index[0])[h] << ")" << std::endl; |
---|
305 | // } |
---|
306 | // ofs2.close(); |
---|
307 | } |
---|
308 | |
---|
309 | //---------------------------------------------------------------- |
---|
310 | |
---|
311 | boost::shared_ptr<CGrid> |
---|
312 | CGrid::CreateGrid(boost::shared_ptr<CDomain> domain) |
---|
313 | { |
---|
314 | StdString new_id = StdString("__") + domain->getId() + StdString("__") ; |
---|
315 | boost::shared_ptr<CGrid> grid = |
---|
316 | CGroupFactory::CreateChild(CObjectFactory::GetObject<CGridGroup> ("grid_definition"), new_id); |
---|
317 | grid->domain_ref.setValue(domain->getId()); |
---|
318 | return (grid); |
---|
319 | } |
---|
320 | |
---|
321 | boost::shared_ptr<CGrid> |
---|
322 | CGrid::CreateGrid(boost::shared_ptr<CDomain> domain, boost::shared_ptr<CAxis> axis) |
---|
323 | { |
---|
324 | StdString new_id = StdString("__") + domain->getId() + |
---|
325 | StdString("_") + axis->getId() + StdString("__") ; |
---|
326 | boost::shared_ptr<CGrid> grid = |
---|
327 | CGroupFactory::CreateChild(CObjectFactory::GetObject<CGridGroup> ("grid_definition"), new_id); |
---|
328 | grid->domain_ref.setValue(domain->getId()); |
---|
329 | grid->axis_ref.setValue(axis->getId()); |
---|
330 | return (grid); |
---|
331 | } |
---|
332 | |
---|
333 | //---------------------------------------------------------------- |
---|
334 | |
---|
335 | template <> |
---|
336 | void CGrid::outputField |
---|
337 | (const ARRAY(double, 1) stored, ARRAY(double, 3) field) const |
---|
338 | { |
---|
339 | //std::cout <<"champ : " ; |
---|
340 | for(StdSize n = 0; n < storeIndex[0]->num_elements(); n++) |
---|
341 | { |
---|
342 | (*field)[(*out_i_index[0])[n]][(*out_j_index[0])[n]][(*out_l_index[0])[n]] = (*stored)[n] ; |
---|
343 | /*if (storeIndex[0]->num_elements() == 31) |
---|
344 | { |
---|
345 | std::cout << "( " << (*field)[(*out_i_index[0])[n]][(*out_j_index[0])[n]][(*out_l_index[0])[n]] << ", " |
---|
346 | << (*out_i_index[0])[n] << ", " |
---|
347 | << (*out_j_index[0])[n] << ", " |
---|
348 | << (*out_l_index[0])[n] << ")"; |
---|
349 | }*/ |
---|
350 | } |
---|
351 | //std::cout << std::endl; |
---|
352 | |
---|
353 | } |
---|
354 | |
---|
355 | //--------------------------------------------------------------- |
---|
356 | |
---|
357 | template <> |
---|
358 | void CGrid::outputField |
---|
359 | (const ARRAY(double, 1) stored, ARRAY(double, 2) field) const |
---|
360 | { |
---|
361 | for(StdSize n = 0; n < storeIndex[0]->num_elements(); n++) |
---|
362 | (*field)[(*out_i_index[0])[n]][(*out_j_index[0])[n]] = (*stored)[n] ; |
---|
363 | } |
---|
364 | |
---|
365 | //--------------------------------------------------------------- |
---|
366 | |
---|
367 | template <> |
---|
368 | void CGrid::outputField |
---|
369 | (const ARRAY(double, 1) stored, ARRAY(double, 1) field) const |
---|
370 | { |
---|
371 | for(StdSize n = 0; n < storeIndex[0]->num_elements(); n++) |
---|
372 | (*field)[(*out_i_index[0])[n]] = (*stored)[n] ; |
---|
373 | } |
---|
374 | |
---|
375 | //---------------------------------------------------------------- |
---|
376 | |
---|
377 | void CGrid::storeField_arr |
---|
378 | (const double * const data, ARRAY(double, 1) stored) const |
---|
379 | { |
---|
380 | const StdSize size = (this->storeIndex[0])->num_elements() ; |
---|
381 | // std::cout << this->getId() << "> size : " << size << std::endl; |
---|
382 | stored->resize(boost::extents[size]) ; |
---|
383 | for(StdSize i = 0; i < size; i++) |
---|
384 | (*stored)[i] = data[(*storeIndex[0])[i]] ; |
---|
385 | } |
---|
386 | |
---|
387 | //--------------------------------------------------------------- |
---|
388 | |
---|
389 | void CGrid::toBinary (StdOStream & os) const |
---|
390 | { |
---|
391 | SuperClass::toBinary(os); |
---|
392 | |
---|
393 | os.write (reinterpret_cast<const char*>(&this->isChecked), sizeof(bool)); |
---|
394 | |
---|
395 | if (this->isChecked) |
---|
396 | { |
---|
397 | this->storeIndex [0]->toBinary(os); |
---|
398 | this->out_i_index[0]->toBinary(os); |
---|
399 | this->out_j_index[0]->toBinary(os); |
---|
400 | this->out_l_index[0]->toBinary(os); |
---|
401 | } |
---|
402 | } |
---|
403 | |
---|
404 | //--------------------------------------------------------------- |
---|
405 | |
---|
406 | void CGrid::fromBinary(StdIStream & is) |
---|
407 | { |
---|
408 | bool hasIndex = false; |
---|
409 | SuperClass::fromBinary(is); |
---|
410 | is.read (reinterpret_cast<char*>(&hasIndex), sizeof(bool)); |
---|
411 | |
---|
412 | if (hasIndex) |
---|
413 | { |
---|
414 | ARRAY_CREATE(storeIndex_ , int, 1, [0]); |
---|
415 | ARRAY_CREATE(out_l_index_, int, 1, [0]); |
---|
416 | ARRAY_CREATE(out_i_index_, int, 1, [0]); |
---|
417 | ARRAY_CREATE(out_j_index_, int, 1, [0]); |
---|
418 | |
---|
419 | storeIndex_ ->fromBinary(is); |
---|
420 | out_i_index_->fromBinary(is); |
---|
421 | out_j_index_->fromBinary(is); |
---|
422 | out_l_index_->fromBinary(is); |
---|
423 | |
---|
424 | this->storeIndex .push_back(storeIndex_); |
---|
425 | this->out_i_index.push_back(out_i_index_); |
---|
426 | this->out_j_index.push_back(out_j_index_); |
---|
427 | this->out_l_index.push_back(out_l_index_); |
---|
428 | } |
---|
429 | } |
---|
430 | |
---|
431 | //--------------------------------------------------------------- |
---|
432 | |
---|
433 | void CGrid::computeIndexServer(void) |
---|
434 | { |
---|
435 | ARRAY(int, 2) local_mask = this->domain->getLocalMask(); |
---|
436 | |
---|
437 | const std::vector<int> & ibegin = this->domain->getIBeginSub(); |
---|
438 | const std::vector<int> & jbegin = this->domain->getJBeginSub(); |
---|
439 | |
---|
440 | const int ibegin_srv = this->domain->ibegin.getValue(); |
---|
441 | const int jbegin_srv = this->domain->jbegin.getValue(); |
---|
442 | const int zoom_ni_srv = this->domain->zoom_ni_loc.getValue(); |
---|
443 | const int zoom_nj_srv = this->domain->zoom_nj_loc.getValue(); |
---|
444 | |
---|
445 | const int ibegin_zoom_srv = this->domain->zoom_ibegin_loc.getValue(); |
---|
446 | const int jbegin_zoom_srv = this->domain->zoom_jbegin_loc.getValue(); |
---|
447 | |
---|
448 | StdSize dn = 0; |
---|
449 | for (StdSize j = 1; j < this->out_i_index.size(); j++) |
---|
450 | dn += this->out_i_index[j]->size(); |
---|
451 | |
---|
452 | ARRAY_CREATE(storeIndex_srv , int, 1, [dn]); |
---|
453 | ARRAY_CREATE(out_i_index_srv, int, 1, [dn]); |
---|
454 | ARRAY_CREATE(out_j_index_srv, int, 1, [dn]); |
---|
455 | ARRAY_CREATE(out_l_index_srv, int, 1, [dn]); |
---|
456 | |
---|
457 | for (StdSize i = 0, dn = 0; i < ibegin.size(); i++) |
---|
458 | { |
---|
459 | ARRAY(int, 1) storeIndex_cl = this->storeIndex [i + 1]; |
---|
460 | ARRAY(int, 1) out_i_index_cl = this->out_i_index[i + 1]; |
---|
461 | ARRAY(int, 1) out_j_index_cl = this->out_j_index[i + 1]; |
---|
462 | ARRAY(int, 1) out_l_index_cl = this->out_l_index[i + 1]; |
---|
463 | |
---|
464 | const int ibegin_cl = ibegin[i]; |
---|
465 | const int jbegin_cl = jbegin[i]; |
---|
466 | |
---|
467 | for (StdSize n = dn, m = 0; n < (dn + storeIndex_cl->size()); n++, m++) |
---|
468 | { |
---|
469 | (*storeIndex_srv)[n] = (*storeIndex_cl)[m]; // Faux mais inutile dans le cas serveur. |
---|
470 | (*out_i_index_srv)[n] = (*out_i_index_cl)[m] |
---|
471 | + (ibegin_cl - 1) - (ibegin_srv - 1) - (ibegin_zoom_srv - 1); |
---|
472 | (*out_j_index_srv)[n] = (*out_j_index_cl)[m] |
---|
473 | + (jbegin_cl - 1) - (jbegin_srv - 1) - (jbegin_zoom_srv - 1); |
---|
474 | (*out_l_index_srv)[n] = (*out_l_index_cl)[m]; |
---|
475 | } |
---|
476 | |
---|
477 | dn += storeIndex_cl->size(); |
---|
478 | } |
---|
479 | |
---|
480 | if (storeIndex_srv->size() != 0) |
---|
481 | { |
---|
482 | const int ibegin_t = |
---|
483 | *std::min_element(out_i_index_srv->begin(), out_i_index_srv->end()); |
---|
484 | const int iend_t = |
---|
485 | *std::max_element(out_i_index_srv->begin(), out_i_index_srv->end()); |
---|
486 | const int jbegin_t = |
---|
487 | *std::min_element(out_j_index_srv->begin(), out_j_index_srv->end()); |
---|
488 | const int jend_t = |
---|
489 | *std::max_element(out_j_index_srv->begin(), out_j_index_srv->end()); |
---|
490 | |
---|
491 | if ((ibegin_t < 0) || (jbegin_t < 0) || |
---|
492 | (iend_t >= zoom_ni_srv) || (jend_t >= zoom_nj_srv)) |
---|
493 | { |
---|
494 | ERROR("CGrid::computeIndexServer(void)", |
---|
495 | <<"Erreur d'indexation de la grille au niveau du serveur") ; |
---|
496 | } |
---|
497 | } |
---|
498 | |
---|
499 | if (storeIndex_srv->size() != 0) |
---|
500 | for (StdSize u = 0; u < storeIndex_srv->size(); u++) |
---|
501 | (*local_mask)[(*out_i_index_srv)[u]][(*out_j_index_srv)[u]] = 1; |
---|
502 | |
---|
503 | // StdOFStream ofs(("log_server_"+this->getId()).c_str()); |
---|
504 | // for (StdSize h = 0; h < storeIndex_srv->size(); h++) |
---|
505 | // { |
---|
506 | // ofs << "(" << (*storeIndex_srv)[h] << ";" |
---|
507 | // << (*out_i_index_srv)[h] << "," |
---|
508 | // << (*out_j_index_srv)[h] << "," |
---|
509 | // << (*out_l_index_srv)[h] << ")" << std::endl; |
---|
510 | // } |
---|
511 | // ofs.close(); |
---|
512 | |
---|
513 | this->storeIndex [0] = storeIndex_srv ; |
---|
514 | this->out_i_index[0] = out_i_index_srv; |
---|
515 | this->out_j_index[0] = out_j_index_srv; |
---|
516 | this->out_l_index[0] = out_l_index_srv; |
---|
517 | |
---|
518 | this->storeIndex.resize(1); |
---|
519 | this->out_i_index.resize(1); |
---|
520 | this->out_j_index.resize(1); |
---|
521 | this->out_l_index.resize(1); |
---|
522 | |
---|
523 | } |
---|
524 | |
---|
525 | |
---|
526 | void CGrid::inputFieldServer |
---|
527 | (const std::deque<ARRAY(double, 1)> storedClient, |
---|
528 | ARRAY(double, 1) storedServer) const |
---|
529 | { |
---|
530 | if ((this->storeIndex.size()-1 ) != storedClient.size()) |
---|
531 | ERROR("CGrid::inputFieldServer(...)", |
---|
532 | << "[ Nombre de tableau attendu = " << (this->storeIndex.size()-1) << ", " |
---|
533 | << "[ Nombre de tableau reçu = " << storedClient.size() << "] " |
---|
534 | << "Les données d'un client sont manquantes !") ; |
---|
535 | if (storedServer.get() != NULL) |
---|
536 | storedServer->resize(boost::extents[this->storeIndex.size()-1]); |
---|
537 | else |
---|
538 | ARRAY_ASSIGN(storedServer, double, 1, [this->storeIndex.size()-1]); |
---|
539 | |
---|
540 | for (StdSize i = 0, n = 0; i < storedClient.size(); i++) |
---|
541 | for (StdSize j = 0; j < storedClient[i]->num_elements(); j++) |
---|
542 | (*storedServer)[n++] = (*storedClient[i])[j]; |
---|
543 | } |
---|
544 | |
---|
545 | ///--------------------------------------------------------------- |
---|
546 | |
---|
547 | } // namespace tree |
---|
548 | } // namespace xmlioserver |
---|