cross product

Hello,

I want to compute the Lamb vector as shown as below, which is vortical vector cross product velocity vector. The vortical vector can be computed by Gradent filiter, but how to get cross product? Could someone give me some advice?

d363ca24f97df64e42795170718494d4

see the documentation 5. Filtering Data — ParaView Documentation 5.12.0 documentation
There is no button for cross(), but it is supported by the Calculator, so you can simply write the following code:

fastUniformGrid1 = FastUniformGrid(registrationName='FastUniformGrid1')
fastUniformGrid1.GenerateDistanceSquaredScalars = 0

# create a new 'Gradient'
gradient1 = Gradient(registrationName='Gradient1', Input=fastUniformGrid1)
gradient1.ScalarArray = ['POINTS', 'Swirl']
gradient1.ComputeGradient = 0
gradient1.ComputeVorticity = 1

# create a new 'Calculator'
calculator1 = Calculator(registrationName='Calculator1', Input=gradient1)
calculator1.Function = 'cross(Vorticity, Swirl)'

Thanks for your kind reply. But forgive my stubid question, how to use this code? I tried to import in the Calculator, but it failed.

@jfavre’s posted a Python script. If you are using the GUI, just add the Calculator filter Screenshot 2024-11-04 at 8.56.58 AM and enter cross(omega, u) as the expression. (Of course, replace omega and u with the actual names of your vector fields. The Vectors combo box in the Calculator’s GUI makes it easy to insert the field names into the expression.)

Thanks a lot. But how to import this code? I paste the code in python shell, and run scrip, but it didn’t work.

What are you trying to do? In your screenshot you’ve already added the Calculator filter and set the expression. Why do you need to run a Python script?

Ok, I got it. After I run this python scrip, then I can use gradient and calculator to compute what I need. Thanks a lot.

Another calculator function that does not have a button is sign(). Do you have a list of calculator functions that do not have buttons?

@jfavre referenced the link earlier:

https://docs.paraview.org/en/latest/UsersGuide/filteringData.html#calculator

You can get to this from ParaView by selecting HelpParaView Guide. Then you can navigate to Filtering Data, Filters for attribute manipulation, and Calculator (or just search for calculator).

1 Like

Kenneth,
Thanks very much for the info.
Just thought I would mention that the underlying VTK technology has only the sign() function, but ParaView supports both sign() and sgn(), although only sgn() is mentioned in the UserGuide document that you mentioned.
Matthias