Salome HOME
Merge branch 'master' of salome:modules/med
authorana <ana@opencascade.com>
Mon, 5 May 2014 15:05:34 +0000 (19:05 +0400)
committerana <ana@opencascade.com>
Mon, 5 May 2014 15:05:34 +0000 (19:05 +0400)
15 files changed:
src/MEDCoupling/CMakeLists.txt
src/MEDCoupling/MEDCouplingAHOGMesh.cxx [deleted file]
src/MEDCoupling/MEDCouplingAHOGMesh.hxx [deleted file]
src/MEDCoupling/MEDCouplingCMesh.cxx
src/MEDCoupling/MEDCouplingCMesh.hxx
src/MEDCoupling/MEDCouplingCartesianAMRMesh.cxx [new file with mode: 0644]
src/MEDCoupling/MEDCouplingCartesianAMRMesh.hxx [new file with mode: 0644]
src/MEDCoupling/MEDCouplingCurveLinearMesh.cxx
src/MEDCoupling/MEDCouplingCurveLinearMesh.hxx
src/MEDCoupling/MEDCouplingIMesh.cxx
src/MEDCoupling/MEDCouplingIMesh.hxx
src/MEDCoupling/MEDCouplingStructuredMesh.cxx
src/MEDCoupling/MEDCouplingStructuredMesh.hxx
src/MEDCoupling_Swig/MEDCouplingBasicsTest.py
src/MEDCoupling_Swig/MEDCouplingCommon.i

