X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMEDLoader%2FSwig%2FMEDLoaderTest4.py;h=b7c17377ab1b20225fb0dae45d0b8814080da29d;hb=865eac01b8bdd7a4494afd632f23ac6a1fcc0c88;hp=2425b10f66dc0f1746a2688de022ff806fe720ef;hpb=eda854d4aaf7a516cac9a5c685fc25d22f4194f6;p=tools%2Fmedcoupling.git diff --git a/src/MEDLoader/Swig/MEDLoaderTest4.py b/src/MEDLoader/Swig/MEDLoaderTest4.py index 2425b10f6..b7c17377a 100644 --- a/src/MEDLoader/Swig/MEDLoaderTest4.py +++ b/src/MEDLoader/Swig/MEDLoaderTest4.py @@ -1,5 +1,5 @@ # -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2014 CEA/DEN, EDF R&D +# Copyright (C) 2007-2015 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 @@ -149,7 +149,7 @@ class MEDLoaderTest4(unittest.TestCase): a0Exp=mm.getCoords().deepCpy() del m,m1,mm,fs,f,fCell0,fCell1 ########## GO for reading in MEDReader, by not loading all. Mesh is fully loaded but not fields values - ms=MEDFileMeshes(fname) + ms=MEDFileMeshes(fname) ; ms.cartesianizeMe() fields=MEDFileFields(fname,False) # False is important to not read the values fields.removeFieldsWithoutAnyTimeStep() refMem=fields.getHeapMemorySize() @@ -158,7 +158,11 @@ class MEDLoaderTest4(unittest.TestCase): for fields in fields_per_mesh: allFMTSLeavesToDisplay2=[] for fmts in fields: - allFMTSLeavesToDisplay2+=fmts.splitDiscretizations() + tmp=fmts.splitDiscretizations() + for itmp in tmp: + self.assertTrue(not itmp.presenceOfMultiDiscPerGeoType()) + pass + allFMTSLeavesToDisplay2+=tmp pass allFMTSLeavesToDisplay.append(allFMTSLeavesToDisplay2) pass @@ -361,7 +365,7 @@ class MEDLoaderTest4(unittest.TestCase): a0Exp=mm.getCoords().deepCpy() del m,m1,mm,fs,f,fCell0,fCell1 ########## GO for reading in MEDReader, by not loading all. Mesh is fully loaded but not fields values - ms=MEDFileMeshes(fname) + ms=MEDFileMeshes(fname) ; ms.cartesianizeMe() fields=MEDFileFields(fname,False) fields.removeFieldsWithoutAnyTimeStep() fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()] @@ -369,7 +373,11 @@ class MEDLoaderTest4(unittest.TestCase): for fields in fields_per_mesh: allFMTSLeavesToDisplay2=[] for fmts in fields: - allFMTSLeavesToDisplay2+=fmts.splitDiscretizations() + tmp=fmts.splitDiscretizations() + for itmp in tmp: + self.assertTrue(not itmp.presenceOfMultiDiscPerGeoType()) + pass + allFMTSLeavesToDisplay2+=tmp pass allFMTSLeavesToDisplay.append(allFMTSLeavesToDisplay2) pass @@ -523,7 +531,7 @@ class MEDLoaderTest4(unittest.TestCase): a0Exp=mm.getCoords().deepCpy() del m,m1,mm,fs,f,fCell0,fCell1 ########## GO for reading in MEDReader, by not loading all. Mesh is fully loaded but not fields values - ms=MEDFileMeshes(fname) + ms=MEDFileMeshes(fname) ; ms.cartesianizeMe() fields=MEDFileFields(fname,False) fields.removeFieldsWithoutAnyTimeStep() fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()] @@ -531,7 +539,11 @@ class MEDLoaderTest4(unittest.TestCase): for fields in fields_per_mesh: allFMTSLeavesToDisplay2=[] for fmts in fields: - allFMTSLeavesToDisplay2+=fmts.splitDiscretizations() + tmp=fmts.splitDiscretizations() + for itmp in tmp: + self.assertTrue(not itmp.presenceOfMultiDiscPerGeoType()) + pass + allFMTSLeavesToDisplay2+=tmp pass allFMTSLeavesToDisplay.append(allFMTSLeavesToDisplay2) pass @@ -774,7 +786,7 @@ class MEDLoaderTest4(unittest.TestCase): a0Exp=mm.getCoords().deepCpy() del m,mm,fs1,fs2,fs3,f,fNode ########## GO for reading in MEDReader, by not loading all. Mesh is fully loaded but not fields values - ms=MEDFileMeshes(fname) + ms=MEDFileMeshes(fname) ; ms.cartesianizeMe() fields=MEDFileFields(fname,False) fields.removeFieldsWithoutAnyTimeStep() fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()] @@ -782,7 +794,11 @@ class MEDLoaderTest4(unittest.TestCase): for fields in fields_per_mesh: allFMTSLeavesToDisplay2=[] for fmts in fields: - allFMTSLeavesToDisplay2+=fmts.splitDiscretizations() + tmp=fmts.splitDiscretizations() + for itmp in tmp: + self.assertTrue(not itmp.presenceOfMultiDiscPerGeoType()) + pass + allFMTSLeavesToDisplay2+=tmp pass allFMTSLeavesToDisplay.append(allFMTSLeavesToDisplay2) pass @@ -902,7 +918,7 @@ class MEDLoaderTest4(unittest.TestCase): a0Exp=mm.getCoords().deepCpy() del m,mm,fs1,fs2,fs3,f,fNode ########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values - ms=MEDFileMeshes(fname) + ms=MEDFileMeshes(fname) ; ms.cartesianizeMe() fields=MEDFileFields(fname,False) fields.removeFieldsWithoutAnyTimeStep() fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()] @@ -910,7 +926,11 @@ class MEDLoaderTest4(unittest.TestCase): for fields in fields_per_mesh: allFMTSLeavesToDisplay2=[] for fmts in fields: - allFMTSLeavesToDisplay2+=fmts.splitDiscretizations() + tmp=fmts.splitDiscretizations() + for itmp in tmp: + self.assertTrue(not itmp.presenceOfMultiDiscPerGeoType()) + pass + allFMTSLeavesToDisplay2+=tmp pass allFMTSLeavesToDisplay.append(allFMTSLeavesToDisplay2) pass @@ -1064,7 +1084,7 @@ class MEDLoaderTest4(unittest.TestCase): fs0.write(fname,0) ; fs1.write(fname,0) ; fs2.write(fname,0) ; fs3.write(fname,0) ; fs4.write(fname,0) del m,mm,fs1,fs2,fs3,f,fNode ########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values - ms=MEDFileMeshes(fname) + ms=MEDFileMeshes(fname) ; ms.cartesianizeMe() fields=MEDFileFields(fname,False) fields.removeFieldsWithoutAnyTimeStep() fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()] @@ -1072,7 +1092,11 @@ class MEDLoaderTest4(unittest.TestCase): for fields in fields_per_mesh: allFMTSLeavesToDisplay2=[] for fmts in fields: - allFMTSLeavesToDisplay2+=fmts.splitDiscretizations() + tmp=fmts.splitDiscretizations() + for itmp in tmp: + self.assertTrue(not itmp.presenceOfMultiDiscPerGeoType()) + pass + allFMTSLeavesToDisplay2+=tmp pass allFMTSLeavesToDisplay.append(allFMTSLeavesToDisplay2) pass @@ -1269,7 +1293,7 @@ class MEDLoaderTest4(unittest.TestCase): fs0.write(fname,0) ; fs1.write(fname,0) ; fs2.write(fname,0) ; fs3.write(fname,0) ; fs4.write(fname,0) del m,mm,fs1,fs2,fs3,f,fNode ########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values - ms=MEDFileMeshes(fname) + ms=MEDFileMeshes(fname) ; ms.cartesianizeMe() fields=MEDFileFields(fname,False) fields.removeFieldsWithoutAnyTimeStep() fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()] @@ -1277,7 +1301,11 @@ class MEDLoaderTest4(unittest.TestCase): for fields in fields_per_mesh: allFMTSLeavesToDisplay2=[] for fmts in fields: - allFMTSLeavesToDisplay2+=fmts.splitDiscretizations() + tmp=fmts.splitDiscretizations() + for itmp in tmp: + self.assertTrue(not itmp.presenceOfMultiDiscPerGeoType()) + pass + allFMTSLeavesToDisplay2+=tmp pass allFMTSLeavesToDisplay.append(allFMTSLeavesToDisplay2) pass @@ -1464,7 +1492,7 @@ class MEDLoaderTest4(unittest.TestCase): a0Exp=mm.getCoords().deepCpy() del m,mm,fs1,fs2,fs3,f,fNode ########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values - ms=MEDFileMeshes(fname) + ms=MEDFileMeshes(fname) ; ms.cartesianizeMe() fields=MEDFileFields(fname,False) fields.removeFieldsWithoutAnyTimeStep() fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()] @@ -1472,7 +1500,11 @@ class MEDLoaderTest4(unittest.TestCase): for fields in fields_per_mesh: allFMTSLeavesToDisplay2=[] for fmts in fields: - allFMTSLeavesToDisplay2+=fmts.splitDiscretizations() + tmp=fmts.splitDiscretizations() + #for itmp in tmp: + # self.assertTrue(not itmp.presenceOfMultiDiscPerGeoType()) + # pass + allFMTSLeavesToDisplay2+=tmp pass allFMTSLeavesToDisplay.append(allFMTSLeavesToDisplay2) pass @@ -1608,7 +1640,7 @@ class MEDLoaderTest4(unittest.TestCase): a0Exp=mm.getCoords().deepCpy() del m,mm,fs1,fs2,fs3,f,fNode ########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values - ms=MEDFileMeshes(fname) + ms=MEDFileMeshes(fname) ; ms.cartesianizeMe() fields=MEDFileFields(fname,False) fields.removeFieldsWithoutAnyTimeStep() fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()] @@ -1616,7 +1648,11 @@ class MEDLoaderTest4(unittest.TestCase): for fields in fields_per_mesh: allFMTSLeavesToDisplay2=[] for fmts in fields: - allFMTSLeavesToDisplay2+=fmts.splitDiscretizations() + tmp=fmts.splitDiscretizations() + #for itmp in tmp: + # self.assertTrue(not itmp.presenceOfMultiDiscPerGeoType()) + # pass + allFMTSLeavesToDisplay2+=tmp pass allFMTSLeavesToDisplay.append(allFMTSLeavesToDisplay2) pass @@ -1737,7 +1773,7 @@ class MEDLoaderTest4(unittest.TestCase): a0Exp=mm.getCoords().deepCpy() del m,mm,fs1,fs2,f,fNode ########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values - ms=MEDFileMeshes(fname) + ms=MEDFileMeshes(fname) ; ms.cartesianizeMe() fields=MEDFileFields(fname,False) fields.removeFieldsWithoutAnyTimeStep() fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()] @@ -1745,7 +1781,11 @@ class MEDLoaderTest4(unittest.TestCase): for fields in fields_per_mesh: allFMTSLeavesToDisplay2=[] for fmts in fields: - allFMTSLeavesToDisplay2+=fmts.splitDiscretizations() + tmp=fmts.splitDiscretizations() + for itmp in tmp: + self.assertTrue(not itmp.presenceOfMultiDiscPerGeoType()) + pass + allFMTSLeavesToDisplay2+=tmp pass allFMTSLeavesToDisplay.append(allFMTSLeavesToDisplay2) pass @@ -1836,7 +1876,7 @@ class MEDLoaderTest4(unittest.TestCase): a0Exp=mm.getCoords().deepCpy() del m,mm,fs0,f,fNode ########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values - ms=MEDFileMeshes(fname) + ms=MEDFileMeshes(fname) ; ms.cartesianizeMe() fields=MEDFileFields(fname,False) fields.removeFieldsWithoutAnyTimeStep() fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()] @@ -1844,7 +1884,11 @@ class MEDLoaderTest4(unittest.TestCase): for fields in fields_per_mesh: allFMTSLeavesToDisplay2=[] for fmts in fields: - allFMTSLeavesToDisplay2+=fmts.splitDiscretizations() + tmp=fmts.splitDiscretizations() + #for itmp in tmp: + # self.assertTrue(not itmp.presenceOfMultiDiscPerGeoType()) + # pass + allFMTSLeavesToDisplay2+=tmp pass allFMTSLeavesToDisplay.append(allFMTSLeavesToDisplay2) pass @@ -1927,7 +1971,7 @@ class MEDLoaderTest4(unittest.TestCase): a0Exp=mm.getCoords().deepCpy() del m,mm,fs0,fs1,f,fNode ########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values - ms=MEDFileMeshes(fname) + ms=MEDFileMeshes(fname) ; ms.cartesianizeMe() fields=MEDFileFields(fname,False) fields.removeFieldsWithoutAnyTimeStep() fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()] @@ -1935,7 +1979,11 @@ class MEDLoaderTest4(unittest.TestCase): for fields in fields_per_mesh: allFMTSLeavesToDisplay2=[] for fmts in fields: - allFMTSLeavesToDisplay2+=fmts.splitDiscretizations() + tmp=fmts.splitDiscretizations() + #for itmp in tmp: + # self.assertTrue(not itmp.presenceOfMultiDiscPerGeoType()) + # pass + allFMTSLeavesToDisplay2+=tmp pass allFMTSLeavesToDisplay.append(allFMTSLeavesToDisplay2) pass @@ -2040,7 +2088,7 @@ class MEDLoaderTest4(unittest.TestCase): a0Exp=mm.getCoords().deepCpy() del m,mm,fs0 ########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values - ms=MEDFileMeshes(fname) + ms=MEDFileMeshes(fname) ; ms.cartesianizeMe() fields=MEDFileFields(fname,False) fields.removeFieldsWithoutAnyTimeStep() fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()] @@ -2048,7 +2096,11 @@ class MEDLoaderTest4(unittest.TestCase): for fields in fields_per_mesh: allFMTSLeavesToDisplay2=[] for fmts in fields: - allFMTSLeavesToDisplay2+=fmts.splitDiscretizations() + tmp=fmts.splitDiscretizations() + for itmp in tmp: + self.assertTrue(not itmp.presenceOfMultiDiscPerGeoType()) + pass + allFMTSLeavesToDisplay2+=tmp pass allFMTSLeavesToDisplay.append(allFMTSLeavesToDisplay2) pass @@ -2192,7 +2244,7 @@ class MEDLoaderTest4(unittest.TestCase): a0Exp=mm.getCoords().deepCpy() del m,mm,fs0 ########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values - ms=MEDFileMeshes(fname) + ms=MEDFileMeshes(fname) ; ms.cartesianizeMe() fields=MEDFileFields(fname,False) fields.removeFieldsWithoutAnyTimeStep() fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()] @@ -2200,7 +2252,11 @@ class MEDLoaderTest4(unittest.TestCase): for fields in fields_per_mesh: allFMTSLeavesToDisplay2=[] for fmts in fields: - allFMTSLeavesToDisplay2+=fmts.splitDiscretizations() + tmp=fmts.splitDiscretizations() + for itmp in tmp: + self.assertTrue(not itmp.presenceOfMultiDiscPerGeoType()) + pass + allFMTSLeavesToDisplay2+=tmp pass allFMTSLeavesToDisplay.append(allFMTSLeavesToDisplay2) pass @@ -2350,7 +2406,7 @@ class MEDLoaderTest4(unittest.TestCase): mm.write(fname,2) ffs.write(fname,0) ########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values - ms=MEDFileMeshes(fname) + ms=MEDFileMeshes(fname) ; ms.cartesianizeMe() fields=MEDFileFields(fname,False) fields.removeFieldsWithoutAnyTimeStep() fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()] @@ -2358,7 +2414,11 @@ class MEDLoaderTest4(unittest.TestCase): for fields in fields_per_mesh: allFMTSLeavesToDisplay2=[] for fmts in fields: - allFMTSLeavesToDisplay2+=fmts.splitDiscretizations() + tmp=fmts.splitDiscretizations() + for itmp in tmp: + self.assertTrue(not itmp.presenceOfMultiDiscPerGeoType()) + pass + allFMTSLeavesToDisplay2+=tmp pass allFMTSLeavesToDisplay.append(allFMTSLeavesToDisplay2) pass @@ -2538,7 +2598,7 @@ class MEDLoaderTest4(unittest.TestCase): # mms.write(fname,2) ; mts.write(fname,0) ########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values - ms=MEDFileMeshes(fname) + ms=MEDFileMeshes(fname) ; ms.cartesianizeMe() fields=MEDFileFields(fname,False) fields.removeFieldsWithoutAnyTimeStep() fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()] @@ -2546,7 +2606,11 @@ class MEDLoaderTest4(unittest.TestCase): for fields in fields_per_mesh: allFMTSLeavesToDisplay2=[] for fmts in fields: - allFMTSLeavesToDisplay2+=fmts.splitDiscretizations() + tmp=fmts.splitDiscretizations() + for itmp in tmp: + self.assertTrue(not itmp.presenceOfMultiDiscPerGeoType()) + pass + allFMTSLeavesToDisplay2+=tmp pass allFMTSLeavesToDisplay.append(allFMTSLeavesToDisplay2) pass @@ -2610,7 +2674,7 @@ class MEDLoaderTest4(unittest.TestCase): f3.setName(fieldName3) MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fname,f3) ########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values - ms=MEDFileMeshes(fname) + ms=MEDFileMeshes(fname) ; ms.cartesianizeMe() fields=MEDFileFields(fname,False) fields.removeFieldsWithoutAnyTimeStep() fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()] @@ -2618,7 +2682,11 @@ class MEDLoaderTest4(unittest.TestCase): for fields in fields_per_mesh: allFMTSLeavesToDisplay2=[] for fmts in fields: - allFMTSLeavesToDisplay2+=fmts.splitDiscretizations() + tmp=fmts.splitDiscretizations() + for itmp in tmp: + self.assertTrue(not itmp.presenceOfMultiDiscPerGeoType()) + pass + allFMTSLeavesToDisplay2+=tmp pass allFMTSLeavesToDisplay.append(allFMTSLeavesToDisplay2) pass @@ -2722,7 +2790,7 @@ class MEDLoaderTest4(unittest.TestCase): f3.setName(fieldName3) MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fname,f3) ########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values - ms=MEDFileMeshes(fname) + ms=MEDFileMeshes(fname) ; ms.cartesianizeMe() fields=MEDFileFields(fname,False) fields.removeFieldsWithoutAnyTimeStep() fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()] @@ -2730,7 +2798,11 @@ class MEDLoaderTest4(unittest.TestCase): for fields in fields_per_mesh: allFMTSLeavesToDisplay2=[] for fmts in fields: - allFMTSLeavesToDisplay2+=fmts.splitDiscretizations() + tmp=fmts.splitDiscretizations() + for itmp in tmp: + self.assertTrue(not itmp.presenceOfMultiDiscPerGeoType()) + pass + allFMTSLeavesToDisplay2+=tmp pass allFMTSLeavesToDisplay.append(allFMTSLeavesToDisplay2) pass @@ -2788,14 +2860,18 @@ class MEDLoaderTest4(unittest.TestCase): self.assertTrue(v.isEqual(vExp1[i],1e-12)) pass ## Now same exercise but with a different load strategy. All is load directly. - ms=MEDFileMeshes(fname) + ms=MEDFileMeshes(fname) ; ms.cartesianizeMe() fields=MEDFileFields(fname) # here all is read, the SauvReader (or other Reader) is emulated fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()] allFMTSLeavesToDisplay=[] for fields in fields_per_mesh: allFMTSLeavesToDisplay2=[] for fmts in fields: - allFMTSLeavesToDisplay2+=fmts.splitDiscretizations() + tmp=fmts.splitDiscretizations() + for itmp in tmp: + self.assertTrue(not itmp.presenceOfMultiDiscPerGeoType()) + pass + allFMTSLeavesToDisplay2+=tmp pass allFMTSLeavesToDisplay.append(allFMTSLeavesToDisplay2) pass @@ -2888,7 +2964,7 @@ class MEDLoaderTest4(unittest.TestCase): mm.write(fname,2) ff.write(fname,0) ########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values - ms=MEDFileMeshes(fname) + ms=MEDFileMeshes(fname) ; ms.cartesianizeMe() fields=MEDFileFields(fname,False) fields.removeFieldsWithoutAnyTimeStep() fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()] @@ -2896,7 +2972,11 @@ class MEDLoaderTest4(unittest.TestCase): for fields in fields_per_mesh: allFMTSLeavesToDisplay2=[] for fmts in fields: - allFMTSLeavesToDisplay2+=fmts.splitDiscretizations() + tmp=fmts.splitDiscretizations() + for itmp in tmp: + self.assertTrue(not itmp.presenceOfMultiDiscPerGeoType()) + pass + allFMTSLeavesToDisplay2+=tmp pass allFMTSLeavesToDisplay.append(allFMTSLeavesToDisplay2) pass @@ -3068,7 +3148,7 @@ class MEDLoaderTest4(unittest.TestCase): fs.appendGlobs(fmts3,1e-12) fs.write(fname,0) ########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values - ms=MEDFileMeshes(fname) + ms=MEDFileMeshes(fname) ; ms.cartesianizeMe() fields=MEDFileFields(fname,False) fields.removeFieldsWithoutAnyTimeStep() fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()] @@ -3076,7 +3156,11 @@ class MEDLoaderTest4(unittest.TestCase): for fields in fields_per_mesh: allFMTSLeavesToDisplay2=[] for fmts in fields: - allFMTSLeavesToDisplay2+=fmts.splitDiscretizations() + tmp=fmts.splitDiscretizations() + for itmp in tmp: + self.assertTrue(not itmp.presenceOfMultiDiscPerGeoType()) + pass + allFMTSLeavesToDisplay2+=tmp pass allFMTSLeavesToDisplay.append(allFMTSLeavesToDisplay2) pass @@ -3265,7 +3349,7 @@ class MEDLoaderTest4(unittest.TestCase): mm.write(fname,2) fs.write(fname,0) ########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values - ms=MEDFileMeshes(fname) + ms=MEDFileMeshes(fname) ; ms.cartesianizeMe() fields=MEDFileFields(fname,False) fields.removeFieldsWithoutAnyTimeStep() fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()] @@ -3273,7 +3357,11 @@ class MEDLoaderTest4(unittest.TestCase): for fields in fields_per_mesh: allFMTSLeavesToDisplay2=[] for fmts in fields: - allFMTSLeavesToDisplay2+=fmts.splitDiscretizations() + tmp=fmts.splitDiscretizations() + for itmp in tmp: + self.assertTrue(not itmp.presenceOfMultiDiscPerGeoType()) + pass + allFMTSLeavesToDisplay2+=tmp pass allFMTSLeavesToDisplay.append(allFMTSLeavesToDisplay2) pass @@ -3373,7 +3461,7 @@ class MEDLoaderTest4(unittest.TestCase): mm.write(fname,2) fmts0.write(fname,0) ########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values - ms=MEDFileMeshes(fname) + ms=MEDFileMeshes(fname) ; ms.cartesianizeMe() fields=MEDFileFields(fname,False) fields.removeFieldsWithoutAnyTimeStep() fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()] @@ -3381,7 +3469,11 @@ class MEDLoaderTest4(unittest.TestCase): for fields in fields_per_mesh: allFMTSLeavesToDisplay2=[] for fmts in fields: - allFMTSLeavesToDisplay2+=fmts.splitDiscretizations() + tmp=fmts.splitDiscretizations() + for itmp in tmp: + self.assertTrue(not itmp.presenceOfMultiDiscPerGeoType()) + pass + allFMTSLeavesToDisplay2+=tmp pass allFMTSLeavesToDisplay.append(allFMTSLeavesToDisplay2) pass @@ -3474,7 +3566,7 @@ class MEDLoaderTest4(unittest.TestCase): mm.write(fname,2) fmts0.write(fname,0) ########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values - ms=MEDFileMeshes(fname) + ms=MEDFileMeshes(fname) ; ms.cartesianizeMe() fields=MEDFileFields(fname,False) fields.removeFieldsWithoutAnyTimeStep() fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()] @@ -3482,7 +3574,11 @@ class MEDLoaderTest4(unittest.TestCase): for fields in fields_per_mesh: allFMTSLeavesToDisplay2=[] for fmts in fields: - allFMTSLeavesToDisplay2+=fmts.splitDiscretizations() + tmp=fmts.splitDiscretizations() + for itmp in tmp: + self.assertTrue(not itmp.presenceOfMultiDiscPerGeoType()) + pass + allFMTSLeavesToDisplay2+=tmp pass allFMTSLeavesToDisplay.append(allFMTSLeavesToDisplay2) pass @@ -3578,7 +3674,7 @@ class MEDLoaderTest4(unittest.TestCase): m.write(fname,2) fmts.write(fname,0) ########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values - ms=MEDFileMeshes(fname) + ms=MEDFileMeshes(fname) ; ms.cartesianizeMe() fields=MEDFileFields(fname,False) # false is absolutely necessary for the test fields.removeFieldsWithoutAnyTimeStep() fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()] @@ -3586,7 +3682,11 @@ class MEDLoaderTest4(unittest.TestCase): for fields in fields_per_mesh: allFMTSLeavesToDisplay2=[] for fmts in fields: - allFMTSLeavesToDisplay2+=fmts.splitDiscretizations() + tmp=fmts.splitDiscretizations() + for itmp in tmp: + self.assertTrue(not itmp.presenceOfMultiDiscPerGeoType()) + pass + allFMTSLeavesToDisplay2+=tmp pass allFMTSLeavesToDisplay.append(allFMTSLeavesToDisplay2) pass @@ -3788,7 +3888,7 @@ class MEDLoaderTest4(unittest.TestCase): mm.write(fname,2) fs.write(fname,0) ########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values - ms=MEDFileMeshes(fname) + ms=MEDFileMeshes(fname) ; ms.cartesianizeMe() fields=MEDFileFields(fname,False) fields.removeFieldsWithoutAnyTimeStep() fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()] @@ -3796,7 +3896,11 @@ class MEDLoaderTest4(unittest.TestCase): for fields in fields_per_mesh: allFMTSLeavesToDisplay2=[] for fmts in fields: - allFMTSLeavesToDisplay2+=fmts.splitDiscretizations() + tmp=fmts.splitDiscretizations() + for itmp in tmp: + self.assertTrue(not itmp.presenceOfMultiDiscPerGeoType()) + pass + allFMTSLeavesToDisplay2+=tmp pass allFMTSLeavesToDisplay.append(allFMTSLeavesToDisplay2) pass @@ -3899,7 +4003,7 @@ class MEDLoaderTest4(unittest.TestCase): mm.write(fname,2) fs.write(fname,0) ########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values - ms=MEDFileMeshes(fname) + ms=MEDFileMeshes(fname) ; ms.cartesianizeMe() fields=MEDFileFields(fname,False) fields.removeFieldsWithoutAnyTimeStep() self.assertEqual(fields[0].getMeshName(),"mesh") @@ -3911,7 +4015,11 @@ class MEDLoaderTest4(unittest.TestCase): for fields in fields_per_mesh: allFMTSLeavesToDisplay2=[] for fmts in fields: - allFMTSLeavesToDisplay2+=fmts.splitDiscretizations() + tmp=fmts.splitDiscretizations() + for itmp in tmp: + self.assertTrue(not itmp.presenceOfMultiDiscPerGeoType()) + pass + allFMTSLeavesToDisplay2+=tmp pass allFMTSLeavesToDisplay.append(allFMTSLeavesToDisplay2) pass @@ -4041,7 +4149,7 @@ class MEDLoaderTest4(unittest.TestCase): mm.write(fname,2) fs.write(fname,0) ########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values - ms=MEDFileMeshes(fname) + ms=MEDFileMeshes(fname) ; ms.cartesianizeMe() fields=MEDFileFields(fname,False) fields.removeFieldsWithoutAnyTimeStep() fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()] @@ -4049,7 +4157,11 @@ class MEDLoaderTest4(unittest.TestCase): for fields in fields_per_mesh: allFMTSLeavesToDisplay2=[] for fmts in fields: - allFMTSLeavesToDisplay2+=fmts.splitDiscretizations() + tmp=fmts.splitDiscretizations() + for itmp in tmp: + self.assertTrue(not itmp.presenceOfMultiDiscPerGeoType()) + pass + allFMTSLeavesToDisplay2+=tmp pass allFMTSLeavesToDisplay.append(allFMTSLeavesToDisplay2) pass @@ -4175,7 +4287,7 @@ class MEDLoaderTest4(unittest.TestCase): fGauss.setArray(arrGauss) MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fname,fGauss) ########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values - ms=MEDFileMeshes(fname) + ms=MEDFileMeshes(fname) ; ms.cartesianizeMe() fields=MEDFileFields(fname,False) fields.removeFieldsWithoutAnyTimeStep() fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()] @@ -4183,7 +4295,11 @@ class MEDLoaderTest4(unittest.TestCase): for fields in fields_per_mesh: allFMTSLeavesToDisplay2=[] for fmts in fields: - allFMTSLeavesToDisplay2+=fmts.splitDiscretizations() + tmp=fmts.splitDiscretizations() + for itmp in tmp: + self.assertTrue(not itmp.presenceOfMultiDiscPerGeoType()) + pass + allFMTSLeavesToDisplay2+=tmp pass allFMTSLeavesToDisplay.append(allFMTSLeavesToDisplay2) pass @@ -4279,7 +4395,7 @@ class MEDLoaderTest4(unittest.TestCase): cc.write(fname,2) fs.write(fname,0) ########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values - ms=MEDFileMeshes(fname) + ms=MEDFileMeshes(fname) ; ms.cartesianizeMe() fields=MEDFileFields(fname,False) fields.removeFieldsWithoutAnyTimeStep() fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()] @@ -4287,7 +4403,11 @@ class MEDLoaderTest4(unittest.TestCase): for fields in fields_per_mesh: allFMTSLeavesToDisplay2=[] for fmts in fields: - allFMTSLeavesToDisplay2+=fmts.splitDiscretizations() + tmp=fmts.splitDiscretizations() + for itmp in tmp: + self.assertTrue(not itmp.presenceOfMultiDiscPerGeoType()) + pass + allFMTSLeavesToDisplay2+=tmp pass allFMTSLeavesToDisplay.append(allFMTSLeavesToDisplay2) pass @@ -4385,7 +4505,7 @@ class MEDLoaderTest4(unittest.TestCase): cc.write(fname,2) fs.write(fname,0) ########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values - ms=MEDFileMeshes(fname) + ms=MEDFileMeshes(fname) ; ms.cartesianizeMe() fields=MEDFileFields(fname,False) fields.removeFieldsWithoutAnyTimeStep() fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()] @@ -4393,7 +4513,11 @@ class MEDLoaderTest4(unittest.TestCase): for fields in fields_per_mesh: allFMTSLeavesToDisplay2=[] for fmts in fields: - allFMTSLeavesToDisplay2+=fmts.splitDiscretizations() + tmp=fmts.splitDiscretizations() + for itmp in tmp: + self.assertTrue(not itmp.presenceOfMultiDiscPerGeoType()) + pass + allFMTSLeavesToDisplay2+=tmp pass allFMTSLeavesToDisplay.append(allFMTSLeavesToDisplay2) pass @@ -4481,7 +4605,7 @@ class MEDLoaderTest4(unittest.TestCase): cc.write(fname,2) fs.write(fname,0) ########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values - ms=MEDFileMeshes(fname) + ms=MEDFileMeshes(fname) ; ms.cartesianizeMe() fields=MEDFileFields(fname,False) fields.removeFieldsWithoutAnyTimeStep() fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()] @@ -4489,7 +4613,11 @@ class MEDLoaderTest4(unittest.TestCase): for fields in fields_per_mesh: allFMTSLeavesToDisplay2=[] for fmts in fields: - allFMTSLeavesToDisplay2+=fmts.splitDiscretizations() + tmp=fmts.splitDiscretizations() + for itmp in tmp: + self.assertTrue(not itmp.presenceOfMultiDiscPerGeoType()) + pass + allFMTSLeavesToDisplay2+=tmp pass allFMTSLeavesToDisplay.append(allFMTSLeavesToDisplay2) pass @@ -4581,7 +4709,7 @@ class MEDLoaderTest4(unittest.TestCase): MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fname,fCell0) pass ########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values - ms=MEDFileMeshes(fname) + ms=MEDFileMeshes(fname) ; ms.cartesianizeMe() fields=MEDFileFields(fname,False) fields.removeFieldsWithoutAnyTimeStep() fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()] @@ -4589,7 +4717,11 @@ class MEDLoaderTest4(unittest.TestCase): for fields in fields_per_mesh: allFMTSLeavesToDisplay2=[] for fmts in fields: - allFMTSLeavesToDisplay2+=fmts.splitDiscretizations() + tmp=fmts.splitDiscretizations() + for itmp in tmp: + self.assertTrue(not itmp.presenceOfMultiDiscPerGeoType()) + pass + allFMTSLeavesToDisplay2+=tmp pass allFMTSLeavesToDisplay.append(allFMTSLeavesToDisplay2) pass @@ -4627,6 +4759,624 @@ class MEDLoaderTest4(unittest.TestCase): self.assertTrue(v.isEqual(myarr,1e-12)) pass pass + + def test34(self): + """ This test is the thirs ultimate test (base on test12) for the profiles with gauss points. + This test highlight the hidden imp linked to bug #8655. + This test is close to test11 but here a 2nd field on cells without profile. So here the mesh is expected to be the same than m. + """ + fname="ForMEDReader34.med" + m=MEDCouplingCMesh("mesh") + arr=DataArrayDouble(5) ; arr.iota() + m.setCoords(arr,arr) + m=m.buildUnstructured() ; m.getCoords().setInfoOnComponents(["XX [m]","YYY [km]"]) + mm=MEDFileUMesh() ; mm.setMeshes([m]) + # + fieldName0="zeField0" + fieldName1="zeField1" + fs0=MEDFileFieldMultiTS() ; fs1=MEDFileFieldMultiTS() + for i in xrange(5): + f=MEDFileField1TS() + fNode=MEDCouplingFieldDouble(ON_GAUSS_PT) ; fNode.setTime(float(i),i,0) + fNode.setName(fieldName0) ; fNode.setMesh(m) + fNode.setGaussLocalizationOnCells([0,2,3,4,7,15],[-1.,-1.,1.,-1.,1.,1.,-1.,1.],[0.5,0.5,0.7,0.7],[0.8,0.2]) + fNode.setGaussLocalizationOnCells([1,5,8,9],[-1.,-1.,1.,-1.,1.,1.,-1.,1.],[0.5,0.5,0.7,0.7,0.1,0.1,0.2,0.2,0.3,0.3],[0.8,0.05,0.1,0.04,0.01]) + fNode.setGaussLocalizationOnCells([6,10,13],[-1.,-1.,1.,-1.,1.,1.,-1.,1.],[0.5,0.5,0.7,0.7,0.1,0.1,0.2,0.2],[0.8,0.05,0.1,0.04]) + fNode.setGaussLocalizationOnCells([11,12,14],[-1.,-1.,1.,-1.,1.,1.,-1.,1.],[0.5,0.5,0.7,0.7,0.1,0.1,0.2,0.2,0.3,0.3,0.4,0.4,0.8,0.8],[0.8,0.05,0.1,0.01,0.02,0.005,0.005]) + arr=DataArrayDouble(2*(2*6+5*4+4*3+7*3)) ; arr.iota(0+1000*i) ; arr.rearrange(2) + fNode.setArray(arr) ; arr.setInfoOnComponents(["Comp1_0 [m]","Com2_0 [s^2]"]) ; fNode.checkCoherency() + f.setFieldNoProfileSBT(fNode) + fs0.pushBackTimeStep(f) + # + f=MEDFileField1TS() + fNode=MEDCouplingFieldDouble(ON_CELLS) ; fNode.setTime(float(i),i,0) + fNode.setName(fieldName1) ; fNode.setMesh(m) + arr=DataArrayDouble(2*16) ; arr.iota(300+1000*i) ; arr.rearrange(2) + fNode.setArray(arr) ; arr.setInfoOnComponents(["Comp1_1 [m]","Com2_1 [s^2]"]) ; fNode.checkCoherency() + f.setFieldNoProfileSBT(fNode) + fs1.pushBackTimeStep(f) + pass + mm.write(fname,2) + fs0.write(fname,0) ; fs1.write(fname,0) + a0Exp=mm.getCoords().deepCpy() + del m,mm,fs0,fs1,f,fNode + ########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values + 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: + 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 + # Here 2 MED fields in input and at the end 5 ! 1+4 ! 4 fields have been built from zeField0 due to subspliting per dis / per geo type + self.assertEqual(len(allFMTSLeavesToDisplay),1) + self.assertEqual(len(allFMTSLeavesToDisplay[0]),5) + 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]),5) + allFMTSLeavesPerCommonSupport=MEDFileAnyTypeFieldMultiTS.SplitPerCommonSupport(allFMTSLeavesPerTimeSeries[0],ms[ms.getMeshesNames()[0]]) + self.assertEqual(len(allFMTSLeavesPerCommonSupport),5) + for i in xrange(5): + self.assertEqual(len(allFMTSLeavesPerCommonSupport[i][0]),1) + # + mst=MEDFileMeshStruct.New(ms[0]) + # + fcscp=allFMTSLeavesPerCommonSupport[4][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([9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9]))) + self.assertTrue(a2.isEqual(DataArrayInt([0,5,10,15,20,25,30,35,40,45,50,55,60,65,70,75]))) + self.assertTrue(a3.isEqual(DataArrayInt([4,1,0,5,6,4,2,1,6,7,4,3,2,7,8,4,4,3,8,9,4,6,5,10,11,4,7,6,11,12,4,8,7,12,13,4,9,8,13,14,4,11,10,15,16,4,12,11,16,17,4,13,12,17,18,4,14,13,18,19,4,16,15,20,21,4,17,16,21,22,4,18,17,22,23,4,19,18,23,24]))) # <- here the mesh is NOT renumbered : the mesh is equal to m + self.assertTrue(a4 is None) + self.assertTrue(a5 is None) + for i in xrange(1,5): + self.assertTrue((fcscp.isDataSetSupportEqualToThePreviousOne(i,fields))) + pass + for i in xrange(5): + f=allFMTSLeavesPerCommonSupport[0][0][0][i] + fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst) + f.loadArraysIfNecessary() + v=mml.buildDataArray(fsst,fields,f.getUndergroundDataArray()) + self.assertEqual(f.getName(),fieldName0) + vExp=DataArrayDouble([(0.,1.),(2.,3.),(14.,15.),(16.,17.),(18.,19.),(20.,21.),(22.,23.),(24.,25.),(44.,45.),(46.,47.),(126.,127.),(128.,129.)]) + vExp.setInfoOnComponents(['Comp1_0 [m]','Com2_0 [s^2]']) + vExp+=i*1000 + self.assertTrue(v.isEqual(vExp,1e-12)) + # + f=allFMTSLeavesPerCommonSupport[1][0][0][i] + fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst) + f.loadArraysIfNecessary() + v=mml.buildDataArray(fsst,fields,f.getUndergroundDataArray()) + self.assertEqual(f.getName(),fieldName0) + vExp=DataArrayDouble([(4.,5.),(6.,7.),(8.,9.),(10.,11.),(12.,13.),(26.,27.),(28.,29.),(30.,31.),(32.,33.),(34.,35.),(48.,49.),(50.,51.),(52.,53.),(54.,55.),(56.,57.),(58.,59.),(60.,61.),(62.,63.),(64.,65.),(66.,67.)]) + vExp.setInfoOnComponents(['Comp1_0 [m]','Com2_0 [s^2]']) + vExp+=i*1000 + self.assertTrue(v.isEqual(vExp,1e-12)) + # + f=allFMTSLeavesPerCommonSupport[2][0][0][i] + fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst) + f.loadArraysIfNecessary() + v=mml.buildDataArray(fsst,fields,f.getUndergroundDataArray()) + self.assertEqual(f.getName(),fieldName0) + vExp=DataArrayDouble([(36.,37.),(38.,39.),(40.,41.),(42.,43.),(68.,69.),(70.,71.),(72.,73.),(74.,75.),(104.,105.),(106.,107.),(108.,109.),(110.,111.)]) + vExp.setInfoOnComponents(['Comp1_0 [m]','Com2_0 [s^2]']) + vExp+=i*1000 + self.assertTrue(v.isEqual(vExp,1e-12)) + # + f=allFMTSLeavesPerCommonSupport[3][0][0][i] + fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst) + f.loadArraysIfNecessary() + v=mml.buildDataArray(fsst,fields,f.getUndergroundDataArray()) + self.assertEqual(f.getName(),fieldName0) + vExp=DataArrayDouble([(76,77),(78,79),(80,81),(82,83),(84,85),(86,87),(88,89),(90,91),(92,93),(94,95),(96,97),(98,99),(100,101),(102,103),(112,113),(114,115),(116,117),(118,119),(120,121),(122,123),(124,125)]) + vExp.setInfoOnComponents(['Comp1_0 [m]','Com2_0 [s^2]']) + vExp+=i*1000 + self.assertTrue(v.isEqual(vExp,1e-12)) + # + f=allFMTSLeavesPerCommonSupport[4][0][0][i] + fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst) + f.loadArraysIfNecessary() + v=mml.buildDataArray(fsst,fields,f.getUndergroundDataArray()) + self.assertEqual(f.getName(),fieldName1) + self.assertEqual(v.getHiddenCppPointer(),f.getUndergroundDataArray().getHiddenCppPointer()) + vExp=DataArrayDouble(16*2) ; vExp.iota(300+i*1000) ; vExp.rearrange(2) ; vExp.setInfoOnComponents(['Comp1_1 [m]','Com2_1 [s^2]']) + self.assertTrue(v.isEqual(vExp,1e-12)) + pass + 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.""" + 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"]) + MEDLoader.WriteUMesh(fname,m,True) + MEDLoader.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) + 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 + + 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.checkCoherency() + 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.checkCoherency() + 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.checkCoherency() + f3.setTime(*zeTime) + f3.setName("aaa") + ff3.setFieldNoProfileSBT(f3) + # + ff4=MEDFileField1TS() + m0d=m0.deepCpy() ; m0d.zipCoords() + f4=MEDCouplingFieldDouble(ON_NODES) ; f4.setMesh(m0d) + arr=DataArrayDouble(5) ; arr.iota(3000) + f4.setArray(arr) + f4.setName("ccc") + f4.checkCoherency() + 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) + for i in xrange(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) + for i in xrange(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 + + 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.setAxType(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.checkCoherency() + 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) + # WARNING for the moment we do not reread fname ! It is not a hidden bug it is just to wait EF control. Coming soon. + 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]) + for i in xrange(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 + + 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.setAxType(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.checkCoherency() + 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) + # WARNING for the moment we do not reread fname ! It is not a hidden bug it is just to wait EF control. Coming soon. + 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]) + for i in xrange(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 + + 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.setAxType(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.checkCoherency() + 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,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 + for i in xrange(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 + + 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.setAxType(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.checkCoherency() + 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]) + for i in xrange(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 -unittest.main() +if __name__ == "__main__": + unittest.main()