]> SALOME platform Git repositories - modules/med.git/commitdiff
Salome HOME
Debug on limit cases when input part are empty. Correct bug of DeduceNumberOfEntities.
authorgeay <anthony.geay@cea.fr>
Wed, 11 Jun 2014 15:55:58 +0000 (17:55 +0200)
committergeay <anthony.geay@cea.fr>
Wed, 11 Jun 2014 15:55:58 +0000 (17:55 +0200)
src/MEDCoupling/MEDCouplingIMesh.cxx
src/MEDCoupling/MEDCouplingStructuredMesh.cxx
src/MEDCoupling_Swig/MEDCouplingBasicsTest.py

index 3821d60db48be380a7a7d5ac987691992e4096c3..a61d4fab21b2903bee15dc76f022732cc27bc35c 100644 (file)
@@ -294,6 +294,8 @@ void MEDCouplingIMesh::CondenseFineToCoarse(const std::vector<int>& coarseSt, co
       throw INTERP_KERNEL::Exception(oss.str().c_str());
     }
   int nbTuplesFine(fineDA->getNumberOfTuples());
+  if(nbOfTuplesInFineExp==0)
+    return ;
   if(nbTuplesFine%nbOfTuplesInFineExp!=0)
     throw INTERP_KERNEL::Exception("MEDCouplingIMesh::CondenseFineToCoarse : Invalid nb of tuples in fine DataArray regarding its structure !");
   int fact(std::accumulate(facts.begin(),facts.end(),1,std::multiplies<int>()));
index ebc71739d87730d4fed275aaa67c844d2047bc7c..58ec89f01f767fe0a55e02f76ef62f9eca7cfca7 100644 (file)
@@ -748,7 +748,6 @@ DataArrayInt *MEDCouplingStructuredMesh::ComputeCornersGhost(const std::vector<i
 int MEDCouplingStructuredMesh::DeduceNumberOfGivenRangeInCompactFrmt(const std::vector< std::pair<int,int> >& partCompactFormat)
 {
   int ret(1);
-  bool isFetched(false);
   std::size_t ii(0);
   for(std::vector< std::pair<int,int> >::const_iterator it=partCompactFormat.begin();it!=partCompactFormat.end();it++,ii++)
     {
@@ -758,13 +757,9 @@ int MEDCouplingStructuredMesh::DeduceNumberOfGivenRangeInCompactFrmt(const std::
           std::ostringstream oss; oss << "MEDCouplingStructuredMesh::DeduceNumberOfGivenRangeInCompactFrmt : invalid input at dimension " << ii << " !";
           throw INTERP_KERNEL::Exception(oss.str().c_str());
         }
-      if(b-a>0)
-        {
-          isFetched=true;
-          ret*=(b-a);
-        }
+      ret*=(b-a);
     }
-  return isFetched?ret:0;
+  return ret;
 }
 
 int MEDCouplingStructuredMesh::DeduceNumberOfGivenStructure(const std::vector<int>& st)
index 7e3a7696421a366566e3463253a9a71c9747f256..914dfdb22e2e2948e5fa0cb6e701524ac4dea1fc 100644 (file)
@@ -13525,7 +13525,7 @@ class MEDCouplingBasicsTest(unittest.TestCase):
         a,b=MEDCouplingStructuredMesh.IsPartStructured(d20,st)
         self.assertTrue(a) ; self.assertEqual(b,[(1,5),(0,3)])
         self.assertEqual(12,MEDCouplingStructuredMesh.DeduceNumberOfGivenRangeInCompactFrmt(b))
-        self.assertEqual(8,MEDCouplingStructuredMesh.DeduceNumberOfGivenRangeInCompactFrmt([(1,5),(1,3),(2,2)]))
+        self.assertEqual(0,MEDCouplingStructuredMesh.DeduceNumberOfGivenRangeInCompactFrmt([(1,5),(1,3),(2,2)]))
         self.assertEqual(0,MEDCouplingStructuredMesh.DeduceNumberOfGivenRangeInCompactFrmt([(5,5),(3,3),(2,2)]))
         self.assertEqual(36,MEDCouplingStructuredMesh.DeduceNumberOfGivenStructure([3,2,6]))
         self.assertEqual(126,MEDCouplingStructuredMesh.DeduceNumberOfGivenStructure((3,7,6)))