From: Anthony Geay Date: Thu, 16 Mar 2017 07:46:23 +0000 (+0100) Subject: Improve perf for users with more than 1000 time steps X-Git-Tag: V8_3_0a2~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=95e5d4fa65dc5f8d8c972d2802e90b996e4f7720;p=tools%2Fmedcoupling.git Improve perf for users with more than 1000 time steps --- diff --git a/src/MEDLoader/MEDFileField.cxx b/src/MEDLoader/MEDFileField.cxx index b0a9eb651..43b0b19b4 100644 --- a/src/MEDLoader/MEDFileField.cxx +++ b/src/MEDLoader/MEDFileField.cxx @@ -5890,7 +5890,7 @@ MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS() //= MEDFileAnyTypeField1TS -MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, bool loadAll, const MEDFileMeshes *ms) +MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities) { med_field_type typcha; // @@ -5925,16 +5925,16 @@ MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_i ret->setTime(numdt,numit,dt); ret->_csit=1; if(loadAll) - ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0); + ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,entities); else - ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0); + ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,entities); return ret.retn(); } -MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms) +MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities) try:MEDFileFieldGlobsReal(fid) { - _content=BuildContentFrom(fid,loadAll,ms); + _content=BuildContentFrom(fid,loadAll,ms,entities); loadGlobals(fid); } catch(INTERP_KERNEL::Exception& e) @@ -5942,7 +5942,7 @@ catch(INTERP_KERNEL::Exception& e) throw e; } -MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms) +MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities) { med_field_type typcha; std::vector infos; @@ -5983,16 +5983,16 @@ MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_i ret->setTime(numdt,numit,dt); ret->_csit=1; if(loadAll) - ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0); + ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,entities); else - ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0); + ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,entities); return ret.retn(); } -MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms) +MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities) try:MEDFileFieldGlobsReal(fid) { - _content=BuildContentFrom(fid,fieldName,loadAll,ms); + _content=BuildContentFrom(fid,fieldName,loadAll,ms,entities); loadGlobals(fid); } catch(INTERP_KERNEL::Exception& e) @@ -6034,7 +6034,7 @@ MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, bool loadAll) { - MCAuto c(BuildContentFrom(fid,loadAll,0)); + MCAuto c(BuildContentFrom(fid,loadAll,0,0)); MCAuto ret(BuildNewInstanceFromContent(c,fid)); ret->loadGlobals(fid); return ret.retn(); @@ -6048,7 +6048,7 @@ MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, const std::string& fieldName, bool loadAll) { - MCAuto c(BuildContentFrom(fid,fieldName,loadAll,0)); + MCAuto c(BuildContentFrom(fid,fieldName,loadAll,0,0)); MCAuto ret(BuildNewInstanceFromContent(c,fid)); ret->loadGlobals(fid); return ret.retn(); @@ -6062,13 +6062,27 @@ MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll) { - MCAuto c(BuildContentFrom(fid,fieldName,iteration,order,loadAll,0)); + MCAuto c(BuildContentFrom(fid,fieldName,iteration,order,loadAll,0,0)); + MCAuto ret(BuildNewInstanceFromContent(c,fid)); + ret->loadGlobals(fid); + return ret.retn(); +} + +MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::NewAdv(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileEntities *entities) +{ + MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName)); + return NewAdv(fid,fieldName,iteration,order,loadAll,entities); +} + +MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::NewAdv(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileEntities *entities) +{ + MCAuto c(BuildContentFrom(fid,fieldName,iteration,order,loadAll,0,entities)); MCAuto ret(BuildNewInstanceFromContent(c,fid)); ret->loadGlobals(fid); return ret.retn(); } -MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms) +MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities) { med_field_type typcha; std::vector infos; @@ -6120,16 +6134,16 @@ MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_i throw INTERP_KERNEL::Exception(oss.str()); } if(loadAll) - ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0); + ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,entities); else - ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0); + ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,entities); return ret.retn(); } -MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms) +MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities) try:MEDFileFieldGlobsReal(fid) { - _content=BuildContentFrom(fid,fieldName,iteration,order,loadAll,ms); + _content=BuildContentFrom(fid,fieldName,iteration,order,loadAll,ms,entities); loadGlobals(fid); } catch(INTERP_KERNEL::Exception& e) @@ -10708,6 +10722,17 @@ MEDFileFields *MEDFileFields::New(const std::string& fileName, bool loadAll) return New(fid,loadAll); } +MEDFileFields *MEDFileFields::NewAdv(const std::string& fileName, bool loadAll, const MEDFileEntities *entities) +{ + MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName)); + return NewAdv(fid,loadAll,entities); +} + +MEDFileFields *MEDFileFields::NewAdv(med_idt fid, bool loadAll, const MEDFileEntities *entities) +{ + return new MEDFileFields(fid,loadAll,0,entities); +} + MEDFileFields *MEDFileFields::NewWithDynGT(const std::string& fileName, const MEDFileStructureElements *se, bool loadAll) { MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName)); diff --git a/src/MEDLoader/MEDFileField.hxx b/src/MEDLoader/MEDFileField.hxx index f935d5284..81ec25452 100644 --- a/src/MEDLoader/MEDFileField.hxx +++ b/src/MEDLoader/MEDFileField.hxx @@ -752,15 +752,15 @@ namespace MEDCoupling { protected: MEDLOADER_EXPORT MEDFileAnyTypeField1TS(); - MEDLOADER_EXPORT MEDFileAnyTypeField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms); - MEDLOADER_EXPORT MEDFileAnyTypeField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms); - MEDLOADER_EXPORT MEDFileAnyTypeField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms); + MEDLOADER_EXPORT MEDFileAnyTypeField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities=0); + MEDLOADER_EXPORT MEDFileAnyTypeField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities=0); + MEDLOADER_EXPORT MEDFileAnyTypeField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities=0); MEDLOADER_EXPORT MEDFileAnyTypeField1TS(const MEDFileAnyTypeField1TSWithoutSDA& other, bool shallowCopyOfContent); MEDLOADER_EXPORT static MEDFileAnyTypeField1TS *BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c); MEDLOADER_EXPORT static MEDFileAnyTypeField1TS *BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c, med_idt fid); - MEDLOADER_EXPORT static MEDFileAnyTypeField1TSWithoutSDA *BuildContentFrom(med_idt fid, bool loadAll, const MEDFileMeshes *ms); - MEDLOADER_EXPORT static MEDFileAnyTypeField1TSWithoutSDA *BuildContentFrom(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms); - MEDLOADER_EXPORT static MEDFileAnyTypeField1TSWithoutSDA *BuildContentFrom(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms); + MEDLOADER_EXPORT static MEDFileAnyTypeField1TSWithoutSDA *BuildContentFrom(med_idt fid, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities); + MEDLOADER_EXPORT static MEDFileAnyTypeField1TSWithoutSDA *BuildContentFrom(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities); + MEDLOADER_EXPORT static MEDFileAnyTypeField1TSWithoutSDA *BuildContentFrom(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities); MEDLOADER_EXPORT void writeLL(med_idt fid) const; // direct forwarding to MEDFileAnyTypeField1TSWithoutSDA instance _content public: @@ -770,6 +770,8 @@ namespace MEDCoupling MEDLOADER_EXPORT static MEDFileAnyTypeField1TS *New(med_idt fid, const std::string& fieldName, bool loadAll=true); MEDLOADER_EXPORT static MEDFileAnyTypeField1TS *New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll=true); MEDLOADER_EXPORT static MEDFileAnyTypeField1TS *New(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll=true); + MEDLOADER_EXPORT static MEDFileAnyTypeField1TS *NewAdv(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileEntities *entities); + MEDLOADER_EXPORT static MEDFileAnyTypeField1TS *NewAdv(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileEntities *entities); MEDLOADER_EXPORT int getDimension() const; MEDLOADER_EXPORT int getIteration() const; MEDLOADER_EXPORT int getOrder() const; @@ -1277,6 +1279,8 @@ namespace MEDCoupling MEDLOADER_EXPORT static MEDFileFields *New(); MEDLOADER_EXPORT static MEDFileFields *New(const std::string& fileName, bool loadAll=true); MEDLOADER_EXPORT static MEDFileFields *New(med_idt fid, bool loadAll=true); + MEDLOADER_EXPORT static MEDFileFields *NewAdv(const std::string& fileName, bool loadAll, const MEDFileEntities *entities); + MEDLOADER_EXPORT static MEDFileFields *NewAdv(med_idt fid, bool loadAll, const MEDFileEntities *entities); MEDLOADER_EXPORT static MEDFileFields *NewWithDynGT(const std::string& fileName, const MEDFileStructureElements *se, bool loadAll=true); MEDLOADER_EXPORT static MEDFileFields *NewWithDynGT(med_idt fid, const MEDFileStructureElements *se, bool loadAll=true); MEDLOADER_EXPORT static MEDFileFields *New(DataArrayByte *db) { return BuildFromMemoryChunk(db); } diff --git a/src/MEDLoader/Swig/MEDLoaderCommon.i b/src/MEDLoader/Swig/MEDLoaderCommon.i index 3725a37ba..c205a3e78 100644 --- a/src/MEDLoader/Swig/MEDLoaderCommon.i +++ b/src/MEDLoader/Swig/MEDLoaderCommon.i @@ -37,6 +37,7 @@ #include "MEDFileParameter.hxx" #include "MEDFileData.hxx" #include "MEDFileEquivalence.hxx" +#include "MEDFileEntities.hxx" #include "MEDFileMeshReadSelector.hxx" #include "MEDFileFieldOverView.hxx" #include "MEDLoaderTypemaps.i" @@ -146,6 +147,7 @@ using namespace MEDCoupling; %newobject MEDCoupling::MEDFileStructureElements::New; %newobject MEDCoupling::MEDFileFields::New; +%newobject MEDCoupling::MEDFileFields::NewAdv; %newobject MEDCoupling::MEDFileFields::NewWithDynGT; %newobject MEDCoupling::MEDFileFields::LoadPartOf; %newobject MEDCoupling::MEDFileFields::LoadSpecificEntities; @@ -190,6 +192,7 @@ using namespace MEDCoupling; %newobject MEDCoupling::MEDFileIntFieldMultiTS::getFieldAtLevelOld; %newobject MEDCoupling::MEDFileAnyTypeField1TS::New; +%newobject MEDCoupling::MEDFileAnyTypeField1TS::NewAdv; %newobject MEDCoupling::MEDFileAnyTypeField1TS::shallowCpy; %newobject MEDCoupling::MEDFileAnyTypeField1TS::deepCopy; %newobject MEDCoupling::MEDFileAnyTypeField1TS::extractPart; @@ -218,6 +221,8 @@ using namespace MEDCoupling; %newobject MEDCoupling::MEDFileData::getParams; %newobject MEDCoupling::MEDFileData::Aggregate; +%newobject MEDCoupling::MEDFileEntities::BuildFrom; + %newobject MEDCoupling::MEDFileParameterDouble1TS::New; %newobject MEDCoupling::MEDFileParameterDouble1TS::deepCopy; %newobject MEDCoupling::MEDFileParameterMultiTS::New; @@ -2011,12 +2016,35 @@ namespace MEDCoupling } }; + class MEDFileEntities + { + public: + %extend + { + static MEDFileEntities *BuildFrom(PyObject *entities) throw(INTERP_KERNEL::Exception) + { + std::vector< std::pair > inp; + std::vector< std::pair > inp0(convertTimePairIdsFromPy(entities)); + { + std::size_t sz(inp0.size()); + inp.resize(sz); + for(std::size_t i=0;i((TypeOfField)inp0[i].first,(INTERP_KERNEL::NormalizedCellType)inp0[i].second); + } + return MEDFileEntities::BuildFrom(&inp); + } + } + private: + MEDFileEntities(); + }; + class MEDFileAnyTypeField1TS : public RefCountObject, public MEDFileFieldGlobsReal, public MEDFileWritableStandAlone { public: static MEDFileAnyTypeField1TS *New(const std::string& fileName, bool loadAll=true) throw(INTERP_KERNEL::Exception); static MEDFileAnyTypeField1TS *New(const std::string& fileName, const std::string& fieldName, bool loadAll=true) throw(INTERP_KERNEL::Exception); static MEDFileAnyTypeField1TS *New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll=true) throw(INTERP_KERNEL::Exception); + static MEDFileAnyTypeField1TS *NewAdv(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileEntities *entities) throw(INTERP_KERNEL::Exception); void loadArrays() throw(INTERP_KERNEL::Exception); void loadArraysIfNecessary() throw(INTERP_KERNEL::Exception); void unloadArrays() throw(INTERP_KERNEL::Exception); @@ -3062,6 +3090,7 @@ namespace MEDCoupling static MEDFileFields *New() throw(INTERP_KERNEL::Exception); static MEDFileFields *New(const std::string& fileName, bool loadAll=true) throw(INTERP_KERNEL::Exception); static MEDFileFields *New(DataArrayByte *db) throw(INTERP_KERNEL::Exception); + static MEDFileFields *NewAdv(const std::string& fileName, bool loadAll, const MEDFileEntities *entities) throw(INTERP_KERNEL::Exception); static MEDFileFields *LoadPartOf(const std::string& fileName, bool loadAll=true, const MEDFileMeshes *ms=0) throw(INTERP_KERNEL::Exception); static MEDFileFields *NewWithDynGT(const std::string& fileName, const MEDFileStructureElements *se, bool loadAll=true) throw(INTERP_KERNEL::Exception); MEDFileFields *deepCopy() const throw(INTERP_KERNEL::Exception); @@ -3105,6 +3134,11 @@ namespace MEDCoupling { return MEDFileFields::New(db); } + + MEDFileFields(const std::string& fileName, bool loadAll, const MEDFileEntities *entities) throw(INTERP_KERNEL::Exception) + { + return MEDFileFields::NewAdv(fileName,loadAll,entities); + } // serialization static PyObject *___new___(PyObject *cls, PyObject *args) throw(INTERP_KERNEL::Exception)