From: Anthony Geay Date: Sun, 19 Apr 2020 20:47:20 +0000 (+0200) Subject: Make it work for simple test case X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=6eabc8bc224056aa6950207d676282f0092e6673;p=tools%2Fmedcoupling.git Make it work for simple test case --- diff --git a/src/ParaMEDMEM/ParaSkyLineArray.cxx b/src/ParaMEDMEM/ParaSkyLineArray.cxx index e75283a4a..49fe857aa 100644 --- a/src/ParaMEDMEM/ParaSkyLineArray.cxx +++ b/src/ParaMEDMEM/ParaSkyLineArray.cxx @@ -49,7 +49,10 @@ ParaSkyLineArray::ParaSkyLineArray(MEDCouplingSkyLineArray *ska, DataArrayIdType _ska.checkNotNull(); _global_ids.checkNotNull(); if(_ska->getNumberOf() != _global_ids->getNumberOfTuples()) - throw INTERP_KERNEL::Exception("ParaSkyLineArray constructor : mismatch between # globalIds and len of indices in SkyLineArray."); + { + std::ostringstream oss; oss << "ParaSkyLineArray constructor : mismatch between # globalIds (" << _global_ids->getNumberOfTuples() << ") and len of indices in SkyLineArray (" << _ska->getNumberOf() << ")."; + throw INTERP_KERNEL::Exception(oss.str()); + } } std::size_t ParaSkyLineArray::getHeapMemorySizeWithoutChildren() const @@ -74,10 +77,12 @@ MCAuto ParaSkyLineArray::equiRedistribute(mcIdType nbOfEntitie { mcIdType curStart(0),curEnd(0); DataArrayIdType::GetSlice(0,nbOfEntities,1,curRk,size,curStart,curEnd); - idsCaptured[curRk] = _global_ids->findIdsInRange(curStart,curEnd); + MCAuto idsInGlobalIds(_global_ids->findIdsInRange(curStart,curEnd)); + idsCaptured[curRk] = _global_ids->selectByTupleIdSafe(idsInGlobalIds->begin(),idsInGlobalIds->end()); { DataArrayIdType *tmpValues(nullptr),*tmpIndex(nullptr); - DataArrayIdType::ExtractFromIndexedArrays(idsCaptured[curRk]->begin(),idsCaptured[curRk]->end(),this->_ska->getValuesArray(),this->_ska->getIndexArray(),tmpValues,tmpIndex); + DataArrayIdType::ExtractFromIndexedArrays(idsInGlobalIds->begin(),idsInGlobalIds->end(),this->_ska->getValuesArray(),this->_ska->getIndexArray(),tmpValues,tmpIndex); + MCAuto tmpValues2(tmpValues),tmpIndex2(tmpIndex); skToBeSent[curRk] = MEDCouplingSkyLineArray::New(tmpIndex,tmpValues); } } @@ -101,7 +106,7 @@ MCAuto ParaSkyLineArray::equiRedistribute(mcIdType nbOfEntitie values = DataArrayIdType::Aggregate(FromVecAutoToVecOfConst(myRkSkValues)); } // Reorder results coming from other procs - MCAuto aggregatedIdsSort(aggregatedIds->deepCopy()); aggregatedIds->sort(); + MCAuto aggregatedIdsSort(aggregatedIds->deepCopy()); aggregatedIdsSort->sort(); MCAuto idsIntoAggregatedIds(DataArrayIdType::FindPermutationFromFirstToSecondDuplicate(aggregatedIdsSort,aggregatedIds)); MCAuto indicesSorted,valuesSorted; { @@ -111,7 +116,7 @@ MCAuto ParaSkyLineArray::equiRedistribute(mcIdType nbOfEntitie } MCAuto idxOfSameIds(aggregatedIdsSort->indexOfSameConsecutiveValueGroups()); // - MCAuto globalIdsOut(aggregatedIds->buildUnique()); + MCAuto globalIdsOut(aggregatedIdsSort->buildUnique()); MCAuto skOut(MEDCouplingSkyLineArray::New(valuesSorted,indicesSorted)); skOut = skOut->groupPacks(idxOfSameIds); MCAuto ret(ParaSkyLineArray::New(skOut,globalIdsOut)); diff --git a/src/ParaMEDMEM_Swig/ParaMEDMEMCommon.i b/src/ParaMEDMEM_Swig/ParaMEDMEMCommon.i index 4b4ee79bb..ce4483313 100644 --- a/src/ParaMEDMEM_Swig/ParaMEDMEMCommon.i +++ b/src/ParaMEDMEM_Swig/ParaMEDMEMCommon.i @@ -144,9 +144,14 @@ namespace MEDCoupling class ParaSkyLineArray : public RefCountObject { public: - ParaSkyLineArray(MEDCouplingSkyLineArray *ska, DataArrayIdType *globalIds); + static ParaSkyLineArray *New(MEDCouplingSkyLineArray *ska, DataArrayIdType *globalIds); %extend { + ParaSkyLineArray(MEDCouplingSkyLineArray *ska, DataArrayIdType *globalIds) + { + return ParaSkyLineArray::New(ska,globalIds); + } + ParaSkyLineArray *equiRedistribute(mcIdType nbOfEntities) const { MCAuto ret(self->equiRedistribute(nbOfEntities));