From d511e21c57cbcb4a98b02af9fe3e268f0a878c55 Mon Sep 17 00:00:00 2001 From: Anthony GEAY Date: Tue, 10 Nov 2020 16:21:28 +0100 Subject: [PATCH] WIP --- src/MEDLoader/MEDFileMeshLL.cxx | 26 +++++++++++++++++++---- src/MEDLoader/MEDFileMeshReadSelector.cxx | 16 ++++++++++++-- src/MEDLoader/MEDFileMeshReadSelector.hxx | 12 ++++++----- src/MEDLoader/Swig/MEDLoaderCommon.i | 2 ++ 4 files changed, 45 insertions(+), 11 deletions(-) diff --git a/src/MEDLoader/MEDFileMeshLL.cxx b/src/MEDLoader/MEDFileMeshLL.cxx index 5809f3595..10afc9ebd 100644 --- a/src/MEDLoader/MEDFileMeshLL.cxx +++ b/src/MEDLoader/MEDFileMeshLL.cxx @@ -563,10 +563,28 @@ void MEDFileUMeshL2::loadPart(med_idt fid, const MeshOrStructMeshCls *mId, const 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); + if(!mrs || mrs->getNumberOfCoordsLoadSessions()==1) + { + 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); + } + else + { + mcIdType nbOfCooLS(mrs->getNumberOfCoordsLoadSessions()); + MCAuto fni(DataArrayIdType::BuildListOfSwitchedOn(fetchedNodeIds)); + MCAuto< MapKeyVal > o2n(fni->invertArrayN2O2O2NOptimized()); + 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); + } + } } void MEDFileUMeshL2::loadConnectivity(med_idt fid, int mdim, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs) diff --git a/src/MEDLoader/MEDFileMeshReadSelector.cxx b/src/MEDLoader/MEDFileMeshReadSelector.cxx index eb717c10e..241086d43 100644 --- a/src/MEDLoader/MEDFileMeshReadSelector.cxx +++ b/src/MEDLoader/MEDFileMeshReadSelector.cxx @@ -16,13 +16,17 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -// Author : Anthony Geay (CEA/DEN) +// Author : Anthony Geay (EDF R&D) #include "MEDFileMeshReadSelector.hxx" +#include "InterpKernelException.hxx" + +#include + using namespace MEDCoupling; -MEDFileMeshReadSelector::MEDFileMeshReadSelector():_code(0xFFFFFFFF) +MEDFileMeshReadSelector::MEDFileMeshReadSelector():_nb_coords_load_sessions(1),_code(0xFFFFFFFF) { } @@ -40,6 +44,13 @@ void MEDFileMeshReadSelector::setCode(unsigned int newCode) _code=newCode; } +void MEDFileMeshReadSelector::setNumberOfCoordsLoadSessions(mcIdType newNbOfCoordsLoadSessions) +{ + if(newNbOfCoordsLoadSessions < 1) + throw INTERP_KERNEL::Exception("MEDFileMeshReadSelector::setNumberOfCoordsLoadSessions : input must be >= 1 !"); + _nb_coords_load_sessions = newNbOfCoordsLoadSessions; +} + bool MEDFileMeshReadSelector::isCellFamilyFieldReading() const { return _code & 0x00000001; @@ -141,6 +152,7 @@ void MEDFileMeshReadSelector::setGlobalNodeNumFieldReading(bool b) void MEDFileMeshReadSelector::reprAll(std::ostream& str) const { str << "MEDFileMeshReadSelector (code=" << _code << ") : \n"; + str << "Number of coords load part sessions : " << this->_nb_coords_load_sessions << std::endl; str << "Read family field on cells : " << ReprStatus(isCellFamilyFieldReading()) << std::endl; str << "Read family field on nodes : " << ReprStatus(isNodeFamilyFieldReading()) << std::endl; str << "Read name field on cells : " << ReprStatus(isCellNameFieldReading()) << std::endl; diff --git a/src/MEDLoader/MEDFileMeshReadSelector.hxx b/src/MEDLoader/MEDFileMeshReadSelector.hxx index 514ebea62..8db3a3c3b 100644 --- a/src/MEDLoader/MEDFileMeshReadSelector.hxx +++ b/src/MEDLoader/MEDFileMeshReadSelector.hxx @@ -16,14 +16,14 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -// Author : Anthony Geay (CEA/DEN) +// Author : Anthony Geay (EDF R&D) -#ifndef __MEDFILEMESHREADSELECTOR_HXX__ -#define __MEDFILEMESHREADSELECTOR_HXX__ +#pragma once #include "MEDLoaderDefines.hxx" -#include +#include "MCIdType.hxx" + #include namespace MEDCoupling @@ -35,6 +35,8 @@ namespace MEDCoupling MEDFileMeshReadSelector(unsigned int code); unsigned int getCode() const; void setCode(unsigned int newCode); + mcIdType getNumberOfCoordsLoadSessions() const { return _nb_coords_load_sessions; } + void setNumberOfCoordsLoadSessions(mcIdType newNbOfCoordsLoadSessions); bool isCellFamilyFieldReading() const; bool isNodeFamilyFieldReading() const; bool isCellNameFieldReading() const; @@ -53,6 +55,7 @@ namespace MEDCoupling private: static std::string ReprStatus(bool v); private: + mcIdType _nb_coords_load_sessions; //bit #0 cell family field //bit #1 node family field //bit #2 cell name field @@ -63,4 +66,3 @@ namespace MEDCoupling }; } -#endif diff --git a/src/MEDLoader/Swig/MEDLoaderCommon.i b/src/MEDLoader/Swig/MEDLoaderCommon.i index 955e5f565..b1176fe83 100644 --- a/src/MEDLoader/Swig/MEDLoaderCommon.i +++ b/src/MEDLoader/Swig/MEDLoaderCommon.i @@ -672,6 +672,8 @@ namespace MEDCoupling public: MEDFileMeshReadSelector(); MEDFileMeshReadSelector(unsigned int code); + mcIdType getNumberOfCoordsLoadSessions(); + void setNumberOfCoordsLoadSessions(mcIdType newNbOfCoordsLoadSessions); unsigned int getCode() const; void setCode(unsigned int newCode); bool isCellFamilyFieldReading() const; -- 2.39.2