Salome HOME
Merge branch 'master' of https://codev-tuleap.cea.fr/plugins/git/salome/medcoupling
[tools/medcoupling.git] / src / MEDCoupling / MEDCouplingIMesh.cxx
old mode 100644 (file)
new mode 100755 (executable)
index 0e2eeca..d28b5c0
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2014  CEA/DEN, EDF R&D
+// Copyright (C) 2007-2020  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
@@ -16,7 +16,7 @@
 //
 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
-// Author : Anthony Geay (CEA/DEN)
+// Author : Anthony Geay (EDF R&D)
 
 #include "MEDCouplingIMesh.hxx"
 #include "MEDCouplingCMesh.hxx"
@@ -28,7 +28,7 @@
 #include <sstream>
 #include <numeric>
 
-using namespace ParaMEDMEM;
+using namespace MEDCoupling;
 
 MEDCouplingIMesh::MEDCouplingIMesh():_space_dim(-1)
 {
@@ -37,7 +37,7 @@ MEDCouplingIMesh::MEDCouplingIMesh():_space_dim(-1)
   _structure[0]=0; _structure[1]=0; _structure[2]=0;
 }
 
-MEDCouplingIMesh::MEDCouplingIMesh(const MEDCouplingIMesh& other, bool deepCopy):MEDCouplingStructuredMesh(other,deepCopy),_space_dim(other._space_dim),_axis_unit(other._axis_unit)
+MEDCouplingIMesh::MEDCouplingIMesh(const MEDCouplingIMesh& other, bool deepCpy):MEDCouplingStructuredMesh(other,deepCpy),_space_dim(other._space_dim),_axis_unit(other._axis_unit)
 {
   _origin[0]=other._origin[0]; _origin[1]=other._origin[1]; _origin[2]=other._origin[2];
   _dxyz[0]=other._dxyz[0]; _dxyz[1]=other._dxyz[1]; _dxyz[2]=other._dxyz[2];
@@ -53,10 +53,10 @@ MEDCouplingIMesh *MEDCouplingIMesh::New()
   return new MEDCouplingIMesh;
 }
 
