]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
Make it work for simple test case
authorAnthony Geay <anthony.geay@edf.fr>
Sun, 19 Apr 2020 20:47:20 +0000 (22:47 +0200)
committerAnthony Geay <anthony.geay@edf.fr>
Sun, 19 Apr 2020 20:47:20 +0000 (22:47 +0200)
src/ParaMEDMEM/ParaSkyLineArray.cxx
src/ParaMEDMEM_Swig/ParaMEDMEMCommon.i

index e75283a4a2d84d2fac3574be9ad7d8f8e37898f9..49fe857aa91b76d83f160a6298bbc27f35a82de2 100644 (file)
@@ -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> 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<DataArrayIdType> 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<DataArrayIdType> tmpValues2(tmpValues),tmpIndex2(tmpIndex);
       skToBeSent[curRk] = MEDCouplingSkyLineArray::New(tmpIndex,tmpValues);
     }
   }
@@ -101,7 +106,7 @@ MCAuto<ParaSkyLineArray> ParaSkyLineArray::equiRedistribute(mcIdType nbOfEntitie
     values = DataArrayIdType::Aggregate(FromVecAutoToVecOfConst<DataArrayIdType>(myRkSkValues));
   }
   // Reorder results coming from other procs
-  MCAuto<DataArrayIdType> aggregatedIdsSort(aggregatedIds->deepCopy()); aggregatedIds->sort();
+  MCAuto<DataArrayIdType> aggregatedIdsSort(aggregatedIds->deepCopy()); aggregatedIdsSort->sort();
   MCAuto<DataArrayIdType> idsIntoAggregatedIds(DataArrayIdType::FindPermutationFromFirstToSecondDuplicate(aggregatedIdsSort,aggregatedIds));
   MCAuto<DataArrayIdType> indicesSorted,valuesSorted;
   {
@@ -111,7 +116,7 @@ MCAuto<ParaSkyLineArray> ParaSkyLineArray::equiRedistribute(mcIdType nbOfEntitie
   }
   MCAuto<DataArrayIdType> idxOfSameIds(aggregatedIdsSort->indexOfSameConsecutiveValueGroups());
   //
-  MCAuto<DataArrayIdType> globalIdsOut(aggregatedIds->buildUnique());
+  MCAuto<DataArrayIdType> globalIdsOut(aggregatedIdsSort->buildUnique());
   MCAuto<MEDCouplingSkyLineArray> skOut(MEDCouplingSkyLineArray::New(valuesSorted,indicesSorted));
   skOut = skOut->groupPacks(idxOfSameIds);
   MCAuto<ParaSkyLineArray> ret(ParaSkyLineArray::New(skOut,globalIdsOut));
index 4b4ee79bbd216f358d1dafb91c3725c12e0958ad..ce4483313d7f2988037e5f2c17130231825841f2 100644 (file)
@@ -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<ParaSkyLineArray> ret(self->equiRedistribute(nbOfEntities));