source: XMLIO_V2/dev/common/src/xmlio/node/grid.cpp @ 286

Last change on this file since 286 was 286, checked in by ymipsl, 13 years ago

reprise en main de la version de H. Ozdoba. Correction de différentes erreurs de conception et bug.
Version NEMO operationnel en client/server, interoperabilita avec OASIS, reconstition de fichiers via netcdf4/HDF5

YM

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