From: ageay Date: Mon, 21 Mar 2011 11:47:04 +0000 (+0000) Subject: *** empty log message *** X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=fd0cd5e9dc9c2e2a73b55508c74b417392b92c85;p=tools%2Fmedcoupling.git *** empty log message *** --- diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTest.hxx b/src/MEDCoupling/Test/MEDCouplingBasicsTest.hxx index 3fcba5e43..7b6a18194 100644 --- a/src/MEDCoupling/Test/MEDCouplingBasicsTest.hxx +++ b/src/MEDCoupling/Test/MEDCouplingBasicsTest.hxx @@ -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(); diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTest4.cxx b/src/MEDCoupling/Test/MEDCouplingBasicsTest4.cxx index 87d3e1b94..abcd6a264 100644 --- a/src/MEDCoupling/Test/MEDCouplingBasicsTest4.cxx +++ b/src/MEDCoupling/Test/MEDCouplingBasicsTest4.cxx @@ -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(); diff --git a/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py b/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py index 0ec5268ac..00773dc2d 100644 --- a/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py +++ b/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py @@ -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);