From: Anthony Geay Date: Thu, 2 Feb 2017 07:11:12 +0000 (+0100) Subject: Stronger tests X-Git-Tag: V8_3_0a2~27 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=456380051b8db9e48ccda9abe8b46895a4300237;p=tools%2Fmedcoupling.git Stronger tests --- diff --git a/src/MEDCoupling/MEDCouplingVoronoi.cxx b/src/MEDCoupling/MEDCouplingVoronoi.cxx index 646cde82b..be334825b 100644 --- a/src/MEDCoupling/MEDCouplingVoronoi.cxx +++ b/src/MEDCoupling/MEDCouplingVoronoi.cxx @@ -308,6 +308,10 @@ MCAuto MEDCoupling::Voronizer2D::doIt(const MEDCouplingUMesh * } std::vector< const MEDCouplingUMesh * > l0Bis(VecAutoToVecOfCstPt(l0)); MCAuto ret(MEDCouplingUMesh::MergeUMeshes(l0Bis)); + { + bool dummy; int dummy2; + MCAuto dummy3(ret->mergeNodes(eps,dummy,dummy2)); + } return ret; } @@ -321,10 +325,9 @@ MCAuto Split3DCellInParts(const MEDCouplingUMesh *m, const dou return res; } -#include - MCAuto MEDCoupling::Voronizer3D::doIt(const MEDCouplingUMesh *m, const DataArrayDouble *points, double eps) const { + double eps2(1.-sqrt(eps));// 2nd eps for interpolation. Here the eps is computed to feet cos(eps) ~ 1-eps^2 if(!m || !points) throw INTERP_KERNEL::Exception("Voronoize3D : null pointer !"); m->checkConsistencyLight(); @@ -395,7 +398,7 @@ MCAuto MEDCoupling::Voronizer3D::doIt(const MEDCouplingUMesh * MEDCouplingNormalizedUnstructuredMesh<3,2> source_mesh_wrapper(facesOfCurSplitPol); MEDCouplingNormalizedUnstructuredMesh<3,2> target_mesh_wrapper(faces3); INTERP_KERNEL::Interpolation3DSurf interpolation; - interpolation.setMinDotBtwPlane3DSurfIntersect(1.*10000.*eps); + interpolation.setMinDotBtwPlane3DSurfIntersect(eps2); interpolation.setMaxDistance3DSurfIntersect(eps); interpolation.setPrecision(1e-12); std::vector > matrix; @@ -424,5 +427,9 @@ MCAuto MEDCoupling::Voronizer3D::doIt(const MEDCouplingUMesh * } std::vector< const MEDCouplingUMesh * > l0Bis(VecAutoToVecOfCstPt(l0)); MCAuto ret(MEDCouplingUMesh::MergeUMeshes(l0Bis)); + { + bool dummy; int dummy2; + MCAuto dummy3(ret->mergeNodes(eps,dummy,dummy2)); + } return ret; } diff --git a/src/MEDCoupling_Swig/MEDCouplingBasicsTest5.py b/src/MEDCoupling_Swig/MEDCouplingBasicsTest5.py index 550f07925..3f5bdda99 100644 --- a/src/MEDCoupling_Swig/MEDCouplingBasicsTest5.py +++ b/src/MEDCoupling_Swig/MEDCouplingBasicsTest5.py @@ -4596,6 +4596,8 @@ class MEDCouplingBasicsTest5(unittest.TestCase): #### fieldOnCell=field.voronoize(1e-12) # hot point fieldOnCell.checkConsistencyLight() + self.assertEqual(fieldOnCell.getMesh().getNumberOfCells(),112) + self.assertEqual(fieldOnCell.getMesh().getNumberOfNodes(),256) self.assertTrue(fieldOnCell.getArray().isEqual(field.getArray(),1e-12)) meaRef=field.getMesh().getMeasureField(True).getArray() mea=fieldOnCell.getMesh().getMeasureField(True).getArray() @@ -4606,6 +4608,38 @@ class MEDCouplingBasicsTest5(unittest.TestCase): self.assertTrue(mea2.isEqual(meaRef,1e-12)) pass + def testVoronoi2D_2(self): + """More aggressive 2D test. No warping here. To check data""" + tmp=MEDCouplingCMesh("mesh") + arr=DataArrayDouble([-1.,1.]) + tmp.setCoords(arr,arr) + tmp=tmp.buildUnstructured() + field=MEDCouplingFieldDouble(ON_GAUSS_PT) + field.setName("MyFieldPG") ; field.setMesh(tmp) + field.setGaussLocalizationOnType(NORM_QUAD4,[-1.,-1.,1.,-1.,1.,1.,-1.,1.],[0.8,-0.8, 0.8,0.8, -0.8,0.8, -0.8,-0.8, 0.,0., 0.2,0.2, 0.1,0.3],[0.1,0.1,0.1,0.1,0.1,0.1,0.4]) + arr=DataArrayDouble(field.getNumberOfTuplesExpected()) ; arr.iota() + field.setArray(arr) + field.checkConsistencyLight() + # + fieldOnCell=field.voronoize(1e-12) # hot point + fieldOnCell.checkConsistencyLight() + self.assertEqual(fieldOnCell.getMesh().getNumberOfCells(),7) + self.assertEqual(fieldOnCell.getMesh().getNumberOfNodes(),16) + self.assertTrue(fieldOnCell.getArray().isEqual(field.getArray(),1e-12)) + meaRef=DataArrayDouble([0.65,0.4710714285714285,0.59875,0.68,0.73875,0.4,0.46142857142857235]) + mea=fieldOnCell.getMesh().getMeasureField(True).getArray() + self.assertTrue(mea.isEqual(meaRef,1e-12))# the first important test is here + self.assertEqual(field.getDiscretization().getNbOfGaussLocalization(),1) + self.assertEqual(field.getDiscretization().getGaussLocalization(0).getNumberOfGaussPt(),7) + # + gsPt=field.getLocalizationOfDiscr() + a,b=fieldOnCell.getMesh().getCellsContainingPoints(gsPt,1e-12) + self.assertTrue(a.isIota(7))# the second important test is here ! Check that Gauss points are inside the associated cell in fieldOnCell ! + self.assertTrue(b.isIota(8)) + # + self.assertEqual(fieldOnCell.getMesh().buildDescendingConnectivity()[0].getNumberOfCells(),22)# last little test to reduce chance of errors. For humans there 21 but last tiny edge is split into 2 subedges due to alg + pass + def testVoronoi3D_1(self): """ Check of voronize on 3D mesh method of MEDCouplingFieldDouble that converts field on Gauss Points to a field on cell""" tmp=MEDCouplingCMesh("mesh") @@ -4654,6 +4688,38 @@ class MEDCouplingBasicsTest5(unittest.TestCase): delta/=meaRef self.assertEqual(len(delta.findIdsNotInRange(0,1e-2)),0) # 1e-2 because hexa8 are warped ! pass + + def testVoronoi3D_2(self): + """More aggressive 3D test. No warping here. To check data""" + tmp=MEDCouplingCMesh("mesh") + arr=DataArrayDouble([-1.,1.]) + tmp.setCoords(arr,arr,arr) + tmp=tmp.buildUnstructured() + field=MEDCouplingFieldDouble(ON_GAUSS_PT) + field.setName("MyFieldPG") ; field.setMesh(tmp) + field.setGaussLocalizationOnType(NORM_HEXA8,[-1,-1,-1, 1,-1,-1, 1,1,-1, -1,1,-1, -1,-1,1, 1,-1,1, 1,1,1, -1,1,1],[0.8,-0.8,0., 0.8,0.8,0., -0.8,0.8,0., -0.8,-0.8,0., 0.,0.,0., 0.2,0.2,0., 0.1,0.3,0.],[0.1,0.1,0.1,0.1,0.1,0.1,0.4]) + arr=DataArrayDouble(field.getNumberOfTuplesExpected()) ; arr.iota() + field.setArray(arr) + field.checkConsistencyLight() + # + fieldOnCell=field.voronoize(1e-12) # hot point + fieldOnCell.checkConsistencyLight() + self.assertEqual(fieldOnCell.getMesh().getNumberOfCells(),7) + self.assertEqual(fieldOnCell.getMesh().getNumberOfNodes(),32) + self.assertTrue(fieldOnCell.getArray().isEqual(field.getArray(),1e-12)) + meaRef=DataArrayDouble([1.3,1.0,1.1975,1.36,1.4775,0.8,0.865]) + mea=fieldOnCell.getMesh().getMeasureField(True).getArray() + self.assertTrue(mea.isEqual(meaRef,1e-12))# the first important test is here + self.assertEqual(field.getDiscretization().getNbOfGaussLocalization(),1) + self.assertEqual(field.getDiscretization().getGaussLocalization(0).getNumberOfGaussPt(),7) + # + gsPt=field.getLocalizationOfDiscr() + a,b=fieldOnCell.getMesh().getCellsContainingPoints(gsPt,1e-12) + self.assertTrue(a.isIota(7))# the second important test is here ! Check that Gauss points are inside the associated cell in fieldOnCell ! + self.assertTrue(b.isIota(8)) + # + self.assertEqual(fieldOnCell.getMesh().buildDescendingConnectivity()[0].getNumberOfCells(),2*7+22)# last little test to reduce chance of errors. For humans there 21 but last tiny edge is split into 2 subedges due to alg + pass pass