X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMEDCoupling_Swig%2FMEDCouplingBasicsTest5.py;h=b0684f46d53724048facaf551d2fbe09e45df67d;hb=b7e277ad50223814bc479c5bd64cf12abe8fc959;hp=b6e54dd7241eb8f1371af857f1412b734eb800bc;hpb=90051050bc0b7f6f8d399674204cf5bdef4c0fdb;p=tools%2Fmedcoupling.git diff --git a/src/MEDCoupling_Swig/MEDCouplingBasicsTest5.py b/src/MEDCoupling_Swig/MEDCouplingBasicsTest5.py index b6e54dd72..b0684f46d 100644 --- a/src/MEDCoupling_Swig/MEDCouplingBasicsTest5.py +++ b/src/MEDCoupling_Swig/MEDCouplingBasicsTest5.py @@ -1430,7 +1430,7 @@ class MEDCouplingBasicsTest5(unittest.TestCase): pass # pass - + # test the when input slice is all the same object is return by MEDCouplingMesh.buildPartRange def testSwig2MeshPartSlice1(self): a=DataArrayDouble(4) ; a.iota() @@ -1482,7 +1482,7 @@ class MEDCouplingBasicsTest5(unittest.TestCase): exp=DataArrayDouble([18.5,118.5,17.5,117.5,16.5,116.5,14.5,114.5,13.5,113.5,12.5,112.5],6,2) ; exp.setInfoOnComponents(["aa [km]","bbb [kJ]"]) self.assertTrue(f2.getArray().isEqual(exp,1e-13)) pass - + def testSwig2NonRegressionBugIntersectMeshes1(self): src=MEDCouplingUMesh("src",2) src.setCoords(DataArrayDouble([-2.5,-3,-2.5,3,2.5,3],3,2)) @@ -1620,7 +1620,7 @@ class MEDCouplingBasicsTest5(unittest.TestCase): self.assertTrue(m.getCellsContainingPoint((-0.4,-0.4),1e-12).isEqual(DataArrayInt([1]))) self.assertTrue(m.getCellsContainingPoint((0.,-0.4),1e-12).isEqual(DataArrayInt([0,1]))) pass - + def testSwig2GetCellsContainingPointsForNonConvexPolygon2(self): coo=DataArrayDouble([-0.5,-0.5,-0.5,0.5,0.5,0.5,0.5,-0.5,-2.0816681711721685e-17,-2.0816681711721685e-17,-0.17677669529663687,0.1767766952966369,0.,0.5,0.5,0.,0.17677669529663684,-0.17677669529663692,0.17677669529663692,0.17677669529663684,-0.17677669529663692,-0.17677669529663687,0.,-0.5,-0.5,0.,0.33838834764831843,-0.3383883476483185,-0.33838834764831843,0.33838834764831843,-0.21213203435596423,0.21213203435596426,0.2121320343559642,-0.2121320343559643,0.21213203435596426,0.2121320343559642,-0.21213203435596423,-0.21213203435596428,0.3560660171779821,-0.35606601717798214,-0.35606601717798214,0.35606601717798214,0.19445436482630052,-0.19445436482630063,-0.19445436482630055,0.19445436482630057,0.,0.27],24,2) m=MEDCouplingUMesh("mesh",2) ; m.setCoords(coo) ; m.allocateCells() @@ -2241,7 +2241,7 @@ class MEDCouplingBasicsTest5(unittest.TestCase): def testSwig2Colinearize2D3(self): """ colinearize was too agressive, potentially producing cells with one edge """ # Flat polygon with 3 edges - nothing should happen (min number of edges for a linear polyg) - coo = DataArrayDouble([0.0,0.0, 2.0,0.0, 1.5,0.0, 1.0,0.0, 0.5,0.0], 5,2) + coo = DataArrayDouble([0.0,0.0, 2.0,0.0, 1.5,0.0, 1.0,0.0, 0.5,0.0], 5,2) m = MEDCouplingUMesh("m", 2) c, cI = [DataArrayInt(l) for l in [[NORM_POLYGON, 0,1,2], [0,4]] ] m.setCoords(coo); m.setConnectivity(c, cI) @@ -2249,8 +2249,8 @@ class MEDCouplingBasicsTest5(unittest.TestCase): m.checkConsistency() self.assertEqual(c.getValues(), m.getNodalConnectivity().getValues()) self.assertEqual(cI.getValues(), m.getNodalConnectivityIndex().getValues()) - - # Flat quad polygon, 2 edges - nothing should happen (min number of edges for a quad polyg) + + # Flat quad polygon, 2 edges - nothing should happen (min number of edges for a quad polyg) m = MEDCouplingUMesh("m", 2) c, cI = [DataArrayInt(l) for l in [[NORM_QPOLYG, 0,1, 2,3], [0,5]] ] m.setCoords(coo); m.setConnectivity(c, cI) @@ -2258,7 +2258,7 @@ class MEDCouplingBasicsTest5(unittest.TestCase): m.checkConsistency() self.assertEqual(c.getValues(), m.getNodalConnectivity().getValues()) self.assertEqual(cI.getValues(), m.getNodalConnectivityIndex().getValues()) - + # Flat polygon, 4 edges - one reduction should happen m = MEDCouplingUMesh("m", 2) c, cI = [DataArrayInt(l) for l in [[NORM_POLYGON, 0,1,2,3], [0,5]] ] @@ -2267,8 +2267,8 @@ class MEDCouplingBasicsTest5(unittest.TestCase): m.checkConsistency() self.assertEqual([NORM_POLYGON, 3,1,2], m.getNodalConnectivity().getValues()) self.assertEqual([0,4], m.getNodalConnectivityIndex().getValues()) - - # Flat quad polygon, 3 edges - one reduction expected + + # Flat quad polygon, 3 edges - one reduction expected m = MEDCouplingUMesh("m", 2) c, cI = [DataArrayInt(l) for l in [[NORM_QPOLYG, 0,1,3, 3,2,4], [0,7]] ] m.setCoords(coo); m.setConnectivity(c, cI) @@ -2277,7 +2277,7 @@ class MEDCouplingBasicsTest5(unittest.TestCase): self.assertEqual([NORM_QPOLYG, 3,1, 5,2], m.getNodalConnectivity().getValues()) self.assertTrue( m.getCoords()[5].isEqual( DataArrayDouble([(1.5,0.0)]), 1.0e-12 ) ) self.assertEqual([0,5], m.getNodalConnectivityIndex().getValues()) - + # Now an actual (neutronic) case: circle made of 4 SEG3. Should be reduced to 2 SEG3 m = MEDCouplingDataForTest.buildCircle2(0.0, 0.0, 1.0) c, cI = [DataArrayInt(l) for l in [[NORM_QPOLYG, 7,5,3,1, 6,4,2,0], [0,9]] ] @@ -2500,7 +2500,7 @@ class MEDCouplingBasicsTest5(unittest.TestCase): self.assertEqual(d.getValuesAsTuple(),[]) d=DataArrayDouble(24) ; d.iota() ; d.rearrange(3) self.assertEqual(d.getValues(),[0.,1.,2.,3.,4.,5.,6.,7.,8.,9.,10.,11.,12.,13.,14.,15.,16.,17.,18.,19.,20.,21.,22.,23.]) - self.assertEqual(d.getValuesAsTuple(),[(0.,1.,2.0),(3.,4.,5.0),(6.,7.,8.0),(9.,10.,11.0),(12.,13.,14.0),(15.,16.,17.0),(18.,19.,20.0),(21.,22.,23.)]) + self.assertEqual(d.getValuesAsTuple(),[(0.,1.,2.0),(3.,4.,5.0),(6.,7.,8.0),(9.,10.,11.0),(12.,13.,14.0),(15.,16.,17.0),(18.,19.,20.0),(21.,22.,23.)]) d=DataArrayInt() self.assertEqual(d.getValues(),[]) self.assertEqual(d.getValuesAsTuple(),[]) @@ -2787,7 +2787,7 @@ class MEDCouplingBasicsTest5(unittest.TestCase): self.assertTrue(isinstance(g1[i],MEDCouplingCartesianAMRPatch)) pass pass - + def testSwig2AMR7(self): """Idem testSwig2AMR6 except that we are in 1D""" amr=MEDCouplingCartesianAMRMesh("",1,[6],[0],[1]) @@ -3035,7 +3035,7 @@ class MEDCouplingBasicsTest5(unittest.TestCase): exp11=DataArrayDouble([61.03,61.03,62.03,62.03,62.03,63.03,63.03,63.03,64.03,64.03,64.03,65.03,65.03,61.03,61.03,62.03,62.03,62.03,63.03,63.03,63.03,64.03,64.03,64.03,65.03,65.03,75.03,75.03,76.03,76.03,76.03,77.03,77.03,77.03,78.03,78.03,78.03,79.03,79.03,75.03,75.03,76.03,76.03,76.03,77.03,77.03,77.03,78.03,78.03,78.03,79.03,79.03,75.03,75.03,76.03,76.03,76.03,77.03,77.03,77.03,78.03,78.03,78.03,79.03,79.03,89.03,89.03,90.03,90.03,90.03,91.03,91.03,91.03,92.03,92.03,92.03,93.03,93.03,89.03,89.03,90.03,90.03,90.03,91.03,91.03,91.03,92.03,92.03,92.03,93.03,93.03,89.03,89.03,90.03,90.03,90.03,91.03,91.03,91.03,92.03,92.03,92.03,93.03,93.03,103.03,103.03,104.03,104.03,104.03,105.03,105.03,105.03,106.03,106.03,106.03,107.03,107.03,103.03,103.03,104.03,104.03,104.03,105.03,105.03,105.03,106.03,106.03,106.03,107.03,107.03,103.03,103.03,104.03,104.03,104.03,105.03,105.03,105.03,106.03,106.03,106.03,107.03,107.03,117.03,117.03,118.03,118.03,118.03,119.03,119.03,119.03,120.03,120.03,120.03,121.03,121.03,117.03,117.03,118.03,118.03,118.03,119.03,119.03,119.03,120.03,120.03,120.03,121.03,121.03]) self.assertTrue(att3.getFieldOn(att3.getMyGodFather().getMeshAtPosition((1,3)),"YY").isEqualWithoutConsideringStr(exp11,1e-12)) del att3 - ### + ### att4.synchronizeAllGhostZonesAtASpecifiedLevel(2) for pos in [(),(0,),(1,),(2,)]: self.assertTrue(att4.getFieldOn(att4.getMyGodFather().getMeshAtPosition(pos),"YY").isEqual(att5.getFieldOn(att5.getMyGodFather().getMeshAtPosition(pos),"YY"),1e-12)) @@ -3173,7 +3173,7 @@ class MEDCouplingBasicsTest5(unittest.TestCase): self.assertTrue(att.getFieldOn(amr[1].getMesh(),"YY").isEqualWithoutConsideringStr(exp1,1e-12)) pass pass - + def testSwig2AMR14(self): """ non regression linked to VTHB write.""" fact=[2,2] ; fact2=[3,3] @@ -3314,7 +3314,7 @@ class MEDCouplingBasicsTest5(unittest.TestCase): m2.setConnectivity(conn2, connI2) # End of construction of input meshes m1bis and m2 -> start of specific part of the test - a,b,c,d = MEDCouplingUMesh.Intersect2DMeshWith1DLine(m1, m2, 1e-10) + a,b,c,d = MEDCouplingUMesh.Intersect2DMeshWith1DLine(m1, m2, 1e-10) self.assertTrue(a.getNodalConnectivity().isEqual(DataArrayInt([4,2,1,4,5,32,0,3,11,7,10,14,15,16,17,18,32,4,1,10,7,11,19,20,21,22,23]))) self.assertTrue(a.getNodalConnectivityIndex().isEqual(DataArrayInt([0,5,16,27]))) self.assertTrue(b.getNodalConnectivity().isEqual(DataArrayInt([1,6,10,1,10,7,2,7,11,12,2,11,8,13]))) @@ -3350,7 +3350,7 @@ class MEDCouplingBasicsTest5(unittest.TestCase): self.assertTrue(c.isEqual(DataArrayInt([0,0,0,0]))) self.assertTrue(d.isEqual(DataArrayInt([(-1,-1),(0,3),(-1,-1),(-1,-1),(1,3),(-1,-1),(-1,-1),(2,3),(-1,-1)]))) pass - + def testSwig2Intersect2DMeshWith1DLine8(self): """ Line pieces ending (or fully located) in the middle of a cell """ m1c = MEDCouplingCMesh() @@ -3411,7 +3411,7 @@ class MEDCouplingBasicsTest5(unittest.TestCase): m_circ = MEDCouplingDataForTest.buildCircle2(0.0, 0.0, 2.0) coords = [0.0,3.0,0.0,-3.0] connec = [0,1] - m_line = MEDCouplingUMesh("seg", 1) + m_line = MEDCouplingUMesh("seg", 1) m_line.allocateCells(1) meshCoords = DataArrayDouble.New(coords, len(coords)/2, 2) m_line.setCoords(meshCoords) @@ -3443,7 +3443,7 @@ class MEDCouplingBasicsTest5(unittest.TestCase): m.checkConsistencyLight() coords2 = [0., 1.3, -1.3, 0., -0.6, 0.6, 0., -1.3, -0.5, -0.5] connec2, cI2 = [NORM_SEG3, 0, 1, 2, NORM_SEG3, 1, 3, 4], [0,4,8] - m_line = MEDCouplingUMesh("seg", 1) + m_line = MEDCouplingUMesh("seg", 1) m_line.setCoords(DataArrayDouble(coords2, len(coords2)/2, 2)) m_line.setConnectivity(DataArrayInt(connec2), DataArrayInt(cI2)) a, b, c, d = MEDCouplingUMesh.Intersect2DMeshWith1DLine(m, m_line, eps) @@ -3472,7 +3472,7 @@ class MEDCouplingBasicsTest5(unittest.TestCase): m.checkConsistencyLight() coords2 = [-1., 0.25, 1., 0.25] connec2, cI2 = [NORM_SEG2, 0, 1], [0,3] - m_line = MEDCouplingUMesh.New("seg", 1) + m_line = MEDCouplingUMesh.New("seg", 1) m_line.setCoords(DataArrayDouble(coords2, len(coords2)/2, 2)) m_line.setConnectivity(DataArrayInt(connec2), DataArrayInt(cI2)) m_line2 = m_line.deepCopy() @@ -3497,9 +3497,9 @@ class MEDCouplingBasicsTest5(unittest.TestCase): m = MEDCouplingUMesh("boxcircle", 2) sq2 = math.sqrt(2.0) soth = (sq2+1.0)/2.0 - coo = [2., 0., sq2, sq2, 0., 2., -sq2, sq2, -2., 0., -sq2, -sq2, 0., -2., sq2, -sq2, -1., -1., -1., 1., 1., + coo = [2., 0., sq2, sq2, 0., 2., -sq2, sq2, -2., 0., -sq2, -sq2, 0., -2., sq2, -sq2, -1., -1., -1., 1., 1., 1., 1., -1., -1., 0., 0., 1., 1., 0., 0., -1., -soth, soth, soth,soth] - coo = DataArrayDouble(coo); coo.rearrange(2) + coo = DataArrayDouble(coo); coo.rearrange(2) m.setCoords(coo) c = [NORM_QPOLYG, 8, 9, 10, 11, 12, 13, 14, 15, NORM_QPOLYG, 3, 1, 10, 9, 2, 17, 13, 16, NORM_QPOLYG, 1, 7, 5, 3, 9, 8, 11, 10, 0, 6, 4, 16, 12, 15, 14, 17] cI = [0, 9, 18, 35] @@ -3507,7 +3507,7 @@ class MEDCouplingBasicsTest5(unittest.TestCase): m.checkConsistencyLight() coords2 = [-2., 1., 2., 1.0] connec2, cI2 = [NORM_SEG2, 0, 1], [0,3] - m_line = MEDCouplingUMesh("seg", 1) + m_line = MEDCouplingUMesh("seg", 1) m_line.setCoords(DataArrayDouble(coords2, len(coords2)/2, 2)) m_line.setConnectivity(DataArrayInt(connec2), DataArrayInt(cI2)) a, b, c, d = MEDCouplingUMesh.Intersect2DMeshWith1DLine(m, m_line, eps) @@ -3530,15 +3530,15 @@ class MEDCouplingBasicsTest5(unittest.TestCase): coo = [2.,0.,1.4142135623730951,1.414213562373095,0.,2.,-1.414213562373095,1.4142135623730951,-2.,0.,-1.4142135623730954,-1.414213562373095,0.,-2., 1.4142135623730947,-1.4142135623730954,1.,0.,0.7071067811865476,0.7071067811865475,0.,1.,-0.7071067811865475,0.7071067811865476,-1.,0.,-0.7071067811865477,-0.7071067811865475, 0.,-1.,0.7071067811865474,-0.7071067811865477,1.060660171779821,-1.0606601717798214,-1.0606601717798214,-1.0606601717798212] - coo = DataArrayDouble(coo); coo.rearrange(2) + coo = DataArrayDouble(coo); coo.rearrange(2) m.setCoords(coo) c = [NORM_QPOLYG, 15, 13, 11, 9, 14, 12, 10, 8, NORM_QPOLYG, 7, 5, 13, 15, 6, 17, 14, 16, NORM_QPOLYG, 5, 3, 1, 7, 15, 9, 11, 13, 4, 2, 0, 16, 8, 10, 12, 17] - cI = [0, 9, 18, 35] + cI = [0, 9, 18, 35] m.setConnectivity(DataArrayInt(c), DataArrayInt(cI)) m.checkConsistencyLight() coords2 = [-2., 0., 2., 0.] connec2, cI2 = [NORM_SEG2, 0, 1], [0,3] - m_line = MEDCouplingUMesh.New("seg", 1) + m_line = MEDCouplingUMesh.New("seg", 1) m_line.setCoords(DataArrayDouble(coords2, len(coords2)/2, 2)) m_line.setConnectivity(DataArrayInt(connec2), DataArrayInt(cI2)) a, b, c, d = MEDCouplingUMesh.Intersect2DMeshWith1DLine(m, m_line, eps) @@ -3561,9 +3561,9 @@ class MEDCouplingBasicsTest5(unittest.TestCase): m = MEDCouplingUMesh("boxcircle", 2) sq2 = math.sqrt(2.0) soth = (sq2+1.0)/2.0 - coo = [2., 0., sq2, sq2, 0., 2., -sq2, sq2, -2., 0., -sq2, -sq2, 0., -2., sq2, -sq2, -1., -1., -1., 1., 1., + coo = [2., 0., sq2, sq2, 0., 2., -sq2, sq2, -2., 0., -sq2, -sq2, 0., -2., sq2, -sq2, -1., -1., -1., 1., 1., 1., 1., -1., -1., 0., 0., 1., 1., 0., 0., -1., -soth, soth, soth,soth] - coo = DataArrayDouble(coo); coo.rearrange(2) + coo = DataArrayDouble(coo); coo.rearrange(2) m.setCoords(coo) c = [NORM_QPOLYG, 8, 9, 10, 11, 12, 13, 14, 15, NORM_QPOLYG, 3, 1, 10, 9, 2, 17, 13, 16, NORM_QPOLYG, 1, 7, 5, 3, 9, 8, 11, 10, 0, 6, 4, 16, 12, 15, 14, 17] cI = [0, 9, 18, 35] @@ -3571,7 +3571,7 @@ class MEDCouplingBasicsTest5(unittest.TestCase): m.checkConsistencyLight() coords2 = [(-2., 1.),(2.,1.),(0.,1)] connec2, cI2 = [NORM_SEG2, 0, 2, NORM_SEG2, 2, 1], [0,3,6] - m_line = MEDCouplingUMesh("seg", 1) + m_line = MEDCouplingUMesh("seg", 1) m_line.setCoords(DataArrayDouble(coords2)) m_line.setConnectivity(DataArrayInt(connec2), DataArrayInt(cI2)) a, b, c, d = MEDCouplingUMesh.Intersect2DMeshWith1DLine(m, m_line, eps) @@ -3594,9 +3594,9 @@ class MEDCouplingBasicsTest5(unittest.TestCase): m = MEDCouplingUMesh("boxcircle", 2) sq2 = math.sqrt(2.0) soth = (sq2+1.0)/2.0 - coo = [2., 0., sq2, sq2, 0., 2., -sq2, sq2, -2., 0., -sq2, -sq2, 0., -2., sq2, -sq2, -1., -1., -1., 1., 1., + coo = [2., 0., sq2, sq2, 0., 2., -sq2, sq2, -2., 0., -sq2, -sq2, 0., -2., sq2, -sq2, -1., -1., -1., 1., 1., 1., 1., -1., -1., 0., 0., 1., 1., 0., 0., -1., -soth, soth, soth,soth] - coo = DataArrayDouble(coo); coo.rearrange(2) + coo = DataArrayDouble(coo); coo.rearrange(2) m.setCoords(coo) c = [NORM_QPOLYG, 8, 9, 10, 11, 12, 13, 14, 15, NORM_QPOLYG, 3, 1, 10, 9, 2, 17, 13, 16, NORM_QPOLYG, 1, 7, 5, 3, 9, 8, 11, 10, 0, 6, 4, 16, 12, 15, 14, 17] cI = [0, 9, 18, 35] @@ -3604,7 +3604,7 @@ class MEDCouplingBasicsTest5(unittest.TestCase): m.checkConsistencyLight() coords2 = [1., 2., 1., -2.] connec2, cI2 = [NORM_SEG2, 0, 1], [0,3] - m_line = MEDCouplingUMesh("seg", 1) + m_line = MEDCouplingUMesh("seg", 1) m_line.setCoords(DataArrayDouble(coords2, len(coords2)/2, 2)) m_line.setConnectivity(DataArrayInt(connec2), DataArrayInt(cI2)) a, b, c, d = MEDCouplingUMesh.Intersect2DMeshWith1DLine(m, m_line, eps) @@ -3632,21 +3632,21 @@ class MEDCouplingBasicsTest5(unittest.TestCase): m2.setCoords(coords2); m2.setConnectivity(c, cI); m2.checkConsistency(1.0e-8); - + # Shuffle a bit :-) m2.renumberCells(DataArrayInt([0,3,6,8,1,4,7,5,2]), True); res = m2.orderConsecutiveCells1D() expRes = [0,3,6,8,1,4,2,7,5] self.assertEqual(m2.getNumberOfCells(),res.getNumberOfTuples()) self.assertEqual(expRes, res.getValues()) - + # A closed line (should also work) m3 = MEDCouplingUMesh.New("bla3", 1) conn3A = DataArrayInt([NORM_SEG2,0,1,NORM_SEG3,1,3,2, NORM_SEG2,3,0]) coord3 = coords2[0:5] c.reAlloc(10) cI.reAlloc(4) - + m3.setCoords(coord3) m3.setConnectivity(conn3A, cI) m3.checkConsistency(1.0e-8) @@ -4085,7 +4085,7 @@ class MEDCouplingBasicsTest5(unittest.TestCase): self.assertAlmostEqual(m.computeDiameterField().getArray()[0],exp5,12) m2=m.buildUnstructured() ; m2.convertLinearCellsToQuadratic(0) self.assertAlmostEqual(m2.computeDiameterField().getArray()[0],exp5,12) - # PYRA5 (1) 5th node is further + # PYRA5 (1) 5th node is further # noise of coo=DataArrayDouble([(0,0,0),(1,0,0),(1,1,0),(0,1,0),(0.5,0.5,2)]) + rotation([0.7,-1.2,0.6],[-4,-1,10],0.3) coo=DataArrayDouble([(-0.31638393672228626,-0.3157865246451914,-0.12555467233075002),(0.7281379795666488,0.03836511217237115,-0.08431662762197323),(0.4757967840735147,0.8798897996143908,-0.2680890320119049),(-0.5386339871809047,0.5933159894201252,-0.2975311238319419),(0.012042592988768974,0.534282135495012,1.7859521682027926)]) m=MEDCoupling1SGTUMesh("mesh",NORM_PYRA5) ; m.setCoords(coo) @@ -4138,19 +4138,19 @@ class MEDCouplingBasicsTest5(unittest.TestCase): self.assertEqual( 0, sla0.getLength() ) sla0.set( index, value ) self.assertTrue( index.isEqual( sla0.getIndexArray() )) - self.assertTrue( value.isEqual( sla0.getValueArray() )) + self.assertTrue( value.isEqual( sla0.getValuesArray() )) self.assertEqual( 4, sla0.getNumberOf() ) self.assertEqual( 6, sla0.getLength() ) sla1 = MEDCouplingSkyLineArray( index, value ) self.assertTrue( index.isEqual( sla1.getIndexArray() )) - self.assertTrue( value.isEqual( sla1.getValueArray() )) + self.assertTrue( value.isEqual( sla1.getValuesArray() )) self.assertEqual( 4, sla1.getNumberOf() ) self.assertEqual( 6, sla1.getLength() ) sla2 = MEDCouplingSkyLineArray( sla1 ) self.assertTrue( index.isEqual( sla2.getIndexArray() )) - self.assertTrue( value.isEqual( sla2.getValueArray() )) + self.assertTrue( value.isEqual( sla2.getValuesArray() )) self.assertEqual( 4, sla2.getNumberOf() ) self.assertEqual( 6, sla2.getLength() ) @@ -4160,12 +4160,12 @@ class MEDCouplingBasicsTest5(unittest.TestCase): for i in value: valueVec.push_back( i[0] ) sla3 = MEDCouplingSkyLineArray( indexVec, valueVec ) self.assertTrue( index.isEqual( sla3.getIndexArray() )) - self.assertTrue( value.isEqual( sla3.getValueArray() )) + self.assertTrue( value.isEqual( sla3.getValuesArray() )) self.assertEqual( 4, sla3.getNumberOf() ) self.assertEqual( 6, sla3.getLength() ) pass - + def testMEDCouplingUMeshgenerateGraph(self): # cartesian mesh 3x3 arr=DataArrayDouble(4) ; arr.iota() @@ -4184,7 +4184,7 @@ class MEDCouplingBasicsTest5(unittest.TestCase): 3,6,7, 4,6,7,8, 5,7,8] - self.assertEqual(valRef,list(graph.getValueArray().getValues())); + self.assertEqual(valRef,list(graph.getValuesArray().getValues())); indRef=[0, 3, 7, 10, 14, 19, 23, 26, 30, 33] self.assertEqual(indRef,list(graph.getIndexArray().getValues())); @@ -4567,6 +4567,375 @@ class MEDCouplingBasicsTest5(unittest.TestCase): d4=DataArrayInt([2,4,6]) ; d4.setName("toto") ; d4.setInfoOnComponents(["b"]) self.assertTrue(d4.isEqual(d2[1])) pass + + def testVoronoi2D_1(self): + """ Check of voronize on 2D mesh method of MEDCouplingFieldDouble that converts field on Gauss Points to a field on cell""" + tmp=MEDCouplingCMesh("mesh") + arr=DataArrayDouble(5) ; arr.iota() + tmp.setCoords(arr,arr) + tmp=tmp.build1SGTUnstructured() + conn=tmp.getNodalConnectivity() + conn.rearrange(4) + conn.reversePerTuple() + conn.circularPermutationPerTuple(2) + conn.rearrange(1) + coo=tmp.getCoords().deepCopy() + coo.circularPermutationPerTuple(2) ; coo*=0.1 + coo.reverse() + coo2=DataArrayDouble(len(tmp.getCoords())*tmp.getSpaceDimension()) ; coo2.iota() ; coo2.rearrange(tmp.getSpaceDimension()) + coo2*=0.14 + coo2.circularPermutationPerTuple(2) + tmp.getCoords()[:]+=coo2*coo + # + field=MEDCouplingFieldDouble(ON_GAUSS_PT) + field.setName("MyFieldPG") ; field.setMesh(tmp) + field.setGaussLocalizationOnType(NORM_QUAD4,[-1.,-1.,1.,-1.,1.,1.,-1.,1.],[0.8,-0.8, 0.8,0.8, -0.8,0.8, -0.8,-0.8, 0.,0., 0.2,0.2, 0.1,0.3],[0.1,0.1,0.1,0.1,0.1,0.1,0.4]) + arr=DataArrayDouble(field.getNumberOfTuplesExpected()) ; arr.iota() + field.setArray(arr) + field.checkConsistencyLight() + #### + fieldOnCell=field.voronoize(1e-12) # hot point + fieldOnCell.checkConsistencyLight() + self.assertEqual(fieldOnCell.getMesh().getNumberOfCells(),112) + self.assertEqual(fieldOnCell.getMesh().getNumberOfNodes(),256) + self.assertTrue(fieldOnCell.getArray().isEqual(field.getArray(),1e-12)) + meaRef=field.getMesh().getMeasureField(True).getArray() + mea=fieldOnCell.getMesh().getMeasureField(True).getArray() + self.assertEqual(field.getDiscretization().getNbOfGaussLocalization(),1) + self.assertEqual(field.getDiscretization().getGaussLocalization(0).getNumberOfGaussPt(),7) + mea.rearrange(7) + mea2=mea.sumPerTuple() + self.assertTrue(mea2.isEqual(meaRef,1e-12)) + pass + + def testVoronoi2D_2(self): + """More aggressive 2D test. No warping here. To check data""" + tmp=MEDCouplingCMesh("mesh") + arr=DataArrayDouble([-1.,1.]) + tmp.setCoords(arr,arr) + tmp=tmp.buildUnstructured() + field=MEDCouplingFieldDouble(ON_GAUSS_PT) + field.setName("MyFieldPG") ; field.setMesh(tmp) + field.setGaussLocalizationOnType(NORM_QUAD4,[-1.,-1.,1.,-1.,1.,1.,-1.,1.],[0.8,-0.8, 0.8,0.8, -0.8,0.8, -0.8,-0.8, 0.,0., 0.2,0.2, 0.1,0.3],[0.1,0.1,0.1,0.1,0.1,0.1,0.4]) + arr=DataArrayDouble(field.getNumberOfTuplesExpected()) ; arr.iota() + field.setArray(arr) + field.checkConsistencyLight() + # + fieldOnCell=field.voronoize(1e-12) # hot point + fieldOnCell.checkConsistencyLight() + self.assertEqual(fieldOnCell.getMesh().getNumberOfCells(),7) + self.assertEqual(fieldOnCell.getMesh().getNumberOfNodes(),16) + self.assertTrue(fieldOnCell.getArray().isEqual(field.getArray(),1e-12)) + meaRef=DataArrayDouble([0.65,0.4710714285714285,0.59875,0.68,0.73875,0.4,0.46142857142857235]) + mea=fieldOnCell.getMesh().getMeasureField(True).getArray() + self.assertTrue(mea.isEqual(meaRef,1e-12))# the first important test is here + self.assertEqual(field.getDiscretization().getNbOfGaussLocalization(),1) + self.assertEqual(field.getDiscretization().getGaussLocalization(0).getNumberOfGaussPt(),7) + # + gsPt=field.getLocalizationOfDiscr() + a,b=fieldOnCell.getMesh().getCellsContainingPoints(gsPt,1e-12) + self.assertTrue(a.isIota(7))# the second important test is here ! Check that Gauss points are inside the associated cell in fieldOnCell ! + self.assertTrue(b.isIota(8)) + # + self.assertEqual(fieldOnCell.getMesh().buildDescendingConnectivity()[0].getNumberOfCells(),22)# last little test to reduce chance of errors. For humans there 21 but last tiny edge is split into 2 subedges due to alg + pass + + def testVoronoi3D_1(self): + """ Check of voronize on 3D mesh method of MEDCouplingFieldDouble that converts field on Gauss Points to a field on cell""" + tmp=MEDCouplingCMesh("mesh") + arr=DataArrayDouble(5) ; arr.iota() + tmp.setCoords(arr,arr) + tmp=tmp.build1SGTUnstructured() + conn=tmp.getNodalConnectivity() + conn.rearrange(4) + conn.reversePerTuple() + conn.circularPermutationPerTuple(2) + conn.rearrange(1) + coo=tmp.getCoords().deepCopy() + coo.circularPermutationPerTuple(2) ; coo*=0.1 + coo.reverse() + coo2=DataArrayDouble(len(tmp.getCoords())*tmp.getSpaceDimension()) ; coo2.iota() ; coo2.rearrange(tmp.getSpaceDimension()) + coo2*=0.14 + coo2.circularPermutationPerTuple(2) + tmp.getCoords()[:]+=coo2*coo + # + tmp.changeSpaceDimension(3,0.) + # + arrZ=DataArrayDouble(5) ; arrZ.iota() + mz=MEDCouplingCMesh() ; mz.setCoords(arrZ) ; mz=mz.buildUnstructured() + mz.changeSpaceDimension(3,0.) + mz.getCoords().circularPermutationPerTuple(1) + tmp=tmp.buildUnstructured().buildExtrudedMesh(mz,0) + # + field=MEDCouplingFieldDouble(ON_GAUSS_PT) + field.setName("MyFieldPG") ; field.setMesh(tmp) + field.setGaussLocalizationOnType(NORM_HEXA8,[-1,-1,-1, 1,-1,-1, 1,1,-1, -1,1,-1, -1,-1,1, 1,-1,1, 1,1,1, -1,1,1],[0.8,-0.8,0., 0.8,0.8,0., -0.8,0.8,0., -0.8,-0.8,0., 0.,0.,0., 0.2,0.2,0., 0.1,0.3,0.],[0.1,0.1,0.1,0.1,0.1,0.1,0.4]) + arr=DataArrayDouble(field.getNumberOfTuplesExpected()) ; arr.iota() + field.setArray(arr) + field.checkConsistencyLight() + #### + fieldOnCell=field.voronoize(1e-12) # hot point + fieldOnCell.checkConsistencyLight() + self.assertTrue(fieldOnCell.getArray().isEqual(field.getArray(),1e-12)) + meaRef=field.getMesh().getMeasureField(True).getArray() + mea=fieldOnCell.getMesh().getMeasureField(False).getArray() + self.assertEqual(field.getDiscretization().getNbOfGaussLocalization(),1) + self.assertEqual(field.getDiscretization().getGaussLocalization(0).getNumberOfGaussPt(),7) + mea.rearrange(7) + mea2=mea.sumPerTuple() + delta=(meaRef-mea2) + delta.abs() + delta/=meaRef + self.assertEqual(len(delta.findIdsNotInRange(0,1e-2)),0) # 1e-2 because hexa8 are warped ! + pass + + def testVoronoi3D_2(self): + """More aggressive 3D test. No warping here. To check data""" + tmp=MEDCouplingCMesh("mesh") + arr=DataArrayDouble([-1.,1.]) + tmp.setCoords(arr,arr,arr) + tmp=tmp.buildUnstructured() + field=MEDCouplingFieldDouble(ON_GAUSS_PT) + field.setName("MyFieldPG") ; field.setMesh(tmp) + field.setGaussLocalizationOnType(NORM_HEXA8,[-1,-1,-1, 1,-1,-1, 1,1,-1, -1,1,-1, -1,-1,1, 1,-1,1, 1,1,1, -1,1,1],[0.8,-0.8,0., 0.8,0.8,0., -0.8,0.8,0., -0.8,-0.8,0., 0.,0.,0., 0.2,0.2,0., 0.1,0.3,0.],[0.1,0.1,0.1,0.1,0.1,0.1,0.4]) + arr=DataArrayDouble(field.getNumberOfTuplesExpected()) ; arr.iota() + field.setArray(arr) + field.checkConsistencyLight() + # + fieldOnCell=field.voronoize(1e-12) # hot point + fieldOnCell.checkConsistencyLight() + self.assertEqual(fieldOnCell.getMesh().getNumberOfCells(),7) + self.assertEqual(fieldOnCell.getMesh().getNumberOfNodes(),34) + self.assertTrue(fieldOnCell.getArray().isEqual(field.getArray(),1e-12)) + meaRef=DataArrayDouble([1.3,0.9421428571428572,1.1975,1.36,1.4775,0.8,0.922857142857143]) + mea=fieldOnCell.getMesh().getMeasureField(True).getArray() + self.assertTrue(mea.isEqual(meaRef,1e-12))# the first important test is here + self.assertEqual(field.getDiscretization().getNbOfGaussLocalization(),1) + self.assertEqual(field.getDiscretization().getGaussLocalization(0).getNumberOfGaussPt(),7) + # + gsPt=field.getLocalizationOfDiscr() + a,b=fieldOnCell.getMesh().getCellsContainingPoints(gsPt,1e-12) + self.assertTrue(a.isIota(7))# the second important test is here ! Check that Gauss points are inside the associated cell in fieldOnCell ! + self.assertTrue(b.isIota(8)) + # + self.assertEqual(fieldOnCell.getMesh().buildDescendingConnectivity()[0].getNumberOfCells(),2*7+21) + pass + + def testVoronoi3DSurf_1(self): + tmp=MEDCouplingCMesh("mesh") + arr=DataArrayDouble(5) ; arr.iota() + tmp.setCoords(arr,arr) + tmp=tmp.build1SGTUnstructured() + conn=tmp.getNodalConnectivity() + conn.rearrange(4) + conn.reversePerTuple() + conn.circularPermutationPerTuple(2) + conn.rearrange(1) + coo=tmp.getCoords().deepCopy() + coo.circularPermutationPerTuple(2) ; coo*=0.1 + coo.reverse() + coo2=DataArrayDouble(len(tmp.getCoords())*tmp.getSpaceDimension()) ; coo2.iota() ; coo2.rearrange(tmp.getSpaceDimension()) + coo2*=0.14 + coo2.circularPermutationPerTuple(2) + tmp.getCoords()[:]+=coo2*coo + # + tmp.changeSpaceDimension(3,0.) # force 3D surf + tmp.rotate([0,0,0],[1,0,0],pi/3) # force 3D surf + # + field=MEDCouplingFieldDouble(ON_GAUSS_PT) + field.setName("MyFieldPG") ; field.setMesh(tmp) + field.setGaussLocalizationOnType(NORM_QUAD4,[-1.,-1.,1.,-1.,1.,1.,-1.,1.],[0.8,-0.8, 0.8,0.8, -0.8,0.8, -0.8,-0.8, 0.,0., 0.2,0.2, 0.1,0.3],[0.1,0.1,0.1,0.1,0.1,0.1,0.4]) + arr=DataArrayDouble(field.getNumberOfTuplesExpected()) ; arr.iota() + field.setArray(arr) + field.checkConsistencyLight() + ##### + fieldOnCell=field.voronoize(1e-12); + fieldOnCell.checkConsistencyLight() + self.assertEqual(fieldOnCell.getMesh().getSpaceDimension(),3) + self.assertEqual(fieldOnCell.getMesh().getMeshDimension(),2) + self.assertEqual(field.getMesh().getSpaceDimension(),fieldOnCell.getMesh().getSpaceDimension()) + self.assertTrue(fieldOnCell.getArray().isEqual(field.getArray(),1e-12)) + meaRef=field.getMesh().getMeasureField(True).getArray() + mea=fieldOnCell.getMesh().getMeasureField(True).getArray() + self.assertEqual(field.getDiscretization().getNbOfGaussLocalization(),1) + self.assertEqual(field.getDiscretization().getGaussLocalization(0).getNumberOfGaussPt(),7) + mea.rearrange(7) + mea2=mea.sumPerTuple() + self.assertTrue(mea2.isEqual(meaRef,1e-12)) + pass + + def testVoronoi1D_1(self): + tmp=MEDCouplingCMesh("mesh") + arr=DataArrayDouble(5) ; arr.iota() + tmp.setCoords(arr) + tmp=tmp.build1SGTUnstructured() + tmp1=tmp.deepCopy() + tmp.changeSpaceDimension(2,0.) + tmp.getCoords()[:,1]=pi/(len(arr)-1)*tmp.getCoords()[:,0] + tmp.getCoords()[:,0]=1. + tmp.setCoords(tmp.getCoords().fromPolarToCart()) + tmp.changeSpaceDimension(3,1.) + # + field=MEDCouplingFieldDouble(ON_GAUSS_PT) + field.setName("MyFieldPG") ; field.setMesh(tmp) + field.setGaussLocalizationOnType(NORM_SEG2,[-1.,1.],[-0.9,-0.8,0.2,0.4,0.5,0.9],[0.1,0.1,0.1,0.1,0.1,0.5]) + arr=DataArrayDouble(field.getNumberOfTuplesExpected()) ; arr.iota() + field.setArray(arr) + field.checkConsistencyLight() + #### + fieldOnCell=field.voronoize(1e-12); + fieldOnCell.checkConsistencyLight() + self.assertEqual(fieldOnCell.getMesh().getSpaceDimension(),3) + self.assertEqual(fieldOnCell.getMesh().getMeshDimension(),1) + assert(fieldOnCell.getArray().isEqual(field.getArray(),1e-12)) + meaRef=field.getMesh().getMeasureField(True).getArray() + mea=fieldOnCell.getMesh().getMeasureField(True).getArray() + self.assertEqual(field.getDiscretization().getNbOfGaussLocalization(),1) + self.assertEqual(field.getDiscretization().getGaussLocalization(0).getNumberOfGaussPt(),6) + mea.rearrange(6) + mea2=mea.sumPerTuple() + self.assertTrue(mea2.isEqual(meaRef,1e-12)) + pass + + def testFieldDoubleConvertToLinear1(self): + da=DataArrayDouble([0,0, 1,0, 2,0, 3,0, 0.5,0, 1.5,0, 2.5,0, 0,0.5, 0.5,0.5, 1, 0.5, 1.5,0.5, 2,0.5, 3,0.5, 0,1, 1,1, 2,1, 2.5,1, 3,1],18,2) + da.setInfoOnComponents(["g","h"]) + m=MEDCouplingUMesh("mesh",2) + m.setCoords(da) + m.allocateCells() + m.insertNextCell(NORM_TRI6,[0,1,13,4,9,7]) + m.insertNextCell(NORM_TRI6,[1,2,14,5,10,9]) + m.insertNextCell(NORM_QUAD8,[2,3,17,15,6,12,16,11]) + refPtr=m.getHiddenCppPointer() + f=MEDCouplingFieldDouble(ON_NODES) + f.setName("aa") + f.setMesh(m) + arr=DataArrayDouble(18*2) ; arr.iota() + arr.rearrange(2) + arr.setInfoOnComponents(["bb","ccc"]) + f.setArray(arr) + f.setTime(0.5,2,3) + f.checkConsistencyLight() + # + f1=f.convertQuadraticCellsToLinear() + self.assertTrue(f.getMesh().getHiddenCppPointer(),refPtr) + self.assertTrue(f1.getMesh().getHiddenCppPointer()!=refPtr) + f1.checkConsistencyLight() + self.assertEqual(f1.getName(),"aa") + self.assertEqual(f1.getTypeOfField(),ON_NODES) + da0=DataArrayDouble([(0,0),(1,0),(2,0),(3,0),(0,1),(1,1),(2,1),(3,1)]) + da0.setInfoOnComponents(["g","h"]) + self.assertTrue(f1.getMesh().getCoords().isEqual(da0,1e-12)) + self.assertTrue(f1.getMesh().getNodalConnectivity().isEqual(DataArrayInt([3,0,1,4,3,1,2,5,4,2,3,7,6]))) + self.assertTrue(f1.getMesh().getNodalConnectivityIndex().isEqual(DataArrayInt([0,4,8,13]))) + da2=DataArrayDouble([(0,1),(2,3),(4,5),(6,7),(26,27),(28,29),(30,31),(34,35)]) + da2.setInfoOnComponents(["bb","ccc"]) + self.assertTrue(f1.getArray().isEqual(da2,1e-12)) + self.assertEqual(f1.getTime(),[0.5,2,3]) + # + f2=MEDCouplingFieldDouble(ON_CELLS) + f2.setName("aa") + f2.setMesh(m) + arr=DataArrayDouble(3*2) ; arr.iota() + arr.rearrange(2) + arr.setInfoOnComponents(["bb","ccc"]) + f2.setArray(arr) + f2.setTime(0.5,2,3) + f2.checkConsistencyLight() + f3=f2.convertQuadraticCellsToLinear() + self.assertEqual(f2.getMesh().getHiddenCppPointer(),refPtr) + f3.checkConsistencyLight() + self.assertTrue(f3.getMesh().getHiddenCppPointer()!=refPtr) + self.assertTrue(f3.getMesh().getCoords().isEqual(da0,1e-12)) + self.assertTrue(f3.getMesh().getNodalConnectivity().isEqual(DataArrayInt([3,0,1,4,3,1,2,5,4,2,3,7,6]))) + self.assertTrue(f3.getMesh().getNodalConnectivityIndex().isEqual(DataArrayInt([0,4,8,13]))) + self.assertEqual(f2.getArray().getHiddenCppPointer(),f3.getArray().getHiddenCppPointer()) + self.assertEqual(f3.getTime(),[0.5,2,3]) + pass + + def testBuild1DMeshFromCoords1(self): + da=DataArrayDouble([(3,4),(5,6),(7,8)]) + da.setName("ZeArr") + da0=da.deepCopy() + m=MEDCouplingUMesh.Build1DMeshFromCoords(da0) + m.checkConsistencyLight() + self.assertEqual(da0.getHiddenCppPointer(),m.getCoords().getHiddenCppPointer()) + self.assertTrue(da.isEqual(da0,1e-12)) + self.assertEqual(m.getName(),da.getName()) + self.assertEqual(m.getMeshDimension(),1) + self.assertTrue(isinstance(m,MEDCouplingUMesh)) + m1=MEDCoupling1SGTUMesh(m) + m1.checkConsistencyLight() + self.assertTrue(m1.getNodalConnectivity().isEqual(DataArrayInt([0,1,1,2]))) + # + da0.setName("") + m2=MEDCouplingUMesh.Build1DMeshFromCoords(da0) + m2.checkConsistencyLight() + self.assertEqual(da0.getHiddenCppPointer(),m2.getCoords().getHiddenCppPointer()) + self.assertEqual(m2.getName(),"Mesh") + pass + + def testVoronoi3D_3(self): + """Non regression test to check MEDCouplingUMesh::clipSingle3DCellByPlane""" + coo=DataArrayDouble([0.,1.,0.,0.,0.,0.,0.,0.,1.,1.,0.,0.],4,3) + m=MEDCouplingUMesh("mesh",3) + m.setCoords(coo) ; m.allocateCells() + m.insertNextCell(NORM_TETRA4,[0,2,3,1]) + f=MEDCouplingFieldDouble(ON_GAUSS_PT) + f.setMesh(m) ; f.setName("field") + f.setGaussLocalizationOnType(NORM_TETRA4,[0.,1.,0.,0.,0.,0.,0.,0.,1.,1.,0.,0.],[0.1381966011250105, 0.1381966011250105, 0.1381966011250105, 0.1381966011250105, 0.1381966011250105, 0.5854101966249685, 0.1381966011250105, 0.5854101966249685, 0.1381966011250105, 0.5854101966249685, 0.1381966011250105, 0.1381966011250105], [0.041667,0.041667,0.041667,0.041667]) + f.setArray(DataArrayDouble([0,1,2,3])) + f3=f.voronoize(1e-12) + ref=DataArrayDouble([0.047256836610416179,0.03980327668541684,0.039803276685416833,0.039803276685416833]) + self.assertTrue(f3.getMesh().getMeasureField(False).getArray().isEqual(ref,1e-12)) + self.assertTrue(f3.getArray().isEqual(DataArrayDouble([0,1,2,3]),1e-12)) + pass + + def testVoronoi3D_4(self): + """Idem testVoronoi3D_3 except that here quadratic cells are considered""" + coo=DataArrayDouble([0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,0.0,0.0,0.0,0.5,0.0,0.0,0.0,0.5,0.0,0.5,0.5,0.5,0.5,0.0,0.5,0.0,0.0,0.5,0.0,0.5],10,3) + m=MEDCouplingUMesh("mesh",3) + m.setCoords(coo) ; m.allocateCells() + m.insertNextCell(NORM_TETRA10,[0,1,2,3,4,5,6,7,8,9]) + f=MEDCouplingFieldDouble(ON_GAUSS_PT) + f.setMesh(m) ; f.setName("field") + f.setGaussLocalizationOnType(NORM_TETRA10,[0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,0.0,0.0,0.0,0.5,0.0,0.0,0.0,0.5,0.0,0.5,0.5,0.5,0.5,0.0,0.5,0.0,0.0,0.5,0.0,0.5],[0.1381966011250105, 0.1381966011250105, 0.1381966011250105, 0.1381966011250105, 0.1381966011250105, 0.5854101966249685, 0.1381966011250105, 0.5854101966249685, 0.1381966011250105, 0.5854101966249685, 0.1381966011250105, 0.1381966011250105], [0.041667,0.041667,0.041667,0.041667]) + f.setArray(DataArrayDouble([0,1,2,3])) + f3=f.voronoize(1e-12) + ref=DataArrayDouble([0.047256836610416179,0.03980327668541684,0.039803276685416833,0.039803276685416833]) + self.assertTrue(f3.getMesh().getMeasureField(False).getArray().isEqual(ref,1e-12)) + self.assertTrue(f3.getArray().isEqual(DataArrayDouble([0,1,2,3]),1e-12)) + pass + + def testConvertQuadToLin4Gauss_1(self): + coo=DataArrayDouble([0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,0.0,0.0,0.0,0.5,0.0,0.0,0.0,0.5,0.0,0.5,0.5,0.5,0.5,0.0,0.5,0.0,0.0,0.5,0.0,0.5],10,3) + m=MEDCouplingUMesh("mesh",3) + m.setCoords(coo) ; m.allocateCells() + m.insertNextCell(NORM_TETRA10,[0,1,2,3,4,5,6,7,8,9]) + f=MEDCouplingFieldDouble(ON_GAUSS_PT) + f.setMesh(m) ; f.setName("field") + aaaa=[0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,0.0,0.0,0.0,0.5,0.0,0.0,0.0,0.5,0.0,0.5,0.5,0.5,0.5,0.0,0.5,0.0,0.0,0.5,0.0,0.5] + bbbb=[0.1381966011250105,0.1381966011250105,0.1381966011250105,0.1381966011250105,0.1381966011250105,0.5854101966249685,0.1381966011250105,0.5854101966249685,0.1381966011250105,0.5854101966249685,0.1381966011250105,0.1381966011250105] + cccc=[0.041667,0.041667,0.041667,0.041667] + f.setGaussLocalizationOnType(NORM_TETRA10,aaaa,bbbb,cccc) + f.setArray(DataArrayDouble([0,1,2,3])) + f.setTime(1.,2,3) + # + mcpy=m.deepCopy() ; mcpy.convertQuadraticCellsToLinear() ; mcpy.zipCoords() + # + f2=f.convertQuadraticCellsToLinear() + f2.checkConsistencyLight() + self.assertTrue(f2.getMesh().isEqual(mcpy,1e-12)) + self.assertTrue(f2.getArray().isEqual(DataArrayDouble([0,1,2,3]),1e-12)) + self.assertEqual(f2.getNbOfGaussLocalization(),1) + gl=f2.getGaussLocalization(0) + self.assertEqual(gl.getType(),NORM_TETRA4) + self.assertTrue(DataArrayDouble(gl.getRefCoords()).isEqual(DataArrayDouble([0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,0.0,0.0]),1e-12)) + self.assertTrue(DataArrayDouble(gl.getGaussCoords()).isEqual(DataArrayDouble(bbbb),1e-12)) + self.assertTrue(DataArrayDouble(gl.getWeights()).isEqual(DataArrayDouble(cccc),1e-12)) + self.assertEqual(f2.getName(),"field") + self.assertEqual(f2.getTime(),[1.,2,3]) + pass pass