magneto Posted March 3, 2015 Share Posted March 3, 2015 Hi, I know Volume Analysis SOP does this but is it possible to do it in Volume VOP? If so, anyone can post a simple example of how this could be done? Thanks 1 Quote Link to comment Share on other sites More sharing options...
pbarua Posted March 3, 2015 Share Posted March 3, 2015 Volume Gradient from File VOP. Quote Link to comment Share on other sites More sharing options...
magneto Posted March 3, 2015 Author Share Posted March 3, 2015 Thanks but that calculates the gradient. I need the divergence of a vector field. Quote Link to comment Share on other sites More sharing options...
magneto Posted March 4, 2015 Author Share Posted March 4, 2015 Is it a matter of evaluating 26 neighbours of any given voxel? Just averaging them and getting the length of that vector doesn't work. 1 Quote Link to comment Share on other sites More sharing options...
edward Posted March 5, 2015 Share Posted March 5, 2015 Have you examined the definition of divergence? From wikipedia, it looks like it's just the sum of the vector components of the gradient. 2 Quote Link to comment Share on other sites More sharing options...
magneto Posted March 5, 2015 Author Share Posted March 5, 2015 Thanks Edward, I did. I spent some more time to get it. What I did is to read the 8 neighbours of each voxel on each side of it and then sum x from the neighbours on X, y from the neighbours on Y, z from the neighbours on Z, and sum all of these. The resulting voxel values (using volumeslice) is different than what I get from Volume Analysis SOP, which also looks different than VDB Analysis SOP. If I am doing it wrong, why are laplacian volumes of the same volume also look different between Volume Analysis SOP and VDB Analysis SOP? I am confused. Quote Link to comment Share on other sites More sharing options...
ikarus Posted March 5, 2015 Share Posted March 5, 2015 divergence.hip finite difference divergence, the difference of neighboring voxels, summed over all axes, regularized over the step size of the grid, from a cfd standpoint atleast. good fluids cheat sheethttp://http.developer.nvidia.com/GPUGems/gpugems_ch38.html 6 Quote Link to comment Share on other sites More sharing options...
magneto Posted March 5, 2015 Author Share Posted March 5, 2015 Thanks Raymond. I understand divergence better now. I ended up with a similar solution but I didn't have step size or -0.5 you are using to multiply in the end. What's the reason for multiplying by -0.5 in the end? Also I converted the volume into a VDB and calculated divergence using VDB Analysis and got this (left: your method, right: VDB Analysis): Do you know why the look so different almost inverted? Thanks again, I learnt a lot Quote Link to comment Share on other sites More sharing options...
Skybar Posted March 5, 2015 Share Posted March 5, 2015 Looks the same to me. Edited Raymonds hip a little, just inverted his solution and added VDB control. 100% match. divergence2.hip 3 Quote Link to comment Share on other sites More sharing options...
ikarus Posted March 5, 2015 Share Posted March 5, 2015 (edited) I chopped my file from a fluid sim recreation in sops, but if you look at the formula for divergence you divide your sum of differences by 2*stepsize. I believe this comes from a need to have your final output be independent of your fluid resolution, though I don't know enough about descretizing pde equations to give a solid answer. Edited March 5, 2015 by ikarus 1 Quote Link to comment Share on other sites More sharing options...
magneto Posted March 5, 2015 Author Share Posted March 5, 2015 Thanks alot guys, helped me massively Ok when I divided it like Raymond said no more inversion necessary. Also is there something that needs to be done at the borders? Since the results match, I assume no, but was wondering if there is more to it. Lastly if I get the divergence of the gradient (using volumegradient), I should get the laplacian? I tried this with VDB Analysis by doing it directly from scalar->scalar, vs scalar->vector->scalar and I got different results. I just used float noise output instead of vector to feed into gradient and then divergence. Quote Link to comment Share on other sites More sharing options...
ikarus Posted March 5, 2015 Share Posted March 5, 2015 Have you tried making the laplacian calculation in a vop? 1 Quote Link to comment Share on other sites More sharing options...
magneto Posted March 5, 2015 Author Share Posted March 5, 2015 Thanks ikarus, I basically used your divergence and fed gradient into it. My understanding was instead of vel that you used, if you get the gradient and then feed it into divergence, it will produce laplacian. Is this not correct? Also a simple question: can you calculate step size automatically? I assume it's any_dimension / number_of_voxels in that dimension? Not sure if one can rely on a single dimension to calculate it, but thought if the voxels are square then it should be. Quote Link to comment Share on other sites More sharing options...
ikarus Posted March 6, 2015 Share Posted March 6, 2015 laplacian.hipnc So i built the laplacian op and i get the same result from the sop volume analysis laplacian (slice1 to slice2) Comparing techniques it appears that splitting the divergence and gradient operations results in a loss of high frequency values (comparing slice2 to slice3 in the file) Problem with discretizing these pde formulas is the inherent loss of data from sample rate, so simplifying the algorithm to one step probably reduces data loss from sample rate. just my guess 6 Quote Link to comment Share on other sites More sharing options...
magneto Posted March 6, 2015 Author Share Posted March 6, 2015 Thanks ikarus, I owe you a big one Lastly do you know if one can also auto calculate the step size? I would be better if I didn't have to figure it out manually because sometimes people use Max Axis option so I don't see the Div Size value in the volume itself. Thanks again. Quote Link to comment Share on other sites More sharing options...
Skybar Posted March 6, 2015 Share Posted March 6, 2015 I think there is a primitive intrinsic that has the voxel resolution of the volume, can't check myself right now. Try that! 1 Quote Link to comment Share on other sites More sharing options...
magneto Posted March 6, 2015 Author Share Posted March 6, 2015 Thanks David, I carefully checked and there is only voxel resolution which is available as a vex function too. So to get the step size, one still has to do: any_axis / number_of_voxels_in_the_same_axis Unless I am thinking of it wrong. Thanks again for the help guys. Quote Link to comment Share on other sites More sharing options...
magneto Posted March 10, 2015 Author Share Posted March 10, 2015 Btw guys do you know how to implement curl and curvature? I spent some time trying to break down curl formula but I don't see any commonality with divergence where I could just modify it to calculate curl. Is it vastly more complicated? I was comparing my results with Volume Analysis Curl but they don't match. Thanks again. Quote Link to comment Share on other sites More sharing options...
Skybar Posted March 10, 2015 Share Posted March 10, 2015 Take a look inside Whitewater Source SOP -> SAMPLE_TO_POINTS. It calculates Vorticity there, which is the length of curl. 1 Quote Link to comment Share on other sites More sharing options...
magneto Posted March 10, 2015 Author Share Posted March 10, 2015 Thanks a lot David, it shows it perfectly. I tried it on the same volume we are using and it's exactly the same as VDB's curl. But step size is not considered for curl? Also is there a built-in HDA that show how to calculate curvature? I saw one in the same subnet but it uses Analysis SOPs. Thanks again. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.