]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
EDF13251 : Correction of bug in appendFieldProfile for MEDFileIntFieldMultiTS objects.
authorAnthony Geay <anthony.geay@edf.fr>
Mon, 11 Jul 2016 11:16:09 +0000 (13:16 +0200)
committerAnthony Geay <anthony.geay@edf.fr>
Mon, 11 Jul 2016 11:16:09 +0000 (13:16 +0200)
src/MEDLoader/MEDFileField.cxx
src/MEDLoader/Swig/MEDLoaderTest3.py

index 85ffea449044e94ac5fbd93c1222b28210314f7c..2b362ece3abb2d7f2b7b6ee536b3ccd9ba03a63b 100644 (file)
@@ -7961,7 +7961,7 @@ void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldProfile(const MEDCouplingF
     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
   if(!_time_steps.empty())
     checkCoherencyOfTinyInfo(field,arr);
-  MEDFileField1TSWithoutSDA *objC=new MEDFileField1TSWithoutSDA;
+  MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
   objC->setFieldProfile(field,arr,mesh,meshDimRelToMax,profile,glob,*this);
   copyTinyInfoFrom(field,arr);
index a3825d4be8349376c2cabba22a8ddefc024b9e4e..4d7d753bebdc3c34841826792708be87842c2f17 100644 (file)
@@ -5090,6 +5090,42 @@ class MEDLoaderTest3(unittest.TestCase):
       self.assertTrue(mm2.getFamilyFieldAtLevel(1) is None)
       pass
 
+    def testAppendFieldProfileOnIntField(self):
+      fname="Pyfile100.med"
+      arrX=DataArrayDouble([0,1,2,3])
+      arrY=DataArrayDouble([0,1,2])
+      mesh=MEDCouplingCMesh() ; mesh.setCoords(arrX,arrY) ; mesh.setName("Mesh")
+      mm=MEDFileCMesh()
+      mm.setMesh(mesh)
+      #
+      fmts=MEDFileIntFieldMultiTS()
+      pflName="PFL"
+      pfl=DataArrayInt([1,3,5]) ; pfl.setName(pflName)
+      f=MEDCouplingFieldDouble(ON_CELLS) ; f.setMesh(mesh)
+      fieldName="FieldOnCell"
+      f.setTime(1.2,1,1) ; f.setName(fieldName)
+      arr=DataArrayInt([101,102,103])
+      fmts.appendFieldProfile(f,arr,mm,0,pfl)
+      #
+      mm.write(fname,2)
+      fmts.write(fname,0)
+      #
+      mm=MEDFileMesh.New(fname)
+      fmts=MEDFileAnyTypeFieldMultiTS.New(fname)
+      self.assertTrue(isinstance(fmts,MEDFileIntFieldMultiTS))
+      self.assertEqual(fmts.getName(),fieldName)
+      self.assertEqual(len(fmts),1)
+      f1ts=fmts[0]
+      ftest,pfltest=f1ts.getFieldWithProfile(ON_CELLS,0,mm)
+      self.assertEqual(pfltest.getName(),pflName)
+      self.assertEqual(ftest.getName(),fieldName)
+      self.assertTrue(ftest.isEqualWithoutConsideringStr(arr))
+      ftest2,vals=f1ts.getFieldOnMeshAtLevel(ON_CELLS,0,mm)
+      self.assertTrue(vals.isEqualWithoutConsideringStr(arr))
+      self.assertEqual(ftest2.getTime(),f.getTime())
+      self.assertEqual(ftest2.getMesh().getNumberOfCells(),len(arr))
+      pass
+
     pass
 
 if __name__ == "__main__":