index bbd0d8ea0de8248158607a2561d52dce1c0e0449..6ac3fbd8682e3eaba9336fcbc1841b098a16333f 100644 (file)
@@ -55,7 +55,7 @@ SET(medcoupling_SOURCES
   MEDCouplingMultiFields.cxx
   MEDCouplingDefinitionTime.cxx
   MEDCouplingFieldOverTime.cxx
-  MEDCouplingAHOGMesh.cxx
+  MEDCouplingCartesianAMRMesh.cxx
   )
 
 SET(medcouplingremapper_SOURCES
diff --git a/src/MEDCoupling/MEDCouplingAHOGMesh.cxx b/src/MEDCoupling/MEDCouplingAHOGMesh.cxx
deleted file mode 100644 (file)
index 82e9bd8..0000000
+++ /dev/null
@@ -1,237 +0,0 @@
-// Copyright (C) 2007-2014  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
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License, or (at your option) any later version.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// Author : Anthony Geay
-
-#include "MEDCouplingAHOGMesh.hxx"
-#include "MEDCouplingIMesh.hxx"
-#include "MEDCouplingUMesh.hxx"
-
-#include <limits>
-#include <sstream>
-
-using namespace ParaMEDMEM;
-
-/// @cond INTERNAL
-
-/*!
- * \param [in] mesh not null pointer of refined mesh replacing the cell range of \a father defined by the bottom left and top right just after.
- * \param [in] bottomLeftTopRight a vector equal to the space dimension of \a mesh that specifies for each dimension, the included cell start of the range for the first element of the pair,
- *                                a the end cell (\b excluded) of the range for the second element of the pair.
- */
-MEDCouplingAHOGPatch::MEDCouplingAHOGPatch(MEDCouplingAHOGMesh *mesh, const std::vector< std::pair<int,int> >& bottomLeftTopRight)
-{
-  if(!mesh)
-    throw INTERP_KERNEL::Exception("EDCouplingAHOGPatch constructor : input mesh is NULL !");
-  _mesh=mesh; _mesh->incrRef();
-  int dim((int)bottomLeftTopRight.size());
-  if(dim!=_mesh->getSpaceDimension())
-    throw INTERP_KERNEL::Exception("MEDCouplingAHOGPatch constructor : space dimension of father and input bottomLeft/topRight size mismatches !");
-  _bl_tr=bottomLeftTopRight;
-}
-
-int MEDCouplingAHOGPatch::getNumberOfCellsRecursiveWithOverlap() const
-{
-  return _mesh->getNumberOfCellsRecursiveWithOverlap();
-}
-
-int MEDCouplingAHOGPatch::getNumberOfCellsRecursiveWithoutOverlap() const
-{
-  return _mesh->getNumberOfCellsRecursiveWithoutOverlap();
-}
-
-int MEDCouplingAHOGPatch::getMaxNumberOfLevelsRelativeToThis() const
-{
-  return _mesh->getMaxNumberOfLevelsRelativeToThis();
-}
-
-void MEDCouplingAHOGPatch::addPatch(const std::vector< std::pair<int,int> >& bottomLeftTopRight, int factor)
-{
-  return _mesh->addPatch(bottomLeftTopRight,factor);
-}
-
-int MEDCouplingAHOGPatch::getNumberOfOverlapedCellsForFather() const
-{
-  return MEDCouplingStructuredMesh::DeduceNumberOfGivenRangeInCompactFrmt(_bl_tr);
-}
-
-std::size_t MEDCouplingAHOGPatch::getHeapMemorySizeWithoutChildren() const
-{
-  std::size_t ret(sizeof(MEDCouplingAHOGPatch));
-  ret+=_bl_tr.capacity()*sizeof(std::pair<int,int>);
-  return ret;
-}
-
-std::vector<const BigMemoryObject *> MEDCouplingAHOGPatch::getDirectChildren() const
-{
-  std::vector<const BigMemoryObject *> ret;
-  if((const MEDCouplingAHOGMesh *)_mesh)
-    ret.push_back((const MEDCouplingAHOGMesh *)_mesh);
-  return ret;
-}
-
-/// @endcond
-
-
-MEDCouplingAHOGMesh *MEDCouplingAHOGMesh::New(const std::string& meshName, int spaceDim, const int *nodeStrctStart, const int *nodeStrctStop,
-                                              const double *originStart, const double *originStop, const double *dxyzStart, const double *dxyzStop)
-{
-  return new MEDCouplingAHOGMesh(meshName,spaceDim,nodeStrctStart,nodeStrctStop,originStart,originStop,dxyzStart,dxyzStop);
-}
-
-int MEDCouplingAHOGMesh::getSpaceDimension() const
-{
-  return _mesh->getSpaceDimension();
-}
-
-int MEDCouplingAHOGMesh::getMaxNumberOfLevelsRelativeToThis() const
-{
-  int ret(1);
-  for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingAHOGPatch> >::const_iterator it=_patches.begin();it!=_patches.end();it++)
-    ret=std::max(ret,(*it)->getMaxNumberOfLevelsRelativeToThis()+1);
-  return ret;
-}
-
-int MEDCouplingAHOGMesh::getNumberOfCellsAtCurrentLevel() const
-{
-  return _mesh->getNumberOfCells();
-}
-
-int MEDCouplingAHOGMesh::getNumberOfCellsRecursiveWithOverlap() const
-{
-  int ret(_mesh->getNumberOfCells());
-  for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingAHOGPatch> >::const_iterator it=_patches.begin();it!=_patches.end();it++)
-    {
-      ret+=(*it)->getNumberOfCellsRecursiveWithOverlap();
-    }
-  return ret;
-}
-
-int MEDCouplingAHOGMesh::getNumberOfCellsRecursiveWithoutOverlap() const
-{
-  int ret(_mesh->getNumberOfCells());
-  for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingAHOGPatch> >::const_iterator it=_patches.begin();it!=_patches.end();it++)
-    {
-      ret-=(*it)->getNumberOfOverlapedCellsForFather();
-      ret+=(*it)->getNumberOfCellsRecursiveWithoutOverlap();
-    }
-  return ret;
-}
-
-const MEDCouplingAHOGMesh *MEDCouplingAHOGMesh::getFather() const
-{
-  return _father;
-}
-
-const MEDCouplingAHOGMesh *MEDCouplingAHOGMesh::getGodFather() const
-{
-  if(_father==0)
-    return this;
-  else
-    return _father->getGodFather();
-}
-
-/*!
- * \param [in] bottomLeftTopRight a vector equal to the space dimension of \a mesh that specifies for each dimension, the included cell start of the range for the first element of the pair,
- *                                a the end cell (\b excluded) of the range for the second element of the pair.
- * \param [in] factor The != 0 factor of refinement.
- */
-void MEDCouplingAHOGMesh::addPatch(const std::vector< std::pair<int,int> >& bottomLeftTopRight, int factor)
-{
-  MEDCouplingAutoRefCountObjectPtr<MEDCouplingIMesh> mesh(static_cast<MEDCouplingIMesh *>(_mesh->buildStructuredSubPart(bottomLeftTopRight)));
-  mesh->refineWithFactor(factor);
-  MEDCouplingAutoRefCountObjectPtr<MEDCouplingAHOGMesh> zeMesh(new MEDCouplingAHOGMesh(this,mesh));
-  MEDCouplingAutoRefCountObjectPtr<MEDCouplingAHOGPatch> elt(new MEDCouplingAHOGPatch(zeMesh,bottomLeftTopRight));
-  _patches.push_back(elt);
-}
-
-int MEDCouplingAHOGMesh::getNumberOfPatches() const
-{
-  return (int)_patches.size();
-}
-
-const MEDCouplingAHOGPatch *MEDCouplingAHOGMesh::getPatch(int patchId) const
-{
-  int sz(getNumberOfPatches());
-  if(patchId<0 || patchId>=sz)
-    {
-      std::ostringstream oss; oss << "MEDCouplingAHOGMesh::getPatch : invalid patchId (" << patchId << ") ! Must be in [0," << sz << ") !";
-      throw INTERP_KERNEL::Exception(oss.str().c_str());
-    }
-  return _patches[patchId];
-}
-
-MEDCouplingUMesh *MEDCouplingAHOGMesh::buildUnstructured() const
-{
-  MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> part(_mesh->buildUnstructured());
-  std::vector<bool> bs(_mesh->getNumberOfCells(),false);
-  std::vector<int> cgs(_mesh->getCellGridStructure());
-  std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> > msSafe(_patches.size()+1);
-  std::size_t ii(0);
-  for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingAHOGPatch> >::const_iterator it=_patches.begin();it!=_patches.end();it++,ii++)
-    {
-      MEDCouplingStructuredMesh::SwitchOnIdsFrom(cgs,(*it)->getBLTRRange(),bs);
-      msSafe[ii+1]=(*it)->getMesh()->buildUnstructured();
-    }
-  MEDCouplingAutoRefCountObjectPtr<DataArrayInt> eltsOff(DataArrayInt::BuildListOfSwitchedOff(bs));
-  msSafe[0]=static_cast<MEDCouplingUMesh *>(part->buildPartOfMySelf(eltsOff->begin(),eltsOff->end(),false));
-  std::vector< const MEDCouplingUMesh * > ms(msSafe.size());
-  for(std::size_t i=0;i<msSafe.size();i++)
-    ms[i]=msSafe[i];
-  return MEDCouplingUMesh::MergeUMeshes(ms);
-}
-
-MEDCouplingAHOGMesh::MEDCouplingAHOGMesh(const std::string& meshName, int spaceDim, const int *nodeStrctStart, const int *nodeStrctStop,
-                                         const double *originStart, const double *originStop, const double *dxyzStart, const double *dxyzStop):_father(0)
-{
-  _mesh=MEDCouplingIMesh::New(meshName,spaceDim,nodeStrctStart,nodeStrctStop,originStart,originStop,dxyzStart,dxyzStop);
-}
-
-MEDCouplingAHOGMesh::MEDCouplingAHOGMesh(MEDCouplingAHOGMesh *father, MEDCouplingIMesh *mesh):_father(father)
-{
-  if(!_father)
-    throw INTERP_KERNEL::Exception("MEDCouplingAHOGMesh(MEDCouplingIMesh *mesh) constructor : empty father !");
-  if(!mesh)
-    throw INTERP_KERNEL::Exception("MEDCouplingAHOGMesh(MEDCouplingIMesh *mesh) constructor : The input mesh is null !");
-  mesh->checkCoherency();
-  _mesh=mesh; _mesh->incrRef();
-}
-
-std::size_t MEDCouplingAHOGMesh::getHeapMemorySizeWithoutChildren() const
-{
-  return sizeof(MEDCouplingAHOGMesh);
-}
-
-std::vector<const BigMemoryObject *> MEDCouplingAHOGMesh::getDirectChildren() const
-{
-  std::vector<const BigMemoryObject *> ret;
-  if((const MEDCouplingIMesh *)_mesh)
-    ret.push_back((const MEDCouplingIMesh *)_mesh);
-  for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingAHOGPatch> >::const_iterator it=_patches.begin();it!=_patches.end();it++)
-    {
-      if((const MEDCouplingAHOGPatch*)*it)
-        ret.push_back((const MEDCouplingAHOGPatch*)*it);
-    }
-  return ret;
-}
-
-void MEDCouplingAHOGMesh::updateTime() const
-{
-  if((const MEDCouplingIMesh *)_mesh)
-    updateTimeWith(*_mesh);
-}
diff --git a/src/MEDCoupling/MEDCouplingAHOGMesh.hxx b/src/MEDCoupling/MEDCouplingAHOGMesh.hxx
deleted file mode 100644 (file)
index b2e7554..0000000
+++ /dev/null
@@ -1,101 +0,0 @@
-// Copyright (C) 2007-2014  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
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License, or (at your option) any later version.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// Author : Anthony Geay
-
-#ifndef __MEDCOUPLINGAHOGMESH_HXX__
-#define __MEDCOUPLINGAHOGMESH_HXX__
-
-#include "MEDCoupling.hxx"
-#include "MEDCouplingTimeLabel.hxx"
-#include "MEDCouplingRefCountObject.hxx"
-#include "MEDCouplingAutoRefCountObjectPtr.hxx"
-
-#include "InterpKernelException.hxx"
-
-namespace ParaMEDMEM
-{
-  class MEDCouplingIMesh;
-  class MEDCouplingUMesh;
-  class MEDCouplingAHOGMesh;
-
-  /// @cond INTERNAL
-  class MEDCouplingAHOGPatch : public RefCountObject
-  {
-  public:
-    MEDCouplingAHOGPatch(MEDCouplingAHOGMesh *mesh, const std::vector< std::pair<int,int> >& bottomLeftTopRight);
-    // direct forward to _mesh
-    MEDCOUPLING_EXPORT int getNumberOfCellsRecursiveWithOverlap() const;
-    MEDCOUPLING_EXPORT int getNumberOfCellsRecursiveWithoutOverlap() const;
-    MEDCOUPLING_EXPORT int getMaxNumberOfLevelsRelativeToThis() const;
-    MEDCOUPLING_EXPORT void addPatch(const std::vector< std::pair<int,int> >& bottomLeftTopRight, int factor);
-    // end of direct forward to _mesh
-    MEDCOUPLING_EXPORT int getNumberOfOverlapedCellsForFather() const;
-    // basic set/get
-    MEDCOUPLING_EXPORT const std::vector< std::pair<int,int> >& getBLTRRange() const { return _bl_tr; }
-    MEDCOUPLING_EXPORT const MEDCouplingAHOGMesh *getMesh() const { return _mesh; }
-  private:
-    std::size_t getHeapMemorySizeWithoutChildren() const;
-    std::vector<const BigMemoryObject *> getDirectChildren() const;
-  private:
-    //! bottom left/top right cell range relative to \a _father
-    std::vector< std::pair<int,int> > _bl_tr;
-    MEDCouplingAutoRefCountObjectPtr<MEDCouplingAHOGMesh> _mesh;
-  };
-  /// @endcond
-
-  /*!
-   * This class is the base class dedicated to AMR using Adaptative Hierarchical Overlapped image Grid.
-   * This class does \b NOT inherit from MEDCouplingMesh because this class overlaps image grid structured meshes to perform adaptative mesh refinement.
-   * But this class aggregates MEDCouplingMesh instances !
-   */
-  class MEDCouplingAHOGMesh : public RefCountObject, public TimeLabel
-  {
-  public:
-    MEDCOUPLING_EXPORT static MEDCouplingAHOGMesh *New(const std::string& meshName, int spaceDim, const int *nodeStrctStart, const int *nodeStrctStop,
-                                                       const double *originStart, const double *originStop, const double *dxyzStart, const double *dxyzStop);
-    MEDCOUPLING_EXPORT int getSpaceDimension() const;
-    MEDCOUPLING_EXPORT int getMaxNumberOfLevelsRelativeToThis() const;
-    MEDCOUPLING_EXPORT int getNumberOfCellsAtCurrentLevel() const;
-    MEDCOUPLING_EXPORT int getNumberOfCellsRecursiveWithOverlap() const;
-    MEDCOUPLING_EXPORT int getNumberOfCellsRecursiveWithoutOverlap() const;
-    //
-    MEDCOUPLING_EXPORT const MEDCouplingAHOGMesh *getFather() const;
-    MEDCOUPLING_EXPORT const MEDCouplingAHOGMesh *getGodFather() const;
-    MEDCOUPLING_EXPORT void addPatch(const std::vector< std::pair<int,int> >& bottomLeftTopRight, int factor);
-    MEDCOUPLING_EXPORT int getNumberOfPatches() const;
-    MEDCOUPLING_EXPORT const MEDCouplingAHOGPatch *getPatch(int patchId) const;
-    //
-    MEDCOUPLING_EXPORT MEDCouplingUMesh *buildUnstructured() const;
-  private:
-    MEDCouplingAHOGMesh(const std::string& meshName, int spaceDim, const int *nodeStrctStart, const int *nodeStrctStop,
-                        const double *originStart, const double *originStop, const double *dxyzStart, const double *dxyzStop);
-    MEDCouplingAHOGMesh(MEDCouplingAHOGMesh *father, MEDCouplingIMesh *mesh);
-  protected:
-    MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
-    MEDCOUPLING_EXPORT std::vector<const BigMemoryObject *> getDirectChildren() const;
-    MEDCOUPLING_EXPORT void updateTime() const;
-  private:
-    MEDCouplingAHOGMesh *_father;
-    MEDCouplingAutoRefCountObjectPtr<MEDCouplingIMesh> _mesh;
-    std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingAHOGPatch> > _patches;
-  };
-}
-
-#endif
-
index 3eeadc1423d2a5db19d2b1f3f7d2c63ef2eea5a1..65ee343c1dc63297911f338e5ca5f15773551617 100644 (file)
@@ -274,30 +274,6 @@ void MEDCouplingCMesh::checkCoherency2(double eps) const
   checkCoherency1(eps);
 }
 
