+
+ @WriteInTmpDir
+ def test35(self):
+ """ Emulate MEDReader in // mode context. Here a Simple mesh having more nodes than really needed. This test focuses on that point particularly."""
+ fname="ForMEDReader35.med"
+ arrX=DataArrayDouble(7) ; arrX.iota()
+ arrY=DataArrayDouble([0.,1.])
+ m=MEDCouplingCMesh() ; m.setCoords(arrX,arrY) ; m=m.buildUnstructured() ; m=m[[0,5,1,4,2,3]] ; m.changeSpaceDimension(3,0.) ; m.setName("Mesh")
+ f=MEDCouplingFieldDouble(ON_CELLS) ; f.setMesh(m) ; f.setName("Field") ; f.setArray(DataArrayDouble([(0.1,1.1),(2.1,3.1),(4.1,5.1),(6.1,7.1),(8.1,9.1),(10.1,11.1)])) ; f.getArray().setInfoOnComponents(["aa","bbb"])
+ WriteUMesh(fname,m,True)
+ WriteFieldUsingAlreadyWrittenMesh(fname,f)
+ ########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values
+ ms=MEDFileMeshes() # here we reproduce what is done by ParaMEDFileMeshes.ParaNew
+ ms.pushMesh(MEDFileUMesh.LoadPartOf(fname,"Mesh",[NORM_QUAD4],[0,2,1],-1,-1));
+ ms[0].zipCoords()
+ ms.cartesianizeMe()
+ #
+ fields=MEDFileFields.LoadPartOf(fname,False,ms);
+ fields.removeFieldsWithoutAnyTimeStep()
+ fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()]
+ allFMTSLeavesToDisplay=[]
+ for fields in fields_per_mesh:
+ allFMTSLeavesToDisplay2=[]
+ for fmts in fields:
+ tmp=fmts.splitDiscretizations()
+ for itmp in tmp:
+ if itmp.presenceOfMultiDiscPerGeoType():
+ tmp2=itmp.splitMultiDiscrPerGeoTypes()
+ for iii,itmp2 in enumerate(tmp2):
+ name="%s_%i"%(itmp2.getName(),iii)
+ itmp2.setName(name)
+ allFMTSLeavesToDisplay2.append(itmp2)
+ pass
+ pass
+ else:
+ allFMTSLeavesToDisplay2.append(itmp)
+ pass
+ pass
+ allFMTSLeavesToDisplay.append(allFMTSLeavesToDisplay2)
+ pass
+ #
+ self.assertEqual(len(allFMTSLeavesToDisplay),1)
+ self.assertEqual(len(allFMTSLeavesToDisplay[0]),1)
+ allFMTSLeavesPerTimeSeries=MEDFileAnyTypeFieldMultiTS.SplitIntoCommonTimeSeries(sum(allFMTSLeavesToDisplay,[]))
+ self.assertEqual(len(allFMTSLeavesPerTimeSeries),1) # one time serie here : because the 2 fields are defined on the same time steps
+ self.assertEqual(len(allFMTSLeavesPerTimeSeries[0]),1)
+ allFMTSLeavesPerCommonSupport=MEDFileAnyTypeFieldMultiTS.SplitPerCommonSupport(allFMTSLeavesPerTimeSeries[0],ms[ms.getMeshesNames()[0]])
+ self.assertEqual(len(allFMTSLeavesPerCommonSupport),1)
+ self.assertEqual(len(allFMTSLeavesPerCommonSupport[0][0]),1)
+ #
+ mst=MEDFileMeshStruct.New(ms[0])
+ #
+ fcscp=allFMTSLeavesPerCommonSupport[0][1]
+ mml=fcscp.buildFromScratchDataSetSupport(0,fields)
+ mml2=mml.prepare()
+ self.assertTrue(isinstance(mml2,MEDUMeshMultiLev))
+ ncc,a0,a1,a2,a3,a4,a5=mml2.buildVTUArrays()
+ self.assertTrue(ncc)
+ self.assertTrue(a0.isEqual(m.getCoords()[[0,1,5,6,7,8,12,13]],1e-12))# <- the aim of the test
+ self.assertTrue(a1.isEqual(DataArrayByte([9,9])))
+ self.assertTrue(a2.isEqual(DataArrayInt([0,5])))
+ self.assertTrue(a3.isEqual(DataArrayInt([4,1,0,4,5,4,3,2,6,7])))
+ self.assertTrue(a4 is None)
+ self.assertTrue(a5 is None)
+ self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny().isEqual(DataArrayInt([0,1,5,6,7,8,12,13])))
+ f2=allFMTSLeavesPerCommonSupport[0][0][0][0]
+ fsst=MEDFileField1TSStructItem.BuildItemFrom(f2,mst)
+ f2.loadArraysIfNecessary()
+ v=mml.buildDataArray(fsst,fields,f2.getUndergroundDataArray())
+ self.assertEqual(f2.getName(),f.getName())
+ vExp=DataArrayDouble([(0.1,1.1),(2.1,3.1)])
+ vExp.setInfoOnComponents(['aa','bbb'])
+ self.assertTrue(v.isEqual(vExp,1e-12))
+ pass
+
+ @WriteInTmpDir
+ def test36(self):
+ """Bug EDF11027. Here mesh at level 0 (TRI3) does not fetch all the nodes. Level -1 (SEG2) does not fetch all the nodes neither. But all TRI3 + all SEG2 fetch all nodes.
+ aaa field on GAUSSPoints lying only on TRI3 share the same support than profile node field ccc.
+ But bbb field on all nodes is not on the same support. Past optimization that make the assumtion a support on all lev0 cells lies on all nodes is now over."""
+ meshName="mesh"
+ fname="ForMEDReader36.med"
+ c=DataArrayDouble([(0,0),(1,0),(1,1),(0,1),(2,0),(-1,0),(1,2)])
+ m0=MEDCoupling1SGTUMesh(meshName,NORM_TRI3)
+ m0.setCoords(c)
+ m0.setNodalConnectivity(DataArrayInt([0,2,1,3,2,0,2,4,1]))
+ mm=MEDFileUMesh()
+ mm[0]=m0
+ m1=MEDCoupling1SGTUMesh(meshName,NORM_SEG2)
+ m1.setCoords(c)
+ m1.setNodalConnectivity(DataArrayInt([5,0,0,3,3,2,2,6]))
+ mm[-1]=m1
+ #
+ zeTime=(1.1,2,3)
+ ff1=MEDFileField1TS()
+ f1=MEDCouplingFieldDouble(ON_NODES) ; f1.setMesh(m0)
+ arr=DataArrayDouble(7) ; arr.iota(2000)
+ f1.setArray(arr)
+ f1.setName("bbb")
+ f1.checkConsistencyLight()
+ f1.setTime(*zeTime)
+ ff1.setFieldNoProfileSBT(f1)
+ #
+ ff2=MEDFileField1TS()
+ f2=MEDCouplingFieldDouble(ON_GAUSS_NE) ; f2.setMesh(m0)
+ arr=DataArrayDouble(9) ; arr.iota(4000)
+ f2.setArray(arr)
+ f2.setName("ddd")
+ f2.checkConsistencyLight()
+ f2.setTime(*zeTime)
+ ff2.setFieldNoProfileSBT(f2)
+ #
+ ff3=MEDFileField1TS()
+ f3=MEDCouplingFieldDouble(ON_GAUSS_PT) ; f3.setMesh(m0)
+ f3.setGaussLocalizationOnType(NORM_TRI3,[0,0,1,0,0,1],[0.333333,0.333333],[0.5])
+ arr=DataArrayDouble(3) ; arr.iota(1000)
+ f3.setArray(arr)
+ f3.checkConsistencyLight()
+ f3.setTime(*zeTime)
+ f3.setName("aaa")
+ ff3.setFieldNoProfileSBT(f3)
+ #
+ ff4=MEDFileField1TS()
+ m0d=m0.deepCopy() ; m0d.zipCoords()
+ f4=MEDCouplingFieldDouble(ON_NODES) ; f4.setMesh(m0d)
+ arr=DataArrayDouble(5) ; arr.iota(3000)
+ f4.setArray(arr)
+ f4.setName("ccc")
+ f4.checkConsistencyLight()
+ f4.setTime(*zeTime)
+ pfl=DataArrayInt([0,1,2,3,4]) ; pfl.setName("PFL")
+ ff4.setFieldProfile(f4,mm,0,pfl)
+ #
+ mm.write(fname,2)
+ ff3.write(fname,0)
+ ff1.write(fname,0)
+ ff4.write(fname,0)
+ ###
+ ms=MEDFileMeshes(fname) ; ms.cartesianizeMe()
+ fields=MEDFileFields(fname,False)
+ fields.removeFieldsWithoutAnyTimeStep()
+ fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()]
+ allFMTSLeavesToDisplay=[]
+ for fields in fields_per_mesh:
+ allFMTSLeavesToDisplay2=[]
+ for fmts in fields:
+ tmp=fmts.splitDiscretizations()
+ for itmp in tmp:
+ self.assertTrue(not itmp.presenceOfMultiDiscPerGeoType())
+ pass
+ allFMTSLeavesToDisplay2+=tmp
+ pass
+ allFMTSLeavesToDisplay.append(allFMTSLeavesToDisplay2)
+ pass
+ self.assertEqual(len(allFMTSLeavesToDisplay),1)
+ self.assertEqual(len(allFMTSLeavesToDisplay[0]),3)
+ allFMTSLeavesPerTimeSeries=MEDFileAnyTypeFieldMultiTS.SplitIntoCommonTimeSeries(sum(allFMTSLeavesToDisplay,[]))
+ self.assertEqual(len(allFMTSLeavesPerTimeSeries),1)
+ self.assertEqual(len(allFMTSLeavesPerTimeSeries[0]),3)
+ allFMTSLeavesPerCommonSupport1=MEDFileAnyTypeFieldMultiTS.SplitPerCommonSupport(allFMTSLeavesToDisplay[0],ms[ms.getMeshesNames()[0]])
+ self.assertEqual(len(allFMTSLeavesPerCommonSupport1),2)
+ self.assertEqual(len(allFMTSLeavesPerCommonSupport1[0][0]),2)
+ self.assertEqual(len(allFMTSLeavesPerCommonSupport1[1][0]),1)
+ #
+ mst=MEDFileMeshStruct.New(ms[0])
+ fcscp=allFMTSLeavesPerCommonSupport1[0][1]
+ mml=fcscp.buildFromScratchDataSetSupport(0,fields)
+ mml2=mml.prepare()
+ self.assertTrue(isinstance(mml2,MEDUMeshMultiLev))
+ ncc,a0,a1,a2,a3,a4,a5=mml2.buildVTUArrays()
+ self.assertTrue(not ncc)# here ncc=False because the coordinates are not in ms neither in children.
+ self.assertTrue(a0.isEqual(DataArrayDouble([(0,0,0),(1,0,0),(1,1,0),(0,1,0),(2,0,0)]),1e-12))
+ self.assertTrue(a1.isEqual(DataArrayByte([5,5,5])))
+ self.assertTrue(a2.isEqual(DataArrayInt([0,4,8])))
+ self.assertTrue(a3.isEqual(DataArrayInt([3,0,2,1,3,3,2,0,3,2,4,1])))
+ self.assertTrue(a4 is None)
+ self.assertTrue(a5 is None)
+ self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None)
+ for i in range(1):
+ ffCell=allFMTSLeavesPerCommonSupport1[0][0][0][i]
+ fsst=MEDFileField1TSStructItem.BuildItemFrom(ffCell,mst)
+ ffCell.loadArraysIfNecessary()
+ v=mml2.buildDataArray(fsst,fields,ffCell.getUndergroundDataArray())
+ self.assertEqual(v.getHiddenCppPointer(),ffCell.getUndergroundDataArray().getHiddenCppPointer())
+ v.isEqual(DataArrayDouble([1000,1001,1002]),1e-12)
+ #
+ ffCell=allFMTSLeavesPerCommonSupport1[0][0][1][i]
+ fsst=MEDFileField1TSStructItem.BuildItemFrom(ffCell,mst)
+ ffCell.loadArraysIfNecessary()
+ v=mml2.buildDataArray(fsst,fields,ffCell.getUndergroundDataArray())
+ self.assertEqual(v.getHiddenCppPointer(),ffCell.getUndergroundDataArray().getHiddenCppPointer())
+ v.isEqual(DataArrayDouble([3000,3001,3002,3003,3004]),1e-12)
+ pass
+ fcscp=allFMTSLeavesPerCommonSupport1[1][1]
+ mml=fcscp.buildFromScratchDataSetSupport(0,fields)
+ mml2=mml.prepare()
+ self.assertTrue(isinstance(mml2,MEDUMeshMultiLev))
+ ncc,a0,a1,a2,a3,a4,a5=mml2.buildVTUArrays()
+ self.assertTrue(not ncc)# here ncc=False because the coordinates are not in ms neither in children.
+ self.assertTrue(a0.isEqual(DataArrayDouble([(0,0,0),(1,0,0),(1,1,0),(0,1,0),(2,0,0),(-1,0,0),(1,2,0)]),1e-12))
+ self.assertTrue(a1.isEqual(DataArrayByte([5,5,5,3,3,3,3])))
+ self.assertTrue(a2.isEqual(DataArrayInt([0,4,8,12,15,18,21])))
+ self.assertTrue(a3.isEqual(DataArrayInt([3,0,2,1,3,3,2,0,3,2,4,1,2,5,0,2,0,3,2,3,2,2,2,6])))
+ self.assertTrue(a4 is None)
+ self.assertTrue(a5 is None)
+ self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None)
+ for i in range(1):
+ ffCell=allFMTSLeavesPerCommonSupport1[1][0][0][i]
+ fsst=MEDFileField1TSStructItem.BuildItemFrom(ffCell,mst)
+ ffCell.loadArraysIfNecessary()
+ v=mml2.buildDataArray(fsst,fields,ffCell.getUndergroundDataArray())
+ self.assertEqual(v.getHiddenCppPointer(),ffCell.getUndergroundDataArray().getHiddenCppPointer())
+ v.isEqual(DataArrayDouble([2000,2001,2002,2003,2004,2005,2006]),1e-12)
+ pass
+ pass
+
+ @WriteInTmpDir
+ def test37(self):
+ """ Introduction of non cartesian meshes management. Here cylindrical."""
+ fname="ForMEDReader37.med"
+ meshName="mesh"
+ description="Cylindrical grid"
+ comps=["X [cm]","Y [cm]","Z [cm]"]
+ arrX=DataArrayDouble(3) ; arrX.iota() ; arrX*=0.8 ; arrX.setInfoOnComponent(0,comps[0])
+ arrY=DataArrayDouble(4) ; arrY.iota() ; arrY*=pi/(len(arrY)-1) ; arrY.setInfoOnComponent(0,comps[1])
+ arrZ=DataArrayDouble(5) ; arrZ.iota() ; arrZ*=1.6 ; arrZ-=8. ; arrZ.setInfoOnComponent(0,comps[2])
+ m=MEDCouplingCMesh() ; m.setCoords(arrX,arrY,arrZ) ; m.setName(meshName)
+ mm=MEDFileCMesh() ; mm.setMesh(m) ; mm.setDescription(description)
+ mm.setAxisType(AX_CYL) # the test is here !
+ f=MEDCouplingFieldDouble(ON_CELLS) ; f.setMesh(m) ; f.setName("Field")
+ arr=DataArrayDouble(m.getNumberOfCells()) ; arr.iota() ; arr*=0.1 ; f.setArray(arr) ; f.checkConsistencyLight()
+ ff=MEDFileField1TS() ; ff.setFieldNoProfileSBT(f)
+ fmts=MEDFileFieldMultiTS() ; fmts.pushBackTimeStep(ff)
+ #
+ ms=MEDFileMeshes() ; ms.pushMesh(mm)
+ fields=MEDFileFields() ; fields.pushField(fmts)
+ ms.write(fname,2) ; fields.write(fname,0)
+ #
+ del mm,fmts,fields,ms
+ ms=MEDFileMeshes(fname)
+ fields=MEDFileFields(fname,False)
+ ms.cartesianizeMe()
+ #
+ fields.removeFieldsWithoutAnyTimeStep()
+ fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()]
+ allFMTSLeavesToDisplay=[]
+ for fields in fields_per_mesh:
+ allFMTSLeavesToDisplay2=[]
+ for fmts in fields:
+ tmp=fmts.splitDiscretizations()
+ for itmp in tmp:
+ self.assertTrue(not itmp.presenceOfMultiDiscPerGeoType())
+ pass
+ allFMTSLeavesToDisplay2+=tmp
+ pass
+ allFMTSLeavesToDisplay.append(allFMTSLeavesToDisplay2)
+ pass
+ #
+ self.assertEqual(len(allFMTSLeavesToDisplay),1)
+ self.assertEqual(len(allFMTSLeavesToDisplay[0]),1)
+ allFMTSLeavesPerTimeSeries=MEDFileAnyTypeFieldMultiTS.SplitIntoCommonTimeSeries(sum(allFMTSLeavesToDisplay,[]))
+ self.assertEqual(len(allFMTSLeavesPerTimeSeries),1)
+ allFMTSLeavesPerCommonSupport1=MEDFileAnyTypeFieldMultiTS.SplitPerCommonSupport(allFMTSLeavesToDisplay[0],ms[ms.getMeshesNames()[0]])
+ self.assertEqual(len(allFMTSLeavesPerCommonSupport1),1)
+ #
+ mst=MEDFileMeshStruct.New(ms[0])
+ fcscp=allFMTSLeavesPerCommonSupport1[0][1]
+ mml=fcscp.buildFromScratchDataSetSupport(0,fields)
+ mml2=mml.prepare()
+ self.assertTrue(isinstance(mml2,MEDCurveLinearMeshMultiLev))# <- hehe it is a CurveLinear no more a CMesh !
+ a,b,c=mml2.buildVTUArrays()
+ self.assertTrue(c)# the array is thoose in structure
+ ref_a=DataArrayDouble([0.,0.,-8.,0.8,0.,-8.,1.6,0.,-8.,0.,0.,-8.,0.4,0.6928203230275509,-8.,0.8,1.3856406460551018,-8.,-0.,0.,-8.,-0.4,0.692820323027551,-8.,-0.8,1.385640646055102,-8.,-0.,0.,-8.,-0.8,0.,-8.,-1.6,0.,-8.,0.,0.,-6.4,0.8,0.,-6.4,1.6,0.,-6.4,0.,0.,-6.4,0.4,0.6928203230275509,-6.4,0.8,1.3856406460551018,-6.4,-0.,0.,-6.4,-0.4,0.692820323027551,-6.4,-0.8,1.385640646055102,-6.4,-0.,0.,-6.4,-0.8,0.,-6.4,-1.6,0.,-6.4,0.,0.,-4.8,0.8,0.,-4.8,1.6,0.,-4.8,0.,0.,-4.8,0.4,0.6928203230275509,-4.8,0.8,1.3856406460551018,-4.8,-0.,0.,-4.8,-0.4,0.692820323027551,-4.8,-0.8,1.385640646055102,-4.8,-0.,0.,-4.8,-0.8,0.,-4.8,-1.6,0.,-4.8,0.,0.,-3.2,0.8,0.,-3.2,1.6,0.,-3.2,0.,0.,-3.2,0.4,0.6928203230275509,-3.2,0.8,1.3856406460551018,-3.2,-0.,0.,-3.2,-0.4,0.692820323027551,-3.2,-0.8,1.385640646055102,-3.2,-0.,0.,-3.2,-0.8,0.,-3.2,-1.6,0.,-3.2,0.,0.,-1.6,0.8,0.,-1.6,1.6,0.,-1.6,0.,0.,-1.6,0.4,0.6928203230275509,-1.6,0.8,1.3856406460551018,-1.6,-0.,0.,-1.6,-0.4,0.692820323027551,-1.6,-0.8,1.385640646055102,-1.6,-0.,0.,-1.6,-0.8,0.,-1.6,-1.6,0.,-1.6],60,3)
+ ref_a.setInfoOnComponents(comps)
+ self.assertTrue(a.isEqual(ref_a,1e-14))
+ self.assertEqual(b,[3,4,5])
+ self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None)
+ for i in range(1):
+ ffCell=allFMTSLeavesPerCommonSupport1[0][0][0][i]
+ fsst=MEDFileField1TSStructItem.BuildItemFrom(ffCell,mst)
+ ffCell.loadArraysIfNecessary()
+ v=mml2.buildDataArray(fsst,fields,ffCell.getUndergroundDataArray())
+ self.assertEqual(v.getHiddenCppPointer(),ffCell.getUndergroundDataArray().getHiddenCppPointer())
+ self.assertTrue(v.isEqual(DataArrayDouble([0.0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,2.0,2.1,2.2,2.3]),1e-14))
+ pass
+ pass
+
+ @WriteInTmpDir
+ def test38(self):
+ """ Introduction of non cartesian meshes management. Here spherical."""
+ fname="ForMEDReader38.med"
+ meshName="mesh"
+ description="Spherical grid"
+ comps=["X [cm]","Y [cm]","Z [cm]"]
+ arrX=DataArrayDouble(3) ; arrX.iota() ; arrX*=0.8 ; arrX.setInfoOnComponent(0,comps[0])
+ arrY=DataArrayDouble(4) ; arrY.iota() ; arrY*=pi/(len(arrY)-1) ; arrY.setInfoOnComponent(0,comps[1])
+ arrZ=DataArrayDouble(5) ; arrZ.iota() ; arrZ*=2*pi/(len(arrZ)-1) ; arrZ.setInfoOnComponent(0,comps[2])
+ m=MEDCouplingCMesh() ; m.setCoords(arrX,arrY,arrZ) ; m.setName(meshName)
+ mm=MEDFileCMesh() ; mm.setMesh(m) ; mm.setDescription(description)
+ mm.setAxisType(AX_SPHER) # the test is here !
+ f=MEDCouplingFieldDouble(ON_CELLS) ; f.setMesh(m) ; f.setName("Field")
+ arr=DataArrayDouble(m.getNumberOfCells()) ; arr.iota() ; arr*=0.1 ; f.setArray(arr) ; f.checkConsistencyLight()
+ ff=MEDFileField1TS() ; ff.setFieldNoProfileSBT(f)
+ fmts=MEDFileFieldMultiTS() ; fmts.pushBackTimeStep(ff)
+ #
+ ms=MEDFileMeshes() ; ms.pushMesh(mm)
+ fields=MEDFileFields() ; fields.pushField(fmts)
+ ms.write(fname,2) ; fields.write(fname,0)
+ #
+ del mm,fmts,fields,ms
+ ms=MEDFileMeshes(fname)
+ fields=MEDFileFields(fname,False)
+ ms.cartesianizeMe()
+ #
+ fields.removeFieldsWithoutAnyTimeStep()
+ fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()]
+ allFMTSLeavesToDisplay=[]
+ for fields in fields_per_mesh:
+ allFMTSLeavesToDisplay2=[]
+ for fmts in fields:
+ tmp=fmts.splitDiscretizations()
+ for itmp in tmp:
+ self.assertTrue(not itmp.presenceOfMultiDiscPerGeoType())
+ pass
+ allFMTSLeavesToDisplay2+=tmp
+ pass
+ allFMTSLeavesToDisplay.append(allFMTSLeavesToDisplay2)
+ pass
+ #
+ self.assertEqual(len(allFMTSLeavesToDisplay),1)
+ self.assertEqual(len(allFMTSLeavesToDisplay[0]),1)
+ allFMTSLeavesPerTimeSeries=MEDFileAnyTypeFieldMultiTS.SplitIntoCommonTimeSeries(sum(allFMTSLeavesToDisplay,[]))
+ self.assertEqual(len(allFMTSLeavesPerTimeSeries),1)
+ allFMTSLeavesPerCommonSupport1=MEDFileAnyTypeFieldMultiTS.SplitPerCommonSupport(allFMTSLeavesToDisplay[0],ms[ms.getMeshesNames()[0]])
+ self.assertEqual(len(allFMTSLeavesPerCommonSupport1),1)
+ #
+ mst=MEDFileMeshStruct.New(ms[0])
+ fcscp=allFMTSLeavesPerCommonSupport1[0][1]
+ mml=fcscp.buildFromScratchDataSetSupport(0,fields)
+ mml2=mml.prepare()
+ self.assertTrue(isinstance(mml2,MEDCurveLinearMeshMultiLev))
+ a,b,c=mml2.buildVTUArrays()
+ self.assertTrue(c)# the array is thoose in structure
+ ref_a=DataArrayDouble([0.,0.,0.,0.,0.,0.8,0.,0.,1.6,0.,0.,0.,0.6928203230275509,0.,0.4,1.3856406460551018,0.,0.8,0.,0.,-0.,0.692820323027551,0.,-0.4,1.385640646055102,0.,-0.8,0.,0.,-0.,0.,0.,-0.8,0.,0.,-1.6,0.,0.,0.,0.,0.,0.8,0.,0.,1.6,0.,0.,0.,0.,0.6928203230275509,0.4,0.,1.3856406460551018,0.8,0.,0.,-0.,0.,0.692820323027551,-0.4,0.,1.385640646055102,-0.8,0.,0.,-0.,0.,0.,-0.8,0.,0.,-1.6,-0.,0.,0.,-0.,0.,0.8,-0.,0.,1.6,-0.,0.,0.,-0.6928203230275509,0.,0.4,-1.3856406460551018,0.,0.8,-0.,0.,-0.,-0.692820323027551,0.,-0.4,-1.385640646055102,0.,-0.8,-0.,0.,-0.,0.,0.,-0.8,0.,0.,-1.6,-0.,-0.,0.,-0.,-0.,0.8,-0.,-0.,1.6,-0.,-0.,0.,0.,-0.6928203230275509,0.4,0.,-1.3856406460551018,0.8,-0.,-0.,-0.,0.,-0.692820323027551,-0.4,0.,-1.385640646055102,-0.8,-0.,-0.,-0.,0.,0.,-0.8,0.,0.,-1.6,0.,-0.,0.,0.,-0.,0.8,0.,-0.,1.6,0.,-0.,0.,0.6928203230275509,0.,0.4,1.3856406460551018,0.,0.8,0.,-0.,-0.,0.692820323027551,0.,-0.4,1.385640646055102,0.,-0.8,0.,-0.,-0.,0.,0.,-0.8,0.,0.,-1.6],60,3)
+ ref_a.setInfoOnComponents(comps)
+ self.assertTrue(a.isEqual(ref_a,1e-14))
+ self.assertEqual(b,[3,4,5])
+ self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None)
+ for i in range(1):
+ ffCell=allFMTSLeavesPerCommonSupport1[0][0][0][i]
+ fsst=MEDFileField1TSStructItem.BuildItemFrom(ffCell,mst)
+ ffCell.loadArraysIfNecessary()
+ v=mml2.buildDataArray(fsst,fields,ffCell.getUndergroundDataArray())
+ self.assertEqual(v.getHiddenCppPointer(),ffCell.getUndergroundDataArray().getHiddenCppPointer())
+ self.assertTrue(v.isEqual(DataArrayDouble([0.0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,2.0,2.1,2.2,2.3]),1e-14))
+ pass
+ pass
+
+ @WriteInTmpDir
+ def test39(self):
+ """Idem test37, test38, test39, test40 except that here it is an unstructured mesh."""
+ fname="ForMEDReader39.med"
+ meshName="mesh"
+ description="Spherical grid"
+ comps=["X [cm]","Y [cm]","Z [cm]"]
+ arrX=DataArrayDouble(3) ; arrX.iota() ; arrX*=0.8 ; arrX.setInfoOnComponent(0,comps[0])
+ arrY=DataArrayDouble(4) ; arrY.iota() ; arrY*=pi/(len(arrY)-1) ; arrY.setInfoOnComponent(0,comps[1])
+ arrZ=DataArrayDouble(5) ; arrZ.iota() ; arrZ*=2*pi/(len(arrZ)-1) ; arrZ.setInfoOnComponent(0,comps[2])
+ m=MEDCouplingCMesh() ; m.setCoords(arrX,arrY,arrZ) ; m.setName(meshName) ; m=m.buildUnstructured()
+ mm=MEDFileUMesh() ; mm[0]=m ; mm.setDescription(description) # the test is here : UMesh !
+ mm.setAxisType(AX_SPHER) # the test is here !
+ f=MEDCouplingFieldDouble(ON_CELLS) ; f.setMesh(m) ; f.setName("Field")
+ arr=DataArrayDouble(m.getNumberOfCells()) ; arr.iota() ; arr*=0.1 ; f.setArray(arr) ; f.checkConsistencyLight()
+ ff=MEDFileField1TS() ; ff.setFieldNoProfileSBT(f)
+ fmts=MEDFileFieldMultiTS() ; fmts.pushBackTimeStep(ff)
+ #
+ ms=MEDFileMeshes() ; ms.pushMesh(mm)
+ fields=MEDFileFields() ; fields.pushField(fmts)
+ ms.write(fname,2) ; fields.write(fname,0)
+ #
+ del mm,fmts,fields,ms
+ ms=MEDFileMeshes(fname)
+ fields=MEDFileFields(fname,False)
+ #
+ ms=MEDFileMeshes(fname) ; ms.cartesianizeMe()
+ fields=MEDFileFields(fname,False)
+ fields.removeFieldsWithoutAnyTimeStep()
+ fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()]
+ allFMTSLeavesToDisplay=[]
+ for fields in fields_per_mesh:
+ allFMTSLeavesToDisplay2=[]
+ for fmts in fields:
+ tmp=fmts.splitDiscretizations()
+ for itmp in tmp:
+ self.assertTrue(not itmp.presenceOfMultiDiscPerGeoType())
+ pass
+ allFMTSLeavesToDisplay2+=tmp
+ pass
+ allFMTSLeavesToDisplay.append(allFMTSLeavesToDisplay2)
+ pass
+ #
+ self.assertEqual(len(allFMTSLeavesToDisplay),1)
+ self.assertEqual(len(allFMTSLeavesToDisplay[0]),1)
+ allFMTSLeavesPerTimeSeries=MEDFileAnyTypeFieldMultiTS.SplitIntoCommonTimeSeries(sum(allFMTSLeavesToDisplay,[]))
+ self.assertEqual(len(allFMTSLeavesPerTimeSeries),1)
+ allFMTSLeavesPerCommonSupport1=MEDFileAnyTypeFieldMultiTS.SplitPerCommonSupport(allFMTSLeavesToDisplay[0],ms[ms.getMeshesNames()[0]])
+ self.assertEqual(len(allFMTSLeavesPerCommonSupport1),1)
+ #
+ mst=MEDFileMeshStruct.New(ms[0])
+ fcscp=allFMTSLeavesPerCommonSupport1[0][1]
+ mml=fcscp.buildFromScratchDataSetSupport(0,fields)
+ mml2=mml.prepare()
+ self.assertTrue(isinstance(mml2,MEDUMeshMultiLev))
+ ncc,a0,a1,a2,a3,a4,a5=mml2.buildVTUArrays()
+ self.assertTrue(ncc)
+ ref_a=DataArrayDouble([0.,0.,0.,0.,0.,0.8,0.,0.,1.6,0.,0.,0.,0.6928203230275509,0.,0.4,1.3856406460551018,0.,0.8,0.,0.,-0.,0.692820323027551,0.,-0.4,1.385640646055102,0.,-0.8,0.,0.,-0.,0.,0.,-0.8,0.,0.,-1.6,0.,0.,0.,0.,0.,0.8,0.,0.,1.6,0.,0.,0.,0.,0.6928203230275509,0.4,0.,1.3856406460551018,0.8,0.,0.,-0.,0.,0.692820323027551,-0.4,0.,1.385640646055102,-0.8,0.,0.,-0.,0.,0.,-0.8,0.,0.,-1.6,-0.,0.,0.,-0.,0.,0.8,-0.,0.,1.6,-0.,0.,0.,-0.6928203230275509,0.,0.4,-1.3856406460551018,0.,0.8,-0.,0.,-0.,-0.692820323027551,0.,-0.4,-1.385640646055102,0.,-0.8,-0.,0.,-0.,0.,0.,-0.8,0.,0.,-1.6,-0.,-0.,0.,-0.,-0.,0.8,-0.,-0.,1.6,-0.,-0.,0.,0.,-0.6928203230275509,0.4,0.,-1.3856406460551018,0.8,-0.,-0.,-0.,0.,-0.692820323027551,-0.4,0.,-1.385640646055102,-0.8,-0.,-0.,-0.,0.,0.,-0.8,0.,0.,-1.6,0.,-0.,0.,0.,-0.,0.8,0.,-0.,1.6,0.,-0.,0.,0.6928203230275509,0.,0.4,1.3856406460551018,0.,0.8,0.,-0.,-0.,0.692820323027551,0.,-0.4,1.385640646055102,0.,-0.8,0.,-0.,-0.,0.,0.,-0.8,0.,0.,-1.6],60,3)
+ ref_a.setInfoOnComponents(comps)
+ self.assertTrue(a0.isEqual(ref_a,1e-14))#<- Test is here
+ self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None)
+ for i in range(1):
+ ffCell=allFMTSLeavesPerCommonSupport1[0][0][0][i]
+ fsst=MEDFileField1TSStructItem.BuildItemFrom(ffCell,mst)
+ ffCell.loadArraysIfNecessary()
+ v=mml2.buildDataArray(fsst,fields,ffCell.getUndergroundDataArray())
+ self.assertEqual(v.getHiddenCppPointer(),ffCell.getUndergroundDataArray().getHiddenCppPointer())
+ self.assertTrue(v.isEqual(DataArrayDouble([0.0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,2.0,2.1,2.2,2.3]),1e-14))
+ pass
+
+ @WriteInTmpDir
+ def test40(self):
+ """Idem test37, test38, test39, test40 except that here it is a CL mesh."""
+ fname="ForMEDReader40.med"
+ meshName="mesh"
+ description="Spherical grid"
+ comps=["X [cm]","Y [cm]","Z [cm]"]
+ arrX=DataArrayDouble(3) ; arrX.iota() ; arrX*=0.8 ; arrX.setInfoOnComponent(0,comps[0])
+ arrY=DataArrayDouble(4) ; arrY.iota() ; arrY*=pi/(len(arrY)-1) ; arrY.setInfoOnComponent(0,comps[1])
+ arrZ=DataArrayDouble(5) ; arrZ.iota() ; arrZ*=2*pi/(len(arrZ)-1) ; arrZ.setInfoOnComponent(0,comps[2])
+ m=MEDCouplingCMesh() ; m.setCoords(arrX,arrY,arrZ) ; m.setName(meshName) ; m=m.buildCurveLinear()
+ mm=MEDFileCurveLinearMesh() ; mm.setMesh(m) ; mm.setDescription(description) # the test is here CLMesh!
+ mm.setAxisType(AX_SPHER) # the test is here !
+ f=MEDCouplingFieldDouble(ON_CELLS) ; f.setMesh(m) ; f.setName("Field")
+ arr=DataArrayDouble(m.getNumberOfCells()) ; arr.iota() ; arr*=0.1 ; f.setArray(arr) ; f.checkConsistencyLight()
+ ff=MEDFileField1TS() ; ff.setFieldNoProfileSBT(f)
+ fmts=MEDFileFieldMultiTS() ; fmts.pushBackTimeStep(ff)
+ #
+ ms=MEDFileMeshes() ; ms.pushMesh(mm)
+ fields=MEDFileFields() ; fields.pushField(fmts)
+ ms.write(fname,2) ; fields.write(fname,0)
+ #
+ ms=MEDFileMeshes(fname) ; ms.cartesianizeMe()
+ fields=MEDFileFields(fname,False)
+ fields.removeFieldsWithoutAnyTimeStep()
+ fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()]
+ allFMTSLeavesToDisplay=[]
+ for fields in fields_per_mesh:
+ allFMTSLeavesToDisplay2=[]
+ for fmts in fields:
+ tmp=fmts.splitDiscretizations()
+ for itmp in tmp:
+ self.assertTrue(not itmp.presenceOfMultiDiscPerGeoType())
+ pass
+ allFMTSLeavesToDisplay2+=tmp
+ pass
+ allFMTSLeavesToDisplay.append(allFMTSLeavesToDisplay2)
+ pass
+ #
+ self.assertEqual(len(allFMTSLeavesToDisplay),1)
+ self.assertEqual(len(allFMTSLeavesToDisplay[0]),1)
+ allFMTSLeavesPerTimeSeries=MEDFileAnyTypeFieldMultiTS.SplitIntoCommonTimeSeries(sum(allFMTSLeavesToDisplay,[]))
+ self.assertEqual(len(allFMTSLeavesPerTimeSeries),1)
+ allFMTSLeavesPerCommonSupport1=MEDFileAnyTypeFieldMultiTS.SplitPerCommonSupport(allFMTSLeavesToDisplay[0],ms[ms.getMeshesNames()[0]])
+ self.assertEqual(len(allFMTSLeavesPerCommonSupport1),1)
+ #
+ mst=MEDFileMeshStruct.New(ms[0])
+ fcscp=allFMTSLeavesPerCommonSupport1[0][1]
+ mml=fcscp.buildFromScratchDataSetSupport(0,fields)
+ mml2=mml.prepare()
+ self.assertTrue(isinstance(mml2,MEDCurveLinearMeshMultiLev))
+ a,b,c=mml2.buildVTUArrays()
+ self.assertTrue(c)
+ ref_a=DataArrayDouble([0.,0.,0.,0.,0.,0.8,0.,0.,1.6,0.,0.,0.,0.6928203230275509,0.,0.4,1.3856406460551018,0.,0.8,0.,0.,-0.,0.692820323027551,0.,-0.4,1.385640646055102,0.,-0.8,0.,0.,-0.,0.,0.,-0.8,0.,0.,-1.6,0.,0.,0.,0.,0.,0.8,0.,0.,1.6,0.,0.,0.,0.,0.6928203230275509,0.4,0.,1.3856406460551018,0.8,0.,0.,-0.,0.,0.692820323027551,-0.4,0.,1.385640646055102,-0.8,0.,0.,-0.,0.,0.,-0.8,0.,0.,-1.6,-0.,0.,0.,-0.,0.,0.8,-0.,0.,1.6,-0.,0.,0.,-0.6928203230275509,0.,0.4,-1.3856406460551018,0.,0.8,-0.,0.,-0.,-0.692820323027551,0.,-0.4,-1.385640646055102,0.,-0.8,-0.,0.,-0.,0.,0.,-0.8,0.,0.,-1.6,-0.,-0.,0.,-0.,-0.,0.8,-0.,-0.,1.6,-0.,-0.,0.,0.,-0.6928203230275509,0.4,0.,-1.3856406460551018,0.8,-0.,-0.,-0.,0.,-0.692820323027551,-0.4,0.,-1.385640646055102,-0.8,-0.,-0.,-0.,0.,0.,-0.8,0.,0.,-1.6,0.,-0.,0.,0.,-0.,0.8,0.,-0.,1.6,0.,-0.,0.,0.6928203230275509,0.,0.4,1.3856406460551018,0.,0.8,0.,-0.,-0.,0.692820323027551,0.,-0.4,1.385640646055102,0.,-0.8,0.,-0.,-0.,0.,0.,-0.8,0.,0.,-1.6],60,3)
+ ref_a.setInfoOnComponents(comps)
+ self.assertTrue(a.isEqual(ref_a,1e-14))#<- Test is here
+ self.assertEqual(b,[3,4,5])
+ self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None)
+ for i in range(1):
+ ffCell=allFMTSLeavesPerCommonSupport1[0][0][0][i]
+ fsst=MEDFileField1TSStructItem.BuildItemFrom(ffCell,mst)
+ ffCell.loadArraysIfNecessary()
+ v=mml2.buildDataArray(fsst,fields,ffCell.getUndergroundDataArray())
+ self.assertEqual(v.getHiddenCppPointer(),ffCell.getUndergroundDataArray().getHiddenCppPointer())
+ self.assertTrue(v.isEqual(DataArrayDouble([0.0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,2.0,2.1,2.2,2.3]),1e-14))
+ pass
+
+ @WriteInTmpDir
+ def test41(self):
+ """This test focused on bug revealed with // load of multi nodes field with no profile. The error was the first node field (dataarray partdef) change the partdef for the others ! """
+ fname="ForMEDReader41.med"
+ meshName="mesh"
+ nx=5
+ arr=DataArrayDouble(nx) ; arr.iota()
+ m=MEDCouplingCMesh() ; m.setCoords(arr,arr) ; m=m.buildUnstructured() ; m.setName(meshName)
+ renum=DataArrayInt.Aggregate([DataArrayInt.Range(0,m.getNumberOfCells(),2),DataArrayInt.Range(1,m.getNumberOfCells(),2)])
+ m=m[renum] # important think to renum if not we see nothing. The goal if to have dynamic_cast<DataPartDefinition>!=NULL
+ mm=MEDFileUMesh() ; mm[0]=m
+ mm.write(fname,2)
+ f0=MEDCouplingFieldDouble(ON_NODES) ; f0.setMesh(m) ; f0.setName("aaa")
+ arr0=DataArrayDouble(nx*nx) ; arr0.iota() ; f0.setArray(arr0)
+ ff0=MEDFileField1TS() ; ff0.setFieldNoProfileSBT(f0)
+ f1=MEDCouplingFieldDouble(ON_NODES) ; f1.setMesh(m) ; f1.setName("bbb")
+ arr1=DataArrayDouble(nx*nx) ; arr1.iota() ; arr1+=100 ; f1.setArray(arr1)
+ ff1=MEDFileField1TS() ; ff1.setFieldNoProfileSBT(f1)
+ ff0.write(fname,0) ; ff1.write(fname,0)
+ #
+ a=8 ; b=16
+ ms=MEDFileMeshes()
+ mm=MEDFileUMesh.LoadPartOf(fname,meshName,[NORM_QUAD4],[a,b,1],-1,-1)
+ ms.pushMesh(mm)
+ ms[0].zipCoords()
+ ms.cartesianizeMe()
+ fields=MEDFileFields.LoadPartOf(fname,False,ms);
+ fields.removeFieldsWithoutAnyTimeStep()
+ fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()]
+ allFMTSLeavesToDisplay=[]
+ for fields in fields_per_mesh:
+ allFMTSLeavesToDisplay2=[]
+ for fmts in fields:
+ tmp=fmts.splitDiscretizations()
+ for itmp in tmp:
+ if itmp.presenceOfMultiDiscPerGeoType():
+ tmp2=itmp.splitMultiDiscrPerGeoTypes()
+ for iii,itmp2 in enumerate(tmp2):
+ name="%s_%i"%(itmp2.getName(),iii)
+ itmp2.setName(name)
+ allFMTSLeavesToDisplay2.append(itmp2)
+ pass
+ pass
+ else:
+ allFMTSLeavesToDisplay2.append(itmp)
+ pass
+ pass
+ allFMTSLeavesToDisplay.append(allFMTSLeavesToDisplay2)
+ pass
+ # GO for reading in MEDReader, by not loading all. Mesh is fully loaded but not fields values
+ allFMTSLeavesPerTimeSeries=MEDFileAnyTypeFieldMultiTS.SplitIntoCommonTimeSeries(sum(allFMTSLeavesToDisplay,[]))
+ allFMTSLeavesPerCommonSupport=MEDFileAnyTypeFieldMultiTS.SplitPerCommonSupport(allFMTSLeavesPerTimeSeries[0],ms[ms.getMeshesNames()[0]])
+ mst=MEDFileMeshStruct.New(ms[0])
+ fcscp=allFMTSLeavesPerCommonSupport[0][1]
+ mml=fcscp.buildFromScratchDataSetSupport(0,fields)
+ mml2=mml.prepare()
+ #
+ f2=allFMTSLeavesPerCommonSupport[0][0][0][0]
+ fsst=MEDFileField1TSStructItem.BuildItemFrom(f2,mst)
+ f2.loadArraysIfNecessary()
+ v0=mml.buildDataArray(fsst,fields,f2.getUndergroundDataArray())
+ assert(v0.isEqual(DataArrayDouble([1,2,3,4,6,7,8,9,11,12,13,14,16,17,18,19,21,22,23,24]),1e-12))
+ #
+ f2=allFMTSLeavesPerCommonSupport[0][0][1][0]
+ fsst=MEDFileField1TSStructItem.BuildItemFrom(f2,mst)
+ f2.loadArraysIfNecessary()
+ v1=mml.buildDataArray(fsst,fields,f2.getUndergroundDataArray())
+ assert(v1.isEqual(DataArrayDouble([101,102,103,104,106,107,108,109,111,112,113,114,116,117,118,119,121,122,123,124]),1e-12))
+ pass
+
+ @WriteInTmpDir
+ def test42(self):
+ """ EDF14869 - SEG4 """
+ fname="ForMEDReader42.med"
+ meshName="mesh"
+ #
+ a0exp=DataArrayDouble([0.,1.,0.3,0.7])
+ m=MEDCouplingUMesh("mesh",1)
+ m.setCoords(a0exp)
+ m.allocateCells()
+ m.insertNextCell(NORM_SEG4,[0,1,2,3])
+ mm=MEDFileUMesh() ; mm[0]=m
+ #
+ f=MEDCouplingFieldDouble(ON_CELLS) ; f.setMesh(m) ; f.setName("Field")
+ arr=DataArrayDouble(m.getNumberOfCells()) ; arr.iota() ; arr*=0.1 ; f.setArray(arr) ; f.checkConsistencyLight()
+ ff=MEDFileField1TS() ; ff.setFieldNoProfileSBT(f)
+ fmts=MEDFileFieldMultiTS() ; fmts.pushBackTimeStep(ff)
+ #
+ ms=MEDFileMeshes() ; ms.pushMesh(mm)
+ fields=MEDFileFields() ; fields.pushField(fmts)
+ ms.write(fname,2) ; fields.write(fname,0)
+ #
+ ms=MEDFileMeshes(fname)
+ fields=MEDFileFields(fname,False)
+ fields.removeFieldsWithoutAnyTimeStep()
+ fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()]
+ allFMTSLeavesToDisplay=[]
+ for fields in fields_per_mesh:
+ allFMTSLeavesToDisplay2=[]
+ for fmts in fields:
+ tmp=fmts.splitDiscretizations()
+ for itmp in tmp:
+ self.assertTrue(not itmp.presenceOfMultiDiscPerGeoType())
+ pass
+ allFMTSLeavesToDisplay2+=tmp
+ pass
+ allFMTSLeavesToDisplay.append(allFMTSLeavesToDisplay2)
+ pass
+ #
+ self.assertEqual(len(allFMTSLeavesToDisplay),1)
+ self.assertEqual(len(allFMTSLeavesToDisplay[0]),1)
+ allFMTSLeavesPerTimeSeries=MEDFileAnyTypeFieldMultiTS.SplitIntoCommonTimeSeries(sum(allFMTSLeavesToDisplay,[]))
+ self.assertEqual(len(allFMTSLeavesPerTimeSeries),1)
+ allFMTSLeavesPerCommonSupport1=MEDFileAnyTypeFieldMultiTS.SplitPerCommonSupport(allFMTSLeavesToDisplay[0],ms[ms.getMeshesNames()[0]])
+ self.assertEqual(len(allFMTSLeavesPerCommonSupport1),1)
+ #
+ mst=MEDFileMeshStruct.New(ms[0])
+ fcscp=allFMTSLeavesPerCommonSupport1[0][1]
+ mml=fcscp.buildFromScratchDataSetSupport(0,fields)
+ mml2=mml.prepare()
+ self.assertTrue(isinstance(mml2,MEDUMeshMultiLev))
+ ncc,a0,a1,a2,a3,a4,a5=mml2.buildVTUArrays()
+ self.assertTrue(not ncc)
+ self.assertTrue(a0.isEqual(a0exp.changeNbOfComponents(3,0.),1e-12))
+ self.assertTrue(a1.isEqual(DataArrayByte([35])))# VTK_CUBIC_LINE
+ self.assertTrue(a2.isEqual(DataArrayInt([0])))
+ self.assertTrue(a3.isEqual(DataArrayInt([4,0,1,2,3])))
+ self.assertTrue(a4 is None)
+ self.assertTrue(a5 is None)
+ self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None)
+ for i in range(1):
+ ffCell=allFMTSLeavesPerCommonSupport1[0][0][0][i]
+ fsst=MEDFileField1TSStructItem.BuildItemFrom(ffCell,mst)
+ ffCell.loadArraysIfNecessary()
+ v=mml2.buildDataArray(fsst,fields,ffCell.getUndergroundDataArray())
+ self.assertEqual(v.getHiddenCppPointer(),ffCell.getUndergroundDataArray().getHiddenCppPointer())
+ self.assertTrue(v.isEqual(DataArrayDouble([0.0]),1e-14))
+ pass
+
+ @WriteInTmpDir
+ def test43(self):
+ """
+ EDF23724 : point to error during 64bit convertion into medcoupling a DataArrayMedInt class was created.
+ This class is not dynamic_castable to DataArrayInt32 nor DataArrayInt64. It lead previously to strange behaviour
+ """
+ fname = "tessss.med"
+ arr=DataArrayDouble(10) ; arr.iota()
+ m = MEDCouplingCMesh() ; m.setCoords(arr)
+ m = m.buildUnstructured()
+ m.setName("mesh")
+ mm = MEDFileUMesh() ; mm[0] = m
+ mm.setGlobalNumFieldAtLevel(1,DataArrayInt([0,4,5,6,10,12,16,17,19,20]))
+ mm.write(fname,2)
+ mm_reload = MEDFileMesh.New(fname)
+ # DataArrayMedInt class no more exists. Check that.
+ self.assertNotEqual(mm_reload.getGlobalNumFieldAtLevel(1).getClassName() , "DataArrayMedInt")
+ pass
+