From 70074ec092502051c6338f02e8b1677277883e10 Mon Sep 17 00:00:00 2001 From: ageay Date: Tue, 30 Jul 2013 10:11:02 +0000 Subject: [PATCH] MEDReader -> debugging session --- src/MEDCoupling/MEDCouplingStructuredMesh.cxx | 8 ++++---- src/MEDCoupling_Swig/MEDCouplingBasicsTest.py | 20 ++++++++++++++++--- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/MEDCoupling/MEDCouplingStructuredMesh.cxx b/src/MEDCoupling/MEDCouplingStructuredMesh.cxx index 2e10e3001..2c92df241 100644 --- a/src/MEDCoupling/MEDCouplingStructuredMesh.cxx +++ b/src/MEDCoupling/MEDCouplingStructuredMesh.cxx @@ -151,13 +151,13 @@ void MEDCouplingStructuredMesh::getNodeIdsOfCell(int cellId, std::vector& c conn.push_back(tmp2[0]); conn.push_back(tmp2[0]+1); break; case 2: - conn.push_back(tmp2[1]*tmpCell[1]+tmp2[0]); conn.push_back(tmp2[1]*tmpCell[1]+tmp2[0]+1); - conn.push_back((tmp2[1]+1)*(tmpCell[1]+1)+tmp2[0]+1); conn.push_back((tmp2[1]+1)*(tmpCell[1]+1)+tmp2[0]); + conn.push_back(tmp2[1]*tmpNode[1]+tmp2[0]); conn.push_back(tmp2[1]*tmpNode[1]+tmp2[0]+1); + conn.push_back((tmp2[1]+1)*tmpNode[1]+tmp2[0]+1); conn.push_back((tmp2[1]+1)*tmpNode[1]+tmp2[0]); break; case 3: - conn.push_back(tmp2[1]*tmpCell[1]+tmp2[0]+tmp2[2]*tmpNode[2]); conn.push_back(tmp2[1]*tmpCell[1]+tmp2[0]+1+tmp2[2]*tmpNode[2]); + conn.push_back(tmp2[1]*tmpNode[1]+tmp2[0]+tmp2[2]*tmpNode[2]); conn.push_back(tmp2[1]*tmpNode[1]+tmp2[0]+1+tmp2[2]*tmpNode[2]); conn.push_back((tmp2[1]+1)*tmpNode[1]+tmp2[0]+1+tmp2[2]*tmpNode[2]); conn.push_back((tmp2[1]+1)*tmpNode[1]+tmp2[0]+tmp2[2]*tmpNode[2]); - conn.push_back(tmp2[1]*tmpCell[1]+tmp2[0]+(tmp2[2]+1)*tmpNode[2]); conn.push_back(tmp2[1]*tmpCell[1]+tmp2[0]+1+(tmp2[2]+1)*tmpNode[2]); + conn.push_back(tmp2[1]*tmpNode[1]+tmp2[0]+(tmp2[2]+1)*tmpNode[2]); conn.push_back(tmp2[1]*tmpNode[1]+tmp2[0]+1+(tmp2[2]+1)*tmpNode[2]); conn.push_back((tmp2[1]+1)*tmpNode[1]+tmp2[0]+1+(tmp2[2]+1)*tmpNode[2]); conn.push_back((tmp2[1]+1)*tmpNode[1]+tmp2[0]+(tmp2[2]+1)*tmpNode[2]); break; default: diff --git a/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py b/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py index 0a171a772..0df84a8f3 100644 --- a/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py +++ b/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py @@ -8907,13 +8907,16 @@ class MEDCouplingBasicsTest(unittest.TestCase): # test in 2D m1c.setCoordsAt(1,coordsY); self.assertEqual(12,m1c.getNumberOfCells()) - expected2=[[0,1,6,5],[1,2,7,6],[2,3,8,7],[3,4,9,8],[4,5,11,10],[5,6,12,11],[6,7,13,12],[7,8,14,13],[8,9,16,15],[9,10,17,16],[10,11,18,17],[11,12,19,18]] + self.assertEqual(20,m1c.getNumberOfNodes()) + expected2=[[0,1,6,5],[1,2,7,6],[2,3,8,7],[3,4,9,8],[5,6,11,10],[6,7,12,11],[7,8,13,12],[8,9,14,13],[10,11,16,15],[11,12,17,16],[12,13,18,17],[13,14,19,18]] for i in xrange(m1c.getNumberOfCells()): self.assertEqual(expected2[i],m1c.getNodeIdsOfCell(i)) pass # test in 3D m1c.setCoordsAt(2,coordsZ); - expected3=[[0,1,6,5,20,21,26,25],[1,2,7,6,21,22,27,26],[2,3,8,7,22,23,28,27],[3,4,9,8,23,24,29,28],[4,5,11,10,24,25,31,30],[5,6,12,11,25,26,32,31],[6,7,13,12,26,27,33,32],[7,8,14,13,27,28,34,33],[8,9,16,15,28,29,36,35],[9,10,17,16,29,30,37,36],[10,11,18,17,30,31,38,37],[11,12,19,18,31,32,39,38],[20,21,26,25,40,41,46,45],[21,22,27,26,41,42,47,46],[22,23,28,27,42,43,48,47],[23,24,29,28,43,44,49,48],[24,25,31,30,44,45,51,50],[25,26,32,31,45,46,52,51],[26,27,33,32,46,47,53,52],[27,28,34,33,47,48,54,53],[28,29,36,35,48,49,56,55],[29,30,37,36,49,50,57,56],[30,31,38,37,50,51,58,57],[31,32,39,38,51,52,59,58]] + self.assertEqual(24,m1c.getNumberOfCells()) + self.assertEqual(60,m1c.getNumberOfNodes()) + expected3=[[0,1,6,5,20,21,26,25],[1,2,7,6,21,22,27,26],[2,3,8,7,22,23,28,27],[3,4,9,8,23,24,29,28],[5,6,11,10,25,26,31,30],[6,7,12,11,26,27,32,31],[7,8,13,12,27,28,33,32],[8,9,14,13,28,29,34,33],[10,11,16,15,30,31,36,35],[11,12,17,16,31,32,37,36],[12,13,18,17,32,33,38,37],[13,14,19,18,33,34,39,38],[20,21,26,25,40,41,46,45],[21,22,27,26,41,42,47,46],[22,23,28,27,42,43,48,47],[23,24,29,28,43,44,49,48],[25,26,31,30,45,46,51,50],[26,27,32,31,46,47,52,51],[27,28,33,32,47,48,53,52],[28,29,34,33,48,49,54,53],[30,31,36,35,50,51,56,55],[31,32,37,36,51,52,57,56],[32,33,38,37,52,53,58,57],[33,34,39,38,53,54,59,58]] self.assertEqual(24,m1c.getNumberOfCells()) for i in xrange(m1c.getNumberOfCells()): self.assertEqual(expected3[i],m1c.getNodeIdsOfCell(i)) @@ -13483,7 +13486,18 @@ class MEDCouplingBasicsTest(unittest.TestCase): self.assertRaises(InterpKernelException,DataArrayInt.FindPermutationFromFirstToSecond,DataArrayInt([3,1,103]),DataArrayInt([1,103,1])) self.assertTrue(DataArrayInt.FindPermutationFromFirstToSecond(DataArrayInt([]),DataArrayInt([])).empty()) pass - + + def testSwig2BugStructuredMeshGetNodeIdsOfCell1(self): + m=MEDCouplingCMesh("mesh") + coordsX=DataArrayDouble([0,1.1,2.2,3.3,4.4]) ; coordsX.setInfoOnComponents(["XX [m]"]) + coordsY=DataArrayDouble([0,1.7,3.4]) ; coordsY.setInfoOnComponents(["YYY [km]"]) + m.setCoords(coordsX,coordsY) + self.assertEqual([2,3,8,7],m.getNodeIdsOfCell(2)) + self.assertEqual([3,4,9,8],m.getNodeIdsOfCell(3)) + self.assertEqual([7,8,13,12],m.getNodeIdsOfCell(6)) + self.assertEqual([8,9,14,13],m.getNodeIdsOfCell(7)) + pass + def setUp(self): pass pass -- 2.39.2