source: XIOS/dev/dev_ym/XIOS_COUPLING/src/node/grid.cpp @ 1975

Last change on this file since 1975 was 1974, checked in by ymipsl, 4 years ago

Big cleaning on XIOS coupling branch
YM

  • Property copyright set to
    Software name : XIOS (Xml I/O Server)
    http://forge.ipsl.jussieu.fr/ioserver
    Creation date : January 2009
    Licence : CeCCIL version2
    see license file in root directory : Licence_CeCILL_V2-en.txt
    or http://www.cecill.info/licences/Licence_CeCILL_V2-en.html
    Holder : CEA/LSCE (Laboratoire des Sciences du CLimat et de l'Environnement)
    CNRS/IPSL (Institut Pierre Simon Laplace)
    Project Manager : Yann Meurdesoif
    yann.meurdesoif@cea.fr
  • Property svn:executable set to *
File size: 63.0 KB
Line 
1
2#include "grid.hpp"
3
4#include "attribute_template.hpp"
5#include "object_template.hpp"
6#include "group_template.hpp"
7#include "message.hpp"
8#include <iostream>
9#include "xios_spl.hpp"
10#include "type.hpp"
11#include "context.hpp"
12#include "context_client.hpp"
13#include "context_server.hpp"
14#include "array_new.hpp"
15#include "server_distribution_description.hpp"
16#include "client_server_mapping_distributed.hpp"
17#include "distribution_client.hpp"
18#include "grid_transformation.hpp"
19#include "grid_generate.hpp"
20#include "server.hpp"
21#include "distribution_type.hpp"
22#include "grid_remote_connector.hpp"
23#include "grid_elements.hpp"
24#include "grid_local_view.hpp"
25#include "grid_mask_connector.hpp"
26
27
28namespace xios {
29
30   /// ////////////////////// Dfinitions ////////////////////// ///
31
32   CGrid::CGrid(void)
33      : CObjectTemplate<CGrid>(), CGridAttributes()
34      , isChecked(false), isDomainAxisChecked(false)
35      , vDomainGroup_(), domList_(), isDomListSet(false)
36      , vAxisGroup_(), axisList_(), isAxisListSet(false)
37      , vScalarGroup_(), scalarList_(), isScalarListSet(false)
38      , clientDistribution_(0), isIndexSent(false)
39      , connectedDataSize_(), connectedServerRank_(), connectedServerRankRead_(), connectedDataSizeRead_()
40            , isCompressible_(false)
41      , transformations_(0), isTransformed_(false)
42      , axisPositionInGrid_(), hasDomainAxisBaseRef_(false)
43      , gridSrc_(), hasTransform_(false), isGenerated_(false), order_()
44      , clients()
45   {
46     setVirtualDomainGroup(CDomainGroup::create(getId() + "_virtual_domain_group"));
47     setVirtualAxisGroup(CAxisGroup::create(getId() + "_virtual_axis_group"));
48     setVirtualScalarGroup(CScalarGroup::create(getId() + "_virtual_scalar_group"));
49   }
50
51   CGrid::CGrid(const StdString& id)
52      : CObjectTemplate<CGrid>(id), CGridAttributes()
53      , isChecked(false), isDomainAxisChecked(false)
54      , vDomainGroup_(), domList_(), isDomListSet(false)
55      , vAxisGroup_(), axisList_(), isAxisListSet(false)
56      , vScalarGroup_(), scalarList_(), isScalarListSet(false)
57      , clientDistribution_(0), isIndexSent(false)
58      , connectedDataSize_(), connectedServerRank_(), connectedServerRankRead_(), connectedDataSizeRead_()
59            , isCompressible_(false)
60      , transformations_(0), isTransformed_(false)
61      , axisPositionInGrid_(), hasDomainAxisBaseRef_(false)
62      , gridSrc_(), hasTransform_(false), isGenerated_(false), order_()
63      , clients()
64   {
65     setVirtualDomainGroup(CDomainGroup::create(getId() + "_virtual_domain_group"));
66     setVirtualAxisGroup(CAxisGroup::create(getId() + "_virtual_axis_group"));
67     setVirtualScalarGroup(CScalarGroup::create(getId() + "_virtual_scalar_group"));
68   }
69
70   CGrid::~CGrid(void)
71   {
72    if (0 != clientDistribution_) delete clientDistribution_;
73    if (0 != transformations_) delete transformations_;
74   }
75
76   ///---------------------------------------------------------------
77
78   StdString CGrid::GetName(void)    { return StdString("grid"); }
79   StdString CGrid::GetDefName(void) { return CGrid::GetName(); }
80   ENodeType CGrid::GetType(void)    { return eGrid; }
81
82
83  ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
84  ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
85  /////////              MEMBER FUNCTION RELATED TO GRID CONSTRUCTION by ELEMNTS AND MANAGEMENT                      /////
86  ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
87  ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
88
89
90   CGrid* CGrid::createGrid(CDomain* domain)
91   TRY
92   {
93     std::vector<CDomain*> vecDom(1, domain);
94     std::vector<CAxis*> vecAxis;
95     return createGrid(vecDom, vecAxis);
96   }
97   CATCH
98
99   CGrid* CGrid::createGrid(CDomain* domain, CAxis* axis)
100   TRY
101  {
102      std::vector<CDomain*> vecDom(1, domain);
103      std::vector<CAxis*> vecAxis(1, axis);
104
105      return createGrid(vecDom, vecAxis);
106   }
107   CATCH
108
109   CGrid* CGrid::createGrid(const std::vector<CDomain*>& domains, const std::vector<CAxis*>& axis,
110                            const CArray<int,1>& axisDomainOrder)
111   TRY
112   {
113     std::vector<CScalar*> vecScalar;
114     return createGrid(generateId(domains, axis, vecScalar, axisDomainOrder), domains, axis, vecScalar, axisDomainOrder);
115   }
116   CATCH
117
118   CGrid* CGrid::createGrid(const std::vector<CDomain*>& domains, const std::vector<CAxis*>& axis,
119                            const std::vector<CScalar*>& scalars, const CArray<int,1>& axisDomainOrder)
120   TRY
121   {
122     return createGrid(generateId(domains, axis, scalars, axisDomainOrder), domains, axis, scalars, axisDomainOrder);
123   }
124   CATCH
125
126   CGrid* CGrid::createGrid(StdString id, const std::vector<CDomain*>& domains, const std::vector<CAxis*>& axis,
127                            const std::vector<CScalar*>& scalars, const CArray<int,1>& axisDomainOrder)
128   TRY
129   {
130      if (axisDomainOrder.numElements() > 0 && axisDomainOrder.numElements() != (domains.size() + axis.size() + scalars.size()))
131        ERROR("CGrid* CGrid::createGrid(...)",
132              << "The size of axisDomainOrder (" << axisDomainOrder.numElements()
133              << ") is not coherent with the number of elements (" << domains.size() + axis.size() <<").");
134
135      CGrid* grid = CGridGroup::get("grid_definition")->createChild(id);
136      grid->setDomainList(domains);
137      grid->setAxisList(axis);
138      grid->setScalarList(scalars);
139
140      // By default, domains are always the first elements of a grid
141      if (0 == axisDomainOrder.numElements())
142      {
143        int size = domains.size() + axis.size() + scalars.size();
144        int nb = 0;
145        grid->axis_domain_order.resize(size);
146        for (int i = 0; i < size; ++i)
147        {
148          if (i < domains.size())
149          {
150            grid->axis_domain_order(i) = 2;
151            grid->order_.push_back(2) ;
152          }
153          else if ((scalars.size() < (size-nb)) < size)
154          {
155            grid->axis_domain_order(i) = 1;
156            grid->order_.push_back(1) ;
157          }
158          else
159          {
160            grid->axis_domain_order(i) = 0;
161            grid->order_.push_back(0) ;
162          }
163          ++nb;
164        }
165      }
166      else
167      {
168        grid->axis_domain_order.resize(axisDomainOrder.numElements());
169        grid->axis_domain_order = axisDomainOrder;
170        grid->order_.clear() ;
171        for(int i=0; i<axisDomainOrder.numElements();i++) grid->order_.push_back(axisDomainOrder(i)) ;
172
173      }
174
175 //     grid->solveElementsRefInheritance(true);
176
177      return grid;
178   }
179   CATCH
180
181   //----------------------------------------------------------------
182
183   //! Change virtual field group to a new one
184   void CGrid::setVirtualDomainGroup(CDomainGroup* newVDomainGroup)
185   TRY
186   {
187      this->vDomainGroup_ = newVDomainGroup;
188   }
189   CATCH_DUMP_ATTR
190
191   //! Change virtual variable group to new one
192   void CGrid::setVirtualAxisGroup(CAxisGroup* newVAxisGroup)
193   TRY
194   {
195      this->vAxisGroup_ = newVAxisGroup;
196   }
197   CATCH_DUMP_ATTR
198
199   //! Change virtual variable group to new one
200   void CGrid::setVirtualScalarGroup(CScalarGroup* newVScalarGroup)
201   TRY
202   {
203      this->vScalarGroup_ = newVScalarGroup;
204   }
205   CATCH_DUMP_ATTR
206
207   //----------------------------------------------------------------
208
209   CDomainGroup* CGrid::getVirtualDomainGroup() const
210   TRY
211   {
212     return this->vDomainGroup_;
213   }
214   CATCH
215
216   CAxisGroup* CGrid::getVirtualAxisGroup() const
217   TRY
218   {
219     return this->vAxisGroup_;
220   }
221   CATCH
222
223   CScalarGroup* CGrid::getVirtualScalarGroup() const
224   TRY
225   {
226     return this->vScalarGroup_;
227   }
228   CATCH
229
230  ///---------------------------------------------------------------
231
232   CDomain* CGrid::addDomain(const std::string& id)
233   TRY
234   {
235     order_.push_back(2);
236     axis_domain_order.resize(order_.size());
237     for (int idx = 0; idx < order_.size(); ++idx) axis_domain_order(idx)=order_[idx];
238     return vDomainGroup_->createChild(id);
239   }
240   CATCH_DUMP_ATTR
241
242   CAxis* CGrid::addAxis(const std::string& id)
243   TRY
244   {
245     order_.push_back(1);
246     axis_domain_order.resize(order_.size());
247     for (int idx = 0; idx < order_.size(); ++idx) axis_domain_order(idx)=order_[idx];
248     return vAxisGroup_->createChild(id);
249   }
250   CATCH_DUMP_ATTR
251
252   CScalar* CGrid::addScalar(const std::string& id)
253   TRY
254   {
255     order_.push_back(0);
256     axis_domain_order.resize(order_.size());
257     for (int idx = 0; idx < order_.size(); ++idx) axis_domain_order(idx)=order_[idx];
258     return vScalarGroup_->createChild(id);
259   }
260   CATCH_DUMP_ATTR
261
262
263
264
265  /*!
266  \brief Get the list of domain pointers
267  \return list of domain pointers
268  */
269  std::vector<CDomain*> CGrid::getDomains()
270  TRY
271  {
272    setDomainList();
273    std::vector<CDomain*> domList;
274    if (!domList_.empty())
275    {
276      for (int i = 0; i < domList_.size(); ++i) domList.push_back(CDomain::get(domList_[i]));
277    }
278    return domList;
279  }
280  CATCH_DUMP_ATTR
281
282  /*!
283  \brief Get the list of  axis pointers
284  \return list of axis pointers
285  */
286  std::vector<CAxis*> CGrid::getAxis()
287  TRY
288  {
289    setAxisList();
290    std::vector<CAxis*> aList;
291    if (!axisList_.empty())
292      for (int i =0; i < axisList_.size(); ++i) aList.push_back(CAxis::get(axisList_[i]));
293
294    return aList;
295  }
296  CATCH_DUMP_ATTR
297
298  /*!
299  \brief Get the list of  axis pointers
300  \return list of axis pointers
301  */
302  std::vector<CScalar*> CGrid::getScalars()
303  TRY
304  {
305    setScalarList() ;
306    std::vector<CScalar*> sList;
307    if (!scalarList_.empty())
308      for (int i =0; i < scalarList_.size(); ++i) sList.push_back(CScalar::get(scalarList_[i]));
309
310    return sList;
311  }
312  CATCH_DUMP_ATTR
313
314  /*!
315  \brief Get domain pointer with index
316  \return domain pointer
317  */
318  CDomain* CGrid::getDomain(int domainIndex)
319  TRY
320  {
321    std::vector<CDomain*> domainListP = this->getDomains();
322    if (domainListP.empty())
323    {
324      ERROR("CGrid::getDomain(int domainIndex)",
325            << "No domain associated to this grid. " << std::endl
326            << "Grid id = " << this->getId());
327    }
328
329    if (domainIndex >= domainListP.size() || (domainIndex < 0))
330      ERROR("CGrid::getDomain(int domainIndex)",
331            << "Domain with the index doesn't exist " << std::endl
332            << "Grid id = " << this->getId() << std::endl
333            << "Grid has only " << domainListP.size() << " domain but domain index required is " << domainIndex << std::endl);
334
335    return domainListP[domainIndex];
336  }
337  CATCH_DUMP_ATTR
338
339  /*!
340  \brief Get the axis pointer with index
341  \return axis pointer
342  */
343  CAxis* CGrid::getAxis(int axisIndex)
344  TRY
345  {
346    std::vector<CAxis*> axisListP = this->getAxis();
347    if (axisListP.empty())
348    {
349      ERROR("CGrid::getDomain(int axisIndex)",
350            << "No axis associated to this grid. " << std::endl
351            << "Grid id = " << this->getId());
352    }
353
354    if (axisIndex >= axisListP.size() || (axisIndex < 0))
355      ERROR("CGrid::getDomain(int axisIndex)",
356            << "Domain with the index doesn't exist " << std::endl
357            << "Grid id = " << this->getId() << std::endl
358            << "Grid has only " << axisListP.size() << " axis but axis index required is " << axisIndex << std::endl);
359
360    return axisListP[axisIndex];
361  }
362  CATCH_DUMP_ATTR
363
364  /*!
365  \brief Get the a scalar pointer
366  \return scalar pointer
367  */
368  CScalar* CGrid::getScalar(int scalarIndex)
369  TRY
370  {
371    std::vector<CScalar*> scalarListP = this->getScalars();
372    if (scalarListP.empty())
373    {
374      ERROR("CGrid::getScalar(int scalarIndex)",
375            << "No scalar associated to this grid. " << std::endl
376            << "Grid id = " << this->getId());
377    }
378
379    if (scalarIndex >= scalarListP.size() || (scalarIndex < 0))
380      ERROR("CGrid::getScalar(int scalarIndex)",
381            << "Scalar with the index doesn't exist " << std::endl
382            << "Grid id = " << this->getId() << std::endl
383            << "Grid has only " << scalarListP.size() << " scalar but scalar index required is " << scalarIndex << std::endl);
384
385    return scalarListP[scalarIndex];
386  }
387  CATCH_DUMP_ATTR
388
389  /*!
390  \brief Set domain(s) of a grid from a list
391  \param[in] domains list of domains
392  */
393  void CGrid::setDomainList(const std::vector<CDomain*> domains)
394  TRY
395  {
396    if (isDomListSet) return;
397    std::vector<CDomain*> domList = this->getVirtualDomainGroup()->getAllChildren();
398    if (!domains.empty() && domList.empty())
399    {
400      for (int i = 0; i < domains.size(); ++i)
401        this->getVirtualDomainGroup()->addChild(domains[i]);
402      domList = this->getVirtualDomainGroup()->getAllChildren();
403    }
404
405    if (!domList.empty())
406    {
407      int sizeDom = domList.size();
408      domList_.resize(sizeDom);
409      for (int i = 0; i < sizeDom; ++i)
410      {
411        domList_[i] = domList[i]->getId();
412      }
413      isDomListSet = true;
414    }
415  }
416  CATCH_DUMP_ATTR
417
418  /*!
419  \brief Set axis(s) of a grid from a list
420  \param[in] axis list of axis
421  */
422  void CGrid::setAxisList(const std::vector<CAxis*> axis)
423  TRY
424  {
425    if (isAxisListSet) return;
426    std::vector<CAxis*> aList = this->getVirtualAxisGroup()->getAllChildren();
427    if (!axis.empty() && aList.empty())
428    {
429      for (int i = 0; i < axis.size(); ++i)
430        this->getVirtualAxisGroup()->addChild(axis[i]);
431      aList = this->getVirtualAxisGroup()->getAllChildren();
432    }
433
434    if (!aList.empty())
435    {
436      int sizeAxis = aList.size();
437      axisList_.resize(sizeAxis);
438      for (int i = 0; i < sizeAxis; ++i)
439      {
440        axisList_[i] = aList[i]->getId();
441      }
442      isAxisListSet = true;
443    }
444  }
445  CATCH_DUMP_ATTR
446
447  /*!
448  \brief Set scalar(s) of a grid from a list
449  \param[in] scalars list of scalars
450  */
451  void CGrid::setScalarList(const std::vector<CScalar*> scalars)
452  TRY
453  {
454    if (isScalarListSet) return;
455    std::vector<CScalar*> sList = this->getVirtualScalarGroup()->getAllChildren();
456    if (!scalars.empty() && sList.empty())
457    {
458      for (int i = 0; i < scalars.size(); ++i)
459        this->getVirtualScalarGroup()->addChild(scalars[i]);
460      sList = this->getVirtualScalarGroup()->getAllChildren();
461    }
462
463    if (!sList.empty())
464    {
465      int sizeScalar = sList.size();
466      scalarList_.resize(sizeScalar);
467      for (int i = 0; i < sizeScalar; ++i)
468      {
469        scalarList_[i] = sList[i]->getId();
470      }
471      isScalarListSet = true;
472    }
473  }
474  CATCH_DUMP_ATTR
475
476  /*!
477  \brief Get list of id of domains
478  \return id list of domains
479  */
480  std::vector<StdString> CGrid::getDomainList()
481  TRY
482  {
483    setDomainList();
484    return domList_;
485  }
486  CATCH
487
488  /*!
489  \brief Get list of id of axis
490  \return id list of axis
491  */
492  std::vector<StdString> CGrid::getAxisList()
493  TRY
494  {
495    setAxisList();
496    return axisList_;
497  }
498  CATCH
499
500  /*!
501  \brief Get list of id of scalar
502  \return id list of scalar
503  */
504  std::vector<StdString> CGrid::getScalarList()
505  TRY
506  {
507    setScalarList();
508    return scalarList_;
509  }
510  CATCH
511
512
513  void CGrid::computeElements(void)
514  {
515    const auto& domains = getDomains() ;
516    const auto& axis = getAxis() ;
517    const auto& scalars = getScalars() ;
518    int idxDomain = 0, idxAxis=0 , idxScalar=0 ; 
519 
520    for(auto type : order_)
521    {
522      if      (type == 0) { elements_.push_back({scalars[idxScalar], TYPE_SCALAR, scalars[idxScalar], nullptr, nullptr } ) ; idxScalar++;}
523      else if (type == 1) { elements_.push_back({axis[idxAxis], TYPE_AXIS, nullptr, axis[idxAxis], nullptr}) ; idxAxis++;}
524      else if (type == 2) { elements_.push_back({domains[idxDomain], TYPE_DOMAIN, nullptr, nullptr, domains[idxDomain] }) ; idxDomain++;}       
525    }
526    elementsComputed_ = true ;
527  }
528 
529 
530 /*!
531    Parse a grid, for now, it contains only domain, axis and scalar
532  */
533  void CGrid::parse(xml::CXMLNode& node)
534  TRY
535  {
536    SuperClass::parse(node);
537
538    if (node.goToChildElement())
539    {
540      StdString domainName("domain");
541      StdString axisName("axis");
542      StdString scalarName("scalar");
543      do
544      {
545        if (node.getElementName() == domainName) {
546          order_.push_back(2);
547          this->getVirtualDomainGroup()->parseChild(node);
548        }
549        if (node.getElementName() == axisName) {
550          order_.push_back(1);
551          this->getVirtualAxisGroup()->parseChild(node);
552        }
553        if (node.getElementName() == scalarName) {
554          order_.push_back(0);
555          this->getVirtualScalarGroup()->parseChild(node);
556        }
557      } while (node.goToNextElement());
558      node.goToParentElement();
559    }
560
561    if (!order_.empty())
562    {
563      int sizeOrd = order_.size();
564      axis_domain_order.resize(sizeOrd);
565      for (int i = 0; i < sizeOrd; ++i)
566      {
567        axis_domain_order(i) = order_[i];
568      }
569    }
570
571    setDomainList();
572    setAxisList();
573    setScalarList();
574   }
575   CATCH_DUMP_ATTR
576
577
578  ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
579  ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
580  ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
581  ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
582
583
584
585   StdSize CGrid::getDimension(void)
586   TRY
587   {
588      return getGlobalDimension().size();
589   }
590   CATCH_DUMP_ATTR
591
592   //---------------------------------------------------------------
593
594   StdSize CGrid::getDataSize(void) 
595   TRY
596   {
597     StdSize retvalue = 1;
598     if (!isScalarGrid())
599     {
600       std::vector<int> dataNindex = getClientDistribution()->getDataNIndex();
601       for (int i = 0; i < dataNindex.size(); ++i) retvalue *= dataNindex[i];       
602     }
603     return retvalue;
604   }
605   CATCH
606   
607   /*!
608    * Get the local data grid size, ie the size of the compressed grid (inside the workflow)
609    * \return The size od the compressed grid
610    */
611    StdSize  CGrid::getLocalDataSize(void) { return getClientDistribution()->getLocalDataSize();}
612
613
614   /*!
615    * Compute the minimum buffer size required to send the attributes to the server(s).
616    *
617    * \return A map associating the server rank with its minimum buffer size.
618    * TODO: Refactor code
619    */
620   std::map<int, StdSize> CGrid::getAttributesBufferSize(CContextClient* client, bool bufferForWriting)
621   TRY
622   {
623     std::map<int, StdSize> attributesSizes = getMinimumBufferSizeForAttributes(client);
624
625     // The grid indexes require a similar size as the actual data
626     std::map<int, StdSize> dataSizes = getDataBufferSize(client, "", bufferForWriting);
627     std::map<int, StdSize>::iterator it, itE = dataSizes.end();
628     for (it = dataSizes.begin(); it != itE; ++it)
629     {
630       it->second += 2 * sizeof(bool);
631       if (it->second > attributesSizes[it->first])
632         attributesSizes[it->first] = it->second;
633     }
634     
635     // Account for the axis attributes
636     std::vector<CAxis*> axisList = getAxis();
637     for (size_t i = 0; i < axisList.size(); ++i)
638     {
639       std::map<int, StdSize> axisAttBuffSize = axisList[i]->getAttributesBufferSize(client, getGlobalDimension(),getAxisPositionInGrid()[i]);
640       for (it = axisAttBuffSize.begin(), itE = axisAttBuffSize.end(); it != itE; ++it)
641       {
642         it->second += 2 * sizeof(bool);
643         if (it->second > attributesSizes[it->first])
644           attributesSizes[it->first] = it->second;
645       }
646     }
647
648     // Account for the domain attributes
649     std::vector<CDomain*> domList = getDomains();
650     for (size_t i = 0; i < domList.size(); ++i)
651     {
652       std::map<int, StdSize> domAttBuffSize = domList[i]->getAttributesBufferSize(client);
653       for (it = domAttBuffSize.begin(), itE = domAttBuffSize.end(); it != itE; ++it)
654       {
655         it->second += 2 * sizeof(bool);
656         if (it->second > attributesSizes[it->first])
657           attributesSizes[it->first] = it->second;
658       }
659     }
660
661     return attributesSizes;
662  }
663   CATCH_DUMP_ATTR
664
665   /*!
666    * Compute the minimum buffer size required to send the data.
667    * \param client contextClient used to determine the size of connected receivers
668    * \param id the id used to tag the data
669    * \param bufferForWriting flag indicating if a buffer is used to send data for writing
670    * \return A map associating the sender rank with its minimum buffer size.
671    */
672   std::map<int, StdSize> CGrid::getDataBufferSize(CContextClient* client, const std::string& id /*= ""*/, bool bufferForWriting /*= "false"*/)
673   TRY
674   {     
675     // The record index is sometimes sent along with the data but we always
676     // include it in the size calculation for the sake of simplicity
677     const size_t extraSize = CEventClient::headerSize + (id.empty() ? getId() : id).size() 
678                                                       + 2 * sizeof(size_t) 
679                                                       + sizeof(size_t);
680
681     std::map<int, StdSize> dataSizes;
682     int receiverSize = client->serverSize;
683     std::map<int,size_t>& dataSizeMap = bufferForWriting ? connectedDataSize_[receiverSize]: connectedDataSizeRead_;
684     std::vector<int>& connectedServerRanks = bufferForWriting ? connectedServerRank_[receiverSize] : connectedServerRankRead_;
685
686     std::map<int, size_t>::const_iterator itEnd = dataSizeMap.end();
687     for (size_t k = 0; k < connectedServerRanks.size(); ++k)
688     {
689       int rank = connectedServerRanks[k];
690       std::map<int, size_t>::const_iterator it = dataSizeMap.find(rank);
691       size_t count = (it != itEnd) ? it->second : 0;
692
693       dataSizes.insert(std::make_pair(rank, extraSize + CArray<double,1>::size(count)));
694     }
695
696     return dataSizes;
697   }
698   CATCH_DUMP_ATTR
699
700   size_t CGrid::getGlobalWrittenSize(void)
701   TRY
702   {
703         std::vector<CDomain*> domainP = this->getDomains();
704     std::vector<CAxis*> axisP = this->getAxis();
705     
706     size_t globalGridSize=1 ;
707     for (std::vector<CDomain*>::iterator it=domainP.begin(); it!=domainP.end();++it) globalGridSize*=(*it)->getGlobalWrittenSize() ;
708     for (std::vector<CAxis*>::iterator it=axisP.begin(); it!=axisP.end();++it) globalGridSize*=(*it)->getGlobalWrittenSize() ;
709     return globalGridSize ;
710   }
711   CATCH_DUMP_ATTR
712   
713
714   void CGrid::computeAxisPositionInGrid(void)
715   {
716     axisPositionInGrid_.resize(0);
717     int idx = 0;
718     for (int i = 0; i < axis_domain_order.numElements(); ++i)
719     {
720       int elementDimension = axis_domain_order(i);
721       if (1 == elementDimension)
722       {
723         axisPositionInGrid_.push_back(idx);
724         ++idx;
725       }
726       else if (2 == elementDimension) idx += 2;
727     }
728   }
729
730 
731   /*!
732    * Test whether the data defined on the grid can be outputted in a compressed way.
733    *
734    * \return true if and only if a mask was defined for this grid
735    */
736   bool CGrid::isCompressible(void) const
737   TRY
738   {
739      return isCompressible_;
740   }
741   CATCH
742
743   //---------------------------------------------------------------
744
745   void CGrid::addRelFileCompressed(const StdString& filename)
746   TRY
747   {
748      this->relFilesCompressed.insert(filename);
749   }
750   CATCH_DUMP_ATTR
751
752   bool CGrid::isWrittenCompressed(const StdString& filename) const
753   TRY
754   {
755      return (this->relFilesCompressed.find(filename) != this->relFilesCompressed.end());
756   }
757   CATCH
758
759   //---------------------------------------------------------------
760   /*
761     Find all reference of grid's components and inherite attributes if necessary
762   */
763   void CGrid::solveDomainAxisRef(bool areAttributesChecked)
764   TRY
765   {
766     if (this->isDomainAxisChecked) return;
767
768     this->solveScalarRef(areAttributesChecked);
769     this->solveAxisRef(areAttributesChecked);
770     this->solveDomainRef(areAttributesChecked);     
771     this->isDomainAxisChecked = areAttributesChecked;
772   }
773   CATCH_DUMP_ATTR
774
775   /*
776     Go up hierachy reference and fill in the base reference with attributes of the children
777     This function should be only used after reading component's attributes from file
778   */
779   void CGrid::solveDomainAxisBaseRef()
780   TRY
781   {
782     if (this->hasDomainAxisBaseRef_) return;
783     // Account for the scalar attributes
784     std::vector<CScalar*> scalarList = getScalars();
785     for (size_t i = 0; i < scalarList.size(); ++i)
786     {
787       scalarList[i]->setAttributesReference();
788     }
789
790     // Account for the axis attributes
791     std::vector<CAxis*> axisList = getAxis();
792     for (size_t i = 0; i < axisList.size(); ++i)
793     {
794       axisList[i]->setAttributesReference();
795     }
796
797     // Account for the domain attributes
798     std::vector<CDomain*> domList = getDomains();
799     for (size_t i = 0; i < domList.size(); ++i)
800     {
801       domList[i]->setAttributesReference();
802     }
803
804     this->hasDomainAxisBaseRef_ = true;
805   }
806   CATCH_DUMP_ATTR
807
808   void CGrid::checkEligibilityForCompressedOutput()
809   TRY
810   {
811     // We don't check if the mask is valid here, just if a mask has been defined at this point.
812     isCompressible_ = !mask_1d.isEmpty() || !mask_2d.isEmpty() || !mask_3d.isEmpty();
813   }
814   CATCH_DUMP_ATTR
815
816   //ym obsolete -> to be removed later
817   void CGrid::checkMaskIndex(bool doSendingIndex)
818   TRY
819   {
820     CContext* context = CContext::getCurrent();
821     
822     if (this->isChecked) return;
823     this->checkElementsAttributes();
824
825     if (!(this->hasTransform() && !this->isTransformed()))
826      this->isChecked = true;
827
828     if (!(this->hasTransform() && (!this->isGenerated())))
829      this->isChecked = true;
830   }
831   CATCH_DUMP_ATTR
832
833
834   bool CGrid::hasMask() const
835   TRY
836   {
837     return (!mask_1d.isEmpty() || !mask_2d.isEmpty() || !mask_3d.isEmpty() ||
838             !mask_4d.isEmpty() || !mask_5d.isEmpty() || !mask_6d.isEmpty() || !mask_7d.isEmpty());
839   }
840   CATCH
841
842   
843   CArray<bool,1>& CGrid::getMask(void)
844   {
845     
846      if (mask_.isEmpty())
847      { 
848        if (!mask_0d.isEmpty()) mask_.reference(CArray<bool,1>(mask_0d.dataFirst(),shape(mask_0d.numElements()), neverDeleteData)) ;
849        if (!mask_1d.isEmpty()) mask_.reference(CArray<bool,1>(mask_1d.dataFirst(),shape(mask_1d.numElements()), neverDeleteData)) ;
850        if (!mask_2d.isEmpty()) mask_.reference(CArray<bool,1>(mask_2d.dataFirst(),shape(mask_2d.numElements()), neverDeleteData)) ;
851        if (!mask_3d.isEmpty()) mask_.reference(CArray<bool,1>(mask_3d.dataFirst(),shape(mask_3d.numElements()), neverDeleteData)) ;
852        if (!mask_4d.isEmpty()) mask_.reference(CArray<bool,1>(mask_4d.dataFirst(),shape(mask_4d.numElements()), neverDeleteData)) ;
853        if (!mask_5d.isEmpty()) mask_.reference(CArray<bool,1>(mask_5d.dataFirst(),shape(mask_5d.numElements()), neverDeleteData)) ;
854        if (!mask_6d.isEmpty()) mask_.reference(CArray<bool,1>(mask_6d.dataFirst(),shape(mask_6d.numElements()), neverDeleteData)) ;
855        if (!mask_7d.isEmpty()) mask_.reference(CArray<bool,1>(mask_7d.dataFirst(),shape(mask_7d.numElements()), neverDeleteData)) ;
856      }
857      return mask_ ;
858   }
859
860 
861   //---------------------------------------------------------------
862
863   void CGrid::solveDomainRef(bool sendAtt)
864   TRY
865   {
866      setDomainList();
867      std::vector<CDomain*> domListP = this->getDomains();
868      if (!domListP.empty())
869        for (int i = 0; i < domListP.size(); ++i) domListP[i]->checkAttributes();
870   }
871   CATCH_DUMP_ATTR
872
873   //---------------------------------------------------------------
874
875   void CGrid::solveAxisRef(bool sendAtt)
876   TRY
877   {
878      setAxisList();
879      std::vector<CAxis*> axisListP = this->getAxis();
880      if (!axisListP.empty())
881        for (int i = 0; i < axisListP.size(); ++i)  axisListP[i]->checkAttributes();
882   }
883   CATCH_DUMP_ATTR
884
885   //---------------------------------------------------------------
886
887   void CGrid::solveScalarRef(bool sendAtt)
888   TRY
889   {
890      setScalarList();
891      std::vector<CScalar*> scalarListP = this->getScalars();
892      if (!scalarListP.empty())
893        for (int i = 0; i < scalarListP.size(); ++i) scalarListP[i]->checkAttributes() ;
894   }
895   CATCH_DUMP_ATTR
896
897
898    //---------------------------------------------------------------
899   CDistributionClient* CGrid::getClientDistribution()
900   TRY
901   {
902     if (!computeClientDistribution_done_) computeClientDistribution() ;
903     return clientDistribution_;
904   }
905   CATCH_DUMP_ATTR
906   
907   void CGrid::computeClientDistribution(void)
908   {
909     if (computeClientDistribution_done_) return ;
910     else computeClientDistribution_done_ = true ;
911
912     CContext* context = CContext::getCurrent();
913     int rank = context-> getIntraCommRank();
914     clientDistribution_ = new CDistributionClient(rank, this);
915   }
916
917
918  bool CGrid::isDataDistributed(void) 
919  { 
920    return getClientDistribution()->isDataDistributed() ;
921  }
922
923 
924   /*!
925     Compute the global index of grid to send to server as well as the connected server of the current client.
926     First of all, from the local data on each element of grid, we can calculate their local index which also allows us to know
927     their global index. We can have a map of global index of grid and local index that each client holds
928     Then, each client holds a piece of information about the distribution of servers, which permits to compute the connected server(s)
929     of the current client.
930   */
931   // ym obsolete : to be removed....
932   void CGrid::computeIndex(void)
933   TRY
934   {
935    // old interface
936     CContext* context = CContext::getCurrent();
937     if (isScalarGrid())
938     {
939       //computeClientIndexScalarGrid();
940       if (context->getServiceType()==CServicesManager::CLIENT || context->getServiceType()==CServicesManager::GATHERER)
941       {
942         // ym computeConnectedClientsScalarGrid();
943       }
944     }
945     else
946     {
947       //computeClientIndex();
948       if (context->getServiceType()==CServicesManager::CLIENT || context->getServiceType()==CServicesManager::GATHERER)
949       {
950         //computeConnectedClients();
951       }
952     }
953//ym     if (CServer::serverLevel==2)
954     if (context->getServiceType()==CServicesManager::OUT_SERVER)
955     {
956       if (clientDistribution_!=0) clientDistribution_->partialClear() ;
957     }
958   }
959   CATCH_DUMP_ATTR
960
961   
962//----------------------------------------------------------------
963
964
965
966   CGrid* CGrid::cloneGrid(const StdString& idNewGrid, CGrid* gridSrc)
967   TRY
968   {
969     std::vector<CDomain*> domainSrcTmp = gridSrc->getDomains(), domainSrc;
970     std::vector<CAxis*> axisSrcTmp = gridSrc->getAxis(), axisSrc;
971     std::vector<CScalar*> scalarSrcTmp = gridSrc->getScalars(), scalarSrc;
972
973     for (int idx = 0; idx < domainSrcTmp.size(); ++idx)
974     {
975       CDomain* domain = CDomain::createDomain();
976       domain->duplicateAttributes(domainSrcTmp[idx]);
977       domain->duplicateTransformation(domainSrcTmp[idx]);
978       domain->solveRefInheritance(true);
979       domain->solveInheritanceTransformation();
980       domainSrc.push_back(domain);
981     }
982
983     for (int idx = 0; idx < axisSrcTmp.size(); ++idx)
984     {
985       CAxis* axis = CAxis::createAxis();
986       axis->duplicateAttributes(axisSrcTmp[idx]);
987       axis->duplicateTransformation(axisSrcTmp[idx]);
988       axis->solveRefInheritance(true);
989       axis->solveInheritanceTransformation();
990       axisSrc.push_back(axis);
991     }
992
993     for (int idx = 0; idx < scalarSrcTmp.size(); ++idx)
994     {
995       CScalar* scalar = CScalar::createScalar();
996       scalar->duplicateAttributes(scalarSrcTmp[idx]);
997       scalar->duplicateTransformation(scalarSrcTmp[idx]);
998       scalar->solveRefInheritance(true);
999       scalar->solveInheritanceTransformation();
1000       scalarSrc.push_back(scalar);
1001     }
1002
1003      CGrid* grid = CGrid::createGrid(idNewGrid, domainSrc, axisSrc, scalarSrc, gridSrc->axis_domain_order);
1004
1005      return grid;
1006   }
1007   CATCH
1008
1009   StdString CGrid::generateId(const std::vector<CDomain*>& domains, const std::vector<CAxis*>& axis,
1010                               const std::vector<CScalar*>& scalars, const CArray<int,1>& axisDomainOrder)
1011   TRY
1012   {
1013      if (axisDomainOrder.numElements() > 0 && axisDomainOrder.numElements() != (domains.size() + axis.size() + scalars.size()))
1014        ERROR("CGrid* CGrid::generateId(...)",
1015              << "The size of axisDomainOrder (" << axisDomainOrder.numElements()
1016              << ") is not coherent with the number of elements (" << domains.size() + axis.size() <<").");
1017
1018      std::ostringstream id;
1019
1020      if (domains.empty() && axis.empty() && !scalars.empty())
1021        id << "__scalar_";
1022
1023      if (0 != (domains.size() + axis.size() + scalars.size()))
1024      {
1025        id << "__grid";
1026
1027        if (0 == axisDomainOrder.numElements())
1028        {
1029          for (size_t i = 0; i < domains.size(); ++i) id << "_" << domains[i]->getId();
1030          for (size_t i = 0; i < axis.size(); ++i) id << "_" << axis[i]->getId();
1031          for (size_t i = 0; i < scalars.size(); ++i) id << "_" << scalars[i]->getId();
1032        }
1033        else
1034        {
1035          size_t iDomain = 0, iAxis = 0, iScalar = 0;
1036          for (size_t i = 0; i < axisDomainOrder.numElements(); ++i)
1037          {
1038            if (2 == axisDomainOrder(i))
1039              id << "_" << domains[iDomain++]->getId();
1040            else if (1 == axisDomainOrder(i))
1041              id << "_" << axis[iAxis++]->getId();
1042            else
1043              id << "_" << scalars[iScalar++]->getId();
1044          }
1045        }
1046
1047        id << "__";
1048      }
1049
1050      return id.str();
1051   }
1052   CATCH
1053
1054   StdString CGrid::generateId(const CGrid* gridSrc, const CGrid* gridDest)
1055   TRY
1056   {
1057     StdString idSrc  = gridSrc->getId();
1058     StdString idDest = gridDest->getId();
1059
1060     std::ostringstream id;
1061     id << idSrc << "__" << idDest;
1062
1063     return id.str();
1064   }
1065   CATCH
1066
1067
1068   //----------------------------------------------------------------
1069
1070   
1071 
1072 
1073  /*
1074     Compute on the fly the global dimension of a grid with its elements
1075     \param[in/out] globalDim global dimension of grid
1076     \param[in] domains list of its domains
1077     \param[in] axiss list of its axis
1078     \param[in] scalars list of its scalars
1079     \param[in] axisDomainOrder the order of element in a grid (e.g: scalar then axis)
1080     \return The dimension of which we do distribution (often for server)
1081  */
1082  int CGrid::computeGridGlobalDimension(std::vector<int>& globalDim,
1083                                        const std::vector<CDomain*> domains,
1084                                        const std::vector<CAxis*> axis,
1085                                        const std::vector<CScalar*> scalars,
1086                                        const CArray<int,1>& axisDomainOrder)
1087  TRY
1088 {
1089 //   globalDim.resize(domains.size()*2+axis.size()+scalars.size());
1090    globalDim.resize(domains.size()*2+axis.size());
1091    int positionDimensionDistributed = 1;
1092    int idx = 0, idxDomain = 0, idxAxis = 0, idxScalar = 0;
1093    for (int i = 0; i < axisDomainOrder.numElements(); ++i)
1094    {
1095      if (2 == axisDomainOrder(i))
1096      {
1097        if (!(domains[idxDomain]->type.isEmpty()) && (domains[idxDomain]->type==CDomain::type_attr::unstructured))
1098        {
1099          positionDimensionDistributed = idx;
1100        }
1101        else
1102        {
1103          positionDimensionDistributed = idx +1;
1104        }
1105
1106        globalDim[idx]   = domains[idxDomain]->ni_glo.getValue();
1107        globalDim[idx+1] = domains[idxDomain]->nj_glo.getValue();
1108
1109        ++idxDomain;
1110        idx += 2;
1111      }
1112      else if (1 == axisDomainOrder(i))
1113      {
1114        globalDim[idx] = axis[idxAxis]->n_glo.getValue();
1115        ++idxAxis;
1116        ++idx;
1117      }
1118      else
1119      {
1120//        globalDim[idx] = 1;
1121        ++idxScalar;
1122//        ++idx;
1123      }
1124    }
1125
1126    return positionDimensionDistributed;
1127  }
1128  CATCH_DUMP_ATTR
1129
1130  // Retrieve the global dimension of grid
1131  std::vector<int> CGrid::getGlobalDimension()
1132  TRY
1133  {
1134    std::vector<int> globalDim;
1135    computeGridGlobalDimension(globalDim, getDomains(), getAxis(), getScalars(), axis_domain_order);
1136
1137    return globalDim;
1138  }
1139  CATCH_DUMP_ATTR
1140
1141  // Retrieve dimension on which we do distribution (Very often, it should be 2nd dimension)
1142  int CGrid::getDistributedDimension()
1143  TRY
1144  {
1145    std::vector<int> globalDim;
1146    return computeGridGlobalDimension(globalDim, getDomains(), getAxis(), getScalars(), axis_domain_order);   
1147  }
1148  CATCH_DUMP_ATTR
1149
1150  bool CGrid::isScalarGrid() const
1151  TRY
1152  {
1153    return (axisList_.empty() && domList_.empty());
1154  }
1155  CATCH
1156
1157  /*!
1158    Verify whether one server need to write data
1159    There are some cases on which one server has nodata to write. For example, when we
1160    just only want to zoom on a domain.
1161  */
1162  bool CGrid::doGridHaveDataToWrite()
1163  TRY
1164  {
1165     return (0 != getGridLocalElements()->getView(CElementView::FULL)->getSize());
1166  }
1167  CATCH_DUMP_ATTR
1168
1169 
1170  bool CGrid::doGridHaveDataDistributed(CContextClient* client)
1171  TRY
1172  {
1173    // This function is now useless because it will return false only if server and client size are equal to 1
1174    // to be seriously check in future
1175
1176    if (isScalarGrid()) return false;
1177    else if (0 != client)
1178    {
1179      return  (isDataDistributed() ||  (1 != client->clientSize) || (1 != client->serverSize));
1180    }
1181    else
1182      return isDataDistributed();   
1183  }
1184  CATCH_DUMP_ATTR
1185
1186   /*!
1187   \brief Dispatch event received from client
1188      Whenever a message is received in buffer of server, it will be processed depending on
1189   its event type. A new event type should be added in the switch list to make sure
1190   it processed on server side.
1191   \param [in] event: Received message
1192   */
1193  bool CGrid::dispatchEvent(CEventServer& event)
1194  TRY
1195  {
1196
1197    if (SuperClass::dispatchEvent(event)) return true;
1198    else
1199    {
1200      switch(event.type)
1201      {
1202         case EVENT_ID_ADD_DOMAIN :
1203           recvAddDomain(event);
1204           return true;
1205           break;
1206
1207         case EVENT_ID_ADD_AXIS :
1208           recvAddAxis(event);
1209           return true;
1210           break;
1211
1212         case EVENT_ID_ADD_SCALAR :
1213           recvAddScalar(event);
1214           return true;
1215           break;
1216
1217         case EVENT_ID_SEND_MASK :
1218           recvMask(event);
1219           return true;
1220           break;
1221        default :
1222          ERROR("bool CGrid::dispatchEvent(CEventServer& event)",
1223                << "Unknown Event");
1224          return false;
1225      }
1226    }
1227  }
1228  CATCH
1229
1230 
1231
1232  void CGrid::sendGridToFileServer(CContextClient* client)
1233  {
1234    if (sendGridToFileServer_done_.count(client)!=0) return ;
1235    else sendGridToFileServer_done_.insert(client) ;
1236
1237    StdString gridDefRoot("grid_definition");
1238    CGridGroup* gridPtr = CGridGroup::get(gridDefRoot);
1239    gridPtr->sendCreateChild(this->getId(),client);
1240    this->sendAllAttributesToServer(client);
1241    distributeGridToFileServer(client) ;
1242  }
1243
1244
1245  void CGrid::distributeGridToFileServer(CContextClient* client)
1246  {
1247    CContext* context = CContext::getCurrent();
1248    // simple Distribution for now
1249    // distribute over the fisrt element except if it is a scalar
1250    auto& elements = getElements() ;
1251    int posDistributed = 0 ;
1252    for(auto& element : elements)
1253    {
1254      if (element.type==TYPE_DOMAIN) break ;
1255      else if (element.type==TYPE_AXIS) break ;
1256      else if (element.type==TYPE_SCALAR) posDistributed++ ;
1257    }
1258   
1259    vector<CLocalView*> localViews ;
1260    vector<CDistributedView*> remoteViews ;
1261
1262    for(int i=0 ; i<elements.size() ; i++)
1263    {
1264      if (elements[i].type==TYPE_DOMAIN) 
1265      { 
1266         CDomain* domain = (CDomain*) elements[i].ptr ;
1267         domain->computeRemoteElement(client, posDistributed==i ? EDistributionType::BANDS : EDistributionType::NONE) ;
1268         remoteViews.push_back(domain->getRemoteElement(client)->getView(CElementView::FULL)) ;
1269         localViews.push_back(domain->getLocalView(CElementView::FULL)) ;
1270      }
1271      else if (elements[i].type==TYPE_AXIS)
1272      {
1273        CAxis* axis = (CAxis*) elements[i].ptr ;
1274        axis->computeRemoteElement(client, posDistributed==i ? EDistributionType::BANDS : EDistributionType::NONE) ;
1275        remoteViews.push_back(axis->getRemoteElement(client)->getView(CElementView::FULL)) ;
1276        localViews.push_back(axis->getLocalView(CElementView::FULL)) ;
1277      }
1278      else if (elements[i].type==TYPE_SCALAR)
1279      {
1280        CScalar* scalar = (CScalar*) elements[i].ptr ;
1281        scalar->computeRemoteElement(client, posDistributed==i ? EDistributionType::BANDS : EDistributionType::NONE) ;
1282        remoteViews.push_back(scalar->getRemoteElement(client)->getView(CElementView::FULL)) ;
1283        localViews.push_back(scalar->getLocalView(CElementView::FULL)) ;
1284      }
1285    }
1286    CGridRemoteConnector gridRemoteConnector(localViews, remoteViews, context->getIntraComm(), client->getRemoteSize()) ;
1287    gridRemoteConnector.computeConnector() ;
1288   
1289    vector<CScattererConnector*> scattererConnectors ;
1290    CScattererConnector* scattererConnector;
1291    for(int i=0 ; i<elements.size() ; i++)
1292    {
1293      if (elements[i].type==TYPE_DOMAIN) 
1294      { 
1295         CDomain* domain = (CDomain*) elements[i].ptr ;
1296         sendAddDomain(domain->getId(),client) ;
1297         domain->distributeToServer(client, gridRemoteConnector.getDistributedGlobalIndex(i), scattererConnector) ;
1298         scattererConnectors.push_back(scattererConnector) ;
1299      }
1300      else if (elements[i].type==TYPE_AXIS)
1301      {
1302        CAxis* axis = (CAxis*) elements[i].ptr ;
1303        sendAddAxis(axis->getId(),client) ;
1304        axis->distributeToServer(client, gridRemoteConnector.getDistributedGlobalIndex(i), scattererConnector) ;
1305        scattererConnectors.push_back(scattererConnector) ;
1306      }
1307      else if (elements[i].type==TYPE_SCALAR)
1308      {
1309        CScalar* scalar = (CScalar*) elements[i].ptr ;
1310        sendAddScalar(scalar->getId(),client) ;
1311        scalar->distributeToServer(client, gridRemoteConnector.getDistributedGlobalIndex(i), scattererConnector) ;
1312        scattererConnectors.push_back(scattererConnector) ;
1313      }
1314    }
1315
1316    CGridScattererConnector gridScattererConnector(scattererConnectors) ;
1317    CGridLocalConnector* workflowToFull = getGridLocalElements()->getConnector(CElementView::WORKFLOW, CElementView::FULL) ;
1318    CArray<bool,1> maskIn(workflowToFull->getSrcSize()) ;
1319    CArray<bool,1> maskOut(workflowToFull->getDstSize()) ;
1320    maskIn = true ;
1321    workflowToFull->transfer(maskIn,maskOut,false) ;
1322
1323    CEventClient event(getType(), EVENT_ID_SEND_MASK);
1324    CMessage message ;
1325    message<<getId() ; 
1326    gridScattererConnector.transfer(maskOut, client, event, message) ;
1327    for(auto& it : scattererConnectors) delete it ;
1328
1329    vector<CScattererConnector*> clientToServerConnectors ;
1330    vector<CGathererConnector*>  clientFromServerConnectors ;
1331    for(auto& element : elements)
1332    {
1333      if (element.type==TYPE_DOMAIN) 
1334      { 
1335         clientToServerConnectors.push_back(element.domain->getClientToServerConnector(client)) ;
1336         clientFromServerConnectors.push_back(element.domain->getClientFromServerConnector(client)) ;
1337      }
1338      else if (element.type==TYPE_AXIS)
1339      {
1340        clientToServerConnectors.push_back(element.axis->getClientToServerConnector(client)) ;
1341        clientFromServerConnectors.push_back(element.axis->getClientFromServerConnector(client)) ;
1342
1343      }
1344      else if (element.type==TYPE_SCALAR)
1345      {
1346        clientToServerConnectors.push_back(element.scalar->getClientToServerConnector(client)) ;
1347        clientFromServerConnectors.push_back(element.scalar->getClientFromServerConnector(client)) ;
1348      }
1349    }
1350   
1351    // compute the grid clientToServerConnector to send flux from client to servers
1352    clientToServerConnector_[client] = new CGridScattererConnector(clientToServerConnectors) ;
1353    clientFromServerConnector_[client] = new CGridGathererConnector(clientFromServerConnectors) ;
1354
1355
1356  }
1357
1358  void CGrid::recvMask(CEventServer& event)
1359  {
1360    string gridId;
1361    for (auto& subEvent : event.subEvents) (*subEvent.buffer) >> gridId  ;
1362    get(gridId)->receiveMask(event);
1363  }
1364 
1365  void CGrid::receiveMask(CEventServer& event)
1366  {
1367    vector<CGathererConnector*> gathererConnectors ;
1368    vector<CLocalView*> fullViews ;
1369
1370    for(auto& element : getElements())
1371    {
1372      if (element.type==TYPE_DOMAIN) 
1373      {
1374        gathererConnectors.push_back(element.domain->getGathererConnector());
1375        fullViews.push_back(element.domain->getLocalElement()->getView(CElementView::FULL));
1376       
1377      }
1378      else if (element.type==TYPE_AXIS)
1379      {
1380       gathererConnectors.push_back(element.axis->getGathererConnector());
1381       fullViews.push_back(element.axis->getLocalElement()->getView(CElementView::FULL));
1382      }
1383      else if (element.type==TYPE_SCALAR) 
1384      {
1385        gathererConnectors.push_back(element.scalar->getGathererConnector());
1386        fullViews.push_back(element.scalar->getLocalElement()->getView(CElementView::FULL));
1387      }
1388    }
1389    CGridGathererConnector gridGathererConnector(gathererConnectors) ;
1390    CGridMaskConnector gridMaskConnector(fullViews) ;
1391
1392    CArray<bool,1> maskOut ;
1393    gridGathererConnector.transfer(event,maskOut,false) ;
1394    gridMaskConnector.computeConnector(maskOut) ;
1395
1396    CContextClient* client = event.getContextServer()->getAssociatedClient() ;
1397    int i=0 ;
1398    for(auto& element : getElements())
1399    {
1400      if (element.type==TYPE_DOMAIN) element.domain->setServerMask(gridMaskConnector.getElementMask(i),client);
1401      else if (element.type==TYPE_AXIS) element.axis->setServerMask(gridMaskConnector.getElementMask(i),client);
1402      else if (element.type==TYPE_SCALAR) element.scalar->setServerMask(gridMaskConnector.getElementMask(i),client);
1403      i++ ;
1404    }
1405  }
1406
1407
1408  void CGrid::sendGridToCouplerOut(CContextClient* client, const string& fieldId)
1409  {
1410/*    if (sendGridToCouplerOut_done_.count(client)!=0) return ;
1411    else sendGridToCouplerOut_done_.insert(client) ;
1412 
1413    CContext* context = CContext::getCurrent();
1414    // simple Distribution for now
1415    // distribute over the fisrt element except if it is a scalar
1416    auto& elements = getElements() ;
1417    int posDistributed = 0 ;
1418    for(auto& element : elements)
1419    {
1420      if (element.type==TYPE_DOMAIN) break ;
1421      else if (element.type==TYPE_AXIS) break ;
1422      else if (element.type==TYPE_SCALAR) posDistributed++ ;
1423    }
1424   
1425    vector<CLocalView*> localViews ;
1426    vector<CDistributedView*> remoteViews ;
1427
1428    for(int i=0 ; i<elements.size() ; i++)
1429    {
1430      if (elements[i].type==TYPE_DOMAIN)
1431      {
1432         CDomain* domain = (CDomain*) elements[i].ptr ;
1433         domain->computeRemoteElement(client, posDistributed==i ? EDistributionType::BANDS : EDistributionType::NONE) ;
1434         remoteViews.push_back(domain->getRemoteElement(client)->getView(CElementView::FULL)) ;
1435         localViews.push_back(domain->getLocalView(CElementView::FULL)) ;
1436      }
1437      else if (elements[i].type==TYPE_AXIS)
1438      {
1439        CAxis* axis = (CAxis*) elements[i].ptr ;
1440        axis->computeRemoteElement(client, posDistributed==i ? EDistributionType::BANDS : EDistributionType::NONE) ;
1441        remoteViews.push_back(axis->getRemoteElement(client)->getView(CElementView::FULL)) ;
1442        localViews.push_back(axis->getLocalView(CElementView::FULL)) ;
1443      }
1444      else if (elements[i].type==TYPE_SCALAR)
1445      {
1446        CScalar* scalar = (CScalar*) elements[i].ptr ;
1447        scalar->computeRemoteElement(client, posDistributed==i ? EDistributionType::BANDS : EDistributionType::NONE) ;
1448        remoteViews.push_back(scalar->getRemoteElement(client)->getView(CElementView::FULL)) ;
1449        localViews.push_back(scalar->getLocalView(CElementView::FULL)) ;
1450      }
1451    }
1452    CGridRemoteConnector gridRemoteConnector(localViews, remoteViews, context->getIntraComm(), client->getRemoteSize()) ;
1453    gridRemoteConnector.computeConnector() ;
1454   
1455    vector<CScattererConnector*> clientToClientConnectors ;
1456    for(int i=0 ; i<elements.size() ; i++)
1457    {
1458      if (elements[i].type==TYPE_DOMAIN)
1459      {
1460         CDomain* domain = (CDomain*) elements[i].ptr ;
1461         sendAddDomain(domain->getId(),client) ;
1462         domain->distributeToServer(client, gridRemoteConnector.getDistributedGlobalIndex(i)) ;
1463         clientToClientConnectors.push_back(domain->getClientToServerConnector(client)) ;
1464      }
1465      else if (elements[i].type==TYPE_AXIS)
1466      {
1467        CAxis* axis = (CAxis*) elements[i].ptr ;
1468        sendAddAxis(axis->getId(),client) ;
1469        axis->distributeToServer(client, gridRemoteConnector.getDistributedGlobalIndex(i)) ;
1470        clientToClientConnectors.push_back(axis->getClientToServerConnector(client)) ;
1471      }
1472      else if (elements[i].type==TYPE_SCALAR)
1473      {
1474        CScalar* scalar = (CScalar*) elements[i].ptr ;
1475        sendAddScalar(scalar->getId(),client) ;
1476        scalar->distributeToServer(client, gridRemoteConnector.getDistributedGlobalIndex(i)) ;
1477        clientToClientConnectors.push_back(scalar->getClientToServerConnector(client)) ;
1478      }
1479    }
1480   
1481    // compute the grid clientToServerConnector to send flux from client to servers
1482    clientToClientConnector_[client] = new CGridScattererConnector(clientToClientConnectors) ;*/
1483  }
1484
1485  void CGrid::makeAliasForCoupling(const string& fieldId)
1486  {
1487    string gridId="_grid_of_"+fieldId ;
1488    createAlias(gridId) ;
1489   
1490    const auto& domVect = getDomains() ;
1491    for (int pos=0; pos<domVect.size();pos++) domVect[pos]->makeAliasForCoupling(fieldId, pos);
1492
1493    const auto& axisVect=getAxis() ;
1494    for (int pos=0; pos<axisVect.size();pos++) axisVect[pos]->makeAliasForCoupling(fieldId, pos);
1495
1496    const auto& scalVect=getScalars() ;
1497    for (int pos=0; pos<scalVect.size();pos++) scalVect[pos]->makeAliasForCoupling(fieldId, pos);
1498  }
1499
1500   /*!
1501   \brief Send a message to create a domain on server side
1502   \param[in] id String identity of domain that will be created on server
1503   */
1504   void CGrid::sendAddDomain(const string& id, CContextClient* contextClient)
1505   TRY
1506  {
1507      sendAddItem(id, (int)EVENT_ID_ADD_DOMAIN, contextClient);
1508   }
1509   CATCH_DUMP_ATTR
1510
1511   /*!
1512   \brief Send a message to create an axis on server side
1513   \param[in] id String identity of axis that will be created on server
1514   */
1515   void CGrid::sendAddAxis(const string& id, CContextClient* contextClient)
1516   TRY
1517   {
1518      sendAddItem(id, (int)EVENT_ID_ADD_AXIS, contextClient);
1519   }
1520   CATCH_DUMP_ATTR
1521
1522   /*!
1523   \brief Send a message to create a scalar on server side
1524   \param[in] id String identity of scalar that will be created on server
1525   */
1526   void CGrid::sendAddScalar(const string& id, CContextClient* contextClient)
1527   TRY
1528   {
1529      sendAddItem(id, (int)EVENT_ID_ADD_SCALAR, contextClient);
1530   }
1531   CATCH_DUMP_ATTR
1532
1533   /*!
1534   \brief Receive a message annoucing the creation of a domain on server side
1535   \param[in] event Received event
1536   */
1537   void CGrid::recvAddDomain(CEventServer& event)
1538   TRY
1539   {
1540
1541      CBufferIn* buffer = event.subEvents.begin()->buffer;
1542      string id;
1543      *buffer >> id;
1544      get(id)->recvAddDomain(*buffer);
1545   }
1546   CATCH
1547
1548   /*!
1549   \brief Receive a message annoucing the creation of a domain on server side
1550   \param[in] buffer Buffer containing message
1551   */
1552   void CGrid::recvAddDomain(CBufferIn& buffer)
1553   TRY
1554   {
1555      string id;
1556      buffer >> id;
1557      addDomain(id);
1558   }
1559   CATCH_DUMP_ATTR
1560
1561   /*!
1562   \brief Receive a message annoucing the creation of an axis on server side
1563   \param[in] event Received event
1564   */
1565   void CGrid::recvAddAxis(CEventServer& event)
1566   TRY
1567   {
1568
1569      CBufferIn* buffer = event.subEvents.begin()->buffer;
1570      string id;
1571      *buffer >> id;
1572      get(id)->recvAddAxis(*buffer);
1573   }
1574   CATCH
1575
1576   /*!
1577   \brief Receive a message annoucing the creation of an axis on server side
1578   \param[in] buffer Buffer containing message
1579   */
1580   void CGrid::recvAddAxis(CBufferIn& buffer)
1581   TRY
1582   {
1583      string id;
1584      buffer >> id;
1585      addAxis(id);
1586   }
1587   CATCH_DUMP_ATTR
1588
1589   /*!
1590   \brief Receive a message annoucing the creation of an scalar on server side
1591   \param[in] event Received event
1592   */
1593   void CGrid::recvAddScalar(CEventServer& event)
1594   TRY
1595   {
1596
1597      CBufferIn* buffer = event.subEvents.begin()->buffer;
1598      string id;
1599      *buffer >> id;
1600      get(id)->recvAddScalar(*buffer);
1601   }
1602   CATCH
1603
1604   /*!
1605   \brief Receive a message annoucing the creation of an scalar on server side
1606   \param[in] buffer Buffer containing message
1607   */
1608   void CGrid::recvAddScalar(CBufferIn& buffer)
1609   TRY
1610   {
1611      string id;
1612      buffer >> id;
1613      addScalar(id);
1614   }
1615   CATCH_DUMP_ATTR
1616
1617  /*!
1618  \brief Check if all elements of the grid are complete
1619  Before make any grid processing, we must be sure that all grid information elements have
1620  been sent, for exemple when reading a grid in a file or when grid elements are sent by an
1621  other context (coupling)
1622  */
1623  bool CGrid::isCompleted(void)
1624  {
1625    setDomainList();
1626    for (auto domainId : domList_) if (!CDomain::get(domainId)->isCompleted()) return false ;
1627    setAxisList() ;
1628    for (auto axisId : axisList_) if (!CAxis::get(axisId)->isCompleted()) return false ;
1629    setScalarList() ;
1630    for (auto scalarId : scalarList_) if (!CScalar::get(scalarId)->isCompleted()) return false ;
1631    return true ;
1632  }
1633
1634  /*!
1635  \brief impose that all elements of the grid are complete
1636  Before make any grid processing, we must be sure that all grid information elements have
1637  been sent, for exemple when reading a grid in a file or when grid elements are sent by an
1638  other context (coupling)
1639  */
1640  void CGrid::setCompleted(void)
1641  {
1642    setDomainList();
1643    for (auto domainId : domList_) CDomain::get(domainId)->setCompleted() ;
1644    setAxisList() ;
1645    for (auto axisId : axisList_) CAxis::get(axisId)->setCompleted() ;
1646    setScalarList() ;
1647    for (auto scalarId : scalarList_) CScalar::get(scalarId)->setCompleted() ;
1648  }
1649
1650/*!
1651  \brief impose that all elements of the grid are incomplete
1652  Before make any grid processing, we must be sure that all grid information elements have
1653  been sent, for exemple when reading a grid in a file or when grid elements are sent by an
1654  other context (coupling)
1655  */
1656  void CGrid::unsetCompleted(void)
1657  {
1658    setDomainList();
1659    for (auto domainId : domList_) CDomain::get(domainId)->unsetCompleted() ;
1660    setAxisList() ;
1661    for (auto axisId : axisList_) CAxis::get(axisId)->unsetCompleted() ;
1662    setScalarList() ;
1663    for (auto scalarId : scalarList_) CScalar::get(scalarId)->unsetCompleted() ;
1664  }
1665
1666  /*!
1667  \brief Solve domain and axis references
1668  As field, domain and axis can refer to other domains or axis. In order to inherit correctly
1669  all attributes from their parents, they should be processed with this function
1670  \param[in] apply inherit all attributes of parents (true)
1671  */
1672  void CGrid::solveElementsRefInheritance(bool apply)
1673  TRY
1674  {
1675    setDomainList();
1676    for (auto domainId : domList_)
1677    {
1678      CDomain* pDom = CDomain::get(domainId);
1679      pDom->solveRefInheritance(apply);
1680      pDom->solveInheritanceTransformation();
1681    }
1682
1683    setAxisList();
1684    for (auto axisId : axisList_)
1685    {
1686      CAxis* pAxis = CAxis::get(axisId);
1687      pAxis->solveRefInheritance(apply);
1688      pAxis->solveInheritanceTransformation();
1689    }
1690
1691    setScalarList();
1692    for (auto scalarId : scalarList_)
1693    {
1694      CScalar* pScalar = CScalar::get(scalarId);
1695      pScalar->solveRefInheritance(apply);
1696      pScalar->solveInheritanceTransformation();
1697    }
1698  }
1699  CATCH_DUMP_ATTR
1700
1701 /*!
1702  \brief check attributes of all elements of the grid
1703  */
1704  void CGrid::checkElementsAttributes(void)
1705  TRY
1706  {
1707    setDomainList();
1708    for (auto domainId : domList_) CDomain::get(domainId)->checkAttributes();
1709
1710    setAxisList();
1711    for (auto axisId : axisList_) CAxis::get(axisId)->checkAttributes();
1712   
1713    setScalarList();
1714    for (auto scalarId : scalarList_) CScalar::get(scalarId)->checkAttributes();
1715  }
1716  CATCH_DUMP_ATTR
1717
1718  bool CGrid::isTransformed()
1719  TRY
1720  {
1721    return isTransformed_;
1722  }
1723  CATCH_DUMP_ATTR
1724
1725  void CGrid::setTransformed()
1726  TRY
1727  {
1728    isTransformed_ = true;
1729  }
1730  CATCH_DUMP_ATTR
1731
1732  CGridTransformation* CGrid::getTransformations()
1733  TRY
1734  {
1735    return transformations_;
1736  }
1737  CATCH_DUMP_ATTR
1738
1739  void CGrid::addTransGridSource(CGrid* gridSrc)
1740  TRY
1741  {
1742    if (gridSrc_.end() == gridSrc_.find(gridSrc))
1743      gridSrc_.insert(make_pair(gridSrc,make_pair(false,"")));
1744  }
1745  CATCH_DUMP_ATTR
1746
1747  std::map<CGrid*,std::pair<bool,StdString> >& CGrid::getTransGridSource()
1748  TRY
1749  {
1750    return gridSrc_;
1751  }
1752  CATCH_DUMP_ATTR
1753
1754  /*!
1755     Complete all the necessary (and lacking) attributes of a grid
1756     This function is similar to gridTransformation but works only (till now) on generate_rectilinear_domain transformation
1757  */
1758  void CGrid::completeGrid(CGrid* transformGridSrc)
1759  TRY
1760  {
1761    if (nullptr != transformGridSrc)
1762    {
1763      if (axis_domain_order.numElements() != transformGridSrc->axis_domain_order.numElements())
1764      {
1765        ERROR("CGrid::completeGrid(CGrid* transformGridSrc)",
1766             << "Two grids have different number of elements. " << std::endl
1767             << "Number of element of grid destination " << this->getId() << " is " << axis_domain_order.numElements() << std::endl
1768             << "Number of element of grid source " << transformGridSrc->getId() << " is " << transformGridSrc->axis_domain_order.numElements());
1769      }
1770    }
1771
1772    if (isGenerated()) return;
1773    setGenerated();
1774
1775    CGridGenerate gridGenerate(this, transformGridSrc);
1776    gridGenerate.completeGrid();
1777  }
1778  CATCH_DUMP_ATTR
1779
1780  bool CGrid::isGenerated()
1781  TRY
1782  {
1783    return isGenerated_;
1784  }
1785  CATCH
1786
1787  void CGrid::setGenerated()
1788  TRY
1789  {
1790    isGenerated_ = true;
1791  }
1792  CATCH_DUMP_ATTR
1793
1794  void CGrid::transformGrid(CGrid* transformGridSrc)
1795  TRY
1796  {
1797    if (!transformGridSrc)
1798      ERROR("CGrid::transformGrid(CGrid* transformGridSrc)",
1799            << "Impossible to transform grid '" << getId() << "', the source grid is null.");
1800
1801    if (isTransformed()) return;
1802    setTransformed();
1803    if (axis_domain_order.numElements() != transformGridSrc->axis_domain_order.numElements())
1804    {
1805      ERROR("CGrid::transformGrid(CGrid* transformGridSrc)",
1806           << "Two grids have different number of elements. " << std::endl
1807           << "Number of element of grid destination " << this->getId() << " is " << axis_domain_order.numElements() << std::endl
1808           << "Number of element of grid source " << transformGridSrc->getId() << " is " << transformGridSrc->axis_domain_order.numElements());
1809    }
1810    else
1811    {
1812    }
1813
1814    transformations_ = new CGridTransformation(this, transformGridSrc);
1815    transformations_->computeAll();
1816    if (0 < transformations_->getNbAlgo()) hasTransform_ = true;
1817
1818 }
1819  CATCH_DUMP_ATTR
1820
1821
1822
1823
1824  void CGrid::prepareTransformGrid(CGrid* transformGridSrc)
1825  TRY
1826  {
1827    if (prepareTransformGrid_done_) return ;
1828
1829    if (!transformGridSrc)
1830      ERROR("CGrid::transformGrid(CGrid* transformGridSrc)",
1831            << "Impossible to transform grid '" << getId() << "', the source grid is null.");
1832
1833    if (isTransformed()) return;
1834    setTransformed();
1835    if (axis_domain_order.numElements() != transformGridSrc->axis_domain_order.numElements())
1836    {
1837      ERROR("CGrid::transformGrid(CGrid* transformGridSrc)",
1838           << "Two grids have different number of elements. " << std::endl
1839           << "Number of element of grid destination " << this->getId() << " is " << axis_domain_order.numElements() << std::endl
1840           << "Number of element of grid source " << transformGridSrc->getId() << " is " << transformGridSrc->axis_domain_order.numElements());
1841    }
1842    else
1843    {
1844    }
1845
1846    transformations_ = new CGridTransformation(this, transformGridSrc);
1847    if (0 < transformations_->getNbAlgo()) hasTransform_ = true;
1848
1849    prepareTransformGrid_done_ = true; 
1850  }
1851  CATCH_DUMP_ATTR
1852
1853
1854  void CGrid::makeTransformGrid(void)
1855  TRY
1856  {
1857    if (makeTransformGrid_done_) return ;
1858    transformations_->computeAll();
1859
1860    makeTransformGrid_done_ = true ; 
1861  }
1862  CATCH_DUMP_ATTR
1863
1864
1865  vector<std::string> CGrid::getAuxInputTransformGrid(void)
1866  TRY
1867  {
1868    if (transformations_ != nullptr) return transformations_->getAuxInputs() ;
1869  }
1870  CATCH_DUMP_ATTR
1871
1872
1873
1874
1875
1876
1877
1878  bool CGrid::hasTransform()
1879  TRY
1880  {
1881    if (hasTransform_) return hasTransform_;
1882
1883    std::vector<CDomain*> domList = getDomains();
1884    std::vector<CAxis*> axisList = getAxis();
1885    std::vector<CScalar*> scalarList = getScalars();
1886
1887    for (int idx = 0; idx < domList.size(); ++idx) hasTransform_ |= domList[idx]->hasTransformation();
1888    for (int idx = 0; idx < axisList.size(); ++idx) hasTransform_ |= axisList[idx]->hasTransformation();
1889    for (int idx = 0; idx < scalarList.size(); ++idx) hasTransform_ |= scalarList[idx]->hasTransformation();
1890
1891    return hasTransform_;
1892  }
1893  CATCH_DUMP_ATTR
1894
1895  void CGrid::setContextClient(CContextClient* contextClient)
1896  TRY
1897  {
1898    if (clientsSet.find(contextClient)==clientsSet.end())
1899    {
1900      clients.push_back(contextClient) ;
1901      clientsSet.insert(contextClient);
1902    }
1903    for (auto domain : getDomains()) domain->setContextClient(contextClient);
1904    for (auto axis : getAxis()) axis->setContextClient(contextClient);
1905    for (auto scalar : getScalars()) scalar->setContextClient(contextClient);
1906   
1907  }
1908  CATCH_DUMP_ATTR
1909
1910 
1911  void CGrid::computeGridLocalElements()
1912  {
1913    std::vector<CDomain*> domainList = this->getDomains();
1914    std::vector<CAxis*> axisList = this->getAxis();
1915    std::vector<CScalar*> scalarList = this->getScalars();
1916    auto domain=domainList.begin() ;
1917    auto axis=axisList.begin() ;
1918    auto scalar=scalarList.begin() ;
1919    vector<CLocalElement*> elements;
1920    for(auto order : order_)
1921    {
1922      if (order==2) 
1923      {
1924        elements.push_back((*domain)->getLocalElement());
1925        domain++ ;
1926      }
1927      else if (order==1)
1928      {
1929        elements.push_back((*axis)->getLocalElement());
1930        axis++ ;
1931      }
1932      else if (order==0)
1933      { 
1934        elements.push_back((*scalar)->getLocalElement());
1935        scalar++ ;
1936      }
1937    }
1938    if (hasMask()) 
1939    {
1940      vector<bool> mask(getMask().getVector()) ;
1941      gridLocalElements_ = new CGridLocalElements(elements, mask) ; 
1942    }
1943    else gridLocalElements_ = new CGridLocalElements(elements) ; 
1944  }
1945
1946  void CGrid::computeModelToWorkflowConnector(void)
1947  {
1948    modelToWorkflowConnector_ = getGridLocalElements()->getConnector(CElementView::MODEL,CElementView::WORKFLOW,true) ;
1949  }
1950
1951  void CGrid::computeWorkflowToFullConnector(void)
1952  {
1953    workflowToFullConnector_ = getGridLocalElements()->getConnector(CElementView::WORKFLOW,CElementView::FULL) ;
1954  }
1955
1956  void CGrid::computeWorkflowToModelConnector(void)
1957  {
1958    workflowToModelConnector_ = getGridLocalElements()->getConnector(CElementView::WORKFLOW,CElementView::MODEL,true) ;
1959  }
1960
1961  void CGrid::computeFullToWorkflowConnector(void)
1962  {
1963    fullToWorkflowConnector_ = getGridLocalElements()->getConnector(CElementView::FULL,CElementView::WORKFLOW) ;
1964  }
1965
1966  void CGrid::computeServerFromClientConnector(void)
1967  {
1968    vector<CGathererConnector*> connectors ;
1969    for(auto& element : getElements())
1970    {
1971      if (element.type==TYPE_DOMAIN) connectors.push_back(element.domain->getServerFromClientConnector()) ;
1972      else if (element.type==TYPE_AXIS) connectors.push_back(element.axis->getServerFromClientConnector()) ; 
1973      else if (element.type==TYPE_SCALAR) connectors.push_back(element.scalar->getServerFromClientConnector()) ; 
1974    }
1975    serverFromClientConnector_ = new CGridGathererConnector(connectors) ;
1976  }
1977
1978  void CGrid::computeServerToClientConnector(void)
1979  {
1980    vector<CScattererConnector*> connectors ;
1981    for(auto& element : getElements())
1982    {
1983      if (element.type==TYPE_DOMAIN) connectors.push_back(element.domain->getServerToClientConnector()) ;
1984      else if (element.type==TYPE_AXIS) connectors.push_back(element.axis->getServerToClientConnector()) ; 
1985      else if (element.type==TYPE_SCALAR) connectors.push_back(element.scalar->getServerToClientConnector()) ; 
1986    }
1987    serverToClientConnector_ = new CGridScattererConnector(connectors) ;
1988  }
1989
1990  void CGrid::computeClientFromClientConnector(void)
1991  {
1992    vector<CGathererConnector*> connectors ;
1993    for(auto& element : getElements())
1994    {
1995      if (element.type==TYPE_DOMAIN) connectors.push_back(element.domain->getServerFromClientConnector()) ;
1996      else if (element.type==TYPE_AXIS) connectors.push_back(element.axis->getServerFromClientConnector()) ; 
1997      else if (element.type==TYPE_SCALAR) connectors.push_back(element.scalar->getServerFromClientConnector()) ; 
1998    }
1999    clientFromClientConnector_ = new CGridGathererConnector(connectors) ;
2000  }
2001
2002 
2003} // namespace xios
Note: See TracBrowser for help on using the repository browser.