-void MEDCouplingCMesh::getSplitCellValues(int *res) const
-{
-  int meshDim(getMeshDimension());
-  for(int l=0;l<meshDim;l++)
-    {
-      int val=1;
-      for(int p=0;p<meshDim-l-1;p++)
-        val*=getCoordsAt(p)->getNbOfElems()-1;
-      res[meshDim-l-1]=val;
-    }
-}
-
-void MEDCouplingCMesh::getSplitNodeValues(int *res) const
-{
-  int spaceDim(getSpaceDimension());
-  for(int l=0;l<spaceDim;l++)
-    {
-      int val=1;
-      for(int p=0;p<spaceDim-l-1;p++)
-        val*=getCoordsAt(p)->getNbOfElems();
-      res[spaceDim-l-1]=val;
-    }
-}
-
 void MEDCouplingCMesh::getNodeGridStructure(int *res) const
 {
   std::vector<int> ret(getNodeGridStructure());
index 92909bea39b6b04e87657926a943595b2ee4371d..e19f6a099b719fa04d3aaf71695a76f09526aa10 100644 (file)
@@ -71,8 +71,6 @@ namespace ParaMEDMEM
     MEDCOUPLING_EXPORT DataArrayDouble *computeIsoBarycenterOfNodesPerCell() const;
     MEDCOUPLING_EXPORT void renumberCells(const int *old2NewBg, bool check=true);
     //some useful methods
-    MEDCOUPLING_EXPORT void getSplitCellValues(int *res) const;
-    MEDCOUPLING_EXPORT void getSplitNodeValues(int *res) const;
     MEDCOUPLING_EXPORT void getNodeGridStructure(int *res) const;
     MEDCOUPLING_EXPORT std::vector<int> getNodeGridStructure() const;
     MEDCouplingStructuredMesh *buildStructuredSubPart(const std::vector< std::pair<int,int> >& cellPart) const;
diff --git a/src/MEDCoupling/MEDCouplingCartesianAMRMesh.cxx b/src/MEDCoupling/MEDCouplingCartesianAMRMesh.cxx
new file mode 100644 (file)
index 0000000..08f1d1f
--- /dev/null
@@ -0,0 +1,269 @@
+// Copyright (C) 2007-2014  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
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// Author : Anthony Geay
+
+#include "MEDCouplingCartesianAMRMesh.hxx"
+#include "MEDCouplingIMesh.hxx"
+#include "MEDCouplingUMesh.hxx"
+
+#include <limits>
+#include <sstream>
+
+using namespace ParaMEDMEM;
+
+/// @cond INTERNAL
+
+/*!
+ * \param [in] mesh not null pointer of refined mesh replacing the cell range of \a father defined by the bottom left and top right just after.
+ * \param [in] bottomLeftTopRight a vector equal to the space dimension of \a mesh that specifies for each dimension, the included cell start of the range for the first element of the pair,
+ *                                a the end cell (\b excluded) of the range for the second element of the pair.
+ */
+MEDCouplingCartesianAMRPatch::MEDCouplingCartesianAMRPatch(MEDCouplingCartesianAMRMesh *mesh, const std::vector< std::pair<int,int> >& bottomLeftTopRight)
+{
+  if(!mesh)
+    throw INTERP_KERNEL::Exception("EDCouplingCartesianAMRPatch constructor : input mesh is NULL !");
+  _mesh=mesh; _mesh->incrRef();
+  int dim((int)bottomLeftTopRight.size());
+  if(dim!=_mesh->getSpaceDimension())
+    throw INTERP_KERNEL::Exception("MEDCouplingCartesianAMRPatch constructor : space dimension of father and input bottomLeft/topRight size mismatches !");
+  _bl_tr=bottomLeftTopRight;
+}
+
+int MEDCouplingCartesianAMRPatch::getNumberOfCellsRecursiveWithOverlap() const
+{
+  return _mesh->getNumberOfCellsRecursiveWithOverlap();
+}
+
+int MEDCouplingCartesianAMRPatch::getNumberOfCellsRecursiveWithoutOverlap() const
+{
+  return _mesh->getNumberOfCellsRecursiveWithoutOverlap();
+}
+
+int MEDCouplingCartesianAMRPatch::getMaxNumberOfLevelsRelativeToThis() const
+{
+  return _mesh->getMaxNumberOfLevelsRelativeToThis();
+}
+
+void MEDCouplingCartesianAMRPatch::addPatch(const std::vector< std::pair<int,int> >& bottomLeftTopRight, int factor)
+{
+  return _mesh->addPatch(bottomLeftTopRight,factor);
+}
+
+int MEDCouplingCartesianAMRPatch::getNumberOfOverlapedCellsForFather() const
+{
+  return MEDCouplingStructuredMesh::DeduceNumberOfGivenRangeInCompactFrmt(_bl_tr);
+}
+
+std::size_t MEDCouplingCartesianAMRPatch::getHeapMemorySizeWithoutChildren() const
+{
+  std::size_t ret(sizeof(MEDCouplingCartesianAMRPatch));
+  ret+=_bl_tr.capacity()*sizeof(std::pair<int,int>);
+  return ret;
+}
+
+std::vector<const BigMemoryObject *> MEDCouplingCartesianAMRPatch::getDirectChildren() const
+{
+  std::vector<const BigMemoryObject *> ret;
+  if((const MEDCouplingCartesianAMRMesh *)_mesh)
+    ret.push_back((const MEDCouplingCartesianAMRMesh *)_mesh);
+  return ret;
+}
+
+/// @endcond
+
+
+MEDCouplingCartesianAMRMesh *MEDCouplingCartesianAMRMesh::New(const std::string& meshName, int spaceDim, const int *nodeStrctStart, const int *nodeStrctStop,
+                                              const double *originStart, const double *originStop, const double *dxyzStart, const double *dxyzStop)
+{
+  return new MEDCouplingCartesianAMRMesh(meshName,spaceDim,nodeStrctStart,nodeStrctStop,originStart,originStop,dxyzStart,dxyzStop);
+}
+
+int MEDCouplingCartesianAMRMesh::getSpaceDimension() const
+{
+  return _mesh->getSpaceDimension();
+}
+
+int MEDCouplingCartesianAMRMesh::getMaxNumberOfLevelsRelativeToThis() const
+{
+  int ret(1);
+  for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingCartesianAMRPatch> >::const_iterator it=_patches.begin();it!=_patches.end();it++)
+    ret=std::max(ret,(*it)->getMaxNumberOfLevelsRelativeToThis()+1);
+  return ret;
+}
+
+int MEDCouplingCartesianAMRMesh::getNumberOfCellsAtCurrentLevel() const
+{
+  return _mesh->getNumberOfCells();
+}
+
+int MEDCouplingCartesianAMRMesh::getNumberOfCellsRecursiveWithOverlap() const
+{
+  int ret(_mesh->getNumberOfCells());
+  for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingCartesianAMRPatch> >::const_iterator it=_patches.begin();it!=_patches.end();it++)
+    {
+      ret+=(*it)->getNumberOfCellsRecursiveWithOverlap();
+    }
+  return ret;
+}
+
+int MEDCouplingCartesianAMRMesh::getNumberOfCellsRecursiveWithoutOverlap() const
+{
+  int ret(_mesh->getNumberOfCells());
+  for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingCartesianAMRPatch> >::const_iterator it=_patches.begin();it!=_patches.end();it++)
+    {
+      ret-=(*it)->getNumberOfOverlapedCellsForFather();
+      ret+=(*it)->getNumberOfCellsRecursiveWithoutOverlap();
+    }
+  return ret;
+}
+
+const MEDCouplingCartesianAMRMesh *MEDCouplingCartesianAMRMesh::getFather() const
+{
+  return _father;
+}
+
+const MEDCouplingCartesianAMRMesh *MEDCouplingCartesianAMRMesh::getGodFather() const
+{
+  if(_father==0)
+    return this;
+  else
+    return _father->getGodFather();
+}
+
+void MEDCouplingCartesianAMRMesh::detachFromFather()
+{
+  _father=0;
+}
+
+/*!
+ * \param [in] bottomLeftTopRight a vector equal to the space dimension of \a mesh that specifies for each dimension, the included cell start of the range for the first element of the pair,
+ *                                a the end cell (\b excluded) of the range for the second element of the pair.
+ * \param [in] factor The != 0 factor of refinement.
+ */
+void MEDCouplingCartesianAMRMesh::addPatch(const std::vector< std::pair<int,int> >& bottomLeftTopRight, int factor)
+{
+  MEDCouplingAutoRefCountObjectPtr<MEDCouplingIMesh> mesh(static_cast<MEDCouplingIMesh *>(_mesh->buildStructuredSubPart(bottomLeftTopRight)));
+  mesh->refineWithFactor(factor);
+  MEDCouplingAutoRefCountObjectPtr<MEDCouplingCartesianAMRMesh> zeMesh(new MEDCouplingCartesianAMRMesh(this,mesh));
+  MEDCouplingAutoRefCountObjectPtr<MEDCouplingCartesianAMRPatch> elt(new MEDCouplingCartesianAMRPatch(zeMesh,bottomLeftTopRight));
+  _patches.push_back(elt);
+}
+
+void MEDCouplingCartesianAMRMesh::removePatch(int patchId)
+{
+  checkPatchId(patchId);
+  int sz((int)_patches.size()),j(0);
+  std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingCartesianAMRPatch> > patches(sz-1);
+  for(int i=0;i<sz;i++)
+    if(i!=patchId)
+      patches[j++]=_patches[i];
+  (const_cast<MEDCouplingCartesianAMRMesh *>(_patches[patchId]->getMesh()))->detachFromFather();
+  _patches=patches;
+  declareAsNew();
+}
+
+int MEDCouplingCartesianAMRMesh::getNumberOfPatches() const
+{
+  return (int)_patches.size();
+}
+
+const MEDCouplingCartesianAMRPatch *MEDCouplingCartesianAMRMesh::getPatch(int patchId) const
+{
+  checkPatchId(patchId);
+  return _patches[patchId];
+}
+
+MEDCouplingUMesh *MEDCouplingCartesianAMRMesh::buildUnstructured() const
+{
+  MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> part(_mesh->buildUnstructured());
+  std::vector<bool> bs(_mesh->getNumberOfCells(),false);
+  std::vector<int> cgs(_mesh->getCellGridStructure());
+  std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> > msSafe(_patches.size()+1);
+  std::size_t ii(0);
+  for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingCartesianAMRPatch> >::const_iterator it=_patches.begin();it!=_patches.end();it++,ii++)
+    {
+      MEDCouplingStructuredMesh::SwitchOnIdsFrom(cgs,(*it)->getBLTRRange(),bs);
+      msSafe[ii+1]=(*it)->getMesh()->buildUnstructured();
+    }
+  MEDCouplingAutoRefCountObjectPtr<DataArrayInt> eltsOff(DataArrayInt::BuildListOfSwitchedOff(bs));
+  msSafe[0]=static_cast<MEDCouplingUMesh *>(part->buildPartOfMySelf(eltsOff->begin(),eltsOff->end(),false));
+  std::vector< const MEDCouplingUMesh * > ms(msSafe.size());
+  for(std::size_t i=0;i<msSafe.size();i++)
+    ms[i]=msSafe[i];
+  return MEDCouplingUMesh::MergeUMeshes(ms);
+}
+
+MEDCouplingCartesianAMRMesh::MEDCouplingCartesianAMRMesh(const std::string& meshName, int spaceDim, const int *nodeStrctStart, const int *nodeStrctStop,
+                                         const double *originStart, const double *originStop, const double *dxyzStart, const double *dxyzStop):_father(0)
+{
+  _mesh=MEDCouplingIMesh::New(meshName,spaceDim,nodeStrctStart,nodeStrctStop,originStart,originStop,dxyzStart,dxyzStop);
+}
+
+MEDCouplingCartesianAMRMesh::MEDCouplingCartesianAMRMesh(MEDCouplingCartesianAMRMesh *father, MEDCouplingIMesh *mesh):_father(father)
+{
+  if(!_father)
+    throw INTERP_KERNEL::Exception("MEDCouplingCartesianAMRMesh(MEDCouplingIMesh *mesh) constructor : empty father !");
+  if(!mesh)
+    throw INTERP_KERNEL::Exception("MEDCouplingCartesianAMRMesh(MEDCouplingIMesh *mesh) constructor : The input mesh is null !");
+  mesh->checkCoherency();
+  _mesh=mesh; _mesh->incrRef();
+}
+
+void MEDCouplingCartesianAMRMesh::checkPatchId(int patchId) const
+{
+  int sz(getNumberOfPatches());
+  if(patchId<0 || patchId>=sz)
+    {
+      std::ostringstream oss; oss << "MEDCouplingCartesianAMRMesh::checkPatchId : invalid patchId (" << patchId << ") ! Must be in [0," << sz << ") !";
+      throw INTERP_KERNEL::Exception(oss.str().c_str());
+    }
+}
+
+std::size_t MEDCouplingCartesianAMRMesh::getHeapMemorySizeWithoutChildren() const
+{
+  return sizeof(MEDCouplingCartesianAMRMesh);
+}
+
+std::vector<const BigMemoryObject *> MEDCouplingCartesianAMRMesh::getDirectChildren() const
+{
+  std::vector<const BigMemoryObject *> ret;
+  if((const MEDCouplingIMesh *)_mesh)
+    ret.push_back((const MEDCouplingIMesh *)_mesh);
+  for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingCartesianAMRPatch> >::const_iterator it=_patches.begin();it!=_patches.end();it++)
+    {
+      if((const MEDCouplingCartesianAMRPatch*)*it)
+        ret.push_back((const MEDCouplingCartesianAMRPatch*)*it);
+    }
+  return ret;
+}
+
+void MEDCouplingCartesianAMRMesh::updateTime() const
+{
+  if((const MEDCouplingIMesh *)_mesh)
+    updateTimeWith(*_mesh);
+  for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingCartesianAMRPatch> >::const_iterator it=_patches.begin();it!=_patches.end();it++)
+    {
+      const MEDCouplingCartesianAMRPatch *elt(*it);
+      if(!elt)
+        continue;
+      const MEDCouplingCartesianAMRMesh *mesh(elt->getMesh());
+      if(mesh)
+        updateTimeWith(*mesh);
+    }
+}
diff --git a/src/MEDCoupling/MEDCouplingCartesianAMRMesh.hxx b/src/MEDCoupling/MEDCouplingCartesianAMRMesh.hxx
new file mode 100644 (file)
index 0000000..46cee80
--- /dev/null
@@ -0,0 +1,104 @@
+// Copyright (C) 2007-2014  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
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// Author : Anthony Geay
+
+#ifndef __MEDCOUPLINGCARTESIANAMRMESH_HXX__
+#define __MEDCOUPLINGCARTESIANAMRMESH_HXX__
+
+#include "MEDCoupling.hxx"
+#include "MEDCouplingTimeLabel.hxx"
+#include "MEDCouplingRefCountObject.hxx"
+#include "MEDCouplingAutoRefCountObjectPtr.hxx"
+
+#include "InterpKernelException.hxx"
+
+namespace ParaMEDMEM
+{
+  class MEDCouplingIMesh;
+  class MEDCouplingUMesh;
+  class MEDCouplingCartesianAMRMesh;
+
+  /// @cond INTERNAL
+  class MEDCouplingCartesianAMRPatch : public RefCountObject
+  {
+  public:
+    MEDCouplingCartesianAMRPatch(MEDCouplingCartesianAMRMesh *mesh, const std::vector< std::pair<int,int> >& bottomLeftTopRight);
+    // direct forward to _mesh
+    MEDCOUPLING_EXPORT int getNumberOfCellsRecursiveWithOverlap() const;
+    MEDCOUPLING_EXPORT int getNumberOfCellsRecursiveWithoutOverlap() const;
+    MEDCOUPLING_EXPORT int getMaxNumberOfLevelsRelativeToThis() const;
+    MEDCOUPLING_EXPORT void addPatch(const std::vector< std::pair<int,int> >& bottomLeftTopRight, int factor);
+    // end of direct forward to _mesh
+    MEDCOUPLING_EXPORT int getNumberOfOverlapedCellsForFather() const;
+    // basic set/get
+    MEDCOUPLING_EXPORT const std::vector< std::pair<int,int> >& getBLTRRange() const { return _bl_tr; }
+    MEDCOUPLING_EXPORT const MEDCouplingCartesianAMRMesh *getMesh() const { return _mesh; }
+  private:
+    std::size_t getHeapMemorySizeWithoutChildren() const;
+    std::vector<const BigMemoryObject *> getDirectChildren() const;
+  private:
+    //! bottom left/top right cell range relative to \a _father
+    std::vector< std::pair<int,int> > _bl_tr;
+    MEDCouplingAutoRefCountObjectPtr<MEDCouplingCartesianAMRMesh> _mesh;
+  };
+  /// @endcond
+
+  /*!
+   * This class is the base class dedicated to AMR using Adaptative Hierarchical Overlapped image Grid.
+   * This class does \b NOT inherit from MEDCouplingMesh because this class overlaps image grid structured meshes to perform adaptative mesh refinement.
+   * But this class aggregates MEDCouplingMesh instances !
+   */
+  class MEDCouplingCartesianAMRMesh : public RefCountObject, public TimeLabel
+  {
+  public:
+    MEDCOUPLING_EXPORT static MEDCouplingCartesianAMRMesh *New(const std::string& meshName, int spaceDim, const int *nodeStrctStart, const int *nodeStrctStop,
+                                                       const double *originStart, const double *originStop, const double *dxyzStart, const double *dxyzStop);
+    MEDCOUPLING_EXPORT int getSpaceDimension() const;
+    MEDCOUPLING_EXPORT int getMaxNumberOfLevelsRelativeToThis() const;
+    MEDCOUPLING_EXPORT int getNumberOfCellsAtCurrentLevel() const;
+    MEDCOUPLING_EXPORT int getNumberOfCellsRecursiveWithOverlap() const;
+    MEDCOUPLING_EXPORT int getNumberOfCellsRecursiveWithoutOverlap() const;
+    //
+    MEDCOUPLING_EXPORT const MEDCouplingCartesianAMRMesh *getFather() const;
+    MEDCOUPLING_EXPORT const MEDCouplingCartesianAMRMesh *getGodFather() const;
+    MEDCOUPLING_EXPORT void detachFromFather();
+    MEDCOUPLING_EXPORT void addPatch(const std::vector< std::pair<int,int> >& bottomLeftTopRight, int factor);
+    MEDCOUPLING_EXPORT void removePatch(int patchId);
+    MEDCOUPLING_EXPORT int getNumberOfPatches() const;
+    MEDCOUPLING_EXPORT const MEDCouplingCartesianAMRPatch *getPatch(int patchId) const;
+    //
+    MEDCOUPLING_EXPORT MEDCouplingUMesh *buildUnstructured() const;
+  private:
+    MEDCouplingCartesianAMRMesh(const std::string& meshName, int spaceDim, const int *nodeStrctStart, const int *nodeStrctStop,
+                        const double *originStart, const double *originStop, const double *dxyzStart, const double *dxyzStop);
+    MEDCouplingCartesianAMRMesh(MEDCouplingCartesianAMRMesh *father, MEDCouplingIMesh *mesh);
+    void checkPatchId(int patchId) const;
+  protected:
+    MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
+    MEDCOUPLING_EXPORT std::vector<const BigMemoryObject *> getDirectChildren() const;
+    MEDCOUPLING_EXPORT void updateTime() const;
+  private:
+    MEDCouplingCartesianAMRMesh *_father;
+    MEDCouplingAutoRefCountObjectPtr<MEDCouplingIMesh> _mesh;
+    std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingCartesianAMRPatch> > _patches;
+  };
+}
+
+#endif
+
index 6745edac48acd42c6233e43a1d22b90e9cad433e..a5158def80dd680168d661ecaa03f84e15a8e165 100644 (file)
@@ -223,30 +223,6 @@ int MEDCouplingCurveLinearMesh::getNumberOfNodes() const
   return MEDCouplingStructuredMesh::getNumberOfNodes();
 }
 
