From 82f7a744157ddd8346969cb724fef4e1a47a4b7b Mon Sep 17 00:00:00 2001 From: ageay Date: Wed, 24 Aug 2011 08:43:41 +0000 Subject: [PATCH] Bug correction 2 on globals in MEDFileFields. --- src/MEDLoader/MEDFileField.cxx | 1 + src/MEDLoader/Swig/MEDLoaderTest3.py | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/src/MEDLoader/MEDFileField.cxx b/src/MEDLoader/MEDFileField.cxx index c3cdfb3ff..e0f5c38bf 100644 --- a/src/MEDLoader/MEDFileField.cxx +++ b/src/MEDLoader/MEDFileField.cxx @@ -2701,6 +2701,7 @@ void MEDFileFields::pushField(MEDFileFieldMultiTS *field) throw(INTERP_KERNEL::E throw INTERP_KERNEL::Exception("MEDFileFields::pushMesh : invalid input pointer ! should be different from 0 !"); field->incrRef(); _fields.push_back(field); + appendGlobs(*field,1e-12); } void MEDFileFields::setFieldAtPos(int i, MEDFileFieldMultiTS *field) throw(INTERP_KERNEL::Exception) diff --git a/src/MEDLoader/Swig/MEDLoaderTest3.py b/src/MEDLoader/Swig/MEDLoaderTest3.py index e69815b4d..2e95f0cca 100644 --- a/src/MEDLoader/Swig/MEDLoaderTest3.py +++ b/src/MEDLoader/Swig/MEDLoaderTest3.py @@ -819,6 +819,32 @@ class MEDLoaderTest(unittest.TestCase): f4=ff3.getFieldAtTopLevel(ON_CELLS,1,2) self.assertTrue(f4.getArray().isEqual(f1.getArray(),1e-12)) pass + + # Non regression test to check that globals are correctly appended on MEDFileFields::setFieldAtPos + def testMEDField18(self): + fname="Pyfile40.med" + m1=MEDLoaderDataForTest.build2DMesh_1() + m1.renumberCells([0,1,4,2,3,5],False) + mm1=MEDFileUMesh.New() ; mm1.setCoords(m1.getCoords()) ; mm1.setMeshAtLevel(0,m1) ; mm1.setName(m1.getName()) + mm1.write(fname,2) + ffs=MEDFileFields.New() + ff1=MEDFileFieldMultiTS.New() + f1=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME) ; f1.setName("F2") + d=DataArrayDouble.New() ; d.alloc(2*4,1) ; d.iota(7.); d.rearrange(2); d.setInfoOnComponent(0,"sigX [MPa]") ; d.setInfoOnComponent(1,"sigY [GPa]") + f1.setArray(d) # note that f1 is NOT defined fully (no mesh !). It is not a bug of test it is too test that MEDFileField1TS.appendFieldProfile is NOT sensible of that. + da=DataArrayInt.New(); da.setValues([0,1,2,4],4,1) ; da.setName("sup2") + # + ff1.appendFieldProfile(f1,mm1,0,da) + f1.setTime(1.2,1,2) ; e=d.applyFunc("2*x") ; e.copyStringInfoFrom(d) ; f1.setArray(e) ; + ff1.appendFieldProfile(f1,mm1,0,da) + ffs.pushField(ff1) + ffs.write(fname,0) + # + ffsr=MEDFileFields.New(fname) + ff3=ffsr.getFieldAtPos(0) + f4=ff3.getFieldAtTopLevel(ON_CELLS,1,2) + self.assertTrue(f4.getArray().isEqual(f1.getArray(),1e-12)) + pass pass unittest.main() -- 2.39.2