[vtkusers] A bug in vtkLine::Derivatives()?
Hong Yi
hongyi at renci.org
Thu Mar 7 10:21:32 EST 2013
I found some discrepancy in velocity gradient result for a test data between passing dim=1 and passing dim=3 when computing derivatives, and after some debugging and tracing, I think I found the root of the discrepancy which looks like a bug to me in vtkLine::Derivatives() function. Specifically, here is the code of the function:
-------------------------------
void vtkLine::Derivatives(int vtkNotUsed(subId),
double vtkNotUsed(pcoords)[3],
double *values,
int dim, double *derivs)
{
double x0[3], x1[3], deltaX[3];
int i, j;
this->Points->GetPoint(0, x0);
this->Points->GetPoint(1, x1);
for (i=0; i<3; i++)
{
deltaX[i] = x1[i] - x0[i];
}
for (i=0; i<dim; i++)
{
for (j=0; j<3; j++)
{
if ( deltaX[j] != 0 )
{
derivs[3*i+j] = (values[2*i+1] - values[2*i]) / deltaX[j];
}
else
{
derivs[3*i+j] =0;
}
}
}
}
-------------------------------
The suspicious line is highlighted above. When dim=1, this code generates correct result. However, when dim=3 for velocity, values[2*i+1]-values[2*i] are not using the correct indices since the values will be like (vx0, vy0, vz0, vx1, vy1, vz1) and the values[2*i+1]-values[2*i] will be vy0-vx0, vx1-vz0, and vz1-vy1 rather than the expected vx1-vx0, vy1-vy0, and vz1-vz0.
I did not find any bug filed on this, so I am confirming here: is this a bug?
Thanks,
Hong
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20130307/4bd82596/attachment.htm>
More information about the vtkusers
mailing list