]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
To test on big case agy/para_mesh_opt
authorAnthony Geay <anthony.geay@edf.fr>
Sun, 19 Apr 2020 21:58:02 +0000 (23:58 +0200)
committerAnthony Geay <anthony.geay@edf.fr>
Sun, 19 Apr 2020 21:58:02 +0000 (23:58 +0200)
src/MEDCoupling/MEDCouplingSkyLineArray.cxx
src/MEDCoupling/MEDCouplingSkyLineArray.hxx
src/MEDCoupling_Swig/MEDCouplingBasicsTest7.py
src/MEDCoupling_Swig/MEDCouplingCommon.i
src/ParaMEDMEM/ParaSkyLineArray.cxx
src/ParaMEDMEM/ParaSkyLineArray.hxx
src/ParaMEDMEM_Swig/ParaMEDMEMCommon.i

index bc216096ae7aef9616064e80457449365ed922cd..8e795113813a008840562316f0d80bf59530bc5c 100755 (executable)
@@ -326,6 +326,28 @@ MEDCouplingSkyLineArray *MEDCouplingSkyLineArray::groupPacks(const DataArrayIdTy
   return ret.retn();
 }
 
+MEDCouplingSkyLineArray *MEDCouplingSkyLineArray::uniqueNotSortedByPack() const
+{
+  mcIdType nbPacks(this->getNumberOf());
+  MCAuto<DataArrayIdType> retIndex(DataArrayIdType::New()); retIndex->alloc(nbPacks+1,1);
+  const mcIdType *valuesPtr(this->_values->begin()),*indexPtr(this->_index->begin());
+  mcIdType *retIndexPtr(retIndex->getPointer()); *retIndexPtr = 0;
+  for(mcIdType i = 0 ; i < nbPacks ; ++i, ++retIndexPtr)
+  {
+    std::set<mcIdType> s(valuesPtr+indexPtr[i],valuesPtr+indexPtr[i+1]);
+    retIndexPtr[1] = retIndexPtr[0] + ToIdType(s.size());
+  }
+  MCAuto<DataArrayIdType> retValues(DataArrayIdType::New()); retValues->alloc(retIndex->back(),1);
+  mcIdType *retValuesPtr(retValues->getPointer());
+  for(mcIdType i = 0 ; i < nbPacks ; ++i)
+  {
+    std::set<mcIdType> s(valuesPtr+indexPtr[i],valuesPtr+indexPtr[i+1]);
+    retValuesPtr = std::copy(s.begin(),s.end(),retValuesPtr);
+  }
+  MCAuto<MEDCouplingSkyLineArray> ret(MEDCouplingSkyLineArray::New(retIndex,retValues));
+  return ret.retn();
+}
+
 /**
  * For a 2- or 3-level SkyLine array, return a copy of the absolute pack with given identifier.
  */
index 21fba35eb08dd262aa4c650d74f97a4718d39ea4..a514127810853e335dc1c6918141881a6f47a0bf 100644 (file)
@@ -108,6 +108,7 @@ namespace MEDCoupling
     std::string simpleRepr() const;
 
     MEDCouplingSkyLineArray *groupPacks(const DataArrayIdType *indexedPacks) const;
+    MEDCouplingSkyLineArray *uniqueNotSortedByPack() const;
 
     void getSimplePackSafe(const mcIdType absolutePackId, std::vector<mcIdType> & pack) const;
     const mcIdType * getSimplePackSafePtr(const mcIdType absolutePackId, mcIdType & packSize) const;
index 953d7292735fc03e1ce778e04ee494c6d8012645..b11d10b1cc32c14a5e6daa00317917a2369498f9 100644 (file)
@@ -757,7 +757,7 @@ class MEDCouplingBasicsTest7(unittest.TestCase):
 
     def testDAIOccurenceRankInThis(self):
         arr=DataArrayInt([5,3,2,1,4,5,2,1,0,11,5,4])