-void MEDCouplingCurveLinearMesh::getSplitCellValues(int *res) const
-{
-  int meshDim=getMeshDimension();
-  for(int l=0;l<meshDim;l++)
-    {
-      int val=1;
-      for(int p=0;p<meshDim-l-1;p++)
-        val*=_structure[p]-1;
-      res[meshDim-l-1]=val;
-    }
-}
-
-void MEDCouplingCurveLinearMesh::getSplitNodeValues(int *res) const
-{
-  int meshDim=getMeshDimension();
-  for(int l=0;l<meshDim;l++)
-    {
-      int val=1;
-      for(int p=0;p<meshDim-l-1;p++)
-        val*=_structure[p];
-      res[meshDim-l-1]=val;
-    }
-}
-
 void MEDCouplingCurveLinearMesh::getNodeGridStructure(int *res) const
 {
   std::copy(_structure.begin(),_structure.end(),res);
index 98be1d7792aa4cf632d2f2dae5e6b996533a9ecb..ba8a07c91c791188a5978ef6b332c8281b73f8d6 100644 (file)
@@ -75,8 +75,6 @@ namespace ParaMEDMEM
     MEDCOUPLING_EXPORT DataArrayDouble *computeIsoBarycenterOfNodesPerCell() const;
     MEDCOUPLING_EXPORT void renumberCells(const int *old2NewBg, bool check=true);
     //some useful methods
-    MEDCOUPLING_EXPORT void getSplitCellValues(int *res) const;
-    MEDCOUPLING_EXPORT void getSplitNodeValues(int *res) const;
     MEDCOUPLING_EXPORT void getNodeGridStructure(int *res) const;
     //serialisation-unserialization
     MEDCOUPLING_EXPORT void getTinySerializationInformation(std::vector<double>& tinyInfoD, std::vector<int>& tinyInfo, std::vector<std::string>& littleStrings) const;
index dc2cf8793494b41f9b1d9ee2f8714ab4d0a34a23..16dc17763bc9d3ad709b6ed5f1783e1e12e23b00 100644 (file)
@@ -164,7 +164,7 @@ MEDCouplingCMesh *MEDCouplingIMesh::convertToCartesian() const
   MEDCouplingAutoRefCountObjectPtr<MEDCouplingCMesh> ret(MEDCouplingCMesh::New());
   try
   { ret->copyTinyInfoFrom(this); }
-  catch(INTERP_KERNEL::Exception& e) { }
+  catch(INTERP_KERNEL::Exception& ) { }
   int spaceDim(getSpaceDimension());
   std::vector<std::string> infos(buildInfoOnComponents());
   for(int i=0;i<spaceDim;i++)
@@ -196,6 +196,68 @@ void MEDCouplingIMesh::refineWithFactor(int factor)
   declareAsNew();
 }
 
