X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMEDCoupling_Swig%2FMEDCouplingRemapperTest.py;h=58054d5192bf4d97490c27f447c95b37b7042a08;hb=b219559763498c4bd10c730cd3d2c62b1eed45db;hp=75d13766007ebdf239b5667a81719fbf50543944;hpb=4f3fb5a026df7d4be4fa63578f6b9426ce6bc0e6;p=tools%2Fmedcoupling.git diff --git a/src/MEDCoupling_Swig/MEDCouplingRemapperTest.py b/src/MEDCoupling_Swig/MEDCouplingRemapperTest.py index 75d137660..58054d519 100644 --- a/src/MEDCoupling_Swig/MEDCouplingRemapperTest.py +++ b/src/MEDCoupling_Swig/MEDCouplingRemapperTest.py @@ -1,5 +1,5 @@ # -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2016 CEA/DEN, EDF R&D +# Copyright (C) 2007-2019 CEA/DEN, EDF R&D # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -30,13 +30,13 @@ class MEDCouplingBasicsTest(unittest.TestCase): remapper=MEDCouplingRemapper() remapper.setPrecision(1e-12); remapper.setIntersectionType(Triangulation); - self.failUnless(remapper.prepare(sourceMesh,targetMesh,"P0P0")==1); + self.assertTrue(remapper.prepare(sourceMesh,targetMesh,"P0P0")==1); srcField=MEDCouplingFieldDouble.New(ON_CELLS); srcField.setNature(IntensiveMaximum); srcField.setMesh(sourceMesh); array=DataArrayDouble.New(); ptr=sourceMesh.getNumberOfCells()*[None] - for i in xrange(sourceMesh.getNumberOfCells()): + for i in range(sourceMesh.getNumberOfCells()): ptr[i]=float(i+7) pass array.setValues(ptr,sourceMesh.getNumberOfCells(),1); @@ -52,10 +52,10 @@ class MEDCouplingBasicsTest(unittest.TestCase): self.assertEqual(c,10) values=trgfield.getArray().getValues(); valuesExpected=[7.5 ,7. ,7.,8.,7.5]; - for i in xrange(targetMesh.getNumberOfCells()): - self.failUnless(abs(values[i]-valuesExpected[i])<1e-12); + for i in range(targetMesh.getNumberOfCells()): + self.assertTrue(abs(values[i]-valuesExpected[i])<1e-12); pass - self.failUnless(1==trgfield.getArray().getNumberOfComponents()); + self.assertTrue(1==trgfield.getArray().getNumberOfComponents()); pass def testPrepareEx1(self): @@ -75,7 +75,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): srcField.setMesh(sourceMesh); array=DataArrayDouble.New(); ptr=sourceMesh.getNumberOfCells()*[None] - for i in xrange(sourceMesh.getNumberOfCells()): + for i in range(sourceMesh.getNumberOfCells()): ptr[i]=float(i+7); pass array.setValues(ptr,sourceMesh.getNumberOfCells(),1); @@ -85,7 +85,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): 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): + for i0 in range(4): self.assertAlmostEqual(valuesExpected[i0],values[i0],12); pass pass @@ -107,7 +107,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): srcField.setMesh(sourceMesh); array=DataArrayDouble.New(); ptr=sourceMesh.getNumberOfCells()*[None] - for i in xrange(sourceMesh.getNumberOfCells()): + for i in range(sourceMesh.getNumberOfCells()): ptr[i]=float(i+7); pass array.setValues(ptr,sourceMesh.getNumberOfCells(),1); @@ -117,7 +117,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): trgfield.setMesh(targetMesh); array=DataArrayDouble.New(); ptr=targetMesh.getNumberOfCells()*[None] - for i in xrange(targetMesh.getNumberOfCells()): + for i in range(targetMesh.getNumberOfCells()): ptr[i]=4.220173; pass array.setValues(ptr,targetMesh.getNumberOfCells(),1); @@ -127,7 +127,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): 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): + for i0 in range(4): self.assertAlmostEqual(valuesExpected[i0],values[i0],12); pass pass @@ -308,7 +308,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): 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.assertEqual(list(mat1[0].keys()),list(mat2[0].keys())) ; self.assertEqual([0,1],list(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) # @@ -333,7 +333,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): cc=MEDCouplingCMesh() cc.setCoords(c,c,c) um=cc.buildUnstructured() - f=um.getMeasureField(ON_CELLS) + f=um.getMeasureField(False) # n2o=um.simplexize(PLANAR_FACE_5) f.setArray(f.getArray()[n2o]) @@ -570,7 +570,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): self.assertEqual(aRemapper.prepare(s,t,'P1P1'),1) m=aRemapper.getCrudeMatrix() self.assertEqual(len(m),28) - for i in xrange(28): + for i in range(28): if i not in [5,6]: self.assertEqual(len(m[i]),0) pass @@ -605,11 +605,11 @@ class MEDCouplingBasicsTest(unittest.TestCase): pt_c = coo.deepCopy(); pt_c[:,0] = 1.0; pt_c[:,1] = 0.0 # P = x*C+y*A + xy(B-A-C) + ORIGIN coo2 = coo[:,0]*pt_c + coo[:, 1]*pt_a + coo[:, 0]*coo[:, 1]*(pt_b - pt_a - pt_c) + orig - + tgt.setCoords(coo2) - + sCoo = DataArrayDouble([0.0,0.0, -0.3,1.0, 2.0,3.0, 1.0,0.0],4,2) - sCoo[:,0] += 10.0; sCoo[:,1] += 15.0; + sCoo[:,0] += 10.0; sCoo[:,1] += 15.0; sConn = DataArrayInt([0,1,2,3]) s = MEDCoupling1SGTUMesh("source",NORM_QUAD4) ; s.setCoords(sCoo) s.setNodalConnectivity(sConn) @@ -623,11 +623,11 @@ class MEDCouplingBasicsTest(unittest.TestCase): srcField.setMesh(s); srcField.setName("field") srcField.setArray(DataArrayDouble([1.0,2.0,3.0,4.0])) tgtF = aRemapper.transferField(srcField, 1e+300) - ref = [1.0, 1.75, 2.5, 3.25, 4.0, 1.25, 1.875, 2.5, 3.125, 3.75, 1.5, 2.0, 2.5, 3.0, 3.5, 1.75, + ref = [1.0, 1.75, 2.5, 3.25, 4.0, 1.25, 1.875, 2.5, 3.125, 3.75, 1.5, 2.0, 2.5, 3.0, 3.5, 1.75, 2.125, 2.5, 2.875, 3.25, 2.0, 2.25, 2.5, 2.75, 3.0] val = tgtF.getArray().getValues() for i, ref_v in enumerate(ref): - self.assertAlmostEqual(ref_v, val[i]) + self.assertAlmostEqual(ref_v, val[i]) pass def testSwig2MappedBarycentricP1P13_1(self): @@ -658,10 +658,10 @@ class MEDCouplingBasicsTest(unittest.TestCase): pt_1 = coo.deepCopy(); pt_1[:,0] = 0.0; pt_1[:,1] = 0.0; pt_1[:,2] = 1.0 pt_2 = coo.deepCopy(); pt_2[:,0] = 1.0; pt_2[:,1] = 0.0; pt_2[:,2] = 1.0 pt_3 = coo.deepCopy(); pt_3[:,0] = 2.0; pt_3[:,1] = 3.0; pt_3[:,2] = 1.0 - + pt_4 = coo.deepCopy(); pt_4[:,0] = -0.3; pt_4[:,1] = 1.0; pt_4[:,2] = 0.0 orig = coo.deepCopy(); orig[:,0] = 10.0; orig[:,1] = 15.0; orig[:,2] = 20.0 - pt_6 = coo.deepCopy(); pt_6[:,0] = 1.0; pt_6[:,1] = 0.0; pt_6[:,2] = 0.0 + pt_6 = coo.deepCopy(); pt_6[:,0] = 1.0; pt_6[:,1] = 0.0; pt_6[:,2] = 0.0 pt_7 = coo.deepCopy(); pt_7[:,0] = 2.0; pt_7[:,1] = 3.0; pt_7[:,2] = 0.0 # P = x*p6 + y*p4 + z*p1 + xy*(p7-p6-p4) + xz*(p2-p1-p6) + yz*(p0-p4-p1) + xyz(p3-p7-p2-p0+p1+p6+p4) x,y,z = coo[:,0],coo[:,1],coo[:,2] @@ -669,10 +669,10 @@ class MEDCouplingBasicsTest(unittest.TestCase): x*y*(pt_7 - pt_6 - pt_4) + x*z*(pt_2 - pt_1 - pt_6) + y*z*(pt_0 - pt_4 - pt_1) + \ x*y*z*(pt_3 - pt_7 - pt_2 - pt_0 + pt_6 + pt_1 + pt_4) + orig tgt.setCoords(coo2) - - sCoo = DataArrayDouble([-0.3,1.0,1.0, 0.0,0.0,1.0, 1.0,0.0,1.0, 2.0,3.0,1.0, + + sCoo = DataArrayDouble([-0.3,1.0,1.0, 0.0,0.0,1.0, 1.0,0.0,1.0, 2.0,3.0,1.0, -0.3,1.0,0.0, 0.0,0.0,0.0, 1.0,0.0,0.0, 2.0,3.0,0.0,],8,3) - sCoo[:, 0] += 10.0; sCoo[:, 1] += 15.0; sCoo[:, 2] += 20.0; + sCoo[:, 0] += 10.0; sCoo[:, 1] += 15.0; sCoo[:, 2] += 20.0; sConn = DataArrayInt([0,1,2,3,4, 5,6,7]) s = MEDCoupling1SGTUMesh("source",NORM_HEXA8) ; s.setCoords(sCoo) s.setNodalConnectivity(sConn) @@ -687,28 +687,28 @@ class MEDCouplingBasicsTest(unittest.TestCase): srcField.setArray(DataArrayDouble([1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0])) tgtF = aRemapper.transferField(srcField, 1e+300) # print tgtF.getArray().getValues() - ref = [6.0, 6.251802698104413, 6.502397834044702, 6.7517940736426665, 7.0, 5.740554726834594, - 6.1761835575796935, 6.6052985689637564, 7.009392769824465, 7.383488834310164, - 5.487562931129931, 6.140664596972973, 6.720290674177548, 7.220534970454015, 7.651092836860121, - 5.2407867837524345, 6.125759809889516, 6.82853486793175, 7.390880823876876, 7.848445254819061, - 5.0, 6.12211344611157, 6.925740671133115, 7.529623182840827, 8.0, 5.0, 5.251802698104413, - 5.502397834044702, 5.751794073642667, 6.0, 4.740554726834594, 5.1761835575796935, + ref = [6.0, 6.251802698104413, 6.502397834044702, 6.7517940736426665, 7.0, 5.740554726834594, + 6.1761835575796935, 6.6052985689637564, 7.009392769824465, 7.383488834310164, + 5.487562931129931, 6.140664596972973, 6.720290674177548, 7.220534970454015, 7.651092836860121, + 5.2407867837524345, 6.125759809889516, 6.82853486793175, 7.390880823876876, 7.848445254819061, + 5.0, 6.12211344611157, 6.925740671133115, 7.529623182840827, 8.0, 5.0, 5.251802698104413, + 5.502397834044702, 5.751794073642667, 6.0, 4.740554726834594, 5.1761835575796935, 5.6052985689637564, 6.009392769824465, 6.383488834310163, 4.487562931129931, 5.140664596972973, - 5.720290674177548, 6.220534970454015, 6.651092836860121, 4.2407867837524345, 5.125759809889516, - 5.828534867931749, 6.390880823876876, 6.848445254819061, 4.0, 5.122113446111569, 5.925740671133115, - 6.529623182840827, 7.0, 4.0, 4.251802698104413, 4.502397834044702, 4.751794073642667, 5.0, 3.740554726834594, - 4.176183557579693, 4.6052985689637564, 5.009392769824464, 5.383488834310164, 3.487562931129931, - 4.140664596972973, 4.720290674177548, 5.220534970454015, 5.651092836860121, 3.240786783752434, 4.125759809889516, 4.82853486793175, - 5.390880823876876, 5.848445254819061, 3.0, 4.122113446111569, 4.925740671133115, 5.529623182840827, 6.0, 3.0, - 3.2518026981044135, 3.502397834044702, 3.7517940736426674, 4.0, 2.7405547268345933, 3.176183557579693, - 3.6052985689637564, 4.009392769824465, 4.383488834310164, 2.487562931129931, 3.140664596972973, 3.7202906741775474, 4.220534970454015, 4.65109283686012, 2.2407867837524345, 3.1257598098895154, 3.828534867931749, - 4.390880823876876, 4.848445254819061, 2.0, 3.1221134461115687, 3.9257406711331146, 4.529623182840826, 5.0, 2.0, 2.2518026981044135, 2.502397834044702, 2.7517940736426674, 3.0, 1.7405547268345936, 2.176183557579693, 2.6052985689637564, - 3.0093927698244642, 3.3834888343101635, 1.4875629311299305, 2.1406645969729734, 2.720290674177548, + 5.720290674177548, 6.220534970454015, 6.651092836860121, 4.2407867837524345, 5.125759809889516, + 5.828534867931749, 6.390880823876876, 6.848445254819061, 4.0, 5.122113446111569, 5.925740671133115, + 6.529623182840827, 7.0, 4.0, 4.251802698104413, 4.502397834044702, 4.751794073642667, 5.0, 3.740554726834594, + 4.176183557579693, 4.6052985689637564, 5.009392769824464, 5.383488834310164, 3.487562931129931, + 4.140664596972973, 4.720290674177548, 5.220534970454015, 5.651092836860121, 3.240786783752434, 4.125759809889516, 4.82853486793175, + 5.390880823876876, 5.848445254819061, 3.0, 4.122113446111569, 4.925740671133115, 5.529623182840827, 6.0, 3.0, + 3.2518026981044135, 3.502397834044702, 3.7517940736426674, 4.0, 2.7405547268345933, 3.176183557579693, + 3.6052985689637564, 4.009392769824465, 4.383488834310164, 2.487562931129931, 3.140664596972973, 3.7202906741775474, 4.220534970454015, 4.65109283686012, 2.2407867837524345, 3.1257598098895154, 3.828534867931749, + 4.390880823876876, 4.848445254819061, 2.0, 3.1221134461115687, 3.9257406711331146, 4.529623182840826, 5.0, 2.0, 2.2518026981044135, 2.502397834044702, 2.7517940736426674, 3.0, 1.7405547268345936, 2.176183557579693, 2.6052985689637564, + 3.0093927698244642, 3.3834888343101635, 1.4875629311299305, 2.1406645969729734, 2.720290674177548, 3.2205349704540143, 3.6510928368601205, 1.2407867837524345, 2.125759809889516, 2.8285348679317495, 3.390880823876876, 3.848445254819061, 1.0, 2.1221134461115687, 2.9257406711331146, 3.529623182840827, 4.0] val = tgtF.getArray().getValues() for i, ref_v in enumerate(ref): - self.assertAlmostEqual(ref_v, val[i]) + self.assertAlmostEqual(ref_v, val[i]) pass @unittest.skipUnless(MEDCouplingHasNumPyBindings() and MEDCouplingHasSciPyBindings(),"requires numpy AND scipy") @@ -727,7 +727,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): rem=MEDCouplingRemapper() rem.prepare(src,trg,"P0P0") # Internal crude sparse matrix computed. Let's manipulate it using CSR matrix in scipy. - for i in xrange(10): + for i in range(10): m=rem.getCrudeCSRMatrix() pass m2=rem.getCrudeCSRMatrix() @@ -769,14 +769,14 @@ class MEDCouplingBasicsTest(unittest.TestCase): self.assertAlmostEqual(m_1[2,3],0.3,12) self.assertEqual(m_1.getnnz(),7) pass - + @unittest.skipUnless(MEDCouplingHasNumPyBindings() and MEDCouplingHasSciPyBindings(),"requires numpy AND scipy") def testP0P1Bary_1(self): a=MEDCouplingUMesh("a",2) a.allocateCells() conna=[0,1,3,2,1,4,5,3,4,6,7,5,6,8,9,7,8,10,11,9,10,12,13,11,12,14,15,13,14,16,17,15,16,18,19,17,18,20,21,19,20,22,23,21,22,24,25,23,24,26,27,25] a.setCoords(DataArrayDouble([1.54,0,-0.01,1.54,0.02,-0.01,1.54,0,0.01,1.54,0.02,0.01,1.54,0.04,-0.01,1.54,0.04,0.01,1.54,0.06,-0.01,1.54,0.06,0.01,1.54,0.08,-0.01,1.54,0.08,0.01,1.54,0.1,-0.01,1.54,0.1,0.01,1.54,0.12,-0.01,1.54,0.12,0.01,1.54,0.14,-0.01,1.54,0.14,0.01,1.54,0.16,-0.01,1.54,0.16,0.01,1.54,0.18,-0.01,1.54,0.18,0.01,1.54,0.2,-0.01,1.54,0.2,0.01,1.54,0.22,-0.01,1.54,0.22,0.01,1.54,0.24,-0.01,1.54,0.24,0.01,1.54,0.26,-0.01,1.54,0.26,0.01],28,3)) - for i in xrange(13): + for i in range(13): a.insertNextCell(NORM_QUAD4,conna[4*i:4*(i+1)]) pass a.finishInsertingCells() ; a.simplexize(0) @@ -784,7 +784,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): connb=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,0,2,39,3,5,40,6,8,41,9,11,42,12,14,43,15,17,44,18,20,45,21,23,46,24,26,47,27,29,48,30,32,49,33,35,50,36,38,51,52,2,39,53,5,40,54,8,41,55,11,42,56,14,43,57,17,44,58,20,45,59,23,46,60,26,47,61,29,48,62,32,49,63,35,50,64,38,51,52,2,65,53,5,66,54,8,67,55,11,68,56,14,69,57,17,70,58,20,71,59,23,72,60,26,73,61,29,74,62,32,75,63,35,76,64,38,77,53,2,65,54,5,66,55,8,67,56,11,68,57,14,69,58,17,70,59,20,71,60,23,72,61,26,73,62,29,74,63,32,75,64,35,76,78,38,77,53,2,40,54,5,41,55,8,42,56,11,43,57,14,44,58,17,45,59,20,46,60,23,47,61,26,48,62,29,49,63,32,50,64,35,51,78,38,79,3,2,40,6,5,41,9,8,42,12,11,43,15,14,44,18,17,45,21,20,46,24,23,47,27,26,48,30,29,49,33,32,50,36,35,51,80,38,79,3,2,1,6,5,4,9,8,7,12,11,10,15,14,13,18,17,16,21,20,19,24,23,22,27,26,25,30,29,28,33,32,31,36,35,34,80,38,37] b=MEDCouplingUMesh("b",2) b.allocateCells() - for i in xrange(104): + for i in range(104): b.insertNextCell(NORM_TRI3,connb[3*i:3*(i+1)]) pass b.setCoords(DataArrayDouble([1.54,0,-0.01,1.54,0.01,-0.01,1.54,0.01,0,1.54,0.02,-0.01,1.54,0.03,-0.01,1.54,0.03,0,1.54,0.04,-0.01,1.54,0.05,-0.01,1.54,0.05,0,1.54,0.06,-0.01,1.54,0.07,-0.01,1.54,0.07,0,1.54,0.08,-0.01,1.54,0.09,-0.01,1.54,0.09,0,1.54,0.1,-0.01,1.54,0.11,-0.01,1.54,0.11,0,1.54,0.12,-0.01,1.54,0.13,-0.01,1.54,0.13,0,1.54,0.14,-0.01,1.54,0.15,-0.01,1.54,0.15,0,1.54,0.16,-0.01,1.54,0.17,-0.01,1.54,0.17,0,1.54,0.18,-0.01,1.54,0.19,-0.01,1.54,0.19,0,1.54,0.2,-0.01,1.54,0.21,-0.01,1.54,0.21,0,1.54,0.22,-0.01,1.54,0.23,-0.01,1.54,0.23,0,1.54,0.24,-0.01,1.54,0.25,-0.01,1.54,0.25,0,1.54,0,0,1.54,0.02,0,1.54,0.04,0,1.54,0.06,0,1.54,0.08,0,1.54,0.1,0,1.54,0.12,0,1.54,0.14,0,1.54,0.16,0,1.54,0.18,0,1.54,0.2,0,1.54,0.22,0,1.54,0.24,0,1.54,0,0.01,1.54,0.02,0.01,1.54,0.04,0.01,1.54,0.06,0.01,1.54,0.08,0.01,1.54,0.1,0.01,1.54,0.12,0.01,1.54,0.14,0.01,1.54,0.16,0.01,1.54,0.18,0.01,1.54,0.2,0.01,1.54,0.22,0.01,1.54,0.24,0.01,1.54,0.01,0.01,1.54,0.03,0.01,1.54,0.05,0.01,1.54,0.07,0.01,1.54,0.09,0.01,1.54,0.11,0.01,1.54,0.13,0.01,1.54,0.15,0.01,1.54,0.17,0.01,1.54,0.19,0.01,1.54,0.21,0.01,1.54,0.23,0.01,1.54,0.25,0.01,1.54,0.26,0.01,1.54,0.26,0,1.54,0.26,-0.01],81,3)) @@ -806,8 +806,8 @@ class MEDCouplingBasicsTest(unittest.TestCase): vals*=1e-5 eps0=DataArrayDouble(m0.data)-vals ; eps0.abs() self.assertTrue(eps0.findIdsInRange(1e-17,1e300).empty()) - self.assertTrue(DataArrayInt(m0.indices).isEqual(DataArrayInt([0,1,3,1,4,5,4,6,7,6,8,9,8,10,11,10,12,13,12,14,15,14,16,17,16,18,19,18,20,21,20,22,23,22,24,25,24,26,27,0,2,3,1,3,5,4,5,7,6,7,9,8,9,11,10,11,13,12,13,15,14,15,17,16,17,19,18,19,21,20,21,23,22,23,25,24,25,27,0,2,3,1,3,5,4,5,7,6,7,9,8,9,11,10,11,13,12,13,15,14,15,17,16,17,19,18,19,21,20,21,23,22,23,25,24,25,27,0,2,3,1,3,5,4,5,7,6,7,9,8,9,11,10,11,13,12,13,15,14,15,17,16,17,19,18,19,21,20,21,23,22,23,25,24,25,27,0,2,3,1,3,5,4,5,7,6,7,9,8,9,11,10,11,13,12,13,15,14,15,17,16,17,19,18,19,21,20,21,23,22,23,25,24,25,27,0,1,3,1,4,5,4,6,7,6,8,9,8,10,11,10,12,13,12,14,15,14,16,17,16,18,19,18,20,21,20,22,23,22,24,25,24,26,27,0,1,3,1,4,5,4,6,7,6,8,9,8,10,11,10,12,13,12,14,15,14,16,17,16,18,19,18,20,21,20,22,23,22,24,25,24,26,27,0,1,3,1,4,5,4,6,7,6,8,9,8,10,11,10,12,13,12,14,15,14,16,17,16,18,19,18,20,21,20,22,23,22,24,25,24,26,27]))) - self.assertTrue(DataArrayInt(m0.indptr).isEqual(DataArrayInt([0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57,60,63,66,69,72,75,78,81,84,87,90,93,96,99,102,105,108,111,114,117,120,123,126,129,132,135,138,141,144,147,150,153,156,159,162,165,168,171,174,177,180,183,186,189,192,195,198,201,204,207,210,213,216,219,222,225,228,231,234,237,240,243,246,249,252,255,258,261,264,267,270,273,276,279,282,285,288,291,294,297,300,303,306,309,312]))) + self.assertTrue(DataArrayInt32(m0.indices).isEqual(DataArrayInt32([0,1,3,1,4,5,4,6,7,6,8,9,8,10,11,10,12,13,12,14,15,14,16,17,16,18,19,18,20,21,20,22,23,22,24,25,24,26,27,0,2,3,1,3,5,4,5,7,6,7,9,8,9,11,10,11,13,12,13,15,14,15,17,16,17,19,18,19,21,20,21,23,22,23,25,24,25,27,0,2,3,1,3,5,4,5,7,6,7,9,8,9,11,10,11,13,12,13,15,14,15,17,16,17,19,18,19,21,20,21,23,22,23,25,24,25,27,0,2,3,1,3,5,4,5,7,6,7,9,8,9,11,10,11,13,12,13,15,14,15,17,16,17,19,18,19,21,20,21,23,22,23,25,24,25,27,0,2,3,1,3,5,4,5,7,6,7,9,8,9,11,10,11,13,12,13,15,14,15,17,16,17,19,18,19,21,20,21,23,22,23,25,24,25,27,0,1,3,1,4,5,4,6,7,6,8,9,8,10,11,10,12,13,12,14,15,14,16,17,16,18,19,18,20,21,20,22,23,22,24,25,24,26,27,0,1,3,1,4,5,4,6,7,6,8,9,8,10,11,10,12,13,12,14,15,14,16,17,16,18,19,18,20,21,20,22,23,22,24,25,24,26,27,0,1,3,1,4,5,4,6,7,6,8,9,8,10,11,10,12,13,12,14,15,14,16,17,16,18,19,18,20,21,20,22,23,22,24,25,24,26,27]))) + self.assertTrue(DataArrayInt32(m0.indptr).isEqual(DataArrayInt32([0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57,60,63,66,69,72,75,78,81,84,87,90,93,96,99,102,105,108,111,114,117,120,123,126,129,132,135,138,141,144,147,150,153,156,159,162,165,168,171,174,177,180,183,186,189,192,195,198,201,204,207,210,213,216,219,222,225,228,231,234,237,240,243,246,249,252,255,258,261,264,267,270,273,276,279,282,285,288,291,294,297,300,303,306,309,312]))) # rem2=MEDCouplingRemapper() ; rem2.setIntersectionType(Barycentric) rem2.prepare(b,a,"P0P1") @@ -836,10 +836,10 @@ class MEDCouplingBasicsTest(unittest.TestCase): # rem=MEDCouplingRemapper() rem.setMaxDistance3DSurfIntersect(1e-12) - rem.setMinDotBtwPlane3DSurfIntersect(0.99)# this line is important it is to tell to remapper to select only cells with very close orientation + rem.setMinDotBtwPlane3DSurfIntersect(0.99)# this line is important it is to tell to remapper to select only cells with very close orientation rem.prepare(skinAndNonConformCells,skinAndNonConformCells,"P0P0") mat=rem.getCrudeCSRMatrix() - indptr=DataArrayInt(mat.indptr) + indptr=DataArrayInt32(mat.indptr) #not depend on MEDCouplingUse64BitIDs() indptr2=indptr.deltaShiftIndex() cellIdsOfNonConformCells=indptr2.findIdsNotEqual(1) cellIdsOfSkin=indptr2.findIdsEqual(1) @@ -860,7 +860,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): source=MEDCoupling1SGTUMesh("SourcePrimaire",NORM_SEG2) source.setCoords(sourceCoo) source.allocateCells() - for i in xrange(len(sourceCoo)-1): + for i in range(len(sourceCoo) - 1): source.insertNextCell([i,i+1]) pass source=source.buildUnstructured() @@ -909,7 +909,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): # self.assertTrue(coarse.isEqual(trgField.getArray(),1e-12)) pass - + @unittest.skipUnless(MEDCouplingHasNumPyBindings() and MEDCouplingHasSciPyBindings(),"requires numpy AND scipy") def test1DPointLocator1(self): """This test focuses on PointLocator for P1P1 in 1D and 2DCurve.""" @@ -977,7 +977,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): diff=abs(m-mExp0) self.assertAlmostEqual(diff.sum(),0.,14) pass - + def test3D2Dand2D3DPointLocator1(self): """ Non regression test solving SIGSEGV when using 3D<->3Dsurf pointlocator.""" arrX=DataArrayDouble([0,1,2]) @@ -998,8 +998,10 @@ class MEDCouplingBasicsTest(unittest.TestCase): self.assertEqual(rem.getCrudeMatrix(),[{0: 1.0}, {1: 1.0}]) rem2=MEDCouplingRemapper() rem2.setIntersectionType(PointLocator) - rem2.prepare(mt,ms,"P0P0") # reverse mt<->ms - self.assertEqual(rem2.getCrudeMatrix(),[{0: 1.0}, {1: 1.0}]) + ## + # 2D to 3D with point locator does not make sense: + ## + self.assertRaises(InterpKernelException, rem2.prepare,mt,ms,"P0P0") pass def test2D1Dand1D2DPointLocator1(self): @@ -1018,7 +1020,70 @@ class MEDCouplingBasicsTest(unittest.TestCase): rem.prepare(mt,ms,"P0P0") self.assertEqual(rem.getCrudeMatrix(),[{0:1.},{1:1.}]) pass - + + def test3D1DPointLocatorBBoxAdjusted(self): + """ In case a 1D segment lies exactly on the interface between two 2D (or 3D) faces, the default + bounding box logic will make it non-intersecting with the surrounding 2D (or 3D) faces. + Test bounding box adjustment allowing to widen the BB to capture this. + """ + m = MEDCouplingCMesh("source") + di, dd = DataArrayInt, DataArrayDouble + m.setCoordsAt(0, dd([0.0, 1.0, 2.0])) + m.setCoordsAt(1, dd([0.0, 1.0])) + m.setCoordsAt(2, dd([0.0, 1.0])) + m3d = m.buildUnstructured() + m1d = MEDCouplingUMesh("target", 1) + m1d.setCoords(dd([1.0,0.5,0.2 , 1.0,0.5,0.8], 2,3)) + m1d.setConnectivity(di([NORM_SEG2, 0, 1]), di([0,3])) + + rem = MEDCouplingRemapper() + rem.setPrecision(1e-12) + rem.setIntersectionType(PointLocator) + rem.prepare(m3d, m1d,"P0P1") + self.assertEqual(rem.getCrudeMatrix(), [{0: 1.0, 1: 1.0}, {0: 1.0, 1: 1.0}]) + + rem = MEDCouplingRemapper() + rem.setPrecision(1e-12) + rem.setIntersectionType(PointLocator) + rem.setBoundingBoxAdjustment(0.0) + rem.setBoundingBoxAdjustmentAbs(0.0) + rem.prepare(m3d, m1d,"P0P1") + self.assertEqual(rem.getCrudeMatrix(), [{}, {}]) + pass + + def testPointLocator3DTo2D(self): + """Target mesh has spaceDim==3 and meshDim==2. Source has spaceDim==3 and meshDim==3. Here we are on pointlocator alg. + The test evaluates on each nodes of target mesh the bary coor into source mesh.""" + src=MEDCouplingCMesh() + arr=DataArrayDouble([0,1,2]) + src.setCoords(arr,arr,arr) + src=src.buildUnstructured() + src.simplexize(PLANAR_FACE_5) + fsrc=MEDCouplingFieldDouble(ON_NODES) ; fsrc.setMesh(src) + fsrc.setArray(DataArrayDouble([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26])) + # + trg=MEDCouplingCMesh() + arr=DataArrayDouble([0,1]) + trg.setCoords(arr,arr) + trg=trg.buildUnstructured() + trg.changeSpaceDimension(3,0.) + trg.translate([0.5,0.5,0.5]) + # + arrTrg=fsrc.getValueOnMulti(trg.getCoords()) + ftrg=MEDCouplingFieldDouble(ON_NODES) + ftrg.setMesh(trg) + ftrg.setArray(arrTrg) + ftrg.checkConsistencyLight() + ftrg.setNature(IntensiveMaximum) + # + fsrc.setNature(IntensiveMaximum) + remap=MEDCouplingRemapper() + remap.setIntersectionType(PointLocator) + self.assertEqual(remap.prepare(src,trg,"P1P1"),1) + ftrg2=remap.transferField(fsrc,1e300) + self.assertTrue(ftrg.isEqual(ftrg2,1e-12,1e-12)) + pass + def testExtrudedOnDiffZLev1(self): """Non regression bug : This test is base on P0P0 ExtrudedExtruded. This test checks that if the input meshes are not based on a same plane // OXY the interpolation works""" arrX=DataArrayDouble([0,1]) ; arrY=DataArrayDouble([0,1]) ; arrZ=DataArrayDouble([0,1,2]) @@ -1044,9 +1109,202 @@ class MEDCouplingBasicsTest(unittest.TestCase): self.checkMatrix(rem2.getCrudeMatrix(),[{0:0.125,1:0.25}],src.getNumberOfCells(),1e-12) pass + def testP0P0WithHEXGP12(self): + """ Test that HEXGP12 are correctly remapped (elements with polygonal faces were not properly handled) """ + # From Astrid, two disjoint hexagonal prisms: + coo1 = [-4.991193077144312, 8.644999999999998, 0.0, -9.982386154288623, 6.112246755425186e-16, 0.0, -4.991193077144315, -8.644999999999998, 0.0, 4.991193077144309, -8.645000000000005, 0.0, 9.982386154288626, 1.1651321638577316e-15, 0.0, 4.991193077144314, 8.645, 0.0, -4.991193077144312, 8.644999999999998, 7.561799999999991, -9.982386154288623, 6.112246755425186e-16, 7.561799999999991, -4.991193077144315, -8.644999999999998, 7.561799999999991, 4.991193077144309, -8.645000000000005, 7.561799999999991, 9.982386154288626, 1.1651321638577316e-15, 7.561799999999991, 4.991193077144314, 8.645, 7.561799999999991] + coo2 = [-4.991193077144313, -8.645, 0.0, -9.982386154288626, -1.3992140779350848e-15, 0.0, -19.964772308577256, 0.0, 0.0, -24.95596538572157, -8.644999999999998, 0.0, -19.96477230857726, -17.289999999999996, 0.0, -9.982386154288626, -17.289999999999996, 0.0, -4.991193077144313, -8.645, 5.041200000000004, -9.982386154288626, -1.3992140779350848e-15, 5.041200000000004, -19.964772308577256, 0.0, 5.041200000000004, -24.95596538572157, -8.644999999999998, 5.041200000000004, -19.96477230857726, -17.289999999999996, 5.041200000000004, -9.982386154288626, -17.289999999999996, 5.041200000000004] + conn1 = [31, 0, 5, 4, 3, 2, 1, -1, 11, 6, 7, 8, 9, 10, -1, 1, 7, 6, 0, -1, 2, 8, 7, 1, -1, 3, 9, 8, 2, -1, 4, 10, 9, 3, -1, 5, 11, 10, 4, -1, 0, 6, 11, 5] + cI1 = [0, 44] + conn2 = [31, 0, 5, 4, 3, 2, 1, -1, 6, 7, 8, 9, 10, 11, -1, 0, 1, 7, 6, -1, 1, 2, 8, 7, -1, 2, 3, 9, 8, -1, 3, 4, 10, 9, -1, 4, 5, 11, 10, -1, 5, 0, 6, 11] + cI2 = [0, 44] + mTgt = MEDCouplingUMesh("target", 3) + mSrc = MEDCouplingUMesh("src", 3) + mTgt.setCoords(DataArrayDouble(coo1, len(coo1) // 3, 3)) + mSrc.setCoords(DataArrayDouble(coo2, len(coo2) // 3, 3)) + mTgt.setConnectivity(DataArrayInt(conn1), DataArrayInt(cI1)) + mSrc.setConnectivity(DataArrayInt(conn2), DataArrayInt(cI2)) + + # Recognize the HEXGP12: + mTgt.unPolyze() + mSrc.unPolyze() + + rmp = MEDCouplingRemapper() + rmp.setIntersectionType(Triangulation) + rmp.prepare(mSrc, mTgt, "P0P0") + mat = rmp.getCrudeMatrix() + self.assertEqual(len(mat[0]), 0) + self.assertEqual(len(mat), 1) + pass + + def testP0P0KillerTet(self): + """ The killer tetrahedron detected by LMEC!""" + mesh = MEDCouplingUMesh('SupportOf_ECHIA1_Tin', 3) +# # was OK: +# coo = DataArrayDouble([(-4.50135,1.95352,4.59608),(-4.50409,1.86642,4.54551), (-4.55175,1.92167,4.64844),(-4.58813,1.94795,4.5283)]) + # was KO: + coo = DataArrayDouble([(-4.501352938826142847,1.953517433537110159,4.596082552008083688),(-4.504092113061189728,1.866415526007169978,4.545507396150389567),(-4.551750368181751050,1.921669328035479962,4.648439577911889664),(-4.588131417812300050,1.947948377683889953,4.528298931319220344)]) + mesh.setCoords(coo) + c = DataArrayInt([14, 2, 0, 3, 1]); cI = DataArrayInt([0, 5]) + mesh.setConnectivity(c, cI) + mesh_src, mesh_tgt = mesh.deepCopy(), mesh.deepCopy() + field_src = mesh_src.fillFromAnalytic(ON_CELLS, 1, "1") + field_src.setNature(IntensiveMaximum) + rmp = MEDCouplingRemapper() + rmp.setIntersectionType(Triangulation) + rmp.prepare(mesh_src, mesh_tgt, "P0P0") + self.assertEqual(1, len(rmp.getCrudeMatrix())) + self.assertEqual(1, len(rmp.getCrudeMatrix()[0])) + pass + + @unittest.skipUnless(MEDCouplingHasNumPyBindings() and MEDCouplingHasSciPyBindings(),"requires numpy AND scipy AND C++11") + def testP1P1PL3DSpaceFrom1DTo0D(self): + from scipy.sparse import csr_matrix + from numpy import array + + def generateTrg(eps): + trgArr=DataArrayDouble([(0.5,0.5,0.5),(0.2,0.2,0.2),(0.9,0.9,0.9),(0.7+eps*sqrt(3),0.7-eps*sqrt(3),0.7)]) + trg=MEDCouplingUMesh("trg",0) ; trg.setCoords(trgArr) + trg.allocateCells() + RenumTrg=[2,3,0,1] + for rt in RenumTrg: + trg.insertNextCell(NORM_POINT1,[rt]) + return trg + + srcArr=DataArrayDouble([(0.,0.,1.),(0.,0.,0.),(1.,1.,1.)]) + src=MEDCouplingUMesh("src",1) ; src.setCoords(srcArr) + src.allocateCells() + src.insertNextCell(NORM_SEG2,[1,2]) + # + trg=generateTrg(1e-7)# trg point 3 of trg cell 1 is NOT closer enough to source edge #1 -> not intercepted + # + rem=MEDCouplingRemapper() + rem.setIntersectionType(PointLocator) + self.assertEqual(rem.prepare(src,trg,"P1P1"),1) + mat=rem.getCrudeCSRMatrix() + row=array([2,2, 0,0, 1,1]) # here no ref to point 3 ! + col=array([1,2, 1,2, 1,2]) + data=array([0.1,0.9, 0.5,0.5, 0.8,0.2]) + mExp=csr_matrix((data,(row,col)),shape=(4,3)) + delta=abs(mExp-mat) + self.assertAlmostEqual(delta.sum(),0.,14) + # + trg=generateTrg(1e-14) # trg point 3 of trg cell 1 is closer enough to source edge #1 -> intercepted + rem=MEDCouplingRemapper() + rem.setIntersectionType(PointLocator) + self.assertEqual(rem.prepare(src,trg,"P1P1"),1) + mat=rem.getCrudeCSRMatrix() + row=array([2,2, 3,3, 0,0, 1,1]) # here ref to target point 3 + col=array([1,2, 1,2, 1,2, 1,2]) + data=array([0.1,0.9, 0.3,0.7, 0.5,0.5, 0.8,0.2]) + mExp2=csr_matrix((data,(row,col)),shape=(4,3)) + delta2=abs(mExp2-mat) + self.assertAlmostEqual(delta2.sum(),0.,14) + pass + + def testSetMatrix1(self): + """ Remapper has now setCrudeMatrix method to reload matrix to skip prepare phase """ + cooS=DataArrayDouble([1,1, 7,1, 7,2, 1,2],4,2) + cooT=DataArrayDouble([0,0, 3,0, 3,3, 0,3, 6,0, 12,0, 12,3, 6,3],8,2) + ms=MEDCouplingUMesh("source",2) ; ms.allocateCells(1) ; ms.insertNextCell(NORM_QUAD4,[0,1,2,3]) ; ms.setCoords(cooS) + mt=MEDCouplingUMesh("target",2) ; mt.allocateCells(2) ; mt.insertNextCell(NORM_QUAD4,[0,1,2,3]) ; mt.insertNextCell(NORM_QUAD4,[4,5,6,7]) ; mt.setCoords(cooT) + rem=MEDCouplingRemapper() + self.assertEqual(rem.prepare(ms,mt,"P0P0"),1) # [{0: 2.0}, {0: 1.0}] + fs=MEDCouplingFieldDouble(ON_CELLS) + fs.setMesh(ms) + fs.setArray(DataArrayDouble([10])) + fs.checkConsistencyLight() + # + fs.setNature(ExtensiveConservation) + self.assertTrue(rem.transferField(fs,1e300).getArray().isEqual(DataArrayDouble([20./3,10./3.]),1e-12))# sum is equal to 10. First value is twice than second value + # + fs.setNature(ExtensiveMaximum) + self.assertTrue(rem.transferField(fs,1e300).getArray().isEqual(DataArrayDouble([20./6.,10./6.]),1e-12))#sum is equal to 5 (10/2. because only half part on input cell is intercepted by the target cells). First value is twice than second value + # + fs.setNature(IntensiveConservation) + self.assertTrue(rem.transferField(fs,1e300).getArray().isEqual(DataArrayDouble([2./9.*10.,1./18.*10.]),1e-12))# + # + fs.setNature(IntensiveMaximum) + self.assertTrue(rem.transferField(fs,1e300).getArray().isEqual(DataArrayDouble([10.,10.]),1e-12))# + #### + rem2=MEDCouplingRemapper() + rem2.setCrudeMatrix(ms,mt,"P0P0",rem.getCrudeMatrix()) + fs.setNature(ExtensiveConservation) + self.assertTrue(rem2.transferField(fs,1e300).getArray().isEqual(DataArrayDouble([20./3,10./3.]),1e-12)) + # + fs.setNature(ExtensiveMaximum) + self.assertTrue(rem2.transferField(fs,1e300).getArray().isEqual(DataArrayDouble([20./6.,10./6.]),1e-12)) + # + fs.setNature(IntensiveConservation) + self.assertTrue(rem2.transferField(fs,1e300).getArray().isEqual(DataArrayDouble([2./9.*10.,1./18.*10.]),1e-12)) + # + fs.setNature(IntensiveMaximum) + self.assertTrue(rem2.transferField(fs,1e300).getArray().isEqual(DataArrayDouble([10.,10.]),1e-12)) + # + srcFt=MEDCouplingFieldTemplate.New(ON_CELLS); + trgFt=MEDCouplingFieldTemplate.New(ON_CELLS); + srcFt.setMesh(ms); + trgFt.setMesh(mt); + rem3=MEDCouplingRemapper() + rem3.setCrudeMatrixEx(srcFt,trgFt,rem.getCrudeMatrix()) + fs.setNature(ExtensiveConservation) + self.assertTrue(rem3.transferField(fs,1e300).getArray().isEqual(DataArrayDouble([20./3,10./3.]),1e-12)) + pass + + @unittest.skipUnless(MEDCouplingHasNumPyBindings() and MEDCouplingHasSciPyBindings(),"requires numpy AND scipy") + def testSetMatrix2(self): + """ Remapper has now setCrudeMatrix method to reload matrix to skip prepare phase. Same as testSetMatrix1 but with CSR scipy matrix """ + arrx_s=DataArrayDouble(6) ; arrx_s.iota() + arry_s=DataArrayDouble(6) ; arry_s.iota() + ms=MEDCouplingCMesh() ; ms.setCoords(arrx_s,arry_s) + ms=ms.buildUnstructured() + # + arrx_t=DataArrayDouble([2.5,4.5,5.5]) + arry_t=DataArrayDouble([2.5,3.5,5.5]) + mt=MEDCouplingCMesh() ; mt.setCoords(arrx_t,arry_t) + mt=mt.buildUnstructured() + # + rem=MEDCouplingRemapper() + self.assertEqual(rem.prepare(ms,mt,"P0P0"),1) + # + fs=MEDCouplingFieldDouble(ON_CELLS) + fs.setMesh(ms) + arr=DataArrayDouble(25) ; arr.iota() + fs.setArray(arr) + fs.checkConsistencyLight() + # + fs.setNature(ExtensiveConservation) + self.assertTrue(rem.transferField(fs,1e300).getArray().isEqual(DataArrayDouble([54.25,11.75,79.25,16.75]),1e-12)) + mat=rem.getCrudeCSRMatrix() + rem2=MEDCouplingRemapper() + rem2.setCrudeMatrix(ms,mt,"P0P0",mat) + self.assertTrue(rem2.transferField(fs,1e300).getArray().isEqual(DataArrayDouble([54.25,11.75,79.25,16.75]),1e-12)) + pass + + def testSmallTetraCell(self): + """This test is a non regression test. When using tetra/tetra P0P0 interpolation on very small cells the + 3x3 matrix in the TetraAffine contains very small values and so the determinant is small (cubic). + So the tetra was detected as flat. Now the infinite norm of matrix is considered to establish if matrix is inversible or not.""" + coords = [(-0.019866666666666668, 0.02, 0.002), (-0.020000073463967143, 0.019999926535763005, 0.0018666666666666673), (-0.020000073463967143, 0.019999926535763005, 0.002), (-0.020000072974206463, 0.019866593202430387, 0.002)] + m=MEDCouplingUMesh("mesh",3) + m.allocateCells() + m.insertNextCell(NORM_TETRA4,[0,1,2,3]) + m.setCoords(DataArrayDouble(coords)) + rem=MEDCouplingRemapper() + rem.setPrecision(1e-12) + rem.prepare(m,m,"P0P0") + mat=rem.getCrudeMatrix() + self.assertTrue(len(mat)==1) + self.assertTrue(len(mat[0])==1) + self.assertTrue(list(mat[0].keys())==[0]) + res=list(mat[0].values())[0] + ref=float(m.getMeasureField(True).getArray()) + self.assertTrue(abs(res-ref)/ref<1e-12) + pass + def checkMatrix(self,mat1,mat2,nbCols,eps): self.assertEqual(len(mat1),len(mat2)) - for i in xrange(len(mat1)): + for i in range(len(mat1)): self.assertTrue(max(mat2[i].keys())=0) @@ -1063,7 +1321,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): pass pass pass - + def build2DSourceMesh_1(self): sourceCoords=[-0.3,-0.3, 0.7,-0.3, -0.3,0.7, 0.7,0.7] sourceConn=[0,3,1,0,2,3] @@ -1076,7 +1334,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): myCoords.setValues(sourceCoords,4,2); sourceMesh.setCoords(myCoords); return sourceMesh; - + def build2DTargetMesh_1(self): targetCoords=[-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, -0.3,0.2, 0.2,0.2, 0.7,0.2, -0.3,0.7, 0.2,0.7, 0.7,0.7 ] targetConn=[0,3,4,1, 1,4,2, 4,5,2, 6,7,4,3, 7,8,5,4] @@ -1100,7 +1358,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): targetMesh=MEDCouplingUMesh.New(); targetMesh.setMeshDimension(2); targetMesh.allocateCells(4); - for i in xrange(4): + for i in range(4): targetMesh.insertNextCell(NORM_QUAD4,4,targetConn[4*i:4*(i+1)]) pass targetMesh.finishInsertingCells(); @@ -1109,7 +1367,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): targetMesh.setCoords(myCoords); return targetMesh; pass - + def setUp(self): pass pass