]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
[EDF26665] : MEDFileFieldMultiTS.setInfo added in Python wrapping of MEDLoader
authorAnthony Geay <anthony.geay@edf.fr>
Wed, 28 Dec 2022 07:37:01 +0000 (08:37 +0100)
committerAnthony Geay <anthony.geay@edf.fr>
Wed, 28 Dec 2022 07:37:01 +0000 (08:37 +0100)
src/MEDLoader/Swig/MEDLoaderCommon.i
src/MEDLoader/Swig/MEDLoaderTest3.py

index 4befee3420805532d6c79a9b0fc64fb8fad38d33..9bfac569fb47570dc47f0f33c6ca4cc8ba532486 100644 (file)
@@ -2674,6 +2674,7 @@ namespace MEDCoupling
     void setDtUnit(const std::string& dtUnit);
     std::string getMeshName() const;
     void setMeshName(const std::string& newMeshName);
+    void setInfo(const std::vector<std::string>& infos);
     const std::vector<std::string>& getInfo() const;
     bool presenceOfMultiDiscPerGeoType() const;
     int getNumberOfComponents() const;
index 6ff02b41a10f94f81bc47a961a56470933723c30..c0556b16b5a6213218b780aec41b3affb93cde35 100644 (file)
@@ -7073,6 +7073,48 @@ class MEDLoaderTest3(unittest.TestCase):
         self.assertTrue( m0.isEqual(mm[0],1e-12) )
         pass
 
+    @WriteInTmpDir
+    def testFieldMultiTSSetInfo0(self):
+        """
+        [EDF26665] : Test written to check correct behaviour of MEDFileFieldMultiTS.setInfo, lacking in Python wrappers
+        """
+        fname = "Pyfile122.med"
+        def generateAMEDFileFromScratch(fname,fieldToGenerate):
+            arr  = DataArrayDouble(10) ; arr.iota()
+            m = MEDCouplingCMesh() ; m.setCoords(arr,arr)
+            m = m.buildUnstructured() ; m.setName("mesh")
+            f = MEDCouplingFieldDouble(ON_CELLS)
+            f.setMesh(m)
+            f.setName(fieldToGenerate)
+            arr = DataArrayDouble( f.getNumberOfMeshPlacesExpected() )
+            f.setArray(arr)
+            WriteMesh(fname,m,True)
+            for i in range(10):
+                arr[:] = float(i) + 0.1
+                f.setTime(float(i) + 0.1, i , 0)
+                WriteFieldUsingAlreadyWrittenMesh(fname,f)
+
+
+        def changeCompoInMEDFile(fname, fnameTarget, fieldToModify):
+            mfd = MEDFileData(fname)
+            mfd.getMeshes().write(fnameTarget,2)
+            fmtsToModify = mfd.getFields().getFieldWithName(fieldToModify)
+            for f1ts in fmtsToModify:
+                self.assertTrue( f1ts.getUndergroundDataArray().getInfoOnComponents() != ["Scalars"])
+            fmtsToModify.setInfo(["Scalars"]) # <- test is here !
+            fmtsToModify.write(fnameTarget,0)
+
+        fieldToModify = "Field122"
+        generateAMEDFileFromScratch(fname,fieldToModify)
+        fnameTarget = fname
+        changeCompoInMEDFile(fname,fnameTarget,fieldToModify)
+
+        fmts = MEDFileFieldMultiTS(fname,fieldToModify)
+        for f1ts in fmts:
+            self.assertTrue( f1ts.getUndergroundDataArray().getInfoOnComponents() == ["Scalars"])
+
+        pass
+
     pass
 
 if __name__ == "__main__":