Salome HOME
- MEDLoader ReadField is now dealing int32, float64 and float32
authorAnthony Geay <anthony.geay@edf.fr>
Mon, 27 Aug 2018 15:55:00 +0000 (17:55 +0200)
committerAnthony Geay <anthony.geay@edf.fr>
Tue, 28 Aug 2018 15:06:53 +0000 (17:06 +0200)
- Support of Gauss Points on SEG2 with ref coo equal to [0., 1.]
- Addition of DAI.giveN2OOptimized
- MEDCouplingPointSet.renumberNodesInConn support maps as input in python wrapping

23 files changed:
src/INTERP_KERNEL/GaussPoints/InterpKernelGaussCoords.cxx
src/INTERP_KERNEL/GaussPoints/InterpKernelGaussCoords.hxx
src/MEDCoupling/MEDCoupling1GTUMesh.cxx
src/MEDCoupling/MEDCoupling1GTUMesh.hxx
src/MEDCoupling/MEDCoupling1GTUMesh.txx [new file with mode: 0644]
src/MEDCoupling/MEDCouplingMap.hxx
src/MEDCoupling/MEDCouplingMemArray.cxx
src/MEDCoupling/MEDCouplingMemArray.hxx
src/MEDCoupling/MEDCouplingPointSet.hxx
src/MEDCoupling/MEDCouplingUMesh.cxx
src/MEDCoupling/MEDCouplingUMesh.hxx
src/MEDCoupling/MEDCouplingUMesh.txx [new file with mode: 0644]
src/MEDCoupling_Swig/MEDCouplingBasicsTest6.py
src/MEDCoupling_Swig/MEDCouplingCommon.i
src/MEDCoupling_Swig/MEDCouplingMemArray.i
src/MEDLoader/MEDLoader.cxx
src/MEDLoader/MEDLoader.hxx
src/MEDLoader/Swig/MEDLoaderCommon.i
src/MEDLoader/Test/MEDLoaderTest.cxx
src/MEDPartitioner/MEDPARTITIONER_MeshCollection.cxx
src/MEDPartitioner/MEDPARTITIONER_ParaDomainSelector.cxx
src/MEDPartitioner/MEDPARTITIONER_ParaDomainSelector.hxx
src/MEDPartitioner/Test/MEDPARTITIONERTest.cxx

index ef4988b86fb72fa93cb3d387df89ca10637a9766..1fbdfd9a56f26929a253a7d20c374b86a9bf9c94 100644 (file)
@@ -28,7 +28,9 @@
 
 using namespace INTERP_KERNEL;
 
-const double GaussInfo::SEG2_REF[2]={-1.0, 1.0};
+const double GaussInfo::SEG2A_REF[2]={-1.0, 1.0};
+
+const double GaussInfo::SEG2B_REF[2]={0., 1.0};
 
 const double GaussInfo::SEG3_REF[3]={-1.0, 1.0, 0.0};
 
@@ -226,7 +228,7 @@ GaussInfo GaussInfo::convertToLinear() const
         std::vector<double> a(SEG3_REF,SEG3_REF+3);
         if(IsSatisfy(a,_my_reference_coord))
           {
-            std::vector<double> c(SEG2_REF,SEG2_REF+2);
+            std::vector<double> c(SEG2A_REF,SEG2A_REF+2);
             return GaussInfo(NORM_SEG2,_my_gauss_coord,getNbGauss(),c,2);
           }
         throw INTERP_KERNEL::Exception("GaussInfo::convertToLinear : not recognized pattern for SEG3 !");
@@ -454,9 +456,14 @@ void GaussInfo::initLocalInfo()
     case NORM_SEG2:
       _my_local_ref_dim = 1;
       _my_local_nb_ref  = 2;
-      seg2Init();
+      seg2aInit();
       aSatify = isSatisfy();
-      CHECK_MACRO;
+      if(!aSatify)
+        {
+          seg2bInit();
+          aSatify = isSatisfy();
+          CHECK_MACRO;
+        }
       break;
 
     case NORM_SEG3:
@@ -700,14 +707,14 @@ void GaussInfo::point1Init()
 /*!
  * Init Segment 2 Reference coordinates ans Shape function.
  */
-void GaussInfo::seg2Init() 
+void GaussInfo::seg2aInit() 
 {
   LOCAL_COORD_MACRO_BEGIN;
   case 0:
-    coords[0] = SEG2_REF[0];
+    coords[0] = SEG2A_REF[0];
     break;
   case 1:
-    coords[0] = SEG2_REF[1];
+    coords[0] = SEG2A_REF[1];
     break;
   LOCAL_COORD_MACRO_END;
   
@@ -717,6 +724,23 @@ void GaussInfo::seg2Init()
   SHAPE_FUN_MACRO_END;
 }
 
+void GaussInfo::seg2bInit() 
+{
+  LOCAL_COORD_MACRO_BEGIN;
+  case 0:
+    coords[0] = SEG2B_REF[0];
+    break;
+  case 1:
+    coords[0] = SEG2B_REF[1];
+    break;
+  LOCAL_COORD_MACRO_END;
+  
+  SHAPE_FUN_MACRO_BEGIN;
+  funValue[0] = 1.0 - gc[0];
+  funValue[1] = gc[0];
+  SHAPE_FUN_MACRO_END;
+}
+
 /*!
  * Init Segment 3 Reference coordinates ans Shape function.
  */
@@ -1023,7 +1047,7 @@ void GaussInfo::quad4cInit()
 }
 
 /*!
- * This shapefunc map is same as degenerated seg2Init
+ * This shapefunc map is same as degenerated seg2aInit
  */
 void GaussInfo::quad4DegSeg2Init()
 {
index 7f010686ccb9f7bff9347a06cec726ae686dccd1..409cbc5f256873d41ca24f61ace3f1a3f294739e 100644 (file)
@@ -63,7 +63,8 @@ namespace INTERP_KERNEL
     INTERPKERNEL_EXPORT static std::vector<double> NormalizeCoordinatesIfNecessary(NormalizedCellType ct, int inputDim, const std::vector<double>& inputArray);
 
   public:
-    static const double SEG2_REF[2];
+    static const double SEG2A_REF[2];
+    static const double SEG2B_REF[2];
     static const double SEG3_REF[3];
     static const double TRIA3A_REF[6];
     static const double TRIA3B_REF[6];
@@ -99,7 +100,8 @@ namespace INTERP_KERNEL
     void point1Init();
     
     //1D
-    void seg2Init();
+    void seg2aInit();
+    void seg2bInit();
     void seg3Init();
 
     //2D
index 7f7decbd551c6b115fea869eaa007862d2662f01..fa91db76d0b6e709aa51f0a95799ae5560c114d2 100644 (file)
@@ -16,9 +16,9 @@
 //
 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
-// Author : Anthony Geay (CEA/DEN)
+// Author : Anthony Geay (EDF R&D)
 
-#include "MEDCoupling1GTUMesh.hxx"
+#include "MEDCoupling1GTUMesh.txx"
 #include "MEDCouplingUMesh.hxx"
 #include "MEDCouplingFieldDouble.hxx"
 #include "MEDCouplingCMesh.hxx"
@@ -1095,24 +1095,17 @@ void MEDCoupling1SGTUMesh::renumberNodesWithOffsetInConn(int offset)
  */
 void MEDCoupling1SGTUMesh::renumberNodesInConn(const INTERP_KERNEL::HashMap<int,int>& newNodeNumbersO2N)
 {
-  getNumberOfCells();//only to check that all is well defined.
-  int *begPtr(_conn->getPointer());
-  int nbElt(_conn->getNumberOfTuples());
-  int *endPtr(begPtr+nbElt);
-  for(int *it=begPtr;it!=endPtr;it++)
-    {
-      INTERP_KERNEL::HashMap<int,int>::const_iterator it2(newNodeNumbersO2N.find(*it));
-      if(it2!=newNodeNumbersO2N.end())
-        {
-          *it=(*it2).second;
-        }
-      else
-        {
-          std::ostringstream oss; oss << "MEDCoupling1SGTUMesh::renumberNodesInConn : At pos #" << std::distance(begPtr,it) << " of nodal connectivity value is " << *it << ". Not in map !";
-          throw INTERP_KERNEL::Exception(oss.str().c_str());
-        }
-    }
-  updateTime();
+  this->renumberNodesInConnT< INTERP_KERNEL::HashMap<int,int> >(newNodeNumbersO2N);
+}
+
+/*!
+ *  Same than renumberNodesInConn(const int *) except that here the format of old-to-new traducer is using map instead
+ *  of array. This method is dedicated for renumbering from a big set of nodes the a tiny set of nodes which is the case during extraction
+ *  of a big mesh.
+ */
+void MEDCoupling1SGTUMesh::renumberNodesInConn(const std::map<int,int>& newNodeNumbersO2N)
+{
+  this->renumberNodesInConnT< std::map<int,int> >(newNodeNumbersO2N);
 }
 
 /*!
@@ -3175,32 +3168,17 @@ void MEDCoupling1DGTUMesh::renumberNodesWithOffsetInConn(int offset)
  */
 void MEDCoupling1DGTUMesh::renumberNodesInConn(const INTERP_KERNEL::HashMap<int,int>& newNodeNumbersO2N)
 {
-  getNumberOfCells();//only to check that all is well defined.
-  //
-  int nbElemsIn(getNumberOfNodes()),nbOfTuples(_conn->getNumberOfTuples());
-  int *pt(_conn->getPointer());
-  for(int i=0;i<nbOfTuples;i++,pt++)
-    {
-      if(*pt==-1) continue;
-      if(*pt>=0 && *pt<nbElemsIn)
-        {
-          INTERP_KERNEL::HashMap<int,int>::const_iterator it(newNodeNumbersO2N.find(*pt));
-          if(it!=newNodeNumbersO2N.end())
-            *pt=(*it).second;
-          else
-            {
-              std::ostringstream oss; oss << "MEDCoupling1DGTUMesh::renumberNodesInConn : At pos #" << i << " of connectivity, node id is " << *pt << ". Not in keys of input map !";
-              throw INTERP_KERNEL::Exception(oss.str().c_str());
-            }
-        }
-      else
-        {
-          std::ostringstream oss; oss << "MEDCoupling1DGTUMesh::renumberNodesInConn : error on tuple #" << i << " value is " << *pt << " and indirectionnal array as a size equal to " << nbElemsIn;
-          throw INTERP_KERNEL::Exception(oss.str().c_str());
-        }
-    }
-  //
-  updateTime();
+  this->renumberNodesInConnT< INTERP_KERNEL::HashMap<int,int> >(newNodeNumbersO2N);
+}
+
+/*!
+ *  Same than renumberNodesInConn(const int *) except that here the format of old-to-new traducer is using map instead
+ *  of array. This method is dedicated for renumbering from a big set of nodes the a tiny set of nodes which is the case during extraction
+ *  of a big mesh.
+ */
+void MEDCoupling1DGTUMesh::renumberNodesInConn(const std::map<int,int>& newNodeNumbersO2N)
+{
+  this->renumberNodesInConnT< std::map<int,int> >(newNodeNumbersO2N);
 }
 
 /*!
index b69f9b13021c8a7300d3adbf47855485f01a9501..e8ae6a50a036543f9afe1ed96000135c9c057415 100644 (file)
@@ -135,6 +135,7 @@ namespace MEDCoupling
     MEDCOUPLING_EXPORT DataArrayInt *getNodeIdsInUse(int& nbrOfNodesInUse) const;
     MEDCOUPLING_EXPORT void renumberNodesWithOffsetInConn(int offset);
     MEDCOUPLING_EXPORT void renumberNodesInConn(const INTERP_KERNEL::HashMap<int,int>& newNodeNumbersO2N);
+    MEDCOUPLING_EXPORT void renumberNodesInConn(const std::map<int,int>& newNodeNumbersO2N) override;
     MEDCOUPLING_EXPORT void renumberNodesInConn(const int *newNodeNumbersO2N);
     MEDCOUPLING_EXPORT void fillCellIdsToKeepFromNodeIds(const int *begin, const int *end, bool fullyIn, DataArrayInt *&cellIdsKeptArr) const;
     MEDCOUPLING_EXPORT int getNumberOfNodesInCell(int cellId) const;
@@ -176,6 +177,8 @@ namespace MEDCoupling
     DataArrayInt *simplexizePlanarFace6();
     MEDCoupling1DGTUMesh *computeDualMesh3D() const;
     MEDCoupling1DGTUMesh *computeDualMesh2D() const;
+    template<class MAPCLS>
+    void renumberNodesInConnT(const MAPCLS& newNodeNumbersO2N);
   private:
     MCAuto<DataArrayInt> _conn;
   public:
@@ -231,6 +234,7 @@ namespace MEDCoupling
     MEDCOUPLING_EXPORT DataArrayInt *getNodeIdsInUse(int& nbrOfNodesInUse) const;
     MEDCOUPLING_EXPORT void renumberNodesWithOffsetInConn(int offset);
     MEDCOUPLING_EXPORT void renumberNodesInConn(const INTERP_KERNEL::HashMap<int,int>& newNodeNumbersO2N);
+    MEDCOUPLING_EXPORT void renumberNodesInConn(const std::map<int,int>& newNodeNumbersO2N) override;
     MEDCOUPLING_EXPORT void renumberNodesInConn(const int *newNodeNumbersO2N);
     MEDCOUPLING_EXPORT void fillCellIdsToKeepFromNodeIds(const int *begin, const int *end, bool fullyIn, DataArrayInt *&cellIdsKeptArr) const;
     MEDCOUPLING_EXPORT int getNumberOfNodesInCell(int cellId) const;
@@ -267,6 +271,8 @@ namespace MEDCoupling
   private:
     void checkDynamicGeoT2ype() const;
     static MEDCoupling1DGTUMesh *Merge1DGTUMeshesLL(std::vector<const MEDCoupling1DGTUMesh *>& a);
+    template<class MAPCLS>
+    void renumberNodesInConnT(const MAPCLS& newNodeNumbersO2N);
   private:
     MCAuto<DataArrayInt> _conn_indx;
     MCAuto<DataArrayInt> _conn;
diff --git a/src/MEDCoupling/MEDCoupling1GTUMesh.txx b/src/MEDCoupling/MEDCoupling1GTUMesh.txx
new file mode 100644 (file)
index 0000000..e6ee854
--- /dev/null
@@ -0,0 +1,78 @@
+// Copyright (C) 2018  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 (EDF R&D)
+
+#pragma once
+#include "MEDCoupling1GTUMesh.hxx"
+
+#include <sstream>
+
+template<class MAPCLS>
+void MEDCoupling::MEDCoupling1SGTUMesh::renumberNodesInConnT(const MAPCLS& newNodeNumbersO2N)
+{
+  getNumberOfCells();//only to check that all is well defined.
+  int *begPtr(_conn->getPointer());
+  int nbElt(_conn->getNumberOfTuples());
+  int *endPtr(begPtr+nbElt);
+  for(int *it=begPtr;it!=endPtr;it++)
+    {
+      auto it2(newNodeNumbersO2N.find(*it));
+      if(it2!=newNodeNumbersO2N.end())
+        {
+          *it=(*it2).second;
+        }
+      else
+        {
+          std::ostringstream oss; oss << "MEDCoupling1SGTUMesh::renumberNodesInConn : At pos #" << std::distance(begPtr,it) << " of nodal connectivity value is " << *it << ". Not in map !";
+          throw INTERP_KERNEL::Exception(oss.str().c_str());
+        }
+    }
+  updateTime();
+}
+
+template<class MAPCLS>
+void MEDCoupling::MEDCoupling1DGTUMesh::renumberNodesInConnT(const MAPCLS& newNodeNumbersO2N)
+{
+  getNumberOfCells();//only to check that all is well defined.
+  //
+  int nbOfTuples(_conn->getNumberOfTuples());
+  int *pt(_conn->getPointer());
+  for(int i=0;i<nbOfTuples;i++,pt++)
+    {
+      if(*pt==-1) continue;
+      if(*pt>=0)
+        {
+          auto it(newNodeNumbersO2N.find(*pt));
+          if(it!=newNodeNumbersO2N.end())
+            *pt=(*it).second;
+          else
+            {
+              std::ostringstream oss; oss << "MEDCoupling1DGTUMesh::renumberNodesInConn : At pos #" << i << " of connectivity, node id is " << *pt << ". Not in keys of input map !";
+              throw INTERP_KERNEL::Exception(oss.str().c_str());
+            }
+        }
+      else
+        {
+          std::ostringstream oss; oss << "MEDCoupling1DGTUMesh::renumberNodesInConn : error on tuple #" << i << " value is " << *pt << " ! Should be >=0 !";
+          throw INTERP_KERNEL::Exception(oss.str().c_str());
+        }
+    }
+  //
+  updateTime();
+}
index b63bd5cdc95106ef54acbac9bcb0d293b0b2b3f6..9a5b1cfe3b5a758ccee43bba97912aab4540c6c5 100644 (file)
@@ -48,7 +48,7 @@ namespace MEDCoupling
     std::map<T,T> _m;
   };
 
-  typedef MapKeyVal<int> MapII;
+  using MapII = MapKeyVal<int>;
 }
 
 #endif
index 0343614a83d4f0325d914e15de2f74bd6b8b4e67..f7bcef0096840fb202f9441261088ae73f37c6af 100644 (file)
@@ -4234,7 +4234,7 @@ DataArrayInt *DataArrayInt::invertArrayN2O2O2N(int oldNbOfElem) const
  *  \ref cpp_mcdataarrayint_invertarrayn2o2o2n "Here is a C++ example".
  *
  *  \ref py_mcdataarrayint_invertarrayn2o2o2n "Here is a Python example".
- *  \sa invertArrayN2O2O2N
+ *  \sa invertArrayN2O2O2N, giveN2OOptimized, MEDCouplingPointSet::renumberNodesInConn
  *  \endif
  */
 MCAuto< MapKeyVal<int> > DataArrayInt32::invertArrayN2O2O2NOptimized() const
@@ -4254,6 +4254,30 @@ MCAuto< MapKeyVal<int> > DataArrayInt32::invertArrayN2O2O2NOptimized() const
   return ret;
 }
 
