X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMEDLoader%2FSwig%2FMEDLoaderTest4.py;h=be9440267df2c744f5597e2ec2641976772f0e7c;hb=b4634cfcaa239b987c02485ba0b9b5e6a666676f;hp=1efc267ebce4cbe81bc0974a4b82dc7200870ec1;hpb=f1ffb79038f0a198742f1ffc52428179a0f1ef86;p=tools%2Fmedcoupling.git diff --git a/src/MEDLoader/Swig/MEDLoaderTest4.py b/src/MEDLoader/Swig/MEDLoaderTest4.py index 1efc267eb..be9440267 100644 --- a/src/MEDLoader/Swig/MEDLoaderTest4.py +++ b/src/MEDLoader/Swig/MEDLoaderTest4.py @@ -17,7 +17,7 @@ # # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # -# Author : Anthony Geay (CEA/DEN) +# Author : Anthony Geay (EDF R&D) from MEDLoader import * import unittest @@ -4119,7 +4119,7 @@ class MEDLoaderTest4(unittest.TestCase): pass def test28(self): - """ This test defines 2 fields f0,f1,f2,f3 lying on an unstructured mesh whith cells including NORM_POINT1. + """ This test defines 2 fields f0,f1,f2,f3 lying on an unstructured mesh with cells including NORM_POINT1. Both f0 and f1 are on NODES and f2 and f3 are on cells. f1 and f2 share the same support. f0 is on a nodal support that is not matchable with any cells (including NORM_POINT1) This test is a more aggressive version of test26. @@ -4792,7 +4792,7 @@ class MEDLoaderTest4(unittest.TestCase): mml2=mml.prepare() self.assertTrue(isinstance(mml2,MEDUMeshMultiLev)) ncc,a0,a1,a2,a3,a4,a5=mml2.buildVTUArrays() - self.assertTrue(not ncc)# false beacause 2D in MED file + self.assertTrue(not ncc)# false because 2D in MED file self.assertTrue(a0.isEqual(DataArrayDouble([(5.5,0.5,0),(5.5,-0.5,0),(6.5,0.5,0),(6.5,-0.5,0),(6.5,1.5,0),(7.5,0.5,0),(7.5,-0.5,0),(7.5,1.5,0),(7.5,2.5,0),(8.5,0.5,0),(8.5,-0.5,0),(8.5,1.5,0),(8.5,2.5,0),(8.5,3.5,0),(8.55,0.5,0),(8.55,-0.5,0),(8.55,1.5,0),(8.55,2.5,0),(8.55,3.5,0)]),1e-12)) self.assertTrue(a1.isEqual(DataArrayByte([9,9,9,9,9,9,7,7,7,7]))) self.assertTrue(a2.isEqual(DataArrayInt([0,5,10,15,20,25,30,35,40,45])))# the bug was here. @@ -4959,7 +4959,7 @@ class MEDLoaderTest4(unittest.TestCase): pass def test35(self): - """ Emulate MEDReader in // mode context. Here a Simple mesh having more nodes than really needed. This test focuses on that point particulary.""" + """ 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.]) @@ -5515,6 +5515,74 @@ class MEDLoaderTest4(unittest.TestCase): 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 + 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 + pass if __name__ == "__main__":