]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
OK. Tested
authorAnthony Geay <anthony.geay@edf.fr>
Thu, 20 Apr 2017 06:07:48 +0000 (08:07 +0200)
committerAnthony Geay <anthony.geay@edf.fr>
Thu, 20 Apr 2017 06:07:48 +0000 (08:07 +0200)
src/MEDLoader/MEDFileMesh.cxx
src/MEDLoader/Swig/MEDLoaderCommon.i
src/MEDLoader/Swig/MEDLoaderTest3.py

index 02be59c37deb6b9024b8bd0443a5a16a16929243..35babc642440272ab5955b70892eb36be5ea9dc4 100644 (file)
@@ -3370,7 +3370,7 @@ const DataArrayInt *MEDFileUMesh::getRevNumberFieldAtLevel(int meshDimRelToMaxEx
 {
   if(meshDimRelToMaxExt==1)
     {
-      if(_num_coords.isNotNull())
+      if(_num_coords.isNull())
         throw INTERP_KERNEL::Exception("MEDFileUMesh::getRevNumberFieldAtLevel : no coordinates renum specified !");
       return _rev_num_coords;
     }
@@ -5258,6 +5258,8 @@ void MEDFileUMesh::setGlobalNumFieldAtLevel(int meshDimRelToMaxExt, DataArrayInt
 {
   if(meshDimRelToMaxExt!=1)
     throw INTERP_KERNEL::Exception("MEDFileUMesh::setGlobalNumFieldAtLevel : Only implemented for meshDimRelToMaxExt==1 for the moment !");
+  if(globalNumArr)
+    globalNumArr->checkNbOfTuplesAndComp(_coords->getNumberOfTuples(),1,"MEDFileUMesh::setGlobalNumFieldAtLevel : Problem in size of node global numbering arr ! ");
   _global_num_coords.takeRef(globalNumArr);
 }
 
index 39cc415f69139a8e8d54e35b76366dd05155d42f..3984ba76c7b24147000d3e1214f3f9646edb499b 100644 (file)
@@ -99,6 +99,7 @@ using namespace MEDCoupling;
 %newobject MEDCoupling::MEDFileMesh::getNodeGroupsArr;
 %newobject MEDCoupling::MEDFileMesh::getNodeFamilyArr;
 %newobject MEDCoupling::MEDFileMesh::getNodeFamiliesArr;
+%newobject MEDCoupling::MEDFileMesh::getGlobalNumFieldAtLevel;
 %newobject MEDCoupling::MEDFileMesh::getAllFamiliesIdsReferenced;
 %newobject MEDCoupling::MEDFileMesh::computeAllFamilyIdsInUse;
 %newobject MEDCoupling::MEDFileMesh::getEquivalences;
@@ -1302,6 +1303,12 @@ namespace MEDCoupling
            if(ret) ret->incrRef();
            return ret;
          }
+
+         virtual DataArrayInt *getGlobalNumFieldAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception)
+         {
+           MCAuto<DataArrayInt> ret(self->getGlobalNumFieldAtLevel(meshDimRelToMaxExt));
+           return ret.retn();
+         }
        }
   };
 
index 6738da9247f751ef58ee23a5b81342f104689010..f95495eee5d84868a0eb84ecc66b5d275e1ba34e 100644 (file)
@@ -5911,6 +5911,32 @@ class MEDLoaderTest3(unittest.TestCase):
             self.assertTrue(params[i].isEqual(params7[i],1e-12)[0])
             pass
         pass
+
+    def testGlobalNumOnNodes1(self):
+        fname="Pyfile112.med"
+        arr=DataArrayDouble(5) ; arr.iota()
+        m=MEDCouplingUMesh.Build1DMeshFromCoords(arr)
+        m.setName("mesh")
+        mm=MEDFileUMesh()
+        mm[0]=m
+        self.assertTrue(not mm.getGlobalNumFieldAtLevel(1))
+        d=DataArrayInt([7,8,9,2,0])
+        dRef=d.deepCopy()
+        mm.setGlobalNumFieldAtLevel(1,d)
+        mm.checkConsistency()
+        self.assertRaises(InterpKernelException,mm.setGlobalNumFieldAtLevel,1,d[::2])
+        mm.checkConsistency()
+        self.assertEqual(d.getHiddenCppPointer(),mm.getGlobalNumFieldAtLevel(1).getHiddenCppPointer())
+        self.assertTrue(mm.getGlobalNumFieldAtLevel(1).isEqual(dRef))
+        mm.write(fname,2)
+        mm2=MEDFileMesh.New(fname)
+        self.assertTrue(mm.isEqual(mm2,1e-12)[0])
+        self.assertTrue(mm2.getGlobalNumFieldAtLevel(1).isEqual(dRef))
+        mm2.getGlobalNumFieldAtLevel(1).setIJ(0,0,10)
+        self.assertTrue(not mm.isEqual(mm2,1e-12)[0])
+        mm2.getGlobalNumFieldAtLevel(1).setIJ(0,0,7)
+        self.assertTrue(mm.isEqual(mm2,1e-12)[0])
+        pass
     
     pass