+/*!
+ * Creates a map, whose contents are computed
+ * from values of \a this array, which is supposed to contain a renumbering map in 
+ * "New to Old" mode. The result array contains a renumbering map in "New to Old" mode as C++ map for performance reasons.
+ *
+ * \sa invertArrayN2O2O2NOptimized, MEDCouplingPointSet::renumberNodesInConn
+ */
+MCAuto< MapKeyVal<int> > DataArrayInt32::giveN2OOptimized() const
+{
+  checkAllocated();
+  if(getNumberOfComponents()!=1)
+    throw INTERP_KERNEL::Exception("DataArrayInt32::giveN2OOptimized : single component expected !");
+  MCAuto< MapKeyVal<int> > ret(MapKeyVal<int>::New());
+  std::map<int,int>& m(ret->data());
+  const int *new2Old(begin());
+  std::size_t nbOfNewElems(this->getNumberOfTuples());
+  for(std::size_t i=0;i<nbOfNewElems;i++)
+    {
+      int v(new2Old[i]);
+      m[i]=v;
+    }
+  return ret;
+}
+
 /*!
  * Returns a new DataArrayInt containing a renumbering map in "Old to New" mode.
  * This map, if applied to \a this array, would make it sorted. For example, if
index 825b9c8979e66d2717ad964c2994b084b700668b..0fdbdcf1c04e56b7c5ce2c2068d71c6994f8235e 100644 (file)
@@ -579,6 +579,7 @@ namespace MEDCoupling
     MEDCOUPLING_EXPORT DataArrayInt32 *invertArrayO2N2N2O(int newNbOfElem) const;
     MEDCOUPLING_EXPORT DataArrayInt32 *invertArrayN2O2O2N(int oldNbOfElem) const;
     MEDCOUPLING_EXPORT MCAuto< MapKeyVal<int> > invertArrayN2O2O2NOptimized() const;
+    MEDCOUPLING_EXPORT MCAuto< MapKeyVal<int> > giveN2OOptimized() const;
     MEDCOUPLING_EXPORT DataArrayInt32 *invertArrayO2N2N2OBis(int newNbOfElem) const;
     MEDCOUPLING_EXPORT DataArrayInt32 *selectByTupleId(const int *new2OldBg, const int *new2OldEnd) const { return DataArrayTemplate<int>::mySelectByTupleId(new2OldBg,new2OldEnd); }
     MEDCOUPLING_EXPORT DataArrayInt32 *selectByTupleId(const DataArrayInt32& di) const { return DataArrayTemplate<int>::mySelectByTupleId(di); }
index a3ece6f4dd5aa12eb244332b269ac0120cc5fd6e..61ee630dbf786d7d0ed0ec6f2621f451097ab697 100644 (file)
@@ -125,6 +125,7 @@ namespace MEDCoupling
     MEDCOUPLING_EXPORT virtual void fillCellIdsToKeepFromNodeIds(const int *begin, const int *end, bool fullyIn, DataArrayInt *&cellIdsKeptArr) const = 0;
     MEDCOUPLING_EXPORT virtual void renumberNodesInConn(const int *newNodeNumbersO2N) = 0;
     MEDCOUPLING_EXPORT virtual void renumberNodesInConn(const INTERP_KERNEL::HashMap<int,int>& newNodeNumbersO2N) = 0;
+    MEDCOUPLING_EXPORT virtual void renumberNodesInConn(const std::map<int,int>& newNodeNumbersO2N) = 0;
     MEDCOUPLING_EXPORT virtual void renumberNodesWithOffsetInConn(int offset) = 0;
     MEDCOUPLING_EXPORT virtual void renumberNodes(const int *newNodeNumbers, int newNbOfNodes);
     MEDCOUPLING_EXPORT virtual void renumberNodesCenter(const int *newNodeNumbers, int newNbOfNodes);
index ca95dc944d9d694e3ea83fd918c603ea3e09942b..8d9162b2ce63089dd13786b92b7cc236ae6f039b 100644 (file)
@@ -18,7 +18,7 @@
 //
 // Author : Anthony Geay (EDF R&D)
 
-#include "MEDCouplingUMesh.hxx"
+#include "MEDCouplingUMesh.txx"
 #include "MEDCouplingCMesh.hxx"
 #include "MEDCoupling1GTUMesh.hxx"
 #include "MEDCouplingFieldDouble.hxx"
@@ -2480,30 +2480,17 @@ void MEDCouplingUMesh::renumberNodesWithOffsetInConn(int offset)
  */
 void MEDCouplingUMesh::renumberNodesInConn(const INTERP_KERNEL::HashMap<int,int>& newNodeNumbersO2N)
 {
-  checkConnectivityFullyDefined();
-  int *conn(getNodalConnectivity()->getPointer());
-  const int *connIndex(getNodalConnectivityIndex()->getConstPointer());
-  int nbOfCells(getNumberOfCells());
-  for(int i=0;i<nbOfCells;i++)
-    for(int iconn=connIndex[i]+1;iconn!=connIndex[i+1];iconn++)
-      {
-        int& node=conn[iconn];
-        if(node>=0)//avoid polyhedron separator
-          {
-            INTERP_KERNEL::HashMap<int,int>::const_iterator it(newNodeNumbersO2N.find(node));
-            if(it!=newNodeNumbersO2N.end())
-              {
-                node=(*it).second;
-              }
-            else
-              {
-                std::ostringstream oss; oss << "MEDCouplingUMesh::renumberNodesInConn(map) : presence in connectivity for cell #" << i << " of node #" << node << " : Not in map !";
-                throw INTERP_KERNEL::Exception(oss.str());
-              }
-          }
-      }
-  _nodal_connec->declareAsNew();
-  updateTime();
+  this->renumberNodesInConnT< INTERP_KERNEL::HashMap<int,int> >(newNodeNumbersO2N);
+}
+
+/*!
+ *  Same than renumberNodesInConn(const int *) except that here the format of old-to-new traducer is using map instead
+ *  of array. This method is dedicated for renumbering from a big set of nodes the a tiny set of nodes which is the case during extraction
+ *  of a big mesh.
+ */
+void MEDCouplingUMesh::renumberNodesInConn(const std::map<int,int>& newNodeNumbersO2N)
+{
+  this->renumberNodesInConnT< std::map<int,int> >(newNodeNumbersO2N);
 }
 
 /*!
index a7be645d8e3104dbed85713059b89026701b1059..85690d7d2b13b0a9a2b36f5c3ced94356547630c 100644 (file)
@@ -149,6 +149,7 @@ namespace MEDCoupling
     MEDCOUPLING_EXPORT void renumberNodesWithOffsetInConn(int offset);
     MEDCOUPLING_EXPORT void renumberNodesInConn(const INTERP_KERNEL::HashMap<int,int>& newNodeNumbersO2N);
     MEDCOUPLING_EXPORT void renumberNodesInConn(const int *newNodeNumbersO2N);
+    MEDCOUPLING_EXPORT void renumberNodesInConn(const std::map<int,int>& newNodeNumbersO2N) override;
     MEDCOUPLING_EXPORT void shiftNodeNumbersInConn(int delta);
     MEDCOUPLING_EXPORT void duplicateNodesInConn(const int *nodeIdsToDuplicateBg, const int *nodeIdsToDuplicateEnd, int offset);
     MEDCOUPLING_EXPORT void renumberCells(const int *old2NewBg, bool check=true);
@@ -361,6 +362,8 @@ namespace MEDCoupling
                                       const std::vector<int>& insidePoints, std::vector<int>& modifiedFace);
     void attractSeg3MidPtsAroundNodesUnderground(double ratio, const int *nodeIdsBg, const int *nodeIdsEnd);
     DataArrayInt *internalColinearize2D(double eps, bool stayConform);
+    template<class MAPCLS>
+    void renumberNodesInConnT(const MAPCLS& newNodeNumbersO2N);
   public:
     MEDCOUPLING_EXPORT static DataArrayInt *ComputeRangesFromTypeDistribution(const std::vector<int>& code);
     MEDCOUPLING_EXPORT static const int N_MEDMEM_ORDER=25;
diff --git a/src/MEDCoupling/MEDCouplingUMesh.txx b/src/MEDCoupling/MEDCouplingUMesh.txx
new file mode 100644 (file)
index 0000000..f2a692b
--- /dev/null
@@ -0,0 +1,53 @@
+// Copyright (C) 2018  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 (EDF R&D)
+
+#pragma once
+#include "MEDCouplingUMesh.hxx"
+
+#include <sstream>
+
+template<class MAPCLS>
+void MEDCoupling::MEDCouplingUMesh::renumberNodesInConnT(const MAPCLS& newNodeNumbersO2N)
+{
+  checkConnectivityFullyDefined();
+  int *conn(getNodalConnectivity()->getPointer());
+  const int *connIndex(getNodalConnectivityIndex()->getConstPointer());
+  int nbOfCells(getNumberOfCells());
+  for(int i=0;i<nbOfCells;i++)
+    for(int iconn=connIndex[i]+1;iconn!=connIndex[i+1];iconn++)
+      {
+        int& node=conn[iconn];
+        if(node>=0)//avoid polyhedron separator
+          {
+            auto it(newNodeNumbersO2N.find(node));
+            if(it!=newNodeNumbersO2N.end())
+              {
+                node=(*it).second;
+              }
+            else
+              {
+                std::ostringstream oss; oss << "MEDCouplingUMesh::renumberNodesInConn(map) : presence in connectivity for cell #" << i << " of node #" << node << " : Not in map !";
+                throw INTERP_KERNEL::Exception(oss.str());
+              }
+          }
+      }
+  _nodal_connec->declareAsNew();
+  updateTime();
+}
index 30b4af3046b41c284b45cc54bbde9cd74a88e1a9..978cfd221c772dfee51315c8ecaf1481ee73ff99 100644 (file)
@@ -210,6 +210,63 @@ class MEDCouplingBasicsTest6(unittest.TestCase):
         ptsPosExp=DataArrayDouble([6.+a,3.+b,3.+a,6.+a,3.,3.+b,6.+b,3.+b,3.+b,7.,3.+b,3.+b,6.+a,6.+a,3.+a,6.+b,6.+a,3.+b,7.,6.+a,3.+b,6.+a,7.,3.+b,6.+a,3.+b,3.,6.+a,6.+a,3.],10,3)
         self.assertTrue(m.getCoords()[ptsExpToBeModified].isEqual(ptsPosExp,1e-12))
         pass
+
+    def testRenumberNodesInConnOpt(self):
+        """ Test of MEDCouplingPointSet.renumberNodesInConn with map as input coming from DataArrayInt.invertArrayN2O2O2NOptimized
+        """
+        m=MEDCouplingUMesh("mesh",2)
+        m.allocateCells()
+        m.insertNextCell(NORM_QUAD4,[10000,10002,10001,10003])
+        coo=DataArrayDouble([(0,0),(1,1),(1,0),(0,1)])
+        m.setCoords(coo)
+        m.checkConsistencyLight()
+        #
+        d=DataArrayInt([10000,10001,10002,10003])
+        myMap=d.invertArrayN2O2O2NOptimized()
+        myMap2=d.giveN2OOptimized()
+        m.checkConsistencyLight()
+        #
+        m.renumberNodesInConn(myMap) # <- test is here for UMesh
+        self.assertTrue(m.getNodalConnectivity().isEqual(DataArrayInt([4,0,2,1,3])))
+        m.renumberNodesInConn(myMap2) # <- test is here for UMesh
+        self.assertTrue(m.getNodalConnectivity().isEqual(DataArrayInt([4,10000,10002,10001,10003])))
+        #
+        m=MEDCoupling1SGTUMesh("mesh",NORM_QUAD4)
+        m.setNodalConnectivity(DataArrayInt([10000,10002,10001,10003]))
+        m.setCoords(coo)
+        m.checkConsistencyLight()
+        m.renumberNodesInConn(myMap) # <- test is here for 1SGTUMesh
+        self.assertTrue(m.getNodalConnectivity().isEqual(DataArrayInt([0,2,1,3])))
+        #
+        m=MEDCoupling1DGTUMesh("mesh",NORM_POLYGON)
+        m.setCoords(coo)
+        m.setNodalConnectivity(DataArrayInt([10000,10002,10001,10003]),DataArrayInt([0,4]))
+        m.checkConsistencyLight()
+        m.renumberNodesInConn(myMap) # <- test is here for 1DGTUMesh
+        self.assertTrue(m.getNodalConnectivity().isEqual(DataArrayInt([0,2,1,3])))
+        self.assertTrue(m.getNodalConnectivityIndex().isEqual(DataArrayInt([0,4])))
+        pass
+
+    def testSeg2bGP(self):
+        """Test of Gauss points on SEG2 using SEG2B style as ref coords
+        """
+        coo=DataArrayDouble([[0.,0.,0.],[1.,1.,1.]])
+        m=MEDCouplingUMesh("mesh",1) ; m.setCoords(coo)
+        m.allocateCells()
+        # the cell description is exactly those described in the description of HEXA27 in MED file 3.0.7 documentation
+        m.insertNextCell(NORM_SEG2,[0,1])
+        refCoo=[0.,1.]
+        weights=[0.8,0.1,0.1]
+        gCoords=[0.2,0.5,0.9]
+        fGauss=MEDCouplingFieldDouble(ON_GAUSS_PT) ; fGauss.setName("fGauss")
+        fGauss.setMesh(m)
+        fGauss.setGaussLocalizationOnType(NORM_SEG2,refCoo,gCoords,weights)
+        arr=DataArrayDouble(fGauss.getNumberOfTuplesExpected()) ; arr.iota()
+        fGauss.setArray(arr)
+        fGauss.checkConsistencyLight()
+        arrOfDisc=fGauss.getLocalizationOfDiscr()
+        self.assertTrue(arrOfDisc.isEqual(DataArrayDouble([0.2,0.2,0.2,0.5,0.5,0.5,0.9,0.9,0.9],3,3),1e-12))
+        pass
     
     pass
 
index 45d2fc793d050c861baecd579ea948b183d8a62e..3793ba25cd4e932dddceb7118f7a5022a34c6ce7 100644 (file)
@@ -1635,7 +1635,7 @@ namespace MEDCoupling
 
            virtual PyObject *findCommonCells(int compType, int startCellId=0) const throw(INTERP_KERNEL::Exception)
            {
-             DataArrayInt *v0=0,*v1=0;
+             DataArrayInt *v0(nullptr),*v1(nullptr);
              self->findCommonCells(compType,startCellId,v0,v1);
              PyObject *res = PyList_New(2);
              PyList_SetItem(res,0,SWIG_NewPointerObj(SWIG_as_voidptr(v0),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 ));
@@ -1646,8 +1646,17 @@ namespace MEDCoupling
       
            virtual void renumberNodesInConn(PyObject *li) throw(INTERP_KERNEL::Exception)
            {
-             void *da=0;
-             int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_MEDCoupling__DataArrayInt, 0 | 0 );
+             void *da(nullptr);
+             {
+               int res1(SWIG_ConvertPtr(li,&da,SWIGTYPE_p_MEDCoupling__MapII, 0 |  0 ));
+               if(SWIG_IsOK(res1))
+                 {
+                   MapII *da2(reinterpret_cast<MapII *>(da));
+                   self->renumberNodesInConn(da2->data());
+                   return ;
+                 }
+             }
+             int res1(SWIG_ConvertPtr(li,&da,SWIGTYPE_p_MEDCoupling__DataArrayInt, 0 | 0 ));
              if (!SWIG_IsOK(res1))
                {
                  int size;
@@ -1656,7 +1665,7 @@ namespace MEDCoupling
                }
              else
                {
-                 DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
+                 DataArrayInt *da2(reinterpret_cast< DataArrayInt * >(da));
                  if(!da2)
                    throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
                  da2->checkAllocated();
@@ -1676,7 +1685,7 @@ namespace MEDCoupling
 
            virtual DataArrayInt *fillCellIdsToKeepFromNodeIds(PyObject *li, bool fullyIn) const
            {
-             DataArrayInt *ret=0;
+             DataArrayInt *ret(nullptr);
              //
              int szArr,sw,iTypppArr;
              std::vector<int> stdvecTyyppArr;
index 8637c98fd93d8c776cd6b18e4b4597d2e4739d16..9ef614e64cacb0c7a7bf9e90a058f3625db64e29 100644 (file)
@@ -2290,6 +2290,7 @@ namespace MEDCoupling
     DataArrayInt *invertArrayN2O2O2N(int oldNbOfElem) const throw(INTERP_KERNEL::Exception);
     DataArrayInt *invertArrayO2N2N2OBis(int newNbOfElem) const throw(INTERP_KERNEL::Exception);
     MCAuto< MapII > invertArrayN2O2O2NOptimized() const throw(INTERP_KERNEL::Exception);
+    MCAuto< MapII > giveN2OOptimized() const throw(INTERP_KERNEL::Exception);
     DataArrayInt *indicesOfSubPart(const DataArrayInt& partOfThis) const throw(INTERP_KERNEL::Exception);
     DataArrayInt *fromNoInterlace() const throw(INTERP_KERNEL::Exception);
     DataArrayInt *toNoInterlace() const throw(INTERP_KERNEL::Exception);
index fcbe7d8ebc2d875f42c4ad7e09f262a3bc9e0167..18dbcd4ba2cb26cf766f5370d54fec3d851513a3 100644 (file)
@@ -1233,24 +1233,21 @@ MCAuto<MEDCoupling::MEDCouplingField> MEDCoupling::ReadField(const std::string&
       }
   }
   throw INTERP_KERNEL::Exception("MEDCoupling::ReadField : only FLOAT32, FLOAT64 and INT32 supported for the moment !");
-  //MCAuto<MEDFileMesh> mesh(MEDFileMesh::New(fileName,f->getMeshName()));
-  //MCAuto<MEDCoupling::MEDCouplingFieldDouble> ret(f->field(mesh));
-  //return ret;
 }
 
-MCAuto<MEDCoupling::MEDCouplingFieldDouble> MEDCoupling::ReadField(MEDCoupling::TypeOfField type, const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName, int iteration, int order)
+MCAuto<MEDCoupling::MEDCouplingField> MEDCoupling::ReadField(MEDCoupling::TypeOfField type, const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName, int iteration, int order)
 {
   MEDCoupling::CheckFileForRead(fileName);
   switch(type)
   {
     case ON_CELLS:
-      return MCAuto<MEDCoupling::MEDCouplingFieldDouble>(ReadFieldCell(fileName,meshName,meshDimRelToMax,fieldName,iteration,order));
+      return ReadFieldCell(fileName,meshName,meshDimRelToMax,fieldName,iteration,order);
     case ON_NODES:
-      return MCAuto<MEDCoupling::MEDCouplingFieldDouble>(ReadFieldNode(fileName,meshName,meshDimRelToMax,fieldName,iteration,order));
+      return ReadFieldNode(fileName,meshName,meshDimRelToMax,fieldName,iteration,order);
     case ON_GAUSS_PT:
-      return MCAuto<MEDCoupling::MEDCouplingFieldDouble>(ReadFieldGauss(fileName,meshName,meshDimRelToMax,fieldName,iteration,order));
+      return ReadFieldGauss(fileName,meshName,meshDimRelToMax,fieldName,iteration,order);
     case ON_GAUSS_NE:
-      return MCAuto<MEDCoupling::MEDCouplingFieldDouble>(ReadFieldGaussNE(fileName,meshName,meshDimRelToMax,fieldName,iteration,order));
+      return ReadFieldGaussNE(fileName,meshName,meshDimRelToMax,fieldName,iteration,order);
     default:
       throw INTERP_KERNEL::Exception("Type of field specified not managed ! manages are ON_NODES, ON_CELLS, ON_GAUSS_PT or ON_GAUSS_NE !");
   }
@@ -1317,97 +1314,139 @@ std::vector<MEDCoupling::MEDCouplingFieldDouble *> MEDCoupling::ReadFieldsGaussN
   return ReadFieldsOnSameMesh(ON_GAUSS_NE,fileName,meshName,meshDimRelToMax,fieldName,its);
 }
 
-MEDCoupling::MEDCouplingFieldDouble *MEDCoupling::ReadFieldCell(const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName, int iteration, int order)
+namespace MEDCoupling
 {
-  MCAuto<MEDFileField1TS> ff(MEDFileField1TS::New(fileName,fieldName,iteration,order));
-  MCAuto<MEDFileMesh> mm(MEDFileMesh::New(fileName,meshName));
-  MCAuto<MEDCouplingMesh> m(mm->getMeshAtLevel(meshDimRelToMax,false));
-  MEDFileMesh *mPtr(mm);
-  MEDFileUMesh *muPtr=dynamic_cast<MEDFileUMesh *>(mPtr);
-  MCAuto<MEDCouplingFieldDouble> ret(ff->getFieldOnMeshAtLevel(ON_CELLS,m));
-  if(muPtr)
-    {
-      const DataArrayInt *num(muPtr->getNumberFieldAtLevel(meshDimRelToMax));
-      if(num)
-        ret->renumberCells(num->begin());
-    }
-  return ret.retn();
-}
+  template<class T>
+  MCAuto<typename Traits<T>::FieldType> ReadFieldCellLikeT(typename MLFieldTraits<T>::F1TSType *ff, MEDCoupling::TypeOfField type, const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName, int iteration, int order)
+  {
+    MCAuto<MEDFileMesh> mm(MEDFileMesh::New(fileName,meshName));
+    MCAuto<MEDFileUMesh> muPtr(MEDCoupling::DynamicCast<MEDFileMesh,MEDFileUMesh>(mm));
+    MCAuto<MEDCouplingMesh> m(mm->getMeshAtLevel(meshDimRelToMax,false));
+    MCAuto<typename Traits<T>::FieldType> ret(ff->getFieldOnMeshAtLevel(type,m));
+    if(muPtr.isNotNull())
+      {
+        const DataArrayInt *num(muPtr->getNumberFieldAtLevel(meshDimRelToMax));
+        if(num)
+          ret->renumberCells(num->begin());
+      }
+    return ret;
+  }
 
-MEDCoupling::MEDCouplingFieldDouble *MEDCoupling::ReadFieldNode(const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName, int iteration, int order)
-{
-  MCAuto<MEDFileField1TS> ff(MEDFileField1TS::New(fileName,fieldName,iteration,order));
-  MCAuto<MEDFileMesh> mm(MEDFileMesh::New(fileName,meshName));
-  MCAuto<MEDCouplingMesh> m(mm->getMeshAtLevel(meshDimRelToMax,false));
-  MEDFileMesh *mPtr(mm);
-  MCAuto<MEDCouplingFieldDouble> ret(ff->getFieldOnMeshAtLevel(ON_NODES,m));
-  MEDFileUMesh *muPtr=dynamic_cast<MEDFileUMesh *>(mPtr);
-  if(ff->getPflsReallyUsed().empty())
+  MEDCoupling::MEDCouplingField *ReadFieldCellLike(MEDCoupling::TypeOfField type, const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName, int iteration, int order)
+  {
+    MCAuto<MEDFileAnyTypeField1TS> f(MEDFileAnyTypeField1TS::New(fileName,fieldName,iteration,order));
     {
-      if(muPtr)
+      MCAuto<MEDFileField1TS> f1(MEDCoupling::DynamicCast<MEDFileAnyTypeField1TS,MEDFileField1TS>(f));
+      if(f1.isNotNull())
         {
-          const DataArrayInt *num(muPtr->getNumberFieldAtLevel(meshDimRelToMax));
-          if(num)
-            ret->renumberCells(num->begin());
+          MCAuto<MEDCoupling::MEDCouplingFieldDouble> ret(ReadFieldCellLikeT<double>(f1,type,fileName,meshName,meshDimRelToMax,fieldName,iteration,order));
+          return ret.retn();
         }
     }
-  else
     {
-      DataArrayInt *pfl=0,*arr2=0;
-      MCAuto<DataArrayDouble> arr(ff->getFieldWithProfile(ON_NODES,meshDimRelToMax,mm,pfl));
-      MCAuto<DataArrayInt> pflSafe(pfl);
-      MCAuto<DataArrayInt> mp(m->getCellIdsFullyIncludedInNodeIds(pfl->begin(),pfl->end()));
-      MCAuto<MEDCouplingUMesh> mzip(static_cast<MEDCouplingUMesh *>(m->buildPartAndReduceNodes(mp->begin(),mp->end(),arr2)));
-      MCAuto<DataArrayInt> arr2Safe(arr2);
-      MCAuto<DataArrayInt> arr3(arr2->invertArrayO2N2N2O(mzip->getNumberOfNodes()));
-      MCAuto<DataArrayInt> pflSorted(pflSafe->deepCopy()); pflSorted->sort(true);
-      if(!arr3->isEqualWithoutConsideringStr(*pflSorted))
-        throw INTERP_KERNEL::Exception("ReadFieldNode : not implemented yet !");
-      if(!arr3->isEqualWithoutConsideringStr(*pflSafe))
+      MCAuto<MEDFileIntField1TS> f1(MEDCoupling::DynamicCast<MEDFileAnyTypeField1TS,MEDFileIntField1TS>(f));
+      if(f1.isNotNull())
         {
-          MCAuto<DataArrayInt> o2n2(pflSafe->checkAndPreparePermutation());
-          MCAuto<DataArrayInt> n2o2(o2n2->invertArrayO2N2N2O(o2n2->getNumberOfTuples()));
-          mzip->renumberNodes(n2o2->begin(),n2o2->getNumberOfTuples());
-          arr->setName("");
-          ret->setArray(arr);
+          MCAuto<MEDCoupling::MEDCouplingFieldInt> ret(ReadFieldCellLikeT<int>(f1,type,fileName,meshName,meshDimRelToMax,fieldName,iteration,order));
+          return ret.retn();
         }
-      ret->setMesh(mzip);
     }
-  return ret.retn();
+    {
+      MCAuto<MEDFileFloatField1TS> f1(MEDCoupling::DynamicCast<MEDFileAnyTypeField1TS,MEDFileFloatField1TS>(f));
+      if(f1.isNotNull())
+        {
+          MCAuto<MEDCoupling::MEDCouplingFieldFloat> ret(ReadFieldCellLikeT<float>(f1,type,fileName,meshName,meshDimRelToMax,fieldName,iteration,order));
+          return ret.retn();
+        }
+    }
+    throw INTERP_KERNEL::Exception("MEDCoupling::ReadFieldCell : only FLOAT32, FLOAT64 and INT32 supported for the moment !");
+  }
+
+  template<class T>
+  MCAuto<typename Traits<T>::FieldType> ReadFieldNodeT(typename MLFieldTraits<T>::F1TSType *ff, const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName, int iteration, int order)
+  {
+    MCAuto<MEDFileMesh> mm(MEDFileMesh::New(fileName,meshName));
+    MCAuto<MEDCouplingMesh> m(mm->getMeshAtLevel(meshDimRelToMax,false));
+    MCAuto<typename Traits<T>::FieldType> ret(ff->getFieldOnMeshAtLevel(ON_NODES,m));
+    MCAuto<MEDFileUMesh> muPtr(MEDCoupling::DynamicCast<MEDFileMesh,MEDFileUMesh>(mm));
+    if(ff->getPflsReallyUsed().empty())
+      {
+        if(muPtr.isNotNull())
+          {
+            const DataArrayInt *num(muPtr->getNumberFieldAtLevel(meshDimRelToMax));
+            if(num)
+              ret->renumberCells(num->begin());
+          }
+      }
+    else
+      {
+        DataArrayInt *pfl(nullptr),*arr2(nullptr);
+        MCAuto<typename Traits<T>::ArrayType> arr(ff->getFieldWithProfile(ON_NODES,meshDimRelToMax,mm,pfl));
+        MCAuto<DataArrayInt> pflSafe(pfl);
+        MCAuto<DataArrayInt> mp(m->getCellIdsFullyIncludedInNodeIds(pfl->begin(),pfl->end()));
+        MCAuto<MEDCouplingUMesh> mzip(static_cast<MEDCouplingUMesh *>(m->buildPartAndReduceNodes(mp->begin(),mp->end(),arr2)));
+        MCAuto<DataArrayInt> arr2Safe(arr2);
+        MCAuto<DataArrayInt> arr3(arr2->invertArrayO2N2N2O(mzip->getNumberOfNodes()));
+        MCAuto<DataArrayInt> pflSorted(pflSafe->deepCopy()); pflSorted->sort(true);
+        if(!arr3->isEqualWithoutConsideringStr(*pflSorted))
+          throw INTERP_KERNEL::Exception("ReadFieldNode : not implemented yet !");
+        if(!arr3->isEqualWithoutConsideringStr(*pflSafe))
+          {
+            MCAuto<DataArrayInt> o2n2(pflSafe->checkAndPreparePermutation());
+            MCAuto<DataArrayInt> n2o2(o2n2->invertArrayO2N2N2O(o2n2->getNumberOfTuples()));
+            mzip->renumberNodes(n2o2->begin(),n2o2->getNumberOfTuples());
+            arr->setName("");
+            ret->setArray(arr);
+          }
+        ret->setMesh(mzip);
+      }
+    return ret;
+  }
 }
 
-MEDCoupling::MEDCouplingFieldDouble *MEDCoupling::ReadFieldGauss(const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName, int iteration, int order)
+MEDCoupling::MEDCouplingField *MEDCoupling::ReadFieldCell(const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName, int iteration, int order)
 {
-  MCAuto<MEDFileField1TS> ff(MEDFileField1TS::New(fileName,fieldName,iteration,order));
-  MCAuto<MEDFileMesh> mm(MEDFileMesh::New(fileName,meshName));
-  MCAuto<MEDCouplingMesh> m(mm->getMeshAtLevel(meshDimRelToMax,false));
-  MEDFileMesh *mPtr(mm);
-  MEDFileUMesh *muPtr=dynamic_cast<MEDFileUMesh *>(mPtr);
-  MCAuto<MEDCouplingFieldDouble> ret(ff->getFieldOnMeshAtLevel(ON_GAUSS_PT,m));
-  if(muPtr)
-    {
-      const DataArrayInt *num(muPtr->getNumberFieldAtLevel(meshDimRelToMax));
-      if(num)
-        ret->renumberCells(num->begin());
-    }
-  return ret.retn();
+  return ReadFieldCellLike(ON_CELLS,fileName,meshName,meshDimRelToMax,fieldName,iteration,order);
 }
 
-MEDCoupling::MEDCouplingFieldDouble *MEDCoupling::ReadFieldGaussNE(const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName, int iteration, int order)
+MEDCoupling::MEDCouplingField *MEDCoupling::ReadFieldNode(const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName, int iteration, int order)
 {
-  MCAuto<MEDFileField1TS> ff(MEDFileField1TS::New(fileName,fieldName,iteration,order));
-  MCAuto<MEDFileMesh> mm(MEDFileMesh::New(fileName,meshName));
-  MCAuto<MEDCouplingMesh> m(mm->getMeshAtLevel(meshDimRelToMax,false));
-  MEDFileMesh *mPtr(mm);
-  MEDFileUMesh *muPtr=dynamic_cast<MEDFileUMesh *>(mPtr);
-  MCAuto<MEDCouplingFieldDouble> ret(ff->getFieldOnMeshAtLevel(ON_GAUSS_NE,m));
-  if(muPtr)
-    {
-      const DataArrayInt *num(muPtr->getNumberFieldAtLevel(meshDimRelToMax));
-      if(num)
-        ret->renumberCells(num->begin());
-    }
-  return ret.retn();
+  MCAuto<MEDFileAnyTypeField1TS> f(MEDFileAnyTypeField1TS::New(fileName,fieldName,iteration,order));
+  {
+    MCAuto<MEDFileField1TS> f1(MEDCoupling::DynamicCast<MEDFileAnyTypeField1TS,MEDFileField1TS>(f));
+    if(f1.isNotNull())
+      {
+        MCAuto<MEDCoupling::MEDCouplingFieldDouble> ret(ReadFieldNodeT<double>(f1,fileName,meshName,meshDimRelToMax,fieldName,iteration,order));
+        return ret.retn();
+      }
+  }
+  {
+    MCAuto<MEDFileIntField1TS> f1(MEDCoupling::DynamicCast<MEDFileAnyTypeField1TS,MEDFileIntField1TS>(f));
+    if(f1.isNotNull())
+      {
+        MCAuto<MEDCoupling::MEDCouplingFieldInt> ret(ReadFieldNodeT<int>(f1,fileName,meshName,meshDimRelToMax,fieldName,iteration,order));
+        return ret.retn();
+      }
+  }
+  {
+    MCAuto<MEDFileFloatField1TS> f1(MEDCoupling::DynamicCast<MEDFileAnyTypeField1TS,MEDFileFloatField1TS>(f));
+    if(f1.isNotNull())
+      {
+        MCAuto<MEDCoupling::MEDCouplingFieldFloat> ret(ReadFieldNodeT<float>(f1,fileName,meshName,meshDimRelToMax,fieldName,iteration,order));
+        return ret.retn();
+      }
+  }
+  throw INTERP_KERNEL::Exception("MEDCoupling::ReadFieldNode : only FLOAT32, FLOAT64 and INT32 supported for the moment !");
+}
+
+MEDCoupling::MEDCouplingField *MEDCoupling::ReadFieldGauss(const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName, int iteration, int order)
+{
+  return ReadFieldCellLike(ON_GAUSS_PT,fileName,meshName,meshDimRelToMax,fieldName,iteration,order);
+}
+
+MEDCoupling::MEDCouplingField *MEDCoupling::ReadFieldGaussNE(const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName, int iteration, int order)
+{
+  return ReadFieldCellLike(ON_GAUSS_NE,fileName,meshName,meshDimRelToMax,fieldName,iteration,order);
 }
 
 void MEDCoupling::WriteMesh(const std::string& fileName, const MEDCoupling::MEDCouplingMesh *mesh, bool writeFromScratch)
index 5398b1c3f83653d7582b937fd5a5a80ccc86136b..8c82058fd78790de9defa6425b03114960a630f9 100644 (file)
@@ -76,7 +76,7 @@ namespace MEDCoupling
   MEDLOADER_EXPORT MCAuto<MEDCoupling::MEDCouplingField> ReadField(const std::string& fileName);
   MEDLOADER_EXPORT MCAuto<MEDCoupling::MEDCouplingField> ReadField(const std::string& fileName, const std::string& fieldName);
   MEDLOADER_EXPORT MCAuto<MEDCoupling::MEDCouplingField> ReadField(const std::string& fileName, const std::string& fieldName, int iteration, int order);
-  MEDLOADER_EXPORT MCAuto<MEDCoupling::MEDCouplingFieldDouble> ReadField(MEDCoupling::TypeOfField type, const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName, int iteration, int order);
+  MEDLOADER_EXPORT MCAuto<MEDCoupling::MEDCouplingField> ReadField(MEDCoupling::TypeOfField type, const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName, int iteration, int order);
   MEDLOADER_EXPORT std::vector<MEDCoupling::MEDCouplingFieldDouble *> ReadFieldsOnSameMesh(MEDCoupling::TypeOfField type, const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName,
                                                                                            const std::vector<std::pair<int,int> >& its);
   MEDLOADER_EXPORT std::vector<MEDCoupling::MEDCouplingFieldDouble *> ReadFieldsCellOnSameMesh(const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName,
@@ -87,10 +87,10 @@ namespace MEDCoupling
                                                                                                 const std::vector<std::pair<int,int> >& its);
   MEDLOADER_EXPORT std::vector<MEDCoupling::MEDCouplingFieldDouble *> ReadFieldsGaussNEOnSameMesh(const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName,
                                                                                                   const std::vector<std::pair<int,int> >& its);
-  MEDLOADER_EXPORT MEDCoupling::MEDCouplingFieldDouble *ReadFieldCell(const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName, int iteration, int order);
-  MEDLOADER_EXPORT MEDCoupling::MEDCouplingFieldDouble *ReadFieldNode(const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName, int iteration, int order);
-  MEDLOADER_EXPORT MEDCoupling::MEDCouplingFieldDouble *ReadFieldGauss(const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName, int iteration, int order);
-  MEDLOADER_EXPORT MEDCoupling::MEDCouplingFieldDouble *ReadFieldGaussNE(const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName, int iteration, int order);
+  MEDLOADER_EXPORT MEDCoupling::MEDCouplingField *ReadFieldCell(const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName, int iteration, int order);
+  MEDLOADER_EXPORT MEDCoupling::MEDCouplingField *ReadFieldNode(const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName, int iteration, int order);
+  MEDLOADER_EXPORT MEDCoupling::MEDCouplingField *ReadFieldGauss(const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName, int iteration, int order);
+  MEDLOADER_EXPORT MEDCoupling::MEDCouplingField *ReadFieldGaussNE(const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName, int iteration, int order);
   MEDLOADER_EXPORT void WriteMesh(const std::string& fileName, const MEDCoupling::MEDCouplingMesh *mesh, bool writeFromScratch);
   MEDLOADER_EXPORT void WriteUMesh(const std::string& fileName, const MEDCoupling::MEDCouplingUMesh *mesh, bool writeFromScratch);
   MEDLOADER_EXPORT void WriteUMeshDep(const std::string& fileName, const MEDCoupling::MEDCouplingUMesh *mesh, bool writeFromScratch);
index c6630e17930354888e81c22febe1931c40f49400..460be09dec786653b248b0904397dafd34c49564 100644 (file)
@@ -364,10 +364,10 @@ namespace MEDCoupling
   MEDCoupling::MEDCouplingUMesh *ReadUMeshFromFile(const std::string& fileName, const std::string& meshName, int meshDimRelToMax=0) throw(INTERP_KERNEL::Exception);
   MEDCoupling::MEDCouplingUMesh *ReadUMeshFromFile(const std::string& fileName, int meshDimRelToMax=0) throw(INTERP_KERNEL::Exception);
   int ReadUMeshDimFromFile(const std::string& fileName, const std::string& meshName) throw(INTERP_KERNEL::Exception);
-  MEDCoupling::MEDCouplingFieldDouble *ReadFieldCell(const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
-  MEDCoupling::MEDCouplingFieldDouble *ReadFieldNode(const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
-  MEDCoupling::MEDCouplingFieldDouble *ReadFieldGauss(const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
-  MEDCoupling::MEDCouplingFieldDouble *ReadFieldGaussNE(const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
+  MEDCoupling::MEDCouplingField *ReadFieldCell(const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
+  MEDCoupling::MEDCouplingField *ReadFieldNode(const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
+  MEDCoupling::MEDCouplingField *ReadFieldGauss(const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
+  MEDCoupling::MEDCouplingField *ReadFieldGaussNE(const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
   void WriteMesh(const std::string& fileName, const MEDCoupling::MEDCouplingMesh *mesh, bool writeFromScratch) throw(INTERP_KERNEL::Exception);
   void WriteUMesh(const std::string& fileName, const MEDCoupling::MEDCouplingUMesh *mesh, bool writeFromScratch) throw(INTERP_KERNEL::Exception);
   void WriteUMeshDep(const std::string& fileName, const MEDCoupling::MEDCouplingUMesh *mesh, bool writeFromScratch) throw(INTERP_KERNEL::Exception);
@@ -423,9 +423,9 @@ namespace MEDCoupling
     return ret.retn();
   }
   
-  MEDCoupling::MEDCouplingFieldDouble *ReadFieldSwig(MEDCoupling::TypeOfField type, const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception)
+  MEDCoupling::MEDCouplingField *ReadFieldSwig(MEDCoupling::TypeOfField type, const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception)
   {
-    MCAuto<MEDCoupling::MEDCouplingFieldDouble> ret(MEDCoupling::ReadField(type,fileName,meshName,meshDimRelToMax,fieldName,iteration,order));
+    MCAuto<MEDCoupling::MEDCouplingField> ret(MEDCoupling::ReadField(type,fileName,meshName,meshDimRelToMax,fieldName,iteration,order));
     return ret.retn();
   }
 
index 8e60454b2a7192ab6916c19354406b9d93cc7652..1219b7b25e73cada08b45f1c6ca047ff8f415479 100644 (file)
@@ -93,14 +93,14 @@ void MEDLoaderTest::testFieldRW1()
 {
   MEDCouplingFieldDouble *f1=buildVecFieldOnCells_1();
   WriteField("file6.med",f1,true);
-  MEDCouplingFieldDouble *f2=ReadFieldCell("file6.med",f1->getMesh()->getName().c_str(),0,f1->getName().c_str(),0,1);
+  MEDCouplingFieldDouble *f2=dynamic_cast<MEDCouplingFieldDouble *>(ReadFieldCell("file6.med",f1->getMesh()->getName().c_str(),0,f1->getName().c_str(),0,1));
   CPPUNIT_ASSERT(f1->isEqual(f2,1e-12,1e-12));
   f1->decrRef();
   f2->decrRef();
   //
   f1=buildVecFieldOnNodes_1();
   WriteField("file7.med",f1,true);
-  f2=ReadFieldNode("file7.med",f1->getMesh()->getName().c_str(),0,f1->getName().c_str(),2,3);
+  f2=dynamic_cast<MEDCouplingFieldDouble *>(ReadFieldNode("file7.med",f1->getMesh()->getName().c_str(),0,f1->getName().c_str(),2,3));
   CPPUNIT_ASSERT(f1->isEqual(f2,1e-12,1e-12));
   // testing kind message on error of field type.
   CPPUNIT_ASSERT_THROW(ReadFieldCell("file7.med",f1->getMesh()->getName().c_str(),0,f1->getName().c_str(),2,3),INTERP_KERNEL::Exception);
@@ -127,17 +127,17 @@ void MEDLoaderTest::testFieldRW2()
   tmp[0]=VAL2;
   WriteFieldUsingAlreadyWrittenMesh(fileName,f1);
   //retrieving time steps...
-  MEDCouplingFieldDouble *f2=ReadFieldCell(fileName,f1->getMesh()->getName().c_str(),0,f1->getName().c_str(),8,9);
+  MEDCouplingFieldDouble *f2=dynamic_cast<MEDCouplingFieldDouble *>(ReadFieldCell(fileName,f1->getMesh()->getName().c_str(),0,f1->getName().c_str(),8,9));
   f1->setTime(10.,8,9);
   tmp[0]=VAL1;
   CPPUNIT_ASSERT(f1->isEqual(f2,1e-12,1e-12));
   f2->decrRef();
-  f2=ReadFieldCell(fileName,f1->getMesh()->getName().c_str(),0,f1->getName().c_str(),0,1);
+  f2=dynamic_cast<MEDCouplingFieldDouble *>(ReadFieldCell(fileName,f1->getMesh()->getName().c_str(),0,f1->getName().c_str(),0,1));
   MEDCouplingFieldDouble *f3=buildVecFieldOnCells_1();
   CPPUNIT_ASSERT(f3->isEqual(f2,1e-12,1e-12));
   f3->decrRef();
   f2->decrRef();
-  f2=ReadFieldCell(fileName,f1->getMesh()->getName().c_str(),0,f1->getName().c_str(),18,19);
+  f2=dynamic_cast<MEDCouplingFieldDouble *>(ReadFieldCell(fileName,f1->getMesh()->getName().c_str(),0,f1->getName().c_str(),18,19));
   f1->setTime(10.14,18,19);
   tmp[0]=VAL2;
   CPPUNIT_ASSERT(f1->isEqual(f2,1e-12,1e-12));
@@ -156,17 +156,17 @@ void MEDLoaderTest::testFieldRW2()
   f1->setTime(210.,208,209);
   tmp[3]=VAL2;
   WriteFieldUsingAlreadyWrittenMesh(fileName2,f1);
-  f2=ReadFieldNode(fileName2,f1->getMesh()->getName().c_str(),0,f1->getName().c_str(),108,109);
+  f2=dynamic_cast<MEDCouplingFieldDouble *>(ReadFieldNode(fileName2,f1->getMesh()->getName().c_str(),0,f1->getName().c_str(),108,109));
   f1->setTime(110.,108,109);
   tmp[3]=VAL1;
   CPPUNIT_ASSERT(f1->isEqual(f2,1e-12,1e-12));
   f2->decrRef();
-  f2=ReadFieldNode(fileName2,f1->getMesh()->getName().c_str(),0,f1->getName().c_str(),2,3);
+  f2=dynamic_cast<MEDCouplingFieldDouble *>(ReadFieldNode(fileName2,f1->getMesh()->getName().c_str(),0,f1->getName().c_str(),2,3));
   f3=buildVecFieldOnNodes_1();
   CPPUNIT_ASSERT(f3->isEqual(f2,1e-12,1e-12));
   f3->decrRef();
   f2->decrRef();
-  f2=ReadFieldNode(fileName2,f1->getMesh()->getName().c_str(),0,f1->getName().c_str(),208,209);
+  f2=dynamic_cast<MEDCouplingFieldDouble *>(ReadFieldNode(fileName2,f1->getMesh()->getName().c_str(),0,f1->getName().c_str(),208,209));
   f1->setTime(210.,208,209);
   tmp[3]=VAL2;
   CPPUNIT_ASSERT(f1->isEqual(f2,1e-12,1e-12));
@@ -233,29 +233,29 @@ void MEDLoaderTest::testFieldRW3()
   //
   f1->decrRef();
   //
-  f1=ReadFieldCell(fileName,name3,0,name1,8,9);
+  f1=dynamic_cast<MEDCouplingFieldDouble *>(ReadFieldCell(fileName,name3,0,name1,8,9));
   CPPUNIT_ASSERT_DOUBLES_EQUAL(VAL1,f1->getArray()->getConstPointer()[0],1e-13);
   f1->decrRef();
-  f1=ReadFieldCell(fileName,name3,0,name1,18,19);
+  f1=dynamic_cast<MEDCouplingFieldDouble *>(ReadFieldCell(fileName,name3,0,name1,18,19));
   CPPUNIT_ASSERT_DOUBLES_EQUAL(VAL2,f1->getArray()->getConstPointer()[0],1e-13);
   f1->decrRef();
-  f1=ReadFieldCell(fileName,name3,0,name1,28,29);
+  f1=dynamic_cast<MEDCouplingFieldDouble *>(ReadFieldCell(fileName,name3,0,name1,28,29));
   CPPUNIT_ASSERT_DOUBLES_EQUAL(3*VAL1,f1->getArray()->getConstPointer()[0],1e-13);
   f1->decrRef();
-  f1=ReadFieldCell(fileName,name3,0,name1,38,39);
+  f1=dynamic_cast<MEDCouplingFieldDouble *>(ReadFieldCell(fileName,name3,0,name1,38,39));
   CPPUNIT_ASSERT_DOUBLES_EQUAL(3*VAL2,f1->getArray()->getConstPointer()[0],1e-13);
   f1->decrRef();
-  f1=ReadFieldCell(fileName,name3,0,name1,48,49);
+  f1=dynamic_cast<MEDCouplingFieldDouble *>(ReadFieldCell(fileName,name3,0,name1,48,49));
   CPPUNIT_ASSERT_DOUBLES_EQUAL(4*VAL2,f1->getArray()->getConstPointer()[0],1e-13);
   f1->decrRef();
   //
-  f1=ReadFieldNode(fileName,name3,0,name1,8,9);
+  f1=dynamic_cast<MEDCouplingFieldDouble *>(ReadFieldNode(fileName,name3,0,name1,8,9));
   CPPUNIT_ASSERT_DOUBLES_EQUAL(71.,f1->getArray()->getConstPointer()[3],1e-13);
   f1->decrRef();
-  f1=ReadFieldNode(fileName,name3,0,name1,108,109);
+  f1=dynamic_cast<MEDCouplingFieldDouble *>(ReadFieldNode(fileName,name3,0,name1,108,109));
   CPPUNIT_ASSERT_DOUBLES_EQUAL(VAL1,f1->getArray()->getConstPointer()[3],1e-13);
   f1->decrRef();
-  f1=ReadFieldNode(fileName,name3,0,name1,208,209);
+  f1=dynamic_cast<MEDCouplingFieldDouble *>(ReadFieldNode(fileName,name3,0,name1,208,209));
   CPPUNIT_ASSERT_DOUBLES_EQUAL(VAL2,f1->getArray()->getConstPointer()[3],1e-13);
   f1->decrRef();
 }
@@ -377,7 +377,7 @@ void MEDLoaderTest::testFieldProfilRW1()
   //
   WriteField(fileName,f1,false);//<- false important for the test
   //
-  MEDCouplingFieldDouble *f2=ReadFieldCell(fileName,f1->getMesh()->getName().c_str(),0,f1->getName().c_str(),2,7);
+  MEDCouplingFieldDouble *f2=dynamic_cast<MEDCouplingFieldDouble *>(ReadFieldCell(fileName,f1->getMesh()->getName().c_str(),0,f1->getName().c_str(),2,7));
   std::vector<MEDCoupling::TypeOfField> types=GetTypesOfField(fileName,f1->getMesh()->getName().c_str(),f1->getName().c_str());
   CPPUNIT_ASSERT_EQUAL(1,(int)types.size());
   CPPUNIT_ASSERT(types[0]==ON_CELLS);
@@ -418,7 +418,7 @@ void MEDLoaderTest::testFieldNodeProfilRW1()
   (const_cast<MEDCouplingMesh *>(f2->getMesh()))->setName(f1->getMesh()->getName().c_str());
   WriteField(fileName,f2,false);//<- false important for the test
   //
-  MEDCouplingFieldDouble *f3=ReadFieldNode(fileName,f2->getMesh()->getName().c_str(),0,f2->getName().c_str(),2,7);
+  MEDCouplingFieldDouble *f3=dynamic_cast<MEDCouplingFieldDouble *>(ReadFieldNode(fileName,f2->getMesh()->getName().c_str(),0,f2->getName().c_str(),2,7));
   f3->checkConsistencyLight();
   CPPUNIT_ASSERT(f3->isEqual(f2,1e-12,1e-12));
   f3->decrRef();
@@ -427,7 +427,7 @@ void MEDLoaderTest::testFieldNodeProfilRW1()
   f2->renumberNodes(arr3);
   WriteUMesh(fileName2,m,true);
   WriteField(fileName2,f2,false);//<- false important for the test
-  f3=ReadFieldNode(fileName2,f2->getMesh()->getName().c_str(),0,f2->getName().c_str(),2,7);
+  f3=dynamic_cast<MEDCouplingFieldDouble *>(ReadFieldNode(fileName2,f2->getMesh()->getName().c_str(),0,f2->getName().c_str(),2,7));
   f3->checkConsistencyLight();
   CPPUNIT_ASSERT(f3->isEqual(f2,1e-12,1e-12));
   f3->decrRef();
@@ -464,7 +464,7 @@ void MEDLoaderTest::testFieldNodeProfilRW2()
   f1->renumberNodes(renumArr);
   f1->checkConsistencyLight();
   WriteField(fileName,f1,false);//<- false important for the test
-  MEDCouplingFieldDouble *f2=ReadFieldNode(fileName,f1->getMesh()->getName().c_str(),0,f1->getName().c_str(),2,7);
+  MEDCouplingFieldDouble *f2=dynamic_cast<MEDCouplingFieldDouble *>(ReadFieldNode(fileName,f1->getMesh()->getName().c_str(),0,f1->getName().c_str(),2,7));
   CPPUNIT_ASSERT(f2->isEqual(f1,1e-12,1e-12));
   //
   f2->decrRef();
@@ -477,7 +477,8 @@ void MEDLoaderTest::testFieldGaussRW1()
   const char fileName[]="file13.med";
   MEDCouplingFieldDouble *f1=buildVecFieldOnGauss_1();
   WriteField(fileName,f1,true);
-  MCAuto<MEDCouplingFieldDouble> f2(ReadField(ON_GAUSS_PT,fileName,f1->getMesh()->getName().c_str(),0,f1->getName().c_str(),1,5));
+  MCAuto<MEDCouplingField> f2Tmp(ReadField(ON_GAUSS_PT,fileName,f1->getMesh()->getName().c_str(),0,f1->getName().c_str(),1,5));
+  MCAuto<MEDCouplingFieldDouble> f2(MEDCoupling::DynamicCast<MEDCouplingField,MEDCouplingFieldDouble>(f2Tmp));
   CPPUNIT_ASSERT(f1->isEqual(f2,1e-12,1e-12));
   f1->decrRef();
 }
@@ -490,7 +491,8 @@ void MEDLoaderTest::testFieldGaussNERW1()
   std::vector<MEDCoupling::TypeOfField> tof(GetTypesOfField(fileName,"2DMesh_2","MyFieldOnGaussNE"));
   CPPUNIT_ASSERT_EQUAL(1,(int)tof.size());
   CPPUNIT_ASSERT(ON_GAUSS_NE==tof[0]);
-  MCAuto<MEDCouplingFieldDouble> f2(ReadField(ON_GAUSS_NE,fileName,f1->getMesh()->getName().c_str(),0,f1->getName().c_str(),1,5));
+  MCAuto<MEDCouplingField> f2Tmp(ReadField(ON_GAUSS_NE,fileName,f1->getMesh()->getName().c_str(),0,f1->getName().c_str(),1,5));
+  MCAuto<MEDCouplingFieldDouble> f2(MEDCoupling::DynamicCast<MEDCouplingField,MEDCouplingFieldDouble>(f2Tmp));
   CPPUNIT_ASSERT(f1->isEqual(f2,1e-12,1e-12));
   f1->decrRef();
 }
@@ -560,7 +562,7 @@ void MEDLoaderTest::testFieldShuffleRW1()
   const int renumber1[6]={2,1,5,0,3,4};
   f1->renumberCells(renumber1,false);
   WriteField(fileName,f1,true);
-  MEDCouplingFieldDouble *f2=ReadFieldCell(fileName,mesh->getName().c_str(),0,f1->getName().c_str(),2,7);
+  MEDCouplingFieldDouble *f2=dynamic_cast<MEDCouplingFieldDouble *>((MEDCouplingField *)ReadFieldCell(fileName,mesh->getName().c_str(),0,f1->getName().c_str(),2,7));
   CPPUNIT_ASSERT(f2->isEqual(f1,1e-12,1e-12));
   f2->decrRef();
   //
@@ -661,7 +663,7 @@ void MEDLoaderTest::testWriteUMeshesRW1()
   f1->setTime(3.14,2,7);
   f1->checkConsistencyLight();
   WriteFieldUsingAlreadyWrittenMesh(fileName,f1);
-  MEDCouplingFieldDouble *f2=ReadFieldCell(fileName,f1->getMesh()->getName().c_str(),-1,f1->getName().c_str(),2,7);
+  MEDCouplingFieldDouble *f2=dynamic_cast<MEDCouplingFieldDouble *>((MEDCouplingField *)ReadFieldCell(fileName,f1->getMesh()->getName().c_str(),-1,f1->getName().c_str(),2,7));
   CPPUNIT_ASSERT(f2->isEqual(f1,1e-12,1e-12));
   f1->decrRef();
   f2->decrRef();
@@ -726,10 +728,10 @@ void MEDLoaderTest::testMixCellAndNodesFieldRW1()
   CPPUNIT_ASSERT_EQUAL(ON_NODES,ts[0]);
   CPPUNIT_ASSERT_EQUAL(ON_CELLS,ts[1]);
   //
-  MEDCouplingFieldDouble *f3=ReadFieldNode(fileName,f1->getMesh()->getName().c_str(),0,f1->getName().c_str(),2,7);
+  MEDCouplingFieldDouble *f3=dynamic_cast<MEDCouplingFieldDouble *>((MEDCouplingField *)ReadFieldNode(fileName,f1->getMesh()->getName().c_str(),0,f1->getName().c_str(),2,7));
   CPPUNIT_ASSERT(f3->isEqual(f2,1e-12,1e-12));
   f3->decrRef();
-  f3=ReadFieldCell(fileName,f1->getMesh()->getName().c_str(),0,f1->getName().c_str(),2,7);
+  f3=dynamic_cast<MEDCouplingFieldDouble *>((MEDCouplingField *)ReadFieldCell(fileName,f1->getMesh()->getName().c_str(),0,f1->getName().c_str(),2,7));
   CPPUNIT_ASSERT(f3->isEqual(f1,1e-12,1e-12));
   f3->decrRef();
   //
@@ -857,7 +859,7 @@ void MEDLoaderTest::testMEDLoaderRead1()
   CPPUNIT_ASSERT_EQUAL(-1,its1[0].first);
   CPPUNIT_ASSERT_EQUAL(-1,its1[0].second);
   //
-  MEDCouplingFieldDouble *field0=ReadFieldCell(fileName.c_str(),meshNames[0].c_str(),0,fieldsName[0].c_str(),its0[0].first,its0[0].second);
+  MEDCouplingFieldDouble *field0=dynamic_cast<MEDCouplingFieldDouble *>((MEDCouplingField *)ReadFieldCell(fileName.c_str(),meshNames[0].c_str(),0,fieldsName[0].c_str(),its0[0].first,its0[0].second));
   field0->checkConsistencyLight();
   CPPUNIT_ASSERT(field0->getName()==fieldsName[0]);
  CPPUNIT_ASSERT_EQUAL(1,(int)field0->getNumberOfComponents());
@@ -886,11 +888,11 @@ void MEDLoaderTest::testMEDLoaderRead1()
   CPPUNIT_ASSERT_DOUBLES_EQUAL(46.,std::accumulate(constMesh->getCoords()->getConstPointer(),constMesh->getCoords()->getConstPointer()+57,0),1e-12);
   field0->decrRef();
   //
-  MEDCouplingFieldDouble *field1=ReadFieldCell(fileName.c_str(),meshNames[0].c_str(),0,fieldsName[1].c_str(),its1[0].first,its1[0].second);
+  MEDCouplingFieldDouble *field1=dynamic_cast<MEDCouplingFieldDouble *>((MEDCouplingField *)ReadFieldCell(fileName.c_str(),meshNames[0].c_str(),0,fieldsName[1].c_str(),its1[0].first,its1[0].second));
   field1->checkConsistencyLight();
   CPPUNIT_ASSERT(field1->getName()==fieldsName[1]);
- CPPUNIT_ASSERT_EQUAL(3,(int)field1->getNumberOfComponents());
- CPPUNIT_ASSERT_EQUAL(16,(int)field1->getNumberOfTuples());
 CPPUNIT_ASSERT_EQUAL(3,(int)field1->getNumberOfComponents());
 CPPUNIT_ASSERT_EQUAL(16,(int)field1->getNumberOfTuples());
   const double expectedValues2[48]={1.,0.,1.,1.,0.,1.,1.,0.,1.,2.,1.,0.,2.,1.,0.,2.,1.,0.,3.,0.,1.,3.,0.,1.,3.,0.,1.,4.,1.,0.,4.,1.,0.,4.,1.,0.,5.,0.,0.,6.,1.,1.,6.,0.,0.,5.,1.,1.};
   double diffValue2[48];
   std::transform(field1->getArray()->getPointer(),field1->getArray()->getPointer()+48,expectedValues2,diffValue2,std::minus<double>());
@@ -927,7 +929,7 @@ void MEDLoaderTest::testMEDLoaderRead1()
   CPPUNIT_ASSERT_EQUAL(-1,its0Node[1].second);
   CPPUNIT_ASSERT_EQUAL(2,its0Node[2].first);
   CPPUNIT_ASSERT_EQUAL(-1,its0Node[2].second);
-  MEDCouplingFieldDouble *field0Nodes=ReadFieldNode(fileName.c_str(),meshNames[0].c_str(),0,fieldsNameNode[0].c_str(),its0Node[0].first,its0Node[0].second);
+  MEDCouplingFieldDouble *field0Nodes=dynamic_cast<MEDCouplingFieldDouble *>((MEDCouplingField *)ReadFieldNode(fileName.c_str(),meshNames[0].c_str(),0,fieldsNameNode[0].c_str(),its0Node[0].first,its0Node[0].second));
   field0Nodes->checkConsistencyLight();
   CPPUNIT_ASSERT(field0Nodes->getName()==fieldsNameNode[0]);
  CPPUNIT_ASSERT_EQUAL(1,(int)field0Nodes->getNumberOfComponents());
@@ -941,7 +943,7 @@ void MEDLoaderTest::testMEDLoaderRead1()
   CPPUNIT_ASSERT(constMesh);
   field0Nodes->decrRef();
   //
-  field0Nodes=ReadFieldNode(fileName.c_str(),meshNames[0].c_str(),0,fieldsNameNode[0].c_str(),its0Node[2].first,its0Node[2].second);
+  field0Nodes=dynamic_cast<MEDCouplingFieldDouble *>((MEDCouplingField *)ReadFieldNode(fileName.c_str(),meshNames[0].c_str(),0,fieldsNameNode[0].c_str(),its0Node[2].first,its0Node[2].second));
   field0Nodes->checkConsistencyLight();
   CPPUNIT_ASSERT(field0Nodes->getName()==fieldsNameNode[0]);
  CPPUNIT_ASSERT_EQUAL(1,(int)field0Nodes->getNumberOfComponents());
@@ -969,7 +971,7 @@ void MEDLoaderTest::testMEDLoaderRead1()
   CPPUNIT_ASSERT_DOUBLES_EQUAL(46.,std::accumulate(constMesh->getCoords()->getConstPointer(),constMesh->getCoords()->getConstPointer()+57,0),1e-12);
   field0Nodes->decrRef();
   //
-  field0Nodes=ReadFieldNode(fileName.c_str(),meshNames[0].c_str(),0,fieldsNameNode[0].c_str(),its0Node[0].first,its0Node[0].second);
+  field0Nodes=dynamic_cast<MEDCouplingFieldDouble *>((MEDCouplingField *)ReadFieldNode(fileName.c_str(),meshNames[0].c_str(),0,fieldsNameNode[0].c_str(),its0Node[0].first,its0Node[0].second));
   field0Nodes->checkConsistencyLight();
   CPPUNIT_ASSERT(field0Nodes->getName()==fieldsNameNode[0]);
  CPPUNIT_ASSERT_EQUAL(1,(int)field0Nodes->getNumberOfComponents());
@@ -1036,7 +1038,7 @@ void MEDLoaderTest::testMEDLoaderPolygonRead()
   CPPUNIT_ASSERT(fieldsName[2]=="bord_:_non-ortho");
   std::vector<std::pair<int,int> > its0=GetCellFieldIterations(fileName.c_str(),meshNames[0].c_str(),fieldsName[0].c_str());
   CPPUNIT_ASSERT_EQUAL(1,(int)its0.size());
-  MEDCouplingFieldDouble *field=ReadFieldCell(fileName.c_str(),meshNames[0].c_str(),0,fieldsName[0].c_str(),its0[0].first,its0[0].second);
+  MEDCouplingFieldDouble *field=dynamic_cast<MEDCouplingFieldDouble *>((MEDCouplingField *)ReadFieldCell(fileName.c_str(),meshNames[0].c_str(),0,fieldsName[0].c_str(),its0[0].first,its0[0].second));
   field->checkConsistencyLight();
   CPPUNIT_ASSERT(field->getName()==fieldsName[0]);
  CPPUNIT_ASSERT_EQUAL(1,(int)field->getNumberOfComponents());
index 061bea0010defd0b9067bc822107d7d3804ab4c4..272303a1c2cb7320936dfa622b1435ac5970ff28 100644 (file)
@@ -2273,9 +2273,9 @@ MEDCoupling::DataArrayDouble *MEDPARTITIONER::MeshCollection::getField(std::stri
     std::cout << "proc " << MyGlobals::_Rank << " : in " << fileName << " " << iold << " " << descriptionIold << std::endl;
   FieldShortDescriptionToData(descriptionIold, fieldName, typeField, entity, DT, IT);
   meshName=MyGlobals::_Mesh_Names[iold];
-  
-  MEDCoupling::MCAuto<MEDCoupling::MEDCouplingFieldDouble> f2=ReadField((MEDCoupling::TypeOfField) typeField,
-                                                                        fileName, meshName, 0, fieldName, DT, IT);
+
+  MCAuto<MEDCoupling::MEDCouplingField> f2Tmp(ReadField((MEDCoupling::TypeOfField) typeField, fileName, meshName, 0, fieldName, DT, IT));
+  MCAuto<MEDCoupling::MEDCouplingFieldDouble> f2(MEDCoupling::DynamicCast<MEDCouplingField,MEDCouplingFieldDouble>(f2Tmp));
   
   MEDCoupling::DataArrayDouble* res=f2->getArray();
   //to know names of components
index 2a840a350dcc6a16c0cc42f0a6886c47c608f0f5..e496ace68626a97ad442856adf3dae384258f64c 100644 (file)
@@ -285,7 +285,7 @@ int MEDPARTITIONER::ParaDomainSelector::getProcNodeShift() const
 /*!
  * \brief Gather graphs from all processors into one
  */
