Salome HOME
For load balancing on // interpolation
authorageay <ageay>
Thu, 8 Aug 2013 10:53:42 +0000 (10:53 +0000)
committerageay <ageay>
Thu, 8 Aug 2013 10:53:42 +0000 (10:53 +0000)
- MEDCouplingPointSet::ComputeNbOfInteractionsWithSrcCells
- DataArrayDouble::computeNbOfInteractionsWith
- DataArrayInt::splitInBalancedSlices

src/MEDCoupling/MEDCouplingMemArray.cxx
src/MEDCoupling_Swig/MEDCouplingBasicsTest.py

index e96490c05902ab81504f25be836541ae9e1ba18b..9c2fda8fa2970156c018b98427efe2e7928d62e9 100644 (file)
@@ -9932,7 +9932,10 @@ std::vector< std::pair<int,int> > DataArrayInt::splitInBalancedSlices(int nbOfSl
       std::pair<int,int> p(pos,-1);
       int locSum(0);
       while(locSum<sumPerSlc && pos<nbOfTuples) { pos++; locSum+=*w++; }
-      p.second=pos;
+      if(i!=nbOfSlices-1)
+        p.second=pos;
+      else
+        p.second=nbOfTuples;
       ret[i]=p;
     }
   return ret;
index 94f70f0b92b7fc9986d23dca6d23a13e6d13ef79..ae1c8c58d844b7e5f07a152ea077c7784bbbfea0 100644 (file)
@@ -13733,6 +13733,25 @@ class MEDCouplingBasicsTest(unittest.TestCase):
         self.assertAlmostEqual(16.,d.getMeasureField(False).accumulate()[0],1e-13)
         pass
 
+    def testSwig2LoadBalanceBBox1(self):
+        arr=DataArrayDouble(5) ; arr.iota()
+        t=MEDCouplingCMesh() ; t.setCoords(arr,arr)
+        arr=DataArrayDouble(16) ; arr.iota() ; arr*=2./15
+        s=MEDCouplingCMesh() ; s.setCoords(arr,arr[:]) ; s.translate([2.,1.])
+        #
+        s1=s.build1SGTUnstructured()
+        t1=t.build1SGTUnstructured()
+        w=MEDCouplingPointSet.ComputeNbOfInteractionsWithSrcCells(s1,t1,1e-12)
+        wExp=DataArrayInt([0,0,0,0,0,0,64,64,0,0,64,64,0,0,0,0])
+        self.assertTrue(w.isEqual(wExp))
+        slcs=w.splitInBalancedSlices(4)
+        self.assertEqual(len(slcs),4)
+        self.assertEqual(slcs,[slice(0,7,1),slice(7,8,1),slice(8,11,1),slice(11,16,1)])
+        bbs=s1.getBoundingBoxForBBTree()
+        bbt=t1.getBoundingBoxForBBTree()
+        self.assertTrue(bbt.computeNbOfInteractionsWith(bbs,1e-12).isEqual(wExp))
+        pass
+
     def setUp(self):
         pass
     pass