From: Anthony Geay Date: Tue, 17 Oct 2017 08:32:53 +0000 (+0200) Subject: Add a non reg test to highlight debug on computeEnlargedNeighborsOfNodes X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=3d3665607d368ce07e5ffc0d854286add8846f0c;p=tools%2Fmedcoupling.git Add a non reg test to highlight debug on computeEnlargedNeighborsOfNodes --- diff --git a/src/MEDCoupling/MEDCouplingUMesh.cxx b/src/MEDCoupling/MEDCouplingUMesh.cxx index 07ba32835..dfd764ab3 100644 --- a/src/MEDCoupling/MEDCouplingUMesh.cxx +++ b/src/MEDCoupling/MEDCouplingUMesh.cxx @@ -974,12 +974,13 @@ void MEDCouplingUMesh::computeEnlargedNeighborsOfNodes(MCAuto &nei neighborsIdx=DataArrayInt::New(); neighborsIdx->alloc(nbOfNodes+1,1); neighborsIdx->setIJ(0,0,0); { int *neighIdx(neighborsIdx->getPointer()); - for(std::vector< std::set >::const_iterator it=st0.begin();it!=st0.end();it++,neighIdx++){ - if ((*it).empty()) - neighIdx[1]=neighIdx[0]; - else - neighIdx[1]=neighIdx[0]+(*it).size()-1; - } + for(std::vector< std::set >::const_iterator it=st0.begin();it!=st0.end();it++,neighIdx++) + { + if ((*it).empty()) + neighIdx[1]=neighIdx[0]; + else + neighIdx[1]=neighIdx[0]+(*it).size()-1; + } } neighbors=DataArrayInt::New(); neighbors->alloc(neighborsIdx->back(),1); { diff --git a/src/MEDCoupling_Swig/MEDCouplingBasicsTest5.py b/src/MEDCoupling_Swig/MEDCouplingBasicsTest5.py index 5929051f4..8bc39b38a 100644 --- a/src/MEDCoupling_Swig/MEDCouplingBasicsTest5.py +++ b/src/MEDCoupling_Swig/MEDCouplingBasicsTest5.py @@ -4592,8 +4592,16 @@ class MEDCouplingBasicsTest5(unittest.TestCase): def testUMeshComputeEnlargedNeighborsOfNodes(self): m=MEDCouplingCMesh() ; arr=DataArrayDouble(4) ; arr.iota() ; m.setCoords(arr,arr) ; m=m.buildUnstructured() a,b=m.computeEnlargedNeighborsOfNodes() - self.assertTrue(a.isEqual(DataArrayInt([1,4,5,0,2,4,5,6,1,3,5,6,7,2,6,7,0,1,5,8,9,0,1,2,4,6,8,9,10,1,2,3,5,7,9,10,11,2,3,6,10,11,4,5,9,12,13,4,5,6,8,10,12,13,14,5,6,7,9,11,13,14,15,6,7,10,14,15,8,9,13,8,9,10,12,14,9,10,11,13,15,10,11,14]))) - self.assertTrue(b.isEqual(DataArrayInt([0,3,8,13,16,21,29,37,42,47,55,63,68,71,76,81,84]))) + aExp=DataArrayInt([1,4,5,0,2,4,5,6,1,3,5,6,7,2,6,7,0,1,5,8,9,0,1,2,4,6,8,9,10,1,2,3,5,7,9,10,11,2,3,6,10,11,4,5,9,12,13,4,5,6,8,10,12,13,14,5,6,7,9,11,13,14,15,6,7,10,14,15,8,9,13,8,9,10,12,14,9,10,11,13,15,10,11,14]) + bExp=DataArrayInt([0,3,8,13,16,21,29,37,42,47,55,63,68,71,76,81,84]) + self.assertTrue(a.isEqual(aExp)) + self.assertTrue(b.isEqual(bExp)) + m2=m[[1,2,3]] + c,d=m2.computeEnlargedNeighborsOfNodes() + cExp=DataArrayInt([2,5,6,1,3,5,6,7,2,6,7,5,8,9,1,2,4,6,8,9,1,2,3,5,7,2,3,6,4,5,9,4,5,8]) + dExp=DataArrayInt([0,0,3,8,11,14,20,25,28,31,34,34,34,34,34,34,34]) + self.assertTrue(c.isEqual(cExp)) + self.assertTrue(d.isEqual(dExp)) pass def testDAIfindIdsExt1(self):