-MEDCouplingIMesh *MEDCouplingIMesh::New(const std::string& meshName, int spaceDim, const int *nodeStrctStart, const int *nodeStrctStop,
+MEDCouplingIMesh *MEDCouplingIMesh::New(const std::string& meshName, int spaceDim, const mcIdType *nodeStrctStart, const mcIdType *nodeStrctStop,
                                         const double *originStart, const double *originStop, const double *dxyzStart, const double *dxyzStop)
 {
-  MEDCouplingAutoRefCountObjectPtr<MEDCouplingIMesh> ret(new MEDCouplingIMesh);
+  MCAuto<MEDCouplingIMesh> ret(new MEDCouplingIMesh);
   ret->setName(meshName);
   ret->setSpaceDimension(spaceDim);
   ret->setNodeStruct(nodeStrctStart,nodeStrctStop);
@@ -65,7 +65,7 @@ MEDCouplingIMesh *MEDCouplingIMesh::New(const std::string& meshName, int spaceDi
   return ret.retn();
 }
 
-MEDCouplingMesh *MEDCouplingIMesh::deepCpy() const
+MEDCouplingIMesh *MEDCouplingIMesh::deepCopy() const
 {
   return clone(true);
 }
@@ -75,6 +75,11 @@ MEDCouplingIMesh *MEDCouplingIMesh::clone(bool recDeepCpy) const
   return new MEDCouplingIMesh(*this,recDeepCpy);
 }
 
+const DataArrayDouble *MEDCouplingIMesh::getDirectAccessOfCoordsArrIfInStructure() const
+{
+  throw INTERP_KERNEL::Exception("MEDCouplingIMesh::getDirectAccessOfCoordsArrIfInStructure : MEDCouplingIMesh does not aggregate array of coordinates !");
+}
+
 /*!
  * This method creates a copy of \a this enlarged by \a ghostLev cells on each axis.
  * If \a ghostLev equal to 0 this method behaves as MEDCouplingIMesh::clone.
@@ -83,45 +88,45 @@ MEDCouplingIMesh *MEDCouplingIMesh::clone(bool recDeepCpy) const
  * \return MEDCouplingIMesh * - a newly alloacted object to be managed by the caller.
  * \throw if \a ghostLev < 0.
  */
-MEDCouplingIMesh *MEDCouplingIMesh::buildWithGhost(int ghostLev) const
+MEDCouplingIMesh *MEDCouplingIMesh::buildWithGhost(mcIdType ghostLev) const
 {
   if(ghostLev<0)
     throw INTERP_KERNEL::Exception("MEDCouplingIMesh::buildWithGhost : the ghostLev must be >= 0 !");
-  checkCoherency();
+  checkConsistencyLight();
   int spaceDim(getSpaceDimension());
   double origin[3],dxyz[3];
-  int structure[3];
+  mcIdType structure[3];
   for(int i=0;i<spaceDim;i++)
     {
-      origin[i]=_origin[i]-ghostLev*_dxyz[i];
+      origin[i]=_origin[i]-FromIdType<double>(ghostLev)*_dxyz[i];
       dxyz[i]=_dxyz[i];
       structure[i]=_structure[i]+2*ghostLev;
     }
-  MEDCouplingAutoRefCountObjectPtr<MEDCouplingIMesh> ret(MEDCouplingIMesh::New(getName(),spaceDim,structure,structure+spaceDim,origin,origin+spaceDim,dxyz,dxyz+spaceDim));
+  MCAuto<MEDCouplingIMesh> ret(MEDCouplingIMesh::New(getName(),spaceDim,structure,structure+spaceDim,origin,origin+spaceDim,dxyz,dxyz+spaceDim));
   ret->copyTinyInfoFrom(this);
   return ret.retn();
 }
 
-void MEDCouplingIMesh::setNodeStruct(const int *nodeStrctStart, const int *nodeStrctStop)
+void MEDCouplingIMesh::setNodeStruct(const mcIdType *nodeStrctStart, const mcIdType *nodeStrctStop)
 {
   checkSpaceDimension();
-  int sz((int)std::distance(nodeStrctStart,nodeStrctStop));
+  mcIdType sz((mcIdType)std::distance(nodeStrctStart,nodeStrctStop));
   if(sz!=_space_dim)
     throw INTERP_KERNEL::Exception("MEDCouplingIMesh::setNodeStruct : input vector of node structure has not the right size ! Or change space dimension before calling it !");
   std::copy(nodeStrctStart,nodeStrctStop,_structure);
   declareAsNew();
 }
 
-std::vector<int> MEDCouplingIMesh::getNodeStruct() const
+std::vector<mcIdType> MEDCouplingIMesh::getNodeStruct() const
 {
   checkSpaceDimension();
-  return std::vector<int>(_structure,_structure+_space_dim);
+  return std::vector<mcIdType>(_structure,_structure+_space_dim);
 }
 
 void MEDCouplingIMesh::setOrigin(const double *originStart, const double *originStop)
 {
   checkSpaceDimension();
-  int sz((int)std::distance(originStart,originStop));
+  mcIdType sz(ToIdType(std::distance(originStart,originStop)));
   if(sz!=_space_dim)
     throw INTERP_KERNEL::Exception("MEDCouplingIMesh::setOrigin : input vector of origin vector has not the right size ! Or change space dimension before calling it !");
   std::copy(originStart,originStop,_origin);
@@ -137,7 +142,7 @@ std::vector<double> MEDCouplingIMesh::getOrigin() const
 void MEDCouplingIMesh::setDXYZ(const double *dxyzStart, const double *dxyzStop)
 {
   checkSpaceDimension();
-  int sz((int)std::distance(dxyzStart,dxyzStop));
+  mcIdType sz(ToIdType(std::distance(dxyzStart,dxyzStop)));
   if(sz!=_space_dim)
     throw INTERP_KERNEL::Exception("MEDCouplingIMesh::setDXYZ : input vector of dxyz vector has not the right size ! Or change space dimension before calling it !");
   std::copy(dxyzStart,dxyzStop,_dxyz);
@@ -170,7 +175,7 @@ std::string MEDCouplingIMesh::getAxisUnit() const
  */
 double MEDCouplingIMesh::getMeasureOfAnyCell() const
 {
-  checkCoherency();
+  checkConsistencyLight();
   int dim(getSpaceDimension());
   double ret(1.);
   for(int i=0;i<dim;i++)
@@ -187,8 +192,8 @@ double MEDCouplingIMesh::getMeasureOfAnyCell() const
  */
 MEDCouplingCMesh *MEDCouplingIMesh::convertToCartesian() const
 {
-  checkCoherency();
-  MEDCouplingAutoRefCountObjectPtr<MEDCouplingCMesh> ret(MEDCouplingCMesh::New());
+  checkConsistencyLight();
+  MCAuto<MEDCouplingCMesh> ret(MEDCouplingCMesh::New());
   try
   { ret->copyTinyInfoFrom(this); }
   catch(INTERP_KERNEL::Exception& ) { }
@@ -196,7 +201,7 @@ MEDCouplingCMesh *MEDCouplingIMesh::convertToCartesian() const
   std::vector<std::string> infos(buildInfoOnComponents());
   for(int i=0;i<spaceDim;i++)
     {
-      MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr(DataArrayDouble::New()); arr->alloc(_structure[i],1); arr->setInfoOnComponent(0,infos[i]);
+      MCAuto<DataArrayDouble> arr(DataArrayDouble::New()); arr->alloc(_structure[i],1); arr->setInfoOnComponent(0,infos[i]);
       arr->iota(); arr->applyLin(_dxyz[i],_origin[i]);
       ret->setCoordsAt(i,arr);
     }
@@ -209,12 +214,12 @@ MEDCouplingCMesh *MEDCouplingIMesh::convertToCartesian() const
  * The origin of \a this will be not touched only spacing and node structure will be changed.
  * This method can be useful for AMR users.
  */
-void MEDCouplingIMesh::refineWithFactor(const std::vector<int>& factors)
+void MEDCouplingIMesh::refineWithFactor(const std::vector<mcIdType>& factors)
 {
-  if((int)factors.size()!=_space_dim)
+  if(ToIdType(factors.size())!=_space_dim)
     throw INTERP_KERNEL::Exception("MEDCouplingIMesh::refineWithFactor : refinement factors must have size equal to spaceDim !");
-  checkCoherency();
-  std::vector<int> structure(_structure,_structure+3);
+  checkConsistencyLight();
+  std::vector<mcIdType> structure(_structure,_structure+3);
   std::vector<double> dxyz(_dxyz,_dxyz+3);
   for(int i=0;i<_space_dim;i++)
     {
@@ -223,7 +228,7 @@ void MEDCouplingIMesh::refineWithFactor(const std::vector<int>& factors)
           std::ostringstream oss; oss << "MEDCouplingIMesh::refineWithFactor : factor for axis #" << i << " (" << factors[i] << ")is invalid ! Must be > 0 !";
           throw INTERP_KERNEL::Exception(oss.str().c_str());
         }
-      int factAbs(std::abs(factors[i]));
+      mcIdType factAbs(std::abs(factors[i]));
       double fact2(1./(double)factors[i]);
       structure[i]=(_structure[i]-1)*factAbs+1;
       dxyz[i]=fact2*_dxyz[i];
@@ -238,19 +243,19 @@ void MEDCouplingIMesh::refineWithFactor(const std::vector<int>& factors)
  *
  * \return MEDCouplingIMesh * - A newly created object (to be managed by the caller with decrRef) containing simply one cell.
  *
- * \throw if \a this does not pass the \c checkCoherency test.
+ * \throw if \a this does not pass the \c checkConsistencyLight test.
  */
 MEDCouplingIMesh *MEDCouplingIMesh::asSingleCell() const
 {
-  checkCoherency();
-  int spaceDim(getSpaceDimension()),nodeSt[3];
+  checkConsistencyLight();
+  mcIdType spaceDim(getSpaceDimension()),nodeSt[3];
   double dxyz[3];
   for(int i=0;i<spaceDim;i++)
     {
       if(_structure[i]>=2)
         {
           nodeSt[i]=2;
-          dxyz[i]=(_structure[i]-1)*_dxyz[i];
+          dxyz[i]=double(_structure[i]-1)*_dxyz[i];
         }
       else
         {
@@ -258,14 +263,14 @@ MEDCouplingIMesh *MEDCouplingIMesh::asSingleCell() const
           dxyz[i]=_dxyz[i];
         }
     }
-  MEDCouplingAutoRefCountObjectPtr<MEDCouplingIMesh> ret(MEDCouplingIMesh::New(getName(),getSpaceDimension(),nodeSt,nodeSt+spaceDim,_origin,_origin+spaceDim,dxyz,dxyz+spaceDim));
+  MCAuto<MEDCouplingIMesh> ret(MEDCouplingIMesh::New(getName(),getSpaceDimension(),nodeSt,nodeSt+spaceDim,_origin,_origin+spaceDim,dxyz,dxyz+spaceDim));
   ret->copyTinyInfoFrom(this);
   return ret.retn();
 }
 
 /*!
  * This static method is useful to condense field on cells of a MEDCouplingIMesh instance coming from a refinement ( MEDCouplingIMesh::refineWithFactor for example)
- * to a coarse MEDCouplingIMesh instance. So this method can be seen as a specialization in P0P0 conservative interpolation non overlaping from fine image mesh
+ * to a coarse MEDCouplingIMesh instance. So this method can be seen as a specialization in P0P0 conservative interpolation non overlapping from fine image mesh
  * to a coarse image mesh. Only tuples ( deduced from \a fineLocInCoarse ) of \a coarseDA will be modified. Other tuples of \a coarseDA will be let unchanged.
  *
  * \param [in] coarseSt The cell structure of coarse mesh.
@@ -276,24 +281,25 @@ MEDCouplingIMesh *MEDCouplingIMesh::asSingleCell() const
  *
  * \sa CondenseFineToCoarseGhost,SpreadCoarseToFine
  */
-void MEDCouplingIMesh::CondenseFineToCoarse(const std::vector<int>& coarseSt, const DataArrayDouble *fineDA, const std::vector< std::pair<int,int> >& fineLocInCoarse, const std::vector<int>& facts, DataArrayDouble *coarseDA)
+void MEDCouplingIMesh::CondenseFineToCoarse(const std::vector<mcIdType>& coarseSt, const DataArrayDouble *fineDA, const std::vector< std::pair<mcIdType,mcIdType> >& fineLocInCoarse, const std::vector<mcIdType>& facts, DataArrayDouble *coarseDA)
 {
   if(coarseSt.size()!=fineLocInCoarse.size() || coarseSt.size()!=facts.size())
     throw INTERP_KERNEL::Exception("MEDCouplingIMesh::CondenseFineToCoarse : All input vectors (dimension) must have the same size !");
   if(!coarseDA || !coarseDA->isAllocated() || !fineDA || !fineDA->isAllocated())
     throw INTERP_KERNEL::Exception("MEDCouplingIMesh::CondenseFineToCoarse : the parameters 1 or 3 are NULL or not allocated !");
-  int meshDim((int)coarseSt.size()),nbOfTuplesInCoarseExp(MEDCouplingStructuredMesh::DeduceNumberOfGivenStructure(coarseSt)),nbOfTuplesInFineExp(MEDCouplingStructuredMesh::DeduceNumberOfGivenRangeInCompactFrmt(fineLocInCoarse));
-  int nbCompo(fineDA->getNumberOfComponents());
+  std::size_t meshDim(coarseSt.size());
+  mcIdType nbOfTuplesInCoarseExp(MEDCouplingStructuredMesh::DeduceNumberOfGivenStructure(coarseSt)),nbOfTuplesInFineExp(MEDCouplingStructuredMesh::DeduceNumberOfGivenRangeInCompactFrmt(fineLocInCoarse));
+  std::size_t nbCompo=fineDA->getNumberOfComponents();
   if(coarseDA->getNumberOfComponents()!=nbCompo)
     throw INTERP_KERNEL::Exception("MEDCouplingIMesh::CondenseFineToCoarse : the number of components of fine DA and coarse one mismatches !");
-  if(meshDim!=(int)fineLocInCoarse.size() || meshDim!=(int)facts.size())
+  if(meshDim!=fineLocInCoarse.size() || meshDim!=facts.size())
     throw INTERP_KERNEL::Exception("MEDCouplingIMesh::CondenseFineToCoarse : the size of fineLocInCoarse (4th param) and facts (5th param) must be equal to the sier of coarseSt (2nd param) !");
   if(coarseDA->getNumberOfTuples()!=nbOfTuplesInCoarseExp)
     {
       std::ostringstream oss; oss << "MEDCouplingIMesh::CondenseFineToCoarse : Expecting " << nbOfTuplesInCoarseExp << " tuples having " << coarseDA->getNumberOfTuples() << " !";
       throw INTERP_KERNEL::Exception(oss.str().c_str());
     }
-  int nbTuplesFine(fineDA->getNumberOfTuples());
+  mcIdType nbTuplesFine(fineDA->getNumberOfTuples());
   if(nbOfTuplesInFineExp==0)
     {
       if(nbTuplesFine==0)
@@ -303,7 +309,7 @@ void MEDCouplingIMesh::CondenseFineToCoarse(const std::vector<int>& coarseSt, co
     }
   if(nbTuplesFine%nbOfTuplesInFineExp!=0)
     throw INTERP_KERNEL::Exception("MEDCouplingIMesh::CondenseFineToCoarse : Invalid nb of tuples in fine DataArray regarding its structure !");
-  int fact(std::accumulate(facts.begin(),facts.end(),1,std::multiplies<int>()));
+  mcIdType fact(std::accumulate(facts.begin(),facts.end(),1,std::multiplies<mcIdType>()));
   if(nbTuplesFine!=fact*nbOfTuplesInFineExp)
     {
       std::ostringstream oss; oss << "MEDCouplingIMesh::CondenseFineToCoarse : Invalid number of tuples ("  << nbTuplesFine << ") of fine dataarray is invalid ! Must be " << fact*nbOfTuplesInFineExp << "!";
@@ -313,16 +319,16 @@ void MEDCouplingIMesh::CondenseFineToCoarse(const std::vector<int>& coarseSt, co
   double *outPtr(coarseDA->getPointer());
   const double *inPtr(fineDA->begin());
   //
-  std::vector<int> dims(MEDCouplingStructuredMesh::GetDimensionsFromCompactFrmt(fineLocInCoarse));
+  std::vector<mcIdType> dims(MEDCouplingStructuredMesh::GetDimensionsFromCompactFrmt(fineLocInCoarse));
   switch(meshDim)
   {
     case 1:
       {
-        int offset(fineLocInCoarse[0].first),fact0(facts[0]);
+        mcIdType offset(fineLocInCoarse[0].first),fact0(facts[0]);
         for(int i=0;i<dims[0];i++)
           {
             double *loc(outPtr+(offset+i)*nbCompo);
-            for(int ifact=0;ifact<fact0;ifact++,inPtr+=nbCompo)
+            for(mcIdType ifact=0;ifact<fact0;ifact++,inPtr+=nbCompo)
               {
                 if(ifact!=0)
                   std::transform(inPtr,inPtr+nbCompo,loc,loc,std::plus<double>());
@@ -334,15 +340,15 @@ void MEDCouplingIMesh::CondenseFineToCoarse(const std::vector<int>& coarseSt, co
       }
     case 2:
       {
-        int kk(fineLocInCoarse[0].first+coarseSt[0]*fineLocInCoarse[1].first),fact1(facts[1]),fact0(facts[0]);
+        mcIdType kk(fineLocInCoarse[0].first+coarseSt[0]*fineLocInCoarse[1].first),fact1(facts[1]),fact0(facts[0]);
         for(int j=0;j<dims[1];j++)
           {
-            for(int jfact=0;jfact<fact1;jfact++)
+            for(mcIdType jfact=0;jfact<fact1;jfact++)
               {
                 for(int i=0;i<dims[0];i++)
                   {
                     double *loc(outPtr+(kk+i)*nbCompo);
-                    for(int ifact=0;ifact<fact0;ifact++,inPtr+=nbCompo)
+                    for(mcIdType ifact=0;ifact<fact0;ifact++,inPtr+=nbCompo)
                       {
                         if(jfact!=0 || ifact!=0)
                           std::transform(inPtr,inPtr+nbCompo,loc,loc,std::plus<double>());
@@ -357,19 +363,19 @@ void MEDCouplingIMesh::CondenseFineToCoarse(const std::vector<int>& coarseSt, co
       }
     case 3:
       {
-        int kk(fineLocInCoarse[0].first+coarseSt[0]*fineLocInCoarse[1].first+coarseSt[0]*coarseSt[1]*fineLocInCoarse[2].first),fact2(facts[2]),fact1(facts[1]),fact0(facts[0]);
+        mcIdType kk(fineLocInCoarse[0].first+coarseSt[0]*fineLocInCoarse[1].first+coarseSt[0]*coarseSt[1]*fineLocInCoarse[2].first),fact2(facts[2]),fact1(facts[1]),fact0(facts[0]);
         for(int k=0;k<dims[2];k++)
           {
-            for(int kfact=0;kfact<fact2;kfact++)
+            for(mcIdType kfact=0;kfact<fact2;kfact++)
               {
                 for(int j=0;j<dims[1];j++)
                   {
-                    for(int jfact=0;jfact<fact1;jfact++)
+                    for(mcIdType jfact=0;jfact<fact1;jfact++)
                       {
                         for(int i=0;i<dims[0];i++)
                           {
                             double *loc(outPtr+(kk+i+j*coarseSt[0])*nbCompo);
-                            for(int ifact=0;ifact<fact0;ifact++,inPtr+=nbCompo)
+                            for(mcIdType ifact=0;ifact<fact0;ifact++,inPtr+=nbCompo)
                               {
                                 if(kfact!=0 || jfact!=0 || ifact!=0)
                                   std::transform(inPtr,inPtr+nbCompo,loc,loc,std::plus<double>());
@@ -391,7 +397,7 @@ void MEDCouplingIMesh::CondenseFineToCoarse(const std::vector<int>& coarseSt, co
 
 /*!
  * This static method is useful to condense field on cells of a MEDCouplingIMesh instance coming from a refinement ( MEDCouplingIMesh::refineWithFactor for example)
- * to a coarse MEDCouplingIMesh instance. So this method can be seen as a specialization in P0P0 conservative interpolation non overlaping from fine image mesh
+ * to a coarse MEDCouplingIMesh instance. So this method can be seen as a specialization in P0P0 conservative interpolation non overlapping from fine image mesh
  * to a coarse image mesh. Only tuples ( deduced from \a fineLocInCoarse ) of \a coarseDA will be modified. Other tuples of \a coarseDA will be let unchanged.
  *
  * \param [in] coarseSt The cell structure of coarse mesh.
@@ -403,7 +409,7 @@ void MEDCouplingIMesh::CondenseFineToCoarse(const std::vector<int>& coarseSt, co
  *
  * \sa CondenseFineToCoarse,SpreadCoarseToFineGhost
  */
-void MEDCouplingIMesh::CondenseFineToCoarseGhost(const std::vector<int>& coarseSt, const DataArrayDouble *fineDA, const std::vector< std::pair<int,int> >& fineLocInCoarse, const std::vector<int>& facts, DataArrayDouble *coarseDA, int ghostSize)
+void MEDCouplingIMesh::CondenseFineToCoarseGhost(const std::vector<mcIdType>& coarseSt, const DataArrayDouble *fineDA, const std::vector< std::pair<mcIdType,mcIdType> >& fineLocInCoarse, const std::vector<mcIdType>& facts, DataArrayDouble *coarseDA, mcIdType ghostSize)
 {
   if(ghostSize<0)
     throw INTERP_KERNEL::Exception("MEDCouplingIMesh::CondenseFineToCoarseGhost : ghost level has to be >= 0 !");
@@ -411,12 +417,13 @@ void MEDCouplingIMesh::CondenseFineToCoarseGhost(const std::vector<int>& coarseS
     throw INTERP_KERNEL::Exception("MEDCouplingIMesh::CondenseFineToCoarseGhost : All input vectors (dimension) must have the same size !");
   if(!coarseDA || !coarseDA->isAllocated() || !fineDA || !fineDA->isAllocated())
     throw INTERP_KERNEL::Exception("MEDCouplingIMesh::CondenseFineToCoarseGhost : the parameters 1 or 3 are NULL or not allocated !");
-  std::vector<int> coarseStG(coarseSt.size()); std::transform(coarseSt.begin(),coarseSt.end(),coarseStG.begin(),std::bind2nd(std::plus<int>(),2*ghostSize));
-  int meshDim((int)coarseSt.size()),nbOfTuplesInCoarseExp(MEDCouplingStructuredMesh::DeduceNumberOfGivenStructure(coarseStG));
-  int nbCompo(fineDA->getNumberOfComponents());
+  std::vector<mcIdType> coarseStG(coarseSt.size()); std::transform(coarseSt.begin(),coarseSt.end(),coarseStG.begin(),std::bind2nd(std::plus<mcIdType>(),2*ghostSize));
+  std::size_t meshDim(coarseSt.size());
+  mcIdType nbOfTuplesInCoarseExp(MEDCouplingStructuredMesh::DeduceNumberOfGivenStructure(coarseStG));
+  std::size_t nbCompo(fineDA->getNumberOfComponents());
   if(coarseDA->getNumberOfComponents()!=nbCompo)
     throw INTERP_KERNEL::Exception("MEDCouplingIMesh::CondenseFineToCoarseGhost : the number of components of fine DA and coarse one mismatches !");
-  if(meshDim!=(int)fineLocInCoarse.size() || meshDim!=(int)facts.size())
+  if(meshDim!=fineLocInCoarse.size() || meshDim!=facts.size())
     throw INTERP_KERNEL::Exception("MEDCouplingIMesh::CondenseFineToCoarseGhost : the size of fineLocInCoarse (4th param) and facts (5th param) must be equal to the sier of coarseSt (2nd param) !");
   if(coarseDA->getNumberOfTuples()!=nbOfTuplesInCoarseExp)
     {
@@ -424,10 +431,10 @@ void MEDCouplingIMesh::CondenseFineToCoarseGhost(const std::vector<int>& coarseS
       throw INTERP_KERNEL::Exception(oss.str().c_str());
     }
   //
-  std::vector<int> fineStG(MEDCouplingStructuredMesh::GetDimensionsFromCompactFrmt(fineLocInCoarse));
-  std::transform(fineStG.begin(),fineStG.end(),facts.begin(),fineStG.begin(),std::multiplies<int>());
-  std::transform(fineStG.begin(),fineStG.end(),fineStG.begin(),std::bind2nd(std::plus<int>(),2*ghostSize));
-  int nbTuplesFine(fineDA->getNumberOfTuples()),nbTuplesFineExp(MEDCouplingStructuredMesh::DeduceNumberOfGivenStructure(fineStG));
+  std::vector<mcIdType> fineStG(MEDCouplingStructuredMesh::GetDimensionsFromCompactFrmt(fineLocInCoarse));
+  std::transform(fineStG.begin(),fineStG.end(),facts.begin(),fineStG.begin(),std::multiplies<mcIdType>());
+  std::transform(fineStG.begin(),fineStG.end(),fineStG.begin(),std::bind2nd(std::plus<mcIdType>(),2*ghostSize));
+  mcIdType nbTuplesFine(fineDA->getNumberOfTuples()),nbTuplesFineExp(MEDCouplingStructuredMesh::DeduceNumberOfGivenStructure(fineStG));
   if(fineDA->getNumberOfTuples()!=nbTuplesFineExp)
     {
       std::ostringstream oss; oss << "MEDCouplingIMesh::CondenseFineToCoarseGhost : Expecting " << nbTuplesFineExp << " tuples in fine DataArray having " << nbTuplesFine << " !";
@@ -437,17 +444,17 @@ void MEDCouplingIMesh::CondenseFineToCoarseGhost(const std::vector<int>& coarseS
   double *outPtr(coarseDA->getPointer());
   const double *inPtr(fineDA->begin());
   //
-  std::vector<int> dims(MEDCouplingStructuredMesh::GetDimensionsFromCompactFrmt(fineLocInCoarse));
+  std::vector<mcIdType> dims(MEDCouplingStructuredMesh::GetDimensionsFromCompactFrmt(fineLocInCoarse));
   switch(meshDim)
   {
     case 1:
       {
-        int offset(fineLocInCoarse[0].first+ghostSize),fact0(facts[0]);
+        mcIdType offset(fineLocInCoarse[0].first+ghostSize),fact0(facts[0]);
         inPtr+=ghostSize*nbCompo;
         for(int i=0;i<dims[0];i++)
           {
             double *loc(outPtr+(offset+i)*nbCompo);
-            for(int ifact=0;ifact<fact0;ifact++,inPtr+=nbCompo)
+            for(mcIdType ifact=0;ifact<fact0;ifact++,inPtr+=nbCompo)
               {
                 if(ifact!=0)
                   std::transform(inPtr,inPtr+nbCompo,loc,loc,std::plus<double>());
@@ -459,18 +466,18 @@ void MEDCouplingIMesh::CondenseFineToCoarseGhost(const std::vector<int>& coarseS
       }
     case 2:
       {
-        int nxwg(coarseSt[0]+2*ghostSize);
-        int kk(fineLocInCoarse[0].first+ghostSize+nxwg*(fineLocInCoarse[1].first+ghostSize)),fact1(facts[1]),fact0(facts[0]);
-        inPtr+=(dims[0]*fact0+2*ghostSize)*nbCompo;
+        mcIdType nxwg(coarseSt[0]+2*ghostSize);
+        mcIdType kk(fineLocInCoarse[0].first+ghostSize+nxwg*(fineLocInCoarse[1].first+ghostSize)),fact1(facts[1]),fact0(facts[0]);
+        inPtr+=(dims[0]*fact0+2*ghostSize)*ghostSize*nbCompo;
         for(int j=0;j<dims[1];j++)
           {
-             for(int jfact=0;jfact<fact1;jfact++)
+             for(mcIdType jfact=0;jfact<fact1;jfact++)
               {
                 inPtr+=ghostSize*nbCompo;
                 for(int i=0;i<dims[0];i++)
                   {
                     double *loc(outPtr+(kk+i)*nbCompo);
-                    for(int ifact=0;ifact<fact0;ifact++,inPtr+=nbCompo)
+                    for(mcIdType ifact=0;ifact<fact0;ifact++,inPtr+=nbCompo)
                       {
                         if(jfact!=0 || ifact!=0)
                           std::transform(inPtr,inPtr+nbCompo,loc,loc,std::plus<double>());
@@ -484,8 +491,44 @@ void MEDCouplingIMesh::CondenseFineToCoarseGhost(const std::vector<int>& coarseS
           }
         break;
       }
+    case 3:
+      {
+        mcIdType nxwg(coarseSt[0]+2*ghostSize),nxywg((coarseSt[0]+2*ghostSize)*(coarseSt[1]+2*ghostSize));
+        mcIdType kk(fineLocInCoarse[0].first+ghostSize+nxwg*(fineLocInCoarse[1].first+ghostSize)+nxywg*(fineLocInCoarse[2].first+ghostSize)),fact2(facts[2]),fact1(facts[1]),fact0(facts[0]);
+        inPtr+=(dims[0]*fact0+2*ghostSize)*(dims[1]*fact1+2*ghostSize)*ghostSize*nbCompo;
+        for(int k=0;k<dims[2];k++)
+          {
+            for(mcIdType kfact=0;kfact<fact2;kfact++)
+              {
+                inPtr+=ghostSize*(dims[0]*fact0+2*ghostSize)*nbCompo;
+                for(int j=0;j<dims[1];j++)
+                  {
+                    mcIdType kky(j*nxwg);
+                    for(mcIdType jfact=0;jfact<fact1;jfact++)
+                      {
+                        inPtr+=ghostSize*nbCompo;
+                        for(int i=0;i<dims[0];i++)
+                          {
+                            double *loc(outPtr+(kky+kk+i)*nbCompo);
+                            for(mcIdType ifact=0;ifact<fact0;ifact++,inPtr+=nbCompo)
+                              {
+                                if(kfact!=0 || jfact!=0 || ifact!=0)
+                                  std::transform(inPtr,inPtr+nbCompo,loc,loc,std::plus<double>());
+                                else
+                                  std::copy(inPtr,inPtr+nbCompo,loc);
+                              }
+                          }
+                        inPtr+=ghostSize*nbCompo;
+                      }
+                  }
+                inPtr+=ghostSize*(dims[0]*fact0+2*ghostSize)*nbCompo;
+              }
+            kk+=nxywg;
+          }
+        break;
+      }
     default:
-      throw INTERP_KERNEL::Exception("MEDCouplingIMesh::CondenseFineToCoarseGhost : only dimensions 1, 2 supported !");
+      throw INTERP_KERNEL::Exception("MEDCouplingIMesh::CondenseFineToCoarseGhost : only dimensions 1, 2, 3 supported !");
   }
 }
 
@@ -499,27 +542,28 @@ void MEDCouplingIMesh::CondenseFineToCoarseGhost(const std::vector<int>& coarseS
  * \param [in] facts The refinement coefficient per axis.
  * \sa SpreadCoarseToFineGhost, CondenseFineToCoarse
  */
-void MEDCouplingIMesh::SpreadCoarseToFine(const DataArrayDouble *coarseDA, const std::vector<int>& coarseSt, DataArrayDouble *fineDA, const std::vector< std::pair<int,int> >& fineLocInCoarse, const std::vector<int>& facts)
+void MEDCouplingIMesh::SpreadCoarseToFine(const DataArrayDouble *coarseDA, const std::vector<mcIdType>& coarseSt, DataArrayDouble *fineDA, const std::vector< std::pair<mcIdType,mcIdType> >& fineLocInCoarse, const std::vector<mcIdType>& facts)
 {
   if(coarseSt.size()!=fineLocInCoarse.size() || coarseSt.size()!=facts.size())
       throw INTERP_KERNEL::Exception("MEDCouplingIMesh::SpreadCoarseToFine : All input vectors (dimension) must have the same size !");
   if(!coarseDA || !coarseDA->isAllocated() || !fineDA || !fineDA->isAllocated())
     throw INTERP_KERNEL::Exception("MEDCouplingIMesh::SpreadCoarseToFine : the parameters 1 or 3 are NULL or not allocated !");
-  int meshDim((int)coarseSt.size()),nbOfTuplesInCoarseExp(MEDCouplingStructuredMesh::DeduceNumberOfGivenStructure(coarseSt)),nbOfTuplesInFineExp(MEDCouplingStructuredMesh::DeduceNumberOfGivenRangeInCompactFrmt(fineLocInCoarse));
-  int nbCompo(fineDA->getNumberOfComponents());
+  std::size_t meshDim(coarseSt.size());
+  mcIdType nbOfTuplesInCoarseExp(MEDCouplingStructuredMesh::DeduceNumberOfGivenStructure(coarseSt)),nbOfTuplesInFineExp(MEDCouplingStructuredMesh::DeduceNumberOfGivenRangeInCompactFrmt(fineLocInCoarse));
+  std::size_t nbCompo=fineDA->getNumberOfComponents();
   if(coarseDA->getNumberOfComponents()!=nbCompo)
     throw INTERP_KERNEL::Exception("MEDCouplingIMesh::SpreadCoarseToFine : the number of components of fine DA and coarse one mismatches !");
-  if(meshDim!=(int)fineLocInCoarse.size() || meshDim!=(int)facts.size())
+  if(meshDim!=fineLocInCoarse.size() || meshDim!=facts.size())
     throw INTERP_KERNEL::Exception("MEDCouplingIMesh::SpreadCoarseToFine : the size of fineLocInCoarse (4th param) and facts (5th param) must be equal to the sier of coarseSt (2nd param) !");
   if(coarseDA->getNumberOfTuples()!=nbOfTuplesInCoarseExp)
     {
       std::ostringstream oss; oss << "MEDCouplingIMesh::SpreadCoarseToFine : Expecting " << nbOfTuplesInCoarseExp << " tuples having " << coarseDA->getNumberOfTuples() << " !";
       throw INTERP_KERNEL::Exception(oss.str().c_str());
     }
-  int nbTuplesFine(fineDA->getNumberOfTuples());
+  mcIdType nbTuplesFine(fineDA->getNumberOfTuples());
   if(nbTuplesFine%nbOfTuplesInFineExp!=0)
     throw INTERP_KERNEL::Exception("MEDCouplingIMesh::SpreadCoarseToFine : Invalid nb of tuples in fine DataArray regarding its structure !");
-  int fact(std::accumulate(facts.begin(),facts.end(),1,std::multiplies<int>()));
+  mcIdType fact(std::accumulate(facts.begin(),facts.end(),1,std::multiplies<mcIdType>()));
   if(nbTuplesFine!=fact*nbOfTuplesInFineExp)
     {
       std::ostringstream oss; oss << "MEDCouplingIMesh::SpreadCoarseToFine : Invalid number of tuples ("  << nbTuplesFine << ") of fine dataarray is invalid ! Must be " << fact*nbOfTuplesInFineExp << "!";
@@ -529,31 +573,31 @@ void MEDCouplingIMesh::SpreadCoarseToFine(const DataArrayDouble *coarseDA, const
   double *outPtr(fineDA->getPointer());
   const double *inPtr(coarseDA->begin());
   //
-  std::vector<int> dims(MEDCouplingStructuredMesh::GetDimensionsFromCompactFrmt(fineLocInCoarse));
+  std::vector<mcIdType> dims(MEDCouplingStructuredMesh::GetDimensionsFromCompactFrmt(fineLocInCoarse));
   switch(meshDim)
   {
     case 1:
       {
-        int offset(fineLocInCoarse[0].first),fact0(facts[0]);
+        mcIdType offset(fineLocInCoarse[0].first),fact0(facts[0]);
         for(int i=0;i<dims[0];i++)
           {
             const double *loc(inPtr+(offset+i)*nbCompo);
-            for(int ifact=0;ifact<fact0;ifact++)
+            for(mcIdType ifact=0;ifact<fact0;ifact++)
               outPtr=std::copy(loc,loc+nbCompo,outPtr);
           }
         break;
       }
     case 2:
       {
-        int kk(fineLocInCoarse[0].first+coarseSt[0]*fineLocInCoarse[1].first),fact0(facts[0]),fact1(facts[1]);
+        mcIdType kk(fineLocInCoarse[0].first+coarseSt[0]*fineLocInCoarse[1].first),fact0(facts[0]),fact1(facts[1]);
         for(int j=0;j<dims[1];j++)
           {
-            for(int jfact=0;jfact<fact1;jfact++)
+            for(mcIdType jfact=0;jfact<fact1;jfact++)
               {
                 for(int i=0;i<dims[0];i++)
                   {
                     const double *loc(inPtr+(kk+i)*nbCompo);
-                    for(int ifact=0;ifact<fact0;ifact++)
+                    for(mcIdType ifact=0;ifact<fact0;ifact++)
                       outPtr=std::copy(loc,loc+nbCompo,outPtr);
                   }
               }
@@ -563,19 +607,19 @@ void MEDCouplingIMesh::SpreadCoarseToFine(const DataArrayDouble *coarseDA, const
       }
     case 3:
       {
-        int kk(fineLocInCoarse[0].first+coarseSt[0]*fineLocInCoarse[1].first+coarseSt[0]*coarseSt[1]*fineLocInCoarse[2].first),fact0(facts[0]),fact1(facts[2]),fact2(facts[2]);
+        mcIdType kk(fineLocInCoarse[0].first+coarseSt[0]*fineLocInCoarse[1].first+coarseSt[0]*coarseSt[1]*fineLocInCoarse[2].first),fact0(facts[0]),fact1(facts[2]),fact2(facts[2]);
         for(int k=0;k<dims[2];k++)
           {
-            for(int kfact=0;kfact<fact2;kfact++)
+            for(mcIdType kfact=0;kfact<fact2;kfact++)
               {
                 for(int j=0;j<dims[1];j++)
                   {
-                    for(int jfact=0;jfact<fact1;jfact++)
+                    for(mcIdType jfact=0;jfact<fact1;jfact++)
                       {
                         for(int i=0;i<dims[0];i++)
                           {
                             const double *loc(inPtr+(kk+i+j*coarseSt[0])*nbCompo);
-                            for(int ifact=0;ifact<fact0;ifact++)
+                            for(mcIdType ifact=0;ifact<fact0;ifact++)
                               outPtr=std::copy(loc,loc+nbCompo,outPtr);
                           }
                       }
@@ -602,7 +646,7 @@ void MEDCouplingIMesh::SpreadCoarseToFine(const DataArrayDouble *coarseDA, const
  *
  * \sa CondenseFineToCoarse, SpreadCoarseToFineGhostZone
  */
-void MEDCouplingIMesh::SpreadCoarseToFineGhost(const DataArrayDouble *coarseDA, const std::vector<int>& coarseSt, DataArrayDouble *fineDA, const std::vector< std::pair<int,int> >& fineLocInCoarse, const std::vector<int>& facts, int ghostSize)
+void MEDCouplingIMesh::SpreadCoarseToFineGhost(const DataArrayDouble *coarseDA, const std::vector<mcIdType>& coarseSt, DataArrayDouble *fineDA, const std::vector< std::pair<mcIdType,mcIdType> >& fineLocInCoarse, const std::vector<mcIdType>& facts, mcIdType ghostSize)
 {
   if(ghostSize<0)
     throw INTERP_KERNEL::Exception("MEDCouplingIMesh::SpreadCoarseToFineGhost : ghost level has to be >= 0 !");
@@ -610,12 +654,13 @@ void MEDCouplingIMesh::SpreadCoarseToFineGhost(const DataArrayDouble *coarseDA,
     throw INTERP_KERNEL::Exception("MEDCouplingIMesh::SpreadCoarseToFineGhost : All input vectors (dimension) must have the same size !");
   if(!coarseDA || !coarseDA->isAllocated() || !fineDA || !fineDA->isAllocated())
     throw INTERP_KERNEL::Exception("MEDCouplingIMesh::SpreadCoarseToFineGhost : the parameters 1 or 3 are NULL or not allocated !");
-  std::vector<int> coarseStG(coarseSt.size()); std::transform(coarseSt.begin(),coarseSt.end(),coarseStG.begin(),std::bind2nd(std::plus<int>(),2*ghostSize));
-  int meshDim((int)coarseSt.size()),nbOfTuplesInCoarseExp(MEDCouplingStructuredMesh::DeduceNumberOfGivenStructure(coarseStG));
-  int nbCompo(fineDA->getNumberOfComponents());
+  std::vector<mcIdType> coarseStG(coarseSt.size()); std::transform(coarseSt.begin(),coarseSt.end(),coarseStG.begin(),std::bind2nd(std::plus<mcIdType>(),2*ghostSize));
+  std::size_t meshDim(coarseSt.size());
+  mcIdType nbOfTuplesInCoarseExp(MEDCouplingStructuredMesh::DeduceNumberOfGivenStructure(coarseStG));
+  std::size_t nbCompo=fineDA->getNumberOfComponents();
   if(coarseDA->getNumberOfComponents()!=nbCompo)
     throw INTERP_KERNEL::Exception("MEDCouplingIMesh::SpreadCoarseToFineGhost : the number of components of fine DA and coarse one mismatches !");
-  if(meshDim!=(int)fineLocInCoarse.size() || meshDim!=(int)facts.size())
+  if(meshDim!=fineLocInCoarse.size() || meshDim!=facts.size())
     throw INTERP_KERNEL::Exception("MEDCouplingIMesh::SpreadCoarseToFineGhost : the size of fineLocInCoarse (4th param) and facts (5th param) must be equal to the sier of coarseSt (2nd param) !");
   if(coarseDA->getNumberOfTuples()!=nbOfTuplesInCoarseExp)
     {
@@ -623,10 +668,10 @@ void MEDCouplingIMesh::SpreadCoarseToFineGhost(const DataArrayDouble *coarseDA,
       throw INTERP_KERNEL::Exception(oss.str().c_str());
     }
   //
-  std::vector<int> fineStG(MEDCouplingStructuredMesh::GetDimensionsFromCompactFrmt(fineLocInCoarse));
-  std::transform(fineStG.begin(),fineStG.end(),facts.begin(),fineStG.begin(),std::multiplies<int>());
-  std::transform(fineStG.begin(),fineStG.end(),fineStG.begin(),std::bind2nd(std::plus<int>(),2*ghostSize));
-  int nbTuplesFine(fineDA->getNumberOfTuples()),nbTuplesFineExp(MEDCouplingStructuredMesh::DeduceNumberOfGivenStructure(fineStG));
+  std::vector<mcIdType> fineStG(MEDCouplingStructuredMesh::GetDimensionsFromCompactFrmt(fineLocInCoarse));
+  std::transform(fineStG.begin(),fineStG.end(),facts.begin(),fineStG.begin(),std::multiplies<mcIdType>());
+  std::transform(fineStG.begin(),fineStG.end(),fineStG.begin(),std::bind2nd(std::plus<mcIdType>(),2*ghostSize));
+  mcIdType nbTuplesFine(fineDA->getNumberOfTuples()),nbTuplesFineExp(MEDCouplingStructuredMesh::DeduceNumberOfGivenStructure(fineStG));
   if(fineDA->getNumberOfTuples()!=nbTuplesFineExp)
     {
       std::ostringstream oss; oss << "MEDCouplingIMesh::SpreadCoarseToFineGhost : Expecting " << nbTuplesFineExp << " tuples in fine DataArray having " << nbTuplesFine << " !";
@@ -636,75 +681,49 @@ void MEDCouplingIMesh::SpreadCoarseToFineGhost(const DataArrayDouble *coarseDA,
   double *outPtr(fineDA->getPointer());
   const double *inPtr(coarseDA->begin());
   //
-  std::vector<int> dims(MEDCouplingStructuredMesh::GetDimensionsFromCompactFrmt(fineLocInCoarse));
   switch(meshDim)
   {
     case 1:
       {
-        int offset(fineLocInCoarse[0].first+ghostSize-1),fact0(facts[0]);//offset is always >=0 thanks to the fact that ghostSize>=1 !
-        for(int i=0;i<ghostSize;i++)
+        std::vector<mcIdType> dims(MEDCouplingStructuredMesh::GetDimensionsFromCompactFrmt(fineLocInCoarse));
+        mcIdType offset(fineLocInCoarse[0].first+ghostSize-1),fact0(facts[0]);//offset is always >=0 thanks to the fact that ghostSize>=1 !
+        for(mcIdType i=0;i<ghostSize;i++)
           outPtr=std::copy(inPtr+offset*nbCompo,inPtr+(offset+1)*nbCompo,outPtr);
         offset=fineLocInCoarse[0].first+ghostSize;
         for(int i=0;i<dims[0];i++)
           {
             const double *loc(inPtr+(offset+i)*nbCompo);
-            for(int ifact=0;ifact<fact0;ifact++)
+            for(mcIdType ifact=0;ifact<fact0;ifact++)
               outPtr=std::copy(loc,loc+nbCompo,outPtr);
           }
         offset=fineLocInCoarse[0].second+ghostSize;
-        for(int i=0;i<ghostSize;i++)
+        for(mcIdType i=0;i<ghostSize;i++)
           outPtr=std::copy(inPtr+offset*nbCompo,inPtr+(offset+1)*nbCompo,outPtr);
         break;
       }
     case 2:
       {
-        int nxwg(coarseSt[0]+2*ghostSize),fact0(facts[0]),fact1(facts[1]);
-        int kk(fineLocInCoarse[0].first+ghostSize-1+nxwg*(fineLocInCoarse[1].first+ghostSize-1));//kk is always >=0 thanks to the fact that ghostSize>=1 !
-        for(int jg=0;jg<ghostSize;jg++)
-          {
-            for(int ig=0;ig<ghostSize;ig++)
-              outPtr=std::copy(inPtr+kk*nbCompo,inPtr+(kk+1)*nbCompo,outPtr);
-            int kk0(kk+1);
-            for(int ig=0;ig<dims[0];ig++,kk0++)
-              for(int ifact=0;ifact<fact0;ifact++)
-                outPtr=std::copy(inPtr+(kk0)*nbCompo,inPtr+(kk0+1)*nbCompo,outPtr);
-            for(int ik=0;ik<ghostSize;ik++)
-              outPtr=std::copy(inPtr+kk0*nbCompo,inPtr+(kk0+1)*nbCompo,outPtr);
-          }
-        for(int j=0;j<dims[1];j++)
-          {
-            kk=fineLocInCoarse[0].first-1+ghostSize+nxwg*(fineLocInCoarse[1].first+ghostSize+j);
-            for(int jfact=0;jfact<fact1;jfact++)
-              {
-                for(int ig=0;ig<ghostSize;ig++)
-                  outPtr=std::copy(inPtr+kk*nbCompo,inPtr+(kk+1)*nbCompo,outPtr);
-                int kk0(kk+1);//1 not ghost. We make the hypothesis that factors is >= ghostlev
-                for(int i=0;i<dims[0];i++,kk0++)
-                  {
-                    const double *loc(inPtr+kk0*nbCompo);
-                    for(int ifact=0;ifact<fact0;ifact++)
-                      outPtr=std::copy(loc,loc+nbCompo,outPtr);
-                  }
-                for(int ig=0;ig<ghostSize;ig++)
-                  outPtr=std::copy(inPtr+kk0*nbCompo,inPtr+(kk0+1)*nbCompo,outPtr);
-              }
-          }
-        kk=fineLocInCoarse[0].first+ghostSize-1+nxwg*(fineLocInCoarse[1].second+ghostSize);
-        for(int jg=0;jg<ghostSize;jg++)
-          {
-            for(int ig=0;ig<ghostSize;ig++)
-              outPtr=std::copy(inPtr+kk*nbCompo,inPtr+(kk+1)*nbCompo,outPtr);
-            int kk0(kk+1);
-            for(int ig=0;ig<dims[0];ig++,kk0++)
-              for(int ifact=0;ifact<fact0;ifact++)
-                outPtr=std::copy(inPtr+(kk0)*nbCompo,inPtr+(kk0+1)*nbCompo,outPtr);
-            for(int ik=0;ik<ghostSize;ik++)
-              outPtr=std::copy(inPtr+kk0*nbCompo,inPtr+(kk0+1)*nbCompo,outPtr);
-          }
+        SpreadCoarseToFineGhost2D(inPtr,outPtr,nbCompo,coarseSt,fineLocInCoarse,facts,ghostSize);
+        break;
+      }
+    case 3:
+      {
+        std::vector<mcIdType> dims(MEDCouplingStructuredMesh::GetDimensionsFromCompactFrmt(fineLocInCoarse));
+        mcIdType fact0(facts[0]),fact1(facts[1]),fact2(facts[2]);
+        mcIdType nxyWgCoarse((coarseSt[0]+2*ghostSize)*(coarseSt[1]+2*ghostSize)),nxyWgFine((dims[0]*fact0+2*ghostSize)*(dims[1]*fact1+2*ghostSize));
+        mcIdType offset((fineLocInCoarse[2].first+ghostSize-1)*nxyWgCoarse);//offset is always >=0 thanks to the fact that ghostSize>=1 !
+        for(mcIdType i=0;i<ghostSize;i++,outPtr+=nxyWgFine*nbCompo)
+          SpreadCoarseToFineGhost2D(inPtr+offset*nbCompo,outPtr,nbCompo,coarseSt,fineLocInCoarse,facts,ghostSize);
+        offset+=nxyWgCoarse;
+        for(int i=0;i<dims[2];i++,offset+=nxyWgCoarse)
+          for(mcIdType j=0;j<fact2;j++,outPtr+=nxyWgFine*nbCompo)
+            SpreadCoarseToFineGhost2D(inPtr+offset*nbCompo,outPtr,nbCompo,coarseSt,fineLocInCoarse,facts,ghostSize);
+        for(mcIdType i=0;i<ghostSize;i++,outPtr+=nxyWgFine*nbCompo)
+          SpreadCoarseToFineGhost2D(inPtr+offset*nbCompo,outPtr,nbCompo,coarseSt,fineLocInCoarse,facts,ghostSize);
         break;
       }
     default:
-      throw INTERP_KERNEL::Exception("MEDCouplingIMesh::SpreadCoarseToFineGhost : only dimensions 1, 2 supported !");
+      throw INTERP_KERNEL::Exception("MEDCouplingIMesh::SpreadCoarseToFineGhost : only dimensions 1, 2, 3 supported !");
   }
 }
 
@@ -720,7 +739,7 @@ void MEDCouplingIMesh::SpreadCoarseToFineGhost(const DataArrayDouble *coarseDA,
  *
  * \sa SpreadCoarseToFineGhost
  */
-void MEDCouplingIMesh::SpreadCoarseToFineGhostZone(const DataArrayDouble *coarseDA, const std::vector<int>& coarseSt, DataArrayDouble *fineDA, const std::vector< std::pair<int,int> >& fineLocInCoarse, const std::vector<int>& facts, int ghostSize)
+void MEDCouplingIMesh::SpreadCoarseToFineGhostZone(const DataArrayDouble *coarseDA, const std::vector<mcIdType>& coarseSt, DataArrayDouble *fineDA, const std::vector< std::pair<mcIdType,mcIdType> >& fineLocInCoarse, const std::vector<mcIdType>& facts, mcIdType ghostSize)
 {
   if(ghostSize<0)
     throw INTERP_KERNEL::Exception("MEDCouplingIMesh::SpreadCoarseToFineGhostZone : ghost level has to be >= 0 !");
@@ -728,12 +747,13 @@ void MEDCouplingIMesh::SpreadCoarseToFineGhostZone(const DataArrayDouble *coarse
     throw INTERP_KERNEL::Exception("MEDCouplingIMesh::SpreadCoarseToFineGhostZone : All input vectors (dimension) must have the same size !");
   if(!coarseDA || !coarseDA->isAllocated() || !fineDA || !fineDA->isAllocated())
     throw INTERP_KERNEL::Exception("MEDCouplingIMesh::SpreadCoarseToFineGhostZone : the parameters 1 or 3 are NULL or not allocated !");
-  std::vector<int> coarseStG(coarseSt.size()); std::transform(coarseSt.begin(),coarseSt.end(),coarseStG.begin(),std::bind2nd(std::plus<int>(),2*ghostSize));
-  int meshDim((int)coarseSt.size()),nbOfTuplesInCoarseExp(MEDCouplingStructuredMesh::DeduceNumberOfGivenStructure(coarseStG));
-  int nbCompo(fineDA->getNumberOfComponents());
+  std::vector<mcIdType> coarseStG(coarseSt.size()); std::transform(coarseSt.begin(),coarseSt.end(),coarseStG.begin(),std::bind2nd(std::plus<mcIdType>(),2*ghostSize));
+  std::size_t meshDim(coarseSt.size());
+  mcIdType nbOfTuplesInCoarseExp(MEDCouplingStructuredMesh::DeduceNumberOfGivenStructure(coarseStG));
+  std::size_t nbCompo=fineDA->getNumberOfComponents();
   if(coarseDA->getNumberOfComponents()!=nbCompo)
     throw INTERP_KERNEL::Exception("MEDCouplingIMesh::SpreadCoarseToFineGhostZone : the number of components of fine DA and coarse one mismatches !");
-  if(meshDim!=(int)fineLocInCoarse.size() || meshDim!=(int)facts.size())
+  if(meshDim!=fineLocInCoarse.size() || meshDim!=facts.size())
     throw INTERP_KERNEL::Exception("MEDCouplingIMesh::SpreadCoarseToFineGhostZone : the size of fineLocInCoarse (4th param) and facts (5th param) must be equal to the sier of coarseSt (2nd param) !");
   if(coarseDA->getNumberOfTuples()!=nbOfTuplesInCoarseExp)
     {
@@ -741,10 +761,10 @@ void MEDCouplingIMesh::SpreadCoarseToFineGhostZone(const DataArrayDouble *coarse
       throw INTERP_KERNEL::Exception(oss.str().c_str());
     }
   //
-  std::vector<int> fineStG(MEDCouplingStructuredMesh::GetDimensionsFromCompactFrmt(fineLocInCoarse));
-  std::transform(fineStG.begin(),fineStG.end(),facts.begin(),fineStG.begin(),std::multiplies<int>());
-  std::transform(fineStG.begin(),fineStG.end(),fineStG.begin(),std::bind2nd(std::plus<int>(),2*ghostSize));
-  int nbTuplesFine(fineDA->getNumberOfTuples()),nbTuplesFineExp(MEDCouplingStructuredMesh::DeduceNumberOfGivenStructure(fineStG));
+  std::vector<mcIdType> fineStG(MEDCouplingStructuredMesh::GetDimensionsFromCompactFrmt(fineLocInCoarse));
+  std::transform(fineStG.begin(),fineStG.end(),facts.begin(),fineStG.begin(),std::multiplies<mcIdType>());
+  std::transform(fineStG.begin(),fineStG.end(),fineStG.begin(),std::bind2nd(std::plus<mcIdType>(),2*ghostSize));
+  mcIdType nbTuplesFine(fineDA->getNumberOfTuples()),nbTuplesFineExp(MEDCouplingStructuredMesh::DeduceNumberOfGivenStructure(fineStG));
   if(fineDA->getNumberOfTuples()!=nbTuplesFineExp)
     {
       std::ostringstream oss; oss << "MEDCouplingIMesh::SpreadCoarseToFineGhostZone : Expecting " << nbTuplesFineExp << " tuples in fine DataArray having " << nbTuplesFine << " !";
@@ -754,64 +774,42 @@ void MEDCouplingIMesh::SpreadCoarseToFineGhostZone(const DataArrayDouble *coarse
   double *outPtr(fineDA->getPointer());
   const double *inPtr(coarseDA->begin());
   //
-  std::vector<int> dims(MEDCouplingStructuredMesh::GetDimensionsFromCompactFrmt(fineLocInCoarse));
+  std::vector<mcIdType> dims(MEDCouplingStructuredMesh::GetDimensionsFromCompactFrmt(fineLocInCoarse));
   switch(meshDim)
   {
     case 1:
       {
-        int offset(fineLocInCoarse[0].first+ghostSize-1),fact0(facts[0]);//offset is always >=0 thanks to the fact that ghostSize>=1 !
-        for(int i=0;i<ghostSize;i++)
+        mcIdType offset(fineLocInCoarse[0].first+ghostSize-1),fact0(facts[0]);//offset is always >=0 thanks to the fact that ghostSize>=1 !
+        for(mcIdType i=0;i<ghostSize;i++)
           outPtr=std::copy(inPtr+offset*nbCompo,inPtr+(offset+1)*nbCompo,outPtr);
         outPtr+=nbCompo*fact0*dims[0];
         offset=fineLocInCoarse[0].second+ghostSize;
-        for(int i=0;i<ghostSize;i++)
+        for(mcIdType i=0;i<ghostSize;i++)
           outPtr=std::copy(inPtr+offset*nbCompo,inPtr+(offset+1)*nbCompo,outPtr);
         break;
       }
     case 2:
       {
-        int nxwg(coarseSt[0]+2*ghostSize),fact0(facts[0]),fact1(facts[1]);
-        int kk(fineLocInCoarse[0].first+ghostSize-1+nxwg*(fineLocInCoarse[1].first+ghostSize-1));//kk is always >=0 thanks to the fact that ghostSize>=1 !
-        for(int jg=0;jg<ghostSize;jg++)
-          {
-            for(int ig=0;ig<ghostSize;ig++)
-              outPtr=std::copy(inPtr+kk*nbCompo,inPtr+(kk+1)*nbCompo,outPtr);
-            int kk0(kk+1);
-            for(int ig=0;ig<dims[0];ig++,kk0++)
-              for(int ifact=0;ifact<fact0;ifact++)
-                outPtr=std::copy(inPtr+(kk0)*nbCompo,inPtr+(kk0+1)*nbCompo,outPtr);
-            for(int ik=0;ik<ghostSize;ik++)
-              outPtr=std::copy(inPtr+kk0*nbCompo,inPtr+(kk0+1)*nbCompo,outPtr);
-          }
-        for(int j=0;j<dims[1];j++)
-          {
-            kk=fineLocInCoarse[0].first-1+ghostSize+nxwg*(fineLocInCoarse[1].first+ghostSize+j);
-            for(int jfact=0;jfact<fact1;jfact++)
-              {
-                for(int ig=0;ig<ghostSize;ig++)
-                  outPtr=std::copy(inPtr+kk*nbCompo,inPtr+(kk+1)*nbCompo,outPtr);
-                int kk0(kk+1+dims[0]);//1 not ghost. We make the hypothesis that factors is >= ghostlev
-                outPtr+=fact0*nbCompo*dims[0];
-                for(int ig=0;ig<ghostSize;ig++)
-                  outPtr=std::copy(inPtr+kk0*nbCompo,inPtr+(kk0+1)*nbCompo,outPtr);
-              }
-          }
-        kk=fineLocInCoarse[0].first+ghostSize-1+nxwg*(fineLocInCoarse[1].second+ghostSize);
-        for(int jg=0;jg<ghostSize;jg++)
-          {
-            for(int ig=0;ig<ghostSize;ig++)
-              outPtr=std::copy(inPtr+kk*nbCompo,inPtr+(kk+1)*nbCompo,outPtr);
-            int kk0(kk+1);
-            for(int ig=0;ig<dims[0];ig++,kk0++)
-              for(int ifact=0;ifact<fact0;ifact++)
-                outPtr=std::copy(inPtr+(kk0)*nbCompo,inPtr+(kk0+1)*nbCompo,outPtr);
-            for(int ik=0;ik<ghostSize;ik++)
-              outPtr=std::copy(inPtr+kk0*nbCompo,inPtr+(kk0+1)*nbCompo,outPtr);
-          }
+        SpreadCoarseToFineGhostZone2D(inPtr,outPtr,ToIdType(nbCompo),coarseSt,fineLocInCoarse,facts,ghostSize);
+        break;
+      }
+    case 3:
+      {
+        mcIdType fact0(facts[0]),fact1(facts[1]),fact2(facts[2]);
+        mcIdType nxyWgCoarse((coarseSt[0]+2*ghostSize)*(coarseSt[1]+2*ghostSize)),nxyWgFine((dims[0]*fact0+2*ghostSize)*(dims[1]*fact1+2*ghostSize));
+        mcIdType offset((fineLocInCoarse[2].first+ghostSize-1)*nxyWgCoarse);//offset is always >=0 thanks to the fact that ghostSize>=1 !
+        for(mcIdType i=0;i<ghostSize;i++,outPtr+=nxyWgFine*nbCompo)
+          SpreadCoarseToFineGhost2D(inPtr+offset*nbCompo,outPtr,ToIdType(nbCompo),coarseSt,fineLocInCoarse,facts,ghostSize);
+        offset+=nxyWgCoarse;
+        for(int i=0;i<dims[2];i++,offset+=nxyWgCoarse)
+          for(mcIdType j=0;j<fact2;j++,outPtr+=nxyWgFine*nbCompo)
+            SpreadCoarseToFineGhostZone2D(inPtr+offset*nbCompo,outPtr,ToIdType(nbCompo),coarseSt,fineLocInCoarse,facts,ghostSize);
+        for(mcIdType i=0;i<ghostSize;i++,outPtr+=nxyWgFine*nbCompo)
+          SpreadCoarseToFineGhost2D(inPtr+offset*nbCompo,outPtr,ToIdType(nbCompo),coarseSt,fineLocInCoarse,facts,ghostSize);
         break;
       }
     default:
-      throw INTERP_KERNEL::Exception("MEDCouplingIMesh::SpreadCoarseToFineGhostZone : only dimensions 1, 2 supported !");
+      throw INTERP_KERNEL::Exception("MEDCouplingIMesh::SpreadCoarseToFineGhostZone : only dimensions 1, 2, 3 supported !");
   }
 }
 
@@ -833,7 +831,7 @@ std::size_t MEDCouplingIMesh::getHeapMemorySizeWithoutChildren() const
   return MEDCouplingStructuredMesh::getHeapMemorySizeWithoutChildren();
 }
 
-std::vector<const BigMemoryObject *> MEDCouplingIMesh::getDirectChildren() const
+std::vector<const BigMemoryObject *> MEDCouplingIMesh::getDirectChildrenWithNull() const
 {
   return std::vector<const BigMemoryObject *>();
 }
@@ -928,73 +926,68 @@ bool MEDCouplingIMesh::isEqualWithoutConsideringStrInternal(const MEDCouplingMes
 }
 
 void MEDCouplingIMesh::checkDeepEquivalWith(const MEDCouplingMesh *other, int cellCompPol, double prec,
-                                            DataArrayInt *&cellCor, DataArrayInt *&nodeCor) const
+                                            DataArrayIdType *&cellCor, DataArrayIdType *&nodeCor) const
 {
   if(!isEqualWithoutConsideringStr(other,prec))
     throw INTERP_KERNEL::Exception("MEDCouplingIMesh::checkDeepEquivalWith : Meshes are not the same !");
 }
 
 /*!
- * Nothing is done here (except to check that the other is a ParaMEDMEM::MEDCouplingIMesh instance too).
- * The user intend that the nodes are the same, so by construction of ParaMEDMEM::MEDCouplingIMesh, \a this and \a other are the same !
+ * Nothing is done here (except to check that the other is a MEDCoupling::MEDCouplingIMesh instance too).
+ * The user intend that the nodes are the same, so by construction of MEDCoupling::MEDCouplingIMesh, \a this and \a other are the same !
  */
 void MEDCouplingIMesh::checkDeepEquivalOnSameNodesWith(const MEDCouplingMesh *other, int cellCompPol, double prec,
-                                                       DataArrayInt *&cellCor) const
+                                                       DataArrayIdType *&cellCor) const
 {
   if(!isEqualWithoutConsideringStr(other,prec))
     throw INTERP_KERNEL::Exception("MEDCouplingIMesh::checkDeepEquivalOnSameNodesWith : Meshes are not the same !");
 }
 
-void MEDCouplingIMesh::checkCoherency() const
+void MEDCouplingIMesh::checkConsistencyLight() const
 {
   checkSpaceDimension();
   for(int i=0;i<_space_dim;i++)
     if(_structure[i]<1)
       {
-        std::ostringstream oss; oss << "MEDCouplingIMesh::checkCoherency : On axis " << i << "/" << _space_dim << ", number of nodes is equal to " << _structure[i] << " ! must be >=1 !";
+        std::ostringstream oss; oss << "MEDCouplingIMesh::checkConsistencyLight : On axis " << i << "/" << _space_dim << ", number of nodes is equal to " << _structure[i] << " ! must be >=1 !";
         throw INTERP_KERNEL::Exception(oss.str().c_str());
       }
 }
 
-void MEDCouplingIMesh::checkCoherency1(double eps) const
-{
-  checkCoherency();
-}
-
-void MEDCouplingIMesh::checkCoherency2(double eps) const
+void MEDCouplingIMesh::checkConsistency(double eps) const
 {
-  checkCoherency1(eps);
+  checkConsistencyLight();
 }
 
-void MEDCouplingIMesh::getNodeGridStructure(int *res) const
+void MEDCouplingIMesh::getNodeGridStructure(mcIdType *res) const
 {
   checkSpaceDimension();
   std::copy(_structure,_structure+_space_dim,res);
 }
 
-std::vector<int> MEDCouplingIMesh::getNodeGridStructure() const
+std::vector<mcIdType> MEDCouplingIMesh::getNodeGridStructure() const
 {
   checkSpaceDimension();
-  std::vector<int> ret(_structure,_structure+_space_dim);
+  std::vector<mcIdType> ret(_structure,_structure+_space_dim);
   return ret;
 }
 
-MEDCouplingStructuredMesh *MEDCouplingIMesh::buildStructuredSubPart(const std::vector< std::pair<int,int> >& cellPart) const
+MEDCouplingStructuredMesh *MEDCouplingIMesh::buildStructuredSubPart(const std::vector< std::pair<mcIdType,mcIdType> >& cellPart) const
 {
-  checkCoherency();
+  checkConsistencyLight();
   int dim(getSpaceDimension());
-  if(dim!=(int)cellPart.size())
+  if(dim!=ToIdType(cellPart.size()))
     {
       std::ostringstream oss; oss << "MEDCouplingIMesh::buildStructuredSubPart : the space dimension is " << dim << " and cell part size is " << cellPart.size() << " !";
       throw INTERP_KERNEL::Exception(oss.str().c_str());
     }
   double retOrigin[3]={0.,0.,0.};
-  int retStruct[3]={0,0,0};
-  MEDCouplingAutoRefCountObjectPtr<MEDCouplingIMesh> ret(dynamic_cast<MEDCouplingIMesh *>(deepCpy()));
+  mcIdType retStruct[3]={0,0,0};
+  MCAuto<MEDCouplingIMesh> ret(dynamic_cast<MEDCouplingIMesh *>(deepCopy()));
   for(int i=0;i<dim;i++)
     {
-      int startNode(cellPart[i].first),endNode(cellPart[i].second+1);
-      int myDelta(endNode-startNode);
+      mcIdType startNode(cellPart[i].first),endNode(cellPart[i].second+1);
+      mcIdType myDelta(endNode-startNode);
       if(startNode<0 || startNode>=_structure[i])
         {
           std::ostringstream oss; oss << "MEDCouplingIMesh::buildStructuredSubPart : At dimension #" << i << " the start node id is " << startNode << " it should be in [0," << _structure[i] << ") !";
@@ -1005,12 +998,12 @@ MEDCouplingStructuredMesh *MEDCouplingIMesh::buildStructuredSubPart(const std::v
           std::ostringstream oss; oss << "MEDCouplingIMesh::buildStructuredSubPart : Along dimension #" << i << " the number of nodes is " << _structure[i] << ", and you are requesting for " << myDelta << " nodes wide range !" << std::endl;
           throw INTERP_KERNEL::Exception(oss.str().c_str());
         }
-      retOrigin[i]=_origin[i]+startNode*_dxyz[i];
+      retOrigin[i]=_origin[i]+FromIdType<double>(startNode)*_dxyz[i];
       retStruct[i]=myDelta;
     }
   ret->setNodeStruct(retStruct,retStruct+dim);
   ret->setOrigin(retOrigin,retOrigin+dim);
-  ret->checkCoherency();
+  ret->checkConsistencyLight();
   return ret.retn();
 }
 
@@ -1022,15 +1015,15 @@ int MEDCouplingIMesh::getSpaceDimension() const
   return _space_dim;
 }
 
-void MEDCouplingIMesh::getCoordinatesOfNode(int nodeId, std::vector<double>& coo) const
+void MEDCouplingIMesh::getCoordinatesOfNode(mcIdType nodeId, std::vector<double>& coo) const
 {
-  int tmp[3];
+  mcIdType tmp[3];
   int spaceDim(getSpaceDimension());
   getSplitNodeValues(tmp);
-  int tmp2[3];
+  mcIdType tmp2[3];
   GetPosFromId(nodeId,spaceDim,tmp,tmp2);
   for(int j=0;j<spaceDim;j++)
-    coo.push_back(_origin[j]+_dxyz[j]*tmp2[j]);
+    coo.push_back(_origin[j]+_dxyz[j]*FromIdType<double>(tmp2[j]));
 }
 
 std::string MEDCouplingIMesh::simpleRepr() const
@@ -1061,12 +1054,12 @@ std::string MEDCouplingIMesh::advancedRepr() const
 
 void MEDCouplingIMesh::getBoundingBox(double *bbox) const
 {
-  checkCoherency();
+  checkConsistencyLight();
   int dim(getSpaceDimension());
   for(int idim=0; idim<dim; idim++)
     {
       bbox[2*idim]=_origin[idim];
-      int coeff(_structure[idim]);
+      mcIdType coeff(_structure[idim]);
       if(_structure[idim]<0)
         {
           std::ostringstream oss; oss << "MEDCouplingIMesh::getBoundingBox : on axis #" << idim << " number of nodes in structure is < 0 !";
@@ -1074,7 +1067,7 @@ void MEDCouplingIMesh::getBoundingBox(double *bbox) const
         }
       if(_structure[idim]>1)
         coeff=_structure[idim]-1;
-      bbox[2*idim+1]=_origin[idim]+_dxyz[idim]*coeff;
+      bbox[2*idim+1]=_origin[idim]+_dxyz[idim]*FromIdType<double>(coeff);
     }
 }
 
@@ -1091,10 +1084,10 @@ void MEDCouplingIMesh::getBoundingBox(double *bbox) const
  */
 MEDCouplingFieldDouble *MEDCouplingIMesh::getMeasureField(bool isAbs) const
 {
-  checkCoherency();
+  checkConsistencyLight();
   std::string name="MeasureOfMesh_";
   name+=getName();
-  int nbelem(getNumberOfCells());
+  std::size_t nbelem=getNumberOfCells();
   MEDCouplingFieldDouble *field(MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME));
   field->setName(name);
   DataArrayDouble* array(DataArrayDouble::New());
@@ -1116,14 +1109,14 @@ MEDCouplingFieldDouble *MEDCouplingIMesh::getMeasureFieldOnNode(bool isAbs) cons
   //return 0;
 }
 
-int MEDCouplingIMesh::getCellContainingPoint(const double *pos, double eps) const
+mcIdType MEDCouplingIMesh::getCellContainingPoint(const double *pos, double eps) const
 {
-  int dim(getSpaceDimension()),ret(0),coeff(1);
-  for(int i=0;i<dim;i++)
+  mcIdType dim(getSpaceDimension()),ret(0),coeff(1);
+  for(mcIdType i=0;i<dim;i++)
     {
-      int nbOfCells(_structure[i]-1);
+      mcIdType nbOfCells(_structure[i]-1);
       double ref(pos[i]);
-      int tmp((int)((ref-_origin[i])/_dxyz[i]));
+      mcIdType tmp(ToIdType((ref-_origin[i])/_dxyz[i]));
       if(tmp>=0 && tmp<nbOfCells)
         {
           ret+=coeff*tmp;
@@ -1135,6 +1128,12 @@ int MEDCouplingIMesh::getCellContainingPoint(const double *pos, double eps) cons
   return ret;
 }
 
+void MEDCouplingIMesh::getCellsContainingPoint(const double *pos, double eps, std::vector<mcIdType>& elts) const
+{
+  mcIdType ret(getCellContainingPoint(pos,eps));
+  elts.push_back(ret);
+}
+
 void MEDCouplingIMesh::rotate(const double *center, const double *vector, double angle)
 {
   throw INTERP_KERNEL::Exception("No rotation available on IMesh : Traduce it to unstructured mesh to apply it !");
@@ -1186,19 +1185,20 @@ MEDCouplingMesh *MEDCouplingIMesh::mergeMyselfWith(const MEDCouplingMesh *other)
  */
 DataArrayDouble *MEDCouplingIMesh::getCoordinatesAndOwner() const
 {
-  checkCoherency();
-  MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> ret(DataArrayDouble::New());
-  int spaceDim(getSpaceDimension()),nbNodes(getNumberOfNodes());
+  checkConsistencyLight();
+  MCAuto<DataArrayDouble> ret(DataArrayDouble::New());
+  int spaceDim(getSpaceDimension());
+  mcIdType nbNodes(getNumberOfNodes());
   ret->alloc(nbNodes,spaceDim);
   double *pt(ret->getPointer());
   ret->setInfoOnComponents(buildInfoOnComponents());
-  int tmp2[3],tmp[3];
+  mcIdType tmp2[3],tmp[3];
   getSplitNodeValues(tmp);
-  for(int i=0;i<nbNodes;i++)
+  for(mcIdType i=0;i<nbNodes;i++)
     {
       GetPosFromId(i,spaceDim,tmp,tmp2);
       for(int j=0;j<spaceDim;j++)
-        pt[i*spaceDim+j]=_dxyz[j]*tmp2[j]+_origin[j];
+        pt[i*spaceDim+j]=_dxyz[j]*FromIdType<double>(tmp2[j])+_origin[j];
     }
   return ret.retn();
 }
@@ -1211,37 +1211,38 @@ DataArrayDouble *MEDCouplingIMesh::getCoordinatesAndOwner() const
  *          components. The caller is to delete this array using decrRef() as it is
  *          no more needed.
  */
-DataArrayDouble *MEDCouplingIMesh::getBarycenterAndOwner() const
+DataArrayDouble *MEDCouplingIMesh::computeCellCenterOfMass() const
 {
-  checkCoherency();
-  MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> ret(DataArrayDouble::New());
-  int spaceDim(getSpaceDimension()),nbCells(getNumberOfCells()),tmp[3],tmp2[3];
+  checkConsistencyLight();
+  MCAuto<DataArrayDouble> ret(DataArrayDouble::New());
+  int spaceDim(getSpaceDimension());
+  mcIdType nbCells(ToIdType(getNumberOfCells())),tmp[3],tmp2[3];
   ret->alloc(nbCells,spaceDim);
   double *pt(ret->getPointer()),shiftOrigin[3];
   std::transform(_dxyz,_dxyz+spaceDim,shiftOrigin,std::bind2nd(std::multiplies<double>(),0.5));
   std::transform(_origin,_origin+spaceDim,shiftOrigin,shiftOrigin,std::plus<double>());
   getSplitCellValues(tmp);
   ret->setInfoOnComponents(buildInfoOnComponents());
-  for(int i=0;i<nbCells;i++)
+  for(mcIdType i=0;i<nbCells;i++)
     {
       GetPosFromId(i,spaceDim,tmp,tmp2);
       for(int j=0;j<spaceDim;j++)
-        pt[i*spaceDim+j]=_dxyz[j]*tmp2[j]+shiftOrigin[j];
+        pt[i*spaceDim+j]=_dxyz[j]*FromIdType<double>(tmp2[j])+shiftOrigin[j];
     }
   return ret.retn();
 }
 
 DataArrayDouble *MEDCouplingIMesh::computeIsoBarycenterOfNodesPerCell() const
 {
-  return MEDCouplingIMesh::getBarycenterAndOwner();
+  return MEDCouplingIMesh::computeCellCenterOfMass();
 }
 
-void MEDCouplingIMesh::renumberCells(const int *old2NewBg, bool check)
+void MEDCouplingIMesh::renumberCells(const mcIdType *old2NewBg, bool check)
 {
-  throw INTERP_KERNEL::Exception("Functionnality of renumbering cell not available for IMesh !");
+  throw INTERP_KERNEL::Exception("Functionality of renumbering cell not available for IMesh !");
 }
 
-void MEDCouplingIMesh::getTinySerializationInformation(std::vector<double>& tinyInfoD, std::vector<int>& tinyInfo, std::vector<std::string>& littleStrings) const
+void MEDCouplingIMesh::getTinySerializationInformation(std::vector<double>& tinyInfoD, std::vector<mcIdType>& tinyInfo, std::vector<std::string>& littleStrings) const
 {
   int it,order;
   double time(getTime(it,order));
@@ -1261,29 +1262,29 @@ void MEDCouplingIMesh::getTinySerializationInformation(std::vector<double>& tiny
   tinyInfoD.insert(tinyInfoD.end(),_origin,_origin+3);
 }
 
-void MEDCouplingIMesh::resizeForUnserialization(const std::vector<int>& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector<std::string>& littleStrings) const
+void MEDCouplingIMesh::resizeForUnserialization(const std::vector<mcIdType>& tinyInfo, DataArrayIdType *a1, DataArrayDouble *a2, std::vector<std::string>& littleStrings) const
 {
   a1->alloc(0,1);
   a2->alloc(0,1);
 }
 
-void MEDCouplingIMesh::serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const
+void MEDCouplingIMesh::serialize(DataArrayIdType *&a1, DataArrayDouble *&a2) const
 {
-  a1=DataArrayInt::New();
+  a1=DataArrayIdType::New();
   a1->alloc(0,1);
   a2=DataArrayDouble::New();
   a2->alloc(0,1);
 }
 
-void MEDCouplingIMesh::unserialization(const std::vector<double>& tinyInfoD, const std::vector<int>& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2,
+void MEDCouplingIMesh::unserialization(const std::vector<double>& tinyInfoD, const std::vector<mcIdType>& tinyInfo, const DataArrayIdType *a1, DataArrayDouble *a2,
                                        const std::vector<std::string>& littleStrings)
 {
   setName(littleStrings[0]);
   setDescription(littleStrings[1]);
   setTimeUnit(littleStrings[2]);
   setAxisUnit(littleStrings[3]);
-  setTime(tinyInfoD[0],tinyInfo[0],tinyInfo[1]);
-  _space_dim=tinyInfo[2];
+  setTime(tinyInfoD[0],FromIdType<int>(tinyInfo[0]),FromIdType<int>(tinyInfo[1]));
+  _space_dim=FromIdType<int>(tinyInfo[2]);
   _structure[0]=tinyInfo[3]; _structure[1]=tinyInfo[4]; _structure[2]=tinyInfo[5];
   _dxyz[0]=tinyInfoD[1]; _dxyz[1]=tinyInfoD[2]; _dxyz[2]=tinyInfoD[3];
   _origin[0]=tinyInfoD[4]; _origin[1]=tinyInfoD[5]; _origin[2]=tinyInfoD[6];
@@ -1292,7 +1293,7 @@ void MEDCouplingIMesh::unserialization(const std::vector<double>& tinyInfoD, con
 
 void MEDCouplingIMesh::writeVTKLL(std::ostream& ofs, const std::string& cellData, const std::string& pointData, DataArrayByte *byteData) const
 {
-  checkCoherency();
+  checkConsistencyLight();
   std::ostringstream extent,origin,spacing;
   for(int i=0;i<3;i++)
     {
@@ -1320,12 +1321,12 @@ void MEDCouplingIMesh::reprQuickOverview(std::ostream& stream) const
     return ;
   stream << "\n";
   std::ostringstream stream0,stream1;
-  int nbNodes(1),nbCells(0);
+  mcIdType nbNodes(1),nbCells(0);
   bool isPb(false);
   for(int i=0;i<_space_dim;i++)
     {
-      char tmp('X'+i);
-      int tmpNodes(_structure[i]);
+      char tmp=(char)((int)('X')+i);
+      mcIdType tmpNodes(_structure[i]);
       stream1 << "- Axis " << tmp << " : " << tmpNodes << " nodes (orig=" << _origin[i] << ", inter=" << _dxyz[i] << ").";
       if(i!=_space_dim-1)
         stream1 << std::endl;
@@ -1346,6 +1347,11 @@ void MEDCouplingIMesh::reprQuickOverview(std::ostream& stream) const
   stream << stream1.str();
 }
 
+std::string MEDCouplingIMesh::getVTKFileExtension() const
+{
+  return std::string("vti");
+}
+
 std::string MEDCouplingIMesh::getVTKDataSetType() const
 {
   return std::string("ImageData");
@@ -1359,7 +1365,7 @@ std::vector<std::string> MEDCouplingIMesh::buildInfoOnComponents() const
   for(int i=0;i<dim;i++)
     {
       std::ostringstream oss;
-      char tmp('X'+i); oss << tmp;
+      char tmp=(char)((int)('X')+i); oss << tmp;
       ret[i]=DataArray::BuildInfoFromVarAndUnit(oss.str(),_axis_unit);
     }
   return ret;
@@ -1407,3 +1413,96 @@ int MEDCouplingIMesh::FindIntRoot(int val, int order)
         return ret2;
     }
 }
+
+void MEDCouplingIMesh::SpreadCoarseToFineGhost2D(const double *inPtr, double *outPtr, std::size_t nbCompo, const std::vector<mcIdType>& coarseSt, const std::vector< std::pair<mcIdType,mcIdType> >& fineLocInCoarse, const std::vector<mcIdType>& facts, mcIdType ghostSize)
+{
+  double *outPtrWork(outPtr);
+  std::vector<mcIdType> dims(MEDCouplingStructuredMesh::GetDimensionsFromCompactFrmt(fineLocInCoarse));
+  mcIdType nxwg(coarseSt[0]+2*ghostSize),fact0(facts[0]),fact1(facts[1]);
+  mcIdType kk(fineLocInCoarse[0].first+ghostSize-1+nxwg*(fineLocInCoarse[1].first+ghostSize-1));//kk is always >=0 thanks to the fact that ghostSize>=1 !
+  for(mcIdType jg=0;jg<ghostSize;jg++)
+    {
+      for(mcIdType ig=0;ig<ghostSize;ig++)
+        outPtrWork=std::copy(inPtr+kk*nbCompo,inPtr+(kk+1)*nbCompo,outPtrWork);
+      mcIdType kk0(kk+1);
+      for(mcIdType ig=0;ig<dims[0];ig++,kk0++)
+        for(mcIdType ifact=0;ifact<fact0;ifact++)
+          outPtrWork=std::copy(inPtr+(kk0)*nbCompo,inPtr+(kk0+1)*nbCompo,outPtrWork);
+      for(mcIdType ik=0;ik<ghostSize;ik++)
+        outPtrWork=std::copy(inPtr+kk0*nbCompo,inPtr+(kk0+1)*nbCompo,outPtrWork);
+    }
+  for(mcIdType j=0;j<dims[1];j++)
+    {
+      kk=fineLocInCoarse[0].first-1+ghostSize+nxwg*(fineLocInCoarse[1].first+ghostSize+j);
+      for(mcIdType jfact=0;jfact<fact1;jfact++)
+        {
+          for(mcIdType ig=0;ig<ghostSize;ig++)
+            outPtrWork=std::copy(inPtr+kk*nbCompo,inPtr+(kk+1)*nbCompo,outPtrWork);
+          mcIdType kk0(kk+1);//1 not ghost. We make the hypothesis that factors is >= ghostlev
+          for(mcIdType i=0;i<dims[0];i++,kk0++)
+            {
+              const double *loc(inPtr+kk0*nbCompo);
+              for(mcIdType ifact=0;ifact<fact0;ifact++)
+                outPtrWork=std::copy(loc,loc+nbCompo,outPtrWork);
+            }
+          for(mcIdType ig=0;ig<ghostSize;ig++)
+            outPtrWork=std::copy(inPtr+kk0*nbCompo,inPtr+(kk0+1)*nbCompo,outPtrWork);
+        }
+    }
+  kk=fineLocInCoarse[0].first+ghostSize-1+nxwg*(fineLocInCoarse[1].second+ghostSize);
+  for(mcIdType jg=0;jg<ghostSize;jg++)
+    {
+      for(mcIdType ig=0;ig<ghostSize;ig++)
+        outPtrWork=std::copy(inPtr+kk*nbCompo,inPtr+(kk+1)*nbCompo,outPtrWork);
+      mcIdType kk0(kk+1);
+      for(mcIdType ig=0;ig<dims[0];ig++,kk0++)
+        for(mcIdType ifact=0;ifact<fact0;ifact++)
+          outPtrWork=std::copy(inPtr+(kk0)*nbCompo,inPtr+(kk0+1)*nbCompo,outPtrWork);
+      for(mcIdType ik=0;ik<ghostSize;ik++)
+        outPtrWork=std::copy(inPtr+kk0*nbCompo,inPtr+(kk0+1)*nbCompo,outPtrWork);
+    }
+}
+
+void MEDCouplingIMesh::SpreadCoarseToFineGhostZone2D(const double *inPtr, double *outPtr, std::size_t nbCompo, const std::vector<mcIdType>& coarseSt, const std::vector< std::pair<mcIdType,mcIdType> >& fineLocInCoarse, const std::vector<mcIdType>& facts, mcIdType ghostSize)
+{
+  double *outPtr2(outPtr);
+  std::vector<mcIdType> dims(MEDCouplingStructuredMesh::GetDimensionsFromCompactFrmt(fineLocInCoarse));
+  mcIdType nxwg(coarseSt[0]+2*ghostSize),fact0(facts[0]),fact1(facts[1]);
+  mcIdType kk(fineLocInCoarse[0].first+ghostSize-1+nxwg*(fineLocInCoarse[1].first+ghostSize-1));//kk is always >=0 thanks to the fact that ghostSize>=1 !
+  for(mcIdType jg=0;jg<ghostSize;jg++)
+    {
+      for(mcIdType ig=0;ig<ghostSize;ig++)
+        outPtr2=std::copy(inPtr+kk*nbCompo,inPtr+(kk+1)*nbCompo,outPtr2);
+      mcIdType kk0(kk+1);
+      for(mcIdType ig=0;ig<dims[0];ig++,kk0++)
+        for(mcIdType ifact=0;ifact<fact0;ifact++)
+          outPtr2=std::copy(inPtr+(kk0)*nbCompo,inPtr+(kk0+1)*nbCompo,outPtr2);
+      for(mcIdType ik=0;ik<ghostSize;ik++)
+        outPtr2=std::copy(inPtr+kk0*nbCompo,inPtr+(kk0+1)*nbCompo,outPtr2);
+    }
+  for(mcIdType j=0;j<dims[1];j++)
+    {
+      kk=fineLocInCoarse[0].first-1+ghostSize+nxwg*(fineLocInCoarse[1].first+ghostSize+j);
+      for(mcIdType jfact=0;jfact<fact1;jfact++)
+        {
+          for(mcIdType ig=0;ig<ghostSize;ig++)
+            outPtr2=std::copy(inPtr+kk*nbCompo,inPtr+(kk+1)*nbCompo,outPtr2);
+          mcIdType kk0(kk+1+dims[0]);//1 not ghost. We make the hypothesis that factors is >= ghostlev
+          outPtr2+=fact0*nbCompo*dims[0];
+          for(mcIdType ig=0;ig<ghostSize;ig++)
+            outPtr2=std::copy(inPtr+kk0*nbCompo,inPtr+(kk0+1)*nbCompo,outPtr2);
+        }
+    }
+  kk=fineLocInCoarse[0].first+ghostSize-1+nxwg*(fineLocInCoarse[1].second+ghostSize);
+  for(mcIdType jg=0;jg<ghostSize;jg++)
+    {
+      for(mcIdType ig=0;ig<ghostSize;ig++)
+        outPtr2=std::copy(inPtr+kk*nbCompo,inPtr+(kk+1)*nbCompo,outPtr2);
+      mcIdType kk0(kk+1);
+      for(mcIdType ig=0;ig<dims[0];ig++,kk0++)
+        for(mcIdType ifact=0;ifact<fact0;ifact++)
+          outPtr2=std::copy(inPtr+(kk0)*nbCompo,inPtr+(kk0+1)*nbCompo,outPtr2);
+      for(mcIdType ik=0;ik<ghostSize;ik++)
+        outPtr2=std::copy(inPtr+kk0*nbCompo,inPtr+(kk0+1)*nbCompo,outPtr2);
+    }
+}