From: ageay Date: Thu, 18 Feb 2010 07:26:54 +0000 (+0000) Subject: Some tests to validate -1D management by Remapper. X-Git-Tag: V5_1_main_FINAL~205 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=1c1246dc9f90e31defa6ebd4676020213ddbd2a9;p=tools%2Fmedcoupling.git Some tests to validate -1D management by Remapper. --- diff --git a/src/MEDCoupling/Test/MEDCouplingRemapperTest.cxx b/src/MEDCoupling/Test/MEDCouplingRemapperTest.cxx index ae907888d..8abb9d487 100644 --- a/src/MEDCoupling/Test/MEDCouplingRemapperTest.cxx +++ b/src/MEDCoupling/Test/MEDCouplingRemapperTest.cxx @@ -383,6 +383,45 @@ void MEDCouplingRemapperTest::testMultiDimCombi() srcField->decrRef(); sourceMesh->decrRef(); targetMesh->decrRef(); + // ------------- 2D -> -1D + sourceMesh=build2DTargetMesh_1(); + targetMesh=MEDCouplingUMesh::New("an example of -1 D mesh",-1); + srcField=MEDCouplingFieldDouble::New(ON_CELLS); + srcField->setNature(ConservativeVolumic); + srcField->setMesh(sourceMesh); + array=DataArrayDouble::New(); + array->alloc(sourceMesh->getNumberOfCells(),1); + srcField->setArray(array); + ptr=array->getPointer(); + for(int i=0;igetNumberOfCells();i++) + ptr[i]=(double)(i+7); + array->decrRef(); + CPPUNIT_ASSERT_EQUAL(1,remapper.prepare(sourceMesh,targetMesh,"P0P0")); + trgfield=remapper.transferField(srcField,4.57); + values=trgfield->getArray()->getConstPointer(); + CPPUNIT_ASSERT_EQUAL(1,trgfield->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(1,trgfield->getNumberOfComponents()); + CPPUNIT_ASSERT_DOUBLES_EQUAL(9.125,values[0],1e-14); + srcField->decrRef(); + srcField=remapper.reverseTransferField(trgfield,4.220173); + CPPUNIT_ASSERT_EQUAL(5,srcField->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(1,srcField->getNumberOfComponents()); + values=srcField->getArray()->getConstPointer(); + for(int i0=0;i0<5;i0++) + CPPUNIT_ASSERT_DOUBLES_EQUAL(9.125,values[i0],1e-14); + srcField->decrRef(); + trgfield->setNature(Integral); + srcField=remapper.reverseTransferField(trgfield,4.220173); + CPPUNIT_ASSERT_EQUAL(5,srcField->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(1,srcField->getNumberOfComponents()); + values=srcField->getArray()->getConstPointer(); + const double valuesExpected6[5]={2.28125,1.140625,1.140625,2.28125,2.28125}; + for(int i0=0;i0<5;i0++) + CPPUNIT_ASSERT_DOUBLES_EQUAL(valuesExpected6[i0],values[i0],1e-14); + srcField->decrRef(); + trgfield->decrRef(); + sourceMesh->decrRef(); + targetMesh->decrRef(); } void MEDCouplingRemapperTest::testNatureOfField()