Skip to content

Commit 11432e4

Browse files
authored
fix(vtk): transpose vector before numpy_to_vtk (#2733)
add_vector() assigns a vector to each grid cell. The method takes an array of shape (3, nnodes) and passes it to numpy_support.numpy_to_vtk(), which due to the order of indices flattens it in column-major order, but VTK expects row-major order. So where cell i should get (x[i], y[i], z[i]) it instead gets (x[3i], x[3i+1], x[3i+2]) Fixed by transposing the array passed to numpy_to_vtk() so it is (nnodes, 3) and is flattened/interpreted correctly
1 parent 705b271 commit 11432e4

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

flopy/export/vtk.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -897,7 +897,7 @@ def add_vector(self, vector, name, masked_values=None):
897897
else:
898898
raise AssertionError("Size of vector must be 3 * nnodes or 3 * ncpl")
899899
else:
900-
vector = np.reshape(vector, (3, self.nnodes))
900+
vector = np.reshape(vector, (3, self.nnodes)).T
901901

902902
if self.point_scalars:
903903
tmp = []

0 commit comments

Comments
 (0)