-std::auto_ptr<MEDPARTITIONER::Graph> MEDPARTITIONER::ParaDomainSelector::gatherGraph(const Graph* graph) const
+std::unique_ptr<MEDPARTITIONER::Graph> MEDPARTITIONER::ParaDomainSelector::gatherGraph(const Graph* graph) const
 {
   Graph* glob_graph = 0;
 
@@ -382,7 +382,7 @@ std::auto_ptr<MEDPARTITIONER::Graph> MEDPARTITIONER::ParaDomainSelector::gatherG
 
 #endif // HAVE_MPI
 
-  return std::auto_ptr<Graph>( glob_graph );
+  return std::unique_ptr<Graph>( glob_graph );
 }
 
 
index 97502406f36cb3ed441c931b90a596adff9433e5..9fde64b3f06db20f0368e0cc347723ed80c59d54 100644 (file)
@@ -77,7 +77,7 @@ namespace MEDPARTITIONER
     int getDomainNodeShift(int domainIndex) const;
 
     //Gather graphs from all processors into one
-    std::auto_ptr<Graph> gatherGraph(const Graph* graph) const;
+    std::unique_ptr<Graph> gatherGraph(const Graph* graph) const;
 
     //Set nb of cell/cell pairs in a joint between domains
     void setNbCellPairs( int nb_cell_pairs, int dist_domain, int loc_domain );
