Index: XIOS/trunk/src/node/grid.cpp
===================================================================
--- XIOS/trunk/src/node/grid.cpp	(revision 619)
+++ XIOS/trunk/src/node/grid.cpp	(revision 620)
@@ -14,6 +14,4 @@
 #include "array_new.hpp"
 #include "client_server_mapping_distributed.hpp"
-#include "invert_algorithm.hpp"
-#include "visitable.hpp"
 
 namespace xios {
@@ -26,5 +24,6 @@
       , vDomainGroup_(), vAxisGroup_(), axisList_(), isAxisListSet(false), isDomListSet(false), clientDistribution_(0), isIndexSent(false)
       , serverDistribution_(0), serverDistributionDescription_(0), clientServerMap_(0), writtenDataSize_(0), globalDim_()
-      , connectedDataSize_(), connectedServerRank_(), isDataDistributed_(true), algorithms_(), transformations_(), isTransformed_(false)
+      , connectedDataSize_(), connectedServerRank_(), isDataDistributed_(true), transformations_(0), isTransformed_(false)
+      , axisPositionInGrid_()
    {
      setVirtualDomainGroup();
@@ -37,5 +36,6 @@
       , vDomainGroup_(), vAxisGroup_(), axisList_(), isAxisListSet(false), isDomListSet(false), clientDistribution_(0), isIndexSent(false)
       , serverDistribution_(0), serverDistributionDescription_(0), clientServerMap_(0), writtenDataSize_(0), globalDim_()
-      , connectedDataSize_(), connectedServerRank_(), isDataDistributed_(true), algorithms_(), transformations_(), isTransformed_(false)
+      , connectedDataSize_(), connectedServerRank_(), isDataDistributed_(true), transformations_(0), isTransformed_(false)
+      , axisPositionInGrid_()
    {
      setVirtualDomainGroup();
@@ -53,5 +53,5 @@
     if (0 != serverDistribution_) delete serverDistribution_;
     if (0 != serverDistributionDescription_) delete serverDistributionDescription_;
-    for (std::vector<CGenericAlgorithm*>::iterator it = algorithms_.begin(); it != algorithms_.end(); ++it) delete *it;
+    if (0 != transformations_) delete transformations_;
    }
 
@@ -324,10 +324,10 @@
       {
         int idx = 0;
-        std::vector<int> axisPositionMap;
+        axisPositionInGrid_.resize(0);
         for (int i = 0; i < axis_domain_order.numElements(); ++i)
         {
           if (false == axis_domain_order(i))
           {
-            axisPositionMap.push_back(idx);
+            axisPositionInGrid_.push_back(idx);
             ++idx;
           }
@@ -339,7 +339,7 @@
         {
           if (sendAtt)
-            axisListP[i]->sendCheckedAttributes(globalDim_,axisPositionMap[i]);
+            axisListP[i]->sendCheckedAttributes(globalDim_,axisPositionInGrid_[i]);
           else
-            axisListP[i]->checkAttributesOnClient(globalDim_,axisPositionMap[i]);
+            axisListP[i]->checkAttributesOnClient(globalDim_,axisPositionInGrid_[i]);
           ++idx;
         }
@@ -347,4 +347,10 @@
       }
    }
+
+   std::vector<int> CGrid::getAxisPositionInGrid() const
+   {
+     return axisPositionInGrid_;
+   }
+
 
    //---------------------------------------------------------------
@@ -759,4 +765,9 @@
   {
     return serverDistribution_;
+  }
+
+  const CDistributionClient* CGrid::getDistributionClient() const
+  {
+    return clientDistribution_;
   }
 
@@ -1103,67 +1114,17 @@
   }
 
-  CGrid::EElementType CGrid::getGridElementType()
-  {
-    EElementType gridType = GRID_ONLY_AXIS;
-    int numElements = axis_domain_order.numElements();
-    if (1 == numElements)
-    {
-      if (true == axis_domain_order(0)) gridType = GRID_ONLY_DOMAIN;
-    }
-    else gridType = GRID_AXIS_DOMAIN;
-  }
-
-  void CGrid::solveTransformations()
-  {
-    std::vector<CAxis*> axisPtr = getAxis();
-    for (std::vector<CAxis*>::iterator it = axisPtr.begin(); it != axisPtr.end(); ++it)
-    {
-      std::vector<ETransformationType> axisTransformation = (*it)->getTransformations();
-      std::vector<ETransformationType>::iterator itTrans  = axisTransformation.begin(),
-                                                 iteTrans = axisTransformation.end();
-      for (;itTrans != iteTrans; ++ itTrans)
-        transformations_.push_back(*itTrans);
-    }
-  }
-
-  void CGrid::setTransformationAlgorithms()
-  {
-    std::vector<ETransformationType>::iterator itTrans  = transformations_.begin(),
-                                               iteTrans = transformations_.end();
-    std::set<ETransformationType> tmp;
-    for (; itTrans != iteTrans; ++itTrans)
-    {
-      if (tmp.end() == tmp.find(*itTrans))
-      {
-        switch (*itTrans) {
-        case eInverse:
-          algorithms_.push_back(new CInvertAlgorithm());
-          break;
-        default:
-          break;
-        }
-      }
-      tmp.insert(*itTrans);
-    }
-  }
-
-  std::vector<ETransformationType> CGrid::getTransformations()
+  bool CGrid::isTransformed()
+  {
+    return isTransformed_;
+  }
+
+  void CGrid::setTransformed()
+  {
+    isTransformed_ = true;
+  }
+
+  CGridTransformation* CGrid::getTransformations()
   {
     return transformations_;
-  }
-
-  bool CGrid::isTransformed()
-  {
-    return isTransformed_;
-  }
-
-  void CGrid::setTransformed()
-  {
-    isTransformed_ = true;
-  }
-
-  const std::vector<CGenericAlgorithm*>& CGrid::getTransformationAlgo()
-  {
-    return algorithms_;
   }
 
@@ -1189,22 +1150,8 @@
     }
 
-    EElementType gridType = getGridElementType();
-    CGenericTransformation* gTransform = 0;
-    switch (gridType) {
-    case GRID_ONLY_AXIS:
-      gTransform = new CAxisTransformation(this->getAxis(), transformedGrid->getAxis());
-      break;
-    case GRID_ONLY_DOMAIN:
-      break;
-    case GRID_AXIS_DOMAIN:
-      break;
-    default:
-      break;
-    }
-
-    transformedGrid->solveTransformations();
-    transformedGrid->setTransformationAlgorithms();
-    gTransform->apply(transformedGrid->algorithms_);
-    if (0 != gTransform) delete gTransform;
+    transformations_ = new CGridTransformation(transformedGrid, this);
+    transformations_->computeTransformationMapping();
+    std::cout << "send index " << *(transformations_->getLocalIndexToSendFromGridSource()[0]) << std::endl;
+    std::cout << "receive index " << *(transformations_->getLocalIndexToReceiveOnGridDest()[0][0]) << std::endl;
   }
 
