ValueError with Numpy Programmable Filter and Exodus File

Hello all,

I am trying to extract the lambda-2 criterion from an Exodus solution file following the method in this post. My solution has 3 individual vector components, so I apply a Merge Vector Components filter to create the velocity field, and then attempt to apply a programmable filter on top of that to calculate the lambda-2s, as described in that post. When I hit apply, I get the following error:

ValueError: matmul: Input operand 0 does not have enough dimensions (has 0, gufunc core with signature (n?,k),(k,m?)->(n?,m?) requires 1)

I have tried troubleshooting the script a few ways but cannot get around this issue. The script works as expected when I generate a mesh with a source in ParaView and create a synthetic velocity field with the Calculator filter, but it refuses to work with the Exodus solution file.

Any help would be appreciated. I have attached both a sample .exo solution file and a ParaView state file to this post for anyone who is interested in debugging.

Thanks,
Kellis

lambda-2-script.pvsm (418.6 KB)
incompressible_3d_wale_cavity_small_solution.exo (792.6 KB)

In version 5.12.0, I incorporated a Merge Blocks filter prior to the Programmable filter, and the following Script did not trigger any errors.

import numpy as np

# Compute the lambda_2 Vortex criterion, see pp.76-77 in
# J. Jeong and F. Hussain, “On the identification of a vortex,” 
#  Journal of Fluid Mechanics, vol. 285, pp. 69–94, 1995, doi: 10.1017/S0022112095000462.

vvector = inputs[0].PointData['velocity']

vstrain = strain(vvector)
vskew = gradient(vvector) - vstrain

aaa = matmul(vstrain, vstrain) + matmul(vskew, vskew)

# since aaa is symmetric, it only has real eigenvalues
lambdas  = np.linalg.eigvals(aaa)
lambdas  = np.real(lambdas )
lambda2 = sort(lambdas)[:,1]

output.DeepCopy(inputs[0].VTKObject)
output.PointData.append(lambda2, 'lambda2')

lambda-2-script_01.pvsm (738.3 KB)

Thank you very much! Applying your script gave the expected results in Paraview 5.11.0 as well.

Cheers,
Kellis

To give some context here:

MergeBlocks converts MultiBlock Data (like Exodus) into Unstructured Grid data. You can work with the MultiBlock data directly, but you have to loop over the blocks. There aren’t a lot of Programmable Filter examples out there with MultiBlock Data to learn from, so most of us use MergeBlocks.