I'm looking to calculate curl of a vector field to visualize vorticity within a velocity field.
Curl is stated as the cross product of the vector and the gradient or
From a houdini standpoint the gradient of a vector field is a 3x3matrix, so I don't see how you could possibly do a cross product of a matrix and a vector.
I think I'm missing a key point here since I can't find any information online about this kind of implementation.
Can any math gurus help me out here? I know its available in dop context so I don't think it would be too difficult to get together in sops(vex).
Curl Calculation
18024 15 3 icarus551
 Member
 22 posts
 Joined: Dec. 2009
 Offline
 Dennis Weil
 Member
 150 posts
 Joined: May 2011
 Offline
 symek
 Member
 1390 posts
 Joined: July 2005
 Offline
 bhaveshpandey
 Member
 127 posts
 Joined: Nov. 2008
 Offline
 Solitude
 Member
 373 posts
 Joined: March 2009
 Offline
 neil_math_comp
 Member
 1743 posts
 Joined: March 2012
 Offline
The curl of a vector field is just a vector field, not a matrix field. The second equation image on Wikipedia is probably what you're looking for. It defines curl directly in terms of derivatives, so there's no ambiguity about cross products: http://en.wikipedia.org/wiki/Curl_%28mathematics%29#Definition [en.wikipedia.org]
Hopefully this helps!
Hopefully this helps!
Writing code for fun and profit since... 2005? Wow, I'm getting old.
https://www.youtube.com/channel/UC_HFmdvpe9U2G3OMNViKMEQ [www.youtube.com]
https://www.youtube.com/channel/UC_HFmdvpe9U2G3OMNViKMEQ [www.youtube.com]
 Alejandro Echeverry
 Member
 691 posts
 Joined: June 2006
 Offline
I have an asset for a post curl calculation in sops; Hope that helps you!!!
Feel The Knowledge, Kiss The Goat!!!
http://www.linkedin.com/in/alejandroecheverry [linkedin.com]
http://vimeo.com/lordpazuzu/videos [vimeo.com]
http://www.linkedin.com/in/alejandroecheverry [linkedin.com]
http://vimeo.com/lordpazuzu/videos [vimeo.com]
 icarus551
 Member
 22 posts
 Joined: Dec. 2009
 Offline
dennis.weil
Hi,
I've never seen the gradient expressed as a matrix. What did you do to get this result?
The Volume Gradient VOP or volumegradient() vex function return a gradient vector which should be exactly what you need.
dennis
This is only in terms of scalar fields, a vector field will return a matrix (a vector consists of 3 scalars, so you have 3x the components)
I'm really looking to keep this simple and avoid using a wrapper around the gas analysis dop.
 Dennis Weil
 Member
 150 posts
 Joined: May 2011
 Offline
 icarus551
 Member
 22 posts
 Joined: Dec. 2009
 Offline
Symek, I think that is correct, I took the tensorvector dot product of the gradient matrix and the normalized vector, then used that in a cross product with the vector, which first look appears to give a correct curl vector.
On a basic vortex velocity field it looks correct, but I need to check it out on a more complex field.
On a basic vortex velocity field it looks correct, but I need to check it out on a more complex field.
 icarus551
 Member
 22 posts
 Joined: Dec. 2009
 Offline
 johner
 Staff
 818 posts
 Joined: July 2006
 Offline
The VolumeAnalyis SOP should really have an option to calculate the curl, but in the meantime you can compute the gradient of each velocity component and calculate the curl by hand in VOPs (thereby doing a little extra work: nine derivatives instead of the six minimally required).
See attached for an example of computing the curl of a FLIP sim (and turn on the curl attribute visualization).
See attached for an example of computing the curl of a FLIP sim (and turn on the curl attribute visualization).
 Alejandro Echeverry
 Member
 691 posts
 Joined: June 2006
 Offline
Thanks Johner!!! :shock:
Feel The Knowledge, Kiss The Goat!!!
http://www.linkedin.com/in/alejandroecheverry [linkedin.com]
http://vimeo.com/lordpazuzu/videos [vimeo.com]
http://www.linkedin.com/in/alejandroecheverry [linkedin.com]
http://vimeo.com/lordpazuzu/videos [vimeo.com]
 icarus551
 Member
 22 posts
 Joined: Dec. 2009
 Offline
johner
The VolumeAnalyis SOP should really have an option to calculate the curl, but in the meantime you can compute the gradient of each velocity component and calculate the curl by hand in VOPs (thereby doing a little extra work: nine derivatives instead of the six minimally required).
See attached for an example of computing the curl of a FLIP sim (and turn on the curl attribute visualization).
I was shown a similar solution which is correctly theoretically, but if you compare it against the dop computed curl they don't even look similar.
I ran a 2D smoke sim (xz axis) to compare. Curl vectors of a 2d field should all point along one axis (y axis). The dop computed curl does this but none of the sop solutions do.
Very mysterious.
 johner
 Staff
 818 posts
 Joined: July 2006
 Offline
icarus551
I was shown a similar solution which is correctly theoretically, but if you compare it against the dop computed curl they don't even look similar.
I ran a 2D smoke sim (xz axis) to compare. Curl vectors of a 2d field should all point along one axis (y axis). The dop computed curl does this but none of the sop solutions do.
Hmm, I'm not seeing much discrepancy. The attached 2d smoke test creates a curl attribute from both a DOP GasAnalysisgenerated field, and the SOP solution. The values aren't identical, but are very close. Switch the smoke sim to 3d and the values are still very close.
 icarus551
 Member
 22 posts
 Joined: Dec. 2009
 Offline
Ahh cool, yes its definitely working in your scene. I'll look for why it wasn't working in mine. thanks!
Note: I was using vex gradient() instead of volume analysis sop, I wonder if theres a descrepancy between outputs.
Edit: vex gradient function and volume gradient sop give same result. prolly same code in hdk..
Note: I was using vex gradient() instead of volume analysis sop, I wonder if theres a descrepancy between outputs.
Edit: vex gradient function and volume gradient sop give same result. prolly same code in hdk..

 Quick Links