index 2329b41e968f0ef649f85dc42b0469a92a1b620e..6b25be16ffe5d92cb7a849678bcbaa56bd717ec7 100644 (file)
@@ -649,7 +649,8 @@ void MEDPARTITIONERTest::createTestMeshWithVecFieldOnCells()
     if (_verbose) cout<<endl<<name<<" created"<<endl;
     if (_ntot<1000000) //too long
       {
-        MCAuto<MEDCouplingFieldDouble> f2=ReadFieldCell(name.c_str(),f1->getMesh()->getName().c_str(),0,f1->getName().c_str(),0,1);
+        MCAuto<MEDCoupling::MEDCouplingField> f2Tmp(ReadFieldCell(name.c_str(),f1->getMesh()->getName().c_str(),0,f1->getName().c_str(),0,1));
+        MCAuto<MEDCoupling::MEDCouplingFieldDouble> f2(MEDCoupling::DynamicCast<MEDCouplingField,MEDCouplingFieldDouble>(f2Tmp));
         //DataArrayDouble *res=f2->getArray();
         if (_verbose) cout<<name<<" reread"<<endl;
         //CPPUNIT_ASSERT(f1->isEqual(f2,1e-12,1e-12));
@@ -706,7 +707,8 @@ void MEDPARTITIONERTest::createTestMeshWithVecFieldOnCells()
     f1->decrRef();
     if (_ntot<1000000) //too long
       {
-        MCAuto<MEDCouplingFieldDouble> f4=ReadField(ON_GAUSS_NE, name.c_str(), f3->getMesh()->getName().c_str(), 0, "MyFieldOnGaussNE", 5, 6);
+        MCAuto<MEDCoupling::MEDCouplingField> f4Tmp(ReadField(ON_GAUSS_NE, name.c_str(), f3->getMesh()->getName().c_str(), 0, "MyFieldOnGaussNE", 5, 6));
+        MCAuto<MEDCoupling::MEDCouplingFieldDouble> f4(MEDCoupling::DynamicCast<MEDCouplingField,MEDCouplingFieldDouble>(f4Tmp));
         if (_verbose) cout<<"MyFieldOnGaussNE reread"<<endl;
       }
     f3->decrRef();
@@ -719,7 +721,8 @@ void MEDPARTITIONERTest::createTestMeshWithVecFieldOnCells()
     if (_verbose) cout<<endl<<name<<" created"<<endl;
     if (_ntot<1000000) //too long
       {
-        MCAuto<MEDCouplingFieldDouble> f2=ReadFieldCell(name.c_str(),f1->getMesh()->getName().c_str(),0,f1->getName().c_str(),0,1);
+        MCAuto<MEDCouplingField> f2Tmp=ReadFieldCell(name.c_str(),f1->getMesh()->getName().c_str(),0,f1->getName().c_str(),0,1);
+        MCAuto<MEDCoupling::MEDCouplingFieldDouble> f2(MEDCoupling::DynamicCast<MEDCouplingField,MEDCouplingFieldDouble>(f2Tmp));
         if (_verbose) cout<<name<<" reread"<<endl;
         //CPPUNIT_ASSERT(f1->isEqual(f2,1e-12,1e-12)); assertion failed!!
       }
@@ -736,7 +739,7 @@ void MEDPARTITIONERTest::createTestMeshWithVecFieldOnNodes()
   if (_verbose) cout<<endl<<name<<" created"<<endl;
   if (_ntot<1000000) //too long
     {
-      MCAuto<MEDCouplingFieldDouble> f2=ReadFieldNode(name.c_str(),f1->getMesh()->getName().c_str(),0,f1->getName().c_str(),0,1);
+      MCAuto<MEDCouplingField> f2=ReadFieldNode(name.c_str(),f1->getMesh()->getName().c_str(),0,f1->getName().c_str(),0,1);
       if (_verbose) cout<<name<<" reread"<<endl;
       //CPPUNIT_ASSERT(f1->isEqual(f2,1e-12,1e-12)); assertion failed!!
     }
@@ -879,7 +882,7 @@ void MEDPARTITIONERTest::testMeshCollectionComplexPartitionMetis()
   for (int ndomains=2 ; ndomains<=16 ; ndomains++)
     {
       //Creating the graph and partitioning it
-      auto_ptr< MEDPARTITIONER::Topology > new_topo;
+      std::unique_ptr< MEDPARTITIONER::Topology > new_topo;
       new_topo.reset( collection.createPartition(ndomains,MEDPARTITIONER::Graph::METIS) );
       //Creating a new mesh collection from the partitioning
       MEDPARTITIONER::MeshCollection new_collection(collection,new_topo.get(),split_family,empty_groups);
@@ -925,7 +928,7 @@ void MEDPARTITIONERTest::testMeshCollectionSinglePartitionScotch()
   MEDPARTITIONER::ParallelTopology* aPT = (MEDPARTITIONER::ParallelTopology*) collection.getTopology();
   aPT->setGlobalNumerotationDefault(collection.getParaDomainSelector());
   //Creating the graph and partitioning it
-  auto_ptr< MEDPARTITIONER::Topology > new_topo;
+  std::unique_ptr< MEDPARTITIONER::Topology > new_topo;
   new_topo.reset( collection.createPartition(ndomains,MEDPARTITIONER::Graph::SCOTCH) );
   //Creating a new mesh collection from the partitioning
   MEDPARTITIONER::MeshCollection new_collection(collection,new_topo.get(),split_family,empty_groups);
@@ -961,7 +964,7 @@ void MEDPARTITIONERTest::testMeshCollectionComplexPartitionScotch()
   for (int ndomains=2 ; ndomains<=16 ; ndomains++)
     {
       //Creating the graph and partitioning it
-      auto_ptr< MEDPARTITIONER::Topology > new_topo;
+      std::unique_ptr< MEDPARTITIONER::Topology > new_topo;
       new_topo.reset( collection.createPartition(ndomains,MEDPARTITIONER::Graph::SCOTCH) );
       //Creating a new mesh collection from the partitioning
       MEDPARTITIONER::MeshCollection new_collection(collection,new_topo.get(),split_family,empty_groups);
@@ -1179,8 +1182,9 @@ void MEDPARTITIONERTest::verifyMetisOrScotchMedpartitionerOnSmallSizeForFieldOnC
   MEDCouplingUMesh* fusedCell=MEDCouplingUMesh::FuseUMeshesOnSameCoords(meshes,0,corr);
   CPPUNIT_ASSERT_EQUAL(cellMesh->getNumberOfCells(), fusedCell->getNumberOfCells());
 
-  MCAuto<MEDCouplingFieldDouble> field1=ReadFieldCell(fileName.c_str(),initialMesh->getName().c_str(),0,"VectorFieldOnCells",0,1);
-  MCAuto<MEDCouplingFieldDouble> field2=ReadFieldCell(refusedName.c_str(),refusedCellMesh->getName().c_str(),0,"VectorFieldOnCells",0,1);
+  MCAuto<MEDCouplingField> field1Tmp(ReadFieldCell(fileName.c_str(),initialMesh->getName().c_str(),0,"VectorFieldOnCells",0,1));
+  MCAuto<MEDCouplingField> field2Tmp(ReadFieldCell(refusedName.c_str(),refusedCellMesh->getName().c_str(),0,"VectorFieldOnCells",0,1));
+  MCAuto<MEDCouplingFieldDouble> field1(MEDCoupling::DynamicCast<MEDCouplingField,MEDCouplingFieldDouble>(field1Tmp)),field2(MEDCoupling::DynamicCast<MEDCouplingField,MEDCouplingFieldDouble>(field2Tmp));
 
   int nbcells=corr[1]->getNumberOfTuples();
   CPPUNIT_ASSERT_EQUAL((int)cellMesh->getNumberOfCells(), nbcells);
@@ -1266,8 +1270,9 @@ void MEDPARTITIONERTest::verifyMetisOrScotchMedpartitionerOnSmallSizeForFieldOnG
   MEDCouplingUMesh* fusedCell=MEDCouplingUMesh::FuseUMeshesOnSameCoords(meshes,0,corr);
   CPPUNIT_ASSERT_EQUAL(cellMesh->getNumberOfCells(), fusedCell->getNumberOfCells());
 
-  MCAuto<MEDCouplingFieldDouble> field1=ReadField(ON_GAUSS_NE,fileName.c_str(),initialMesh->getName().c_str(),0,"MyFieldOnGaussNE",5,6);
-  MCAuto<MEDCouplingFieldDouble> field2=ReadField(ON_GAUSS_NE,refusedName.c_str(),refusedCellMesh->getName().c_str(),0,"MyFieldOnGaussNE",5,6);
+  MCAuto<MEDCouplingField> field1Tmp=ReadField(ON_GAUSS_NE,fileName.c_str(),initialMesh->getName().c_str(),0,"MyFieldOnGaussNE",5,6);
+  MCAuto<MEDCouplingField> field2Tmp=ReadField(ON_GAUSS_NE,refusedName.c_str(),refusedCellMesh->getName().c_str(),0,"MyFieldOnGaussNE",5,6);
+  MCAuto<MEDCouplingFieldDouble> field1(MEDCoupling::DynamicCast<MEDCouplingField,MEDCouplingFieldDouble>(field1Tmp)),field2(MEDCoupling::DynamicCast<MEDCouplingField,MEDCouplingFieldDouble>(field2Tmp));
 
   int nbcells=corr[1]->getNumberOfTuples();
   CPPUNIT_ASSERT_EQUAL((int)cellMesh->getNumberOfCells(), nbcells);
@@ -1406,7 +1411,7 @@ void MEDPARTITIONERTest::testCreateBoundaryFaces2D()
   ParallelTopology* aPT = (ParallelTopology*) collection.getTopology();
   aPT->setGlobalNumerotationDefault(collection.getParaDomainSelector());
 
-  std::auto_ptr< Topology > new_topo;
+  std::unique_ptr< Topology > new_topo;
 #if defined(MED_ENABLE_METIS) || defined(MED_ENABLE_PARMETIS)
   new_topo.reset( collection.createPartition(ndomains,Graph::METIS) );
 #endif