]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
Stronger tests
authorAnthony Geay <anthony.geay@edf.fr>
Thu, 2 Feb 2017 07:11:12 +0000 (08:11 +0100)
committerAnthony Geay <anthony.geay@edf.fr>
Thu, 2 Feb 2017 07:11:12 +0000 (08:11 +0100)
src/MEDCoupling/MEDCouplingVoronoi.cxx
src/MEDCoupling_Swig/MEDCouplingBasicsTest5.py

index 646cde82b36b2e62d5f3c6a7aec2c4da23eaa512..be334825bc8d018e3e7f91abe157fb7123bd42bb 100644 (file)
@@ -308,6 +308,10 @@ MCAuto<MEDCouplingUMesh> MEDCoupling::Voronizer2D::doIt(const MEDCouplingUMesh *
     }
   std::vector< const MEDCouplingUMesh * > l0Bis(VecAutoToVecOfCstPt(l0));
   MCAuto<MEDCouplingUMesh> ret(MEDCouplingUMesh::MergeUMeshes(l0Bis));
+  {
+    bool dummy; int dummy2;
+    MCAuto<DataArrayInt> dummy3(ret->mergeNodes(eps,dummy,dummy2));
+  }
   return ret;
 }
 
@@ -321,10 +325,9 @@ MCAuto<MEDCouplingUMesh> Split3DCellInParts(const MEDCouplingUMesh *m, const dou
   return res;
 }
 
-#include <sstream>
-
 MCAuto<MEDCouplingUMesh> 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<MEDCouplingUMesh> 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<std::map<int,double> > matrix;
@@ -424,5 +427,9 @@ MCAuto<MEDCouplingUMesh> MEDCoupling::Voronizer3D::doIt(const MEDCouplingUMesh *
     }
   std::vector< const MEDCouplingUMesh * > l0Bis(VecAutoToVecOfCstPt(l0));
   MCAuto<MEDCouplingUMesh> ret(MEDCouplingUMesh::MergeUMeshes(l0Bis));
+  {
+    bool dummy; int dummy2;
+    MCAuto<DataArrayInt> dummy3(ret->mergeNodes(eps,dummy,dummy2));
+  }
   return ret;
 }
index 550f07925a2853aeefd4eead920a0c6514c6c9a0..3f5bdda999ea698b7f75adcb5ef1b61beafb343b 100644 (file)
@@ -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