+/*!
+ * 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 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,out] coarseDA The DataArrayDouble corresponding to the a cell field of a coarse mesh whose cell structure is defined by \a coarseSt.
+ * \param [in] coarseSt The cell structure of coarse mesh.
+ * \param [in] fineDA The DataArray containing the cell field on uniformly refined mesh
+ * \param [in] fineLocInCoarse The cell localization of refined mesh into the coarse one.
+ */
+void MEDCouplingIMesh::CondenseFineToCoarse(DataArrayDouble *coarseDA, const std::vector<int>& coarseSt, const DataArrayDouble *fineDA, const std::vector< std::pair<int,int> >& fineLocInCoarse)
+{
+  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());
+  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())
+    throw INTERP_KERNEL::Exception("MEDCouplingIMesh::CondenseFineToCoarse : the size of fineLocInCoarse (4th param) must be equal to the sier of coarseSt (2nd param) !");
+  if(coarseDA->getNumberOfTuples()!=nbOfTuplesInCoarseExp)
+    {
+      std::ostringstream oss; oss << "MEDCouplingIMesh::CondenseFineToCoarse : Expecting " << nbOfTuplesInCoarseExp << " having " << coarseDA->getNumberOfTuples() << " !";
+      throw INTERP_KERNEL::Exception(oss.str().c_str());
+    }
+  int nbTuplesFine(fineDA->getNumberOfTuples());
+  if(nbTuplesFine%nbOfTuplesInCoarseExp!=0)
+    throw INTERP_KERNEL::Exception("MEDCouplingIMesh::CondenseFineToCoarse : Invalid nb of tuples in fine DataArray regarding its structure !");
+  int factN(nbTuplesFine/nbOfTuplesInFineExp);
+  int fact(FindIntRoot(factN,meshDim));
+  // to improve use jump-iterator. Factorizes with SwitchOnIdsFrom BuildExplicitIdsFrom
+  MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids(BuildExplicitIdsFrom(coarseSt,fineLocInCoarse));
+  const int *idsPtr(ids->begin());
+  double *outPtr(coarseDA->getPointer());
+  const double *inPtr(fineDA->begin());
+  coarseDA->setPartOfValuesSimple3(0.,ids->begin(),ids->end(),0,nbCompo,1);
+  //
+  switch(meshDim)
+  {
+    case 2:
+      {
+        int kk(0);
+        std::vector<int> dims(MEDCouplingStructuredMesh::GetDimensionsFromCompactFrmt(fineLocInCoarse));
+        for(int it=0;it<dims[1];it++)
+          {
+            for(int i=0;i<fact;i++)
+              {
+                for(int j=0;j<dims[0];j++,inPtr+=fact)
+                  {
+                    double *loc(outPtr+idsPtr[kk+j]*nbCompo);
+                    std::transform(inPtr,inPtr+fact,loc,loc,std::plus<double>());
+                  }
+              }
+            kk+=it;
+          }
+        break;
+      }
+    default:
+      throw INTERP_KERNEL::Exception("MEDCouplingIMesh::CondenseFineToCoarse : only dimensions 2 supported !");
+  }
+}
+
 void MEDCouplingIMesh::setSpaceDimension(int spaceDim)
 {
   if(spaceDim==_space_dim)
@@ -347,30 +409,6 @@ void MEDCouplingIMesh::checkCoherency2(double eps) const
   checkCoherency1(eps);
 }
 
