Just for the record, the cause was actually writing data into the vtkDoubleArray
in a wrong way -- the array has 3 components and the indices were actually 1/3 of what they should have been, with x/y/z values interspersed (that gives the 3x3 pattern in the lower third, as I realized); I was assuming the components were stored contiguously, which is apparently not the case.
The old code was something like this:
auto flow=vtkSmartPointer<vtkDoubleArray>::New();
flow->SetNumberOfComponents(3);
auto grid=vtkSmartPointer<vtkUniformGrid>::New();
grid->SetDimensions(...);
grid->GetPointData()->AddArray(flow);
for(int i:{0,1,2}) flow->FillComponent(i,0);
for(ijk: ... /* traverses the grid, each point potentially more than once */ ){
vtkIdType dataId=grid->ComputePointId(ijk);
// XXX: this is what caused troubles:
double* f0=flow->GetPointer(dataId);
f[0]+=dx;
f[1]+=dy;
f[2]+=dz;
}
The correct version of the loop body is:
double f[3];
flow->GetTupleValue(dataId,f); // copy the data
f[0]+=dx;
f[1]+=dy;
f[2]+=dz;
flow->SetTupleValue(dataId,f);
Both scalar and vector datasets are now matching: