]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
Some performance loss linked to users having non uniform numbering in source mesh.
authorageay <ageay>
Thu, 10 Jan 2013 07:32:55 +0000 (07:32 +0000)
committerageay <ageay>
Thu, 10 Jan 2013 07:32:55 +0000 (07:32 +0000)
src/MEDCoupling_Swig/MEDCouplingRemapperTest.py

index 5c8042f5ecc6323988e8577041bb17e480ba1990..1998d7fdfe386981d9b8027c2632bd5143e42c7f 100644 (file)
@@ -285,6 +285,39 @@ class MEDCouplingBasicsTest(unittest.TestCase):
             self.assertAlmostEqual(expected3[i],trgField.getArray().getIJ(i,0),12);
             pass
         pass
+
+    # Bug when source mesh is not homogeneously oriented in source mesh
+    def testNonRegressionNonHomegenousOrriented3DCells(self):
+        csrc=DataArrayDouble([-0.15240000188350677,0,0,-0.1086929515004158,0,0,-0.15240000188350677,0.018142856657505035,0,-0.13054648041725159,0.0090714283287525177,0.019050000235438347,-0.13054648041725159,0.0090714283287525177,0],5,3)
+        src1=MEDCouplingUMesh("src",3) ; src1.allocateCells(0) ; src1.insertNextCell(NORM_TETRA4,[0,1,4,3]) ; src1.insertNextCell(NORM_TETRA4,[2,0,4,3])
+        src2=MEDCouplingUMesh("src",3) ; src2.allocateCells(0) ; src2.insertNextCell(NORM_TETRA4,[0,4,1,3]) ; src2.insertNextCell(NORM_TETRA4,[2,0,4,3])
+        src1.setCoords(csrc) ; src2.setCoords(csrc)
+        ctrg=DataArrayDouble([-0.15240000188350677,-0.038100000470876694,0,0.32379999756813049,-0.038100000470876694,0,-0.15240000188350677,0.076200000941753387,0,0.32379999756813049,0.076200000941753387,0,-0.15240000188350677,-0.038100000470876694,0.076200000941753387,0.32379999756813049,-0.038100000470876694,0.076200000941753387,-0.15240000188350677,0.076200000941753387,0.076200000941753387,0.32379999756813049,0.076200000941753387,0.076200000941753387],8,3)
+        trg=MEDCouplingUMesh("trg",3) ; trg.allocateCells(0) ; trg.insertNextCell(NORM_HEXA8,[0,1,3,2,4,5,7,6])
+        trg.setCoords(ctrg)
+        rem1=MEDCouplingRemapper() ; rem1.setSplittingPolicy(PLANAR_FACE_5) ; rem1.prepare(src1,trg,"P0P0")
+        rem2=MEDCouplingRemapper() ; rem2.setSplittingPolicy(PLANAR_FACE_5) ; rem2.prepare(src1,trg,"P0P0")
+        mat1=rem1.getCrudeMatrix() ; mat2=rem2.getCrudeMatrix()
+        self.assertEqual(1,len(mat1)) ; self.assertEqual(1,len(mat2))
+        self.assertEqual(mat1[0].keys(),mat2[0].keys()) ; self.assertEqual([0,1],mat1[0].keys())
+        self.assertAlmostEqual(1.25884108122e-06,mat1[0][0],16) ; self.assertAlmostEqual(1.25884108122e-06,mat2[0][0],16)
+        self.assertAlmostEqual(1.25884086663e-06,mat1[0][1],16) ; self.assertAlmostEqual(1.25884086663e-06,mat2[0][1],16)
+        #
+        d=DataArrayDouble([13.45,27.67],2,1)
+        f1=MEDCouplingFieldDouble(ON_CELLS,ONE_TIME) ; f1.setMesh(src1) ; f1.setArray(d) ; f1.setNature(RevIntegral)
+        f2=MEDCouplingFieldDouble(ON_CELLS,ONE_TIME) ; f2.setMesh(src2) ; f2.setArray(d) ; f2.setNature(RevIntegral)
+        f11=rem1.transferField(f1,1e300) ; f22=rem2.transferField(f2,1e300)
+        expected1=DataArrayDouble([0.012480539537637884])
+        self.assertTrue(f11.getArray().isEqual(expected1,1e-15))
+        self.assertTrue(f22.getArray().isEqual(expected1,1e-15))
+        #
+        f1.setNature(Integral) ; f2.setNature(Integral)
+        f11=rem1.transferField(f1,1e300) ; f22=rem2.transferField(f2,1e300)
+        #
+        expected2=DataArrayDouble([41.12])
+        self.assertTrue(f11.getArray().isEqual(expected2,1e-13))
+        self.assertTrue(f22.getArray().isEqual(expected2,1e-13))
+        pass
     
     def build2DSourceMesh_1(self):
         sourceCoords=[-0.3,-0.3, 0.7,-0.3, -0.3,0.7, 0.7,0.7]