]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
First test of partial loading with multiple coords sessions
authorAnthony GEAY <anthony.geay@edf.fr>
Thu, 12 Nov 2020 09:10:31 +0000 (10:10 +0100)
committerAnthony GEAY <anthony.geay@edf.fr>
Thu, 12 Nov 2020 09:10:31 +0000 (10:10 +0100)
src/MEDLoader/MEDFileMeshLL.cxx
src/MEDLoader/Swig/MEDLoaderTest3.py

index 2cae9e845762cc3ae751802c686e1681dd636ff2..cb771459ddf5dfb31a413b055b6793b32fd8286f 100644 (file)
@@ -762,7 +762,8 @@ void MEDFileUMeshL2::loadPartCoordsSlice(med_idt fid, const std::vector<std::str
     {
       mcIdType partStart,partStop;
       DataArray::GetSlice(nMin,nMax,1,ipart,nbOfCoordLS,partStart,partStop);
-      MCAuto<DataArrayIdType> nodeIdsToKeep(nodeIds->findIdsInRange(partStart,partStop));
+      MCAuto<DataArrayIdType> idsNodeIdsToKeep(nodeIds->findIdsInRange(partStart,partStop));
+      MCAuto<DataArrayIdType> nodeIdsToKeep( nodeIds->selectByTupleIdSafe(idsNodeIdsToKeep->begin(),idsNodeIdsToKeep->end()) );
       LoadPartCoordsArray(fid,infosOnComp,mName,dt,it,nodeIdsToKeep,coords[ipart],famCoords[ipart],numCoords[ipart],nameCoords[ipart]);
     }
   _coords = DataArrayDouble::Aggregate(ToConstVect<DataArrayDouble>(coords));
index de1a827a62f636e9bf5b41e972c5e2f23c0b8888..cc6f3ad128ff6af16058fffe02f6526a82981ec1 100644 (file)
@@ -4159,6 +4159,28 @@ class MEDLoaderTest3(unittest.TestCase):
         arr=DataArrayDouble([(204,304),(205,305),(206,306),(207,307),(210,310),(211,311),(212,312),(213,313)])
         arr.setInfoOnComponents(compos)
         self.assertTrue(fs[1][0].getUndergroundDataArray().isEqual(arr,1e-12))
+        m_ref = mm[0].deepCopy()
+        # now read it in 2 load sessions to avoid memory peak. zipCoords is no more requested here.
+        ms=MEDFileMeshes()
+        mrs = MEDFileMeshReadSelector()
+        mrs.setNumberOfCoordsLoadSessions(2)
+        mm=MEDFileUMesh.LoadPartOf(fileName,meshName,[NORM_QUAD4],[4,6,1],-1,-1,mrs)
+        ms.pushMesh(mm)
+        spd=mm.getPartDefAtLevel(0,NORM_QUAD4)
+        self.assertEqual(spd.getSlice(),slice(4,6,1))
+        spd=mm.getPartDefAtLevel(1)
+        self.assertTrue(spd.getNumberOfElems()==8 and spd.getNumberOfElems()==mm.getNumberOfNodes())
+        self.assertTrue(spd.toDAI().isEqual(DataArrayInt([4,5,6,7,10,11,12,13])))
+        fs=MEDFileFields.LoadPartOf(fileName,False,ms)
+        fs[0][0].loadArrays()
+        arr=DataArrayDouble([(4,104),(5,105)])
+        arr.setInfoOnComponents(compos)
+        self.assertTrue(fs[0][0].getUndergroundDataArray().isEqual(arr,1e-12))
+        fs[1][0].loadArrays()
+        arr=DataArrayDouble([(204,304),(205,305),(206,306),(207,307),(210,310),(211,311),(212,312),(213,313)])
+        arr.setInfoOnComponents(compos)
+        self.assertTrue(fs[1][0].getUndergroundDataArray().isEqual(arr,1e-12))
+        self.assertTrue( mm[0].deepCopy().isEqual(m_ref,1e-12) )
         pass
 
     @WriteInTmpDir