]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
partialTranfer python test.
authorageay <ageay>
Thu, 12 Apr 2012 16:20:40 +0000 (16:20 +0000)
committerageay <ageay>
Thu, 12 Apr 2012 16:20:40 +0000 (16:20 +0000)
src/MEDCoupling_Swig/MEDCouplingRemapperTest.py

index a1561e7b4ed7f88e11824e99c710cefc6aa89fdf..ba4826c69e284fa2020764173785f3cd0415ea9b 100644 (file)
@@ -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]