From: ageay Date: Thu, 12 Apr 2012 16:20:40 +0000 (+0000) Subject: partialTranfer python test. X-Git-Tag: TRIPOLI_323~69 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=a1a744cee86de68ad9965571bf758faa0f663c82;p=tools%2Fmedcoupling.git partialTranfer python test. --- diff --git a/src/MEDCoupling_Swig/MEDCouplingRemapperTest.py b/src/MEDCoupling_Swig/MEDCouplingRemapperTest.py index a1561e7b4..ba4826c69 100644 --- a/src/MEDCoupling_Swig/MEDCouplingRemapperTest.py +++ b/src/MEDCoupling_Swig/MEDCouplingRemapperTest.py @@ -80,6 +80,48 @@ class MEDCouplingBasicsTest(unittest.TestCase): self.assertAlmostEqual(valuesExpected[i0],values[i0],12); pass pass + + def testPartialTransfer1(self): + sourceMesh=self.build2DSourceMesh_1(); + targetMesh=self.build2DTargetMesh_3(); + # + remapper=MEDCouplingRemapper(); + remapper.setPrecision(1e-12); + remapper.setIntersectionType(Triangulation); + srcFt=MEDCouplingFieldTemplate.New(ON_CELLS); + trgFt=MEDCouplingFieldTemplate.New(ON_CELLS); + srcFt.setMesh(sourceMesh); + trgFt.setMesh(targetMesh); + self.assertEqual(1,remapper.prepareEx(srcFt,trgFt)); + srcField=MEDCouplingFieldDouble.New(ON_CELLS); + srcField.setNature(ConservativeVolumic); + srcField.setMesh(sourceMesh); + array=DataArrayDouble.New(); + ptr=sourceMesh.getNumberOfCells()*[None] + for i in xrange(sourceMesh.getNumberOfCells()): + ptr[i]=float(i+7); + pass + array.setValues(ptr,sourceMesh.getNumberOfCells(),1); + srcField.setArray(array); + trgfield=MEDCouplingFieldDouble.New(ON_CELLS); + trgfield.setNature(ConservativeVolumic); + trgfield.setMesh(targetMesh); + array=DataArrayDouble.New(); + ptr=targetMesh.getNumberOfCells()*[None] + for i in xrange(targetMesh.getNumberOfCells()): + ptr[i]=4.220173; + pass + array.setValues(ptr,targetMesh.getNumberOfCells(),1); + trgfield.setArray(array); + remapper.partialTransfer(srcField,trgfield); + values=trgfield.getArray().getValues(); + valuesExpected=[7.75, 7.0625, 4.220173,8.0] + self.assertEqual(4,trgfield.getArray().getNumberOfTuples()); + self.assertEqual(1,trgfield.getArray().getNumberOfComponents()); + for i0 in xrange(4): + self.assertAlmostEqual(valuesExpected[i0],values[i0],12); + pass + pass def build2DSourceMesh_1(self): sourceCoords=[-0.3,-0.3, 0.7,-0.3, -0.3,0.7, 0.7,0.7]