[vtkusers] A bug in vtkLine::Derivatives()?
Andy Bauer
andy.bauer at kitware.com
Tue Mar 19 10:12:59 EDT 2013
Hi,
This is now fixed in VTK. Thanks for the help in finding the bug.
Andy
On Thu, Mar 7, 2013 at 10:21 AM, Hong Yi <hongyi at renci.org> wrote:
> 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****
>
> ** **
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20130319/15f5afba/attachment.htm>
More information about the vtkusers
mailing list