From: Anthony GEAY Date: Tue, 10 Nov 2020 16:07:32 +0000 (+0100) Subject: WIP X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=723e8a350a522de7017aafb32039c55f2c93eb44;p=tools%2Fmedcoupling.git WIP --- diff --git a/src/MEDLoader/MEDFileMeshLL.cxx b/src/MEDLoader/MEDFileMeshLL.cxx index 10afc9ebd..86e4119d7 100644 --- a/src/MEDLoader/MEDFileMeshLL.cxx +++ b/src/MEDLoader/MEDFileMeshLL.cxx @@ -560,15 +560,15 @@ void MEDFileUMeshL2::loadPart(med_idt fid, const MeshOrStructMeshCls *mId, const for(std::vector< std::vector< MCAuto > >::const_iterator it0=_per_type_mesh.begin();it0!=_per_type_mesh.end();it0++) for(std::vector< MCAuto >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++) (*it1)->getMesh()->computeNodeIdsAlg(fetchedNodeIds); - mcIdType nMin(ToIdType(std::distance(fetchedNodeIds.begin(),std::find(fetchedNodeIds.begin(),fetchedNodeIds.end(),true)))); - mcIdType nMax(ToIdType(std::distance(fetchedNodeIds.rbegin(),std::find(fetchedNodeIds.rbegin(),fetchedNodeIds.rend(),true)))); - nMax=nCoords-nMax; if(!mrs || mrs->getNumberOfCoordsLoadSessions()==1) { + mcIdType nMin(ToIdType(std::distance(fetchedNodeIds.begin(),std::find(fetchedNodeIds.begin(),fetchedNodeIds.end(),true)))); + mcIdType nMax(ToIdType(std::distance(fetchedNodeIds.rbegin(),std::find(fetchedNodeIds.rbegin(),fetchedNodeIds.rend(),true)))); + nMax=nCoords-nMax; for(std::vector< std::vector< MCAuto > >::const_iterator it0=_per_type_mesh.begin();it0!=_per_type_mesh.end();it0++) for(std::vector< MCAuto >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++) (*it1)->getMesh()->renumberNodesWithOffsetInConn(-nMin); - loadPartCoords(fid,infosOnComp,mName,dt,it,nMin,nMax); + this->loadPartCoords(fid,infosOnComp,mName,dt,it,nMin,nMax); } else { @@ -578,12 +578,7 @@ void MEDFileUMeshL2::loadPart(med_idt fid, const MeshOrStructMeshCls *mId, const for(std::vector< std::vector< MCAuto > >::const_iterator it0=_per_type_mesh.begin();it0!=_per_type_mesh.end();it0++) for(std::vector< MCAuto >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++) (*it1)->getMesh()->renumberNodesInConn(o2n->data()); - for(mcIdType ipart = 0 ; ipart < nbOfCooLS ; ++ipart) - { - mcIdType partStart,partStop; - DataArray::GetSlice(nMin,nMax,1,ipart,nbOfCooLS,partStart,partStop); - loadPartCoords(fid,infosOnComp,mName,dt,it,partStart,partStop); - } + this->loadPartCoordsSlice(fid,infosOnComp,mName,dt,it,fni,nbOfCooLS); } } @@ -716,11 +711,45 @@ MCAuto& _coords, MCAuto& _part_coords, MCAutosetInfoOnComponents(infosOnComp); } +/*! + * For performance reasons LoadPartCoordsArray method calls LoadPartCoords + */ +void MEDFileUMeshL2::LoadPartCoordsArray(med_idt fid, const std::vector& infosOnComp, const std::string& mName, int dt, int it, const DataArrayIdType *nodeIds, +MCAuto& _coords, MCAuto& _fam_coords, MCAuto& _num_coords, MCAuto& _name_coords) +{ + MCAuto useless; + nodeIds->checkAllocated(); + nodeIds->checkNbOfComps(1,"loadPartCoordsSlice : Only one component expected !"); + mcIdType nMin(0),nMax(0); + if(!nodeIds->empty()) + { nMin = nodeIds->front(); nMax = nodeIds->back()+1; } +} + void MEDFileUMeshL2::loadPartCoords(med_idt fid, const std::vector& infosOnComp, const std::string& mName, int dt, int it, mcIdType nMin, mcIdType nMax) { LoadPartCoords(fid,infosOnComp,mName,dt,it,nMin,nMax,_coords,_part_coords,_fam_coords,_num_coords,_name_coords); } +void MEDFileUMeshL2::loadPartCoordsSlice(med_idt fid, const std::vector& infosOnComp, const std::string& mName, int dt, int it, const DataArrayIdType *nodeIds, mcIdType nbOfCoordLS) +{ + nodeIds->checkAllocated(); + nodeIds->checkNbOfComps(1,"loadPartCoordsSlice : Only one component expected !"); + if(nodeIds->empty()) + return ; + mcIdType nMin(nodeIds->front()),nMax(nodeIds->back()+1); + for(mcIdType ipart = 0 ; ipart < nbOfCoordLS ; ++ipart) + { + mcIdType partStart,partStop; + DataArray::GetSlice(nMin,nMax,1,ipart,nbOfCoordLS,partStart,partStop); + MCAuto coords; + MCAuto famCoords; + MCAuto numCoords; + MCAuto nameCoords; + MCAuto nodeIdsToKeep(nodeIds->findIdsInRange(partStart,partStop)); + LoadPartCoordsArray(fid,infosOnComp,mName,dt,it,nodeIdsToKeep,coords,famCoords,numCoords,nameCoords); + } +} + void MEDFileUMeshL2::sortTypes() { std::set mdims; diff --git a/src/MEDLoader/MEDFileMeshLL.hxx b/src/MEDLoader/MEDFileMeshLL.hxx index 7552e158f..5c9a667a2 100644 --- a/src/MEDLoader/MEDFileMeshLL.hxx +++ b/src/MEDLoader/MEDFileMeshLL.hxx @@ -125,6 +125,7 @@ namespace MEDCoupling void loadPartOfConnectivity(med_idt fid, int mdim, const std::string& mName, const std::vector& types, const std::vector& slicPerTyp, int dt, int it, MEDFileMeshReadSelector *mrs); void loadCoords(med_idt fid, const std::vector& infosOnComp, const std::string& mName, int dt, int it); void loadPartCoords(med_idt fid, const std::vector& infosOnComp, const std::string& mName, int dt, int it, mcIdType nMin, mcIdType nMax); + void loadPartCoordsSlice(med_idt fid, const std::vector& infosOnComp, const std::string& mName, int dt, int it, const DataArrayIdType *nodeIds, mcIdType nbOfCoordLS); int getNumberOfLevels() const { return (int)_per_type_mesh.size(); } bool emptyLev(int levId) const { return _per_type_mesh[levId].empty(); } const std::vector< MCAuto >& getLev(int levId) const { return _per_type_mesh[levId]; } @@ -139,6 +140,8 @@ namespace MEDCoupling static void WriteCoords(med_idt fid, const std::string& mname, int dt, int it, double time, const DataArrayDouble *coords, const DataArrayIdType *famCoords, const DataArrayIdType *numCoords, const DataArrayAsciiChar *nameCoords, const DataArrayIdType *globalNumCoords); static void LoadPartCoords(med_idt fid, const std::vector& infosOnComp, const std::string& mName, int dt, int it, mcIdType nMin, mcIdType nMax, MCAuto& _coords, MCAuto& _part_coords, MCAuto& _fam_coords, MCAuto& _num_coords, MCAuto& _name_coords); + static void LoadPartCoordsArray(med_idt fid, const std::vector& infosOnComp, const std::string& mName, int dt, int it, const DataArrayIdType *nodeIds, +MCAuto& _coords, MCAuto& _fam_coords, MCAuto& _num_coords, MCAuto& _name_coords); private: void sortTypes(); private: