From: Anthony Geay Date: Wed, 11 Mar 2020 16:43:10 +0000 (+0100) Subject: Fast read for new internal model (>=4.1). Same behavior for legacy MED files. X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=63f66491c89126d03bd73e70c3443b9d72f0079a;p=tools%2Fmedcoupling.git Fast read for new internal model (>=4.1). Same behavior for legacy MED files. --- diff --git a/src/MEDLoader/MEDFileField1TS.cxx b/src/MEDLoader/MEDFileField1TS.cxx index 1e4e091ca..ea2514be5 100644 --- a/src/MEDLoader/MEDFileField1TS.cxx +++ b/src/MEDLoader/MEDFileField1TS.cxx @@ -739,21 +739,21 @@ bool MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFrom throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !"); } -void MEDFileAnyTypeField1TSWithoutSDA::loadOnlyStructureOfDataRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const MEDFileEntities *entities) +void MEDFileAnyTypeField1TSWithoutSDA::loadOnlyStructureOfDataRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const MEDFileEntities *entities, const MEDFileCapability *capability) { med_int numdt,numit; med_float dt; - med_int meshnumdt,meshnumit; + med_int meshnumdt(-1),meshnumit(-1); MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&_dt)); - /*{ + if(!capability || !capability->isFastReader()) + { med_bool localMesh; med_int nmesh; INTERP_KERNEL::AutoPtr meshName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE)); MEDFILESAFECALLERRD0(MEDfield23ComputingStepMeshInfo,(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&dt,&nmesh,meshName,&localMesh,&meshnumdt,&meshnumit)); // to check with Adrien for legacy MED files - }*/ - /*MEDFILESAFECALLERRD0(MEDfieldComputingStepMeshInfo,(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&_dt,&meshnumdt,&meshnumit)); + } if(_iteration!=numdt || _order!=numit) - throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively : unexpected exception internal error !");*/ + throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively : unexpected exception internal error !"); _field_per_mesh.resize(1); // MEDFileMesh *mm(0); diff --git a/src/MEDLoader/MEDFileField1TS.hxx b/src/MEDLoader/MEDFileField1TS.hxx index 924ef6ee3..f88d5a6ab 100644 --- a/src/MEDLoader/MEDFileField1TS.hxx +++ b/src/MEDLoader/MEDFileField1TS.hxx @@ -116,7 +116,7 @@ namespace MEDCoupling public: MEDLOADER_EXPORT void allocNotFromFile(mcIdType newNbOfTuples); MEDLOADER_EXPORT bool allocIfNecessaryTheArrayToReceiveDataFromFile(); - MEDLOADER_EXPORT void loadOnlyStructureOfDataRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const MEDFileEntities *entities); + MEDLOADER_EXPORT void loadOnlyStructureOfDataRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const MEDFileEntities *entities, const MEDFileCapability *capability = nullptr); MEDLOADER_EXPORT void loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc); MEDLOADER_EXPORT void loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc); MEDLOADER_EXPORT void loadStructureAndBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const MEDFileEntities *entities); diff --git a/src/MEDLoader/MEDFileFieldMultiTS.cxx b/src/MEDLoader/MEDFileFieldMultiTS.cxx index a14497642..087f8cd85 100644 --- a/src/MEDLoader/MEDFileFieldMultiTS.cxx +++ b/src/MEDLoader/MEDFileFieldMultiTS.cxx @@ -489,7 +489,8 @@ void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysR // INTERP_KERNEL::AutoCppPtr entitiesFast; const MEDFileEntities *entitiesForSubInstances(entities); - if(!entities) + MEDFileCapability mfcap(fid); + if(!entities && mfcap.isFastReader()) {// no entities int nentitype(MEDfieldnEntityType(fid,_name.c_str(),MED_ALL_DT,MED_ALL_IT)); INTERP_KERNEL::AutoPtr types(new med_entity_type[nentitype]); @@ -548,9 +549,9 @@ void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysR if(loadAll) _time_steps[i]->loadStructureAndBigArraysRecursively(fid,*this,ms,entitiesForSubInstances); else - _time_steps[i]->loadOnlyStructureOfDataRecursively(fid,*this,ms,entitiesForSubInstances); - //synchronizeNameScope(); + _time_steps[i]->loadOnlyStructureOfDataRecursively(fid,*this,ms,entitiesForSubInstances,&mfcap); } + synchronizeNameScope(); } void MEDFileAnyTypeFieldMultiTSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts) const diff --git a/src/MEDLoader/MEDFileUtilities.cxx b/src/MEDLoader/MEDFileUtilities.cxx index d30377eae..2b10b10d2 100644 --- a/src/MEDLoader/MEDFileUtilities.cxx +++ b/src/MEDLoader/MEDFileUtilities.cxx @@ -239,3 +239,8 @@ std::string MEDCoupling::MEDFileWritableStandAlone::GenerateUniqueDftFileNameInM std::ostringstream oss; oss << DFT_FILENAME_IN_MEM << "_" << ii++; return oss.str(); } + +MEDCoupling::MEDFileCapability::MEDFileCapability(med_idt fid) +{ + MEDFILESAFECALLERRD0(MEDfileNumVersionRd,(fid,&_maj,&_min,&_rel)); +} diff --git a/src/MEDLoader/MEDFileUtilities.hxx b/src/MEDLoader/MEDFileUtilities.hxx index 501a6d5e5..45173dbe7 100644 --- a/src/MEDLoader/MEDFileUtilities.hxx +++ b/src/MEDLoader/MEDFileUtilities.hxx @@ -79,6 +79,16 @@ namespace MEDCoupling static T *BuildFromMemoryChunk(DataArrayByte *db); }; + class MEDFileCapability + { + public: + MEDFileCapability(med_idt fid); + bool isFastReader() const { return _maj>=4 && _min >=1; } + private: + med_int _maj; + med_int _min; + med_int _rel; + }; MEDFileUtilities::AutoFid OpenMEDFileForRead(const std::string& fileName); }