From: Anthony Geay Date: Tue, 5 Feb 2019 07:38:23 +0000 (+0100) Subject: Bug correction : Multi WriteField on field lying on mesh with duplicate nodes X-Git-Tag: V9_3_0a1~9 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=a8e20f18393d770b2c849b02ca43e64ecf134f6a;p=tools%2Fmedcoupling.git Bug correction : Multi WriteField on field lying on mesh with duplicate nodes --- diff --git a/src/MEDLoader/MEDLoader.cxx b/src/MEDLoader/MEDLoader.cxx index 18dbcd4ba..56e38a9d1 100644 --- a/src/MEDLoader/MEDLoader.cxx +++ b/src/MEDLoader/MEDLoader.cxx @@ -1636,7 +1636,10 @@ void WriteFieldT(const std::string& fileName, const typename MEDCoupling::Traits MCAuto mread(mmuPtr->getMeshAtLevel(m->getMeshDimension()-mm->getMeshDimension())); if(f2->getTypeOfField()!=ON_NODES) { - m->tryToShareSameCoordsPermute(*mread,_EPS_FOR_NODE_COMP); + if(!m->getCoords()->isEqualWithoutConsideringStr(*mread->getCoords(),_EPS_FOR_NODE_COMP)) + m->tryToShareSameCoordsPermute(*mread,_EPS_FOR_NODE_COMP); + else + mread->setCoords(m->getCoords()); DataArrayInt *part(NULL); bool b(mread->areCellsIncludedIn(m,_COMP_FOR_CELL,part)); MCAuto partSafe(part); diff --git a/src/MEDLoader/Swig/MEDLoaderTest1.py b/src/MEDLoader/Swig/MEDLoaderTest1.py index 5f6d1d7ae..dd63c1477 100644 --- a/src/MEDLoader/Swig/MEDLoaderTest1.py +++ b/src/MEDLoader/Swig/MEDLoaderTest1.py @@ -872,6 +872,27 @@ class MEDLoaderTest1(unittest.TestCase): self.assertRaises(Exception,MEDLoader.ReadField,MEDLoader.ON_CELLS,fname,"mesh",0,"field2",5,5) # invalid time step pass + def testMultiWriteFieldOnMergeableNodesMeshes(self): + fname="Pyfile120.med" + arr=MEDLoader.DataArrayDouble([(0,0),(1,0),(0,1),(0,0),(1,0),(0,1)]) + m=MEDLoader.MEDCouplingUMesh("mesh",2) + m.setCoords(arr) + m.allocateCells() + m.insertNextCell(MEDLoader.NORM_TRI3,[0,4,2]) + m.insertNextCell(MEDLoader.NORM_TRI3,[3,1,5]) + m.setName("mesh") + # + f=MEDLoader.MEDCouplingFieldDouble(MEDLoader.ON_CELLS) + f.setMesh(m) + f.setArray(MEDLoader.DataArrayDouble([5,6])) + f.setName("field") + # + f.setTime(0.,0,0) + MEDLoader.WriteField(fname,f,True) + f.setTime(1.,1,0) + MEDLoader.WriteField(fname,f,False) + pass + pass if __name__ == "__main__":