-        self.assertTrue(arr.occurenceRankInThis().isEqual(DataArrayInt([0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 2, 1])))
+        self.assertTrue(arr.occurenceRankInThis().isEqual(DataArrayInt([0,0,0,0,0,1,1,1,0,0,2,1])))
 
     def testDAIFindPermutationFromFirstToSecondDuplicate(self):
         arr0 = DataArrayInt([5,3,2,1,4,5,2,1,0,11,5,4])
@@ -767,7 +767,7 @@ class MEDCouplingBasicsTest7(unittest.TestCase):
         
     def testDAIIndexOfSameConsecutiveValueGroups(self):
         arr = DataArrayInt([0,1,1,2,2,3,4,4,5,5,5,11])
-        self.assertTrue(arr.indexOfSameConsecutiveValueGroups().isEqual(DataArrayInt([0, 1, 3, 5, 6, 8, 11, 12])))
+        self.assertTrue(arr.indexOfSameConsecutiveValueGroups().isEqual(DataArrayInt([0,1,3,5,6,8,11,12])))
 
     def testSkyLineGroupPacks(self):
         arr = DataArrayInt([1,4,5,0,2,4,5,6,1,3,5,6,7,2,6,7,0,1,5,8,9,0,1,2,4,6,8,9,10,1,2,3,5,7,9,10,11,2,3,6,10,11,4,5,9,12,13,4,5,6,8,10,12,13,14,5,6,7,9,11,13,14,15,6,7,10,14,15,8,9,13,8,9,10,12,14,9,10,11,13,15,10,11,14])
@@ -777,6 +777,15 @@ class MEDCouplingBasicsTest7(unittest.TestCase):
         sk2 = sk.groupPacks(part)
         self.assertTrue(sk2.getValuesArray().isEqual(arr))
         self.assertTrue(sk2.getIndexArray().isEqual(DataArrayInt([0,13,16,37,84])))
+
+    def testSkyLineUniqueNotSortedByPack(self):    
+        arrI = DataArrayInt([0,3,9,15,18,24,36,48,54])
+        arr = DataArrayInt([1,4,5,0,4,5,2,5,6,3,6,7,1,5,6,2,6,7,0,1,5,5,8,9,0,1,4,6,9,10,1,2,4,6,8,9,2,3,5,7,9,10,1,2,5,7,10,11,2,3,6,6,10,11])
+        sk = MEDCouplingSkyLineArray(arrI,arr)
+        sk2 = sk.uniqueNotSortedByPack()
+        self.assertTrue(sk2.getIndexArray().isEqual(DataArrayInt([0,3,8,13,16,21,29,37,42])))
+        self.assertTrue(sk2.getValuesArray().isEqual(DataArrayInt([1,4,5,0,2,4,5,6,1,3,5,6,7,2,6,7,0,1,5,8,9,0,1,2,4,6,8,9,10,1,2,3,5,7,9,10,11,2,3,6,10,11])))
+
     pass
 
 if __name__ == '__main__':
index b3b8069957d4bb5f4f7ae8a1dec117195e924e00..cc5ab47be26821bf5f0d64d78168971a3d02ce12 100644 (file)
@@ -467,6 +467,7 @@ typedef long int mcIdType;
 %newobject MEDCoupling::MEDCouplingSkyLineArray::getIndexArray;
 %newobject MEDCoupling::MEDCouplingSkyLineArray::getValuesArray;
 %newobject MEDCoupling::MEDCouplingSkyLineArray::groupPacks;
+%newobject MEDCoupling::MEDCouplingSkyLineArray::uniqueNotSortedByPack;
 
 %feature("unref") MEDCouplingPointSet "$this->decrRef();"
 %feature("unref") MEDCouplingMesh "$this->decrRef();"
@@ -1299,6 +1300,7 @@ namespace MEDCoupling
     void deleteSimplePacks(const DataArrayIdType* idx);
 
     MEDCouplingSkyLineArray *groupPacks(const DataArrayIdType *indexedPacks) const;
