From f24946d0e9800b47e69e3362762b910326467196 Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Sat, 18 Apr 2020 09:23:40 +0200 Subject: [PATCH] WIP --- src/MEDCoupling/MCAuto.hxx | 11 +++++++++++ src/ParaMEDMEM/CommInterface.cxx | 7 ++----- src/ParaMEDMEM/ParaSkyLineArray.cxx | 13 ++++++++++--- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/src/MEDCoupling/MCAuto.hxx b/src/MEDCoupling/MCAuto.hxx index 1d47b7f67..6ef2fab78 100644 --- a/src/MEDCoupling/MCAuto.hxx +++ b/src/MEDCoupling/MCAuto.hxx @@ -24,6 +24,7 @@ #include "InterpKernelException.hxx" #include +#include namespace MEDCoupling { @@ -60,6 +61,16 @@ namespace MEDCoupling T *_ptr; }; + template + std::vector FromVecAutoToVecOfConst(const std::vector>& inputVec) + { + std::size_t size(inputVec.size()); + std::vector< const T *> ret(size); + typename std::vector< const T *>::iterator itArrays(ret.begin()); + std::for_each(inputVec.begin(),inputVec.end(),[&itArrays](MCAuto elt) { *itArrays++=elt; }); + return ret; + } + template typename MEDCoupling::MCAuto DynamicCast(typename MEDCoupling::MCAuto& autoSubPtr) throw() { diff --git a/src/ParaMEDMEM/CommInterface.cxx b/src/ParaMEDMEM/CommInterface.cxx index 96c85fd9e..eaab8af02 100644 --- a/src/ParaMEDMEM/CommInterface.cxx +++ b/src/ParaMEDMEM/CommInterface.cxx @@ -86,11 +86,8 @@ namespace MEDCoupling this->commSize(comm,&size); if( arrays.size() != ToSizeT(size) ) throw INTERP_KERNEL::Exception("AllToAllArrays : internal error ! Invalid size of input array."); - std::vector< const DataArrayIdType *> arraysBis(size); - { - std::vector< const DataArrayIdType *>::iterator itArraysBis(arraysBis.begin()); - std::for_each(arrays.begin(),arrays.end(),[&itArraysBis](MCAuto elt) { *itArraysBis++=elt; }); - } + + std::vector< const DataArrayIdType *> arraysBis(FromVecAutoToVecOfConst(arrays)); std::unique_ptr nbOfElems2(new mcIdType[size]),nbOfElems3(new mcIdType[size]); for(int curRk = 0 ; curRk < size ; ++curRk) { diff --git a/src/ParaMEDMEM/ParaSkyLineArray.cxx b/src/ParaMEDMEM/ParaSkyLineArray.cxx index fc88c3807..a7f0d22b9 100644 --- a/src/ParaMEDMEM/ParaSkyLineArray.cxx +++ b/src/ParaMEDMEM/ParaSkyLineArray.cxx @@ -77,15 +77,22 @@ MCAuto ParaSkyLineArray::equiRedistribute(mcIdType nbOfEntitie } } // communication : 3 arrays are going to be all2allized : ids, SkyLine index and SyLine values - std::vector< MCAuto > myRkIdsCaptured, myRkSkIndex, myRkSkValues; - ci.allToAllArrays(comm,idsCaptured,myRkIdsCaptured); + MCAuto aggregatedIds,indices,values; { + std::vector< MCAuto > myRkIdsCaptured; + ci.allToAllArrays(comm,idsCaptured,myRkIdsCaptured); + aggregatedIds = DataArrayIdType::Aggregate(FromVecAutoToVecOfConst(myRkIdsCaptured)); + } + { + std::vector< MCAuto > myRkSkIndex; std::vector< MCAuto > indexToBeSent(MEDCouplingSkyLineArray::RetrieveVecIndex(skToBeSent)); ci.allToAllArrays(comm,indexToBeSent,myRkSkIndex); + indices = DataArrayIdType::AggregateIndexes(FromVecAutoToVecOfConst(myRkSkIndex)); } { + std::vector< MCAuto > myRkSkValues; std::vector< MCAuto > valuesToBeSent(MEDCouplingSkyLineArray::RetrieveVecValues(skToBeSent)); ci.allToAllArrays(comm,valuesToBeSent,myRkSkValues); + values = DataArrayIdType::Aggregate(FromVecAutoToVecOfConst(myRkSkValues)); } - // assemble the 3 arrays myRkIdsCaptured, myRkSkIndex, myRkSkValues } \ No newline at end of file -- 2.39.2