]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
Bug correction in unPolyze on PENTA6.
authorageay <ageay>
Thu, 12 Jul 2012 13:54:39 +0000 (13:54 +0000)
committerageay <ageay>
Thu, 12 Jul 2012 13:54:39 +0000 (13:54 +0000)
src/INTERP_KERNEL/InterpKernelCellSimplify.cxx
src/MEDCoupling/Test/MEDCouplingBasicsTest5.cxx
src/MEDCoupling/Test/MEDCouplingBasicsTest5.hxx
src/MEDCoupling_Swig/MEDCouplingBasicsTest.py

index 4daceef0f67acd33a1659e61b12c1993446a3650..1200fcf85185e9d7e649e7841b51167b3b50ad83 100644 (file)
@@ -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;
index 8ffec84e1756b308948fa3a427936bd89d024b89..afb99cb372d545f5b7e67dabcd3faae987b458da 100644 (file)
@@ -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<INTERP_KERNEL::NormalizedCellType> 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();
+}
index babcbe5d4f9d55eb19ace884d946d636a6fa7df5..966a44ccb1b4970490ae54a929d90ea82653807f 100644 (file)
@@ -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();
   };
 }
 
index 79f5adb37ee2b13c33aa0ff5507af62132872ca5..71a832c1ef37ab14ccd6a5ce46fd92ab5b7911da 100644 (file)
@@ -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