+    MEDCouplingSkyLineArray *uniqueNotSortedByPack() const;
     
     %extend 
     {
index 49fe857aa91b76d83f160a6298bbc27f35a82de2..586c0c4a85e8041d13926369788e8c66000a6781 100644 (file)
@@ -42,6 +42,16 @@ ParaSkyLineArray *ParaSkyLineArray::New(MEDCouplingSkyLineArray *ska, DataArrayI
   return new ParaSkyLineArray(ska,globalIds);
 }
 
+MEDCouplingSkyLineArray *ParaSkyLineArray::getSkyLineArray() const
+{
+  return this->_ska.iAmATrollConstCast();
+}
+
+DataArrayIdType *ParaSkyLineArray::getGlobalIdsArray() const
+{
+  return this->_global_ids.iAmATrollConstCast();
+}
+
 ParaSkyLineArray::ParaSkyLineArray(MEDCouplingSkyLineArray *ska, DataArrayIdType *globalIds)
 {
   _ska.takeRef(ska);
@@ -117,8 +127,9 @@ MCAuto<ParaSkyLineArray> ParaSkyLineArray::equiRedistribute(mcIdType nbOfEntitie
   MCAuto<DataArrayIdType> idxOfSameIds(aggregatedIdsSort->indexOfSameConsecutiveValueGroups());
   //
   MCAuto<DataArrayIdType> globalIdsOut(aggregatedIdsSort->buildUnique());
-  MCAuto<MEDCouplingSkyLineArray> skOut(MEDCouplingSkyLineArray::New(valuesSorted,indicesSorted));
-  skOut = skOut->groupPacks(idxOfSameIds);
+  MCAuto<MEDCouplingSkyLineArray> skOut(MEDCouplingSkyLineArray::New(indicesSorted,valuesSorted));
+  skOut = skOut->groupPacks(idxOfSameIds);//group partial packs coming from different procs
+  skOut = skOut->uniqueNotSortedByPack();//remove duplicates
   MCAuto<ParaSkyLineArray> ret(ParaSkyLineArray::New(skOut,globalIdsOut));
   return ret.retn();
 }
\ No newline at end of file
index 19dad005a5b96340816074e07014b54459998bf2..7e3ba19627b7c99853ca79ad0fc03fe912c428e5 100644 (file)
@@ -39,6 +39,8 @@ namespace MEDCoupling
   public:
     static ParaSkyLineArray *New(MEDCouplingSkyLineArray *ska, DataArrayIdType *globalIds);
     MCAuto<ParaSkyLineArray> equiRedistribute(mcIdType nbOfEntities) const;
+    MEDCouplingSkyLineArray *getSkyLineArray() const;
+    DataArrayIdType *getGlobalIdsArray() const;
     virtual ~ParaSkyLineArray() { }
   private:
     ParaSkyLineArray(MEDCouplingSkyLineArray *ska, DataArrayIdType *globalIds);
index ce4483313d7f2988037e5f2c17130231825841f2..6cde35541ee2184ef5be3bf42ef738d39c946285 100644 (file)
@@ -60,6 +60,8 @@ using namespace ICoCo;
 
 %newobject MEDCoupling::ParaUMesh::getCellIdsLyingOnNodes;
 %newobject MEDCoupling::ParaSkyLineArray::equiRedistribute;
+%newobject MEDCoupling::ParaSkyLineArray::getSkyLineArray;
+%newobject MEDCoupling::ParaSkyLineArray::getGlobalIdsArray;
 
 %feature("unref") ParaSkyLineArray "$this->decrRef();"
 
@@ -157,6 +159,22 @@ namespace MEDCoupling
         MCAuto<ParaSkyLineArray> ret(self->equiRedistribute(nbOfEntities));
         return ret.retn();
       }
+
+      MEDCouplingSkyLineArray *getSkyLineArray() const
+      {
+        MEDCouplingSkyLineArray *ret(self->getSkyLineArray());
+        if(ret)
+          ret->incrRef();
+        return ret;
+      }
+      
+      DataArrayIdType *getGlobalIdsArray() const
+      {
+        DataArrayIdType *ret(self->getGlobalIdsArray());
+        if(ret)
+          ret->incrRef();
+        return ret;
+      }
     }
   };
 }