]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
Bug correction : Multi WriteField on field lying on mesh with duplicate nodes
authorAnthony Geay <anthony.geay@edf.fr>
Tue, 5 Feb 2019 07:38:23 +0000 (08:38 +0100)
committerAnthony Geay <anthony.geay@edf.fr>
Tue, 5 Feb 2019 07:38:23 +0000 (08:38 +0100)
src/MEDLoader/MEDLoader.cxx
src/MEDLoader/Swig/MEDLoaderTest1.py

index 18dbcd4ba2cb26cf766f5370d54fec3d851513a3..56e38a9d162fb663872851d8babd39b1c4922617 100644 (file)
@@ -1636,7 +1636,10 @@ void WriteFieldT(const std::string& fileName, const typename MEDCoupling::Traits
           MCAuto<MEDCouplingUMesh> 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<DataArrayInt> partSafe(part);
index 5f6d1d7ae80dbd3768c2a83fbe0e0888cd03a703..dd63c1477e7486a62fcee8a6972a36172ff8aab9 100644 (file)
@@ -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__":