-void MEDCouplingIMesh::getSplitCellValues(int *res) const
-{
-  int meshDim(getMeshDimension());
-  for(int l=0;l<meshDim;l++)
-    {
-      int val=1;
-      for(int p=0;p<meshDim-l-1;p++)
-        val*=_structure[p]-1;
-      res[meshDim-l-1]=val;
-    }
-}
-
-void MEDCouplingIMesh::getSplitNodeValues(int *res) const
-{
-  int spaceDim(getSpaceDimension());
-  for(int l=0;l<spaceDim;l++)
-    {
-      int val=1;
-      for(int p=0;p<spaceDim-l-1;p++)
-        val*=_structure[p];
-      res[spaceDim-l-1]=val;
-    }
-}
-
 void MEDCouplingIMesh::getNodeGridStructure(int *res) const
 {
   checkSpaceDimension();
@@ -520,7 +558,7 @@ int MEDCouplingIMesh::getCellContainingPoint(const double *pos, double eps) cons
     {
       int nbOfCells(_structure[i]-1);
       double ref(pos[i]);
-      int tmp((ref-_origin[i])/_dxyz[i]);
+      int tmp((int)((ref-_origin[i])/_dxyz[i]));
       if(tmp>=0 && tmp<nbOfCells)
         {
           ret+=coeff*tmp;
@@ -773,3 +811,34 @@ void MEDCouplingIMesh::CheckSpaceDimension(int spaceDim)
     throw INTERP_KERNEL::Exception("MEDCouplingIMesh::CheckSpaceDimension : input spaceDim must be in [0,1,2,3] !");
 }
 
+int MEDCouplingIMesh::FindIntRoot(int val, int order)
+{
+  if(order==0)
+    return 1;
+  if(val<0)
+    throw INTERP_KERNEL::Exception("MEDCouplingIMesh::FindIntRoot : input val is < 0 ! Not possible to compute a root !");
+  if(order==1)
+    return val;
+  if(order!=2 && order!=3)
+    throw INTERP_KERNEL::Exception("MEDCouplingIMesh::FindIntRoot : the order available are 0,1,2 or 3 !");
+  double valf((double)val);
+  if(order==2)
+    {
+      double retf(sqrt(valf));
+      int ret((int)retf);
+      if(ret*ret!=val)
+        throw INTERP_KERNEL::Exception("MEDCouplingIMesh::FindIntRoot : the input val is not a perfect square root !");
+      return ret;
+    }
+  else//order==3
+    {
+      double retf(std::pow(val,0.3333333333333333));
+      int ret((int)retf),ret2(ret+1);
+      if(ret*ret*ret!=val || ret2*ret2*ret2!=val)
+        throw INTERP_KERNEL::Exception("MEDCouplingIMesh::FindIntRoot : the input val is not a perfect cublic root !");
+      if(ret*ret*ret==val)
+        return ret;
+      else
+        return ret2;
+    }
+}
index cba2da67a9fb7b73f6798ce16630ea1da9a823ee..b18c5c98b0605f04f7ecb297ba9fd2f6f1530e49 100644 (file)
@@ -47,6 +47,7 @@ namespace ParaMEDMEM
     MEDCOUPLING_EXPORT double getMeasureOfAnyCell() const;
     MEDCOUPLING_EXPORT MEDCouplingCMesh *convertToCartesian() const;
     MEDCOUPLING_EXPORT void refineWithFactor(int factor);
+    MEDCOUPLING_EXPORT static void CondenseFineToCoarse(DataArrayDouble *coarseDA, const std::vector<int>& coarseSt, const DataArrayDouble *fineDA, const std::vector< std::pair<int,int> >& fineLocInCoarse);
     //
     MEDCOUPLING_EXPORT MEDCouplingMesh *deepCpy() const;
     MEDCOUPLING_EXPORT MEDCouplingIMesh *clone(bool recDeepCpy) const;
@@ -82,8 +83,6 @@ namespace ParaMEDMEM
     MEDCOUPLING_EXPORT DataArrayDouble *computeIsoBarycenterOfNodesPerCell() const;
     MEDCOUPLING_EXPORT void renumberCells(const int *old2NewBg, bool check=true);
     //some useful methods
-    MEDCOUPLING_EXPORT void getSplitCellValues(int *res) const;
-    MEDCOUPLING_EXPORT void getSplitNodeValues(int *res) const;
     MEDCOUPLING_EXPORT void getNodeGridStructure(int *res) const;
     MEDCOUPLING_EXPORT std::vector<int> getNodeGridStructure() const;
     MEDCouplingStructuredMesh *buildStructuredSubPart(const std::vector< std::pair<int,int> >& cellPart) const;
@@ -104,6 +103,7 @@ namespace ParaMEDMEM
     std::vector<std::string> buildInfoOnComponents() const;
     void checkSpaceDimension() const;
     static void CheckSpaceDimension(int spaceDim);
+    static int FindIntRoot(int val, int order);
   private:
     int _space_dim;
     double _origin[3];
index d716be4799cc586bfed4bc822103e1dc640f0340..e737159ea3d3a800979363d645c84559ad0186ec 100644 (file)
@@ -209,6 +209,20 @@ int MEDCouplingStructuredMesh::getSpaceDimensionOnNodeStruct() const
   return spd1;
 }
 
+void MEDCouplingStructuredMesh::getSplitCellValues(int *res) const
+{
+  std::vector<int> strct(getCellGridStructure());
+  std::vector<int> ret(MEDCouplingStructuredMesh::GetSplitVectFromStruct(strct));
+  std::copy(ret.begin(),ret.end(),res);
+}
+
+void MEDCouplingStructuredMesh::getSplitNodeValues(int *res) const
+{
+  std::vector<int> strct(getNodeGridStructure());
+  std::vector<int> ret(MEDCouplingStructuredMesh::GetSplitVectFromStruct(strct));
+  std::copy(ret.begin(),ret.end(),res);
+}
+
 /*!
  * This method returns the number of cells of unstructured sub level mesh, without building it.
  */
@@ -904,6 +918,24 @@ std::vector<int> MEDCouplingStructuredMesh::getCellGridStructure() const
   return ret;
 }
 
