]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
*** empty log message ***
authorageay <ageay>
Mon, 21 Mar 2011 11:47:04 +0000 (11:47 +0000)
committerageay <ageay>
Mon, 21 Mar 2011 11:47:04 +0000 (11:47 +0000)
src/MEDCoupling/Test/MEDCouplingBasicsTest.hxx
src/MEDCoupling/Test/MEDCouplingBasicsTest4.cxx
src/MEDCoupling_Swig/MEDCouplingBasicsTest.py

index 3fcba5e4342a2fa7b6854dabf7850aaf4e3e8266..7b6a18194fe6adf26b5c8725ed8f7cc8c909a33e 100644 (file)
@@ -206,6 +206,7 @@ namespace ParaMEDMEM
     CPPUNIT_TEST( testDAUnitVar1 );
     CPPUNIT_TEST( testGaussCoordinates1 );
     CPPUNIT_TEST( testP2Localization1 );
+    CPPUNIT_TEST( testP2Localization2 );
     CPPUNIT_TEST( testGetValueOn2 );
     CPPUNIT_TEST( testDAIGetIdsNotEqual1 );
     CPPUNIT_TEST( testDAIComputeOffsets1 );
@@ -442,6 +443,7 @@ namespace ParaMEDMEM
     void testGaussCoordinates1();
     void testQ1Localization1();
     void testP2Localization1();
+    void testP2Localization2();
     void testGetValueOn2();
     void testDAIGetIdsNotEqual1();
     void testDAIComputeOffsets1();
index 87d3e1b94455f7e97775e93a4a4405ed57ac9b74..abcd6a2640889fbc1a155bfa2a8fce26afb4a06f 100644 (file)
@@ -676,6 +676,40 @@ void MEDCouplingBasicsTest::testP2Localization1()
   f->decrRef();
 }
 
+void MEDCouplingBasicsTest::testP2Localization2()
+{
+  MEDCouplingUMesh *m=MEDCouplingUMesh::New("testP2_2",3);
+  const double coords[30]={0.33312787792955395, -0.35155740179580952, -0.03567564825034563, 1.307146326477638, -0.57234557776250305, -0.08608044208272235, 0.5551834466499993, 0.62324964668794192, -0.014638951108536295, 0.37761817224442129, -0.38324019806913578, 0.96283164472856886, 0.79494856035658679, -0.40628057809270046, 0.0021004190225864614, 1.023740446371799, 0.07665912970471335, -0.072889657161871096, 0.54564584619517376, 0.11132872093429744, 0.039647326652013051, 0.27164784387819052, -0.42018012100866675, 0.46563376500745146, 0.89501965094896418, -0.56148455362735061, 0.43337469695473035, 0.49118025152924394, 0.093884938060727313, 0.47216346905220891};
+  const int conn[10]={0,1,2,3,4,5,6,7,8,9};
+  DataArrayDouble *coo=DataArrayDouble::New();
+  coo->alloc(10,3);
+  std::copy(coords,coords+30,coo->getPointer());
+  m->setCoords(coo);
+  coo->decrRef();
+  m->allocateCells(1);
+  m->insertNextCell(INTERP_KERNEL::NORM_TETRA10,10,conn);
+  m->finishInsertingCells();
+  //
+  MEDCouplingFieldDouble *f=MEDCouplingFieldDouble::New(ON_NODES,ONE_TIME);
+  f->setMesh(m);
+  DataArrayDouble *da=DataArrayDouble::New();
+  da->alloc(10,1);
+  const double vals1[10]={1.1,2.1,3.1,4.1,5.2,6.2,7.2,8.2,9.2,10.2};
+  std::copy(vals1,vals1+10,da->getPointer());
+  f->setArray(da);
+  da->decrRef();
+  //
+  const double loc[3]={0.64637931739890486, -0.16185896817550552, 0.22678966365273748};
+  DataArrayDouble *locs=f->getValueOnMulti(loc,1);
+  const double expected1[1]={10.0844021968047};
+  for(int i=0;i<1;i++)
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],locs->getIJ(0,i),1e-12);
+  locs->decrRef();
+  //
+  m->decrRef();
+  f->decrRef();
+}
+
 void MEDCouplingBasicsTest::testGetValueOn2()
 {
   MEDCouplingUMesh *m=build2DTargetMesh_1();
index 0ec5268ac5bc34c374772e0db69bf4a855bf7f68..00773dc2d4fa8d726be15c379bcbb9620b8ab501 100644 (file)
@@ -6507,6 +6507,32 @@ class MEDCouplingBasicsTest(unittest.TestCase):
             pass
         pass
 
+    def testP2Localization2(self):
+        m=MEDCouplingUMesh.New("testP2_2",3);
+        coords=[0.33312787792955395, -0.35155740179580952, -0.03567564825034563, 1.307146326477638, -0.57234557776250305, -0.08608044208272235, 0.5551834466499993, 0.62324964668794192, -0.014638951108536295, 0.37761817224442129, -0.38324019806913578, 0.96283164472856886, 0.79494856035658679, -0.40628057809270046, 0.0021004190225864614, 1.023740446371799, 0.07665912970471335, -0.072889657161871096, 0.54564584619517376, 0.11132872093429744, 0.039647326652013051, 0.27164784387819052, -0.42018012100866675, 0.46563376500745146, 0.89501965094896418, -0.56148455362735061, 0.43337469695473035, 0.49118025152924394, 0.093884938060727313, 0.47216346905220891]
+        conn=[0,1,2,3,4,5,6,7,8,9]
+        coo=DataArrayDouble.New();
+        coo.setValues(coords,10,3);
+        m.setCoords(coo);
+        m.allocateCells(1);
+        m.insertNextCell(NORM_TETRA10,10,conn[0:10])
+        m.finishInsertingCells();
+        #
+        f=MEDCouplingFieldDouble.New(ON_NODES,ONE_TIME);
+        f.setMesh(m);
+        da=DataArrayDouble.New();
+        vals1=[1.1,2.1,3.1,4.1,5.2,6.2,7.2,8.2,9.2,10.2]
+        da.setValues(vals1,10,1);
+        f.setArray(da);
+        #
+        loc=[0.64637931739890486, -0.16185896817550552, 0.22678966365273748]
+        locs=f.getValueOnMulti(loc);
+        expected1=[10.0844021968047]
+        for i in xrange(1):
+            self.assertAlmostEqual(expected1[i],locs.getIJ(0,i),12);
+            pass
+        pass
+
     def testGetValueOn2(self):
         m=MEDCouplingDataForTest.build2DTargetMesh_1();
         f=MEDCouplingFieldDouble.New(ON_CELLS,NO_TIME);