From: Anthony Geay Date: Fri, 5 May 2017 09:34:13 +0000 (+0200) Subject: Maps available for partitioning X-Git-Tag: V8_4_0a1~54 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=8f5dc67009ccb1d3a57bcd783be2ad4b7edf173f;p=tools%2Fmedcoupling.git Maps available for partitioning --- diff --git a/src/MEDCoupling_Swig/MEDCouplingBasicsTest5.py b/src/MEDCoupling_Swig/MEDCouplingBasicsTest5.py index c55eaf8a3..b1ed46f08 100644 --- a/src/MEDCoupling_Swig/MEDCouplingBasicsTest5.py +++ b/src/MEDCoupling_Swig/MEDCouplingBasicsTest5.py @@ -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__': diff --git a/src/MEDCoupling_Swig/MEDCouplingMemArray.i b/src/MEDCoupling_Swig/MEDCouplingMemArray.i index 08ba64fb0..2bff77e43 100644 --- a/src/MEDCoupling_Swig/MEDCouplingMemArray.i +++ b/src/MEDCoupling_Swig/MEDCouplingMemArray.i @@ -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 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(da); + self->transformWithIndArr(*m); + } + else + { + int size; + INTERP_KERNEL::AutoPtr tmp=convertPyToNewIntArr2(li,&size); + self->transformWithIndArr(tmp,tmp+size); + } } else {