+/*!
+ * Given a struct \a strct it returns a split vector [1,strct[0],strct[0]*strct[1]...]
+ * This decomposition allows to quickly find i,j,k given a global id.
+ */
+std::vector<int> MEDCouplingStructuredMesh::GetSplitVectFromStruct(const std::vector<int>& strct)
+{
+  int spaceDim((int)strct.size());
+  std::vector<int> res(spaceDim);
+  for(int l=0;l<spaceDim;l++)
+    {
+      int val=1;
+      for(int p=0;p<spaceDim-l-1;p++)
+        val*=strct[p];
+      res[spaceDim-l-1]=val;
+    }
+  return res;
+}
+
 /*!
  * This method states if given part ids [ \a startIds, \a stopIds) and a structure \a st returns if it can be considered as a structured dataset.
  * If true is returned \a partCompactFormat will contain the information to build the corresponding part.
@@ -995,6 +1027,14 @@ bool MEDCouplingStructuredMesh::IsPartStructured(const int *startIds, const int
   }
 }
 
+std::vector<int> MEDCouplingStructuredMesh::GetDimensionsFromCompactFrmt(const std::vector< std::pair<int,int> >& partCompactFormat)
+{
+  std::vector<int> ret(partCompactFormat.size());
+  for(std::size_t i=0;i<partCompactFormat.size();i++)
+    ret[i]=partCompactFormat[i].second-partCompactFormat[i].first;
+  return ret;
+}
+
 /*!
  * This method is close to BuildExplicitIdsFrom except that instead of returning a DataArrayInt instance containing explicit ids it
  * enable elems in the vector of booleans (for performance reasons). As it is method for performance, this method is \b not
@@ -1012,9 +1052,7 @@ void MEDCouplingStructuredMesh::SwitchOnIdsFrom(const std::vector<int>& st, cons
     throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::SwitchOnIdsFrom : input arrays must have the same size !");
   if((int)vectToSwitchOn.size()!=DeduceNumberOfGivenStructure(st))
     throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::SwitchOnIdsFrom : invalid size of input vector of boolean regarding the structure !");
-  std::vector<int> dims(st.size());
-  for(std::size_t i=0;i<st.size();i++)
-    dims[i]=partCompactFormat[i].second-partCompactFormat[i].first;
+  std::vector<int> dims(GetDimensionsFromCompactFrmt(partCompactFormat));
   switch(st.size())
   {
     case 3:
index cb12e85af7bf4e2f9e549e7f58558f6d9e376f4e..3e2072e285122054b59bf62fdaabea45b81c9295 100644 (file)
@@ -65,12 +65,14 @@ namespace ParaMEDMEM
     MEDCOUPLING_EXPORT int getNumberOfCellsOfSubLevelMesh() const;
     MEDCOUPLING_EXPORT int getSpaceDimensionOnNodeStruct() const;
     MEDCOUPLING_EXPORT virtual void getNodeGridStructure(int *res) const = 0;
-    MEDCOUPLING_EXPORT virtual void getSplitCellValues(int *res) const = 0;
-    MEDCOUPLING_EXPORT virtual void getSplitNodeValues(int *res) const = 0;
+    MEDCOUPLING_EXPORT virtual void getSplitCellValues(int *res) const;
+    MEDCOUPLING_EXPORT virtual void getSplitNodeValues(int *res) const;
     MEDCOUPLING_EXPORT virtual std::vector<int> getNodeGridStructure() const = 0;
     MEDCOUPLING_EXPORT std::vector<int> getCellGridStructure() const;
     MEDCOUPLING_EXPORT virtual MEDCouplingStructuredMesh *buildStructuredSubPart(const std::vector< std::pair<int,int> >& cellPart) const = 0;
+    MEDCOUPLING_EXPORT static std::vector<int> GetSplitVectFromStruct(const std::vector<int>& strct);
     MEDCOUPLING_EXPORT static bool IsPartStructured(const int *startIds, const int *stopIds, const std::vector<int>& st, std::vector< std::pair<int,int> >& partCompactFormat);
+    MEDCOUPLING_EXPORT static std::vector<int> GetDimensionsFromCompactFrmt(const std::vector< std::pair<int,int> >& partCompactFormat);
     MEDCOUPLING_EXPORT static void SwitchOnIdsFrom(const std::vector<int>& st, const std::vector< std::pair<int,int> >& partCompactFormat, std::vector<bool>& vectToSwitchOn);
     MEDCOUPLING_EXPORT static DataArrayInt *BuildExplicitIdsFrom(const std::vector<int>& st, const std::vector< std::pair<int,int> >& partCompactFormat);
     MEDCOUPLING_EXPORT static DataArrayInt *Build1GTNodalConnectivity(const int *nodeStBg, const int *nodeStEnd);
index 58eb47e11d3c7333f9066b925f8689ef9d3c5949..9d834779bbfcf9b0f0ab933487922b0624728348 100644 (file)
@@ -14934,6 +14934,49 @@ class MEDCouplingBasicsTest(unittest.TestCase):
         self.assertTrue(mu.getCoords().isEqual(coordsExp,1e-12))
         self.assertTrue(mu.getNodalConnectivity().isEqual(DataArrayInt([1,0,3,4,2,1,4,5,4,3,6,7,5,4,7,8,7,6,9,10,8,7,10,11])))
         pass
+
+    def testSwig2AMR1(self):
+        self.assertEqual((1,3,12),MEDCouplingStructuredMesh.GetSplitVectFromStruct([3,4,5]))
+        self.assertEqual((3,2),MEDCouplingStructuredMesh.GetDimensionsFromCompactFrmt([(1,4),(2,4)]))
+        #
+        amr=MEDCouplingCartesianAMRMesh("",2,[3,3],[0,0],[1,1])
+        self.assertEqual(4,amr.getNumberOfCellsAtCurrentLevel())
+        self.assertEqual(4,amr.getNumberOfCellsRecursiveWithOverlap())
+        self.assertEqual(4,amr.getNumberOfCellsRecursiveWithoutOverlap())
+        self.assertEqual(0,amr.getNumberOfPatches())
+        self.assertEqual(1,amr.getMaxNumberOfLevelsRelativeToThis())
+        self.assertEqual(2,amr.getSpaceDimension())
+        amr.addPatch([(1,2),(0,1)],4)
+        self.assertEqual(4,amr.getNumberOfCellsAtCurrentLevel())
+        self.assertEqual(20,amr.getNumberOfCellsRecursiveWithOverlap())
+        self.assertEqual(19,amr.getNumberOfCellsRecursiveWithoutOverlap())
+        self.assertEqual(1,amr.getNumberOfPatches())
+        self.assertEqual(2,amr.getMaxNumberOfLevelsRelativeToThis())
+        self.assertEqual(2,amr.getSpaceDimension())
+        amr[0].addPatch([(2,3),(1,3)],2)
+        self.assertEqual(amr[0].getBLTRRange(),[(1,2),(0,1)])
+        self.assertEqual(4,amr.getNumberOfCellsAtCurrentLevel())
+        self.assertEqual(28,amr.getNumberOfCellsRecursiveWithOverlap())
+        self.assertEqual(25,amr.getNumberOfCellsRecursiveWithoutOverlap())
+        self.assertEqual(1,amr.getNumberOfPatches())
+        self.assertEqual(3,amr.getMaxNumberOfLevelsRelativeToThis())
+        self.assertEqual(2,amr.getSpaceDimension())
+        amr[0].addPatch([(0,2),(3,4)],3)
+        self.assertEqual(16,amr[0].getMesh().getNumberOfCellsAtCurrentLevel())
+        self.assertEqual(46,amr.getNumberOfCellsRecursiveWithOverlap())
+        self.assertEqual(41,amr.getNumberOfCellsRecursiveWithoutOverlap())
+        self.assertEqual(2,amr[0].getMesh().getNumberOfPatches())
+        self.assertEqual(3,amr.getMaxNumberOfLevelsRelativeToThis())
+        self.assertEqual(2,amr.getSpaceDimension())
+        del amr[0][1]
+        self.assertEqual(amr[0].getBLTRRange(),[(1,2),(0,1)])
+        self.assertEqual(4,amr.getNumberOfCellsAtCurrentLevel())
+        self.assertEqual(28,amr.getNumberOfCellsRecursiveWithOverlap())
+        self.assertEqual(25,amr.getNumberOfCellsRecursiveWithoutOverlap())
+        self.assertEqual(1,amr.getNumberOfPatches())
+        self.assertEqual(3,amr.getMaxNumberOfLevelsRelativeToThis())
+        self.assertEqual(2,amr.getSpaceDimension())
+        pass
     
     def setUp(self):
         pass
index 8f0dfb8c9f5d7419ee1317d91e4827c17e46ac07..92cd4bbd2b7bfc0be1466963a026130eba996d86 100644 (file)
@@ -40,7 +40,7 @@
 #include "MEDCouplingFieldOverTime.hxx"
 #include "MEDCouplingDefinitionTime.hxx"
 #include "MEDCouplingFieldDiscretization.hxx"
-#include "MEDCouplingAHOGMesh.hxx"
+#include "MEDCouplingCartesianAMRMesh.hxx"
 #include "MEDCouplingTypemaps.i"
 
 #include "InterpKernelAutoPtr.hxx"
@@ -311,14 +311,14 @@ using namespace INTERP_KERNEL;
 %newobject ParaMEDMEM::MEDCouplingMultiFields::New;
 %newobject ParaMEDMEM::MEDCouplingMultiFields::deepCpy;
 %newobject ParaMEDMEM::MEDCouplingFieldOverTime::New;
-%newobject ParaMEDMEM::MEDCouplingAHOGPatch::getMesh;
-%newobject ParaMEDMEM::MEDCouplingAHOGPatch::__getitem__;
-%newobject ParaMEDMEM::MEDCouplingAHOGMesh::New;
-%newobject ParaMEDMEM::MEDCouplingAHOGMesh::buildUnstructured;
-%newobject ParaMEDMEM::MEDCouplingAHOGMesh::getGodFather;
-%newobject ParaMEDMEM::MEDCouplingAHOGMesh::getFather;
-%newobject ParaMEDMEM::MEDCouplingAHOGMesh::getPatch;
-%newobject ParaMEDMEM::MEDCouplingAHOGMesh::__getitem__;
+%newobject ParaMEDMEM::MEDCouplingCartesianAMRPatch::getMesh;
+%newobject ParaMEDMEM::MEDCouplingCartesianAMRPatch::__getitem__;
+%newobject ParaMEDMEM::MEDCouplingCartesianAMRMesh::New;
+%newobject ParaMEDMEM::MEDCouplingCartesianAMRMesh::buildUnstructured;
+%newobject ParaMEDMEM::MEDCouplingCartesianAMRMesh::getGodFather;
+%newobject ParaMEDMEM::MEDCouplingCartesianAMRMesh::getFather;
+%newobject ParaMEDMEM::MEDCouplingCartesianAMRMesh::getPatch;
+%newobject ParaMEDMEM::MEDCouplingCartesianAMRMesh::__getitem__;
 
 %feature("unref") MEDCouplingPointSet "$this->decrRef();"
 %feature("unref") MEDCouplingMesh "$this->decrRef();"
@@ -340,8 +340,8 @@ using namespace INTERP_KERNEL;
 %feature("unref") MEDCouplingMultiFields "$this->decrRef();"
 %feature("unref") MEDCouplingFieldTemplate "$this->decrRef();"
 %feature("unref") MEDCouplingMultiFields "$this->decrRef();"
-%feature("unref") MEDCouplingAHOGMesh "$this->decrRef();"
-%feature("unref") MEDCouplingAHOGPatch "$this->decrRef();"
+%feature("unref") MEDCouplingCartesianAMRMesh "$this->decrRef();"
+%feature("unref") MEDCouplingCartesianAMRPatch "$this->decrRef();"
 
 %rename(assign) *::operator=;
 %ignore ParaMEDMEM::MEDCouplingGaussLocalization::pushTinySerializationIntInfo;
@@ -2769,6 +2769,7 @@ namespace ParaMEDMEM
     static INTERP_KERNEL::NormalizedCellType GetGeoTypeGivenMeshDimension(int meshDim) throw(INTERP_KERNEL::Exception);
     MEDCoupling1SGTUMesh *build1SGTSubLevelMesh() const throw(INTERP_KERNEL::Exception);
     static int DeduceNumberOfGivenStructure(const std::vector<int>& st) throw(INTERP_KERNEL::Exception);
+    static std::vector<int> GetSplitVectFromStruct(const std::vector<int>& strct) throw(INTERP_KERNEL::Exception);
     %extend
     {
       virtual MEDCouplingStructuredMesh *buildStructuredSubPart(PyObject *cellPart) const throw(INTERP_KERNEL::Exception)
@@ -2831,6 +2832,13 @@ namespace ParaMEDMEM
         return MEDCouplingStructuredMesh::Build1GTNodalConnectivityOfSubLevelMesh(tmp,tmp+szArr);
       }
 
+      static std::vector<int> GetDimensionsFromCompactFrmt(PyObject *partCompactFormat) throw(INTERP_KERNEL::Exception)
+      {
+        std::vector< std::pair<int,int> > inp;
+        convertPyToVectorPairInt(partCompactFormat,inp);
+        return MEDCouplingStructuredMesh::GetDimensionsFromCompactFrmt(inp);
+      }
+
       static PyObject *IsPartStructured(PyObject *li, PyObject *st) throw(INTERP_KERNEL::Exception)
       {
         int szArr,sw,iTypppArr;
@@ -3027,6 +3035,13 @@ namespace ParaMEDMEM
         self->setDXYZ(originPtr,originPtr+nbTuples);
       }
 
+      static void CondenseFineToCoarse(DataArrayDouble *coarseDA, const std::vector<int>& coarseSt, const DataArrayDouble *fineDA, PyObject *fineLocInCoarse) throw(INTERP_KERNEL::Exception)
+      {
+        std::vector< std::pair<int,int> > inp;
+        convertPyToVectorPairInt(fineLocInCoarse,inp);
+        MEDCouplingIMesh::CondenseFineToCoarse(coarseDA,coarseSt,fineDA,inp);
+      }
+
       std::string __str__() const throw(INTERP_KERNEL::Exception)
       {
         return self->simpleRepr();
@@ -4562,7 +4577,9 @@ namespace ParaMEDMEM
       }
   };
 
-  class MEDCouplingAHOGPatch : public RefCountObject
+  class MEDCouplingCartesianAMRMesh;
+
+  class MEDCouplingCartesianAMRPatch : public RefCountObject
   {
   public:
     int getNumberOfCellsRecursiveWithOverlap() const throw(INTERP_KERNEL::Exception);
@@ -4577,9 +4594,9 @@ namespace ParaMEDMEM
         return convertFromVectorPairInt(ret);
       }
 
-      const MEDCouplingAHOGMesh *getMesh() const throw(INTERP_KERNEL::Exception)
+      MEDCouplingCartesianAMRMesh *getMesh() const throw(INTERP_KERNEL::Exception)
       {
-        MEDCouplingAHOGMesh *ret(const_cast<MEDCouplingAHOGMesh *>(self->getMesh()));
+        MEDCouplingCartesianAMRMesh *ret(const_cast<MEDCouplingCartesianAMRMesh *>(self->getMesh()));
         if(ret)
           ret->incrRef();
         return ret;
@@ -4592,11 +4609,11 @@ namespace ParaMEDMEM
         self->addPatch(inp,factor);
       }
 
-      MEDCouplingAHOGPatch *__getitem__(int patchId) const throw(INTERP_KERNEL::Exception)
+      MEDCouplingCartesianAMRPatch *__getitem__(int patchId) const throw(INTERP_KERNEL::Exception)
       {
-        const MEDCouplingAHOGMesh *mesh(self->getMesh());
+        const MEDCouplingCartesianAMRMesh *mesh(self->getMesh());
         if(!mesh)
-          throw INTERP_KERNEL::Exception("wrap MEDCouplingAHOGPatch.__getitem__ : no underlying mesh !");
+          throw INTERP_KERNEL::Exception("wrap MEDCouplingCartesianAMRPatch.__getitem__ : no underlying mesh !");
         if(patchId==mesh->getNumberOfPatches())
           {
             std::ostringstream oss;
@@ -4604,23 +4621,31 @@ namespace ParaMEDMEM
             PyErr_SetString(PyExc_StopIteration,oss.str().c_str());
             return 0;
           }
-        MEDCouplingAHOGPatch *ret(const_cast<MEDCouplingAHOGPatch *>(mesh->getPatch(patchId)));
+        MEDCouplingCartesianAMRPatch *ret(const_cast<MEDCouplingCartesianAMRPatch *>(mesh->getPatch(patchId)));
         if(ret)
           ret->incrRef();
         return ret;
       }
 
+      void __delitem__(int patchId) throw(INTERP_KERNEL::Exception)
+      {
+        MEDCouplingCartesianAMRMesh *mesh(const_cast<MEDCouplingCartesianAMRMesh *>(self->getMesh()));
+        if(!mesh)
+          throw INTERP_KERNEL::Exception("wrap MEDCouplingCartesianAMRPatch.__delitem__ : no underlying mesh !");
+        mesh->removePatch(patchId);
+      }
+
       int __len__() const throw(INTERP_KERNEL::Exception)
       {
-        const MEDCouplingAHOGMesh *mesh(self->getMesh());
+        const MEDCouplingCartesianAMRMesh *mesh(self->getMesh());
         if(!mesh)
-          throw INTERP_KERNEL::Exception("wrap MEDCouplingAHOGPatch.__len__ : no underlying mesh !");
+          throw INTERP_KERNEL::Exception("wrap MEDCouplingCartesianAMRPatch.__len__ : no underlying mesh !");
         return mesh->getNumberOfPatches();
       }
     }
   };
   
-  class MEDCouplingAHOGMesh : public RefCountObject, public TimeLabel
+  class MEDCouplingCartesianAMRMesh : public RefCountObject, public TimeLabel
   {
   public:
     
@@ -4632,12 +4657,14 @@ namespace ParaMEDMEM
     //
     int getNumberOfPatches() const throw(INTERP_KERNEL::Exception);    
     MEDCouplingUMesh *buildUnstructured() const throw(INTERP_KERNEL::Exception);
+    void removePatch(int patchId) throw(INTERP_KERNEL::Exception);
+    void detachFromFather() throw(INTERP_KERNEL::Exception);
     %extend
     {
-      static MEDCouplingAHOGMesh *New(const std::string& meshName, int spaceDim, PyObject *nodeStrct, PyObject *origin, PyObject *dxyz) throw(INTERP_KERNEL::Exception)
+      static MEDCouplingCartesianAMRMesh *New(const std::string& meshName, int spaceDim, PyObject *nodeStrct, PyObject *origin, PyObject *dxyz) throw(INTERP_KERNEL::Exception)
       {
-        static const char msg0[]="MEDCouplingAHOGMesh::New : error on 'origin' parameter !";
-        static const char msg1[]="MEDCouplingAHOGMesh::New : error on 'dxyz' parameter !";
+        static const char msg0[]="MEDCouplingCartesianAMRMesh::New : error on 'origin' parameter !";
+        static const char msg1[]="MEDCouplingCartesianAMRMesh::New : error on 'dxyz' parameter !";
         const int *nodeStrctPtr(0);
         const double *originPtr(0),*dxyzPtr(0);
         int sw,sz,val0;
@@ -4650,12 +4677,12 @@ namespace ParaMEDMEM
         originPtr=convertObjToPossibleCpp5_SingleCompo(origin,sw,val,bb,msg0,false,sz1);
         dxyzPtr=convertObjToPossibleCpp5_SingleCompo(dxyz,sw,val2,bb2,msg1,false,sz2);
         //
-        return MEDCouplingAHOGMesh::New(meshName,spaceDim,nodeStrctPtr,nodeStrctPtr+sz,originPtr,originPtr+sz1,dxyzPtr,dxyzPtr+sz2);
+        return MEDCouplingCartesianAMRMesh::New(meshName,spaceDim,nodeStrctPtr,nodeStrctPtr+sz,originPtr,originPtr+sz1,dxyzPtr,dxyzPtr+sz2);
       }
 
-      MEDCouplingAHOGMesh(const std::string& meshName, int spaceDim, PyObject *nodeStrct, PyObject *origin, PyObject *dxyz) throw(INTERP_KERNEL::Exception)
+      MEDCouplingCartesianAMRMesh(const std::string& meshName, int spaceDim, PyObject *nodeStrct, PyObject *origin, PyObject *dxyz) throw(INTERP_KERNEL::Exception)
       {
-        return ParaMEDMEM_MEDCouplingAHOGMesh_New(meshName,spaceDim,nodeStrct,origin,dxyz);
+        return ParaMEDMEM_MEDCouplingCartesianAMRMesh_New(meshName,spaceDim,nodeStrct,origin,dxyz);
       }
 
       void addPatch(PyObject *bottomLeftTopRight, int factor) throw(INTERP_KERNEL::Exception)
@@ -4665,31 +4692,31 @@ namespace ParaMEDMEM
         self->addPatch(inp,factor);
       }
 
-      MEDCouplingAHOGMesh *getFather() const throw(INTERP_KERNEL::Exception)
+      MEDCouplingCartesianAMRMesh *getFather() const throw(INTERP_KERNEL::Exception)
       {
-        MEDCouplingAHOGMesh *ret(const_cast<MEDCouplingAHOGMesh *>(self->getFather()));
+        MEDCouplingCartesianAMRMesh *ret(const_cast<MEDCouplingCartesianAMRMesh *>(self->getFather()));
         if(ret)
           ret->incrRef();
         return ret;
       }
       
-      MEDCouplingAHOGMesh *getGodFather() const throw(INTERP_KERNEL::Exception)
+      MEDCouplingCartesianAMRMesh *getGodFather() const throw(INTERP_KERNEL::Exception)
       {
-        MEDCouplingAHOGMesh *ret(const_cast<MEDCouplingAHOGMesh *>(self->getGodFather()));
+        MEDCouplingCartesianAMRMesh *ret(const_cast<MEDCouplingCartesianAMRMesh *>(self->getGodFather()));
         if(ret)
           ret->incrRef();
         return ret;
       }
 
-      MEDCouplingAHOGPatch *getPatch(int patchId) const throw(INTERP_KERNEL::Exception)
+      MEDCouplingCartesianAMRPatch *getPatch(int patchId) const throw(INTERP_KERNEL::Exception)
       {
-        MEDCouplingAHOGPatch *ret(const_cast<MEDCouplingAHOGPatch *>(self->getPatch(patchId)));
+        MEDCouplingCartesianAMRPatch *ret(const_cast<MEDCouplingCartesianAMRPatch *>(self->getPatch(patchId)));
         if(ret)
           ret->incrRef();
         return ret;
       }
 
-      MEDCouplingAHOGPatch *__getitem__(int patchId) const throw(INTERP_KERNEL::Exception)
+      MEDCouplingCartesianAMRPatch *__getitem__(int patchId) const throw(INTERP_KERNEL::Exception)
       {
         if(patchId==self->getNumberOfPatches())
           {
@@ -4698,12 +4725,17 @@ namespace ParaMEDMEM
             PyErr_SetString(PyExc_StopIteration,oss.str().c_str());
             return 0;
           }
-        MEDCouplingAHOGPatch *ret(const_cast<MEDCouplingAHOGPatch *>(self->getPatch(patchId)));
+        MEDCouplingCartesianAMRPatch *ret(const_cast<MEDCouplingCartesianAMRPatch *>(self->getPatch(patchId)));
         if(ret)
           ret->incrRef();
         return ret;
       }
 
+      void __delitem__(int patchId) throw(INTERP_KERNEL::Exception)
+      {
+        self->removePatch(patchId);
+      }
+
       int __len__() const throw(INTERP_KERNEL::Exception)
       {
         return self->getNumberOfPatches();