const double *d=getCoordsAt(i)->getConstPointer();
int nbOfNodes=getCoordsAt(i)->getNbOfElems();
double ref=pos[i];
- const double *w=std::find_if(d,d+nbOfNodes,std::bind2nd(std::greater<double>(),ref));
+ const double *w=std::find_if(d,d+nbOfNodes,std::bind2nd(std::greater_equal<double>(),ref));
int w2=(int)std::distance(d,w);
- if(w2<nbOfNodes && w2!=0)
+ if(w2<nbOfNodes)
{
+ if(w2==0)
+ {
+ if(ref>d[0]-eps)
+ w2=1;
+ else
+ return -1;
+ }
ret+=coeff*(w2-1);
coeff*=nbOfNodes-1;
}
da.setValues(discX,4,1);
m.setCoordsAt(0,da);
m.checkCoherency();
- self.assertEqual(0,m.getCellContainingPoint([2.4],12));
- self.assertEqual(1,m.getCellContainingPoint([3.7],12));
- self.assertEqual(2,m.getCellContainingPoint([5.9],12));
- self.assertEqual(-1,m.getCellContainingPoint([10.3],12));
- self.assertEqual(-1,m.getCellContainingPoint([1.3],12));
+ self.assertEqual(0,m.getCellContainingPoint([2.4],1e-12));
+ self.assertEqual(1,m.getCellContainingPoint([3.7],1e-12));
+ self.assertEqual(2,m.getCellContainingPoint([5.9],1e-12));
+ self.assertEqual(-1,m.getCellContainingPoint([10.3],1e-12));
+ self.assertEqual(-1,m.getCellContainingPoint([1.3],1e-12));
#
m2=m.buildUnstructured();
m2.checkCoherency();