]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
Correct bug when a umesh without any cells is written.
authorAnthony Geay <anthony.geay@edf.fr>
Thu, 20 Nov 2014 16:40:18 +0000 (17:40 +0100)
committerAnthony Geay <anthony.geay@edf.fr>
Thu, 20 Nov 2014 16:40:18 +0000 (17:40 +0100)
src/MEDLoader/MEDFileMesh.cxx
src/MEDLoader/Swig/MEDLoaderTest3.py

index f07c99ce462ffef190cbeb2cc11b1382b6b3d0d0..f9074f9709045520a4c6016ecb4919b785ec95eb 100644 (file)
@@ -2314,7 +2314,9 @@ void MEDFileUMesh::writeLL(med_idt fid) const
   MEDLoaderBase::safeStrCpy(_name.c_str(),MED_NAME_SIZE,maa,_too_long_str);
   MEDLoaderBase::safeStrCpy(_desc_name.c_str(),MED_COMMENT_SIZE,desc,_too_long_str);
   int spaceDim=coo?coo->getNumberOfComponents():0;
-  int mdim=getMeshDimension();
+  int mdim(0);
+  if(!_ms.empty())
+    mdim=getMeshDimension();
   INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(spaceDim*MED_SNAME_SIZE);
   INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(spaceDim*MED_SNAME_SIZE);
   for(int i=0;i<spaceDim;i++)
index 4e94bc2739b07c34c9da5ae2fe311c1ab532e013..55762ee812267b3f551c73b53644c7c0986ec998 100644 (file)
@@ -3782,6 +3782,20 @@ class MEDLoaderTest(unittest.TestCase):
         self.assertTrue(fs[1][0].getUndergroundDataArray().isEqual(arr,1e-12))
         pass
 
+    def testMEDFileWithoutCells1(self):
+        fileName="Pyfile83.med"
+        coo=DataArrayDouble([(0,0,0),(1,0,0),(2,0,0)])
+        coo.setInfoOnComponents(["aa [m]","bbb [s]","cccc [m/s]"])
+        mm=MEDFileUMesh()
+        mm.setCoords(coo)
+        mm.setName("mesh")
+        mm.write(fileName,2)
+        #
+        mm=MEDFileMesh.New(fileName)
+        self.assertEqual(mm.getName(),"mesh")
+        self.assertTrue(mm.getCoords().isEqual(coo,1e-12))
+        pass
+
     pass
 
 unittest.main()