From 3290a793594664041aa464ab64e340bf32200098 Mon Sep 17 00:00:00 2001 From: ageay Date: Mon, 5 Aug 2013 12:48:52 +0000 Subject: [PATCH] Improve perf of P1P0,P0P1,P1P1 --- src/MEDCoupling/MEDCouplingUMesh.cxx | 46 +++++---- src/MEDCoupling/MEDCouplingUMesh.hxx | 5 +- src/MEDCoupling_Swig/MEDCouplingBasicsTest.py | 93 +++++++++---------- 3 files changed, 67 insertions(+), 77 deletions(-) diff --git a/src/MEDCoupling/MEDCouplingUMesh.cxx b/src/MEDCoupling/MEDCouplingUMesh.cxx index 9c66c9c1b..5d690ea3f 100644 --- a/src/MEDCoupling/MEDCouplingUMesh.cxx +++ b/src/MEDCoupling/MEDCouplingUMesh.cxx @@ -5239,7 +5239,7 @@ void MEDCouplingUMesh::tessellate2DCurve(double eps) throw(INTERP_KERNEL::Except * and \a this->getMeshDimension() != 3. * \throw If \a policy is not one of the four discussed above. * \throw If the nodal connectivity of cells is not defined. - * \sa MEDCouplingUMesh::simplexize3D + * \sa MEDCouplingUMesh::tetrahedrize */ DataArrayInt *MEDCouplingUMesh::simplexize(int policy) throw(INTERP_KERNEL::Exception) { @@ -9289,33 +9289,35 @@ DataArrayInt *MEDCouplingUMesh::ComputeRangesFromTypeDistribution(const std::vec /*! * This method expects that \a this a 3D mesh (spaceDim=3 and meshDim=3) with all coordinates and connectivities set. * All cells in \a this are expected to be linear 3D cells. - * This method will split all 3D cells in \a this into INTERP_KERNEL::NORM_TETRA4 cells. It leads to an increase to number of cells. - * This method contrary to MEDCouplingUMesh::simplexize3D can append coordinates in \a this to perform its work. - * The \a nbOfAdditionalPoints returned value informs about it. If > 0, the coordinates array in \a this will be replaced by an another one - * having \a nbOfAdditionalPoints more tuples (nodes) than previously. Anyway, The nodes and their order initially present in \a this - * before the call are kept. + * This method will split **all** 3D cells in \a this into INTERP_KERNEL::NORM_TETRA4 cells and put them in the returned mesh. + * It leads to an increase to number of cells. + * This method contrary to MEDCouplingUMesh::simplexize can append coordinates in \a this to perform its work. + * The \a nbOfAdditionalPoints returned value informs about it. If > 0, the coordinates array in returned mesh will have \a nbOfAdditionalPoints + * more tuples (nodes) than in \a this. Anyway, all the nodes in \a this (with the same order) will be in the returned mesh. * * \param [in] policy - the policy of splitting that must be in (PLANAR_FACE_5, PLANAR_FACE_6, GENERAL_24, GENERAL_48). The policy will be used only for INTERP_KERNEL::NORM_HEXA8 cells. * For all other cells, the splitting policy will be ignored. * \param [out] nbOfAdditionalPoints - number of nodes added to \c this->_coords. If > 0 a new coordinates object will be constructed result of the aggregation of the old one and the new points added. - * \return DataArrayInt * - a new instance of DataArrayInt holding, for each new cell, + * \param [out] n2oCells - A new instance of DataArrayInt holding, for each new cell, * an id of old cell producing it. The caller is to delete this array using - * decrRef() as it is no more needed. + * decrRef() as it is no more needed. + * \return MEDCoupling1SGTUMesh * - the mesh containing only INTERP_KERNEL::NORM_TETRA4 cells. * * \throw If \a this is not a 3D mesh (spaceDim==3 and meshDim==3). * \throw If \a this is not fully constituted with linear 3D cells. * \sa MEDCouplingUMesh::simplexize */ -DataArrayInt *MEDCouplingUMesh::simplexize3D(int policy, int& nbOfAdditionalPoints) throw(INTERP_KERNEL::Exception) +MEDCoupling1SGTUMesh *MEDCouplingUMesh::tetrahedrize(int policy, DataArrayInt *& n2oCells, int& nbOfAdditionalPoints) const throw(INTERP_KERNEL::Exception) { INTERP_KERNEL::SplittingPolicy pol((INTERP_KERNEL::SplittingPolicy)policy); checkConnectivityFullyDefined(); if(getMeshDimension()!=3 || getSpaceDimension()!=3) - throw INTERP_KERNEL::Exception("MEDCouplingUMesh::simplexize3D : only available for mesh with meshdim == 3 and spacedim == 3 !"); + throw INTERP_KERNEL::Exception("MEDCouplingUMesh::tetrahedrize : only available for mesh with meshdim == 3 and spacedim == 3 !"); int nbOfCells(getNumberOfCells()),nbNodes(getNumberOfNodes()); + MEDCouplingAutoRefCountObjectPtr ret0(MEDCoupling1SGTUMesh::New(getName().c_str(),INTERP_KERNEL::NORM_TETRA4)); MEDCouplingAutoRefCountObjectPtr ret(DataArrayInt::New()); ret->alloc(nbOfCells,1); int *retPt(ret->getPointer()); - MEDCouplingAutoRefCountObjectPtr newConn(DataArrayInt::New()),newConnI(DataArrayInt::New()); newConn->alloc(0,1); newConnI->alloc(1,1); newConnI->setIJ(0,0,0); + MEDCouplingAutoRefCountObjectPtr newConn(DataArrayInt::New()); newConn->alloc(0,1); MEDCouplingAutoRefCountObjectPtr addPts(DataArrayDouble::New()); addPts->alloc(0,1); const int *oldc(_nodal_connec->begin()); const int *oldci(_nodal_connec_index->begin()); @@ -9335,29 +9337,25 @@ DataArrayInt *MEDCouplingUMesh::simplexize3D(int policy, int& nbOfAdditionalPoin nbNodes+=(int)b.size()/3; } for(std::size_t j=0;jback()); - int val(idx+4+1); - newConnI->pushBackSilent(val); - newConn->writeOnPlace(idx,(int)INTERP_KERNEL::NORM_TETRA4,aa,4); - } + newConn->insertAtTheEnd(aa,aa+4); } if(!addPts->empty()) { addPts->rearrange(3); nbOfAdditionalPoints=addPts->getNumberOfTuples(); addPts=DataArrayDouble::Aggregate(getCoords(),addPts); - setCoords(addPts); + ret0->setCoords(addPts); } else - nbOfAdditionalPoints=0; - setConnectivity(newConn,newConnI,false); - _types.clear(); _types.insert(INTERP_KERNEL::NORM_TETRA4); - computeTypes(); - updateTime(); + { + nbOfAdditionalPoints=0; + ret0->setCoords(getCoords()); + } + ret0->setNodalConnectivity(newConn); // ret->computeOffsets2(); - return ret->buildExplicitArrOfSliceOnScaledArr(0,nbOfCells,1); + n2oCells=ret->buildExplicitArrOfSliceOnScaledArr(0,nbOfCells,1); + return ret0.retn(); } MEDCouplingUMeshCellIterator::MEDCouplingUMeshCellIterator(MEDCouplingUMesh *mesh):_mesh(mesh),_cell(new MEDCouplingUMeshCell(mesh)), diff --git a/src/MEDCoupling/MEDCouplingUMesh.hxx b/src/MEDCoupling/MEDCouplingUMesh.hxx index baca4e362..5729dcdad 100644 --- a/src/MEDCoupling/MEDCouplingUMesh.hxx +++ b/src/MEDCoupling/MEDCouplingUMesh.hxx @@ -31,8 +31,9 @@ namespace ParaMEDMEM { - class MEDCouplingUMeshCellIterator; class MEDCouplingUMeshCellByTypeEntry; + class MEDCouplingUMeshCellIterator; + class MEDCoupling1SGTUMesh; class MEDCoupling1GTUMesh; class MEDCouplingUMesh : public MEDCouplingPointSet @@ -170,7 +171,7 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT DataArrayInt *convertLinearCellsToQuadratic(int conversionType=0) throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT void tessellate2D(double eps) throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT void tessellate2DCurve(double eps) throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT DataArrayInt *simplexize3D(int policy, int& nbOfAdditionalPoints) throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT MEDCoupling1SGTUMesh *tetrahedrize(int policy, DataArrayInt *& n2oCells, int& nbOfAdditionalPoints) const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT DataArrayInt *simplexize(int policy) throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT bool areOnlySimplexCells() const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT void convertDegeneratedCells() throw(INTERP_KERNEL::Exception); diff --git a/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py b/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py index e06404160..7ebacabdd 100644 --- a/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py +++ b/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py @@ -13589,7 +13589,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): self.assertTrue(m3.getNodalConnectivityIndex().isEqual(DataArrayInt([0,9,18,27,36,45,54,63,72,186,286,330,423]))) pass - def testSwig2Simplexize3D1(self): + def testSwig2Tetrahedrize1(self): d=DataArrayInt([0,3,6,10,14,20]) d2=d.buildExplicitArrOfSliceOnScaledArr(slice(0,5,2)) self.assertTrue(d2.isEqual(DataArrayInt([0,0,0, 2,2,2,2, 4,4,4,4,4,4]))) @@ -13598,28 +13598,26 @@ class MEDCouplingBasicsTest(unittest.TestCase): m.allocateCells() m.insertNextCell(NORM_PENTA6,[1,2,0,4,5,3]) st=m.getCoords().getHiddenCppPointer() - a,b=m.simplexize3D(PLANAR_FACE_5) - m.checkCoherency2() + c,a,b=m.tetrahedrize(PLANAR_FACE_5) + c.checkCoherency2() self.assertTrue(a.isEqual(DataArrayInt([0,0,0]))) self.assertEqual(0,b) - self.assertEqual(m.getCoords().getHiddenCppPointer(),st) - self.assertTrue(m.getNodalConnectivity().isEqual(DataArrayInt([14,1,2,0,4,14,4,3,5,0,14,5,0,2,4]))) - self.assertTrue(m.getNodalConnectivityIndex().isEqual(DataArrayInt([0,5,10,15]))) - del m + self.assertEqual(m.getCoords().getHiddenCppPointer(),c.getCoords().getHiddenCppPointer()) + self.assertTrue(c.getNodalConnectivity().isEqual(DataArrayInt([1,2,0,4,4,3,5,0,5,0,2,4]))) + del m,c # m2=MEDCouplingUMesh("octa12",3) coords=DataArrayDouble([1.,0.,0.,0.5,0.8660254037844386,0.,-0.5,0.8660254037844387,0.,-1.,1.2246467991473532e-16,0.,-0.5,-0.8660254037844384,0.,0.5,-0.866025403784439,0.,1.,0.,2.,0.5,0.8660254037844386,2.,-0.5,0.8660254037844387,2.,-1.,1.2246467991473532e-16,2.,-0.5,-0.8660254037844384,2.,0.5,-0.866025403784439,2.0],12,3) m2.setCoords(coords) m2.allocateCells() m2.insertNextCell(NORM_HEXGP12,[3,2,1,0,5,4,9,8,7,6,11,10]) - a,b=m2.simplexize3D(PLANAR_FACE_5) - m2.checkCoherency2() + c,a,b=m2.tetrahedrize(PLANAR_FACE_5) + c.checkCoherency2() self.assertTrue(a.isEqual(DataArrayInt([0,0,0,0,0,0,0,0,0,0,0,0]))) self.assertEqual(0,b) - self.assertEqual(m2.getCoords().getHiddenCppPointer(),coords.getHiddenCppPointer()) - self.assertTrue(m2.getNodalConnectivity().isEqual(DataArrayInt([14,3,2,4,9,14,9,10,8,4,14,8,4,2,9,14,2,5,4,8,14,8,10,11,4,14,11,4,5,8,14,2,1,5,8,14,8,11,7,5,14,7,5,1,8,14,1,0,5,7,14,7,11,6,5,14,6,5,0,7]))) - self.assertTrue(m2.getNodalConnectivityIndex().isEqual(DataArrayInt([0,5,10,15,20,25,30,35,40,45,50,55,60]))) - del m2,coords + self.assertEqual(c.getCoords().getHiddenCppPointer(),coords.getHiddenCppPointer()) + self.assertTrue(c.getNodalConnectivity().isEqual(DataArrayInt([3,2,4,9,9,10,8,4,8,4,2,9,2,5,4,8,8,10,11,4,11,4,5,8,2,1,5,8,8,11,7,5,7,5,1,8,1,0,5,7,7,11,6,5,6,5,0,7]))) + del m2,coords,c # coords=DataArrayDouble([0.,0.,0.,1.,0.,0.,1.,1.,0.,0.,1.,0.,0.,0.,2.,1.,0.,2.,1.,1.,2.,0.,1.,2.],8,3) ; coords.setInfoOnComponents(["X","YY","ZZZ"]) m3=MEDCouplingUMesh("hexa8",3) @@ -13627,79 +13625,73 @@ class MEDCouplingBasicsTest(unittest.TestCase): m3.allocateCells(0) m3.insertNextCell(NORM_HEXA8,[3,2,1,0,7,6,5,4]) st=m3.getCoords().getHiddenCppPointer() - a,b=m3.simplexize3D(PLANAR_FACE_5) - m3.checkCoherency2() + c,a,b=m3.tetrahedrize(PLANAR_FACE_5) + c.checkCoherency2() a.isEqual(DataArrayInt([0,0,0,0,0])) self.assertEqual(0,b) self.assertEqual(m3.getCoords().getHiddenCppPointer(),coords.getHiddenCppPointer()) - self.assertTrue(m3.getNodalConnectivity().isEqual(DataArrayInt([14,3,6,2,1,14,3,7,6,4,14,3,0,4,1,14,6,4,5,1,14,3,6,1,4]))) - self.assertTrue(m3.getNodalConnectivityIndex().isEqual(DataArrayInt([0,5,10,15,20,25]))) + self.assertTrue(c.getNodalConnectivity().isEqual(DataArrayInt([3,6,2,1,3,7,6,4,3,0,4,1,6,4,5,1,3,6,1,4]))) # m4=MEDCouplingUMesh("hexa8",3) m4.setCoords(coords) m4.allocateCells(0) m4.insertNextCell(NORM_HEXA8,[3,2,1,0,7,6,5,4]) - st=m4.getCoords().getHiddenCppPointer() - a,b=m4.simplexize3D(PLANAR_FACE_6) + c,a,b=m4.tetrahedrize(PLANAR_FACE_6) m4.checkCoherency2() a.isEqual(DataArrayInt([0,0,0,0,0,0])) self.assertEqual(0,b) - self.assertEqual(m4.getCoords().getHiddenCppPointer(),coords.getHiddenCppPointer()) - self.assertTrue(m4.getNodalConnectivity().isEqual(DataArrayInt([14,3,6,2,5,14,3,2,1,5,14,3,7,6,5,14,3,4,7,5,14,3,1,0,5,14,3,0,4,5]))) - self.assertTrue(m4.getNodalConnectivityIndex().isEqual(DataArrayInt([0,5,10,15,20,25,30]))) + self.assertEqual(c.getCoords().getHiddenCppPointer(),coords.getHiddenCppPointer()) + self.assertTrue(c.getNodalConnectivity().isEqual(DataArrayInt([3,6,2,5,3,2,1,5,3,7,6,5,3,4,7,5,3,1,0,5,3,0,4,5]))) # m4=MEDCouplingUMesh("hexa8",3) m4.setCoords(coords) m4.allocateCells(0) m4.insertNextCell(NORM_HEXA8,[3,2,1,0,7,6,5,4]) st=m4.getCoords().getHiddenCppPointer() - a,b=m4.simplexize3D(GENERAL_24) - m4.checkCoherency2() + c,a,b=m4.tetrahedrize(GENERAL_24) + c.checkCoherency2() a.isEqual(DataArrayInt([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0])) self.assertEqual(7,b) - self.assertTrue(m4.getCoords().getHiddenCppPointer()!=coords.getHiddenCppPointer()) - self.assertTrue(m4.getCoords()[:8].isEqual(coords,0)) - self.assertTrue(m4.getNodalConnectivity().isEqual(DataArrayInt([14,3,7,8,14,14,7,6,8,14,14,6,2,8,14,14,2,3,8,14,14,3,2,9,14,14,2,1,9,14,14,1,0,9,14,14,0,3,9,14,14,3,0,10,14,14,0,4,10,14,14,4,7,10,14,14,7,3,10,14,14,2,6,11,14,14,6,5,11,14,14,5,1,11,14,14,1,2,11,14,14,7,4,12,14,14,4,5,12,14,14,5,6,12,14,14,6,7,12,14,14,1,5,13,14,14,5,4,13,14,14,4,0,13,14,14,0,1,13,14]))) - self.assertTrue(m4.getNodalConnectivityIndex().isEqual(DataArrayInt([0,5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100,105,110,115,120]))) + self.assertTrue(c.getCoords().getHiddenCppPointer()!=coords.getHiddenCppPointer()) + self.assertTrue(c.getCoords()[:8].isEqual(coords,0)) + self.assertTrue(c.getNodalConnectivity().isEqual(DataArrayInt([3,7,8,14,7,6,8,14,6,2,8,14,2,3,8,14,3,2,9,14,2,1,9,14,1,0,9,14,0,3,9,14,3,0,10,14,0,4,10,14,4,7,10,14,7,3,10,14,2,6,11,14,6,5,11,14,5,1,11,14,1,2,11,14,7,4,12,14,4,5,12,14,5,6,12,14,6,7,12,14,1,5,13,14,5,4,13,14,4,0,13,14,0,1,13,14]))) m4CoordsExp=DataArrayDouble([0.,0.,0.,1.,0.,0.,1.,1.,0.,0.,1.,0.,0.,0.,2.,1.,0.,2.,1.,1.,2.,0.,1.,2.,0.5,1.,1.,0.5,0.5,0.,0.,0.5,1.,1.,0.5,1.,0.5,0.5,2.,0.5,0.,1.,0.5,0.5,1.],15,3) m4CoordsExp.setInfoOnComponents(["X","YY","ZZZ"]) - self.assertTrue(m4.getCoords().isEqual(m4CoordsExp,1e-12)) - self.assertAlmostEqual(2.,m4.getMeasureField(False).accumulate()[0],12) + self.assertTrue(c.getCoords().isEqual(m4CoordsExp,1e-12)) + self.assertAlmostEqual(2.,c.getMeasureField(False).accumulate()[0],12) # m6=MEDCouplingUMesh("hexa8",3) m6.setCoords(coords) m6.allocateCells(0) m6.insertNextCell(NORM_HEXA8,[3,2,1,0,7,6,5,4]) st=m6.getCoords().getHiddenCppPointer() - a,b=m6.simplexize3D(GENERAL_48) - m6.checkCoherency2() + c,a,b=m6.tetrahedrize(GENERAL_48) + c.checkCoherency2() a.isEqual(DataArrayInt([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0])) self.assertEqual(19,b) - self.assertTrue(m6.getCoords().getHiddenCppPointer()!=coords.getHiddenCppPointer()) - self.assertTrue(m6.getCoords()[:8].isEqual(coords,0)) - self.assertTrue(m6.getNodalConnectivity().isEqual(DataArrayInt([14,3,20,8,26,14,3,8,21,26,14,3,9,20,26,14,3,22,9,26,14,3,21,12,26,14,3,12,22,26,14,8,10,2,23,14,8,2,13,23,14,8,20,10,23,14,8,26,20,23,14,8,13,21,23,14,8,21,26,23,14,12,26,21,25,14,12,21,16,25,14,12,22,26,25,14,12,17,22,25,14,12,16,0,25,14,12,0,17,25,14,21,23,13,18,14,21,13,1,18,14,21,26,23,18,14,21,25,26,18,14,21,1,16,18,14,21,16,25,18,14,9,11,20,24,14,9,20,26,24,14,9,7,11,24,14,9,14,7,24,14,9,26,22,24,14,9,22,14,24,14,20,6,10,15,14,20,10,23,15,14,20,11,6,15,14,20,24,11,15,14,20,23,26,15,14,20,26,24,15,14,22,24,26,19,14,22,26,25,19,14,22,14,24,19,14,22,4,14,19,14,22,25,17,19,14,22,17,4,19,14,26,15,23,5,14,26,23,18,5,14,26,24,15,5,14,26,19,24,5,14,26,18,25,5,14,26,25,19,5]))) - self.assertTrue(m6.getNodalConnectivityIndex().isEqual(DataArrayInt([0,5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100,105,110,115,120,125,130,135,140,145,150,155,160,165,170,175,180,185,190,195,200,205,210,215,220,225,230,235,240]))) + self.assertTrue(c.getCoords().getHiddenCppPointer()!=coords.getHiddenCppPointer()) + self.assertTrue(c.getCoords()[:8].isEqual(coords,0)) + self.assertTrue(c.getNodalConnectivity().isEqual(DataArrayInt([3,20,8,26,3,8,21,26,3,9,20,26,3,22,9,26,3,21,12,26,3,12,22,26,8,10,2,23,8,2,13,23,8,20,10,23,8,26,20,23,8,13,21,23,8,21,26,23,12,26,21,25,12,21,16,25,12,22,26,25,12,17,22,25,12,16,0,25,12,0,17,25,21,23,13,18,21,13,1,18,21,26,23,18,21,25,26,18,21,1,16,18,21,16,25,18,9,11,20,24,9,20,26,24,9,7,11,24,9,14,7,24,9,26,22,24,9,22,14,24,20,6,10,15,20,10,23,15,20,11,6,15,20,24,11,15,20,23,26,15,20,26,24,15,22,24,26,19,22,26,25,19,22,14,24,19,22,4,14,19,22,25,17,19,22,17,4,19,26,15,23,5,26,23,18,5,26,24,15,5,26,19,24,5,26,18,25,5,26,25,19,5]))) m6CoordsExp=DataArrayDouble([0.,0.,0.,1.,0.,0.,1.,1.,0.,0.,1.,0.,0.,0.,2.,1.,0.,2.,1.,1.,2.,0.,1.,2.,0.5,1.,0.,0.,1.,1.,1.,1.,1.,0.5,1.,2.,0.,0.5,0.,1.,0.5,0.,0.,0.5,2.,1.,0.5,2.,0.5,0.,0.,0.,0.,1.,1.,0.,1.,0.5,0.,2.,0.5,1.,1.,0.5,0.5,0.,0.,0.5,1.,1.,0.5,1.,0.5,0.5,2.,0.5,0.,1.,0.5,0.5,1.],27,3) m6CoordsExp.setInfoOnComponents(["X","YY","ZZZ"]) - self.assertTrue(m6.getCoords().isEqual(m6CoordsExp,1e-12)) - self.assertAlmostEqual(2.,m6.getMeasureField(False).accumulate()[0],12) + self.assertTrue(c.getCoords().isEqual(m6CoordsExp,1e-12)) + self.assertAlmostEqual(2.,c.getMeasureField(False).accumulate()[0],12) # m7=MEDCouplingUMesh("polyhed",3) coords=DataArrayDouble([1.,0.,0.,0.5,0.8660254037844386,0.,-0.5,0.8660254037844387,0.,-1.,0.,0.,-0.5,-0.8660254037844384,0.,0.5,-0.866025403784439,0.,1.,0.,2.,0.5,0.8660254037844386,2.,-0.5,0.8660254037844387,2.,-1.,0.,2.,-0.5,-0.8660254037844384,2.,0.5,-0.866025403784439,2.0],12,3) ; coords.setInfoOnComponents(["X","YY","ZZZ"]) m7.setCoords(coords) m7.allocateCells() m7.insertNextCell(NORM_POLYHED,[3,2,1,0,5,4,-1,9,10,11,6,7,8,-1,3,9,8,2,-1,2,8,7,1,-1,1,7,6,0,-1,0,6,11,5,-1,5,11,10,4,-1,4,10,9,3]) - a,b=m7.simplexize3D(PLANAR_FACE_5) - m7.checkCoherency2() + c,a,b=m7.tetrahedrize(PLANAR_FACE_5) + c.checkCoherency2() self.assertTrue(a.isEqual(DataArrayInt([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]))) self.assertEqual(9,b) - self.assertTrue(m7.getNodalConnectivity().isEqual(DataArrayInt([14,3,2,12,20,14,2,1,12,20,14,1,0,12,20,14,0,5,12,20,14,5,4,12,20,14,4,3,12,20,14,9,10,13,20,14,10,11,13,20,14,11,6,13,20,14,6,7,13,20,14,7,8,13,20,14,8,9,13,20,14,3,9,14,20,14,9,8,14,20,14,8,2,14,20,14,2,3,14,20,14,2,8,15,20,14,8,7,15,20,14,7,1,15,20,14,1,2,15,20,14,1,7,16,20,14,7,6,16,20,14,6,0,16,20,14,0,1,16,20,14,0,6,17,20,14,6,11,17,20,14,11,5,17,20,14,5,0,17,20,14,5,11,18,20,14,11,10,18,20,14,10,4,18,20,14,4,5,18,20,14,4,10,19,20,14,10,9,19,20,14,9,3,19,20,14,3,4,19,20]))) - self.assertTrue(m7.getNodalConnectivityIndex().isEqual(DataArrayInt([0,5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100,105,110,115,120,125,130,135,140,145,150,155,160,165,170,175,180]))) - self.assertAlmostEqual(5.196152422706635,m7.getMeasureField(False).accumulate()[0],12) - m7CoordsExp=DataArrayDouble([1.0, 0.0, 0.0, 0.5, 0.8660254037844386, 0.0, -0.5, 0.8660254037844387, 0.0, -1.0, 0., 0.0, -0.5, -0.8660254037844384, 0.0, 0.5, -0.866025403784439, 0.0, 1.0, 0.0, 2.0, 0.5, 0.8660254037844386, 2.0, -0.5, 0.8660254037844387, 2.0, -1.0, 0., 2.0, -0.5, -0.8660254037844384, 2.0, 0.5, -0.866025403784439, 2.0, 0.0, 0.0, 0.0, 0.0, 0., 2.0, -0.75, 0.4330127018922194, 1.0, 0.0, 0.8660254037844386, 1.0, 0.75, 0.4330127018922193, 1.0, 0.75, -0.4330127018922195, 1.0, 0.0, -0.8660254037844387, 1.0, -0.75, -0.4330127018922191, 1.0, 0.0,0., 1.0],21,3) + self.assertTrue(c.getNodalConnectivity().isEqual(DataArrayInt([3,2,12,20,2,1,12,20,1,0,12,20,0,5,12,20,5,4,12,20,4,3,12,20,9,10,13,20,10,11,13,20,11,6,13,20,6,7,13,20,7,8,13,20,8,9,13,20,3,9,14,20,9,8,14,20,8,2,14,20,2,3,14,20,2,8,15,20,8,7,15,20,7,1,15,20,1,2,15,20,1,7,16,20,7,6,16,20,6,0,16,20,0,1,16,20,0,6,17,20,6,11,17,20,11,5,17,20,5,0,17,20,5,11,18,20,11,10,18,20,10,4,18,20,4,5,18,20,4,10,19,20,10,9,19,20,9,3,19,20,3,4,19,20]))) + self.assertAlmostEqual(5.196152422706635,c.getMeasureField(False).accumulate()[0],12) + m7CoordsExp=DataArrayDouble([1.0,0.0,0.0,0.5,0.8660254037844386,0.0,-0.5,0.8660254037844387,0.0,-1.0,0.,0.0,-0.5,-0.8660254037844384,0.0,0.5,-0.866025403784439,0.0,1.0,0.0,2.0,0.5,0.8660254037844386,2.0,-0.5,0.8660254037844387,2.0,-1.0,0.,2.0,-0.5,-0.8660254037844384,2.0,0.5,-0.866025403784439,2.0,0.0,0.0,0.0,0.0,0.,2.0,-0.75,0.4330127018922194,1.0,0.0,0.8660254037844386,1.0,0.75,0.4330127018922193,1.0,0.75,-0.4330127018922195,1.0,0.0,-0.8660254037844387,1.0,-0.75,-0.4330127018922191,1.0,0.0,0.,1.0],21,3) m7CoordsExp.setInfoOnComponents(["X","YY","ZZZ"]) - self.assertTrue(m7.getCoords().isEqual(m7CoordsExp,1e-12)) - del m7,coords + self.assertTrue(c.getCoords().isEqual(m7CoordsExp,1e-12)) + del m7,coords,c # coords=DataArrayDouble([0.,0.,0.,1.,0.,0.,1.,1.,0.,0.,1.,0.,0.,0.,2.,1.,0.,2.,1.,1.,2.,0.,1.,2.],8,3) ; coords.setInfoOnComponents(["X","YY","ZZZ"]) m8=MEDCouplingUMesh("pyra5",3) @@ -13707,14 +13699,13 @@ class MEDCouplingBasicsTest(unittest.TestCase): m8.allocateCells(0) m8.insertNextCell(NORM_PYRA5,[3,2,1,0,7]) st=m8.getCoords().getHiddenCppPointer() - a,b=m8.simplexize3D(PLANAR_FACE_5) + c,a,b=m8.tetrahedrize(PLANAR_FACE_5) self.assertEqual(m8.getCoords().getHiddenCppPointer(),coords.getHiddenCppPointer()) - m8.checkCoherency2() + c.checkCoherency2() self.assertTrue(a.isEqual(DataArrayInt([0,0]))) self.assertEqual(0,b) - self.assertTrue(m8.getNodalConnectivity().isEqual(DataArrayInt([14,3,2,1,7,14,3,1,0,7]))) - self.assertTrue(m8.getNodalConnectivityIndex().isEqual(DataArrayInt([0,5,10]))) - self.assertAlmostEqual(0.6666666666666667,m8.getMeasureField(False).accumulate()[0],12) + self.assertTrue(c.getNodalConnectivity().isEqual(DataArrayInt([3,2,1,7,3,1,0,7]))) + self.assertAlmostEqual(0.6666666666666667,c.getMeasureField(False).accumulate()[0],12) pass def setUp(self): -- 2.39.2