From c1bb015afdafd68c756337db3f06be699a6329a3 Mon Sep 17 00:00:00 2001 From: ageay Date: Thu, 12 Jul 2012 13:54:39 +0000 Subject: [PATCH] Bug correction in unPolyze on PENTA6. --- .../InterpKernelCellSimplify.cxx | 2 +- .../Test/MEDCouplingBasicsTest5.cxx | 40 +++++++++++++++++++ .../Test/MEDCouplingBasicsTest5.hxx | 2 + src/MEDCoupling_Swig/MEDCouplingBasicsTest.py | 26 ++++++++++++ 4 files changed, 69 insertions(+), 1 deletion(-) diff --git a/src/INTERP_KERNEL/InterpKernelCellSimplify.cxx b/src/INTERP_KERNEL/InterpKernelCellSimplify.cxx index 4daceef0f..1200fcf85 100644 --- a/src/INTERP_KERNEL/InterpKernelCellSimplify.cxx +++ b/src/INTERP_KERNEL/InterpKernelCellSimplify.cxx @@ -397,7 +397,7 @@ INTERP_KERNEL::NormalizedCellType CellSimplify::tryToUnPolyPenta6(const int *con int tmp2[3]; if(tryToArrangeOppositeFace(conn,lgth,3,tri_0,tri_1,5,tmp2)) { - std::copy(conn,conn+4,retConn); + std::copy(tri_0,tri_0+3,retConn); std::copy(tmp2,tmp2+3,retConn+3); retLgth=6; return INTERP_KERNEL::NORM_PENTA6; diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTest5.cxx b/src/MEDCoupling/Test/MEDCouplingBasicsTest5.cxx index 8ffec84e1..afb99cb37 100644 --- a/src/MEDCoupling/Test/MEDCouplingBasicsTest5.cxx +++ b/src/MEDCoupling/Test/MEDCouplingBasicsTest5.cxx @@ -1451,3 +1451,43 @@ s.clear(); s.insert(INTERP_KERNEL::NORM_TRI3); s.insert(INTERP_KERNEL::NORM_QUAD part->decrRef(); m->decrRef(); } + +void MEDCouplingBasicsTest5::testUnPolyze3() +{ + const double coord[18]={0.0,0.5,-0.5,-0.5,-0.5,-0.5,0.5,-0.5,-0.5,0.0,0.5,0.5,-0.5,-0.5,0.5,0.5,-0.5,0.5}; + const int conn[22]={1,2,5,4,-1,4,3,0,1,-1,2,0,3,5,-1,0,2,1,-1,4,5,3}; + MEDCouplingUMesh *m=MEDCouplingUMesh::New("a mesh",3); + m->allocateCells(1); + m->insertNextCell(INTERP_KERNEL::NORM_POLYHED,22,conn); + m->finishInsertingCells(); + DataArrayDouble *coords=DataArrayDouble::New(); + coords->alloc(6,3); + std::copy(coord,coord+18,coords->getPointer()); + m->setCoords(coords); + coords->decrRef(); + m->checkCoherency(); + // + MEDCouplingFieldDouble *vol=m->getMeasureField(ON_CELLS); + CPPUNIT_ASSERT_EQUAL(1,vol->getArray()->getNumberOfTuples()); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,vol->getArray()->getIJ(0,0),1e-12); + vol->decrRef(); + // + m->unPolyze(); + CPPUNIT_ASSERT_EQUAL(1,m->getNumberOfCells()); + std::set s; s.insert(INTERP_KERNEL::NORM_PENTA6); + CPPUNIT_ASSERT(s==m->getAllTypes()); + // + const int expected1[2]={0,7}; + const int expected2[7]={16,0,2,1,3,5,4}; + CPPUNIT_ASSERT_EQUAL(2,m->getNodalConnectivityIndex()->getNumberOfTuples()); + CPPUNIT_ASSERT(std::equal(expected1,expected1+2,m->getNodalConnectivityIndex()->getConstPointer())); + CPPUNIT_ASSERT_EQUAL(7,m->getNodalConnectivity()->getNumberOfTuples()); + CPPUNIT_ASSERT(std::equal(expected2,expected2+7,m->getNodalConnectivity()->getConstPointer())); + // + vol=m->getMeasureField(ON_CELLS); + CPPUNIT_ASSERT_EQUAL(1,vol->getArray()->getNumberOfTuples()); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,vol->getArray()->getIJ(0,0),1e-12); + vol->decrRef(); + // + m->decrRef(); +} diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTest5.hxx b/src/MEDCoupling/Test/MEDCouplingBasicsTest5.hxx index babcbe5d4..966a44ccb 100644 --- a/src/MEDCoupling/Test/MEDCouplingBasicsTest5.hxx +++ b/src/MEDCoupling/Test/MEDCouplingBasicsTest5.hxx @@ -62,6 +62,7 @@ namespace ParaMEDMEM CPPUNIT_TEST( testComputeTupleIdsToSelectFromCellIds1 ); CPPUNIT_TEST( testComputeSkin1 ); CPPUNIT_TEST( testUMeshSetPartOfMySelf2 ); + CPPUNIT_TEST( testUnPolyze3 ); CPPUNIT_TEST_SUITE_END(); public: void testUMeshTessellate2D1(); @@ -91,6 +92,7 @@ namespace ParaMEDMEM void testComputeTupleIdsToSelectFromCellIds1(); void testComputeSkin1(); void testUMeshSetPartOfMySelf2(); + void testUnPolyze3(); }; } diff --git a/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py b/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py index 79f5adb37..71a832c1e 100644 --- a/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py +++ b/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py @@ -10090,6 +10090,32 @@ class MEDCouplingBasicsTest(unittest.TestCase): self.assertEqual([3,4,5],m.getAllTypes()) pass + def testUnPolyze3(self): + coord=[0.0,0.5,-0.5,-0.5,-0.5,-0.5,0.5,-0.5,-0.5,0.0,0.5,0.5,-0.5,-0.5,0.5,0.5,-0.5,0.5] + conn=[1,2,5,4,-1,4,3,0,1,-1,2,0,3,5,-1,0,2,1,-1,4,5,3] + m=MEDCouplingUMesh.New("a mesh",3); + m.allocateCells(1); + m.insertNextCell(NORM_POLYHED,22,conn[0:22]) + m.finishInsertingCells(); + coords=DataArrayDouble(coord,6,3); + m.setCoords(coords); + m.checkCoherency(); + # + vol=m.getMeasureField(ON_CELLS); + self.assertEqual(1,vol.getArray().getNumberOfTuples()); + self.assertAlmostEqual(0.5,vol.getArray().getIJ(0,0),12) + # + m.unPolyze(); + # + self.assertEqual([NORM_PENTA6],m.getAllTypes()) + self.assertTrue(DataArrayInt([0,7]).isEqual(m.getNodalConnectivityIndex())) + self.assertTrue(DataArrayInt([16,0,2,1,3,5,4]).isEqual(m.getNodalConnectivity())) + # + vol=m.getMeasureField(ON_CELLS); + self.assertEqual(1,vol.getArray().getNumberOfTuples()); + self.assertAlmostEqual(0.5,vol.getArray().getIJ(0,0),12) + pass + def setUp(self): pass pass -- 2.39.2