]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
Maps available for partitioning
authorAnthony Geay <anthony.geay@edf.fr>
Fri, 5 May 2017 09:34:13 +0000 (11:34 +0200)
committerAnthony Geay <anthony.geay@edf.fr>
Fri, 5 May 2017 09:34:13 +0000 (11:34 +0200)
src/MEDCoupling_Swig/MEDCouplingBasicsTest5.py
src/MEDCoupling_Swig/MEDCouplingMemArray.i

index c55eaf8a3c086c8049ad5a79a978c54163ec9422..b1ed46f0806c83d8c95a790231ee04f82a9f9916 100644 (file)
@@ -4640,6 +4640,16 @@ class MEDCouplingBasicsTest5(unittest.TestCase):
         self.assertTrue(d.convertToFloatArr().isEqual(DataArrayFloat([-5,-4,-3,-2,-1,0,1,2,3,4]),1e-7))
         self.assertTrue(d.convertToFloatArr().convertToDblArr().isEqual(d,1e-12))
         pass
+
+    def testMapII1(self):
+        """ Test optimized maps for renumbering. Typical usage local to global in parallel mode"""
+        d=DataArrayInt([1003,1007])
+        m=d.invertArrayN2O2O2NOptimized()
+        d2=DataArrayInt([1003,1003,1007,1003,1007])
+        d2.transformWithIndArr(m)
+        self.assertTrue(d2.isEqual(DataArrayInt([0,0,1,0,1])))
+        pass
+    
     pass
 
 if __name__ == '__main__':
index 08ba64fb0ac2f39392494ee1d078326221876b79..2bff77e433dc5f5baa3f859b7700edbb58efe720 100644 (file)
@@ -2322,6 +2322,7 @@ namespace MEDCoupling
     DataArrayInt *invertArrayO2N2N2O(int newNbOfElem) const throw(INTERP_KERNEL::Exception);
     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);
     DataArrayInt *indicesOfSubPart(const DataArrayInt& partOfThis) const throw(INTERP_KERNEL::Exception);
     DataArrayInt *fromNoInterlace() const throw(INTERP_KERNEL::Exception);
     DataArrayInt *toNoInterlace() const throw(INTERP_KERNEL::Exception);
@@ -2737,12 +2738,21 @@ namespace MEDCoupling
       void transformWithIndArr(PyObject *li) throw(INTERP_KERNEL::Exception)
       {
         void *da=0;
-        int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_MEDCoupling__DataArrayInt, 0 |  0 );
+        int res1(SWIG_ConvertPtr(li,&da,SWIGTYPE_p_MEDCoupling__DataArrayInt, 0 |  0 ));
         if (!SWIG_IsOK(res1))
           {
-            int size;
-            INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
-            self->transformWithIndArr(tmp,tmp+size);
+            int res2(SWIG_ConvertPtr(li,&da,SWIGTYPE_p_MEDCoupling__MapII, 0 |  0 ));
+            if(SWIG_IsOK(res2))
+              {
+                MapII *m=reinterpret_cast<MapII *>(da);
+                self->transformWithIndArr(*m);
+              }
+            else
+              {
+                int size;
+                INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+                self->transformWithIndArr(tmp,tmp+size);
+              }
           }
         else
           {