]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
imp umesh with mdim=1 getValueOnMulti
authorageay <ageay>
Mon, 16 Apr 2012 13:26:09 +0000 (13:26 +0000)
committerageay <ageay>
Mon, 16 Apr 2012 13:26:09 +0000 (13:26 +0000)
src/MEDCoupling/Test/MEDCouplingBasicsTest5.cxx
src/MEDCoupling/Test/MEDCouplingBasicsTest5.hxx

index a018ea2d6df8ea0cc9f576a26411fac948d9f9c6..9c92eebb3327e6928d9abb93fd6818261ef80a04 100644 (file)
@@ -590,3 +590,39 @@ void MEDCouplingBasicsTest5::testDataArrayAbs1()
   d2->decrRef();
   d1->decrRef();
 }
+
+void MEDCouplingBasicsTest5::testGetValueOn3()
+{
+  const double v[4]={0.,1.,1.5,2.};
+  const double v2[5]={0.7,1.25,0.,2.,1.5};
+  const double disp[12]={5.,50.,500.,6.,60.,600.,7.,70.,700.,8.,80.,800.};
+  MEDCouplingUMesh *m=MEDCouplingUMesh::New("myMesh",1);
+  const int nbNodes=4;
+  const int nbCells=nbNodes-1;
+  m->allocateCells(nbCells);
+  DataArrayDouble *coords=DataArrayDouble::New();
+  coords->alloc(nbNodes,1);
+  std::copy(v,v+nbNodes,coords->getPointer());
+  m->setCoords(coords);
+  coords->decrRef();
+  const int conn[6]={0,1,2,1,2,3};
+  m->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn);
+  m->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn+2);
+  m->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn+4);
+  m->finishInsertingCells();
+  MEDCouplingFieldDouble *f=MEDCouplingFieldDouble::New(ON_NODES);
+  f->setMesh(m);
+  DataArrayDouble *array=DataArrayDouble::New();
+  array->alloc(m->getNumberOfNodes(),3);
+  std::copy(disp,disp+12,array->getPointer());
+  f->setArray(array);
+  array->decrRef();
+  DataArrayDouble *arr1=f->getValueOnMulti(v2,5);
+  CPPUNIT_ASSERT_EQUAL(5,arr1->getNumberOfTuples());
+  CPPUNIT_ASSERT_EQUAL(3,arr1->getNumberOfComponents());
+  const double expected1[15]={5.7,57.,570.,6.5,65.,650.,5.,50.,500.,8.,80.,800.,7.,70.,700.};
+  for(int i=0;i<15;i++)
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],arr1->getIJ(0,i),1e-14);
+  f->decrRef();
+  m->decrRef();
+}
index 46aa74d8416ab0bb17e03714c53d782cb69645d1..28b5e49189aa93a24b434c3087cf48b571294c5d 100644 (file)
@@ -57,6 +57,7 @@ namespace ParaMEDMEM
     void testBuildDescendingConnec2Of3DMesh1();
     void testAre2DCellsNotCorrectlyOriented1();
     void testDataArrayAbs1();
+    void testGetValueOn3();
   };
 }